[PATCH] libstdc++: Use 32-bit platform wait type for OpenBSD and DragonFly [PR120527]

Jonathan Wakely jwakely@redhat.com
Tue Apr 21 13:26:58 GMT 2026


This defines __platform_wait_t as unsigned int for OpenBSD and
DragonFly. This means that std::semaphore will use unsigned int by
default, and so will benefit from more efficient wait/notify ops if we
start to use the OpenBSD futex(2) syscall or the DragonFly umtx(2)
syscalls. We don't currently use them, but if we start to in future, it
would be an ABI break to change __platform_wait_t later.

libstdc++-v3/ChangeLog:

	PR libstdc++/120527
	* include/bits/atomic_wait.h [__OpenBSD__ || __DragonFly]: Use
	unsigned int for __platform_wait_t.
---

Tested DragonFly 6.4 and x86_64-linux.

 libstdc++-v3/include/bits/atomic_wait.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
index 3d10b0a155e5..c874d6097304 100644
--- a/libstdc++-v3/include/bits/atomic_wait.h
+++ b/libstdc++-v3/include/bits/atomic_wait.h
@@ -108,7 +108,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 // a mutex/condvar based wait.
   namespace __detail
   {
-# if ATOMIC_LONG_LOCK_FREE == 2
+# if defined __OpenBSD__ || defined __DragonFly__
+    // These targets provide 32-bit futex-like syscalls.
+    // We don't currently make use of them, but we want to in future.
+    using __platform_wait_t = unsigned int;
+# elif ATOMIC_LONG_LOCK_FREE == 2
     using __platform_wait_t = unsigned long;
 # else
     using __platform_wait_t = unsigned int;
-- 
2.53.0



More information about the Libstdc++ mailing list