]> git.lizzy.rs Git - rust.git/blob - src/libstd/os/linux/raw.rs
7c9274d06016180e0bd7c1afab07e185984bd30c
[rust.git] / src / libstd / os / linux / raw.rs
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.
4 //
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.
10
11 //! Linux-specific raw type definitions
12
13 #![stable(feature = "raw_ext", since = "1.1.0")]
14 #![rustc_deprecated(since = "1.8.0",
15                     reason = "these type aliases are no longer supported by \
16                               the standard library, the `libc` crate on \
17                               crates.io should be used instead for the correct \
18                               definitions")]
19 #![allow(deprecated)]
20 #![allow(missing_debug_implementations)]
21
22 use os::raw::c_ulong;
23
24 #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
25 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
26
27 #[stable(feature = "pthread_t", since = "1.8.0")]
28 pub type pthread_t = c_ulong;
29
30 #[doc(inline)]
31 #[stable(feature = "raw_ext", since = "1.1.0")]
32 pub use self::arch::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t};
33
34 #[cfg(any(target_arch = "x86",
35           target_arch = "le32",
36           target_arch = "powerpc",
37           target_arch = "arm",
38           target_arch = "asmjs",
39           target_arch = "wasm32"))]
40 mod arch {
41     use os::raw::{c_long, c_short, c_uint};
42
43     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
44     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
45     #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
46     #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
47     #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
48     #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
49
50     #[repr(C)]
51     #[derive(Clone)]
52     #[stable(feature = "raw_ext", since = "1.1.0")]
53     pub struct stat {
54         #[stable(feature = "raw_ext", since = "1.1.0")]
55         pub st_dev: u64,
56         #[stable(feature = "raw_ext", since = "1.1.0")]
57         pub __pad1: c_short,
58         #[stable(feature = "raw_ext", since = "1.1.0")]
59         pub __st_ino: u32,
60         #[stable(feature = "raw_ext", since = "1.1.0")]
61         pub st_mode: u32,
62         #[stable(feature = "raw_ext", since = "1.1.0")]
63         pub st_nlink: u32,
64         #[stable(feature = "raw_ext", since = "1.1.0")]
65         pub st_uid: u32,
66         #[stable(feature = "raw_ext", since = "1.1.0")]
67         pub st_gid: u32,
68         #[stable(feature = "raw_ext", since = "1.1.0")]
69         pub st_rdev: u64,
70         #[stable(feature = "raw_ext", since = "1.1.0")]
71         pub __pad2: c_uint,
72         #[stable(feature = "raw_ext", since = "1.1.0")]
73         pub st_size: i64,
74         #[stable(feature = "raw_ext", since = "1.1.0")]
75         pub st_blksize: i32,
76         #[stable(feature = "raw_ext", since = "1.1.0")]
77         pub st_blocks: i64,
78         #[stable(feature = "raw_ext", since = "1.1.0")]
79         pub st_atime: i32,
80         #[stable(feature = "raw_ext", since = "1.1.0")]
81         pub st_atime_nsec: c_long,
82         #[stable(feature = "raw_ext", since = "1.1.0")]
83         pub st_mtime: i32,
84         #[stable(feature = "raw_ext", since = "1.1.0")]
85         pub st_mtime_nsec: c_long,
86         #[stable(feature = "raw_ext", since = "1.1.0")]
87         pub st_ctime: i32,
88         #[stable(feature = "raw_ext", since = "1.1.0")]
89         pub st_ctime_nsec: c_long,
90         #[stable(feature = "raw_ext", since = "1.1.0")]
91         pub st_ino: u64,
92     }
93 }
94
95 #[cfg(target_arch = "mips")]
96 mod arch {
97     use os::raw::{c_long, c_ulong};
98
99     #[cfg(target_env = "musl")]
100     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
101     #[cfg(not(target_env = "musl"))]
102     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
103     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
104     #[cfg(target_env = "musl")]
105     #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
106     #[cfg(not(target_env = "musl"))]
107     #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
108     #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
109     #[cfg(target_env = "musl")]
110     #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
111     #[cfg(not(target_env = "musl"))]
112     #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
113     #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
114
115     #[repr(C)]
116     #[derive(Clone)]
117     #[stable(feature = "raw_ext", since = "1.1.0")]
118     pub struct stat {
119         #[stable(feature = "raw_ext", since = "1.1.0")]
120         pub st_dev: c_ulong,
121         #[stable(feature = "raw_ext", since = "1.1.0")]
122         pub st_pad1: [c_long; 3],
123         #[stable(feature = "raw_ext", since = "1.1.0")]
124         pub st_ino: u64,
125         #[stable(feature = "raw_ext", since = "1.1.0")]
126         pub st_mode: u32,
127         #[stable(feature = "raw_ext", since = "1.1.0")]
128         pub st_nlink: u32,
129         #[stable(feature = "raw_ext", since = "1.1.0")]
130         pub st_uid: u32,
131         #[stable(feature = "raw_ext", since = "1.1.0")]
132         pub st_gid: u32,
133         #[stable(feature = "raw_ext", since = "1.1.0")]
134         pub st_rdev: c_ulong,
135         #[stable(feature = "raw_ext", since = "1.1.0")]
136         pub st_pad2: [c_long; 2],
137         #[stable(feature = "raw_ext", since = "1.1.0")]
138         pub st_size: i64,
139         #[stable(feature = "raw_ext", since = "1.1.0")]
140         pub st_atime: i32,
141         #[stable(feature = "raw_ext", since = "1.1.0")]
142         pub st_atime_nsec: c_long,
143         #[stable(feature = "raw_ext", since = "1.1.0")]
144         pub st_mtime: i32,
145         #[stable(feature = "raw_ext", since = "1.1.0")]
146         pub st_mtime_nsec: c_long,
147         #[stable(feature = "raw_ext", since = "1.1.0")]
148         pub st_ctime: i32,
149         #[stable(feature = "raw_ext", since = "1.1.0")]
150         pub st_ctime_nsec: c_long,
151         #[stable(feature = "raw_ext", since = "1.1.0")]
152         pub st_blksize: i32,
153         #[stable(feature = "raw_ext", since = "1.1.0")]
154         pub st_blocks: i64,
155         #[stable(feature = "raw_ext", since = "1.1.0")]
156         pub st_pad5: [c_long; 14],
157     }
158 }
159
160 #[cfg(target_arch = "mips64")]
161 mod arch {
162     pub use libc::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t};
163 }
164
165 #[cfg(target_arch = "s390x")]
166 mod arch {
167     pub use libc::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t};
168 }
169
170 #[cfg(target_arch = "aarch64")]
171 mod arch {
172     use os::raw::{c_long, c_int};
173
174     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
175     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
176     #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
177     #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
178     #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
179     #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
180
181     #[repr(C)]
182     #[derive(Clone)]
183     #[stable(feature = "raw_ext", since = "1.1.0")]
184     pub struct stat {
185         #[stable(feature = "raw_ext", since = "1.1.0")]
186         pub st_dev: u64,
187         #[stable(feature = "raw_ext", since = "1.1.0")]
188         pub st_ino: u64,
189         #[stable(feature = "raw_ext", since = "1.1.0")]
190         pub st_mode: u32,
191         #[stable(feature = "raw_ext", since = "1.1.0")]
192         pub st_nlink: u32,
193         #[stable(feature = "raw_ext", since = "1.1.0")]
194         pub st_uid: u32,
195         #[stable(feature = "raw_ext", since = "1.1.0")]
196         pub st_gid: u32,
197         #[stable(feature = "raw_ext", since = "1.1.0")]
198         pub st_rdev: u64,
199         #[stable(feature = "raw_ext", since = "1.1.0")]
200         pub __pad1: u64,
201         #[stable(feature = "raw_ext", since = "1.1.0")]
202         pub st_size: i64,
203         #[stable(feature = "raw_ext", since = "1.1.0")]
204         pub st_blksize: i32,
205         #[stable(feature = "raw_ext", since = "1.1.0")]
206         pub __pad2: c_int,
207         #[stable(feature = "raw_ext", since = "1.1.0")]
208         pub st_blocks: i64,
209         #[stable(feature = "raw_ext", since = "1.1.0")]
210         pub st_atime: i64,
211         #[stable(feature = "raw_ext", since = "1.1.0")]
212         pub st_atime_nsec: c_long,
213         #[stable(feature = "raw_ext", since = "1.1.0")]
214         pub st_mtime: i64,
215         #[stable(feature = "raw_ext", since = "1.1.0")]
216         pub st_mtime_nsec: c_long,
217         #[stable(feature = "raw_ext", since = "1.1.0")]
218         pub st_ctime: i64,
219         #[stable(feature = "raw_ext", since = "1.1.0")]
220         pub st_ctime_nsec: c_long,
221         #[stable(feature = "raw_ext", since = "1.1.0")]
222         pub __unused: [c_int; 2],
223     }
224 }
225
226 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64"))]
227 mod arch {
228     use os::raw::{c_long, c_int};
229
230     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
231     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
232     #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
233     #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
234     #[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64;
235     #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
236
237     #[repr(C)]
238     #[derive(Clone)]
239     #[stable(feature = "raw_ext", since = "1.1.0")]
240     pub struct stat {
241         #[stable(feature = "raw_ext", since = "1.1.0")]
242         pub st_dev: u64,
243         #[stable(feature = "raw_ext", since = "1.1.0")]
244         pub st_ino: u64,
245         #[stable(feature = "raw_ext", since = "1.1.0")]
246         pub st_nlink: u64,
247         #[stable(feature = "raw_ext", since = "1.1.0")]
248         pub st_mode: u32,
249         #[stable(feature = "raw_ext", since = "1.1.0")]
250         pub st_uid: u32,
251         #[stable(feature = "raw_ext", since = "1.1.0")]
252         pub st_gid: u32,
253         #[stable(feature = "raw_ext", since = "1.1.0")]
254         pub __pad0: c_int,
255         #[stable(feature = "raw_ext", since = "1.1.0")]
256         pub st_rdev: u64,
257         #[stable(feature = "raw_ext", since = "1.1.0")]
258         pub st_size: i64,
259         #[stable(feature = "raw_ext", since = "1.1.0")]
260         pub st_blksize: i64,
261         #[stable(feature = "raw_ext", since = "1.1.0")]
262         pub st_blocks: i64,
263         #[stable(feature = "raw_ext", since = "1.1.0")]
264         pub st_atime: i64,
265         #[stable(feature = "raw_ext", since = "1.1.0")]
266         pub st_atime_nsec: c_long,
267         #[stable(feature = "raw_ext", since = "1.1.0")]
268         pub st_mtime: i64,
269         #[stable(feature = "raw_ext", since = "1.1.0")]
270         pub st_mtime_nsec: c_long,
271         #[stable(feature = "raw_ext", since = "1.1.0")]
272         pub st_ctime: i64,
273         #[stable(feature = "raw_ext", since = "1.1.0")]
274         pub st_ctime_nsec: c_long,
275         #[stable(feature = "raw_ext", since = "1.1.0")]
276         pub __unused: [c_long; 3],
277     }
278 }