mdbx: minor refine MDBX_UNALIGNED_OK.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-07-11 23:06:09 +03:00
parent 08e936a809
commit a82f59a998

View File

@ -370,14 +370,11 @@
#endif /* MDBX_64BIT_CAS */ #endif /* MDBX_64BIT_CAS */
#ifndef MDBX_UNALIGNED_OK #ifndef MDBX_UNALIGNED_OK
#if defined(__ALIGNED__) || defined(__SANITIZE_UNDEFINED__) #if defined(__ALIGNED__) || defined(__SANITIZE_UNDEFINED__) || \
defined(ENABLE_UBSAN)
#define MDBX_UNALIGNED_OK 0 /* no unaligned access allowed */ #define MDBX_UNALIGNED_OK 0 /* no unaligned access allowed */
#elif defined(__ARM_FEATURE_UNALIGNED) #elif defined(__ARM_FEATURE_UNALIGNED)
#define MDBX_UNALIGNED_OK 4 /* ok unaligned for 32-bit words */ #define MDBX_UNALIGNED_OK 4 /* ok unaligned for 32-bit words */
#elif __CLANG_PREREQ(5, 0) || __GNUC_PREREQ(5, 0)
/* expecting an optimization will well done, also this
* hushes false-positives from UBSAN (undefined behaviour sanitizer) */
#define MDBX_UNALIGNED_OK 0
#elif defined(__e2k__) || defined(__elbrus__) #elif defined(__e2k__) || defined(__elbrus__)
#if __iset__ > 4 #if __iset__ > 4
#define MDBX_UNALIGNED_OK 8 /* ok unaligned for 64-bit words */ #define MDBX_UNALIGNED_OK 8 /* ok unaligned for 64-bit words */
@ -386,6 +383,10 @@
#endif #endif
#elif defined(__ia32__) #elif defined(__ia32__)
#define MDBX_UNALIGNED_OK 8 /* ok unaligned for 64-bit words */ #define MDBX_UNALIGNED_OK 8 /* ok unaligned for 64-bit words */
#elif __CLANG_PREREQ(5, 0) || __GNUC_PREREQ(5, 0)
/* expecting an optimization will well done, also this
* hushes false-positives from UBSAN (undefined behaviour sanitizer) */
#define MDBX_UNALIGNED_OK 0
#else #else
#define MDBX_UNALIGNED_OK 0 /* no unaligned access allowed */ #define MDBX_UNALIGNED_OK 0 /* no unaligned access allowed */
#endif #endif