Skip to content

[runloop] Fix the failure memory order argument to atomic_compare_exchange_strong_explicit #4855

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

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

MaskRay
Copy link
Contributor

@MaskRay MaskRay commented Dec 19, 2023

The failure memory order cannot be release or acq_rel. Clang since llvm/llvm-project@fed5644 diagnoses an invalid argument.

…hange_strong_explicit

The failure memory order cannot be release or acq_rel. Clang since
llvm/llvm-project@fed5644
diagnoses an invalid argument.
@AZero13
Copy link
Contributor

AZero13 commented Dec 20, 2023

@compnerd please take a look at this

@@ -1306,7 +1306,7 @@ static Boolean __CFRunLoopSourceIsSignaled(CFRunLoopSourceRef rls) {
}

CF_INLINE void __CFRunLoopSourceSetSignaled(CFRunLoopSourceRef rls) {
atomic_compare_exchange_strong_explicit(&rls->_signaledTime, &(uint64_t){0}, mach_absolute_time(), memory_order_acq_rel, memory_order_acq_rel);
atomic_compare_exchange_strong_explicit(&rls->_signaledTime, &(uint64_t){0}, mach_absolute_time(), memory_order_acq_rel, memory_order_acquire);
Copy link
Contributor

@AZero13 AZero13 Dec 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After more testing, just go with

CF_INLINE void __CFRunLoopSourceSetSignaled(CFRunLoopSourceRef rls) {
    uint64_t zero = 0;
    atomic_compare_exchange_strong_explicit(&rls->_signaledTime, &zero, mach_absolute_time(), memory_order_release, memory_order_relaxed);
}

Copy link
Contributor

@Azoy Azoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for contributing! This change looks fine to me. It was mentioned that we could probably downgrade the memory ordering here, but this change doesn't change any existing behavior and just keeps the status quo working. Thanks!

@Azoy
Copy link
Contributor

Azoy commented Jan 5, 2024

@swift-ci please test

@Azoy Azoy merged commit dbca8c7 into swiftlang:main Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants