tavianator 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");
----------------
bcraig wrote:
> 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.
pthread_key destructors run after the key is set to null. I re-set it here
since the loop reads the key.
================
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) {
----------------
bcraig wrote:
> 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.
Sure, I can do that. Would reduce the number of setspecific() calls in
__cxa_thread_atexit too.
http://reviews.llvm.org/D21803
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits