From 7ffddb3549e42f1171457b782fdcba2d20cd8274 Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 2 Jul 2023 14:43:25 -0500 Subject: [PATCH] Only compile outlined-atomics intrinsics on linux --- src/{aarch64.rs => aarch64_linux.rs} | 0 src/lib.rs | 4 ++-- testcrate/tests/lse.rs | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) rename src/{aarch64.rs => aarch64_linux.rs} (100%) diff --git a/src/aarch64.rs b/src/aarch64_linux.rs similarity index 100% rename from src/aarch64.rs rename to src/aarch64_linux.rs diff --git a/src/lib.rs b/src/lib.rs index 58603a57..a6b61bdf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,8 +58,8 @@ pub mod mem; #[cfg(target_arch = "arm")] pub mod arm; -#[cfg(all(target_arch = "aarch64", not(feature = "no-asm"),))] -pub mod aarch64; +#[cfg(all(target_arch = "aarch64", target_os = "linux", not(feature = "no-asm"),))] +pub mod aarch64_linux; #[cfg(all( kernel_user_helpers, diff --git a/testcrate/tests/lse.rs b/testcrate/tests/lse.rs index 7b54ab5d..5589f22f 100644 --- a/testcrate/tests/lse.rs +++ b/testcrate/tests/lse.rs @@ -17,7 +17,9 @@ mod cas { testcrate::fuzz_2(10000, |expected: super::int_ty!($bytes), new| { let mut target = expected.wrapping_add(10); assert_eq!( - unsafe { compiler_builtins::aarch64::$name::$name(expected, new, &mut target) }, + unsafe { + compiler_builtins::aarch64_linux::$name::$name(expected, new, &mut target) + }, expected.wrapping_add(10), "return value should always be the previous value", ); @@ -29,7 +31,9 @@ mod cas { target = expected; assert_eq!( - unsafe { compiler_builtins::aarch64::$name::$name(expected, new, &mut target) }, + unsafe { + compiler_builtins::aarch64_linux::$name::$name(expected, new, &mut target) + }, expected ); assert_eq!(target, new, "should have updated target"); @@ -49,7 +53,7 @@ mod swap { testcrate::fuzz_2(10000, |left: super::int_ty!($bytes), mut right| { let orig_right = right; assert_eq!( - unsafe { compiler_builtins::aarch64::$name::$name(left, &mut right) }, + unsafe { compiler_builtins::aarch64_linux::$name::$name(left, &mut right) }, orig_right ); assert_eq!(left, right); @@ -69,7 +73,7 @@ macro_rules! test_op { let mut target = old; let op: fn(super::int_ty!($bytes), super::int_ty!($bytes)) -> _ = $($op)*; let expected = op(old, val); - assert_eq!(old, unsafe { compiler_builtins::aarch64::$name::$name(val, &mut target) }, "{} should return original value", stringify!($name)); + assert_eq!(old, unsafe { compiler_builtins::aarch64_linux::$name::$name(val, &mut target) }, "{} should return original value", stringify!($name)); assert_eq!(expected, target, "{} should store to target", stringify!($name)); }); }