-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc++] Use Fuchsia futex operations #133571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
|
|
||
| _LIBCPP_BEGIN_NAMESPACE_STD | ||
|
|
||
| #if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__)) | ||
| #if defined(__linux__) || defined(__Fuchsia__) || (defined(_AIX) && !defined(__64BIT__)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't modify the C++03 headers for now.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @philnik777 Is this still an issue?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping @philnik777
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine now. The large refactorings have been done and I don't think I'll touch |
||
| using __cxx_contention_t = int32_t; | ||
| #else | ||
| using __cxx_contention_t = int64_t; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -41,6 +41,10 @@ | |||||
| // OpenBSD has no indirect syscalls | ||||||
| # define _LIBCPP_FUTEX(...) futex(__VA_ARGS__) | ||||||
|
|
||||||
| #elif defined(__Fuchsia__) | ||||||
|
|
||||||
| # include <zircon/syscalls.h> | ||||||
|
|
||||||
| #else // <- Add other operating systems here | ||||||
|
|
||||||
| // Baseline needs no new headers | ||||||
|
|
@@ -101,6 +105,24 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo | |||||
| _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr); | ||||||
| } | ||||||
|
|
||||||
| #elif defined(__Fuchsia__) | ||||||
|
|
||||||
| static inline zx_futex_t const* __libcpp_zx_futex(__cxx_atomic_contention_t const volatile* ptr) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's move away from |
||||||
| // Implicitly link against the vDSO system call ABI without requiring the | ||||||
| // final link to specify -lzircon explicitly when statically linking libc++. | ||||||
| # pragma comment(lib, "zircon") | ||||||
| return const_cast<zx_futex_t const*>(reinterpret_cast<zx_futex_t const volatile*>(&ptr->__a_value)); | ||||||
| } | ||||||
|
|
||||||
| static void | ||||||
| __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { | ||||||
| _zx_futex_wait(__libcpp_zx_futex(__ptr), __val, ZX_HANDLE_INVALID, ZX_TIME_INFINITE); | ||||||
| } | ||||||
|
|
||||||
| static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { | ||||||
| _zx_futex_wake(__libcpp_zx_futex(__ptr), __notify_one ? 1 : UINT32_MAX); | ||||||
| } | ||||||
|
|
||||||
| #else // <- Add other operating systems here | ||||||
|
|
||||||
| // Baseline is just a timed backoff | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be bit unfortunate, but isn’t this an ABI break for your platform ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not really an issue on Fuchsia.