1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#![unstable(feature = "raw_os", reason = "recently added API")]
#[cfg(target_arch = "aarch64")] pub type c_char = u8;
#[cfg(not(target_arch = "aarch64"))] pub type c_char = i8;
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;
#[cfg(any(target_pointer_width = "32", windows))] pub type c_long = i32;
#[cfg(any(target_pointer_width = "32", windows))] pub type c_ulong = u32;
#[cfg(all(target_pointer_width = "64", not(windows)))] pub type c_long = i64;
#[cfg(all(target_pointer_width = "64", not(windows)))] pub type c_ulong = u64;
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type c_float = f32;
pub type c_double = f64;
#[repr(u8)]
pub enum c_void {
#[doc(hidden)] __variant1,
#[doc(hidden)] __variant2,
}
#[cfg(test)]
mod tests {
use any::TypeId;
use libc;
use mem;
macro_rules! ok {
($($t:ident)*) => {$(
assert!(TypeId::of::<libc::$t>() == TypeId::of::<raw::$t>(),
"{} is wrong", stringify!($t));
)*}
}
macro_rules! ok_size {
($($t:ident)*) => {$(
assert!(mem::size_of::<libc::$t>() == mem::size_of::<raw::$t>(),
"{} is wrong", stringify!($t));
)*}
}
#[test]
fn same() {
use os::raw;
ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
c_longlong c_ulonglong c_float c_double);
}
#[cfg(unix)]
fn unix() {
{
use os::unix::raw;
ok!(uid_t gid_t dev_t ino_t mode_t nlink_t off_t blksize_t blkcnt_t);
}
{
use sys::platform::raw;
ok_size!(stat);
}
}
#[cfg(windows)]
fn windows() {
use os::windows::raw;
}
}