Skip to content

Commit

Permalink
fix all features
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Dec 17, 2022
1 parent de040ba commit d946bc2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ serde = { version = "1.0.103", optional = true, default-features = false }
critical-section = { version = "1", optional = true }

[dev-dependencies]
critical-section = { version = "1", features = ["std"] }
crossbeam-utils = "0.8"
fastrand = "1"
paste = "1"
Expand Down
2 changes: 2 additions & 0 deletions src/imp/interrupt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
// [^avr1]: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp#L1008
// [^avr2]: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/llvm/test/CodeGen/AVR/atomics/load16.ll#L5

#![cfg_attr(test, allow(dead_code))]

// On some platforms, atomic load/store can be implemented in a more efficient
// way than disabling interrupts. On MSP430, some RMWs that do not return the
// previous value can also be optimized.
Expand Down
36 changes: 27 additions & 9 deletions src/imp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
#[cfg(not(any(
portable_atomic_no_atomic_load_store,
portable_atomic_unsafe_assume_single_core,
feature = "critical-section",
target_arch = "avr",
target_arch = "msp430",
)))]
#[cfg_attr(
portable_atomic_no_cfg_target_has_atomic,
cfg(not(all(feature = "critical-section", portable_atomic_no_atomic_cas)))
)]
#[cfg_attr(
not(portable_atomic_no_cfg_target_has_atomic),
cfg(not(all(
any(target_arch = "riscv32", target_arch = "riscv64"),
any(target_arch = "riscv32", target_arch = "riscv64", feature = "critical-section"),
not(target_has_atomic = "ptr")
)))
)]
Expand Down Expand Up @@ -147,14 +150,17 @@ pub(crate) mod float;
#[cfg(not(any(
portable_atomic_no_atomic_load_store,
portable_atomic_unsafe_assume_single_core,
feature = "critical-section",
target_arch = "avr",
target_arch = "msp430",
)))]
#[cfg_attr(
portable_atomic_no_cfg_target_has_atomic,
cfg(not(all(feature = "critical-section", portable_atomic_no_atomic_cas)))
)]
#[cfg_attr(
not(portable_atomic_no_cfg_target_has_atomic),
cfg(not(all(
any(target_arch = "riscv32", target_arch = "riscv64"),
any(target_arch = "riscv32", target_arch = "riscv64", feature = "critical-section"),
not(target_has_atomic = "ptr")
)))
)]
Expand Down Expand Up @@ -186,14 +192,17 @@ pub(crate) use self::interrupt::{
#[cfg(not(any(
portable_atomic_no_atomic_load_store,
portable_atomic_unsafe_assume_single_core,
feature = "critical-section",
target_arch = "avr",
target_arch = "msp430",
)))]
#[cfg_attr(
portable_atomic_no_cfg_target_has_atomic,
cfg(not(all(feature = "critical-section", portable_atomic_no_atomic_cas)))
)]
#[cfg_attr(
not(portable_atomic_no_cfg_target_has_atomic),
cfg(not(all(
any(target_arch = "riscv32", target_arch = "riscv64"),
any(target_arch = "riscv32", target_arch = "riscv64", feature = "critical-section"),
not(target_has_atomic = "ptr")
)))
)]
Expand All @@ -220,17 +229,26 @@ pub(crate) use self::interrupt::{AtomicI32, AtomicU32};
#[cfg(not(any(
portable_atomic_no_atomic_load_store,
portable_atomic_unsafe_assume_single_core,
feature = "critical-section",
)))]
#[cfg_attr(portable_atomic_no_cfg_target_has_atomic, cfg(not(portable_atomic_no_atomic_64)))]
#[cfg_attr(
portable_atomic_no_cfg_target_has_atomic,
cfg(not(any(
portable_atomic_no_atomic_64,
not(all(feature = "critical-section", portable_atomic_no_atomic_cas))
)))
)]
#[cfg_attr(
not(portable_atomic_no_cfg_target_has_atomic),
cfg(any(
target_has_atomic = "64",
all(
not(any(target_pointer_width = "16", target_pointer_width = "32")),
not(all(
any(target_arch = "riscv32", target_arch = "riscv64"),
any(
target_arch = "riscv32",
target_arch = "riscv64",
feature = "critical-section"
),
not(target_has_atomic = "ptr")
))
)
Expand Down

0 comments on commit d946bc2

Please sign in to comment.