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

rustc_data_structures: Explicitly check for 64-bit atomics support #127075

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ libc = "0.2"
memmap2 = "0.2.1"
# tidy-alphabetical-end

[target.'cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "sparc"))'.dependencies]
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
portable-atomic = "1.5.1"

[features]
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_data_structures/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,13 @@ cfg_match! {
[crate::owned_slice::OwnedSlice]
);

// MIPS, PowerPC and SPARC platforms with 32-bit pointers do not
// have AtomicU64 type.
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc", target_arch = "sparc")))]
// Use portable AtomicU64 for targets without native 64-bit atomics

Choose a reason for hiding this comment

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

Wrong comment position, should be placed before line 156.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment applies to both the following statements, see the comment from the previous version.

#[cfg(target_has_atomic = "64")]
already_sync!(
[std::sync::atomic::AtomicU64]
);

#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "sparc"))]
#[cfg(not(target_has_atomic = "64"))]
already_sync!(
[portable_atomic::AtomicU64]
);
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,11 @@ cfg_match! {

pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32};

// MIPS, PowerPC and SPARC platforms with 32-bit pointers do not
// have AtomicU64 type.
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "sparc")))]
// Use portable AtomicU64 for targets without native 64-bit atomics
#[cfg(target_has_atomic = "64")]
pub use std::sync::atomic::AtomicU64;

#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "sparc"))]
#[cfg(not(target_has_atomic = "64"))]
pub use portable_atomic::AtomicU64;

pub use std::sync::Arc as Lrc;
Expand Down
Loading