Skip to content

Commit

Permalink
Update no_atomic.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Aug 9, 2023
1 parent cd412be commit 8bfd8d1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
only_if: $CIRRUS_TAG == '' && ($CIRRUS_PR != '' || $CIRRUS_BRANCH == 'master' || $CIRRUS_BRANCH == 'staging')
only_if: $CIRRUS_TAG == '' && ($CIRRUS_PR != '' || $CIRRUS_BRANCH == 'staging')
auto_cancellation: $CIRRUS_BRANCH != 'master'
env:
CARGO_INCREMENTAL: '0'
Expand Down
18 changes: 13 additions & 5 deletions ci/no_atomic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cd "$(dirname "$0")"/..
file="no_atomic.rs"

no_atomic_cas=()
no_atomic_32=()
no_atomic_64=()
no_atomic=()
for target in $(rustc --print target-list); do
Expand All @@ -27,13 +28,11 @@ for target in $(rustc --print target-list); do
# `"target-pointer-width" == "32"`, so assuming them `"max-atomic-width" == 32`
# for now.
32 | null) no_atomic_64+=("${target}") ;;
16) no_atomic_32+=("${target}") ;;
# `"max-atomic-width" == 0` means that atomic is not supported at all.
0)
no_atomic_64+=("${target}")
no_atomic+=("${target}")
;;
0) no_atomic+=("${target}") ;;
64 | 128) ;;
# There is no `"max-atomic-width" == 16` or `"max-atomic-width" == 8` targets.
# There is no `"max-atomic-width" == 8` targets.
*) exit 1 ;;
esac
case "${min_atomic_width}" in
Expand Down Expand Up @@ -63,6 +62,15 @@ done
cat >>"${file}" <<EOF
];
#[allow(dead_code)] // Only crossbeam-utils uses this.
const NO_ATOMIC_32: &[&str] = &[
EOF
for target in "${no_atomic_32[@]}"; do
echo " \"${target}\"," >>"${file}"
done
cat >>"${file}" <<EOF
];
#[allow(dead_code)] // Only crossbeam-utils uses this.
const NO_ATOMIC: &[&str] = &[
EOF
Expand Down
4 changes: 4 additions & 0 deletions crossbeam-utils/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ fn main() {
}
if NO_ATOMIC.contains(&&*target) {
println!("cargo:rustc-cfg=crossbeam_no_atomic");
println!("cargo:rustc-cfg=crossbeam_no_atomic_32");
println!("cargo:rustc-cfg=crossbeam_no_atomic_64");
} else if NO_ATOMIC_32.contains(&&*target) {
println!("cargo:rustc-cfg=crossbeam_no_atomic_32");
println!("cargo:rustc-cfg=crossbeam_no_atomic_64");
} else if NO_ATOMIC_64.contains(&&*target) {
println!("cargo:rustc-cfg=crossbeam_no_atomic_64");
Expand Down
6 changes: 6 additions & 0 deletions crossbeam-utils/src/atomic/atomic_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,14 @@ impl_arithmetic!(u8, atomic::AtomicU8, "let a = AtomicCell::new(7u8);");
impl_arithmetic!(i8, atomic::AtomicI8, "let a = AtomicCell::new(7i8);");
impl_arithmetic!(u16, atomic::AtomicU16, "let a = AtomicCell::new(7u16);");
impl_arithmetic!(i16, atomic::AtomicI16, "let a = AtomicCell::new(7i16);");
#[cfg(not(crossbeam_no_atomic_32))]
impl_arithmetic!(u32, atomic::AtomicU32, "let a = AtomicCell::new(7u32);");
#[cfg(not(crossbeam_no_atomic_32))]
impl_arithmetic!(i32, atomic::AtomicI32, "let a = AtomicCell::new(7i32);");
#[cfg(crossbeam_no_atomic_32)]
impl_arithmetic!(u32, fallback, "let a = AtomicCell::new(7u32);");
#[cfg(crossbeam_no_atomic_32)]
impl_arithmetic!(i32, fallback, "let a = AtomicCell::new(7i32);");
#[cfg(not(crossbeam_no_atomic_64))]
impl_arithmetic!(u64, atomic::AtomicU64, "let a = AtomicCell::new(7u64);");
#[cfg(not(crossbeam_no_atomic_64))]
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-utils/src/atomic/consume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ impl_atomic!(AtomicU8, u8);
impl_atomic!(AtomicI8, i8);
impl_atomic!(AtomicU16, u16);
impl_atomic!(AtomicI16, i16);
#[cfg(not(crossbeam_no_atomic_32))]
impl_atomic!(AtomicU32, u32);
#[cfg(not(crossbeam_no_atomic_32))]
impl_atomic!(AtomicI32, i32);
#[cfg(not(crossbeam_no_atomic_64))]
impl_atomic!(AtomicU64, u64);
Expand Down
5 changes: 3 additions & 2 deletions crossbeam-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ mod primitive {
pub(crate) use core::sync::atomic::spin_loop_hint;
#[cfg(not(crossbeam_no_atomic))]
pub(crate) use core::sync::atomic::{
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32,
AtomicU8, AtomicUsize,
AtomicBool, AtomicI16, AtomicI8, AtomicIsize, AtomicU16, AtomicU8, AtomicUsize,
};
#[cfg(not(crossbeam_no_atomic_32))]
pub(crate) use core::sync::atomic::{AtomicI32, AtomicU32};
#[cfg(not(crossbeam_no_atomic_64))]
pub(crate) use core::sync::atomic::{AtomicI64, AtomicU64};
}
Expand Down
13 changes: 6 additions & 7 deletions no_atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,18 @@ const NO_ATOMIC_64: &[&str] = &[
"armv5te-unknown-linux-musleabi",
"armv5te-unknown-linux-uclibceabi",
"armv6k-nintendo-3ds",
"avr-unknown-gnu-atmega328",
"hexagon-unknown-linux-musl",
"m68k-unknown-linux-gnu",
"mips-unknown-linux-gnu",
"mips-unknown-linux-musl",
"mips-unknown-linux-uclibc",
"mipsel-sony-psp",
"mipsel-sony-psx",
"mipsel-unknown-linux-gnu",
"mipsel-unknown-linux-musl",
"mipsel-unknown-linux-uclibc",
"mipsel-unknown-none",
"mipsisa32r6-unknown-linux-gnu",
"mipsisa32r6el-unknown-linux-gnu",
"msp430-none-elf",
"powerpc-unknown-freebsd",
"powerpc-unknown-linux-gnu",
"powerpc-unknown-linux-gnuspe",
Expand All @@ -51,11 +48,9 @@ const NO_ATOMIC_64: &[&str] = &[
"powerpc-wrs-vxworks-spe",
"riscv32gc-unknown-linux-gnu",
"riscv32gc-unknown-linux-musl",
"riscv32i-unknown-none-elf",
"riscv32im-unknown-none-elf",
"riscv32imac-unknown-none-elf",
"riscv32imac-unknown-xous-elf",
"riscv32imc-unknown-none-elf",
"sparc-unknown-linux-gnu",
"sparc-unknown-none-elf",
"thumbv4t-none-eabi",
"thumbv5te-none-eabi",
Expand All @@ -69,8 +64,12 @@ const NO_ATOMIC_64: &[&str] = &[
];

#[allow(dead_code)] // Only crossbeam-utils uses this.
const NO_ATOMIC: &[&str] = &[
const NO_ATOMIC_32: &[&str] = &[
"avr-unknown-gnu-atmega328",
];

#[allow(dead_code)] // Only crossbeam-utils uses this.
const NO_ATOMIC: &[&str] = &[
"bpfeb-unknown-none",
"bpfel-unknown-none",
"mipsel-sony-psx",
Expand Down

0 comments on commit 8bfd8d1

Please sign in to comment.