Skip to content

Commit 9bd9ba4

Browse files
committed
add support for no_std
1 parent b40f23b commit 9bd9ba4

File tree

7 files changed

+23
-3
lines changed

7 files changed

+23
-3
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ cupid = "0.3"
3232

3333
[features]
3434
strict = []
35+
std = []

ci/run.sh

+3
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ echo "RUSTFLAGS=${RUSTFLAGS}"
1919

2020
cargo test --target $TARGET --features "strict"
2121
cargo test --release --target $TARGET --features "strict"
22+
23+
cargo test --target $TARGET --features "strict,std"
24+
cargo test --release --target $TARGET --features "strict,std"

src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@
128128
cast_possible_truncation, cast_precision_loss,
129129
shadow_reuse, cyclomatic_complexity, similar_names,
130130
doc_markdown, many_single_char_names))]
131+
#![cfg_attr(not(feature = "std"), no_std)]
132+
133+
#[cfg(not(feature = "std"))]
134+
extern crate core as std;
131135

132136
#[cfg(test)]
133137
extern crate stdsimd_test;

src/x86/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,14 @@ mod abm;
4141
mod bmi;
4242
mod bmi2;
4343
mod tbm;
44+
45+
#[allow(non_camel_case_types)]
46+
#[cfg(not(feature = "std"))]
47+
#[repr(u8)]
48+
pub enum c_void {
49+
#[doc(hidden)] __variant1,
50+
#[doc(hidden)] __variant2,
51+
}
52+
53+
#[cfg(feature = "std")]
54+
use std::os::raw::c_void;

src/x86/runtime.rs

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ pub fn __unstable_detect_feature(x: __Feature) -> bool {
283283

284284
#[cfg(test)]
285285
mod tests {
286+
#[cfg(feature = "std")]
286287
#[test]
287288
fn runtime_detection_x86_nocapture() {
288289
println!("sse: {:?}", cfg_feature_enabled!("sse"));

src/x86/sse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use simd_llvm::simd_shuffle4;
44
use v128::*;
55
use v64::f32x2;
6-
use std::os::raw::c_void;
6+
use super::c_void;
77
use std::mem;
88
use std::ptr;
99

src/x86/sse2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use stdsimd_test::assert_instr;
55

66
use std::mem;
7-
use std::os::raw::c_void;
7+
use super::c_void;
88
use std::ptr;
99

1010
use simd_llvm::{simd_cast, simd_shuffle16, simd_shuffle2, simd_shuffle4,
@@ -2242,7 +2242,7 @@ extern "C" {
22422242

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

0 commit comments

Comments
 (0)