summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2019-03-07 16:01:55 -0800
committerQi Wang <interwq@gmail.com>2019-03-09 12:52:06 -0800
commitb804d0f019df87d8cc96e3c812e98793256cb418 (patch)
treeaaab4006d73c8f3f4094f34abc746b07404e3559 /include
parent06f0850427e26cb24950de60bbe70bc192ffce6a (diff)
Fallback to 32-bit when 8-bit atomics are missing for TSD.
When it happens, this might cause a slowdown on the fast path operations. However such case is very rare.
Diffstat (limited to 'include')
-rw-r--r--include/jemalloc/internal/tsd.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/include/jemalloc/internal/tsd.h b/include/jemalloc/internal/tsd.h
index 00a9500b..9ba26004 100644
--- a/include/jemalloc/internal/tsd.h
+++ b/include/jemalloc/internal/tsd.h
@@ -169,6 +169,18 @@ enum {
*/
#define TSD_MANGLE(n) cant_access_tsd_items_directly_use_a_getter_or_setter_##n
+#ifdef JEMALLOC_U8_ATOMICS
+# define tsd_state_t atomic_u8_t
+# define tsd_atomic_load atomic_load_u8
+# define tsd_atomic_store atomic_store_u8
+# define tsd_atomic_exchange atomic_exchange_u8
+#else
+# define tsd_state_t atomic_u32_t
+# define tsd_atomic_load atomic_load_u32
+# define tsd_atomic_store atomic_store_u32
+# define tsd_atomic_exchange atomic_exchange_u32
+#endif
+
/* The actual tsd. */
struct tsd_s {
/*
@@ -177,8 +189,11 @@ struct tsd_s {
* setters below.
*/
- /* We manually limit the state to just a single byte. */
- atomic_u8_t state;
+ /*
+ * We manually limit the state to just a single byte. Unless the 8-bit
+ * atomics are unavailable (which is rare).
+ */
+ tsd_state_t state;
#define O(n, t, nt) \
t TSD_MANGLE(n);
MALLOC_TSD