Define testsuite macro for correct thread_local destructors
authorJonathan Wakely <jwakely@redhat.com>
Mon, 9 Jan 2017 13:06:03 +0000 (13:06 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 9 Jan 2017 13:06:03 +0000 (13:06 +0000)
* 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.

From-SVN: r244226

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc
libstdc++-v3/testsuite/util/testsuite_hooks.h

index 79b12ccab09eb266b0602c4f512ac09dd4eaac7e..4111bae8342fefcab7b83e7d1419d44fda7510c8 100644 (file)
@@ -1,3 +1,10 @@
+2017-01-09  Jonathan Wakely  <jwakely@redhat.com>
+
+       * 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.
+
 2017-01-09  Jonathan Wakely  <jwakely@redhat.com>
            Aditya Kumar  <hiraditya@msn.com>
 
index 3f6885d1942b0a394ef5f67bd505040a1f59e074..cedb2abf2bf3ddd25346828f5628deee192b0189 100644 (file)
@@ -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()
index 6baff15e6955eabf3f3dcc07505699325c37316a..6f064a41c8588ffe84888a130c4126d3eb3db224 100644 (file)
 # 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