libecb memory fence on s390 and s390x

Alexey Borzenkov snaury at gmail.com
Fri Jan 27 23:06:23 CET 2012


Hi Marc,

I recently fixed support for s390 and s390x in greenlet, which was
needed for the latest version of gevent. However, after we greenlet
finally worked, latest gevent (which uses libev) couldn't be
installed, because there's no support for memory fence in libecb. I
just looked into gcc sources and it defines memory_barrier for s390 as
"bcr\t15,0" (conditional branch on all conditions that is used for
synchronization, see
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr002/7.5.12?DT=20030424140649),
which seems to make sense. Could you please add it to libecb and libev
too? Here's the patch:

--- ecb.h.orig	2012-01-28 01:53:08.000000000 +0400
+++ ecb.h	2012-01-28 01:54:13.000000000 +0400
@@ -94,6 +94,8 @@
       #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("membar
#LoadStore | #LoadLoad | #StoreStore | #StoreLoad | " : : : "memory")
       #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar
#LoadStore | #LoadLoad" : : : "memory")
       #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar
#LoadStore |             #StoreStore")
+    #elif defined(__s390__) || defined(__s390x__)
+      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("bcr 15,
0", : : : "memory")
     #endif
   #endif
 #endif

Haven't asked that person to test it yet, but given the docs and the
use by gcc it should be straight forward.

Thanks,
Alexey.



More information about the libev mailing list