diff options
author | roblabla <unfiltered@roblab.la> | 2018-08-02 13:46:37 +0200 |
---|---|---|
committer | roblabla <unfiltered@roblab.la> | 2018-08-02 13:46:37 +0200 |
commit | 8ff70b6a4c8feeba9e9c00bb4d1a0af4b94d4bb1 (patch) | |
tree | 14b4f3a3c3012077d3f31f51d374281454c62eb4 /src/switch.rs | |
parent | 8318a3ec1c1f13aab21d0a74ac9a7cf618bb2261 (diff) | |
download | rust-libc-8ff70b6a4c8feeba9e9c00bb4d1a0af4b94d4bb1.tar.gz |
Add some switch-related libc typedefs
Diffstat (limited to 'src/switch.rs')
-rw-r--r-- | src/switch.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/switch.rs b/src/switch.rs new file mode 100644 index 0000000000..c11379541e --- /dev/null +++ b/src/switch.rs @@ -0,0 +1,48 @@ +//! Switch C type definitions + +// 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, +} + +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; + +// Arch specific +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; |