Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions libcxxabi/include/__cxxabi_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,15 @@
# define _LIBCXXABI_DISABLE_POINTER_FIELD_PROTECTION
#endif

// On Apple, Clang generates calls to _tlv_atexit and __cxa_thread_atexit is defined
// in libc instead. AIX uses a different mechanism for registering thread local
// destructors (__pt_atexit_np).
//
// On other platforms, libc++abi provides __cxa_thread_atexit.
#if defined(__APPLE__) || defined(_AIX)
# define _LIBCXXABI_DEFINE_THREAD_ATEXIT 0
#else
# define _LIBCXXABI_DEFINE_THREAD_ATEXIT 1
#endif

#endif // ____CXXABI_CONFIG_H
4 changes: 2 additions & 2 deletions libcxxabi/include/cxxabi.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ __cxa_decrement_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;
extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() _LIBCXXABI_NOEXCEPT;
extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() _LIBCXXABI_NOEXCEPT;

#if defined(__linux__) || defined(__Fuchsia__)
// Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.
#if _LIBCXXABI_DEFINE_THREAD_ATEXIT
// Register a thread local destructor. This is not yet an official part of the Itanium ABI.
// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,
void *) _LIBCXXABI_NOEXCEPT;
Expand Down
8 changes: 1 addition & 7 deletions libcxxabi/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(LIBCXXABI_SOURCES
cxa_handlers.cpp
cxa_vector.cpp
cxa_virtual.cpp
cxa_thread_atexit.cpp
# C++ STL files
stdlib_exception.cpp
stdlib_stdexcept.cpp
Expand Down Expand Up @@ -36,13 +37,6 @@ else()
)
endif()

if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA) AND NOT (APPLE OR CYGWIN)
AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "AIX"))
list(APPEND LIBCXXABI_SOURCES
cxa_thread_atexit.cpp
)
endif()

set(LIBCXXABI_HEADERS
../include/cxxabi.h
)
Expand Down
18 changes: 11 additions & 7 deletions libcxxabi/src/cxa_thread_atexit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
//
//===----------------------------------------------------------------------===//

#include "abort_message.h"
#include "cxxabi.h"

#if !defined(_LIBCXXABI_HAS_NO_THREADS) && _LIBCXXABI_DEFINE_THREAD_ATEXIT

#include <__thread/support.h>
#ifndef _LIBCXXABI_HAS_NO_THREADS
#include <stdlib.h>

#include "abort_message.h"

#if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
#endif

#include <stdlib.h>

namespace __cxxabiv1 {

Expand Down Expand Up @@ -106,7 +108,6 @@ namespace {

#endif // HAVE___CXA_THREAD_ATEXIT_IMPL

#if defined(__linux__) || defined(__Fuchsia__)
extern "C" {
Comment thread
whitequark marked this conversation as resolved.

_LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(Dtor dtor, void* obj, void* dso_symbol) throw() {
Expand Down Expand Up @@ -141,6 +142,9 @@ extern "C" {
}
#endif // HAVE___CXA_THREAD_ATEXIT_IMPL
}

} // extern "C"
#endif // defined(__linux__) || defined(__Fuchsia__)

} // namespace __cxxabiv1

#endif // !defined(_LIBCXXABI_HAS_NO_THREADS) && _LIBCXXABI_DEFINE_THREAD_ATEXIT
Loading