-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
core: Support variety of atomic widths in width-agnostic functions #106856
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @scottmcm (or someone else) soon. Please see the contribution instructions for more information. |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
4b6e7aa
to
5740692
Compare
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.
Not really my place to review this, just my 2 cents
5740692
to
5868b3f
Compare
ef104b3
to
e00a9a8
Compare
@bjorn3 ping. Does it look good for you now? |
LGTM. I will defer to |
We need to wait for the following fixes in Rust nightly to be able to use the newest one: * rust-lang/rust#106796 * rust-lang/rust#106856 Signed-off-by: Michal Rostecki <[email protected]>
We need to wait for the following fixes in Rust nightly to be able to use the newest one: * rust-lang/rust#106796 * rust-lang/rust#106856 Signed-off-by: Michal Rostecki <[email protected]>
We need to wait for the following fixes in Rust nightly to be able to use the newest one: * rust-lang/rust#106796 * rust-lang/rust#106856 Signed-off-by: Michal Rostecki <[email protected]>
We need to wait for the following fixes in Rust nightly to be able to use the newest one: * rust-lang/rust#106796 * rust-lang/rust#106856 Signed-off-by: Michal Rostecki <[email protected]>
@scottmcm ping Sorry for rushing, but it's quite urgent PR, we are trying to unblock BPF builds in Nightly. |
Atomic operations for different widths (8-bit, 16-bit, 32-bit etc.) are guarded by `target_has_atomic = "value"` symbol (i.e. `target_has_atomic = "8"`) (and the other derivatives), but before this change, there was no width-agnostic symbol indicating a general availability of atomic operations. This change introduces: * `target_has_atomic_load_store` symbol when atomics for any integer width are supported by the target. * `target_has_atomic` symbol when also CAS is supported. Fixes rust-lang#106845 Signed-off-by: Michal Rostecki <[email protected]>
Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or `#[cfg(target_has_atomic_load_store = "8")]`: * `atomic_int` * `strongest_failure_ordering` * `atomic_swap` * `atomic_add` * `atomic_sub` * `atomic_compare_exchange` * `atomic_compare_exchange_weak` * `atomic_and` * `atomic_nand` * `atomic_or` * `atomic_xor` * `atomic_max` * `atomic_min` * `atomic_umax` * `atomic_umin` However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it). This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths. Fixes rust-lang#106845 Fixes rust-lang#106795 Signed-off-by: Michal Rostecki <[email protected]>
e00a9a8
to
474ea87
Compare
This seems fine to me for nightly. I think this would probably be fine to stabilize, but I'd want to give some more detailed thought to the case of unsupported sizes on a given target. I think that works correctly, and the way @alessandrod explained it to me on Zulip made sense, but I'd want to doublecheck before stabilizing. But for nightly: @bors r+ |
… r=joshtriplett core: Support variety of atomic widths in width-agnostic functions Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or `#[cfg(target_has_atomic_load_store = "8")]`: * `atomic_int` * `strongest_failure_ordering` * `atomic_swap` * `atomic_add` * `atomic_sub` * `atomic_compare_exchange` * `atomic_compare_exchange_weak` * `atomic_and` * `atomic_nand` * `atomic_or` * `atomic_xor` * `atomic_max` * `atomic_min` * `atomic_umax` * `atomic_umin` However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it). This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths. Fixes rust-lang#106845 Fixes rust-lang#106795 Signed-off-by: Michal Rostecki <[email protected]>
Rollup of 8 pull requests Successful merges: - rust-lang#105784 (update stdarch) - rust-lang#106856 (core: Support variety of atomic widths in width-agnostic functions) - rust-lang#107171 (rustc_metadata: Fix `encode_attrs`) - rust-lang#107242 (rustdoc: make item links consistently use `title="{shortty} {path}"`) - rust-lang#107279 (Use new solver during selection) - rust-lang#107284 (rustdoc: use smarter encoding for playground URL) - rust-lang#107325 (rustdoc: Stop using `HirId`s) - rust-lang#107336 (rustdoc: remove mostly-unused CSS classes `import-item` and `module-item`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Before this change, the following functions and macros were annotated with
#[cfg(target_has_atomic = "8")]
or#[cfg(target_has_atomic_load_store = "8")]
:atomic_int
strongest_failure_ordering
atomic_swap
atomic_add
atomic_sub
atomic_compare_exchange
atomic_compare_exchange_weak
atomic_and
atomic_nand
atomic_or
atomic_xor
atomic_max
atomic_min
atomic_umax
atomic_umin
However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it).
This change fixes that by removing the
"8"
argument from annotations, which results in accepting the whole variety of widths.Fixes #106845
Fixes #106795
Signed-off-by: Michal Rostecki [email protected]