From 6c986ce904d5d1a8ccf636fb49800a90021cdd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Thu, 13 Oct 2022 17:36:53 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=BA=D0=BE=D1=81=D1=82=D1=8B=D0=BB?= =?UTF-8?q?=D1=8C=20=D0=B4=D0=BB=D1=8F=20=D1=81=D1=82=D0=B0=D1=80=D1=8B?= =?UTF-8?q?=D1=85=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B9=20`stdatomic.h`,?= =?UTF-8?q?=20=D0=B3=D0=B4=D0=B5=20=D0=BC=D0=B0=D0=BA=D1=80=D0=BE=D1=81?= =?UTF-8?q?=D1=8B=20`ATOMIC=5F*=5FLOCK=5FFREE`=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BE=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D1=8F=D1=8E=D1=82=D1=81=D1=8F=20?= =?UTF-8?q?=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core.c | 21 --------------------- src/options.h | 14 +++++++------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/core.c b/src/core.c index a47a9c08..3e7ebd23 100644 --- a/src/core.c +++ b/src/core.c @@ -934,14 +934,7 @@ static __always_inline bool atomic_cas64(MDBX_atomic_uint64_t *p, uint64_t c, uint64_t v) { #ifdef MDBX_HAVE_C11ATOMICS STATIC_ASSERT(sizeof(long long) >= sizeof(uint64_t)); -#ifdef ATOMIC_LLONG_LOCK_FREE - STATIC_ASSERT(ATOMIC_LLONG_LOCK_FREE > 0); -#if ATOMIC_LLONG_LOCK_FREE < 2 assert(atomic_is_lock_free(MDBX_c11a_rw(uint64_t, p))); -#endif /* ATOMIC_LLONG_LOCK_FREE < 2 */ -#else /* defined(ATOMIC_LLONG_LOCK_FREE) */ - assert(atomic_is_lock_free(MDBX_c11a_rw(uint64_t, p))); -#endif return atomic_compare_exchange_strong(MDBX_c11a_rw(uint64_t, p), &c, v); #elif defined(__GNUC__) || defined(__clang__) return __sync_bool_compare_and_swap(&p->weak, c, v); @@ -960,14 +953,7 @@ static __always_inline bool atomic_cas32(MDBX_atomic_uint32_t *p, uint32_t c, uint32_t v) { #ifdef MDBX_HAVE_C11ATOMICS STATIC_ASSERT(sizeof(int) >= sizeof(uint32_t)); -#ifdef ATOMIC_INT_LOCK_FREE - STATIC_ASSERT(ATOMIC_INT_LOCK_FREE > 0); -#if ATOMIC_INT_LOCK_FREE < 2 assert(atomic_is_lock_free(MDBX_c11a_rw(uint32_t, p))); -#endif -#else - assert(atomic_is_lock_free(MDBX_c11a_rw(uint32_t, p))); -#endif return atomic_compare_exchange_strong(MDBX_c11a_rw(uint32_t, p), &c, v); #elif defined(__GNUC__) || defined(__clang__) return __sync_bool_compare_and_swap(&p->weak, c, v); @@ -986,14 +972,7 @@ static __always_inline uint32_t atomic_add32(MDBX_atomic_uint32_t *p, uint32_t v) { #ifdef MDBX_HAVE_C11ATOMICS STATIC_ASSERT(sizeof(int) >= sizeof(uint32_t)); -#ifdef ATOMIC_INT_LOCK_FREE - STATIC_ASSERT(ATOMIC_INT_LOCK_FREE > 0); -#if ATOMIC_INT_LOCK_FREE < 2 assert(atomic_is_lock_free(MDBX_c11a_rw(uint32_t, p))); -#endif -#else - assert(atomic_is_lock_free(MDBX_c11a_rw(uint32_t, p))); -#endif return atomic_fetch_add(MDBX_c11a_rw(uint32_t, p), v); #elif defined(__GNUC__) || defined(__clang__) return __sync_fetch_and_add(&p->weak, v); diff --git a/src/options.h b/src/options.h index 762bd2eb..127a13be 100644 --- a/src/options.h +++ b/src/options.h @@ -358,13 +358,7 @@ #endif /* MDBX_64BIT_ATOMIC */ #ifndef MDBX_64BIT_CAS -#if defined(ATOMIC_LLONG_LOCK_FREE) -#if ATOMIC_LLONG_LOCK_FREE > 1 -#define MDBX_64BIT_CAS 1 -#else -#define MDBX_64BIT_CAS 0 -#endif -#elif defined(__GCC_ATOMIC_LLONG_LOCK_FREE) +#if defined(__GCC_ATOMIC_LLONG_LOCK_FREE) #if __GCC_ATOMIC_LLONG_LOCK_FREE > 1 #define MDBX_64BIT_CAS 1 #else @@ -376,6 +370,12 @@ #else #define MDBX_64BIT_CAS 0 #endif +#elif defined(ATOMIC_LLONG_LOCK_FREE) +#if ATOMIC_LLONG_LOCK_FREE > 1 +#define MDBX_64BIT_CAS 1 +#else +#define MDBX_64BIT_CAS 0 +#endif #elif defined(_MSC_VER) || defined(__APPLE__) || defined(DOXYGEN) #define MDBX_64BIT_CAS 1 #else