]> rtime.felk.cvut.cz Git - sojka/libev.git/blobdiff - ev.c
*** empty log message ***
[sojka/libev.git] / ev.c
diff --git a/ev.c b/ev.c
index 58ee2101efd14d9e1345d58d9aad7ccb2879672e..c9198ca25633f63326946c9a9bd67de94862ee92 100644 (file)
--- a/ev.c
+++ b/ev.c
@@ -561,7 +561,6 @@ struct signalfd_siginfo
 #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 @@ struct signalfd_siginfo
 
 #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 @@ struct signalfd_siginfo
     /* we assume that these memory fences work on all variables/all memory accesses, */
     /* not just C11 atomics and atomic accesses */
     #include <stdatomic.h>
-    /* 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 @@ ev_run (EV_P_ int flags)
 
         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)));