[PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation
Ben Craig via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 30 12:57:31 PDT 2016
bcraig added inline comments.
================
Comment at: src/cxa_thread_atexit.cpp:47
@@ +46,3 @@
+ void run_dtors(void* ptr) {
+ if (pthread_setspecific(dtors, ptr) != 0) {
+ abort_message("pthread_setspecific() failed during thread_local destruction");
----------------
Why are we doing this? I can see it being a little useful when debugging / developing, so that you get an early warning that something has gone wrong, but it seems like this will always be setting a value to the value it already has.
================
Comment at: src/cxa_thread_atexit.cpp:54
@@ +53,3 @@
+ // __cxa_thread_atexit() is called during the loop.
+ while (auto elem = static_cast<DtorList*>(pthread_getspecific(dtors))) {
+ if (pthread_setspecific(dtors, elem->next) != 0) {
----------------
Maybe this concern is unfounded, but I'm not overly fond of pthread_getspecific and setspecific in a loop. I've always been under the impression that those functions are rather slow. Could we add a layer of indirection so that we don't need to call getspecific and setspecific so often? Basically make the pointer that is directly stored in TLS an immutable pointer to pointer.
http://reviews.llvm.org/D21803
More information about the cfe-commits
mailing list