Skip to main content

std/os/linux/
raw.rs

1//! Linux-specific raw type definitions.
2
3#![stable(feature = "raw_ext", since = "1.1.0")]
4#![deprecated(
5    since = "1.8.0",
6    note = "these type aliases are no longer supported by \
7            the standard library, the `libc` crate on \
8            crates.io should be used instead for the correct \
9            definitions"
10)]
11#![allow(deprecated)]
12
13use crate::os::raw::c_ulong;
14
15#[stable(feature = "raw_ext", since = "1.1.0")]
16pub type dev_t = u64;
17#[stable(feature = "raw_ext", since = "1.1.0")]
18pub type mode_t = u32;
19
20#[stable(feature = "pthread_t", since = "1.8.0")]
21pub type pthread_t = c_ulong;
22
23#[doc(inline)]
24#[stable(feature = "raw_ext", since = "1.1.0")]
25pub use self::arch::{blkcnt_t, blksize_t, ino_t, nlink_t, off_t, stat, time_t};
26
27#[cfg(any(
28    target_arch = "x86",
29    target_arch = "m68k",
30    target_arch = "csky",
31    target_arch = "powerpc",
32    target_arch = "sparc",
33    target_arch = "arm",
34))]
35mod arch {
36    use crate::os::raw::{c_long, c_short, c_uint};
37
38    #[stable(feature = "raw_ext", since = "1.1.0")]
39    pub type blkcnt_t = u64;
40    #[stable(feature = "raw_ext", since = "1.1.0")]
41    pub type blksize_t = u64;
42    #[stable(feature = "raw_ext", since = "1.1.0")]
43    pub type ino_t = u64;
44    #[stable(feature = "raw_ext", since = "1.1.0")]
45    pub type nlink_t = u64;
46    #[stable(feature = "raw_ext", since = "1.1.0")]
47    pub type off_t = u64;
48    #[stable(feature = "raw_ext", since = "1.1.0")]
49    pub type time_t = i64;
50
51    #[repr(C)]
52    #[derive(Clone)]
53    #[stable(feature = "raw_ext", since = "1.1.0")]
54    pub struct stat {
55        #[stable(feature = "raw_ext", since = "1.1.0")]
56        pub st_dev: u64,
57        #[stable(feature = "raw_ext", since = "1.1.0")]
58        pub __pad1: c_short,
59        #[stable(feature = "raw_ext", since = "1.1.0")]
60        pub __st_ino: u32,
61        #[stable(feature = "raw_ext", since = "1.1.0")]
62        pub st_mode: u32,
63        #[stable(feature = "raw_ext", since = "1.1.0")]
64        pub st_nlink: u32,
65        #[stable(feature = "raw_ext", since = "1.1.0")]
66        pub st_uid: u32,
67        #[stable(feature = "raw_ext", since = "1.1.0")]
68        pub st_gid: u32,
69        #[stable(feature = "raw_ext", since = "1.1.0")]
70        pub st_rdev: u64,
71        #[stable(feature = "raw_ext", since = "1.1.0")]
72        pub __pad2: c_uint,
73        #[stable(feature = "raw_ext", since = "1.1.0")]
74        pub st_size: i64,
75        #[stable(feature = "raw_ext", since = "1.1.0")]
76        pub st_blksize: i32,
77        #[stable(feature = "raw_ext", since = "1.1.0")]
78        pub st_blocks: i64,
79        #[stable(feature = "raw_ext", since = "1.1.0")]
80        pub st_atime: i32,
81        #[stable(feature = "raw_ext", since = "1.1.0")]
82        pub st_atime_nsec: c_long,
83        #[stable(feature = "raw_ext", since = "1.1.0")]
84        pub st_mtime: i32,
85        #[stable(feature = "raw_ext", since = "1.1.0")]
86        pub st_mtime_nsec: c_long,
87        #[stable(feature = "raw_ext", since = "1.1.0")]
88        pub st_ctime: i32,
89        #[stable(feature = "raw_ext", since = "1.1.0")]
90        pub st_ctime_nsec: c_long,
91        #[stable(feature = "raw_ext", since = "1.1.0")]
92        pub st_ino: u64,
93    }
94}
95
96#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
97mod arch {
98    use crate::os::raw::{c_long, c_ulong};
99
100    #[cfg(target_env = "musl")]
101    #[stable(feature = "raw_ext", since = "1.1.0")]
102    pub type blkcnt_t = i64;
103    #[cfg(not(target_env = "musl"))]
104    #[stable(feature = "raw_ext", since = "1.1.0")]
105    pub type blkcnt_t = u64;
106    #[stable(feature = "raw_ext", since = "1.1.0")]
107    pub type blksize_t = u64;
108    #[cfg(target_env = "musl")]
109    #[stable(feature = "raw_ext", since = "1.1.0")]
110    pub type ino_t = u64;
111    #[cfg(not(target_env = "musl"))]
112    #[stable(feature = "raw_ext", since = "1.1.0")]
113    pub type ino_t = u64;
114    #[stable(feature = "raw_ext", since = "1.1.0")]
115    pub type nlink_t = u64;
116    #[cfg(target_env = "musl")]
117    #[stable(feature = "raw_ext", since = "1.1.0")]
118    pub type off_t = u64;
119    #[cfg(not(target_env = "musl"))]
120    #[stable(feature = "raw_ext", since = "1.1.0")]
121    pub type off_t = u64;
122    #[stable(feature = "raw_ext", since = "1.1.0")]
123    pub type time_t = i64;
124
125    #[repr(C)]
126    #[derive(Clone)]
127    #[stable(feature = "raw_ext", since = "1.1.0")]
128    pub struct stat {
129        #[stable(feature = "raw_ext", since = "1.1.0")]
130        pub st_dev: c_ulong,
131        #[stable(feature = "raw_ext", since = "1.1.0")]
132        pub st_pad1: [c_long; 3],
133        #[stable(feature = "raw_ext", since = "1.1.0")]
134        pub st_ino: u64,
135        #[stable(feature = "raw_ext", since = "1.1.0")]
136        pub st_mode: u32,
137        #[stable(feature = "raw_ext", since = "1.1.0")]
138        pub st_nlink: u32,
139        #[stable(feature = "raw_ext", since = "1.1.0")]
140        pub st_uid: u32,
141        #[stable(feature = "raw_ext", since = "1.1.0")]
142        pub st_gid: u32,
143        #[stable(feature = "raw_ext", since = "1.1.0")]
144        pub st_rdev: c_ulong,
145        #[stable(feature = "raw_ext", since = "1.1.0")]
146        pub st_pad2: [c_long; 2],
147        #[stable(feature = "raw_ext", since = "1.1.0")]
148        pub st_size: i64,
149        #[stable(feature = "raw_ext", since = "1.1.0")]
150        pub st_atime: i32,
151        #[stable(feature = "raw_ext", since = "1.1.0")]
152        pub st_atime_nsec: c_long,
153        #[stable(feature = "raw_ext", since = "1.1.0")]
154        pub st_mtime: i32,
155        #[stable(feature = "raw_ext", since = "1.1.0")]
156        pub st_mtime_nsec: c_long,
157        #[stable(feature = "raw_ext", since = "1.1.0")]
158        pub st_ctime: i32,
159        #[stable(feature = "raw_ext", since = "1.1.0")]
160        pub st_ctime_nsec: c_long,
161        #[stable(feature = "raw_ext", since = "1.1.0")]
162        pub st_blksize: i32,
163        #[stable(feature = "raw_ext", since = "1.1.0")]
164        pub st_blocks: i64,
165        #[stable(feature = "raw_ext", since = "1.1.0")]
166        pub st_pad5: [c_long; 14],
167    }
168}
169
170#[cfg(target_arch = "hexagon")]
171mod arch {
172    use crate::os::raw::{c_int, c_long, c_uint};
173
174    #[stable(feature = "raw_ext", since = "1.1.0")]
175    pub type blkcnt_t = i64;
176    #[stable(feature = "raw_ext", since = "1.1.0")]
177    pub type blksize_t = c_long;
178    #[stable(feature = "raw_ext", since = "1.1.0")]
179    pub type ino_t = u64;
180    #[stable(feature = "raw_ext", since = "1.1.0")]
181    pub type nlink_t = c_uint;
182    #[stable(feature = "raw_ext", since = "1.1.0")]
183    pub type off_t = i64;
184    #[stable(feature = "raw_ext", since = "1.1.0")]
185    pub type time_t = i64;
186
187    #[repr(C)]
188    #[derive(Clone)]
189    #[stable(feature = "raw_ext", since = "1.1.0")]
190    pub struct stat {
191        #[stable(feature = "raw_ext", since = "1.1.0")]
192        pub st_dev: u64,
193        #[stable(feature = "raw_ext", since = "1.1.0")]
194        pub st_ino: u64,
195        #[stable(feature = "raw_ext", since = "1.1.0")]
196        pub st_mode: u32,
197        #[stable(feature = "raw_ext", since = "1.1.0")]
198        pub st_nlink: u32,
199        #[stable(feature = "raw_ext", since = "1.1.0")]
200        pub st_uid: u32,
201        #[stable(feature = "raw_ext", since = "1.1.0")]
202        pub st_gid: u32,
203        #[stable(feature = "raw_ext", since = "1.1.0")]
204        pub st_rdev: u64,
205        #[stable(feature = "raw_ext", since = "1.1.0")]
206        pub __pad1: u32,
207        #[stable(feature = "raw_ext", since = "1.1.0")]
208        pub st_size: i64,
209        #[stable(feature = "raw_ext", since = "1.1.0")]
210        pub st_blksize: i32,
211        #[stable(feature = "raw_ext", since = "1.1.0")]
212        pub __pad2: i32,
213        #[stable(feature = "raw_ext", since = "1.1.0")]
214        pub st_blocks: i64,
215        #[stable(feature = "raw_ext", since = "1.1.0")]
216        pub st_atime: i64,
217        #[stable(feature = "raw_ext", since = "1.1.0")]
218        pub st_atime_nsec: c_long,
219        #[stable(feature = "raw_ext", since = "1.1.0")]
220        pub st_mtime: i64,
221        #[stable(feature = "raw_ext", since = "1.1.0")]
222        pub st_mtime_nsec: c_long,
223        #[stable(feature = "raw_ext", since = "1.1.0")]
224        pub st_ctime: i64,
225        #[stable(feature = "raw_ext", since = "1.1.0")]
226        pub st_ctime_nsec: c_long,
227        #[stable(feature = "raw_ext", since = "1.1.0")]
228        pub __pad3: [c_int; 2],
229    }
230}
231
232#[cfg(any(
233    target_arch = "loongarch32",
234    target_arch = "loongarch64",
235    target_arch = "mips64",
236    target_arch = "mips64r6",
237    target_arch = "s390x",
238    target_arch = "sparc64",
239    target_arch = "riscv64",
240    target_arch = "riscv32"
241))]
242mod arch {
243    #[stable(feature = "raw_ext", since = "1.1.0")]
244    pub use libc::{blkcnt_t, blksize_t, ino_t, nlink_t, off_t, stat, time_t};
245}
246
247#[cfg(any(
248    target_arch = "aarch64",
249    // Arm64EC is Windows-only, but docs are always build as Linux, so re-use AArch64 for Arm64EC.
250    all(doc, target_arch = "arm64ec")
251))]
252mod arch {
253    use crate::os::raw::{c_int, c_long};
254
255    #[stable(feature = "raw_ext", since = "1.1.0")]
256    pub type blkcnt_t = i64;
257    #[stable(feature = "raw_ext", since = "1.1.0")]
258    pub type blksize_t = i32;
259    #[stable(feature = "raw_ext", since = "1.1.0")]
260    pub type ino_t = u64;
261    #[stable(feature = "raw_ext", since = "1.1.0")]
262    pub type nlink_t = u32;
263    #[stable(feature = "raw_ext", since = "1.1.0")]
264    pub type off_t = i64;
265    #[stable(feature = "raw_ext", since = "1.1.0")]
266    pub type time_t = c_long;
267
268    #[repr(C)]
269    #[derive(Clone)]
270    #[stable(feature = "raw_ext", since = "1.1.0")]
271    pub struct stat {
272        #[stable(feature = "raw_ext", since = "1.1.0")]
273        pub st_dev: u64,
274        #[stable(feature = "raw_ext", since = "1.1.0")]
275        pub st_ino: u64,
276        #[stable(feature = "raw_ext", since = "1.1.0")]
277        pub st_mode: u32,
278        #[stable(feature = "raw_ext", since = "1.1.0")]
279        pub st_nlink: u32,
280        #[stable(feature = "raw_ext", since = "1.1.0")]
281        pub st_uid: u32,
282        #[stable(feature = "raw_ext", since = "1.1.0")]
283        pub st_gid: u32,
284        #[stable(feature = "raw_ext", since = "1.1.0")]
285        pub st_rdev: u64,
286        #[stable(feature = "raw_ext", since = "1.1.0")]
287        pub __pad1: u64,
288        #[stable(feature = "raw_ext", since = "1.1.0")]
289        pub st_size: i64,
290        #[stable(feature = "raw_ext", since = "1.1.0")]
291        pub st_blksize: i32,
292        #[stable(feature = "raw_ext", since = "1.1.0")]
293        pub __pad2: c_int,
294        #[stable(feature = "raw_ext", since = "1.1.0")]
295        pub st_blocks: i64,
296        #[stable(feature = "raw_ext", since = "1.1.0")]
297        pub st_atime: time_t,
298        #[stable(feature = "raw_ext", since = "1.1.0")]
299        pub st_atime_nsec: c_long,
300        #[stable(feature = "raw_ext", since = "1.1.0")]
301        pub st_mtime: time_t,
302        #[stable(feature = "raw_ext", since = "1.1.0")]
303        pub st_mtime_nsec: c_long,
304        #[stable(feature = "raw_ext", since = "1.1.0")]
305        pub st_ctime: time_t,
306        #[stable(feature = "raw_ext", since = "1.1.0")]
307        pub st_ctime_nsec: c_long,
308        #[stable(feature = "raw_ext", since = "1.1.0")]
309        pub __unused: [c_int; 2],
310    }
311}
312
313#[cfg(any(target_arch = "x86_64", target_arch = "powerpc64",
314    // `wasm32-wali-linux-musl` uses ABI similar to x86_64
315    target_arch = "wasm32"))]
316mod arch {
317    use crate::os::raw::{c_int, c_long};
318
319    #[stable(feature = "raw_ext", since = "1.1.0")]
320    pub type blkcnt_t = u64;
321    #[stable(feature = "raw_ext", since = "1.1.0")]
322    pub type blksize_t = u64;
323    #[stable(feature = "raw_ext", since = "1.1.0")]
324    pub type ino_t = u64;
325    #[stable(feature = "raw_ext", since = "1.1.0")]
326    pub type nlink_t = u64;
327    #[stable(feature = "raw_ext", since = "1.1.0")]
328    pub type off_t = u64;
329    #[stable(feature = "raw_ext", since = "1.1.0")]
330    pub type time_t = i64;
331
332    #[repr(C)]
333    #[derive(Clone)]
334    #[stable(feature = "raw_ext", since = "1.1.0")]
335    pub struct stat {
336        #[stable(feature = "raw_ext", since = "1.1.0")]
337        pub st_dev: u64,
338        #[stable(feature = "raw_ext", since = "1.1.0")]
339        pub st_ino: u64,
340        #[stable(feature = "raw_ext", since = "1.1.0")]
341        pub st_nlink: u64,
342        #[stable(feature = "raw_ext", since = "1.1.0")]
343        pub st_mode: u32,
344        #[stable(feature = "raw_ext", since = "1.1.0")]
345        pub st_uid: u32,
346        #[stable(feature = "raw_ext", since = "1.1.0")]
347        pub st_gid: u32,
348        #[stable(feature = "raw_ext", since = "1.1.0")]
349        pub __pad0: c_int,
350        #[stable(feature = "raw_ext", since = "1.1.0")]
351        pub st_rdev: u64,
352        #[stable(feature = "raw_ext", since = "1.1.0")]
353        pub st_size: i64,
354        #[stable(feature = "raw_ext", since = "1.1.0")]
355        pub st_blksize: i64,
356        #[stable(feature = "raw_ext", since = "1.1.0")]
357        pub st_blocks: i64,
358        #[stable(feature = "raw_ext", since = "1.1.0")]
359        pub st_atime: i64,
360        #[stable(feature = "raw_ext", since = "1.1.0")]
361        pub st_atime_nsec: c_long,
362        #[stable(feature = "raw_ext", since = "1.1.0")]
363        pub st_mtime: i64,
364        #[stable(feature = "raw_ext", since = "1.1.0")]
365        pub st_mtime_nsec: c_long,
366        #[stable(feature = "raw_ext", since = "1.1.0")]
367        pub st_ctime: i64,
368        #[stable(feature = "raw_ext", since = "1.1.0")]
369        pub st_ctime_nsec: c_long,
370        #[stable(feature = "raw_ext", since = "1.1.0")]
371        pub __unused: [c_long; 3],
372    }
373}