blob: 06fa2030cdf569956fa773d2bc835338ab74bb8a [file] [log] [blame]
roblabla8ff70b62018-08-02 13:46:37 +02001//! Switch C type definitions
2
gnzlbg5c1a6b82018-11-21 20:34:50 +01003pub type int8_t = i8;
4pub type int16_t = i16;
5pub type int32_t = i32;
6pub type int64_t = i64;
7pub type uint8_t = u8;
8pub type uint16_t = u16;
9pub type uint32_t = u32;
10pub type uint64_t = u64;
11
12pub type c_schar = i8;
13pub type c_uchar = u8;
14pub type c_short = i16;
15pub type c_ushort = u16;
16pub type c_int = i32;
17pub type c_uint = u32;
18pub type c_float = f32;
19pub type c_double = f64;
20pub type c_longlong = i64;
21pub type c_ulonglong = u64;
22pub type intmax_t = i64;
23pub type uintmax_t = u64;
24
25pub type size_t = usize;
26pub type ptrdiff_t = isize;
27pub type intptr_t = isize;
28pub type uintptr_t = usize;
29pub type ssize_t = isize;
30
roblabla8ff70b62018-08-02 13:46:37 +020031pub type off_t = i64;
32pub type c_char = u8;
33pub type c_long = i64;
34pub type c_ulong = u64;
35pub type wchar_t = u32;
gnzlbg5c1a6b82018-11-21 20:34:50 +010036
37pub const INT_MIN: c_int = -2147483648;
38pub const INT_MAX: c_int = 2147483647;
39
40cfg_if! {
gnzlbga17a91c2019-02-07 11:37:21 +010041 if #[cfg(libc_core_cvoid)] {
42 pub use ::ffi::c_void;
gnzlbg5c1a6b82018-11-21 20:34:50 +010043 } 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 Mairsf3684582019-01-23 07:23:09 -080048 #[allow(missing_copy_implementations)]
gnzlbga17a91c2019-02-07 11:37:21 +010049 #[allow(missing_debug_implementations)]
gnzlbg5c1a6b82018-11-21 20:34:50 +010050 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