Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jan 2023 00:39:06 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 17262e08af4e - stable/13 - libcxx: Implement atomic::wait/notify using _umtx_op(2) for 64bit arches
Message-ID:  <202301310039.30V0d6sv059495@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=17262e08af4e65a75484625417eb4ca0b916502e

commit 17262e08af4e65a75484625417eb4ca0b916502e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-01-20 02:57:26 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-01-31 00:38:18 +0000

    libcxx: Implement atomic::wait/notify using _umtx_op(2) for 64bit arches
    
    (cherry picked from commit 9c996882b0ed279ca314d995f2eb1d538b94e3f8)
---
 contrib/llvm-project/libcxx/src/atomic.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/contrib/llvm-project/libcxx/src/atomic.cpp b/contrib/llvm-project/libcxx/src/atomic.cpp
index 250d33e98b02..e7496fa43666 100644
--- a/contrib/llvm-project/libcxx/src/atomic.cpp
+++ b/contrib/llvm-project/libcxx/src/atomic.cpp
@@ -26,6 +26,11 @@
 # define SYS_futex SYS_futex_time64
 #endif
 
+#elif defined(__FreeBSD__)
+
+#include <sys/types.h>
+#include <sys/umtx.h>
+
 #else // <- Add other operating systems here
 
 // Baseline needs no new headers
@@ -72,6 +77,22 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
                  const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
 }
 
+#elif defined(__FreeBSD__) && defined(__LP64__)
+
+static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
+                                              __cxx_contention_t __val)
+{
+    _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr),
+      UMTX_OP_WAIT, __val, NULL, NULL);
+}
+
+static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr,
+                                              bool __notify_one)
+{
+    _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr),
+      UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL);
+}
+
 #else // <- Add other operating systems here
 
 // Baseline is just a timed backoff



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202301310039.30V0d6sv059495>