From: Jonathan Wakely Date: Thu, 20 Feb 2025 14:08:11 +0000 (+0000) Subject: Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && !__GTHREADS_CXX0X'... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1c87964c1efc84c89d49fd94804549ff94392f9e;p=thirdparty%2Fgcc.git 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 (cherry picked from commit 780932620d859fa9e0190edd0c408d0bedf9179e) --- diff --git a/libstdc++-v3/ChangeLog.omp b/libstdc++-v3/ChangeLog.omp index a3487cda929..7ede4aed966 100644 --- a/libstdc++-v3/ChangeLog.omp +++ b/libstdc++-v3/ChangeLog.omp @@ -1,5 +1,12 @@ 2025-03-19 Thomas Schwinge + Backported from trunk: + 2025-03-06 Jonathan Wakely + Thomas Schwinge + + * src/c++20/tzdb.cc [__GTHREADS && !__GTHREADS_CXX0X]: Use + '__gnu_cxx::__mutex'. + Backported from trunk: 2025-03-06 Thomas Schwinge diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index 7e8cce7ce8c..f6a36f422e1 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -35,6 +35,9 @@ #include // atomic, atomic #include // atomic> #include // mutex +#if defined __GTHREADS && ! defined _GLIBCXX_HAS_GTHREADS +# include // __gnu_cxx::__mutex +#endif #include // 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