Hi Mike, Thanks a lot for the review!
On Sunday 22 March 2026 at 15:03:00 +0000, Mike Crowe wrote: > Did you consider adding generic __gthread_mutex_clocklock(), etc. functions > that take the clock ID as a parameter as direct wrappers of the POSIX > functions? I think this would have made the change less invasive and would > allow other clocks to be supported in the future too. I did consider a generic clock parameter, but clockid_t is a POSIX/Linux type -- it doesn't exist on non-pthreads platforms (which is the whole motivation for routing through gthreads). To make it portable we'd need to define a gthread-level clock type with its own enum values, and then translate those to the platform-specific ones in each backend (e.g. gthr-posix.h maps to clockid_t, FreeRTOS maps to whatever it uses). Given that we currently only support two clocks (system and steady), that abstraction layer felt like unnecessary complexity. If more clocks become relevant in the future (CLOCK_TAI, CLOCK_BOOTTIME), introducing a __gthread_clockid_t abstraction at that point would make more sense -- and the steady-specific functions could be trivially reimplemented in terms of it. > If FreeRTOS also supports read-write locks then equivalent wrapper > functions will be required for pthread_rwlock_clockrdlock and > pthread_rwlock_clockwrlock. FreeRTOS doesn't have native rwlock support, so it wouldn't benefit from rwlock wrappers. That said, other gthread backends might, so I agree it could be worth adding. Would a follow-up patch be acceptable for that, or would you prefer it included here? > IMO _GTHREAD_USE_COND_TIMEDWAIT_STEADY (or equivalent) being defined > implies that __gthread_cond_timedwait_steady can be called whereas > _GTHREAD_USE_PTHREAD_COND_CLOCKWAIT (or similar) implies that > pthread_cond_clockwait() can be called. I'd like to avoid _GTHREAD_USE_PTHREAD_* if possible as it leaks the implementation through the abstraction -- the whole point of gthreads is that consumers shouldn't need to know whether pthreads is the backend. The existing precedent is _GTHREAD_USE_MUTEX_TIMEDLOCK: it signals that __gthread_mutex_timedlock() is available without mentioning pthread_mutex_timedlock in the flag name. gthr-posix.h defines it by checking _POSIX_TIMEOUTS, but the flag itself is implementation- agnostic -- a FreeRTOS backend could define it too based on its own capabilities. _GTHREAD_USE_COND_TIMEDWAIT_STEADY follows the same pattern: it says "the gthread layer can do steady-clock condvar waits" without prescribing how. gthr-posix.h implements it via pthread_cond_clockwait; a FreeRTOS backend would do something different. > For example, a __gthread_cond_timedwait_steady implementation that called > Bionic's pthread_cond_timedwait_relative_np would define > _GTHREAD_USE_COND_TIMEDWAIT_STEADY and > _GTHREAD_USE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP but not > _GTHREAD_USE_PTHREAD_COND_CLOCKWAIT. I'm not opposed to adding a non-gthread flag used only inside gthr-posix.h that selects which pthread function to call when implementing __gthread_cond_timedwait_steady. But we currently have only one implementation. That approach remains available to us in the future if we need to select between multiple underlying pthread functions. > I think that it should be up to libgcc to define this when necessary and > not libstdc++. It's libgcc that is ultimately responsible for knowing > whether it is providing __gthread_cond_timedwait_steady() or not and > another language standard library may want to make use of it too. I modelled it after _GTHREAD_USE_MUTEX_TIMEDLOCK, which is detected by libstdc++'s configure (acinclude.m4), defined in libstdc++'s config.h.in, and then consumed by gthr-posix.h. So I followed the same pattern for _GTHREAD_USE_COND_TIMEDWAIT_STEADY. If there's a preferred way to have libgcc own the detection instead, I'm happy to restructure it -- I just wasn't sure how to do that given there's no POSIX feature-test macro for pthread_cond_clockwait the way _POSIX_TIMEOUTS exists for timedlock. Thanks, Nick On Sun, Mar 22, 2026 at 3:03 PM Mike Crowe <[email protected]> wrote: > > Hi Nick, > > On Sunday 22 March 2026 at 12:38:39 +0000, Nick Nikolov wrote: > > [thread.req.timing] §32.2.4p3 recommends that _for functions use a steady > > clock. libstdc++ honours this for timed mutexes only when > > _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK is defined, and in that case calls > > pthread_mutex_clocklock directly — bypassing the gthread abstraction. > > Similarly, condition_variable calls pthread_cond_clockwait directly > > when _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT is defined. > > I tried to do something like this in my original patch but at that point > there were good reasons[1] not to. I suspect that those reasons have mostly > expired over the last decade. The clocklock/clockwait functions are here to > stay now as they are in POSIX. > > > Non-pthreads gthread backends (eg. FreeRTOS) cannot enable > > this flag, so they're stuck with system_clock even if their > > __gthread_mutex_timedlock uses a monotonic clock internally. > > > > This patch adds __gthread_mutex_timedlock_steady, > > __gthread_recursive_mutex_timedlock_steady, and > > __gthread_cond_timedwait_steady to the gthread API as optional > > extensions. All direct pthread_mutex_clocklock / pthread_cond_clockwait > > calls in libstdc++ are replaced with calls through these new gthread > > functions. The old _GLIBCXX_USE_PTHREAD_* flags are replaced with > > _GTHREAD_USE_* flags that default to 0 when not set. > > Did you consider adding generic __gthread_mutex_clocklock(), etc. functions > that take the clock ID as a parameter as direct wrappers of the POSIX > functions? I think this would have made the change less invasive and would > allow other clocks to be supported in the future too. > > In theory std::chrono::tai_clock could be mapped to CLOCK_TAI one day and > the distinction between CLOCK_MONOTONIC and CLOCK_BOOTTIME could be > important for some applications. Who knows, perhaps someone will want their > phone to wake up when a condition variable wait times out using > CLOCK_BOOTTIME_ALARM! glibc is currently happy to pass arbitrary clocks all > the way through to its lowest level before just failing if the clock is > anything other than CLOCK_REALTIME or CLOCK_MONOTONIC though since > FUTEX_BITSET_MATCH_ANY only uses a single bit to select the clock. > > Having said all that, I'm happy with whatever interface Jonathan prefers. > > If FreeRTOS also supports read-write locks then equivalent wrapper > functions will be required for pthread_rwlock_clockrdlock and > pthread_rwlock_clockwrlock. > > (More patch review below.) > > > Bootstrapped and regression tested on x86_64-pc-linux-gnu. > > > > libgcc/ChangeLog: > > > > * gthr.h: Document new optional steady-clock gthread extensions. > > * gthr-posix.h (_GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY): New flag, > > default 0. > > (_GTHREAD_USE_COND_TIMEDWAIT_STEADY): Likewise. > > (__gthread_mutex_timedlock_steady): New function. > > (__gthread_recursive_mutex_timedlock_steady): New function. > > (__gthread_cond_timedwait_steady): New function. > > > > libstdc++-v3/ChangeLog: > > > > * acinclude.m4 (GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT): Define > > _GTHREAD_USE_COND_TIMEDWAIT_STEADY instead of > > _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT. > > (GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK): Define > > _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY instead of > > _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK. > > * config.h.in: Regenerate. > > * configure: Regenerate. > > * include/bits/std_mutex.h (__condvar::_M_wait_until_steady): Rename > > from wait_until, use __gthread_cond_timedwait_steady. > > * include/std/condition_variable: Replace > > _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT with > > _GTHREAD_USE_COND_TIMEDWAIT_STEADY throughout. > > * include/std/mutex: Replace _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK > > with _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY throughout. Rename > > _M_clocklock to _M_steadylock. > > * src/c++20/atomic.cc (__cond_wait_until): Use > > _GTHREAD_USE_COND_TIMEDWAIT_STEADY and _M_wait_until_steady. > > * testsuite/30_threads/condition_variable/members/116586.cc: > > Update comment. > > * testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc: > > Update comment. > > * testsuite/30_threads/timed_mutex/try_lock_until/116586.cc: > > Update comment. > > > > Signed-off-by: Nick Nikolov <[email protected]> > > --- > > Note: I don't have GCC write access. If approved, I'd appreciate > > a maintainer committing this on my behalf. > > > > Changes in v2: > > - Rename wait_until_steady to _M_wait_until_steady (Jonathan Wakely) > > > > libgcc/gthr-posix.h | 47 +++++++++++++++++++ > > libgcc/gthr.h | 22 +++++++++ > > libstdc++-v3/acinclude.m4 | 16 +++++-- > > libstdc++-v3/config.h.in | 14 +++--- > > libstdc++-v3/configure | 20 ++++++-- > > libstdc++-v3/include/bits/std_mutex.h | 8 ++-- > > libstdc++-v3/include/std/condition_variable | 10 ++-- > > libstdc++-v3/include/std/mutex | 19 ++++---- > > libstdc++-v3/src/c++20/atomic.cc | 4 +- > > .../condition_variable/members/116586.cc | 2 +- > > .../try_lock_until/116586.cc | 2 +- > > .../timed_mutex/try_lock_until/116586.cc | 2 +- > > 12 files changed, 127 insertions(+), 39 deletions(-) > > > > diff --git a/libgcc/gthr-posix.h b/libgcc/gthr-posix.h > > index 3984d066602..73260823233 100644 > > --- a/libgcc/gthr-posix.h > > +++ b/libgcc/gthr-posix.h > > @@ -44,6 +44,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. > > If not, see > > # endif > > #endif > > > > +#ifndef _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > +# define _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY 0 > > +#endif > > + > > +#ifndef _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > +# define _GTHREAD_USE_COND_TIMEDWAIT_STEADY 0 > > +#endif > > + > > #ifdef __has_attribute > > # if __has_attribute(__always_inline__) > > # define __GTHREAD_ALWAYS_INLINE __attribute__((__always_inline__)) > > @@ -139,6 +147,9 @@ __gthrw(pthread_mutex_trylock) > > #if _GTHREAD_USE_MUTEX_TIMEDLOCK > > __gthrw(pthread_mutex_timedlock) > > #endif > > +#if _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > +__gthrw(pthread_mutex_clocklock) > > +#endif > > __gthrw(pthread_mutex_unlock) > > __gthrw(pthread_mutex_init) > > __gthrw(pthread_mutex_destroy) > > @@ -148,6 +159,9 @@ __gthrw(pthread_cond_broadcast) > > __gthrw(pthread_cond_signal) > > __gthrw(pthread_cond_wait) > > __gthrw(pthread_cond_timedwait) > > +#if _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > +__gthrw(pthread_cond_clockwait) > > +#endif > > __gthrw(pthread_cond_destroy) > > > > __gthrw(pthread_key_create) > > @@ -818,6 +832,19 @@ __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, > > } > > #endif > > > > +#if _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > +__GTHREAD_INLINE int > > +__gthread_mutex_timedlock_steady (__gthread_mutex_t *__mutex, > > + const __gthread_time_t *__abs_timeout) > > +{ > > + if (__gthread_active_p ()) > > + return __gthrw_(pthread_mutex_clocklock) (__mutex, CLOCK_MONOTONIC, > > + __abs_timeout); > > + else > > + return 0; > > +} > > +#endif > > + > > __GTHREAD_INLINE int > > __gthread_mutex_unlock (__gthread_mutex_t *__mutex) > > { > > @@ -872,6 +899,15 @@ __gthread_recursive_mutex_timedlock > > (__gthread_recursive_mutex_t *__mutex, > > } > > #endif > > > > +#if _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > +__GTHREAD_INLINE int > > +__gthread_recursive_mutex_timedlock_steady (__gthread_recursive_mutex_t > > *__mutex, > > + const __gthread_time_t > > *__abs_timeout) > > +{ > > + return __gthread_mutex_timedlock_steady (__mutex, __abs_timeout); > > +} > > +#endif > > + > > __GTHREAD_INLINE int > > __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) > > { > > @@ -918,6 +954,17 @@ __gthread_cond_timedwait (__gthread_cond_t *__cond, > > __gthread_mutex_t *__mutex, > > return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); > > } > > > > +#if _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > +__GTHREAD_INLINE int > > +__gthread_cond_timedwait_steady (__gthread_cond_t *__cond, > > + __gthread_mutex_t *__mutex, > > + const __gthread_time_t *__abs_timeout) > > +{ > > + return __gthrw_(pthread_cond_clockwait) (__cond, __mutex, > > CLOCK_MONOTONIC, > > + __abs_timeout); > > +} > > +#endif > > + > > __GTHREAD_INLINE int > > __gthread_cond_wait_recursive (__gthread_cond_t *__cond, > > __gthread_recursive_mutex_t *__mutex) > > diff --git a/libgcc/gthr.h b/libgcc/gthr.h > > index 8cd29834228..1a1ae7ffbf9 100644 > > --- a/libgcc/gthr.h > > +++ b/libgcc/gthr.h > > @@ -130,6 +130,28 @@ see the files COPYING3 and COPYING.RUNTIME > > respectively. If not, see > > __gthread_mutex_t *mutex, > > const __gthread_time_t *abs_timeout); > > > > + The following are optional extensions for steady clock support. > > + If the threading implementation supports timed locking against a > > + steady (monotonic) clock, it should define > > + _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY to 1 and provide: > > + > > + int __gthread_mutex_timedlock_steady (__gthread_mutex_t *m, > > + const __gthread_time_t > > *abs_timeout); > > + int __gthread_recursive_mutex_timedlock_steady > > + (__gthread_recursive_mutex_t *m, > > + const __gthread_time_t > > *abs_timeout); > > + > > + If the threading implementation supports condition variable waits > > + against a steady (monotonic) clock, it should define > > + _GTHREAD_USE_COND_TIMEDWAIT_STEADY to 1 and provide: > > + > > + int __gthread_cond_timedwait_steady (__gthread_cond_t *cond, > > + __gthread_mutex_t *mutex, > > + const __gthread_time_t > > *abs_timeout); > > + > > + For these functions, abs_timeout is measured against the steady clock > > + (CLOCK_MONOTONIC on POSIX systems). > > + > > */ > > > > #if SUPPORTS_WEAK > > diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 > > index 8dc9e17b214..36e8a7c8f91 100644 > > --- a/libstdc++-v3/acinclude.m4 > > +++ b/libstdc++-v3/acinclude.m4 > > @@ -4469,7 +4469,7 @@ AC_DEFUN([GLIBCXX_CHECK_PTHREADS_NUM_PROCESSORS_NP], [ > > > > dnl > > dnl Check whether pthread_cond_clockwait is available in <pthread.h> for > > std::condition_variable to use, > > -dnl and define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT. > > +dnl and define _GTHREAD_USE_COND_TIMEDWAIT_STEADY. > > I'm no expert in the way this works but it feels odd to be making > _GTHREAD_USE_COND_TIMEDWAIT_STEADY imply that pthread_cond_clockwait should > be called when the previous name made that much more obvious. (Though > s/GLIBCXX/GTHREAD/ makes sense given the move from libstd++ to libgcc.) > > IMO _GTHREAD_USE_COND_TIMEDWAIT_STEADY (or equivalent) being defined > implies that __gthread_cond_timedwait_steady can be called whereas > _GTHREAD_USE_PTHREAD_COND_CLOCKWAIT (or similar) implies that > pthread_cond_clockwait() can be called. > > For example, a __gthread_cond_timedwait_steady implementation that called > Bionic's pthread_cond_timedwait_relative_np would define > _GTHREAD_USE_COND_TIMEDWAIT_STEADY and > _GTHREAD_USE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP but not > _GTHREAD_USE_PTHREAD_COND_CLOCKWAIT. > > Given this, I think it would probably make more sense for gthr-posix.h to > contain something like: > > #ifdef _GTHREAD_USE_PTHREAD_COND_CLOCKWAIT > #define _GTHREAD_USE_COND_TIMEDWAIT_STEADY > #endif > > and keep _GTHREAD_USE_PTHREAD_COND_CLOCKWAIT out of the configure scripts > completely. > > > dnl > > AC_DEFUN([GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT], [ > > > > @@ -4489,8 +4489,12 @@ AC_DEFUN([GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT], [ > > [glibcxx_cv_PTHREAD_COND_CLOCKWAIT=no]) > > ]) > > if test $glibcxx_cv_PTHREAD_COND_CLOCKWAIT = yes; then > > - AC_DEFINE(_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT, 1, [Define if > > pthread_cond_clockwait is available in <pthread.h>.]) > > + ac_gthread_use_cond_timedwait_steady=1 > > + else > > + ac_gthread_use_cond_timedwait_steady=0 > > fi > > + AC_DEFINE_UNQUOTED(_GTHREAD_USE_COND_TIMEDWAIT_STEADY, > > $ac_gthread_use_cond_timedwait_steady, > > + [Define to 1 if the gthread backend supports > > steady-clock condition variable waits.]) > > > > CXXFLAGS="$ac_save_CXXFLAGS" > > LIBS="$ac_save_LIBS" > > @@ -4499,7 +4503,7 @@ AC_DEFUN([GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT], [ > > > > dnl > > dnl Check whether pthread_mutex_clocklock is available in <pthread.h> for > > std::timed_mutex to use, > > -dnl and define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK. > > +dnl and define _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY. > > Same comment as for _GTHREAD_USE_COND_TIMEDWAIT_STEADY above. > > > dnl > > AC_DEFUN([GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK], [ > > > > @@ -4519,8 +4523,12 @@ AC_DEFUN([GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK], [ > > [glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK=no]) > > ]) > > if test $glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK = yes; then > > - AC_DEFINE(_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK, 1, [Define if > > pthread_mutex_clocklock is available in <pthread.h>.]) > > + ac_gthread_use_mutex_timedlock_steady=1 > > + else > > + ac_gthread_use_mutex_timedlock_steady=0 > > fi > > + AC_DEFINE_UNQUOTED(_GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY, > > $ac_gthread_use_mutex_timedlock_steady, > > + [Define to 1 if the gthread backend supports > > steady-clock timed mutex locking.]) > > > > CXXFLAGS="$ac_save_CXXFLAGS" > > LIBS="$ac_save_LIBS" > > diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in > > index 4cfb9ba26be..9ec5da10193 100644 > > --- a/libstdc++-v3/config.h.in > > +++ b/libstdc++-v3/config.h.in > > @@ -864,12 +864,6 @@ > > /* Define if pthreads_num_processors_np is available in <pthread.h>. */ > > #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP > > > > -/* Define if pthread_cond_clockwait is available in <pthread.h>. */ > > -#undef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT > > - > > -/* Define if pthread_mutex_clocklock is available in <pthread.h>. */ > > -#undef _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK > > - > > /* Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are > > available in <pthread.h>. */ > > #undef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK > > @@ -953,9 +947,17 @@ > > /* Define if a directory should be searched for tzdata files. */ > > #undef _GLIBCXX_ZONEINFO_DIR > > > > +/* Define to 1 if the gthread backend supports steady-clock condition > > variable > > + waits. */ > > +#undef _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > + > > I think that it should be up to libgcc to define this when necessary and > not libstdc++. It's libgcc that is ultimately responsible for knowing > whether it is providing __gthread_cond_timedwait_steady() or not and > another language standard library may want to make use of it too. > > > /* Define to 1 if mutex_timedlock is available. */ > > #undef _GTHREAD_USE_MUTEX_TIMEDLOCK > > > > +/* Define to 1 if the gthread backend supports steady-clock timed mutex > > + locking. */ > > +#undef _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > + > > Same comment as for _GTHREAD_USE_COND_TIMEDWAIT_STEADY above. > > > /* Define for large files, on AIX-style hosts. */ > > #undef _LARGE_FILES > > > > diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure > > index 6713e4504b1..5423288b2a7 100755 > > --- a/libstdc++-v3/configure > > +++ b/libstdc++-v3/configure > > @@ -22218,10 +22218,15 @@ fi > > { $as_echo "$as_me:${as_lineno-$LINENO}: result: > > $glibcxx_cv_PTHREAD_COND_CLOCKWAIT" >&5 > > $as_echo "$glibcxx_cv_PTHREAD_COND_CLOCKWAIT" >&6; } > > if test $glibcxx_cv_PTHREAD_COND_CLOCKWAIT = yes; then > > + ac_gthread_use_cond_timedwait_steady=1 > > + else > > + ac_gthread_use_cond_timedwait_steady=0 > > + fi > > > > -$as_echo "#define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT 1" >>confdefs.h > > +cat >>confdefs.h <<_ACEOF > > +#define _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > $ac_gthread_use_cond_timedwait_steady > > +_ACEOF > > > > - fi > > > > CXXFLAGS="$ac_save_CXXFLAGS" > > LIBS="$ac_save_LIBS" > > @@ -22300,10 +22305,15 @@ fi > > { $as_echo "$as_me:${as_lineno-$LINENO}: result: > > $glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK" >&5 > > $as_echo "$glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK" >&6; } > > if test $glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK = yes; then > > + ac_gthread_use_mutex_timedlock_steady=1 > > + else > > + ac_gthread_use_mutex_timedlock_steady=0 > > + fi > > > > -$as_echo "#define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK 1" >>confdefs.h > > +cat >>confdefs.h <<_ACEOF > > +#define _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > $ac_gthread_use_mutex_timedlock_steady > > +_ACEOF > > > > - fi > > > > CXXFLAGS="$ac_save_CXXFLAGS" > > LIBS="$ac_save_LIBS" > > @@ -54145,7 +54155,7 @@ $as_echo "$glibcxx_cv_libbacktrace_atomics" >&6; } > > CXXFLAGS='-O0 -S' > > > > cat > conftest.$ac_ext << EOF > > -#line 54148 "configure" > > +#line 54158 "configure" > > #include <stddef.h> > > int main() > > { > > diff --git a/libstdc++-v3/include/bits/std_mutex.h > > b/libstdc++-v3/include/bits/std_mutex.h > > index 7ef33fe5d0d..fb4bbf611df 100644 > > --- a/libstdc++-v3/include/bits/std_mutex.h > > +++ b/libstdc++-v3/include/bits/std_mutex.h > > @@ -181,12 +181,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > __gthread_cond_timedwait(&_M_cond, __m.native_handle(), &__abs_time); > > } > > > > -#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT > > +#if _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > void > > - wait_until(mutex& __m, clockid_t __clock, timespec& __abs_time) > > + _M_wait_until_steady(mutex& __m, timespec& __abs_time) > > { > > - pthread_cond_clockwait(&_M_cond, __m.native_handle(), __clock, > > - &__abs_time); > > + __gthread_cond_timedwait_steady(&_M_cond, __m.native_handle(), > > + &__abs_time); > > } > > #endif > > > > diff --git a/libstdc++-v3/include/std/condition_variable > > b/libstdc++-v3/include/std/condition_variable > > index 9e515123e7c..d6c78fb0555 100644 > > --- a/libstdc++-v3/include/std/condition_variable > > +++ b/libstdc++-v3/include/std/condition_variable > > @@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > { > > using steady_clock = chrono::steady_clock; > > using system_clock = chrono::system_clock; > > -#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT > > +#if _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > using __clock_t = steady_clock; > > #else > > using __clock_t = system_clock; > > @@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > wait(__lock); > > } > > > > -#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT > > +#if _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > template<typename _Duration> > > cv_status > > wait_until(unique_lock<mutex>& __lock, > > @@ -187,14 +187,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > { return _M_cond.native_handle(); } > > > > private: > > -#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT > > +#if _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > template<typename _Dur> > > cv_status > > __wait_until_impl(unique_lock<mutex>& __lock, > > const chrono::time_point<steady_clock, _Dur>& __atime) > > { > > __gthread_time_t __ts = chrono::__to_timeout_gthread_time_t(__atime); > > - _M_cond.wait_until(*__lock.mutex(), CLOCK_MONOTONIC, __ts); > > + _M_cond._M_wait_until_steady(*__lock.mutex(), __ts); > > > > return (steady_clock::now() < __atime > > ? cv_status::no_timeout : cv_status::timeout); > > @@ -229,7 +229,7 @@ _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2) > > // Like above, but mutex is not required to have try_lock. > > class condition_variable_any > > { > > -#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT > > +#if _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > using __clock_t = chrono::steady_clock; > > #else > > using __clock_t = chrono::system_clock; > > diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex > > index fb5b5073834..428327f1174 100644 > > --- a/libstdc++-v3/include/std/mutex > > +++ b/libstdc++-v3/include/std/mutex > > @@ -162,7 +162,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > bool > > _M_try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) > > { > > -#if _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK > > +#if _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > using __clock = chrono::steady_clock; > > #else > > using __clock = chrono::system_clock; > > @@ -183,15 +183,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > return static_cast<_Derived*>(this)->_M_timedlock(__ts); > > } > > > > -#if _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK > > +#if _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > template<typename _Duration> > > bool > > _M_try_lock_until(const chrono::time_point<chrono::steady_clock, > > _Duration>& __atime) > > { > > __gthread_time_t __ts = > > chrono::__to_timeout_gthread_time_t(__atime); > > - return static_cast<_Derived*>(this)->_M_clocklock(CLOCK_MONOTONIC, > > - __ts); > > + return static_cast<_Derived*>(this)->_M_steadylock(__ts); > > } > > #endif > > > > @@ -285,10 +284,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > _M_timedlock(const __gthread_time_t& __ts) > > { return !__gthread_mutex_timedlock(&_M_mutex, &__ts); } > > > > -#if _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK > > +#if _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > bool > > - _M_clocklock(clockid_t __clockid, const __gthread_time_t& __ts) > > - { return !pthread_mutex_clocklock(&_M_mutex, __clockid, &__ts); } > > + _M_steadylock(const __gthread_time_t& __ts) > > + { return !__gthread_mutex_timedlock_steady(&_M_mutex, &__ts); } > > #endif > > }; > > > > @@ -363,10 +362,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > _M_timedlock(const __gthread_time_t& __ts) > > { return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts); } > > > > -#if _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK > > +#if _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY > > bool > > - _M_clocklock(clockid_t __clockid, const __gthread_time_t& __ts) > > - { return !pthread_mutex_clocklock(&_M_mutex, __clockid, &__ts); } > > + _M_steadylock(const __gthread_time_t& __ts) > > + { return !__gthread_recursive_mutex_timedlock_steady(&_M_mutex, > > &__ts); } > > #endif > > }; > > > > diff --git a/libstdc++-v3/src/c++20/atomic.cc > > b/libstdc++-v3/src/c++20/atomic.cc > > index 177c503330d..8103a84dfc1 100644 > > --- a/libstdc++-v3/src/c++20/atomic.cc > > +++ b/libstdc++-v3/src/c++20/atomic.cc > > @@ -533,9 +533,9 @@ __cond_wait_until(__condvar& __cv, mutex& __mx, > > { > > __gthread_time_t __ts = chrono::__to_timeout_gthread_time_t(__atime); > > > > -#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT > > +#if _GTHREAD_USE_COND_TIMEDWAIT_STEADY > > if constexpr (is_same_v<chrono::steady_clock, __wait_clock_t>) > > - __cv.wait_until(__mx, CLOCK_MONOTONIC, __ts); > > + __cv._M_wait_until_steady(__mx, __ts); > > else > > #endif > > __cv.wait_until(__mx, __ts); > > diff --git > > a/libstdc++-v3/testsuite/30_threads/condition_variable/members/116586.cc > > b/libstdc++-v3/testsuite/30_threads/condition_variable/members/116586.cc > > index e8c3e1634e2..be5295d10ec 100644 > > --- a/libstdc++-v3/testsuite/30_threads/condition_variable/members/116586.cc > > +++ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/116586.cc > > @@ -28,7 +28,7 @@ test_absolute(chrono::nanoseconds offset) > > } > > > > // The type of clock used for the actual wait depends on whether > > -// _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK is defined. We might as well just > > test > > +// _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY is defined. We might as well just > > test > > // both steady_clock and system_clock. > > template <typename Clock> > > void > > diff --git > > a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc > > > > b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc > > index 25a78e72f46..28abae267b9 100644 > > --- > > a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc > > +++ > > b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc > > @@ -33,7 +33,7 @@ test_absolute(chrono::nanoseconds offset) > > } > > > > // The type of clock used for the actual wait depends on whether > > -// _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK is defined. We might as well just > > test > > +// _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY is defined. We might as well just > > test > > // both steady_clock and system_clock. > > template <typename Clock> > > void > > diff --git > > a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/116586.cc > > b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/116586.cc > > index 15662281891..78362b43add 100644 > > --- a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/116586.cc > > +++ b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/116586.cc > > @@ -25,7 +25,7 @@ test_absolute(chrono::nanoseconds offset) > > } > > > > // The type of clock used for the actual wait depends on whether > > -// _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK is defined. We might as well just > > test > > +// _GTHREAD_USE_MUTEX_TIMEDLOCK_STEADY is defined. We might as well just > > test > > // both steady_clock and system_clock. > > template <typename Clock> > > void > > -- > > 2.47.3 > > > > > > Thanks. > > Mike. > > [1] https://gcc.gnu.org/pipermail/libstdc++/2015-July/043217.html
