Skip to content

Commit 4a7a630

Browse files
committed
add support for no_std
1 parent 7d0ddd3 commit 4a7a630

File tree

7 files changed

+22
-3
lines changed

7 files changed

+22
-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+
nostd = []

ci/run.sh

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

2020
cargo test --target $TARGET --features "strict"
2121
cargo test --release --target $TARGET --features "strict"
22+
cargo test --release --target $TARGET --features "strict,nostd"

src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@
129129
shadow_reuse, cyclomatic_complexity, similar_names,
130130
doc_markdown, many_single_char_names))]
131131

132+
#![cfg_attr(feature="nostd", no_std)]
133+
134+
#[cfg(feature = "nostd")]
135+
extern crate core as std;
136+
132137
#[cfg(test)]
133138
extern crate stdsimd_test;
134139

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(feature = "nostd")]
47+
#[repr(u8)]
48+
pub enum c_void {
49+
#[doc(hidden)] __variant1,
50+
#[doc(hidden)] __variant2,
51+
}
52+
53+
#[cfg(not(feature = "nostd"))]
54+
use std::os::raw::c_void as 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(not(feature = "nostd"))]
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)