From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 6E23E3857C6D; Fri, 10 Dec 2021 14:05:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E23E3857C6D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-5895] libstdc++: Guard mutex and condvar with gthreads macro [PR103638] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: ca1c7065e9de04ceb521a0b409071275c5690341 X-Git-Newrev: ffb632517fc446474baba10ee2ff13a218ec2c7b Message-Id: <20211210140558.6E23E3857C6D@sourceware.org> Date: Fri, 10 Dec 2021 14:05:58 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Dec 2021 14:05:58 -0000 https://gcc.gnu.org/g:ffb632517fc446474baba10ee2ff13a218ec2c7b commit r12-5895-gffb632517fc446474baba10ee2ff13a218ec2c7b Author: Jonathan Wakely Date: Fri Dec 10 11:44:29 2021 +0000 libstdc++: Guard mutex and condvar with gthreads macro [PR103638] A mutex and condition variable is used for timed waits on atomics if there is no "platform wait" (e.g. futex) supported. But the use of those types wasn't guarded by the _GLIBCXX_HAS_GTHREADS macro, causing errors for --disable-threads builds. This fix allows to work on targets with futexes but no gthreads. libstdc++-v3/ChangeLog: PR libstdc++/103638 * include/bits/atomic_timed_wait.h: Check _GLIBCXX_HAS_GTHREADS before using std::mutex and std::__condvar. Diff: --- libstdc++-v3/include/bits/atomic_timed_wait.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libstdc++-v3/include/bits/atomic_timed_wait.h b/libstdc++-v3/include/bits/atomic_timed_wait.h index efbe3da8b6c..ba83398285c 100644 --- a/libstdc++-v3/include/bits/atomic_timed_wait.h +++ b/libstdc++-v3/include/bits/atomic_timed_wait.h @@ -137,6 +137,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // (e.g. __ulock_wait())which is better than pthread_cond_clockwait #endif // ! PLATFORM_TIMED_WAIT +#ifdef _GLIBCXX_HAS_GTHREADS // Returns true if wait ended before timeout. // _Clock must be either steady_clock or system_clock. template @@ -192,6 +193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return false; } } +#endif // _GLIBCXX_HAS_GTHREADS struct __timed_waiter_pool : __waiter_pool_base { @@ -239,6 +241,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (_M_deadline <= __now) return false; + // FIXME: this_thread::sleep_for not available #ifdef _GLIBCXX_NO_SLEEP + auto __elapsed = __now - _M_t0; if (__elapsed > 128ms) {