roblabla | 8ff70b6 | 2018-08-02 13:46:37 +0200 | [diff] [blame] | 1 | //! Switch C type definitions |
| 2 | |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 3 | pub type int8_t = i8; |
| 4 | pub type int16_t = i16; |
| 5 | pub type int32_t = i32; |
| 6 | pub type int64_t = i64; |
| 7 | pub type uint8_t = u8; |
| 8 | pub type uint16_t = u16; |
| 9 | pub type uint32_t = u32; |
| 10 | pub type uint64_t = u64; |
| 11 | |
| 12 | pub type c_schar = i8; |
| 13 | pub type c_uchar = u8; |
| 14 | pub type c_short = i16; |
| 15 | pub type c_ushort = u16; |
| 16 | pub type c_int = i32; |
| 17 | pub type c_uint = u32; |
| 18 | pub type c_float = f32; |
| 19 | pub type c_double = f64; |
| 20 | pub type c_longlong = i64; |
| 21 | pub type c_ulonglong = u64; |
| 22 | pub type intmax_t = i64; |
| 23 | pub type uintmax_t = u64; |
| 24 | |
| 25 | pub type size_t = usize; |
| 26 | pub type ptrdiff_t = isize; |
| 27 | pub type intptr_t = isize; |
| 28 | pub type uintptr_t = usize; |
| 29 | pub type ssize_t = isize; |
| 30 | |
roblabla | 8ff70b6 | 2018-08-02 13:46:37 +0200 | [diff] [blame] | 31 | pub type off_t = i64; |
| 32 | pub type c_char = u8; |
| 33 | pub type c_long = i64; |
| 34 | pub type c_ulong = u64; |
| 35 | pub type wchar_t = u32; |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 36 | |
| 37 | pub const INT_MIN: c_int = -2147483648; |
| 38 | pub const INT_MAX: c_int = 2147483647; |
| 39 | |
| 40 | cfg_if! { |
gnzlbg | a17a91c | 2019-02-07 11:37:21 +0100 | [diff] [blame] | 41 | if #[cfg(libc_core_cvoid)] { |
| 42 | pub use ::ffi::c_void; |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 43 | } else { |
| 44 | // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help |
| 45 | // enable more optimization opportunities around it recognizing things |
| 46 | // like malloc/free. |
| 47 | #[repr(u8)] |
Bryant Mairs | f368458 | 2019-01-23 07:23:09 -0800 | [diff] [blame] | 48 | #[allow(missing_copy_implementations)] |
gnzlbg | a17a91c | 2019-02-07 11:37:21 +0100 | [diff] [blame] | 49 | #[allow(missing_debug_implementations)] |
gnzlbg | 5c1a6b8 | 2018-11-21 20:34:50 +0100 | [diff] [blame] | 50 | pub enum c_void { |
| 51 | // Two dummy variants so the #[repr] attribute can be used. |
| 52 | #[doc(hidden)] |
| 53 | __variant1, |
| 54 | #[doc(hidden)] |
| 55 | __variant2, |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |