mirror of
https://github.com/isar/libmdbx.git
synced 2025-11-06 19:08:56 +08:00
mdbx: новые настройки clang-format (косметика).
This commit is contained in:
41
src/utils.h
41
src/utils.h
@@ -27,46 +27,36 @@
|
||||
/* Pointer distance as signed number of bytes */
|
||||
#define ptr_dist(more, less) (((intptr_t)(more)) - ((intptr_t)(less)))
|
||||
|
||||
#define MDBX_ASAN_POISON_MEMORY_REGION(addr, size) \
|
||||
do { \
|
||||
TRACE("POISON_MEMORY_REGION(%p, %zu) at %u", (void *)(addr), \
|
||||
(size_t)(size), __LINE__); \
|
||||
ASAN_POISON_MEMORY_REGION(addr, size); \
|
||||
#define MDBX_ASAN_POISON_MEMORY_REGION(addr, size) \
|
||||
do { \
|
||||
TRACE("POISON_MEMORY_REGION(%p, %zu) at %u", (void *)(addr), (size_t)(size), __LINE__); \
|
||||
ASAN_POISON_MEMORY_REGION(addr, size); \
|
||||
} while (0)
|
||||
|
||||
#define MDBX_ASAN_UNPOISON_MEMORY_REGION(addr, size) \
|
||||
do { \
|
||||
TRACE("UNPOISON_MEMORY_REGION(%p, %zu) at %u", (void *)(addr), \
|
||||
(size_t)(size), __LINE__); \
|
||||
ASAN_UNPOISON_MEMORY_REGION(addr, size); \
|
||||
#define MDBX_ASAN_UNPOISON_MEMORY_REGION(addr, size) \
|
||||
do { \
|
||||
TRACE("UNPOISON_MEMORY_REGION(%p, %zu) at %u", (void *)(addr), (size_t)(size), __LINE__); \
|
||||
ASAN_UNPOISON_MEMORY_REGION(addr, size); \
|
||||
} while (0)
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline size_t
|
||||
branchless_abs(intptr_t value) {
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline size_t branchless_abs(intptr_t value) {
|
||||
assert(value > INT_MIN);
|
||||
const size_t expanded_sign =
|
||||
(size_t)(value >> (sizeof(value) * CHAR_BIT - 1));
|
||||
const size_t expanded_sign = (size_t)(value >> (sizeof(value) * CHAR_BIT - 1));
|
||||
return ((size_t)value + expanded_sign) ^ expanded_sign;
|
||||
}
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline bool
|
||||
is_powerof2(size_t x) {
|
||||
return (x & (x - 1)) == 0;
|
||||
}
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline bool is_powerof2(size_t x) { return (x & (x - 1)) == 0; }
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline size_t
|
||||
floor_powerof2(size_t value, size_t granularity) {
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline size_t floor_powerof2(size_t value, size_t granularity) {
|
||||
assert(is_powerof2(granularity));
|
||||
return value & ~(granularity - 1);
|
||||
}
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline size_t
|
||||
ceil_powerof2(size_t value, size_t granularity) {
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED static inline size_t ceil_powerof2(size_t value, size_t granularity) {
|
||||
return floor_powerof2(value + granularity - 1, granularity);
|
||||
}
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED MDBX_INTERNAL unsigned
|
||||
log2n_powerof2(size_t value_uintptr);
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_MAYBE_UNUSED MDBX_INTERNAL unsigned log2n_powerof2(size_t value_uintptr);
|
||||
|
||||
MDBX_NOTHROW_CONST_FUNCTION MDBX_INTERNAL uint64_t rrxmrrxmsx_0(uint64_t v);
|
||||
|
||||
@@ -75,8 +65,7 @@ struct monotime_cache {
|
||||
int expire_countdown;
|
||||
};
|
||||
|
||||
MDBX_MAYBE_UNUSED static inline uint64_t
|
||||
monotime_since_cached(uint64_t begin_timestamp, struct monotime_cache *cache) {
|
||||
MDBX_MAYBE_UNUSED static inline uint64_t monotime_since_cached(uint64_t begin_timestamp, struct monotime_cache *cache) {
|
||||
if (cache->expire_countdown)
|
||||
cache->expire_countdown -= 1;
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user