Skip to content

Commit 3cc7a9c

Browse files
tylerwhalltomtom5152
authored andcommitted
Zephyr OS support
1 parent 9fe7b4e commit 3cc7a9c

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ cfg_if! {
157157

158158
mod xous;
159159
pub use xous::*;
160+
} else if #[cfg(target_os = "zephyr")] {
161+
mod zephyr;
162+
pub use zephyr::*;
160163
} else {
161164
// non-supported targets: empty...
162165
}

src/zephyr/mod.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//! Definitions found commonly among almost all Unix derivatives
2+
//!
3+
//! More functions and definitions can be found in the more specific modules
4+
//! according to the platform in question.
5+
6+
pub type int8_t = i8;
7+
pub type int16_t = i16;
8+
pub type int32_t = i32;
9+
pub type int64_t = i64;
10+
pub type uint8_t = u8;
11+
pub type uint16_t = u16;
12+
pub type uint32_t = u32;
13+
pub type uint64_t = u64;
14+
15+
pub type c_schar = i8;
16+
pub type c_uchar = u8;
17+
pub type c_short = i16;
18+
pub type c_ushort = u16;
19+
pub type c_int = i32;
20+
pub type c_uint = u32;
21+
pub type c_float = f32;
22+
pub type c_double = f64;
23+
pub type c_longlong = i64;
24+
pub type c_ulonglong = u64;
25+
pub type intmax_t = i64;
26+
pub type uintmax_t = u64;
27+
28+
pub type size_t = usize;
29+
pub type ptrdiff_t = isize;
30+
pub type intptr_t = isize;
31+
pub type uintptr_t = usize;
32+
pub type ssize_t = isize;
33+
34+
cfg_if! {
35+
if #[cfg(libc_core_cvoid)] {
36+
pub use ::ffi::c_void;
37+
} else {
38+
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
39+
// enable more optimization opportunities around it recognizing things
40+
// like malloc/free.
41+
#[repr(u8)]
42+
#[allow(missing_copy_implementations)]
43+
#[allow(missing_debug_implementations)]
44+
pub enum c_void {
45+
// Two dummy variants so the #[repr] attribute can be used.
46+
#[doc(hidden)]
47+
__variant1,
48+
#[doc(hidden)]
49+
__variant2,
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)