On 06/01/17 17:06 +0000, Jonathan Wakely wrote:
On 04/01/17 15:42 +0000, Jonathan Wakely wrote:
FreeBSD 11 adds __cxa_thread_atexit to libc, so we should use that
instead of defining our own inferior version. This also avoids
multiple definitions of the symbol.

        PR libstdc++/78968
        * config.h.in: Regenerate.
        * configure: Likewise.
        * configure.ac: Check for __cxa_thread_atexit.
        * libsupc++/atexit_thread.cc [_GLIBCXX_HAVE___CXA_THREAD_ATEXIT]:
        Don't define __cxa_thread_atexit if libc provides it.

Tested powerpc64le-linux, committed to trunk.

This adds the check for freebsd cross-compilers. Tested by building
x86_64-unknown-freebsd11.0 on x86_64-uknown-linux-gnu.

Committed to trunk.

And this adjusts the testsuite so that the test which depends on
correct thread_local destruction order runs for FreeBSD.

Tested x86_64-linux and x86_64-freebsd11. Committed to trunk.


commit 9d592302e39c785eb27beb982768816ad60d6bc8
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Jan 9 11:42:21 2017 +0000

    Define testsuite macro for correct thread_local destructors
    
    	* testsuite/30_threads/condition_variable/members/3.cc: Use new macro
    	to detect correct thread_local destructors.
    	* testsuite/util/testsuite_hooks.h (CORRECT_THREAD_LOCAL_DTORS):
    	Define.

diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc
index 3f6885d..cedb2ab 100644
--- a/libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc
+++ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc
@@ -24,6 +24,7 @@
 #include <condition_variable>
 #include <thread>
 #include <mutex>
+#include <testsuite_hooks.h>
 
 std::mutex mx;
 std::condition_variable cv;
@@ -40,12 +41,12 @@ void func()
 {
   std::unique_lock<std::mutex> lock{mx};
   std::notify_all_at_thread_exit(cv, std::move(lock));
-#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
+#if CORRECT_THREAD_LOCAL_DTORS
   // Correct order of thread_local destruction needs __cxa_thread_atexit_impl
-  static thread_local Inc inc;
-#else
-  Inc inc;
+  // or similar support from libc.
+  static thread_local
 #endif
+  Inc inc;
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index 6baff15..6f064a4 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -81,6 +81,12 @@
 # define THROW(X) noexcept(false)
 #endif
 
+#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT || _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
+// Correct order of thread_local destruction needs __cxa_thread_atexit_impl
+// or similar support from libc.
+# define CORRECT_THREAD_LOCAL_DTORS 1
+#endif
+
 namespace __gnu_test
 {
   // All macros are defined in GLIBCXX_CONFIGURE_TESTSUITE and imported

Reply via email to