mdbx: add pure- & const-function attributes to C API.

Change-Id: Ie4d1742f3d4717a0cd1fd5677b9b1ae641193d45
This commit is contained in:
Leonid Yuriev
2020-08-21 18:01:16 +03:00
parent 100ac532ed
commit 0a75417d5f
5 changed files with 238 additions and 154 deletions

View File

@@ -1354,12 +1354,14 @@ typedef struct MDBX_node {
/* Do not spill pages to disk if txn is getting full, may fail instead */
#define MDBX_NOSPILL 0x8000
static __maybe_unused __inline pgno_t pgno_add(pgno_t base, pgno_t augend) {
__nothrow_const_function static __maybe_unused __inline pgno_t
pgno_add(pgno_t base, pgno_t augend) {
assert(base <= MAX_PAGENO);
return (augend < MAX_PAGENO - base) ? base + augend : MAX_PAGENO;
}
static __maybe_unused __inline pgno_t pgno_sub(pgno_t base, pgno_t subtrahend) {
__nothrow_const_function static __maybe_unused __inline pgno_t
pgno_sub(pgno_t base, pgno_t subtrahend) {
assert(base >= MIN_PAGENO);
return (subtrahend < base - MIN_PAGENO) ? base - subtrahend : MIN_PAGENO;
}
@@ -1373,18 +1375,18 @@ static __maybe_unused __inline void mdbx_jitter4testing(bool tiny) {
#endif
}
static __pure_function __always_inline __maybe_unused bool
__nothrow_const_function static __always_inline __maybe_unused bool
is_powerof2(size_t x) {
return (x & (x - 1)) == 0;
}
static __pure_function __always_inline __maybe_unused size_t
__nothrow_const_function static __always_inline __maybe_unused size_t
floor_powerof2(size_t value, size_t granularity) {
assert(is_powerof2(granularity));
return value & ~(granularity - 1);
}
static __pure_function __always_inline __maybe_unused size_t
__nothrow_const_function static __always_inline __maybe_unused size_t
ceil_powerof2(size_t value, size_t granularity) {
return floor_powerof2(value + granularity - 1, granularity);
}