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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to