Skip to content

Commit

Permalink
Conditionally compile atomic impls
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed May 19, 2023
1 parent a93a856 commit a96056c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions crates/musli/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ use core::num::{
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, Wrapping,
};
use core::sync::atomic::{
AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicU16, AtomicU32,
AtomicU64, AtomicU8, AtomicUsize,
AtomicBool, AtomicUsize, AtomicIsize,
};
#[cfg(target_has_atomic_load_store = "8")]
use core::sync::atomic::{AtomicI8, AtomicU8};
#[cfg(target_has_atomic_load_store = "16")]
use core::sync::atomic::{AtomicI16, AtomicU16};
#[cfg(target_has_atomic_load_store = "32")]
use core::sync::atomic::{AtomicI32, AtomicU32};
#[cfg(target_has_atomic_load_store = "64")]
use core::sync::atomic::{AtomicI64, AtomicU64};
use core::{fmt, marker};

use crate::de::{Decode, Decoder, ValueVisitor, VariantDecoder};
Expand Down Expand Up @@ -89,14 +96,22 @@ macro_rules! atomic_impl {
}

atomic_impl!(AtomicBool);
#[cfg(target_has_atomic_load_store = "16")]
atomic_impl!(AtomicI16);
#[cfg(target_has_atomic_load_store = "32")]
atomic_impl!(AtomicI32);
#[cfg(target_has_atomic_load_store = "64")]
atomic_impl!(AtomicI64);
#[cfg(target_has_atomic_load_store = "8")]
atomic_impl!(AtomicI8);
atomic_impl!(AtomicIsize);
#[cfg(target_has_atomic_load_store = "16")]
atomic_impl!(AtomicU16);
#[cfg(target_has_atomic_load_store = "32")]
atomic_impl!(AtomicU32);
#[cfg(target_has_atomic_load_store = "64")]
atomic_impl!(AtomicU64);
#[cfg(target_has_atomic_load_store = "8")]
atomic_impl!(AtomicU8);
atomic_impl!(AtomicUsize);

Expand Down
1 change: 1 addition & 0 deletions crates/musli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@
#![deny(missing_docs)]
#![no_std]
#![feature(cfg_target_has_atomic)]

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down

0 comments on commit a96056c

Please sign in to comment.