[PATCH] [libcxxabi] Add __cxa_thread_atexit for TLS support on Linux.
Dan Albert
danalbert at google.com
Wed Dec 17 12:17:53 PST 2014
================
Comment at: src/cxa_thread_atexit.cpp:18-20
@@ +17,5 @@
+ void *dso_symbol) throw() {
+ extern int __cxa_thread_atexit_impl(void (*)(void *), void *, void *);
+ return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
+}
+
----------------
majnemer wrote:
> The only libc which provides `__cxa_thread_atexit_impl` is glibc. Other libc implementations on linux do not and it doesn't seem available on the BSDs.
>
> I think it makes sense to forward to `__cxa_thread_atexit_impl` if the symbol exists, otherwise we need to have a definition of `__cxa_thread_atexit` which can do the real heavy lifting.
Oops. I added a guard to the header to make sure this was only there on Linux but forgot to do the same here and in the test.
BTW, glibc is the only one that supports it for now, but we're working on adding it to Bionic.
As for non-glibc libc implementations for non-Android Linux, are you thinking about newlib/musl? Those implementations would just need to add support for this if they want this kind of TLS; I don't think we need to add it here.
================
Comment at: test/cxa_thread_atexit_test.cpp:15
@@ +14,3 @@
+
+extern "C" int __cxa_thread_atexit_impl(void (*dtor)(void *), void *obj,
+ void *dso_symbol) {
----------------
jroelofs wrote:
> What about when the libc provides this symbol? Is it normally weak?
The dynamic linker satisfies the symbol from the main executable first, even if there is a strong symbol in another shared object.
================
Comment at: test/cxa_thread_atexit_test.cpp:16
@@ +15,3 @@
+extern "C" int __cxa_thread_atexit_impl(void (*dtor)(void *), void *obj,
+ void *dso_symbol) {
+ assert(dtor == reinterpret_cast<void (*)(void *)>(1));
----------------
jroelofs wrote:
> to have the same signature, this needs throw().
This is the _impl function, which doesn't have the `throw()` specifier (since it's C code). I suppose the `throw()` on the non-impl version of this is actually unnecessary since it's in `extern "C"`. I had just match the Apple functions above my decl in cxxabi.h.
http://reviews.llvm.org/D6708
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list