Skip to content

Commit 65c3ce9

Browse files
Merge pull request #81 from rust-lang/feature/std-cargo-feature
Add std cargo feature
2 parents d95433d + fa77b19 commit 65c3ce9

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

crates/core_simd/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ keywords = ["core", "simd", "intrinsics"]
99
categories = ["hardware-support", "no-std"]
1010
license = "MIT OR Apache-2.0"
1111

12+
[features]
13+
default = ["std"]
14+
std = []
15+
1216
[target.'cfg(target_arch = "wasm32")'.dev-dependencies.wasm-bindgen]
1317
version = "0.2"
1418

crates/core_simd/src/intrinsics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ extern "platform-intrinsic" {
4141
pub(crate) fn simd_cast<T, U>(x: T) -> U;
4242

4343
// floor
44+
#[cfg(feature = "std")]
4445
pub(crate) fn simd_floor<T>(x: T) -> T;
4546

4647
// ceil
48+
#[cfg(feature = "std")]
4749
pub(crate) fn simd_ceil<T>(x: T) -> T;
4850

4951
pub(crate) fn simd_eq<T, U>(x: T, y: T) -> U;

crates/core_simd/src/round.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ macro_rules! implement {
77
Self: crate::LanesAtMost64,
88
{
99
/// Returns the largest integer less than or equal to each lane.
10+
#[cfg(feature = "std")]
1011
#[must_use = "method returns a new vector and does not mutate the original value"]
1112
#[inline]
1213
pub fn floor(self) -> Self {
1314
unsafe { crate::intrinsics::simd_floor(self) }
1415
}
1516

1617
/// Returns the smallest integer greater than or equal to each lane.
18+
#[cfg(feature = "std")]
1719
#[must_use = "method returns a new vector and does not mutate the original value"]
1820
#[inline]
1921
pub fn ceil(self) -> Self {

crates/core_simd/tests/ops_macros.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,8 @@ macro_rules! impl_float_tests {
265265
impl_binary_op_test!(Vector<LANES>, Scalar, Div::div, DivAssign::div_assign);
266266
impl_binary_op_test!(Vector<LANES>, Scalar, Rem::rem, RemAssign::rem_assign);
267267

268+
#[cfg(feature = "std")]
268269
test_helpers::test_lanes! {
269-
fn abs<const LANES: usize>() {
270-
test_helpers::test_unary_elementwise(
271-
&Vector::<LANES>::abs,
272-
&Scalar::abs,
273-
&|_| true,
274-
)
275-
}
276-
277270
fn ceil<const LANES: usize>() {
278271
test_helpers::test_unary_elementwise(
279272
&Vector::<LANES>::ceil,
@@ -289,6 +282,16 @@ macro_rules! impl_float_tests {
289282
&|_| true,
290283
)
291284
}
285+
}
286+
287+
test_helpers::test_lanes! {
288+
fn abs<const LANES: usize>() {
289+
test_helpers::test_unary_elementwise(
290+
&Vector::<LANES>::abs,
291+
&Scalar::abs,
292+
&|_| true,
293+
)
294+
}
292295

293296
fn round_from_int<const LANES: usize>() {
294297
test_helpers::test_unary_elementwise(

0 commit comments

Comments
 (0)