summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-11-01 13:10:02 -0500
committerBen Gamari <ben@smart-cactus.org>2020-11-01 13:10:02 -0500
commit375512cfbb968ed0ffbdf33153b71fab4b707dce (patch)
tree9d89ec90336e9c3bab4fb9272b42f6da72f6846f /includes
parentb8e66e0eecdc58ec5fea0b2c9a9454d38858886c (diff)
parentedb4b92b218cee5b309866f3d236da30c5621567 (diff)
downloadhaskell-375512cfbb968ed0ffbdf33153b71fab4b707dce.tar.gz
Merge branch 'wip/tsan/wsdeque' into wip/tsan/all
Diffstat (limited to 'includes')
-rw-r--r--includes/stg/SMP.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/includes/stg/SMP.h b/includes/stg/SMP.h
index 8eff276e60..389dd95c88 100644
--- a/includes/stg/SMP.h
+++ b/includes/stg/SMP.h
@@ -454,6 +454,14 @@ load_load_barrier(void) {
// Non-atomic addition for "approximate" counters that can be lossy
#define NONATOMIC_ADD(ptr,val) RELAXED_STORE(ptr, RELAXED_LOAD(ptr) + val)
+// Explicit fences
+//
+// These are typically necessary only in very specific cases (e.g. WSDeque)
+// where the ordered operations aren't expressive enough to capture the desired
+// ordering.
+#define RELEASE_FENCE() __atomic_thread_fence(__ATOMIC_RELEASE)
+#define SEQ_CST_FENCE() __atomic_thread_fence(__ATOMIC_SEQ_CST)
+
/* ---------------------------------------------------------------------- */
#else /* !THREADED_RTS */
@@ -481,6 +489,10 @@ EXTERN_INLINE void load_load_barrier () {} /* nothing */
// Non-atomic addition for "approximate" counters that can be lossy
#define NONATOMIC_ADD(ptr,val) *ptr += val
+// Fences
+#define RELEASE_FENCE()
+#define SEQ_CST_FENCE()
+
#if !IN_STG_CODE || IN_STGCRUN
INLINE_HEADER StgWord
xchg(StgPtr p, StgWord w)
@@ -529,6 +541,9 @@ atomic_dec(StgVolatilePtr p)
}
#endif
+/* An alias for the C11 declspec */
+#define ATOMIC
+
#define VOLATILE_LOAD(p) ((StgWord)*((StgWord*)(p)))
#endif /* !THREADED_RTS */