From 39c5e66ed160cca282f097fa974053cef592046c Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 4 Jul 2021 17:24:47 +0300 Subject: [PATCH] mdbx: fix `safe64_reset()` for platforms without atomic 64-bit compare-and-swap. --- src/core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core.c b/src/core.c index bf48169b..c1fadc4e 100644 --- a/src/core.c +++ b/src/core.c @@ -957,16 +957,18 @@ static __always_inline void safe64_reset(MDBX_atomic_uint64_t *p, mo_Relaxed) /* atomically make >= SAFE64_INVALID_THRESHOLD */; atomic_add32(&p->low, 1) /* avoid ABA in safe64_reset_compare() */; } else -#elif MDBX_64BIT_ATOMIC - /* atomically make value >= SAFE64_INVALID_THRESHOLD by 64-bit operation */ - atomic_store64(p, UINT64_MAX, - single_writer ? mo_AcquireRelease : mo_SequentialConsistency); +#endif /* !MDBX_64BIT_CAS */ +#if MDBX_64BIT_ATOMIC + /* atomically make value >= SAFE64_INVALID_THRESHOLD by 64-bit operation */ + atomic_store64(p, UINT64_MAX, + single_writer ? mo_AcquireRelease + : mo_SequentialConsistency); #else /* atomically make value >= SAFE64_INVALID_THRESHOLD by 32-bit operation */ atomic_store32(&p->high, UINT32_MAX, single_writer ? mo_AcquireRelease : mo_SequentialConsistency); #endif /* MDBX_64BIT_ATOMIC */ - assert(p->weak >= SAFE64_INVALID_THRESHOLD); + assert(p->weak >= SAFE64_INVALID_THRESHOLD); mdbx_jitter4testing(true); }