mdbx: drop mdbx_get_errno_checked().

Change-Id: Ifa829b465083f17eba911e19947bdae854f9759c
This commit is contained in:
Leo Yuriev 2017-06-21 01:41:25 +03:00
parent 151d4540de
commit 10b0197026
3 changed files with 37 additions and 57 deletions

View File

@ -129,7 +129,7 @@ static __inline BOOL funlock(mdbx_filehandle_t fd, uint64_t offset,
int mdbx_txn_lock(MDBX_env *env) { int mdbx_txn_lock(MDBX_env *env) {
if (flock(env->me_fd, LCK_EXCLUSIVE | LCK_WAITFOR, LCK_BODY)) if (flock(env->me_fd, LCK_EXCLUSIVE | LCK_WAITFOR, LCK_BODY))
return MDBX_SUCCESS; return MDBX_SUCCESS;
return mdbx_get_errno_checked(); return GetLastError();
} }
void mdbx_txn_unlock(MDBX_env *env) { void mdbx_txn_unlock(MDBX_env *env) {
@ -155,7 +155,7 @@ int mdbx_rdt_lock(MDBX_env *env) {
/* transite from S-? (used) to S-E (locked), e.g. exlcusive lock upper-part */ /* transite from S-? (used) to S-E (locked), e.g. exlcusive lock upper-part */
if (flock(env->me_lfd, LCK_EXCLUSIVE | LCK_WAITFOR, LCK_UPPER)) if (flock(env->me_lfd, LCK_EXCLUSIVE | LCK_WAITFOR, LCK_UPPER))
return MDBX_SUCCESS; return MDBX_SUCCESS;
return mdbx_get_errno_checked(); return GetLastError();
} }
void mdbx_rdt_unlock(MDBX_env *env) { void mdbx_rdt_unlock(MDBX_env *env) {
@ -196,7 +196,7 @@ static int internal_seize_lck(HANDLE lfd) {
/* 1) now on ?-? (free), get ?-E (middle) */ /* 1) now on ?-? (free), get ?-E (middle) */
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
if (!flock(lfd, LCK_EXCLUSIVE | LCK_WAITFOR, LCK_UPPER)) { if (!flock(lfd, LCK_EXCLUSIVE | LCK_WAITFOR, LCK_UPPER)) {
rc = mdbx_get_errno_checked() /* 2) something went wrong, give up */; rc = GetLastError() /* 2) something went wrong, give up */;
mdbx_error("%s(%s) failed: errcode %u", mdbx_func_, mdbx_error("%s(%s) failed: errcode %u", mdbx_func_,
"?-?(free) >> ?-E(middle)", rc); "?-?(free) >> ?-E(middle)", rc);
return rc; return rc;
@ -208,7 +208,7 @@ static int internal_seize_lck(HANDLE lfd) {
return MDBX_RESULT_TRUE; /* 4) got E-E (exclusive), done */ return MDBX_RESULT_TRUE; /* 4) got E-E (exclusive), done */
/* 5) still on ?-E (middle) */ /* 5) still on ?-E (middle) */
rc = mdbx_get_errno_checked(); rc = GetLastError();
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
if (rc != ERROR_SHARING_VIOLATION && rc != ERROR_LOCK_VIOLATION) { if (rc != ERROR_SHARING_VIOLATION && rc != ERROR_LOCK_VIOLATION) {
/* 6) something went wrong, give up */ /* 6) something went wrong, give up */
@ -220,9 +220,8 @@ static int internal_seize_lck(HANDLE lfd) {
/* 7) still on ?-E (middle), try S-E (locked) */ /* 7) still on ?-E (middle), try S-E (locked) */
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
rc = flock(lfd, LCK_SHARED | LCK_DONTWAIT, LCK_LOWER) rc = flock(lfd, LCK_SHARED | LCK_DONTWAIT, LCK_LOWER) ? MDBX_RESULT_FALSE
? MDBX_RESULT_FALSE : GetLastError();
: mdbx_get_errno_checked();
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
if (rc != MDBX_RESULT_FALSE) if (rc != MDBX_RESULT_FALSE)
@ -247,7 +246,7 @@ int mdbx_lck_seize(MDBX_env *env) {
/* LY: without-lck mode (e.g. on read-only filesystem) */ /* LY: without-lck mode (e.g. on read-only filesystem) */
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
if (!flock(env->me_fd, LCK_SHARED | LCK_DONTWAIT, LCK_WHOLE)) { if (!flock(env->me_fd, LCK_SHARED | LCK_DONTWAIT, LCK_WHOLE)) {
rc = mdbx_get_errno_checked(); rc = GetLastError();
mdbx_error("%s(%s) failed: errcode %u", mdbx_func_, "without-lck", rc); mdbx_error("%s(%s) failed: errcode %u", mdbx_func_, "without-lck", rc);
return rc; return rc;
} }
@ -264,7 +263,7 @@ int mdbx_lck_seize(MDBX_env *env) {
* - we can't lock meta-pages, otherwise other process could get an error * - we can't lock meta-pages, otherwise other process could get an error
* while opening db in valid (non-conflict) mode. */ * while opening db in valid (non-conflict) mode. */
if (!flock(env->me_fd, LCK_EXCLUSIVE | LCK_DONTWAIT, LCK_BODY)) { if (!flock(env->me_fd, LCK_EXCLUSIVE | LCK_DONTWAIT, LCK_BODY)) {
rc = mdbx_get_errno_checked(); rc = GetLastError();
mdbx_error("%s(%s) failed: errcode %u", mdbx_func_, mdbx_error("%s(%s) failed: errcode %u", mdbx_func_,
"lock-against-without-lck", rc); "lock-against-without-lck", rc);
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
@ -292,7 +291,7 @@ int mdbx_lck_downgrade(MDBX_env *env) {
/* 2) now at ?-E (middle), transite to S-E (locked) */ /* 2) now at ?-E (middle), transite to S-E (locked) */
if (!flock(env->me_lfd, LCK_SHARED | LCK_DONTWAIT, LCK_LOWER)) { if (!flock(env->me_lfd, LCK_SHARED | LCK_DONTWAIT, LCK_LOWER)) {
int rc = mdbx_get_errno_checked() /* 3) something went wrong, give up */; int rc = GetLastError() /* 3) something went wrong, give up */;
return rc; return rc;
} }
@ -320,7 +319,7 @@ int mdbx_lck_upgrade(MDBX_env *env) {
return MDBX_RESULT_TRUE; /* 4) got E-E (exclusive), done */ return MDBX_RESULT_TRUE; /* 4) got E-E (exclusive), done */
/* 5) still on ?-E (middle) */ /* 5) still on ?-E (middle) */
int rc = mdbx_get_errno_checked(); int rc = GetLastError();
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
if (rc != ERROR_SHARING_VIOLATION && rc != ERROR_LOCK_VIOLATION) { if (rc != ERROR_SHARING_VIOLATION && rc != ERROR_LOCK_VIOLATION) {
/* 6) something went wrong, report but continue */ /* 6) something went wrong, report but continue */
@ -332,7 +331,7 @@ int mdbx_lck_upgrade(MDBX_env *env) {
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
rc = flock(env->me_lfd, LCK_SHARED | LCK_DONTWAIT, LCK_LOWER) rc = flock(env->me_lfd, LCK_SHARED | LCK_DONTWAIT, LCK_LOWER)
? MDBX_RESULT_FALSE ? MDBX_RESULT_FALSE
: mdbx_get_errno_checked(); : GetLastError();
mdbx_jitter4testing(false); mdbx_jitter4testing(false);
if (rc != MDBX_RESULT_FALSE) { if (rc != MDBX_RESULT_FALSE) {
@ -352,14 +351,14 @@ void mdbx_lck_destroy(MDBX_env *env) {
/* double `unlock` for robustly remove overlapped shared/exclusive locks */ /* double `unlock` for robustly remove overlapped shared/exclusive locks */
while (funlock(env->me_lfd, LCK_LOWER)) while (funlock(env->me_lfd, LCK_LOWER))
; ;
rc = mdbx_get_errno_checked(); rc = GetLastError();
assert(rc == ERROR_NOT_LOCKED); assert(rc == ERROR_NOT_LOCKED);
(void)rc; (void)rc;
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
while (funlock(env->me_lfd, LCK_UPPER)) while (funlock(env->me_lfd, LCK_UPPER))
; ;
rc = mdbx_get_errno_checked(); rc = GetLastError();
assert(rc == ERROR_NOT_LOCKED); assert(rc == ERROR_NOT_LOCKED);
(void)rc; (void)rc;
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
@ -370,21 +369,21 @@ void mdbx_lck_destroy(MDBX_env *env) {
* releases such locks via deferred queues) */ * releases such locks via deferred queues) */
while (funlock(env->me_fd, LCK_BODY)) while (funlock(env->me_fd, LCK_BODY))
; ;
rc = mdbx_get_errno_checked(); rc = GetLastError();
assert(rc == ERROR_NOT_LOCKED); assert(rc == ERROR_NOT_LOCKED);
(void)rc; (void)rc;
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
while (funlock(env->me_fd, LCK_META)) while (funlock(env->me_fd, LCK_META))
; ;
rc = mdbx_get_errno_checked(); rc = GetLastError();
assert(rc == ERROR_NOT_LOCKED); assert(rc == ERROR_NOT_LOCKED);
(void)rc; (void)rc;
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
while (funlock(env->me_fd, LCK_WHOLE)) while (funlock(env->me_fd, LCK_WHOLE))
; ;
rc = mdbx_get_errno_checked(); rc = GetLastError();
assert(rc == ERROR_NOT_LOCKED); assert(rc == ERROR_NOT_LOCKED);
(void)rc; (void)rc;
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
@ -418,7 +417,7 @@ int mdbx_rpid_check(MDBX_env *env, mdbx_pid_t pid) {
rc = WaitForSingleObject(hProcess, 0); rc = WaitForSingleObject(hProcess, 0);
CloseHandle(hProcess); CloseHandle(hProcess);
} else { } else {
rc = mdbx_get_errno_checked(); rc = GetLastError();
} }
switch (rc) { switch (rc) {

View File

@ -22,7 +22,7 @@ static int waitstatus2errcode(DWORD result) {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
return MDBX_SUCCESS; return MDBX_SUCCESS;
case WAIT_FAILED: case WAIT_FAILED:
return mdbx_get_errno_checked(); return GetLastError();
case WAIT_ABANDONED: case WAIT_ABANDONED:
return ERROR_ABANDONED_WAIT_0; return ERROR_ABANDONED_WAIT_0;
case WAIT_IO_COMPLETION: case WAIT_IO_COMPLETION:
@ -202,11 +202,11 @@ int mdbx_condmutex_init(mdbx_condmutex_t *condmutex) {
condmutex->event = NULL; condmutex->event = NULL;
condmutex->mutex = CreateMutex(NULL, FALSE, NULL); condmutex->mutex = CreateMutex(NULL, FALSE, NULL);
if (!condmutex->mutex) if (!condmutex->mutex)
return mdbx_get_errno_checked(); return GetLastError();
condmutex->event = CreateEvent(NULL, FALSE, FALSE, NULL); condmutex->event = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!condmutex->event) { if (!condmutex->event) {
rc = mdbx_get_errno_checked(); rc = GetLastError();
(void)CloseHandle(condmutex->mutex); (void)CloseHandle(condmutex->mutex);
condmutex->mutex = NULL; condmutex->mutex = NULL;
} }
@ -235,14 +235,12 @@ int mdbx_condmutex_destroy(mdbx_condmutex_t *condmutex) {
int rc = MDBX_EINVAL; int rc = MDBX_EINVAL;
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
if (condmutex->event) { if (condmutex->event) {
rc = rc = CloseHandle(condmutex->event) ? MDBX_SUCCESS : GetLastError();
CloseHandle(condmutex->event) ? MDBX_SUCCESS : mdbx_get_errno_checked();
if (rc == MDBX_SUCCESS) if (rc == MDBX_SUCCESS)
condmutex->event = NULL; condmutex->event = NULL;
} }
if (condmutex->mutex) { if (condmutex->mutex) {
rc = rc = CloseHandle(condmutex->mutex) ? MDBX_SUCCESS : GetLastError();
CloseHandle(condmutex->mutex) ? MDBX_SUCCESS : mdbx_get_errno_checked();
if (rc == MDBX_SUCCESS) if (rc == MDBX_SUCCESS)
condmutex->mutex = NULL; condmutex->mutex = NULL;
} }
@ -272,8 +270,7 @@ int mdbx_condmutex_lock(mdbx_condmutex_t *condmutex) {
int mdbx_condmutex_unlock(mdbx_condmutex_t *condmutex) { int mdbx_condmutex_unlock(mdbx_condmutex_t *condmutex) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
return ReleaseMutex(condmutex->mutex) ? MDBX_SUCCESS return ReleaseMutex(condmutex->mutex) ? MDBX_SUCCESS : GetLastError();
: mdbx_get_errno_checked();
#else #else
return pthread_mutex_unlock(&condmutex->mutex); return pthread_mutex_unlock(&condmutex->mutex);
#endif #endif
@ -281,7 +278,7 @@ int mdbx_condmutex_unlock(mdbx_condmutex_t *condmutex) {
int mdbx_condmutex_signal(mdbx_condmutex_t *condmutex) { int mdbx_condmutex_signal(mdbx_condmutex_t *condmutex) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
return SetEvent(condmutex->event) ? MDBX_SUCCESS : mdbx_get_errno_checked(); return SetEvent(condmutex->event) ? MDBX_SUCCESS : GetLastError();
#else #else
return pthread_cond_signal(&condmutex->cond); return pthread_cond_signal(&condmutex->cond);
#endif #endif
@ -385,14 +382,14 @@ int mdbx_openfile(const char *pathname, int flags, mode_t mode,
CreationDisposition, FlagsAndAttributes, NULL); CreationDisposition, FlagsAndAttributes, NULL);
if (*fd == INVALID_HANDLE_VALUE) if (*fd == INVALID_HANDLE_VALUE)
return mdbx_get_errno_checked(); return GetLastError();
if ((flags & O_CREAT) && mdbx_get_errno_checked() != ERROR_ALREADY_EXISTS) { if ((flags & O_CREAT) && GetLastError() != ERROR_ALREADY_EXISTS) {
/* set FILE_ATTRIBUTE_NOT_CONTENT_INDEXED for new file */ /* set FILE_ATTRIBUTE_NOT_CONTENT_INDEXED for new file */
DWORD FileAttributes = GetFileAttributesA(pathname); DWORD FileAttributes = GetFileAttributesA(pathname);
if (FileAttributes == INVALID_FILE_ATTRIBUTES || if (FileAttributes == INVALID_FILE_ATTRIBUTES ||
!SetFileAttributesA(pathname, FileAttributes | !SetFileAttributesA(pathname, FileAttributes |
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)) { FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)) {
int rc = mdbx_get_errno_checked(); int rc = GetLastError();
CloseHandle(*fd); CloseHandle(*fd);
*fd = INVALID_HANDLE_VALUE; *fd = INVALID_HANDLE_VALUE;
return rc; return rc;
@ -417,7 +414,7 @@ int mdbx_openfile(const char *pathname, int flags, mode_t mode,
int mdbx_closefile(mdbx_filehandle_t fd) { int mdbx_closefile(mdbx_filehandle_t fd) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
return CloseHandle(fd) ? MDBX_SUCCESS : mdbx_get_errno_checked(); return CloseHandle(fd) ? MDBX_SUCCESS : GetLastError();
#else #else
return (close(fd) == 0) ? MDBX_SUCCESS : errno; return (close(fd) == 0) ? MDBX_SUCCESS : errno;
#endif #endif
@ -435,7 +432,7 @@ int mdbx_pread(mdbx_filehandle_t fd, void *buf, size_t bytes, uint64_t offset) {
DWORD read = 0; DWORD read = 0;
if (unlikely(!ReadFile(fd, buf, (DWORD)bytes, &read, &ov))) { if (unlikely(!ReadFile(fd, buf, (DWORD)bytes, &read, &ov))) {
int rc = mdbx_get_errno_checked(); int rc = GetLastError();
return (rc == MDBX_SUCCESS) ? /* paranoia */ ERROR_READ_FAULT : rc; return (rc == MDBX_SUCCESS) ? /* paranoia */ ERROR_READ_FAULT : rc;
} }
#else #else
@ -464,7 +461,7 @@ int mdbx_pwrite(mdbx_filehandle_t fd, const void *buf, size_t bytes,
DWORD written; DWORD written;
if (likely(WriteFile(fd, buf, (DWORD)bytes, &written, &ov))) if (likely(WriteFile(fd, buf, (DWORD)bytes, &written, &ov)))
return (bytes == written) ? MDBX_SUCCESS : MDBX_EIO /* ERROR_WRITE_FAULT */; return (bytes == written) ? MDBX_SUCCESS : MDBX_EIO /* ERROR_WRITE_FAULT */;
return mdbx_get_errno_checked(); return GetLastError();
#else #else
int rc; int rc;
ssize_t written; ssize_t written;
@ -524,7 +521,7 @@ int mdbx_write(mdbx_filehandle_t fd, const void *buf, size_t bytes) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
DWORD written; DWORD written;
if (unlikely(!WriteFile(fd, ptr, (DWORD)chunk, &written, NULL))) if (unlikely(!WriteFile(fd, ptr, (DWORD)chunk, &written, NULL)))
return mdbx_get_errno_checked(); return GetLastError();
#else #else
ssize_t written = write(fd, ptr, chunk); ssize_t written = write(fd, ptr, chunk);
if (written < 0) { if (written < 0) {
@ -557,7 +554,7 @@ int mdbx_write(mdbx_filehandle_t fd, const void *buf, size_t bytes) {
int mdbx_filesync(mdbx_filehandle_t fd, bool fullsync) { int mdbx_filesync(mdbx_filehandle_t fd, bool fullsync) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
(void)fullsync; (void)fullsync;
return FlushFileBuffers(fd) ? MDBX_SUCCESS : mdbx_get_errno_checked(); return FlushFileBuffers(fd) ? MDBX_SUCCESS : GetLastError();
#elif __GLIBC_PREREQ(2, 16) || _BSD_SOURCE || _XOPEN_SOURCE || \ #elif __GLIBC_PREREQ(2, 16) || _BSD_SOURCE || _XOPEN_SOURCE || \
(__GLIBC_PREREQ(2, 8) && _POSIX_C_SOURCE >= 200112L) (__GLIBC_PREREQ(2, 8) && _POSIX_C_SOURCE >= 200112L)
for (;;) { for (;;) {
@ -583,7 +580,7 @@ int mdbx_filesize(mdbx_filehandle_t fd, uint64_t *length) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
BY_HANDLE_FILE_INFORMATION info; BY_HANDLE_FILE_INFORMATION info;
if (!GetFileInformationByHandle(fd, &info)) if (!GetFileInformationByHandle(fd, &info))
return mdbx_get_errno_checked(); return GetLastError();
*length = info.nFileSizeLow | (uint64_t)info.nFileSizeHigh << 32; *length = info.nFileSizeLow | (uint64_t)info.nFileSizeHigh << 32;
#else #else
struct stat st; struct stat st;
@ -604,7 +601,7 @@ int mdbx_ftruncate(mdbx_filehandle_t fd, uint64_t length) {
li.QuadPart = length; li.QuadPart = length;
return (SetFilePointerEx(fd, li, NULL, FILE_BEGIN) && SetEndOfFile(fd)) return (SetFilePointerEx(fd, li, NULL, FILE_BEGIN) && SetEndOfFile(fd))
? MDBX_SUCCESS ? MDBX_SUCCESS
: mdbx_get_errno_checked(); : GetLastError();
#else #else
STATIC_ASSERT_MSG(sizeof(off_t) >= sizeof(size_t), STATIC_ASSERT_MSG(sizeof(off_t) >= sizeof(size_t),
"libmdbx requires 64-bit file I/O on 64-bit systems"); "libmdbx requires 64-bit file I/O on 64-bit systems");
@ -617,7 +614,7 @@ int mdbx_ftruncate(mdbx_filehandle_t fd, uint64_t length) {
int mdbx_thread_key_create(mdbx_thread_key_t *key) { int mdbx_thread_key_create(mdbx_thread_key_t *key) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
*key = TlsAlloc(); *key = TlsAlloc();
return (*key != TLS_OUT_OF_INDEXES) ? MDBX_SUCCESS : mdbx_get_errno_checked(); return (*key != TLS_OUT_OF_INDEXES) ? MDBX_SUCCESS : GetLastError();
#else #else
return pthread_key_create(key, mdbx_rthc_dtor); return pthread_key_create(key, mdbx_rthc_dtor);
#endif #endif
@ -652,7 +649,7 @@ int mdbx_thread_create(mdbx_thread_t *thread,
void *arg) { void *arg) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
*thread = CreateThread(NULL, 0, start_routine, arg, 0, NULL); *thread = CreateThread(NULL, 0, start_routine, arg, 0, NULL);
return *thread ? MDBX_SUCCESS : mdbx_get_errno_checked(); return *thread ? MDBX_SUCCESS : GetLastError();
#else #else
return pthread_create(thread, NULL, start_routine, arg); return pthread_create(thread, NULL, start_routine, arg);
#endif #endif
@ -674,8 +671,7 @@ int mdbx_msync(void *addr, size_t length, int async) {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
if (async) if (async)
return MDBX_SUCCESS; return MDBX_SUCCESS;
return FlushViewOfFile(addr, length) ? MDBX_SUCCESS return FlushViewOfFile(addr, length) ? MDBX_SUCCESS : GetLastError();
: mdbx_get_errno_checked();
#else #else
const int mode = async ? MS_ASYNC : MS_SYNC; const int mode = async ? MS_ASYNC : MS_SYNC;
return (msync(addr, length, mode) == 0) ? MDBX_SUCCESS : errno; return (msync(addr, length, mode) == 0) ? MDBX_SUCCESS : errno;

View File

@ -396,21 +396,6 @@ static __inline int mdbx_get_errno(void) {
return rc; return rc;
} }
static __inline int __mdbx_get_errno_checked(const char *file, unsigned line) {
#if defined(_WIN32) || defined(_WIN64)
DWORD rc = GetLastError();
if (unlikely(rc == MDBX_EINVAL))
mdbx_assert_fail(nullptr, "unexpected ERROR_INVALID_PARAMETER", file, line);
#else
int rc = errno;
if (unlikely(rc == MDBX_EINVAL))
mdbx_assert_fail(nullptr, "unexpected EINVAL", file, line);
#endif
return rc;
}
#define mdbx_get_errno_checked() __mdbx_get_errno_checked(__FILE__, __LINE__)
int mdbx_memalign_alloc(size_t alignment, size_t bytes, void **result); int mdbx_memalign_alloc(size_t alignment, size_t bytes, void **result);
void mdbx_memalign_free(void *ptr); void mdbx_memalign_free(void *ptr);