[libcxx-commits] [libcxx] [libc++] Allows any types of size 4 and 8 to use native platform ulock_wait (PR #161086)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 31 10:59:47 PDT 2025


================
@@ -205,6 +205,14 @@ This flag fixes the implementation of CityHash used for ``hash<fundamental-type>
 CityHash has the problem that it drops some bits on the floor. Fixing the implementation changes the hash of values,
 resulting in an ABI break.
 
+``_LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE``
+-------------------------------------------------
+This flag changes the implementation of ``atomic::wait()`` and ``atomic::notify_one()/notify_all()`` to use the
+native atomic wait/notify operations on platforms that support them based on the size of the atomic type, instead
+of the type itself. This changes the behaviour of ``atomic::wait()`` and ``atomic::notify_one()/notify_all()`` in
+some cases, resulting in an ABI break.
----------------
ldionne wrote:

```suggestion
This flag changes the implementation of ``atomic::wait()`` and ``atomic::notify_one()/notify_all()`` to use the
native atomic wait/notify operations on platforms that support them based on the size of the atomic type, instead
of the type itself. This means for example that a type with ``sizeof(T) == 4`` on Linux that doesn't have padding bytes would be able to use the underlying platform's atomic wait primitive, which is otherwise only used for ``int32_t``. Since the whole program must use the same implementation for correctness, changing this is an ABI break since libc++ supports linking against TUs that were compiled against older versions of the library.
```

https://github.com/llvm/llvm-project/pull/161086


More information about the libcxx-commits mailing list