Debian Codegraph @

third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/mod.rs

raw
1 //! 32-bit specific definitions for linux-like values
2
3 use crate::prelude::*;
4 use crate::pthread_mutex_t;
5
6 pub type clock_t = i32;
7
8 pub type shmatt_t = c_ulong;
9 pub type msgqnum_t = c_ulong;
10 pub type msglen_t = c_ulong;
11 pub type nlink_t = u32;
12 pub type __u64 = c_ulonglong;
13 pub type __s64 = c_longlong;
14 pub type __fsword_t = i32;
15 pub type fsblkcnt64_t = u64;
16 pub type fsfilcnt64_t = u64;
17 pub type __syscall_ulong_t = c_ulong;
18
19 cfg_if! {
20 if #[cfg(target_arch = "riscv32")] {
21 pub type time_t = i64;
22 pub type suseconds_t = i64;
23 pub type ino_t = u64;
24 pub type off_t = i64;
25 pub type blkcnt_t = i64;
26 pub type fsblkcnt_t = u64;
27 pub type fsfilcnt_t = u64;
28 pub type rlim_t = u64;
29 pub type blksize_t = i64;
30 } else {
31 pub type time_t = i32;
32 pub type suseconds_t = i32;
33 pub type ino_t = u32;
34 pub type off_t = i32;
35 pub type blkcnt_t = i32;
36 pub type fsblkcnt_t = c_ulong;
37 pub type fsfilcnt_t = c_ulong;
38 pub type rlim_t = c_ulong;
39 pub type blksize_t = i32;
40 }
41 }
42
43 cfg_if! {
44 if #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] {
45 s! {
46 pub struct stat {
47 pub st_dev: crate::dev_t,
48
49 __pad1: c_short,
50 pub st_ino: crate::ino_t,
51 pub st_mode: crate::mode_t,
52 pub st_nlink: crate::nlink_t,
53 pub st_uid: crate::uid_t,
54 pub st_gid: crate::gid_t,
55 pub st_rdev: crate::dev_t,
56 __pad2: c_short,
57 pub st_size: off_t,
58 pub st_blksize: crate::blksize_t,
59 pub st_blocks: crate::blkcnt_t,
60 pub st_atime: crate::time_t,
61 pub st_atime_nsec: c_long,
62 pub st_mtime: crate::time_t,
63 pub st_mtime_nsec: c_long,
64 pub st_ctime: crate::time_t,
65 pub st_ctime_nsec: c_long,
66 __unused4: c_long,
67 __unused5: c_long,
68 }
69 }
70 }
71 }
72
73 s! {
74 pub struct statvfs {
75 pub f_bsize: c_ulong,
76 pub f_frsize: c_ulong,
77 pub f_blocks: crate::fsblkcnt_t,
78 pub f_bfree: crate::fsblkcnt_t,
79 pub f_bavail: crate::fsblkcnt_t,
80 pub f_files: crate::fsfilcnt_t,
81 pub f_ffree: crate::fsfilcnt_t,
82 pub f_favail: crate::fsfilcnt_t,
83 pub f_fsid: c_ulong,
84 __f_unused: c_int,
85 pub f_flag: c_ulong,
86 pub f_namemax: c_ulong,
87 __f_spare: [c_int; 6],
88 }
89
90 pub struct pthread_attr_t {
91 __size: [u32; 9],
92 }
93
94 pub struct sigset_t {
95 __val: [c_ulong; 32],
96 }
97
98 pub struct sysinfo {
99 pub uptime: c_long,
100 pub loads: [c_ulong; 3],
101 pub totalram: c_ulong,
102 pub freeram: c_ulong,
103 pub sharedram: c_ulong,
104 pub bufferram: c_ulong,
105 pub totalswap: c_ulong,
106 pub freeswap: c_ulong,
107 pub procs: c_ushort,
108 #[deprecated(
109 since = "0.2.58",
110 note = "This padding field might become private in the future"
111 )]
112 pub pad: c_ushort,
113 pub totalhigh: c_ulong,
114 pub freehigh: c_ulong,
115 pub mem_unit: c_uint,
116 pub _f: [c_char; 8],
117 }
118
119 pub struct semid_ds {
120 pub sem_perm: ipc_perm,
121 #[cfg(target_arch = "powerpc")]
122 __reserved: crate::__syscall_ulong_t,
123 pub sem_otime: crate::time_t,
124 #[cfg(not(any(
125 target_arch = "mips",
126 target_arch = "mips32r6",
127 target_arch = "powerpc"
128 )))]
129 __reserved: crate::__syscall_ulong_t,
130 #[cfg(target_arch = "powerpc")]
131 __reserved2: crate::__syscall_ulong_t,
132 pub sem_ctime: crate::time_t,
133 #[cfg(not(any(
134 target_arch = "mips",
135 target_arch = "mips32r6",
136 target_arch = "powerpc"
137 )))]
138 __reserved2: crate::__syscall_ulong_t,
139 pub sem_nsems: crate::__syscall_ulong_t,
140 __glibc_reserved3: crate::__syscall_ulong_t,
141 __glibc_reserved4: crate::__syscall_ulong_t,
142 }
143 }
144
145 pub const POSIX_FADV_DONTNEED: c_int = 4;
146 pub const POSIX_FADV_NOREUSE: c_int = 5;
147
148 pub const F_OFD_GETLK: c_int = 36;
149 pub const F_OFD_SETLK: c_int = 37;
150 pub const F_OFD_SETLKW: c_int = 38;
151
152 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
153 pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
154 pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
155 pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20;
156 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
157 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
158 pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
159
160 cfg_if! {
161 if #[cfg(target_arch = "sparc")] {
162 pub const O_NOATIME: c_int = 0x200000;
163 pub const O_PATH: c_int = 0x1000000;
164 pub const O_TMPFILE: c_int = 0x2000000 | O_DIRECTORY;
165
166 pub const SA_ONSTACK: c_int = 1;
167
168 pub const PTRACE_DETACH: c_uint = 11;
169
170 pub const F_SETLK: c_int = 8;
171 pub const F_SETLKW: c_int = 9;
172
173 pub const F_RDLCK: c_int = 1;
174 pub const F_WRLCK: c_int = 2;
175 pub const F_UNLCK: c_int = 3;
176
177 pub const SFD_CLOEXEC: c_int = 0x400000;
178
179 pub const NCCS: usize = 17;
180
181 pub const O_TRUNC: c_int = 0x400;
182 pub const O_CLOEXEC: c_int = 0x400000;
183
184 pub const EBFONT: c_int = 109;
185 pub const ENOSTR: c_int = 72;
186 pub const ENODATA: c_int = 111;
187 pub const ETIME: c_int = 73;
188 pub const ENOSR: c_int = 74;
189 pub const ENONET: c_int = 80;
190 pub const ENOPKG: c_int = 113;
191 pub const EREMOTE: c_int = 71;
192 pub const ENOLINK: c_int = 82;
193 pub const EADV: c_int = 83;
194 pub const ESRMNT: c_int = 84;
195 pub const ECOMM: c_int = 85;
196 pub const EPROTO: c_int = 86;
197 pub const EDOTDOT: c_int = 88;
198
199 pub const SA_NODEFER: c_int = 0x20;
200 pub const SA_RESETHAND: c_int = 0x4;
201 pub const SA_RESTART: c_int = 0x2;
202 pub const SA_NOCLDSTOP: c_int = 0x00000008;
203
204 pub const EPOLL_CLOEXEC: c_int = 0x400000;
205
206 pub const EFD_CLOEXEC: c_int = 0x400000;
207 } else {
208 pub const O_NOATIME: c_int = 0o1000000;
209 pub const O_PATH: c_int = 0o10000000;
210 pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY;
211
212 pub const SA_ONSTACK: c_int = 0x08000000;
213
214 pub const PTRACE_DETACH: c_uint = 17;
215
216 pub const F_SETLK: c_int = 6;
217 pub const F_SETLKW: c_int = 7;
218
219 pub const F_RDLCK: c_int = 0;
220 pub const F_WRLCK: c_int = 1;
221 pub const F_UNLCK: c_int = 2;
222
223 pub const SFD_CLOEXEC: c_int = 0x080000;
224
225 pub const NCCS: usize = 32;
226
227 pub const O_TRUNC: c_int = 512;
228 pub const O_CLOEXEC: c_int = 0x80000;
229 pub const EBFONT: c_int = 59;
230 pub const ENOSTR: c_int = 60;
231 pub const ENODATA: c_int = 61;
232 pub const ETIME: c_int = 62;
233 pub const ENOSR: c_int = 63;
234 pub const ENONET: c_int = 64;
235 pub const ENOPKG: c_int = 65;
236 pub const EREMOTE: c_int = 66;
237 pub const ENOLINK: c_int = 67;
238 pub const EADV: c_int = 68;
239 pub const ESRMNT: c_int = 69;
240 pub const ECOMM: c_int = 70;
241 pub const EPROTO: c_int = 71;
242 pub const EDOTDOT: c_int = 73;
243
244 pub const SA_NODEFER: c_int = 0x40000000;
245 pub const SA_RESETHAND: c_int = 0x80000000;
246 pub const SA_RESTART: c_int = 0x10000000;
247 pub const SA_NOCLDSTOP: c_int = 0x00000001;
248
249 pub const EPOLL_CLOEXEC: c_int = 0x80000;
250
251 pub const EFD_CLOEXEC: c_int = 0x80000;
252 }
253 }
254
255 #[cfg(target_endian = "little")]
256 pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t {
257 size: [
258 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
259 ],
260 };
261 #[cfg(target_endian = "little")]
262 pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t {
263 size: [
264 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
265 ],
266 };
267 #[cfg(target_endian = "little")]
268 pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t {
269 size: [
270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
271 ],
272 };
273 #[cfg(target_endian = "big")]
274 pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t {
275 size: [
276 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
277 ],
278 };
279 #[cfg(target_endian = "big")]
280 pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t {
281 size: [
282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
283 ],
284 };
285 #[cfg(target_endian = "big")]
286 pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t {
287 size: [
288 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
289 ],
290 };
291
292 pub const PTRACE_GETFPREGS: c_uint = 14;
293 pub const PTRACE_SETFPREGS: c_uint = 15;
294 pub const PTRACE_GETREGS: c_uint = 12;
295 pub const PTRACE_SETREGS: c_uint = 13;
296
297 extern "C" {
298 pub fn sysctl(
299 name: *mut c_int,
300 namelen: c_int,
301 oldp: *mut c_void,
302 oldlenp: *mut size_t,
303 newp: *mut c_void,
304 newlen: size_t,
305 ) -> c_int;
306 }
307
308 cfg_if! {
309 if #[cfg(target_arch = "x86")] {
310 mod x86;
311 pub use self::x86::*;
312 } else if #[cfg(target_arch = "arm")] {
313 mod arm;
314 pub use self::arm::*;
315 } else if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] {
316 mod mips;
317 pub use self::mips::*;
318 } else if #[cfg(target_arch = "m68k")] {
319 mod m68k;
320 pub use self::m68k::*;
321 } else if #[cfg(target_arch = "powerpc")] {
322 mod powerpc;
323 pub use self::powerpc::*;
324 } else if #[cfg(target_arch = "sparc")] {
325 mod sparc;
326 pub use self::sparc::*;
327 } else if #[cfg(target_arch = "riscv32")] {
328 mod riscv32;
329 pub use self::riscv32::*;
330 } else if #[cfg(target_arch = "csky")] {
331 mod csky;
332 pub use self::csky::*;
333 } else {
334 // Unknown target_arch
335 }
336 }