diff mbox series

PR libstdc++/84442 if _Exit isn't declared then use _exit instead

Message ID CAH6eHdQPnozbciQqBb_n09wUY3Cnym+m3A+8ZF4SAV+k0Vidcw@mail.gmail.com
State New
Headers show
Series PR libstdc++/84442 if _Exit isn't declared then use _exit instead | expand

Commit Message

Jonathan Wakely April 18, 2018, 11:15 a.m. UTC
Tested x86_64-linux, committed to trunk.
commit f02b9c3a2b9ffe78613ba57e61a4f48413144218
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Apr 18 12:15:16 2018 +0100

    PR libstdc++/84442 if _Exit isn't declared then use _exit instead
    
            PR libstdc++/84442
            * testsuite/30_threads/thread/cons/terminate.cc
            [!_GLIBCXX_USE_C99_STDLIB] : Use _exit or std::exit instead of _Exit.
diff mbox series

Patch

diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/terminate.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/terminate.cc
index 63c3b084c5c..cb6fc3eb120 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/terminate.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/terminate.cc
@@ -25,10 +25,19 @@ 
 #include <thread>
 #include <exception>
 #include <cstdlib>
+#if !_GLIBCXX_USE_C99_STDLIB && defined _GLIBCXX_HAVE_UNISTD_H
+# include <unistd.h>
+#endif
 
 void handle_terminate()
 {
+#if _GLIBCXX_USE_C99_STDLIB
   std::_Exit(0);
+#elif defined _GLIBCXX_HAVE_UNISTD_H
+  _exit(0);
+#else
+  std::exit(0);
+#endif
 }
 
 void f() { throw 1; }
@@ -38,7 +47,9 @@  test01()
 {
   std::set_terminate(handle_terminate);
   std::thread t(f);
+  // This should call the terminate handler and exit with zero status:
   t.join();
+  // Should not reach here:
   std::abort();
 }