#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct Atomics {
has_8: bool,
has_16: bool,
has_32: bool,
has_64: bool,
has_ptr: bool,
}
impl Atomics {
const ALL: Self = Self {
has_8: true,
has_16: true,
has_32: true,
has_64: true,
has_ptr: true,
};
const NONE: Self = Self {
has_8: false,
has_16: false,
has_32: false,
has_64: false,
has_ptr: false,
};
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut atomics = Atomics::ALL;
let target = std::env::var("TARGET")?;
#[allow(clippy::match_single_binding, clippy::single_match)]
match &*target {
"arm-linux-androideabi" => atomics.has_64 = false,
_ => {}
}
let arch = target.split('-').next().ok_or("Invalid target triple")?;
#[allow(clippy::match_single_binding, clippy::single_match)]
match arch {
"mips" | "mipsel" | "powerpc" | "riscv32imac" => atomics.has_64 = false,
"riscv32i" | "riscv32imc" => atomics = Atomics::NONE,
_ => {}
}
if atomics.has_8 {
println!("cargo:rustc-cfg=radium_atomic_8");
}
if atomics.has_16 {
println!("cargo:rustc-cfg=radium_atomic_16");
}
if atomics.has_32 {
println!("cargo:rustc-cfg=radium_atomic_32");
}
if atomics.has_64 {
println!("cargo:rustc-cfg=radium_atomic_64");
}
if atomics.has_ptr {
println!("cargo:rustc-cfg=radium_atomic_ptr");
}
Ok(())
}