public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-9833] libstdc++: Guard mutex and condvar with gthreads macro [PR103638] Date: Tue, 12 Apr 2022 20:18:08 +0000 (GMT) [thread overview] Message-ID: <20220412201808.B7A903857C50@sourceware.org> (raw) https://gcc.gnu.org/g:105f1c08369aa6702d070f911dd658b93230ac46 commit r11-9833-g105f1c08369aa6702d070f911dd658b93230ac46 Author: Jonathan Wakely <jwakely@redhat.com> 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 <atomic> 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. (cherry picked from commit ffb632517fc446474baba10ee2ff13a218ec2c7b) 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 d423a7af7c3..4302774958d 100644 --- a/libstdc++-v3/include/bits/atomic_timed_wait.h +++ b/libstdc++-v3/include/bits/atomic_timed_wait.h @@ -139,6 +139,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<typename _Clock, typename _Dur> @@ -194,6 +195,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return false; } } +#endif // _GLIBCXX_HAS_GTHREADS struct __timed_waiter_pool : __waiter_pool_base { @@ -241,6 +243,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) {
reply other threads:[~2022-04-12 20:18 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220412201808.B7A903857C50@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).