1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Raw OS-specific types for the current platform/architecture
13 #![stable(feature = "raw_os", since = "1.1.0")]
15 #[cfg(all(not(target_os = "ios"), not(target_os = "macos"),
16 any(target_arch = "aarch64", target_arch = "arm",
17 target_os = "android")))]
18 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
19 #[cfg(any(target_os = "ios", target_os = "macos",
20 not(any(target_arch = "aarch64", target_arch = "arm",
21 target_os = "android"))))]
22 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
23 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;
24 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uchar = u8;
25 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_short = i16;
26 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ushort = u16;
27 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_int = i32;
28 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uint = u32;
29 #[cfg(any(target_pointer_width = "32", windows))]
30 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i32;
31 #[cfg(any(target_pointer_width = "32", windows))]
32 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u32;
33 #[cfg(all(target_pointer_width = "64", not(windows)))]
34 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i64;
35 #[cfg(all(target_pointer_width = "64", not(windows)))]
36 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u64;
37 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_longlong = i64;
38 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulonglong = u64;
39 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_float = f32;
40 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_double = f64;
42 /// Type used to construct void pointers for use with C.
44 /// This type is only useful as a pointer target. Do not use it as a
45 /// return type for FFI functions which have the `void` return type in
46 /// C. Use the unit type `()` or omit the return type instead.
47 // NB: For LLVM to recognize the void pointer type and by extension
48 // functions like malloc(), we need to have it represented as i8* in
49 // LLVM bitcode. The enum used here ensures this and prevents misuse
50 // of the "raw" type by only having private variants.. We need two
51 // variants, because the compiler complains about the repr attribute
54 #[stable(feature = "raw_os", since = "1.1.0")]
56 #[unstable(feature = "c_void_variant", reason = "should not have to exist",
58 #[doc(hidden)] __variant1,
59 #[unstable(feature = "c_void_variant", reason = "should not have to exist",
61 #[doc(hidden)] __variant2,
72 assert!(TypeId::of::<libc::$t>() == TypeId::of::<raw::$t>(),
73 "{} is wrong", stringify!($t));
77 macro_rules! ok_size {
79 assert!(mem::size_of::<libc::$t>() == mem::size_of::<raw::$t>(),
80 "{} is wrong", stringify!($t));
87 ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
88 c_longlong c_ulonglong c_float c_double);
95 ok!(uid_t gid_t dev_t ino_t mode_t nlink_t off_t blksize_t blkcnt_t);
98 use sys::platform::raw;
105 use os::windows::raw;