--- libev/ev.c 2012/05/30 15:45:40 1.441 +++ libev/ev.c 2012/05/31 15:47:59 1.442 @@ -561,7 +561,6 @@ #define ECB_C99 (__STDC_VERSION__ >= 199901L) #define ECB_C11 (__STDC_VERSION__ >= 201112L) #define ECB_CPP (__cplusplus+0) -#define ECB_CPP98 (__cplusplus >= 199711L) #define ECB_CPP11 (__cplusplus >= 201103L) /*****************************************************************************/ @@ -616,10 +615,10 @@ #ifndef ECB_MEMORY_FENCE #if ECB_GCC_VERSION(4,7) - /* see comment below about the C11 memory model. in short - avoid */ + /* see comment below (stdatomic.h) about the C11 memory model. */ #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST) #elif defined __clang && __has_feature (cxx_atomic) - /* see above */ + /* see comment below (stdatomic.h) about the C11 memory model. */ #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST) #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__ #define ECB_MEMORY_FENCE __sync_synchronize () @@ -646,8 +645,12 @@ /* we assume that these memory fences work on all variables/all memory accesses, */ /* not just C11 atomics and atomic accesses */ #include - /* unfortunately, the C11 memory model seems to be very limited, and unable to express */ - /* simple barrier semantics. That means we need to take out thor's hammer. */ + /* Unfortunately, neither gcc 4.7 nor clang 3.1 generate any instructions for */ + /* any fence other than seq_cst, which isn't very efficient for us. */ + /* Why that is, we don't know - either the C11 memory model is quite useless */ + /* for most usages, or gcc and clang have a bug */ + /* I *currently* lean towards the latter, and inefficiently implement */ + /* all three of ecb's fences as a seq_cst fence */ #define ECB_MEMORY_FENCE atomic_thread_fence (memory_order_seq_cst) #endif #endif @@ -3137,7 +3140,7 @@ pipe_write_wanted = 0; /* just an optimisation, no fence needed */ - MEMORY_FENCE_ACQUIRE; + ECB_MEMORY_FENCE_ACQUIRE; if (pipe_write_skipped) { assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));