[PATCH] libgcc, libstdc++: Route steady-clock timedlock through gthread

Jonathan Wakely jwakely@redhat.com
Sun Mar 22 11:34:27 GMT 2026


On Sun, 22 Mar 2026 at 10:55, Nick Nikolov <nickooo314@gmail.com> 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.
>
> 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.

This seems like a reasonable direction for GCC 17 (it's too late for
GCC 16) but the name "wait_until_steady" needs to change. That's not a
reserved name in the C++ standard, so you can't use that name in
libstdc++ headers. It needs to be _M_wait_until_steady or
__wait_until_steady.



>
> 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::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 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 <nickooo314@gmail.com>
> ---
> Note: I don't have GCC write access. If approved, I'd appreciate
> a maintainer committing this on my behalf.
>
>  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.
>  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.
>  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
> +
>  /* 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
> +
>  /* 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..c6ecaf12ad8 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)
> +    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..89348989218 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.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..fb0b63e9e13 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.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
>



More information about the Libstdc++ mailing list