[pypy-commit] stmgc c7: Use __sync_synchronize() as a general fall-back. Update comments.

arigo noreply at buildbot.pypy.org
Fri Feb 7 20:24:41 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: c7
Changeset: r710:f59e497a6ec5
Date: 2014-02-07 20:24 +0100
http://bitbucket.org/pypy/stmgc/changeset/f59e497a6ec5/

Log:	Use __sync_synchronize() as a general fall-back. Update comments.

diff --git a/c7/core.h b/c7/core.h
--- a/c7/core.h
+++ b/c7/core.h
@@ -199,14 +199,18 @@
 
 static inline void write_fence(void)
 {
+    /* This function inserts a "write fence".  The goal is to make
+       sure that past writes are really pushed to memory before
+       the future writes.  We assume that the corresponding "read
+       fence" effect is done automatically by a corresponding
+       __sync_bool_compare_and_swap(). */
 #if defined(__amd64__) || defined(__i386__)
-    /* this is only a compiler barrier
-       use __sync_synchronize(...) or other __sync_OPs that
-       are locked by the CPU if you need to prevent
-       loads to be moved before stores to different locations */
+    /* this is only a compiler barrier, which is enough on x86 */
     asm("" : : : "memory");
 #else
-#  error "Define write_fence() for your architecture"
+    /* general fall-back, but we might have more efficient
+       alternative on some other platforms too */
+    __sync_synchronize();
 #endif
 }
 


More information about the pypy-commit mailing list