]> git.lizzy.rs Git - rust.git/blob - library/std/src/os/raw/mod.rs
Rollup merge of #72734 - pickfire:liballoc, r=KodrAus
[rust.git] / library / std / src / os / raw / mod.rs
1 //! Platform-specific types, as defined by C.
2 //!
3 //! Code that interacts via FFI will almost certainly be using the
4 //! base types provided by C, which aren't nearly as nicely defined
5 //! as Rust's primitive types. This module provides types which will
6 //! match those defined by C, so that code that interacts with C will
7 //! refer to the correct types.
8
9 #![stable(feature = "raw_os", since = "1.1.0")]
10
11 #[cfg(test)]
12 mod tests;
13
14 #[doc(include = "char.md")]
15 #[cfg(any(
16     all(
17         target_os = "linux",
18         any(
19             target_arch = "aarch64",
20             target_arch = "arm",
21             target_arch = "hexagon",
22             target_arch = "powerpc",
23             target_arch = "powerpc64",
24             target_arch = "s390x",
25             target_arch = "riscv64",
26             target_arch = "riscv32"
27         )
28     ),
29     all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")),
30     all(target_os = "l4re", target_arch = "x86_64"),
31     all(
32         target_os = "freebsd",
33         any(
34             target_arch = "aarch64",
35             target_arch = "arm",
36             target_arch = "powerpc",
37             target_arch = "powerpc64"
38         )
39     ),
40     all(
41         target_os = "netbsd",
42         any(target_arch = "aarch64", target_arch = "arm", target_arch = "powerpc")
43     ),
44     all(target_os = "openbsd", target_arch = "aarch64"),
45     all(
46         target_os = "vxworks",
47         any(
48             target_arch = "aarch64",
49             target_arch = "arm",
50             target_arch = "powerpc64",
51             target_arch = "powerpc"
52         )
53     ),
54     all(target_os = "fuchsia", target_arch = "aarch64")
55 ))]
56 #[stable(feature = "raw_os", since = "1.1.0")]
57 pub type c_char = u8;
58 #[doc(include = "char.md")]
59 #[cfg(not(any(
60     all(
61         target_os = "linux",
62         any(
63             target_arch = "aarch64",
64             target_arch = "arm",
65             target_arch = "hexagon",
66             target_arch = "powerpc",
67             target_arch = "powerpc64",
68             target_arch = "s390x",
69             target_arch = "riscv64",
70             target_arch = "riscv32"
71         )
72     ),
73     all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")),
74     all(target_os = "l4re", target_arch = "x86_64"),
75     all(
76         target_os = "freebsd",
77         any(
78             target_arch = "aarch64",
79             target_arch = "arm",
80             target_arch = "powerpc",
81             target_arch = "powerpc64"
82         )
83     ),
84     all(
85         target_os = "netbsd",
86         any(target_arch = "aarch64", target_arch = "arm", target_arch = "powerpc")
87     ),
88     all(target_os = "openbsd", target_arch = "aarch64"),
89     all(
90         target_os = "vxworks",
91         any(
92             target_arch = "aarch64",
93             target_arch = "arm",
94             target_arch = "powerpc64",
95             target_arch = "powerpc"
96         )
97     ),
98     all(target_os = "fuchsia", target_arch = "aarch64")
99 )))]
100 #[stable(feature = "raw_os", since = "1.1.0")]
101 pub type c_char = i8;
102 #[doc(include = "schar.md")]
103 #[stable(feature = "raw_os", since = "1.1.0")]
104 pub type c_schar = i8;
105 #[doc(include = "uchar.md")]
106 #[stable(feature = "raw_os", since = "1.1.0")]
107 pub type c_uchar = u8;
108 #[doc(include = "short.md")]
109 #[stable(feature = "raw_os", since = "1.1.0")]
110 pub type c_short = i16;
111 #[doc(include = "ushort.md")]
112 #[stable(feature = "raw_os", since = "1.1.0")]
113 pub type c_ushort = u16;
114 #[doc(include = "int.md")]
115 #[stable(feature = "raw_os", since = "1.1.0")]
116 pub type c_int = i32;
117 #[doc(include = "uint.md")]
118 #[stable(feature = "raw_os", since = "1.1.0")]
119 pub type c_uint = u32;
120 #[doc(include = "long.md")]
121 #[cfg(any(target_pointer_width = "32", windows))]
122 #[stable(feature = "raw_os", since = "1.1.0")]
123 pub type c_long = i32;
124 #[doc(include = "ulong.md")]
125 #[cfg(any(target_pointer_width = "32", windows))]
126 #[stable(feature = "raw_os", since = "1.1.0")]
127 pub type c_ulong = u32;
128 #[doc(include = "long.md")]
129 #[cfg(all(target_pointer_width = "64", not(windows)))]
130 #[stable(feature = "raw_os", since = "1.1.0")]
131 pub type c_long = i64;
132 #[doc(include = "ulong.md")]
133 #[cfg(all(target_pointer_width = "64", not(windows)))]
134 #[stable(feature = "raw_os", since = "1.1.0")]
135 pub type c_ulong = u64;
136 #[doc(include = "longlong.md")]
137 #[stable(feature = "raw_os", since = "1.1.0")]
138 pub type c_longlong = i64;
139 #[doc(include = "ulonglong.md")]
140 #[stable(feature = "raw_os", since = "1.1.0")]
141 pub type c_ulonglong = u64;
142 #[doc(include = "float.md")]
143 #[stable(feature = "raw_os", since = "1.1.0")]
144 pub type c_float = f32;
145 #[doc(include = "double.md")]
146 #[stable(feature = "raw_os", since = "1.1.0")]
147 pub type c_double = f64;
148
149 #[stable(feature = "raw_os", since = "1.1.0")]
150 #[doc(no_inline)]
151 pub use core::ffi::c_void;