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