public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20 Date: Mon, 28 Nov 2022 16:29:57 +0000 [thread overview] Message-ID: <bug-107886-4-pzJhHhNEKW@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107886-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886 --- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> --- Something like ... --- include/bits/atomic_wait.h 2022-11-07 15:38:32.551751184 +0000 +++ /tmp/inc/bits/atomic_wait.h 2022-11-28 16:27:51.352489618 +0000 @@ -33,7 +33,7 @@ #pragma GCC system_header #include <bits/c++config.h> -#if defined _GLIBCXX_HAS_GTHREADS || defined _GLIBCXX_HAVE_LINUX_FUTEX +#if defined _GLIBCXX_HAS_GTHREADS || defined _GLIBCXX_HAVE_LINUX_FUTEX || _WIN32 #include <bits/functional_hash.h> #include <bits/gthr.h> #include <ext/numeric_traits.h> @@ -59,6 +59,10 @@ #define _GLIBCXX_HAVE_PLATFORM_WAIT 1 using __platform_wait_t = int; inline constexpr size_t __platform_wait_alignment = 4; +#elif _WIN32 + using __platform_wait_t = __UINTPTR_TYPE__; + inline constexpr size_t __platform_wait_alignment + = alignof(__platform_wait_t); #else // define _GLIBCX_HAVE_PLATFORM_WAIT and implement __platform_wait() // and __platform_notify() if there is a more efficient primitive supported @@ -122,6 +126,30 @@ static_cast<int>(__futex_wait_flags::__wake_private), __all ? INT_MAX : 1); } +#elif _WIN32 + extern "C" int __glibcxx_get_last_error() __asm("GetLastError"); + + template<typename _Tp> + void + __platform_wait(const _Tp* __addr, __platform_wait_t __val) noexcept + { + const long __timeout = 0xffffffff; + if (WaitOnAddress(__addr, &__val, sizeof(__platform_wait_t), __timeout)) + return; + _GLIBCXX_THROW_OR_ABORT(std::system_error(__glibcxx_get_last_error(), + std::system_category(), + "WaitOnAddress")); + } + + template<typename _Tp> + void + __platform_notify(const _Tp* __addr, bool __all) noexcept + { + if (__all) + WakeByAddressAll(__addr); + else + WakeByAddressOne(__addr); + } #endif inline void
next prev parent reply other threads:[~2022-11-28 16:29 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl 2022-11-27 17:56 ` [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20 pinskia at gcc dot gnu.org 2022-11-27 17:58 ` pinskia at gcc dot gnu.org 2022-11-27 18:01 ` lukaszcz18 at wp dot pl 2022-11-27 18:04 ` lukaszcz18 at wp dot pl 2022-11-27 18:05 ` lukaszcz18 at wp dot pl 2022-11-27 18:12 ` lukaszcz18 at wp dot pl 2022-11-27 20:25 ` redi at gcc dot gnu.org 2022-11-28 8:40 ` lukaszcz18 at wp dot pl 2022-11-28 9:21 ` redi at gcc dot gnu.org 2022-11-28 11:59 ` lukaszcz18 at wp dot pl 2022-11-28 12:03 ` lukaszcz18 at wp dot pl 2022-11-28 12:05 ` lukaszcz18 at wp dot pl 2022-11-28 15:58 ` redi at gcc dot gnu.org 2022-11-28 16:03 ` redi at gcc dot gnu.org 2022-11-28 16:09 ` redi at gcc dot gnu.org 2022-11-28 16:29 ` redi at gcc dot gnu.org [this message] 2022-11-28 18:05 ` lukaszcz18 at wp dot pl 2023-01-17 19:36 ` i.nixman at autistici dot org
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=bug-107886-4-pzJhHhNEKW@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).