about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCaleb Zulawski <caleb.zulawski@gmail.com>2021-03-06 21:56:01 -0500
committerJubilee Young <workingjubilee@gmail.com>2021-03-22 14:00:02 -0700
commitfa77b196c8f4cca27009c334f09466b80aca2f8a (patch)
tree39cc82b750142ee7c9ef7440c5e56aeb7d5dc1df
parentd95433dbb5ba16d809dab3fd8146847d0e38142e (diff)
downloadrust-fa77b196c8f4cca27009c334f09466b80aca2f8a.tar.gz
rust-fa77b196c8f4cca27009c334f09466b80aca2f8a.zip
Add std cargo feature
-rw-r--r--crates/core_simd/Cargo.toml4
-rw-r--r--crates/core_simd/src/intrinsics.rs2
-rw-r--r--crates/core_simd/src/round.rs2
-rw-r--r--crates/core_simd/tests/ops_macros.rs19
4 files changed, 19 insertions, 8 deletions
diff --git a/crates/core_simd/Cargo.toml b/crates/core_simd/Cargo.toml
index 26cc65a8687..6044eabcd14 100644
--- a/crates/core_simd/Cargo.toml
+++ b/crates/core_simd/Cargo.toml
@@ -9,6 +9,10 @@ keywords = ["core", "simd", "intrinsics"]
 categories = ["hardware-support", "no-std"]
 license = "MIT OR Apache-2.0"
 
+[features]
+default = ["std"]
+std = []
+
 [target.'cfg(target_arch = "wasm32")'.dev-dependencies.wasm-bindgen]
 version = "0.2"
 
diff --git a/crates/core_simd/src/intrinsics.rs b/crates/core_simd/src/intrinsics.rs
index 4ea38376348..213ebff3df4 100644
--- a/crates/core_simd/src/intrinsics.rs
+++ b/crates/core_simd/src/intrinsics.rs
@@ -41,9 +41,11 @@ extern "platform-intrinsic" {
     pub(crate) fn simd_cast<T, U>(x: T) -> U;
 
     // floor
+    #[cfg(feature = "std")]
     pub(crate) fn simd_floor<T>(x: T) -> T;
 
     // ceil
+    #[cfg(feature = "std")]
     pub(crate) fn simd_ceil<T>(x: T) -> T;
 
     pub(crate) fn simd_eq<T, U>(x: T, y: T) -> U;
diff --git a/crates/core_simd/src/round.rs b/crates/core_simd/src/round.rs
index ee232e2b222..dc37130a8ce 100644
--- a/crates/core_simd/src/round.rs
+++ b/crates/core_simd/src/round.rs
@@ -7,6 +7,7 @@ macro_rules! implement {
             Self: crate::LanesAtMost64,
         {
             /// Returns the largest integer less than or equal to each lane.
+            #[cfg(feature = "std")]
             #[must_use = "method returns a new vector and does not mutate the original value"]
             #[inline]
             pub fn floor(self) -> Self {
@@ -14,6 +15,7 @@ macro_rules! implement {
             }
 
             /// Returns the smallest integer greater than or equal to each lane.
+            #[cfg(feature = "std")]
             #[must_use = "method returns a new vector and does not mutate the original value"]
             #[inline]
             pub fn ceil(self) -> Self {
diff --git a/crates/core_simd/tests/ops_macros.rs b/crates/core_simd/tests/ops_macros.rs
index 58e80a8f277..8e0b9626861 100644
--- a/crates/core_simd/tests/ops_macros.rs
+++ b/crates/core_simd/tests/ops_macros.rs
@@ -265,15 +265,8 @@ macro_rules! impl_float_tests {
             impl_binary_op_test!(Vector<LANES>, Scalar, Div::div, DivAssign::div_assign);
             impl_binary_op_test!(Vector<LANES>, Scalar, Rem::rem, RemAssign::rem_assign);
 
+            #[cfg(feature = "std")]
             test_helpers::test_lanes! {
-                fn abs<const LANES: usize>() {
-                    test_helpers::test_unary_elementwise(
-                        &Vector::<LANES>::abs,
-                        &Scalar::abs,
-                        &|_| true,
-                    )
-                }
-
                 fn ceil<const LANES: usize>() {
                     test_helpers::test_unary_elementwise(
                         &Vector::<LANES>::ceil,
@@ -289,6 +282,16 @@ macro_rules! impl_float_tests {
                         &|_| true,
                     )
                 }
+            }
+
+            test_helpers::test_lanes! {
+                fn abs<const LANES: usize>() {
+                    test_helpers::test_unary_elementwise(
+                        &Vector::<LANES>::abs,
+                        &Scalar::abs,
+                        &|_| true,
+                    )
+                }
 
                 fn round_from_int<const LANES: usize>() {
                     test_helpers::test_unary_elementwise(