libcxx: Implement atomic::wait/notify using _umtx_op(2) for 64bit arches
Only 64bit architectures can be supported this way, because libcxx defines __cxx_contention_t to be int64_t for FreeBSD, and 32bit arches do not have a kind of UMTX_OP_WAIT_INT64_PRIVATE operation. LLVM review: https://reviews.llvm.org/D142134 Tested by: emaste Reviewed by: dim, emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38132
This commit is contained in:
parent
62adb1e953
commit
9c996882b0
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user