Skip to content

Commit

Permalink
add support for no_std
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Nov 17, 2017
1 parent 62a6cfe commit 231405f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ cupid = "0.3"

[features]
strict = []
std = []
3 changes: 3 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ echo "RUSTFLAGS=${RUSTFLAGS}"

cargo test --target $TARGET --features "strict"
cargo test --release --target $TARGET --features "strict"

cargo test --target $TARGET --features "strict,std"
cargo test --release --target $TARGET --features "strict,std"
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
cast_possible_truncation, cast_precision_loss,
shadow_reuse, cyclomatic_complexity, similar_names,
doc_markdown, many_single_char_names))]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
extern crate core as std;

#[cfg(test)]
extern crate stdsimd_test;
Expand Down
11 changes: 11 additions & 0 deletions src/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ mod abm;
mod bmi;
mod bmi2;
mod tbm;

#[allow(non_camel_case_types)]
#[cfg(not(feature = "std"))]
#[repr(u8)]
pub enum c_void {
#[doc(hidden)] __variant1,
#[doc(hidden)] __variant2,
}

#[cfg(feature = "std")]
use std::os::raw::c_void;
1 change: 1 addition & 0 deletions src/x86/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ pub fn __unstable_detect_feature(x: __Feature) -> bool {

#[cfg(test)]
mod tests {
#[cfg(feature = "std")]
#[test]
fn runtime_detection_x86_nocapture() {
println!("sse: {:?}", cfg_feature_enabled!("sse"));
Expand Down
2 changes: 1 addition & 1 deletion src/x86/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use simd_llvm::simd_shuffle4;
use v128::*;
use v64::f32x2;
use std::os::raw::c_void;
use super::c_void;
use std::mem;
use std::ptr;

Expand Down
4 changes: 2 additions & 2 deletions src/x86/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use stdsimd_test::assert_instr;

use std::mem;
use std::os::raw::c_void;
use super::c_void;
use std::ptr;

use simd_llvm::{simd_cast, simd_shuffle16, simd_shuffle2, simd_shuffle4,
Expand Down Expand Up @@ -2242,7 +2242,7 @@ extern "C" {

#[cfg(test)]
mod tests {
use std::os::raw::c_void;
use super::c_void;
use stdsimd_test::simd_test;
use test::black_box; // Used to inhibit constant-folding.

Expand Down

0 comments on commit 231405f

Please # to comment.