mirror of
https://github.com/isar/libmdbx.git
synced 2025-04-19 03:27:45 +08:00
mdbx: переделка костыля namespace::attr
для MSVC и Apple.
This commit is contained in:
parent
ddea36c54a
commit
5815ff2ef7
41
mdbx.h
41
mdbx.h
@ -191,28 +191,31 @@ typedef mode_t mdbx_mode_t;
|
|||||||
|
|
||||||
#ifndef __has_c_attribute
|
#ifndef __has_c_attribute
|
||||||
#define __has_c_attribute(x) (0)
|
#define __has_c_attribute(x) (0)
|
||||||
|
#define __has_c_attribute_qualified(x) 0
|
||||||
|
#elif !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L
|
||||||
|
#define __has_c_attribute_qualified(x) 0
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
/* MSVC don't support `namespace::attr` syntax */
|
||||||
|
#define __has_c_attribute_qualified(x) 0
|
||||||
|
#else
|
||||||
|
#define __has_c_attribute_qualified(x) __has_c_attribute(x)
|
||||||
#endif /* __has_c_attribute */
|
#endif /* __has_c_attribute */
|
||||||
|
|
||||||
#ifndef __has_cpp_attribute
|
#ifndef __has_cpp_attribute
|
||||||
#define __has_cpp_attribute(x) 0
|
#define __has_cpp_attribute(x) 0
|
||||||
#endif /* __has_cpp_attribute */
|
#define __has_cpp_attribute_qualified(x) 0
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
#ifndef __has_CXX_attribute
|
/* MSVC don't support `namespace::attr` syntax */
|
||||||
#if defined(__cplusplus) && \
|
#define __has_cpp_attribute_qualified(x) 0
|
||||||
(!defined(_MSC_VER) || defined(__clang__) || _MSC_VER >= 1942)
|
|
||||||
#define __has_CXX_attribute(x) __has_cpp_attribute(x)
|
|
||||||
#else
|
#else
|
||||||
#define __has_CXX_attribute(x) 0
|
#define __has_cpp_attribute_qualified(x) __has_cpp_attribute(x)
|
||||||
#endif
|
#endif /* __has_cpp_attribute */
|
||||||
#endif /* __has_CXX_attribute */
|
|
||||||
|
|
||||||
#ifndef __has_C23_or_CXX_attribute
|
#ifndef __has_C23_or_CXX_attribute
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#define __has_C23_or_CXX_attribute(x) __has_CXX_attribute(x)
|
#define __has_C23_or_CXX_attribute(x) __has_cpp_attribute_qualified(x)
|
||||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ > 202311L
|
|
||||||
#define __has_C23_or_CXX_attribute(x) __has_c_attribute(x)
|
|
||||||
#else
|
#else
|
||||||
#define __has_C23_or_CXX_attribute(x) 0
|
#define __has_C23_or_CXX_attribute(x) __has_c_attribute_qualified(x)
|
||||||
#endif
|
#endif
|
||||||
#endif /* __has_C23_or_CXX_attribute */
|
#endif /* __has_C23_or_CXX_attribute */
|
||||||
|
|
||||||
@ -240,9 +243,7 @@ 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 */ || \
|
||||||
@ -266,7 +267,7 @@ typedef mode_t mdbx_mode_t;
|
|||||||
#elif defined(__GNUC__) || \
|
#elif defined(__GNUC__) || \
|
||||||
(__has_attribute(__pure__) && __has_attribute(__nothrow__))
|
(__has_attribute(__pure__) && __has_attribute(__nothrow__))
|
||||||
#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
|
#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
|
||||||
#elif __has_CXX_attribute(pure)
|
#elif __has_cpp_attribute(pure)
|
||||||
#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
|
#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
|
||||||
#else
|
#else
|
||||||
#define MDBX_NOTHROW_PURE_FUNCTION
|
#define MDBX_NOTHROW_PURE_FUNCTION
|
||||||
@ -284,9 +285,7 @@ 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 */ || \
|
||||||
@ -310,7 +309,7 @@ typedef mode_t mdbx_mode_t;
|
|||||||
#elif defined(__GNUC__) || \
|
#elif defined(__GNUC__) || \
|
||||||
(__has_attribute(__const__) && __has_attribute(__nothrow__))
|
(__has_attribute(__const__) && __has_attribute(__nothrow__))
|
||||||
#define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
|
#define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
|
||||||
#elif __has_CXX_attribute(const)
|
#elif __has_cpp_attribute_qualified(const)
|
||||||
#define MDBX_NOTHROW_CONST_FUNCTION [[const]]
|
#define MDBX_NOTHROW_CONST_FUNCTION [[const]]
|
||||||
#else
|
#else
|
||||||
#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
|
#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
|
||||||
|
Loading…
x
Reference in New Issue
Block a user