mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 19:34:15 +08:00
mdbx: minor alignment fix for lck-less stub to avoid false-positive alarm from UndefinedBehaviorSanitize.
Change-Id: I8d9bc00ccfc7228cb42f9419cf77e8eadb92f918
This commit is contained in:
parent
7c45f75010
commit
43f1823cdc
14
src/core.c
14
src/core.c
@ -10852,6 +10852,14 @@ static void __cold mdbx_setup_pagesize(MDBX_env *env, const size_t pagesize) {
|
|||||||
env->me_options.dp_initial = env->me_options.dp_limit;
|
env->me_options.dp_initial = env->me_options.dp_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __inline MDBX_CONST_FUNCTION MDBX_lockinfo *
|
||||||
|
lckless_stub(const MDBX_env *env) {
|
||||||
|
uintptr_t stub = (uintptr_t)&env->x_lckless_stub;
|
||||||
|
/* align to avoid false-positive alarm from UndefinedBehaviorSanitizer */
|
||||||
|
stub = (stub + MDBX_CACHELINE_SIZE - 1) & ~(MDBX_CACHELINE_SIZE - 1);
|
||||||
|
return (MDBX_lockinfo *)stub;
|
||||||
|
}
|
||||||
|
|
||||||
__cold int mdbx_env_create(MDBX_env **penv) {
|
__cold int mdbx_env_create(MDBX_env **penv) {
|
||||||
MDBX_env *env = mdbx_calloc(1, sizeof(MDBX_env));
|
MDBX_env *env = mdbx_calloc(1, sizeof(MDBX_env));
|
||||||
if (unlikely(!env))
|
if (unlikely(!env))
|
||||||
@ -10905,7 +10913,7 @@ __cold int mdbx_env_create(MDBX_env **penv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MDBX_LOCKING > MDBX_LOCKING_SYSV
|
#if MDBX_LOCKING > MDBX_LOCKING_SYSV
|
||||||
MDBX_lockinfo *const stub = (MDBX_lockinfo *)&env->me_lckless_stub;
|
MDBX_lockinfo *const stub = lckless_stub(env);
|
||||||
rc = mdbx_ipclock_stub(&stub->mti_wlock);
|
rc = mdbx_ipclock_stub(&stub->mti_wlock);
|
||||||
#endif /* MDBX_LOCKING */
|
#endif /* MDBX_LOCKING */
|
||||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||||
@ -11838,7 +11846,7 @@ static __cold int mdbx_setup_lck(MDBX_env *env, char *lck_pathname,
|
|||||||
lcklist_unlock();
|
lcklist_unlock();
|
||||||
/* end of a locked section ---------------------------------------------- */
|
/* end of a locked section ---------------------------------------------- */
|
||||||
|
|
||||||
env->me_lck = (MDBX_lockinfo *)&env->me_lckless_stub;
|
env->me_lck = lckless_stub(env);
|
||||||
env->me_maxreaders = UINT_MAX;
|
env->me_maxreaders = UINT_MAX;
|
||||||
mdbx_debug("lck-setup:%s%s%s", " lck-less",
|
mdbx_debug("lck-setup:%s%s%s", " lck-less",
|
||||||
(env->me_flags & MDBX_RDONLY) ? " readonly" : "",
|
(env->me_flags & MDBX_RDONLY) ? " readonly" : "",
|
||||||
@ -12695,7 +12703,7 @@ __cold int mdbx_env_close_ex(MDBX_env *env, bool dont_sync) {
|
|||||||
#endif /* Windows */
|
#endif /* Windows */
|
||||||
|
|
||||||
#if MDBX_LOCKING > MDBX_LOCKING_SYSV
|
#if MDBX_LOCKING > MDBX_LOCKING_SYSV
|
||||||
MDBX_lockinfo *const stub = (MDBX_lockinfo *)&env->me_lckless_stub;
|
MDBX_lockinfo *const stub = lckless_stub(env);
|
||||||
mdbx_ensure(env, mdbx_ipclock_destroy(&stub->mti_wlock) == 0);
|
mdbx_ensure(env, mdbx_ipclock_destroy(&stub->mti_wlock) == 0);
|
||||||
#endif /* MDBX_LOCKING */
|
#endif /* MDBX_LOCKING */
|
||||||
|
|
||||||
|
@ -1236,10 +1236,9 @@ struct MDBX_env {
|
|||||||
#endif /* xMDBX_DEBUG_SPILLING */
|
#endif /* xMDBX_DEBUG_SPILLING */
|
||||||
|
|
||||||
/* ------------------------------------------------- stub for lck-less mode */
|
/* ------------------------------------------------- stub for lck-less mode */
|
||||||
alignas(MDBX_CACHELINE_SIZE) uint64_t
|
MDBX_atomic_uint64_t
|
||||||
me_lckless_stub[((sizeof(MDBX_lockinfo) + MDBX_CACHELINE_SIZE - 1) &
|
x_lckless_stub[(sizeof(MDBX_lockinfo) + MDBX_CACHELINE_SIZE - 1) /
|
||||||
~(MDBX_CACHELINE_SIZE - 1)) /
|
sizeof(MDBX_atomic_uint64_t)];
|
||||||
8];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user