mdbx: костыль для некорректной обработки [[gnu::pure]] в Apple Clang.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2024-10-23 11:26:09 +03:00
parent b43eed2c2b
commit 964ee00116

18
mdbx.h
View File

@ -218,10 +218,14 @@ typedef mode_t mdbx_mode_t;
#ifndef __has_feature #ifndef __has_feature
#define __has_feature(x) (0) #define __has_feature(x) (0)
#define __has_exceptions_disabled (0)
#else
#define __has_exceptions_disabled \
(__has_feature(cxx_noexcept) && !__has_feature(cxx_exceptions))
#endif /* __has_feature */ #endif /* __has_feature */
#ifndef __has_extension #ifndef __has_extension
#define __has_extension(x) (0) #define __has_extension(x) __has_feature(x)
#endif /* __has_extension */ #endif /* __has_extension */
#ifndef __has_builtin #ifndef __has_builtin
@ -236,11 +240,13 @@ typedef mode_t mdbx_mode_t;
* These functions should be declared with the attribute pure. */ * These functions should be declared with the attribute pure. */
#if defined(DOXYGEN) #if defined(DOXYGEN)
#define MDBX_PURE_FUNCTION [[gnu::pure]] #define MDBX_PURE_FUNCTION [[gnu::pure]]
#elif __has_C23_or_CXX_attribute(gnu::pure) #elif __has_C23_or_CXX_attribute(gnu::pure) && \
(!defined(__apple_build_version__) || !defined(__clang_major__) || \
__clang_major__ > 17)
#define MDBX_PURE_FUNCTION [[gnu::pure]] #define MDBX_PURE_FUNCTION [[gnu::pure]]
#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \ #elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
(!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || \ (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || \
!defined(__cplusplus) || !__has_feature(cxx_exceptions)) !defined(__cplusplus) || __has_exceptions_disabled)
#define MDBX_PURE_FUNCTION __attribute__((__pure__)) #define MDBX_PURE_FUNCTION __attribute__((__pure__))
#else #else
#define MDBX_PURE_FUNCTION #define MDBX_PURE_FUNCTION
@ -278,11 +284,13 @@ typedef mode_t mdbx_mode_t;
* It does not make sense for a const function to return void. */ * It does not make sense for a const function to return void. */
#if defined(DOXYGEN) #if defined(DOXYGEN)
#define MDBX_CONST_FUNCTION [[gnu::const]] #define MDBX_CONST_FUNCTION [[gnu::const]]
#elif __has_C23_or_CXX_attribute(gnu::const) #elif __has_C23_or_CXX_attribute(gnu::const) && \
(!defined(__apple_build_version__) || !defined(__clang_major__) || \
__clang_major__ > 17)
#define MDBX_CONST_FUNCTION [[gnu::const]] #define MDBX_CONST_FUNCTION [[gnu::const]]
#elif (defined(__GNUC__) || __has_attribute(__const__)) && \ #elif (defined(__GNUC__) || __has_attribute(__const__)) && \
(!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || \ (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || \
!defined(__cplusplus) || !__has_feature(cxx_exceptions)) !defined(__cplusplus) || __has_exceptions_disabled)
#define MDBX_CONST_FUNCTION __attribute__((__const__)) #define MDBX_CONST_FUNCTION __attribute__((__const__))
#else #else
#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION #define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION