diff options
author | gnzlbg <gonzalobg88@gmail.com> | 2018-11-21 20:34:50 +0100 |
---|---|---|
committer | gnzlbg <gonzalobg88@gmail.com> | 2018-11-21 20:58:02 +0100 |
commit | 5c1a6b8a6d558882927a0816d91c01b9c2a88018 (patch) | |
tree | cd0a4a4fb73591f7417756e56408d912fb1af043 /src/switch.rs | |
parent | 92172d91612e3b2673b69c0d040adc9418710ad9 (diff) | |
download | rust-libc-5c1a6b8a6d558882927a0816d91c01b9c2a88018.tar.gz |
splice the common libc functions and ctypes throughout the library
Diffstat (limited to 'src/switch.rs')
-rw-r--r-- | src/switch.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/switch.rs b/src/switch.rs index 240e938068..e2d9b491cb 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -1,7 +1,57 @@ //! Switch C type definitions +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + pub type off_t = i64; pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; pub type wchar_t = u32; + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +cfg_if! { + if #[cfg(core_cvoid)] { + pub use core::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} + |