[libcxx-commits] [PATCH] D68480: Implementation of C++20's P1135R6 for libcxx

David Chisnall via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 8 06:34:00 PST 2021


theraven added a comment.

This appears to have baked in some ABI details that don't permit efficient implementation on some of our supported platforms.  In the future, please can you post an RFC from things that need to integrate with platform-specific code? We're now stuck with this interface until we are willing to do an ABI-breaking change.  In particular:

- OpenBSD provides a Linux-compatible `futex` that requires a 32-bit integer to be used as the key.  This can't be used with the existing ABI, which has baked in 64-bit integers as the size for OpenBSD.
- FreeBSD's `_umtx_op` uses `long` and so is able to support the ABI on 64-bit platforms (LP64) but not on 32-bit ones.
- Windows' WaitOnAddress supports 1, 2, 4, and 8-byte objects, yet can be used only with 8-byte objects in this interface.
- The semaphore interface does not require exposing the underlying semaphore type, so could have been implemented directly with `_umtx_op` on FreeBSD, rather than with the wrapper.  A binary semaphore is trivial to implement with a futex with the fast path in the uncontended case a single inline atomic op.  This is not possible without breaking the ABI in the current design.

The atomic wait / wake problems could have been addressed by making the size an explicit argument, rather than relying on overload resolution.  The semaphore issue could have been addressed by asking for contributions to the __threading_support bits before a release was cut.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68480/new/

https://reviews.llvm.org/D68480



More information about the libcxx-commits mailing list