mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-29 23:19:20 +08:00
mdbx: использование __has_c_attribute()
и __has_cxx_attribute()
, добавление __has_C23_or_CXX_attribute()
.
This commit is contained in:
parent
22233b0991
commit
bfce1cd24d
85
mdbx.h
85
mdbx.h
@ -189,10 +189,33 @@ typedef mode_t mdbx_mode_t;
|
||||
#define __has_attribute(x) (0)
|
||||
#endif /* __has_attribute */
|
||||
|
||||
#ifndef __has_c_attribute
|
||||
#define __has_c_attribute(x) (0)
|
||||
#endif /* __has_c_attribute */
|
||||
|
||||
#ifndef __has_cpp_attribute
|
||||
#define __has_cpp_attribute(x) 0
|
||||
#endif /* __has_cpp_attribute */
|
||||
|
||||
#ifndef __has_CXX_attribute
|
||||
#if defined(__cplusplus) && \
|
||||
(!defined(_MSC_VER) || defined(__clang__) || _MSC_VER >= 1942)
|
||||
#define __has_CXX_attribute(x) __has_cpp_attribute(x)
|
||||
#else
|
||||
#define __has_CXX_attribute(x) 0
|
||||
#endif
|
||||
#endif /* __has_CXX_attribute */
|
||||
|
||||
#ifndef __has_C23_or_CXX_attribute
|
||||
#if defined(__cplusplus)
|
||||
#define __has_C23_or_CXX_attribute(x) __has_CXX_attribute(x)
|
||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ > 202311L
|
||||
#define __has_C23_or_CXX_attribute(x) __has_c_attribute(x)
|
||||
#else
|
||||
#define __has_C23_or_CXX_attribute(x) 0
|
||||
#endif
|
||||
#endif /* __has_C23_or_CXX_attribute */
|
||||
|
||||
#ifndef __has_feature
|
||||
#define __has_feature(x) (0)
|
||||
#endif /* __has_feature */
|
||||
@ -213,15 +236,12 @@ typedef mode_t mdbx_mode_t;
|
||||
* These functions should be declared with the attribute pure. */
|
||||
#if defined(DOXYGEN)
|
||||
#define MDBX_PURE_FUNCTION [[gnu::pure]]
|
||||
#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
|
||||
(!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ \
|
||||
|| !defined(__cplusplus) || !__has_feature(cxx_exceptions))
|
||||
#define MDBX_PURE_FUNCTION __attribute__((__pure__))
|
||||
#elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
|
||||
#define MDBX_PURE_FUNCTION
|
||||
#elif defined(__cplusplus) && __has_cpp_attribute(gnu::pure) && \
|
||||
(!defined(__clang__) || !__has_feature(cxx_exceptions))
|
||||
#elif __has_C23_or_CXX_attribute(gnu::pure)
|
||||
#define MDBX_PURE_FUNCTION [[gnu::pure]]
|
||||
#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
|
||||
(!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || \
|
||||
!defined(__cplusplus) || !__has_feature(cxx_exceptions))
|
||||
#define MDBX_PURE_FUNCTION __attribute__((__pure__))
|
||||
#else
|
||||
#define MDBX_PURE_FUNCTION
|
||||
#endif /* MDBX_PURE_FUNCTION */
|
||||
@ -231,22 +251,16 @@ typedef mode_t mdbx_mode_t;
|
||||
* that is compatible to CLANG and proposed [[pure]]. */
|
||||
#if defined(DOXYGEN)
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
|
||||
#elif defined(__GNUC__) || \
|
||||
(__has_attribute(__pure__) && __has_attribute(__nothrow__))
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
|
||||
#elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
|
||||
#if __has_cpp_attribute(pure)
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
|
||||
#else
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION
|
||||
#endif
|
||||
#elif defined(__cplusplus) && __has_cpp_attribute(gnu::pure)
|
||||
#if __has_cpp_attribute(gnu::nothrow)
|
||||
#elif __has_C23_or_CXX_attribute(gnu::pure)
|
||||
#if __has_C23_or_CXX_attribute(gnu::nothrow)
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
|
||||
#else
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure]]
|
||||
#endif
|
||||
#elif defined(__cplusplus) && __has_cpp_attribute(pure)
|
||||
#elif defined(__GNUC__) || \
|
||||
(__has_attribute(__pure__) && __has_attribute(__nothrow__))
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
|
||||
#elif __has_CXX_attribute(pure)
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
|
||||
#else
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION
|
||||
@ -264,15 +278,12 @@ typedef mode_t mdbx_mode_t;
|
||||
* It does not make sense for a const function to return void. */
|
||||
#if defined(DOXYGEN)
|
||||
#define MDBX_CONST_FUNCTION [[gnu::const]]
|
||||
#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
|
||||
(!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ \
|
||||
|| !defined(__cplusplus) || !__has_feature(cxx_exceptions))
|
||||
#define MDBX_CONST_FUNCTION __attribute__((__const__))
|
||||
#elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
|
||||
#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
|
||||
#elif defined(__cplusplus) && __has_cpp_attribute(gnu::const) && \
|
||||
(!defined(__clang__) || !__has_feature(cxx_exceptions))
|
||||
#elif __has_C23_or_CXX_attribute(gnu::const)
|
||||
#define MDBX_CONST_FUNCTION [[gnu::const]]
|
||||
#elif (defined(__GNUC__) || __has_attribute(__const__)) && \
|
||||
(!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || \
|
||||
!defined(__cplusplus) || !__has_feature(cxx_exceptions))
|
||||
#define MDBX_CONST_FUNCTION __attribute__((__const__))
|
||||
#else
|
||||
#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
|
||||
#endif /* MDBX_CONST_FUNCTION */
|
||||
@ -282,18 +293,16 @@ typedef mode_t mdbx_mode_t;
|
||||
* that is compatible to CLANG and future [[const]]. */
|
||||
#if defined(DOXYGEN)
|
||||
#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
|
||||
#elif __has_C23_or_CXX_attribute(gnu::const)
|
||||
#if __has_C23_or_CXX_attribute(gnu::nothrow)
|
||||
#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
|
||||
#else
|
||||
#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const]]
|
||||
#endif
|
||||
#elif defined(__GNUC__) || \
|
||||
(__has_attribute(__const__) && __has_attribute(__nothrow__))
|
||||
#define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
|
||||
#elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
|
||||
#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
|
||||
#elif defined(__cplusplus) && __has_cpp_attribute(gnu::const)
|
||||
#if __has_cpp_attribute(gnu::nothrow)
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::const, gnu::nothrow]]
|
||||
#else
|
||||
#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::const]]
|
||||
#endif
|
||||
#elif defined(__cplusplus) && __has_cpp_attribute(const)
|
||||
#elif __has_CXX_attribute(const)
|
||||
#define MDBX_NOTHROW_CONST_FUNCTION [[const]]
|
||||
#else
|
||||
#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
|
||||
@ -3848,7 +3857,7 @@ mdbx_env_get_maxvalsize_ex(const MDBX_env *env, MDBX_db_flags_t flags);
|
||||
/** \deprecated Please use \ref mdbx_env_get_maxkeysize_ex()
|
||||
* and/or \ref mdbx_env_get_maxvalsize_ex()
|
||||
* \ingroup c_statinfo */
|
||||
MDBX_DEPRECATED MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int
|
||||
MDBX_NOTHROW_PURE_FUNCTION MDBX_DEPRECATED LIBMDBX_API int
|
||||
mdbx_env_get_maxkeysize(const MDBX_env *env);
|
||||
|
||||
/** \brief Returns maximal size of key-value pair to fit in a single page
|
||||
|
12
mdbx.h++
12
mdbx.h++
@ -924,7 +924,7 @@ struct LIBMDBX_API_TYPE slice : public ::MDBX_val {
|
||||
/// \param [in] ignore_spaces If `true` function will skips spaces surrounding
|
||||
/// (before, between and after) a encoded bytes. However, spaces should not
|
||||
/// break a pair of characters encoding a single byte.
|
||||
inline MDBX_NOTHROW_PURE_FUNCTION bool
|
||||
MDBX_NOTHROW_PURE_FUNCTION inline bool
|
||||
is_hex(bool ignore_spaces = false) const noexcept;
|
||||
|
||||
/// \brief Checks whether the content of the slice is a
|
||||
@ -932,7 +932,7 @@ struct LIBMDBX_API_TYPE slice : public ::MDBX_val {
|
||||
/// \param [in] ignore_spaces If `true` function will skips spaces surrounding
|
||||
/// (before, between and after) a encoded bytes. However, spaces should not
|
||||
/// break a code group of characters.
|
||||
inline MDBX_NOTHROW_PURE_FUNCTION bool
|
||||
MDBX_NOTHROW_PURE_FUNCTION inline bool
|
||||
is_base58(bool ignore_spaces = false) const noexcept;
|
||||
|
||||
/// \brief Checks whether the content of the slice is a
|
||||
@ -940,7 +940,7 @@ struct LIBMDBX_API_TYPE slice : public ::MDBX_val {
|
||||
/// \param [in] ignore_spaces If `true` function will skips spaces surrounding
|
||||
/// (before, between and after) a encoded bytes. However, spaces should not
|
||||
/// break a code group of characters.
|
||||
inline MDBX_NOTHROW_PURE_FUNCTION bool
|
||||
MDBX_NOTHROW_PURE_FUNCTION inline bool
|
||||
is_base64(bool ignore_spaces = false) const noexcept;
|
||||
|
||||
inline void swap(slice &other) noexcept;
|
||||
@ -5876,17 +5876,17 @@ slice::base64_decode(bool ignore_spaces, const ALLOCATOR &allocator) const {
|
||||
.as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
|
||||
}
|
||||
|
||||
inline MDBX_NOTHROW_PURE_FUNCTION bool
|
||||
MDBX_NOTHROW_PURE_FUNCTION inline bool
|
||||
slice::is_hex(bool ignore_spaces) const noexcept {
|
||||
return !from_hex(*this, ignore_spaces).is_erroneous();
|
||||
}
|
||||
|
||||
inline MDBX_NOTHROW_PURE_FUNCTION bool
|
||||
MDBX_NOTHROW_PURE_FUNCTION inline bool
|
||||
slice::is_base58(bool ignore_spaces) const noexcept {
|
||||
return !from_base58(*this, ignore_spaces).is_erroneous();
|
||||
}
|
||||
|
||||
inline MDBX_NOTHROW_PURE_FUNCTION bool
|
||||
MDBX_NOTHROW_PURE_FUNCTION inline bool
|
||||
slice::is_base64(bool ignore_spaces) const noexcept {
|
||||
return !from_base64(*this, ignore_spaces).is_erroneous();
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ struct actor_params_pod {
|
||||
// FIXME: TODO
|
||||
return 0;
|
||||
}
|
||||
static MDBX_PURE_FUNCTION uint64_t serial_mask(unsigned bits) {
|
||||
MDBX_PURE_FUNCTION static uint64_t serial_mask(unsigned bits) {
|
||||
assert(bits > 0 && bits <= 64);
|
||||
return (~(uint64_t)0u) >> (64 - bits);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user