Drop use of def files for x86, x64 mono-2.0-sgen|boehm.dll Windows build.
[mono.git] / mono / utils / mono-memory-model.h
index a97a7cc16b213dcd170ee94ab7032a69450d5aad..ce0130793a24257f765638140f12f86c084664d5 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * mono-memory-model.h: Mapping of the arch memory model.
+/**
+ * \file
+ * Mapping of the arch memory model.
  *
  * Author:
  *     Rodrigo Kumpera (kumpera@gmail.com)
@@ -34,18 +35,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 +158,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;    \
        }