Add std cargo feature

This commit is contained in:
Caleb Zulawski 2021-03-06 21:56:01 -05:00 committed by Jubilee Young
parent d95433dbb5
commit fa77b196c8
4 changed files with 19 additions and 8 deletions

View File

@ -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"

View File

@ -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;

View File

@ -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 {

View File

@ -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(