[libcxx-commits] [libcxx] 17ecbb3 - [libc++] [FreeBSD] only use _umtx_op(2) on 64bit arches

Ed Maste via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 1 12:51:49 PST 2023


Author: Konstantin Belousov
Date: 2023-03-01T15:51:24-05:00
New Revision: 17ecbb3ea6ff0ae716dd524c0e2bf75a4815c95b

URL: https://github.com/llvm/llvm-project/commit/17ecbb3ea6ff0ae716dd524c0e2bf75a4815c95b
DIFF: https://github.com/llvm/llvm-project/commit/17ecbb3ea6ff0ae716dd524c0e2bf75a4815c95b.diff

LOG: [libc++] [FreeBSD] only use _umtx_op(2) on 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.

Fixes: 83387dbc18e7998f87aa4a2d35320bcb2ed5c392

Reviewed by: arichardson, ldionne, emaste, Mordante
Differential Revision: https://reviews.llvm.org/D142422

Added: 
    

Modified: 
    libcxx/src/atomic.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/src/atomic.cpp b/libcxx/src/atomic.cpp
index 7777e888c0005..61e507d44f644 100644
--- a/libcxx/src/atomic.cpp
+++ b/libcxx/src/atomic.cpp
@@ -77,20 +77,25 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
                  const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
 }
 
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) && defined(__LP64__)
+/*
+ * Since __cxx_contention_t is int64_t even on 32bit FreeBSD
+ * platforms, we have to use umtx ops that work on the long type, and
+ * limit its use to architectures where long and int64_t are synonyms.
+ */
 
 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);
+             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_PRIVATE, __notify_one ? 1 : INT_MAX, NULL, NULL);
+             UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL);
 }
 
 #else // <- Add other operating systems here


        


More information about the libcxx-commits mailing list