diff --git a/ChangeLog.md b/ChangeLog.md index 935254c3..ca3989ba 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,8 @@ ChangeLog Fixes: - Fixed builds with older libc versions after using `fcntl64()` (backport). + - Fixed builds with older `stdatomic.h` versions, + where the `ATOMIC_*_LOCK_FREE` macros mistakenly redefined using functions (backport). ## v0.11.12 (Эребуни) at 2022-10-12 diff --git a/src/core.c b/src/core.c index 438116d4..86f6bc62 100644 --- a/src/core.c +++ b/src/core.c @@ -983,14 +983,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); @@ -1009,14 +1002,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); @@ -1035,14 +1021,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 9ae76dc7..27c3c55d 100644 --- a/src/options.h +++ b/src/options.h @@ -326,13 +326,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 @@ -344,6 +338,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