@@ -6,11 +6,28 @@ pub use std::os::raw as ctypes;
66
77#[ cfg( all( not( feature = "std" ) , feature = "no_std" ) ) ]
88pub mod ctypes {
9- // The signedness of `char` is platform-specific, however a consequence
10- // of it being platform-specific is that any code which depends on the
11- // signedness of `char` is already non-portable. So we can just use `u8`
12- // here and no portable code will notice.
13- pub type c_char = u8 ;
9+ // The signedness of `char` is platform-specific, and we have to match
10+ // what Rust's `CStr` uses.
11+ #[ cfg( any(
12+ target_arch = "aarch64" ,
13+ target_arch = "arm" ,
14+ target_arch = "msp430" ,
15+ target_arch = "powerpc" ,
16+ target_arch = "powerpc64" ,
17+ target_arch = "riscv32" ,
18+ target_arch = "riscv64" ,
19+ target_arch = "s390x" ,
20+ ) ) ]
21+ pub type c_char = c_uchar ;
22+ #[ cfg( any(
23+ target_arch = "mips" ,
24+ target_arch = "mips64" ,
25+ target_arch = "sparc64" ,
26+ target_arch = "x86" ,
27+ target_arch = "x86_64" ,
28+ target_arch = "xtensa" ,
29+ ) ) ]
30+ pub type c_char = c_schar ;
1431
1532 // The following assumes that Linux is always either ILP32 or LP64,
1633 // and char is always 8-bit.
0 commit comments