Skip to content

Commit 23d73d5

Browse files
authored
Merge pull request #1753 from overdrivenpotato/psp
Add c typedefs for the Sony PSP
2 parents bb734e3 + 5dfe013 commit 23d73d5

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ cfg_if! {
115115

116116
mod switch;
117117
pub use switch::*;
118+
} else if #[cfg(target_os = "psp")] {
119+
mod fixed_width_ints;
120+
pub use fixed_width_ints::*;
121+
122+
mod psp;
123+
pub use psp::*;
118124
} else if #[cfg(target_os = "vxworks")] {
119125
mod fixed_width_ints;
120126
pub use fixed_width_ints::*;

src/psp.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//! PSP C type definitions
2+
3+
pub type c_schar = i8;
4+
pub type c_uchar = u8;
5+
pub type c_short = i16;
6+
pub type c_ushort = u16;
7+
pub type c_int = i32;
8+
pub type c_uint = u32;
9+
pub type c_float = f32;
10+
pub type c_double = f64;
11+
pub type c_longlong = i64;
12+
pub type c_ulonglong = u64;
13+
pub type intmax_t = i64;
14+
pub type uintmax_t = u64;
15+
16+
pub type size_t = usize;
17+
pub type ptrdiff_t = isize;
18+
pub type intptr_t = isize;
19+
pub type uintptr_t = usize;
20+
pub type ssize_t = isize;
21+
22+
pub type c_char = u8;
23+
pub type c_long = i64;
24+
pub type c_ulong = u64;
25+
26+
pub const INT_MIN: c_int = -2147483648;
27+
pub const INT_MAX: c_int = 2147483647;
28+
29+
cfg_if! {
30+
if #[cfg(libc_core_cvoid)] {
31+
pub use ::ffi::c_void;
32+
} else {
33+
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
34+
// enable more optimization opportunities around it recognizing things
35+
// like malloc/free.
36+
#[repr(u8)]
37+
#[allow(missing_copy_implementations)]
38+
#[allow(missing_debug_implementations)]
39+
pub enum c_void {
40+
// Two dummy variants so the #[repr] attribute can be used.
41+
#[doc(hidden)]
42+
__variant1,
43+
#[doc(hidden)]
44+
__variant2,
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)