summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaan <daanl@outlook.com>2022-04-08 14:10:08 -0700
committerDaan <daanl@outlook.com>2022-04-08 14:10:08 -0700
commit131b62283b6a58971e48c4521399dcb99004187f (patch)
treefd3fee087e61a903a520313fc322e210b3f062fb /include
parent2a4a3dfa23dbddc1bed7e61d567b9ca4d9ffba87 (diff)
parentb7677b6f8482daad8374b2cf5430be2156308063 (diff)
Merge branch 'dev' into dev-slice
Diffstat (limited to 'include')
-rw-r--r--include/mimalloc-atomic.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/mimalloc-atomic.h b/include/mimalloc-atomic.h
index e07df84..7ad5da5 100644
--- a/include/mimalloc-atomic.h
+++ b/include/mimalloc-atomic.h
@@ -23,10 +23,15 @@ terms of the MIT license. A copy of the license can be found in the file
#define _Atomic(tp) std::atomic<tp>
#define mi_atomic(name) std::atomic_##name
#define mi_memory_order(name) std::memory_order_##name
+#if !defined(ATOMIC_VAR_INIT) || (__cplusplus >= 202002L) // c++20, see issue #571
+ #define MI_ATOMIC_VAR_INIT(x) x
+#else
+ #define MI_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x)
+#endif
#elif defined(_MSC_VER)
// Use MSVC C wrapper for C11 atomics
#define _Atomic(tp) tp
-#define ATOMIC_VAR_INIT(x) x
+#define MI_ATOMIC_VAR_INIT(x) x
#define mi_atomic(name) mi_atomic_##name
#define mi_memory_order(name) mi_memory_order_##name
#else
@@ -34,6 +39,7 @@ terms of the MIT license. A copy of the license can be found in the file
#include <stdatomic.h>
#define mi_atomic(name) atomic_##name
#define mi_memory_order(name) memory_order_##name
+#define MI_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x)
#endif
// Various defines for all used memory orders in mimalloc