… | |
… | |
66 | /*****************************************************************************/ |
66 | /*****************************************************************************/ |
67 | |
67 | |
68 | /* ECB_NO_THREADS - ecb is not used by multiple threads, ever */ |
68 | /* ECB_NO_THREADS - ecb is not used by multiple threads, ever */ |
69 | /* ECB_NO_SMP - ecb might be used in multiple threads, but only on a single cpu */ |
69 | /* ECB_NO_SMP - ecb might be used in multiple threads, but only on a single cpu */ |
70 | |
70 | |
|
|
71 | #if ECB_NO_THREADS |
|
|
72 | # define ECB_NO_SMP 1 |
|
|
73 | #endif |
|
|
74 | |
71 | #if ECB_NO_THREADS || ECB_NO_SMP |
75 | #if ECB_NO_THREADS || ECB_NO_SMP |
72 | #define ECB_MEMORY_FENCE do { } while (0) |
76 | #define ECB_MEMORY_FENCE do { } while (0) |
73 | #endif |
77 | #endif |
74 | |
78 | |
75 | #ifndef ECB_MEMORY_FENCE |
79 | #ifndef ECB_MEMORY_FENCE |
76 | #if ECB_GCC_VERSION(2,5) || defined(__INTEL_COMPILER) || defined(__clang__) || __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 |
80 | #if ECB_GCC_VERSION(2,5) || defined(__INTEL_COMPILER) || (__llvm__ && __GNUC__) || __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 |
77 | #if __i386 || __i386__ |
81 | #if __i386 || __i386__ |
78 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory") |
82 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory") |
79 | #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE /* non-lock xchg might be enough */ |
83 | #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE /* non-lock xchg might be enough */ |
80 | #define ECB_MEMORY_FENCE_RELEASE do { } while (0) /* unlikely to change in future cpus */ |
84 | #define ECB_MEMORY_FENCE_RELEASE do { } while (0) /* unlikely to change in future cpus */ |
81 | #elif __amd64 || __amd64__ || __x86_64 || __x86_64__ |
85 | #elif __amd64 || __amd64__ || __x86_64 || __x86_64__ |
… | |
… | |
90 | #elif defined(__ARM_ARCH_7__ ) || defined(__ARM_ARCH_7A__ ) \ |
94 | #elif defined(__ARM_ARCH_7__ ) || defined(__ARM_ARCH_7A__ ) \ |
91 | || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7R__ ) |
95 | || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7R__ ) |
92 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb" : : : "memory") |
96 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb" : : : "memory") |
93 | #elif __sparc || __sparc__ |
97 | #elif __sparc || __sparc__ |
94 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad | " : : : "memory") |
98 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad | " : : : "memory") |
95 | #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory") |
99 | #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory") |
96 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore") |
100 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore") |
|
|
101 | #elif defined(__s390__) || defined(__s390x__) |
|
|
102 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("bcr 15,0" : : : "memory") |
|
|
103 | #elif defined(__mips__) |
|
|
104 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory") |
97 | #endif |
105 | #endif |
98 | #endif |
106 | #endif |
99 | #endif |
107 | #endif |
100 | |
108 | |
101 | #ifndef ECB_MEMORY_FENCE |
109 | #ifndef ECB_MEMORY_FENCE |
… | |
… | |
114 | #elif __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 |
122 | #elif __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 |
115 | #include <mbarrier.h> |
123 | #include <mbarrier.h> |
116 | #define ECB_MEMORY_FENCE __machine_rw_barrier () |
124 | #define ECB_MEMORY_FENCE __machine_rw_barrier () |
117 | #define ECB_MEMORY_FENCE_ACQUIRE __machine_r_barrier () |
125 | #define ECB_MEMORY_FENCE_ACQUIRE __machine_r_barrier () |
118 | #define ECB_MEMORY_FENCE_RELEASE __machine_w_barrier () |
126 | #define ECB_MEMORY_FENCE_RELEASE __machine_w_barrier () |
|
|
127 | #elif __xlC__ |
|
|
128 | #define ECB_MEMORY_FENCE __lwsync () |
119 | #endif |
129 | #endif |
120 | #endif |
130 | #endif |
121 | |
131 | |
122 | #ifndef ECB_MEMORY_FENCE |
132 | #ifndef ECB_MEMORY_FENCE |
123 | #if !ECB_AVOID_PTHREADS |
133 | #if !ECB_AVOID_PTHREADS |