From d1dec304453fa4874d16daaa15e6f477435edda4 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 19 Aug 2025 18:02:53 +0100 Subject: libstdc++: Check _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK with #if [PR121496] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The change in r14-905-g3b7cb33033fbe6 to disable the use of pthread_mutex_clocklock when TSan is active assumed that the _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK macro was always checked with #if rather than #ifdef, which was not true. This makes the checks use #if consistently. libstdc++-v3/ChangeLog: PR libstdc++/121496 * include/std/mutex (__timed_mutex_impl::_M_try_wait_until): Change preprocessor condition to use #if instead of #ifdef. (recursive_timed_mutex::_M_clocklock): Likewise. * testsuite/30_threads/timed_mutex/121496.cc: New test. Reviewed-by: Tomasz KamiƄski --- libstdc++-v3/include/std/mutex | 4 ++-- libstdc++-v3/testsuite/30_threads/timed_mutex/121496.cc | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/testsuite/30_threads/timed_mutex/121496.cc (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index e575a81..631c380 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -190,7 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return static_cast<_Derived*>(this)->_M_timedlock(__ts); } -#ifdef _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK +#if _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK template bool _M_try_lock_until(const chrono::time_point +#include + +void +test_pr121496(std::timed_mutex& m) +{ + (void) m.try_lock_until(std::chrono::steady_clock::time_point{}); +} -- cgit v1.1