[sgen] Make sure we don't sweep a block if we're not supposed to
[mono.git] / mono / utils / mono-memory-model.h
index a97a7cc16b213dcd170ee94ab7032a69450d5aad..fbb87cff574175996469db0a1ac3b10586a4fcef 100644 (file)
@@ -34,18 +34,20 @@ TODO: if we find places where a data depencency could replace barriers, add macr
 TODO: some arch with strong consistency, such as x86, support weaker access. We might need to expose more kinds of barriers once we exploit this.
 */
 
+/*
+ * Keep in sync with the enum in mini/mini-llvm-cpp.h.
+ */
+enum {
+    MONO_MEMORY_BARRIER_NONE = 0,
+    MONO_MEMORY_BARRIER_ACQ = 1,
+    MONO_MEMORY_BARRIER_REL = 2,
+    MONO_MEMORY_BARRIER_SEQ = 3,
+};
+
 #define MEMORY_BARRIER mono_memory_barrier ()
 #define LOAD_BARRIER mono_memory_read_barrier ()
 #define STORE_BARRIER mono_memory_write_barrier ()
 
-enum {
-       StoreStoreBarrier,
-       LoadLoadBarrier,
-       StoreLoadBarrier,
-       LoadStoreBarrier,
-       FullBarrier
-};
-
 #if defined(__i386__) || defined(__x86_64__)
 /*
 Both x86 and amd64 follow the SPO memory model:
@@ -155,17 +157,17 @@ Acquire/release semantics macros.
 #define mono_atomic_load_release(_type,target) ({      \
        _type __tmp;    \
        LOAD_RELEASE_FENCE;     \
-       __tmp = *target;        \
+       __tmp = *(target);      \
        __tmp; })
 
 #define mono_atomic_load_acquire(var,_type,target) do {        \
-       _type __tmp = *target;  \
+       _type __tmp = *(target);        \
        LOAD_ACQUIRE_FENCE;     \
        (var) = __tmp; \
 } while (0)
 
 #define mono_atomic_store_acquire(target,value) {      \
-       *target = value;        \
+       *(target) = (value);    \
        STORE_ACQUIRE_FENCE;    \
        }