mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 01:34:12 +08:00
mdbx: never use modern __cxa_thread_atexit()
on Apple's OSes.
This commit is contained in:
parent
dd01aabaeb
commit
6d85e35876
@ -157,12 +157,12 @@
|
||||
#define nullptr NULL
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(_DARWIN_C_SOURCE)
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <TargetConditionals.h>
|
||||
#ifndef MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
#define MAC_OS_X_VERSION_MIN_REQUIRED 1070 /* Mac OS X 10.7, 2011 */
|
||||
#endif
|
||||
#include <TargetConditionals.h>
|
||||
#endif /* Apple OSX & iOS */
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
|
||||
|
71
src/core.c
71
src/core.c
@ -1269,55 +1269,50 @@ rthc_compare_and_clean(const void *rthc, const uint64_t signature) {
|
||||
|
||||
static __inline int rthc_atexit(void (*dtor)(void *), void *obj,
|
||||
void *dso_symbol) {
|
||||
int rc = MDBX_ENOSYS;
|
||||
#ifndef MDBX_HAVE_CXA_THREAD_ATEXIT_IMPL
|
||||
#if defined(LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL) || \
|
||||
defined(HAVE___CXA_THREAD_ATEXIT_IMPL) || __GLIBC_PREREQ(2, 18) || \
|
||||
defined(ANDROID)
|
||||
#define MDBX_HAVE_CXA_THREAD_ATEXIT_IMPL 1
|
||||
#else
|
||||
#define MDBX_HAVE_CXA_THREAD_ATEXIT_IMPL 0
|
||||
#endif
|
||||
#endif /* MDBX_HAVE_CXA_THREAD_ATEXIT_IMPL */
|
||||
|
||||
#if defined(__APPLE__) || defined(_DARWIN_C_SOURCE)
|
||||
#if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || !defined(MAC_OS_X_VERSION_10_7)
|
||||
#error \
|
||||
"The <AvailabilityMacros.h> should be included and MAC_OS_X_VERSION_MIN_REQUIRED must be defined"
|
||||
#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
|
||||
#ifndef MDBX_HAVE_CXA_THREAD_ATEXIT
|
||||
#if defined(LIBCXXABI_HAS_CXA_THREAD_ATEXIT) || \
|
||||
defined(HAVE___CXA_THREAD_ATEXIT)
|
||||
#define MDBX_HAVE_CXA_THREAD_ATEXIT 1
|
||||
#elif !MDBX_HAVE_CXA_THREAD_ATEXIT_IMPL && \
|
||||
(defined(__linux__) || defined(__gnu_linux__))
|
||||
#define MDBX_HAVE_CXA_THREAD_ATEXIT 1
|
||||
#else
|
||||
#define MDBX_HAVE_CXA_THREAD_ATEXIT 0
|
||||
#endif
|
||||
#endif /* MDBX_HAVE_CXA_THREAD_ATEXIT */
|
||||
|
||||
int rc = MDBX_ENOSYS;
|
||||
#if MDBX_HAVE_CXA_THREAD_ATEXIT_IMPL && !MDBX_HAVE_CXA_THREAD_ATEXIT
|
||||
#define __cxa_thread_atexit __cxa_thread_atexit_impl
|
||||
#endif
|
||||
#if MDBX_HAVE_CXA_THREAD_ATEXIT || defined(__cxa_thread_atexit)
|
||||
extern int __cxa_thread_atexit(void (*dtor)(void *), void *obj,
|
||||
void *dso_symbol) MDBX_WEAK_IMPORT_ATTRIBUTE;
|
||||
if (&__cxa_thread_atexit)
|
||||
rc = __cxa_thread_atexit(dtor, obj, dso_symbol);
|
||||
#elif defined(__APPLE__) || defined(_DARWIN_C_SOURCE)
|
||||
extern void _tlv_atexit(void (*termfunc)(void *objAddr), void *objAddr)
|
||||
__attribute__((__weak__, __weak_import__));
|
||||
if (rc && &_tlv_atexit) {
|
||||
MDBX_WEAK_IMPORT_ATTRIBUTE;
|
||||
if (&_tlv_atexit) {
|
||||
(void)dso_symbol;
|
||||
_tlv_atexit(dtor, obj);
|
||||
rc = 0;
|
||||
}
|
||||
#elif !defined(MDBX_HAVE_CXA_THREAD_ATEXIT)
|
||||
#define MDBX_HAVE_CXA_THREAD_ATEXIT 1
|
||||
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */
|
||||
#endif /* Apple */
|
||||
|
||||
#if defined(MDBX_HAVE_CXA_THREAD_ATEXIT) && MDBX_HAVE_CXA_THREAD_ATEXIT
|
||||
extern int __cxa_thread_atexit(void (*dtor)(void *), void *obj,
|
||||
void *dso_symbol)
|
||||
#ifdef WEAK_IMPORT_ATTRIBUTE
|
||||
WEAK_IMPORT_ATTRIBUTE
|
||||
#elif defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED >= 1020 && \
|
||||
((__has_attribute(__weak__) && __has_attribute(__weak_import__)) || \
|
||||
(defined(__GNUC__) && __GNUC__ >= 4))
|
||||
__attribute__((__weak__, __weak_import__))
|
||||
#elif (__has_attribute(__weak__) || (defined(__GNUC__) && __GNUC__ >= 4)) && \
|
||||
!defined(MAC_OS_X_VERSION_MIN_REQUIRED)
|
||||
__attribute__((__weak__))
|
||||
#endif
|
||||
;
|
||||
if (rc && &__cxa_thread_atexit)
|
||||
rc = __cxa_thread_atexit(dtor, obj, dso_symbol);
|
||||
#elif __GLIBC_PREREQ(2, 18) || defined(ANDROID) || defined(__linux__) || \
|
||||
defined(__gnu_linux__)
|
||||
extern int __cxa_thread_atexit_impl(void (*dtor)(void *), void *obj,
|
||||
void *dso_symbol)
|
||||
__attribute__((__weak__));
|
||||
if (rc && &__cxa_thread_atexit_impl)
|
||||
rc = __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
|
||||
#else
|
||||
(void)dtor;
|
||||
(void)obj;
|
||||
(void)dso_symbol;
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user