Skip to content
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

Merged
merged 2 commits into from
Jan 27, 2023

Commits on Jan 25, 2023

  1. Add target_has_atomic* symbols if any atomic width is supported

    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]>
    vadorovsky committed Jan 25, 2023
    Configuration menu
    Copy the full SHA
    1cd7dbf View commit details
    Browse the repository at this point in the history
  2. 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]>
    vadorovsky committed Jan 25, 2023
    Configuration menu
    Copy the full SHA
    474ea87 View commit details
    Browse the repository at this point in the history