… | |
… | |
29 | |
29 | |
30 | #ifndef ECB_H |
30 | #ifndef ECB_H |
31 | #define ECB_H |
31 | #define ECB_H |
32 | |
32 | |
33 | /* 16 bits major, 16 bits minor */ |
33 | /* 16 bits major, 16 bits minor */ |
34 | #define ECB_VERSION 0x00010001 |
34 | #define ECB_VERSION 0x00010002 |
35 | |
35 | |
36 | #ifdef _WIN32 |
36 | #ifdef _WIN32 |
37 | typedef signed char int8_t; |
37 | typedef signed char int8_t; |
38 | typedef unsigned char uint8_t; |
38 | typedef unsigned char uint8_t; |
39 | typedef signed short int16_t; |
39 | typedef signed short int16_t; |
… | |
… | |
148 | |
148 | |
149 | #ifndef ECB_MEMORY_FENCE |
149 | #ifndef ECB_MEMORY_FENCE |
150 | #if ECB_GCC_VERSION(4,7) |
150 | #if ECB_GCC_VERSION(4,7) |
151 | /* see comment below (stdatomic.h) about the C11 memory model. */ |
151 | /* see comment below (stdatomic.h) about the C11 memory model. */ |
152 | #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST) |
152 | #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST) |
|
|
153 | |
|
|
154 | /* The __has_feature syntax from clang is so misdesigned that we cannot use it |
|
|
155 | * without risking compile time errors with other compilers. We *could* |
|
|
156 | * define our own ecb_clang_has_feature, but I just can't be bothered to work |
|
|
157 | * around * this shit time and again. |
153 | /*#elif defined __clang && __has_feature (cxx_atomic)*/ |
158 | * #elif defined __clang && __has_feature (cxx_atomic) |
154 | /* see comment below (stdatomic.h) about the C11 memory model. */ |
159 | * // see comment below (stdatomic.h) about the C11 memory model. |
155 | /*#define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST)*/ |
160 | * #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST) |
|
|
161 | */ |
|
|
162 | |
156 | #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__ |
163 | #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__ |
157 | #define ECB_MEMORY_FENCE __sync_synchronize () |
164 | #define ECB_MEMORY_FENCE __sync_synchronize () |
158 | #elif _MSC_VER >= 1400 /* VC++ 2005 */ |
165 | #elif _MSC_VER >= 1400 /* VC++ 2005 */ |
159 | #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier) |
166 | #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier) |
160 | #define ECB_MEMORY_FENCE _ReadWriteBarrier () |
167 | #define ECB_MEMORY_FENCE _ReadWriteBarrier () |