]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && !__GTHREADS_CXX0X'...
authorJonathan Wakely <jwakely@redhat.com>
Thu, 20 Feb 2025 14:08:11 +0000 (14:08 +0000)
committerThomas Schwinge <tschwinge@baylibre.com>
Wed, 19 Mar 2025 08:59:38 +0000 (09:59 +0100)
libstdc++-v3/
* src/c++20/tzdb.cc [__GTHREADS && !__GTHREADS_CXX0X]: Use
'__gnu_cxx::__mutex'.

Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
(cherry picked from commit 780932620d859fa9e0190edd0c408d0bedf9179e)

libstdc++-v3/ChangeLog.omp
libstdc++-v3/src/c++20/tzdb.cc

index a3487cda929108aa3dd8ac7972c61b16208415ee..7ede4aed9664aa2274d6838c4f91f62d58c10038 100644 (file)
@@ -1,5 +1,12 @@
 2025-03-19  Thomas Schwinge  <tschwinge@baylibre.com>
 
+       Backported from trunk:
+       2025-03-06  Jonathan Wakely  <jwakely@redhat.com>
+                   Thomas Schwinge  <tschwinge@baylibre.com>
+
+       * src/c++20/tzdb.cc [__GTHREADS && !__GTHREADS_CXX0X]: Use
+       '__gnu_cxx::__mutex'.
+
        Backported from trunk:
        2025-03-06  Thomas Schwinge  <tschwinge@baylibre.com>
 
index 7e8cce7ce8cf57be9a45dc62be028b02ff5af2ee..f6a36f422e1d78577a3fe91e9bf9e1b28d428c79 100644 (file)
@@ -35,6 +35,9 @@
 #include <atomic>     // atomic<T*>, atomic<int>
 #include <memory>     // atomic<shared_ptr<T>>
 #include <mutex>      // mutex
+#if defined __GTHREADS && ! defined _GLIBCXX_HAS_GTHREADS
+# include <ext/concurrence.h> // __gnu_cxx::__mutex
+#endif
 #include <filesystem> // filesystem::read_symlink
 
 #ifndef _AIX
@@ -97,11 +100,18 @@ namespace std::chrono
 {
   namespace
   {
-#if ! USE_ATOMIC_SHARED_PTR
 #ifndef __GTHREADS
     // Dummy no-op mutex type for single-threaded targets.
     struct mutex { void lock() { } void unlock() { } };
+#elif ! defined _GLIBCXX_HAS_GTHREADS
+    // Use __gnu_cxx::__mutex if std::mutex isn't available.
+    using mutex = __gnu_cxx::__mutex;
+# if ! USE_ATOMIC_SHARED_PTR && defined __GTHREAD_MUTEX_INIT
+#  error "TODO: __gnu_cxx::__mutex can't be initialized with 'constinit'"
+# endif
 #endif
+
+#if ! USE_ATOMIC_SHARED_PTR
     inline mutex& list_mutex()
     {
 #ifdef __GTHREAD_MUTEX_INIT