diff options
author | Isaac Woods <isaacwoods.home@gmail.com> | 2018-09-17 19:33:52 +0100 |
---|---|---|
committer | Isaac Woods <isaacwoods.home@gmail.com> | 2018-09-18 19:50:36 +0100 |
commit | 79c80c4ec44a470e3b9cb194da19a23a2ddb2f0a (patch) | |
tree | e78b3d081d52562641f106f0ee1d9d37d7a1340a /src/switch.rs | |
parent | 1844a772b60771d0124a157019f627d60fea4e73 (diff) | |
download | rust-libc-79c80c4ec44a470e3b9cb194da19a23a2ddb2f0a.tar.gz |
Re-export core::ffi::c_void if supported
Diffstat (limited to 'src/switch.rs')
-rw-r--r-- | src/switch.rs | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/switch.rs b/src/switch.rs index c11379541e..bb6df388e1 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -1,17 +1,5 @@ //! 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; @@ -46,3 +34,21 @@ pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; pub type wchar_t = u32; + +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, + } + } +} |