Skip to content

Commit

Permalink
Fix cargo features
Browse files Browse the repository at this point in the history
  • Loading branch information
calebzulawski committed Aug 20, 2021
1 parent d428753 commit 4c51420
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/core_simd/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![no_std]
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(incomplete_features)]
#![feature(
const_evaluatable_checked,
const_fn_trait_bound,
const_generics,
platform_intrinsics,
Expand All @@ -10,6 +9,10 @@
staged_api,
stdsimd
)]
#![cfg_attr(
feature = "const_evaluatable_checked",
feature(const_evaluatable_checked)
)]
#![warn(missing_docs)]
#![unstable(feature = "portable_simd", issue = "86656")]
//! Portable SIMD module.
Expand Down
2 changes: 2 additions & 0 deletions crates/core_simd/src/masks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,13 @@ where
}

/// Convert this mask to a bitmask, with one bit set per lane.
#[cfg(feature = "const_evaluatable_checked")]
pub fn to_bitmask(self) -> [u8; LaneCount::<LANES>::BITMASK_LEN] {
self.0.to_bitmask()
}

/// Convert a bitmask to a mask.
#[cfg(feature = "const_evaluatable_checked")]
pub fn from_bitmask(bitmask: [u8; LaneCount::<LANES>::BITMASK_LEN]) -> Self {
Self(mask_impl::Mask::from_bitmask(bitmask))
}
Expand Down
2 changes: 2 additions & 0 deletions crates/core_simd/src/masks/bitmask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ where
Self(core::mem::transmute_copy(&mask), PhantomData)
}

#[cfg(feature = "const_evaluatable_checked")]
#[inline]
pub fn to_bitmask(self) -> [u8; LaneCount::<LANES>::BITMASK_LEN] {
// Safety: these are the same type and we are laundering the generic
unsafe { core::mem::transmute_copy(&self.0) }
}

#[cfg(feature = "const_evaluatable_checked")]
#[inline]
pub fn from_bitmask(bitmask: [u8; LaneCount::<LANES>::BITMASK_LEN]) -> Self {
// Safety: these are the same type and we are laundering the generic
Expand Down
2 changes: 2 additions & 0 deletions crates/core_simd/src/masks/full_masks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ where
unsafe { Mask(crate::intrinsics::simd_cast(self.0)) }
}

#[cfg(feature = "const_evaluatable_checked")]
#[inline]
pub fn to_bitmask(self) -> [u8; LaneCount::<LANES>::BITMASK_LEN] {
unsafe {
Expand All @@ -127,6 +128,7 @@ where
}
}

#[cfg(feature = "const_evaluatable_checked")]
#[inline]
pub fn from_bitmask(mut bitmask: [u8; LaneCount::<LANES>::BITMASK_LEN]) -> Self {
unsafe {
Expand Down
1 change: 1 addition & 0 deletions crates/core_simd/tests/masks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ macro_rules! test_mask_api {
assert_eq!(core_simd::Mask::<$type, 8>::from_int(int), mask);
}

#[cfg(feature = "const_evaluatable_checked")]
#[test]
fn roundtrip_bitmask_conversion() {
let values = [
Expand Down

0 comments on commit 4c51420

Please sign in to comment.