Skip to content

Commit 83387db

Browse files
kostikbelemaste
authored andcommitted
[libc++] add FreeBSD atomic wait support
Reviewed By: philnik Differential Revision: https://reviews.llvm.org/D142134
1 parent c3efd52 commit 83387db

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

libcxx/src/atomic.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
# define SYS_futex SYS_futex_time64
2727
#endif
2828

29+
#elif defined(__FreeBSD__)
30+
31+
#include <sys/types.h>
32+
#include <sys/umtx.h>
33+
2934
#else // <- Add other operating systems here
3035

3136
// Baseline needs no new headers
@@ -72,6 +77,22 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
7277
const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
7378
}
7479

80+
#elif defined(__FreeBSD__)
81+
82+
static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
83+
__cxx_contention_t __val)
84+
{
85+
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr),
86+
UMTX_OP_WAIT_UINT_PRIVATE, __val, NULL, NULL);
87+
}
88+
89+
static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr,
90+
bool __notify_one)
91+
{
92+
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr),
93+
UMTX_OP_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, NULL, NULL);
94+
}
95+
7596
#else // <- Add other operating systems here
7697

7798
// Baseline is just a timed backoff

0 commit comments

Comments
 (0)