summaryrefslogtreecommitdiff
path: root/libcxx/src
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@freebsd.org>2023-01-17 20:18:24 -0500
committerEd Maste <emaste@FreeBSD.org>2023-01-20 16:39:38 -0500
commit83387dbc18e7998f87aa4a2d35320bcb2ed5c392 (patch)
tree868fb0d4c76a53cbb20208dddcbf442801f38b13 /libcxx/src
parentc3efd52770ca964ba46287298c1d2f7697fd446c (diff)
downloadllvm-83387dbc18e7998f87aa4a2d35320bcb2ed5c392.tar.gz
[libc++] add FreeBSD atomic wait support
Reviewed By: philnik Differential Revision: https://reviews.llvm.org/D142134
Diffstat (limited to 'libcxx/src')
-rw-r--r--libcxx/src/atomic.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/libcxx/src/atomic.cpp b/libcxx/src/atomic.cpp
index ec7bb7d9b2c3..7777e888c000 100644
--- a/libcxx/src/atomic.cpp
+++ b/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__)
+
+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_UINT_PRIVATE, __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_PRIVATE, __notify_one ? 1 : INT_MAX, NULL, NULL);
+}
+
#else // <- Add other operating systems here
// Baseline is just a timed backoff