aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2025-02-20 14:08:11 +0000
committerThomas Schwinge <tschwinge@baylibre.com>2025-03-06 14:40:58 +0100
commit780932620d859fa9e0190edd0c408d0bedf9179e (patch)
tree930ab815e6d79c756b50e6b15b1b7c38b896481f
parentbf07f9a9832494a7270a7099195f47f2126e8e07 (diff)
downloadgcc-780932620d859fa9e0190edd0c408d0bedf9179e.zip
gcc-780932620d859fa9e0190edd0c408d0bedf9179e.tar.gz
gcc-780932620d859fa9e0190edd0c408d0bedf9179e.tar.bz2
Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && !__GTHREADS_CXX0X' configurations
libstdc++-v3/ * src/c++20/tzdb.cc [__GTHREADS && !__GTHREADS_CXX0X]: Use '__gnu_cxx::__mutex'. Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
-rw-r--r--libstdc++-v3/src/c++20/tzdb.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc
index 9cf9eec..1a1130f 100644
--- a/libstdc++-v3/src/c++20/tzdb.cc
+++ b/libstdc++-v3/src/c++20/tzdb.cc
@@ -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