mirror of
https://github.com/isar/libmdbx.git
synced 2025-03-03 16:58:14 +08:00
mdbx: add public MDBX_MAYBE_UNUSED
.
This also should fix C++ mdbx API build by MSVC 2015.
This commit is contained in:
parent
ed58ff9f81
commit
ebab75642e
8
mdbx.h
8
mdbx.h
@ -454,6 +454,14 @@ typedef mode_t mdbx_mode_t;
|
||||
#endif
|
||||
#endif /* MDBX_PRINTF_ARGS */
|
||||
|
||||
#if defined(DOXYGEN) || __has_cpp_attribute(maybe_unused)
|
||||
#define MDBX_MAYBE_UNUSED [[maybe_unused]]
|
||||
#elif defined(__GNUC__) || __has_attribute(__unused__)
|
||||
#define MDBX_MAYBE_UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
#define MDBX_MAYBE_UNUSED
|
||||
#endif /* MDBX_MAYBE_UNUSED */
|
||||
|
||||
/* Oh, below are some songs and dances since:
|
||||
* - C++ requires explicit definition of the necessary operators.
|
||||
* - the proper implementation of DEFINE_ENUM_FLAG_OPERATORS for C++ required
|
||||
|
22
src/core.c
22
src/core.c
@ -103,7 +103,7 @@ MDBX_NOTHROW_CONST_FUNCTION static uint16_t pages2pv(size_t pages) {
|
||||
/*------------------------------------------------------------------------------
|
||||
* Unaligned access */
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION static __maybe_unused __always_inline unsigned
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_CONST_FUNCTION static __always_inline unsigned
|
||||
field_alignment(unsigned alignment_baseline, size_t field_offset) {
|
||||
unsigned merge = alignment_baseline | (unsigned)field_offset;
|
||||
return merge & -(int)merge;
|
||||
@ -618,7 +618,7 @@ page_used(const MDBX_env *env, const MDBX_page *mp) {
|
||||
}
|
||||
|
||||
/* The percentage of space used in the page, in a percents. */
|
||||
MDBX_NOTHROW_PURE_FUNCTION static __maybe_unused __inline double
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_PURE_FUNCTION static __inline double
|
||||
page_fill(const MDBX_env *env, const MDBX_page *mp) {
|
||||
return page_used(env, mp) * 100.0 / page_space(env);
|
||||
}
|
||||
@ -1024,7 +1024,7 @@ static __always_inline uint64_t safe64_read(const MDBX_atomic_uint64_t *p) {
|
||||
}
|
||||
|
||||
#if 0 /* unused for now */
|
||||
static __maybe_unused __always_inline bool safe64_is_valid(uint64_t v) {
|
||||
MDBX_MAYBE_UNUSED static __always_inline bool safe64_is_valid(uint64_t v) {
|
||||
#if MDBX_WORDBITS >= 64
|
||||
return v < SAFE64_INVALID_THRESHOLD;
|
||||
#else
|
||||
@ -1032,7 +1032,7 @@ static __always_inline uint64_t safe64_read(const MDBX_atomic_uint64_t *p) {
|
||||
#endif /* MDBX_WORDBITS */
|
||||
}
|
||||
|
||||
static __maybe_unused __always_inline bool
|
||||
MDBX_MAYBE_UNUSED static __always_inline bool
|
||||
safe64_is_valid_ptr(const MDBX_atomic_uint64_t *p) {
|
||||
#if MDBX_64BIT_ATOMIC
|
||||
return atomic_load64(p, mo_AcquireRelease) < SAFE64_INVALID_THRESHOLD;
|
||||
@ -1054,7 +1054,7 @@ static __always_inline void safe64_update(MDBX_atomic_uint64_t *p,
|
||||
}
|
||||
|
||||
/* non-atomic increment with safety for reading a half-updated value */
|
||||
static __maybe_unused
|
||||
MDBX_MAYBE_UNUSED static
|
||||
#if MDBX_64BIT_ATOMIC
|
||||
__always_inline
|
||||
#endif /* MDBX_64BIT_ATOMIC */
|
||||
@ -3452,8 +3452,8 @@ static __always_inline unsigned mdbx_dpl_exist(MDBX_txn *txn, pgno_t pgno) {
|
||||
return (dl->items[i].pgno == pgno) ? i : 0;
|
||||
}
|
||||
|
||||
static __maybe_unused const MDBX_page *debug_dpl_find(const MDBX_txn *txn,
|
||||
const pgno_t pgno) {
|
||||
MDBX_MAYBE_UNUSED static const MDBX_page *debug_dpl_find(const MDBX_txn *txn,
|
||||
const pgno_t pgno) {
|
||||
const MDBX_dpl *dl = txn->tw.dirtylist;
|
||||
assert(dl->items[0].pgno == 0 && dl->items[dl->length + 1].pgno == P_INVALID);
|
||||
for (unsigned i = dl->length; i > dl->sorted; --i)
|
||||
@ -3963,7 +3963,7 @@ static const char *mdbx_leafnode_type(MDBX_node *n) {
|
||||
}
|
||||
|
||||
/* Display all the keys in the page. */
|
||||
static __maybe_unused void mdbx_page_list(MDBX_page *mp) {
|
||||
MDBX_MAYBE_UNUSED static void mdbx_page_list(MDBX_page *mp) {
|
||||
pgno_t pgno = mp->mp_pgno;
|
||||
const char *type;
|
||||
MDBX_node *node;
|
||||
@ -4053,7 +4053,7 @@ static __maybe_unused void mdbx_page_list(MDBX_page *mp) {
|
||||
(mc)->mc_xcursor->mx_cursor.mc_pg[0] = node_data(xr_node); \
|
||||
} while (0)
|
||||
|
||||
static __maybe_unused bool cursor_is_tracked(const MDBX_cursor *mc) {
|
||||
MDBX_MAYBE_UNUSED static bool cursor_is_tracked(const MDBX_cursor *mc) {
|
||||
for (MDBX_cursor *scan = mc->mc_txn->tw.cursors[mc->mc_dbi]; scan;
|
||||
scan = scan->mc_next)
|
||||
if (mc == ((mc->mc_flags & C_SUB) ? &scan->mc_xcursor->mx_cursor : scan))
|
||||
@ -4180,7 +4180,7 @@ static __always_inline MDBX_db *mdbx_outer_db(MDBX_cursor *mc) {
|
||||
return couple->outer.mc_db;
|
||||
}
|
||||
|
||||
static __cold __maybe_unused bool mdbx_dirtylist_check(MDBX_txn *txn) {
|
||||
MDBX_MAYBE_UNUSED __cold static bool mdbx_dirtylist_check(MDBX_txn *txn) {
|
||||
const MDBX_dpl *const dl = txn->tw.dirtylist;
|
||||
assert(dl->items[0].pgno == 0 && dl->items[dl->length + 1].pgno == P_INVALID);
|
||||
mdbx_tassert(txn, txn->tw.dirtyroom + dl->length ==
|
||||
@ -5742,7 +5742,7 @@ static int __must_check_result mdbx_page_dirty(MDBX_txn *txn, MDBX_page *mp,
|
||||
}
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN64))
|
||||
static __always_inline __maybe_unused int ignore_enosys(int err) {
|
||||
MDBX_MAYBE_UNUSED static __always_inline int ignore_enosys(int err) {
|
||||
#ifdef ENOSYS
|
||||
if (err == ENOSYS)
|
||||
return MDBX_RESULT_TRUE;
|
||||
|
10
src/defs.h
10
src/defs.h
@ -103,14 +103,6 @@
|
||||
# endif
|
||||
#endif /* __must_check_result */
|
||||
|
||||
#ifndef __maybe_unused
|
||||
# if defined(__GNUC__) || __has_attribute(__unused__)
|
||||
# define __maybe_unused __attribute__((__unused__))
|
||||
# else
|
||||
# define __maybe_unused
|
||||
# endif
|
||||
#endif /* __maybe_unused */
|
||||
|
||||
#if !defined(__noop) && !defined(_MSC_VER)
|
||||
# define __noop(...) do {} while(0)
|
||||
#endif /* __noop */
|
||||
@ -256,7 +248,7 @@
|
||||
#endif /* __anonymous_struct_extension__ */
|
||||
|
||||
#ifndef __Wpedantic_format_voidptr
|
||||
static __inline __maybe_unused const void* MDBX_PURE_FUNCTION
|
||||
MDBX_MAYBE_UNUSED MDBX_PURE_FUNCTION static __inline const void*
|
||||
__Wpedantic_format_voidptr(const void* ptr) {return ptr;}
|
||||
# define __Wpedantic_format_voidptr(ARG) __Wpedantic_format_voidptr(ARG)
|
||||
#endif /* __Wpedantic_format_voidptr */
|
||||
|
@ -266,7 +266,7 @@ static __always_inline memory_order mo_c11_load(enum MDBX_memory_order fence) {
|
||||
|
||||
static __inline void mdbx_jitter4testing(bool tiny);
|
||||
|
||||
static __maybe_unused __always_inline void
|
||||
MDBX_MAYBE_UNUSED static __always_inline void
|
||||
mdbx_memory_fence(enum MDBX_memory_order order, bool write) {
|
||||
#ifdef MDBX_HAVE_C11ATOMICS
|
||||
atomic_thread_fence(write ? mo_c11_store(order) : mo_c11_load(order));
|
||||
@ -278,7 +278,7 @@ mdbx_memory_fence(enum MDBX_memory_order order, bool write) {
|
||||
#endif /* MDBX_HAVE_C11ATOMICS */
|
||||
}
|
||||
|
||||
static __maybe_unused __always_inline uint32_t
|
||||
MDBX_MAYBE_UNUSED static __always_inline uint32_t
|
||||
atomic_store32(MDBX_atomic_uint32_t *p, const uint32_t value,
|
||||
enum MDBX_memory_order order) {
|
||||
STATIC_ASSERT(sizeof(MDBX_atomic_uint32_t) == 4);
|
||||
@ -294,7 +294,7 @@ atomic_store32(MDBX_atomic_uint32_t *p, const uint32_t value,
|
||||
return value;
|
||||
}
|
||||
|
||||
static __maybe_unused __always_inline uint32_t
|
||||
MDBX_MAYBE_UNUSED static __always_inline uint32_t
|
||||
atomic_load32(const MDBX_atomic_uint32_t *p, enum MDBX_memory_order order) {
|
||||
STATIC_ASSERT(sizeof(MDBX_atomic_uint32_t) == 4);
|
||||
#ifdef MDBX_HAVE_C11ATOMICS
|
||||
@ -309,7 +309,7 @@ atomic_load32(const MDBX_atomic_uint32_t *p, enum MDBX_memory_order order) {
|
||||
#endif /* MDBX_HAVE_C11ATOMICS */
|
||||
}
|
||||
|
||||
static __maybe_unused __always_inline uint64_t
|
||||
MDBX_MAYBE_UNUSED static __always_inline uint64_t
|
||||
atomic_store64(MDBX_atomic_uint64_t *p, const uint64_t value,
|
||||
enum MDBX_memory_order order) {
|
||||
STATIC_ASSERT(sizeof(MDBX_atomic_uint64_t) == 8);
|
||||
@ -333,7 +333,7 @@ atomic_store64(MDBX_atomic_uint64_t *p, const uint64_t value,
|
||||
return value;
|
||||
}
|
||||
|
||||
static __maybe_unused
|
||||
MDBX_MAYBE_UNUSED static
|
||||
#if MDBX_64BIT_ATOMIC
|
||||
__always_inline
|
||||
#endif /* MDBX_64BIT_ATOMIC */
|
||||
@ -1380,7 +1380,7 @@ void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func,
|
||||
#define mdbx_flush_incoherent_cpu_writeback() mdbx_compiler_barrier()
|
||||
#endif /* MDBX_CPU_WRITEBACK_INCOHERENT */
|
||||
|
||||
static __maybe_unused __inline void
|
||||
MDBX_MAYBE_UNUSED static __inline void
|
||||
mdbx_flush_incoherent_mmap(void *addr, size_t nbytes, const intptr_t pagesize) {
|
||||
#if MDBX_MMAP_INCOHERENT_FILE_WRITE
|
||||
char *const begin = (char *)(-pagesize & (intptr_t)addr);
|
||||
@ -1422,7 +1422,7 @@ MDBX_INTERNAL_FUNC void mdbx_rthc_global_init(void);
|
||||
MDBX_INTERNAL_FUNC void mdbx_rthc_global_dtor(void);
|
||||
MDBX_INTERNAL_FUNC void mdbx_rthc_thread_dtor(void *ptr);
|
||||
|
||||
static __maybe_unused __inline void mdbx_jitter4testing(bool tiny) {
|
||||
MDBX_MAYBE_UNUSED static __inline void mdbx_jitter4testing(bool tiny) {
|
||||
#if MDBX_DEBUG
|
||||
if (MDBX_DBG_JITTER & mdbx_runtime_flags)
|
||||
mdbx_osal_jitter(tiny);
|
||||
@ -1575,35 +1575,35 @@ typedef struct MDBX_node {
|
||||
/* Do not spill pages to disk if txn is getting full, may fail instead */
|
||||
#define MDBX_NOSPILL 0x8000
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION static __maybe_unused __inline pgno_t
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_CONST_FUNCTION static __inline pgno_t
|
||||
pgno_add(pgno_t base, pgno_t augend) {
|
||||
assert(base <= MAX_PAGENO);
|
||||
return (augend < MAX_PAGENO - base) ? base + augend : MAX_PAGENO;
|
||||
}
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION static __maybe_unused __inline pgno_t
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_CONST_FUNCTION static __inline pgno_t
|
||||
pgno_sub(pgno_t base, pgno_t subtrahend) {
|
||||
assert(base >= MIN_PAGENO);
|
||||
return (subtrahend < base - MIN_PAGENO) ? base - subtrahend : MIN_PAGENO;
|
||||
}
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION static __always_inline __maybe_unused bool
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_CONST_FUNCTION static __always_inline bool
|
||||
is_powerof2(size_t x) {
|
||||
return (x & (x - 1)) == 0;
|
||||
}
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION static __always_inline __maybe_unused size_t
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_CONST_FUNCTION static __always_inline size_t
|
||||
floor_powerof2(size_t value, size_t granularity) {
|
||||
assert(is_powerof2(granularity));
|
||||
return value & ~(granularity - 1);
|
||||
}
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION static __always_inline __maybe_unused size_t
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_CONST_FUNCTION static __always_inline size_t
|
||||
ceil_powerof2(size_t value, size_t granularity) {
|
||||
return floor_powerof2(value + granularity - 1, granularity);
|
||||
}
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION static __maybe_unused unsigned
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_CONST_FUNCTION static unsigned
|
||||
log2n_powerof2(size_t value) {
|
||||
assert(value > 0 && value < INT32_MAX && is_powerof2(value));
|
||||
assert((value & -(int32_t)value) == value);
|
||||
@ -1633,7 +1633,7 @@ log2n_powerof2(size_t value) {
|
||||
#define ENV_USABLE_FLAGS (ENV_CHANGEABLE_FLAGS | ENV_CHANGELESS_FLAGS)
|
||||
|
||||
#if !defined(__cplusplus) || CONSTEXPR_ENUM_FLAGS_OPERATIONS
|
||||
static __maybe_unused void static_checks(void) {
|
||||
MDBX_MAYBE_UNUSED static void static_checks(void) {
|
||||
STATIC_ASSERT_MSG(INT16_MAX - CORE_DBS == MDBX_MAX_DBI,
|
||||
"Oops, MDBX_MAX_DBI or CORE_DBS?");
|
||||
STATIC_ASSERT_MSG((unsigned)(MDBX_DB_ACCEDE | MDBX_CREATE) ==
|
||||
|
@ -204,7 +204,8 @@ template <typename PATH> struct path_to_pchar {
|
||||
operator const char *() const { return str.c_str(); }
|
||||
};
|
||||
|
||||
template <typename PATH>[[maybe_unused]] PATH pchar_to_path(const char *c_str) {
|
||||
template <typename PATH>
|
||||
MDBX_MAYBE_UNUSED PATH pchar_to_path(const char *c_str) {
|
||||
return PATH(c_str);
|
||||
}
|
||||
|
||||
@ -242,7 +243,7 @@ template <> struct path_to_pchar<std::wstring> {
|
||||
};
|
||||
|
||||
template <>
|
||||
[[maybe_unused]] std::wstring pchar_to_path<std::wstring>(const char *c_str) {
|
||||
MDBX_MAYBE_UNUSED std::wstring pchar_to_path<std::wstring>(const char *c_str) {
|
||||
std::wstring wstr;
|
||||
if (c_str && *c_str) {
|
||||
const int chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, c_str,
|
||||
|
@ -2057,8 +2057,8 @@ static LSTATUS mdbx_RegGetValue(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpValue,
|
||||
}
|
||||
#endif
|
||||
|
||||
static __cold __maybe_unused bool bootid_parse_uuid(bin128_t *s, const void *p,
|
||||
const size_t n) {
|
||||
MDBX_MAYBE_UNUSED static __cold bool
|
||||
bootid_parse_uuid(bin128_t *s, const void *p, const size_t n) {
|
||||
if (n > 31) {
|
||||
unsigned bits = 0;
|
||||
for (unsigned i = 0; i < n; ++i) /* try parse an UUID in text form */ {
|
||||
@ -2413,7 +2413,7 @@ __cold int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages,
|
||||
if (unlikely(pagesize < MIN_PAGESIZE || !is_powerof2(pagesize)))
|
||||
return MDBX_INCOMPATIBLE;
|
||||
|
||||
__maybe_unused const int log2page = log2n_powerof2(pagesize);
|
||||
MDBX_MAYBE_UNUSED const int log2page = log2n_powerof2(pagesize);
|
||||
assert(pagesize == (INT64_C(1) << log2page));
|
||||
(void)log2page;
|
||||
|
||||
|
18
src/osal.h
18
src/osal.h
@ -440,7 +440,7 @@ typedef pthread_mutex_t mdbx_fastmutex_t;
|
||||
/* Get the size of a memory page for the system.
|
||||
* This is the basic size that the platform's memory manager uses, and is
|
||||
* fundamental to the use of memory-mapped files. */
|
||||
MDBX_NOTHROW_CONST_FUNCTION static __maybe_unused __inline size_t
|
||||
MDBX_MAYBE_UNUSED MDBX_NOTHROW_CONST_FUNCTION static __inline size_t
|
||||
mdbx_syspagesize(void) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
SYSTEM_INFO si;
|
||||
@ -527,7 +527,7 @@ extern void mdbx_osal_jitter(bool tiny);
|
||||
#include <sys/cachectl.h>
|
||||
#endif
|
||||
|
||||
static __maybe_unused __inline void mdbx_compiler_barrier(void) {
|
||||
MDBX_MAYBE_UNUSED static __inline void mdbx_compiler_barrier(void) {
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
__asm__ __volatile__("" ::: "memory");
|
||||
#elif defined(_MSC_VER)
|
||||
@ -547,7 +547,7 @@ static __maybe_unused __inline void mdbx_compiler_barrier(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static __maybe_unused __inline void mdbx_memory_barrier(void) {
|
||||
MDBX_MAYBE_UNUSED static __inline void mdbx_memory_barrier(void) {
|
||||
#ifdef MDBX_HAVE_C11ATOMICS
|
||||
atomic_thread_fence(memory_order_seq_cst);
|
||||
#elif defined(__ATOMIC_SEQ_CST)
|
||||
@ -587,8 +587,8 @@ static __maybe_unused __inline void mdbx_memory_barrier(void) {
|
||||
#define mdbx_asprintf asprintf
|
||||
#define mdbx_vasprintf vasprintf
|
||||
#else
|
||||
MDBX_INTERNAL_FUNC MDBX_PRINTF_ARGS(2, 3) int __maybe_unused
|
||||
mdbx_asprintf(char **strp, const char *fmt, ...);
|
||||
MDBX_MAYBE_UNUSED MDBX_INTERNAL_FUNC
|
||||
MDBX_PRINTF_ARGS(2, 3) int mdbx_asprintf(char **strp, const char *fmt, ...);
|
||||
MDBX_INTERNAL_FUNC int mdbx_vasprintf(char **strp, const char *fmt, va_list ap);
|
||||
#endif
|
||||
|
||||
@ -611,7 +611,7 @@ MDBX_INTERNAL_VAR bool mdbx_RunningOnWSL1 /* Windows Subsystem 1 for Linux */;
|
||||
LIBMDBX_API char *mdbx_strdup(const char *str);
|
||||
#endif
|
||||
|
||||
static __maybe_unused __inline int mdbx_get_errno(void) {
|
||||
MDBX_MAYBE_UNUSED static __inline int mdbx_get_errno(void) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
DWORD rc = GetLastError();
|
||||
#else
|
||||
@ -713,7 +713,7 @@ MDBX_INTERNAL_FUNC int mdbx_msync(mdbx_mmap_t *map, size_t offset,
|
||||
MDBX_INTERNAL_FUNC int mdbx_check_fs_rdonly(mdbx_filehandle_t handle,
|
||||
const char *pathname, int err);
|
||||
|
||||
static __maybe_unused __inline uint32_t mdbx_getpid(void) {
|
||||
MDBX_MAYBE_UNUSED static __inline uint32_t mdbx_getpid(void) {
|
||||
STATIC_ASSERT(sizeof(mdbx_pid_t) <= sizeof(uint32_t));
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
return GetCurrentProcessId();
|
||||
@ -722,7 +722,7 @@ static __maybe_unused __inline uint32_t mdbx_getpid(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static __maybe_unused __inline uintptr_t mdbx_thread_self(void) {
|
||||
MDBX_MAYBE_UNUSED static __inline uintptr_t mdbx_thread_self(void) {
|
||||
mdbx_tid_t thunk;
|
||||
STATIC_ASSERT(sizeof(uintptr_t) >= sizeof(thunk));
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
@ -733,7 +733,7 @@ static __maybe_unused __inline uintptr_t mdbx_thread_self(void) {
|
||||
return (uintptr_t)thunk;
|
||||
}
|
||||
|
||||
MDBX_INTERNAL_FUNC void __maybe_unused mdbx_osal_jitter(bool tiny);
|
||||
MDBX_MAYBE_UNUSED MDBX_INTERNAL_FUNC void mdbx_osal_jitter(bool tiny);
|
||||
MDBX_INTERNAL_FUNC uint64_t mdbx_osal_monotime(void);
|
||||
MDBX_INTERNAL_FUNC uint64_t
|
||||
mdbx_osal_16dot16_to_monotime(uint32_t seconds_16dot16);
|
||||
|
@ -45,11 +45,11 @@
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#include <atomic>
|
||||
static __inline __maybe_unused int atomic_decrement(std::atomic_int *p) {
|
||||
MDBX_MAYBE_UNUSED static __inline int atomic_decrement(std::atomic_int *p) {
|
||||
return std::atomic_fetch_sub(p, 1) - 1;
|
||||
}
|
||||
#else
|
||||
static __inline __maybe_unused int atomic_decrement(volatile int *p) {
|
||||
MDBX_MAYBE_UNUSED static __inline int atomic_decrement(volatile int *p) {
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
return __sync_sub_and_fetch(p, 1);
|
||||
#elif defined(_MSC_VER)
|
||||
|
Loading…
x
Reference in New Issue
Block a user