diff options
Diffstat (limited to 'third_party/libc/src/unix/notbsd/linux/mod.rs')
-rw-r--r-- | third_party/libc/src/unix/notbsd/linux/mod.rs | 674 |
1 files changed, 674 insertions, 0 deletions
diff --git a/third_party/libc/src/unix/notbsd/linux/mod.rs b/third_party/libc/src/unix/notbsd/linux/mod.rs new file mode 100644 index 0000000..a909082 --- /dev/null +++ b/third_party/libc/src/unix/notbsd/linux/mod.rs | |||
@@ -0,0 +1,674 @@ | |||
1 | //! Linux-specific definitions for linux-like values | ||
2 | |||
3 | use dox::mem; | ||
4 | |||
5 | pub type useconds_t = u32; | ||
6 | pub type dev_t = u64; | ||
7 | pub type socklen_t = u32; | ||
8 | pub type pthread_t = c_ulong; | ||
9 | pub type mode_t = u32; | ||
10 | pub type ino64_t = u64; | ||
11 | pub type off64_t = i64; | ||
12 | pub type blkcnt64_t = i64; | ||
13 | pub type rlim64_t = u64; | ||
14 | pub type key_t = ::c_int; | ||
15 | pub type shmatt_t = ::c_ulong; | ||
16 | pub type mqd_t = ::c_int; | ||
17 | pub type nfds_t = ::c_ulong; | ||
18 | pub type nl_item = ::c_int; | ||
19 | |||
20 | pub enum fpos64_t {} // TODO: fill this out with a struct | ||
21 | |||
22 | s! { | ||
23 | pub struct dirent { | ||
24 | pub d_ino: ::ino_t, | ||
25 | pub d_off: ::off_t, | ||
26 | pub d_reclen: ::c_ushort, | ||
27 | pub d_type: ::c_uchar, | ||
28 | pub d_name: [::c_char; 256], | ||
29 | } | ||
30 | |||
31 | pub struct dirent64 { | ||
32 | pub d_ino: ::ino64_t, | ||
33 | pub d_off: ::off64_t, | ||
34 | pub d_reclen: ::c_ushort, | ||
35 | pub d_type: ::c_uchar, | ||
36 | pub d_name: [::c_char; 256], | ||
37 | } | ||
38 | |||
39 | pub struct rlimit64 { | ||
40 | pub rlim_cur: rlim64_t, | ||
41 | pub rlim_max: rlim64_t, | ||
42 | } | ||
43 | |||
44 | pub struct glob_t { | ||
45 | pub gl_pathc: ::size_t, | ||
46 | pub gl_pathv: *mut *mut c_char, | ||
47 | pub gl_offs: ::size_t, | ||
48 | pub gl_flags: ::c_int, | ||
49 | |||
50 | __unused1: *mut ::c_void, | ||
51 | __unused2: *mut ::c_void, | ||
52 | __unused3: *mut ::c_void, | ||
53 | __unused4: *mut ::c_void, | ||
54 | __unused5: *mut ::c_void, | ||
55 | } | ||
56 | |||
57 | pub struct ifaddrs { | ||
58 | pub ifa_next: *mut ifaddrs, | ||
59 | pub ifa_name: *mut c_char, | ||
60 | pub ifa_flags: ::c_uint, | ||
61 | pub ifa_addr: *mut ::sockaddr, | ||
62 | pub ifa_netmask: *mut ::sockaddr, | ||
63 | pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union | ||
64 | pub ifa_data: *mut ::c_void | ||
65 | } | ||
66 | |||
67 | pub struct pthread_mutex_t { | ||
68 | #[cfg(any(target_arch = "mips", target_arch = "mipsel", | ||
69 | target_arch = "arm"))] | ||
70 | __align: [::c_long; 0], | ||
71 | #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", | ||
72 | target_arch = "arm")))] | ||
73 | __align: [::c_longlong; 0], | ||
74 | size: [u8; __SIZEOF_PTHREAD_MUTEX_T], | ||
75 | } | ||
76 | |||
77 | pub struct pthread_rwlock_t { | ||
78 | #[cfg(any(target_arch = "mips", target_arch = "mipsel", | ||
79 | target_arch = "arm"))] | ||
80 | __align: [::c_long; 0], | ||
81 | #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", | ||
82 | target_arch = "arm")))] | ||
83 | __align: [::c_longlong; 0], | ||
84 | size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], | ||
85 | } | ||
86 | |||
87 | pub struct pthread_mutexattr_t { | ||
88 | #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64"))] | ||
89 | __align: [::c_int; 0], | ||
90 | #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64")))] | ||
91 | __align: [::c_long; 0], | ||
92 | size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], | ||
93 | } | ||
94 | |||
95 | pub struct pthread_cond_t { | ||
96 | #[cfg(any(target_env = "musl"))] | ||
97 | __align: [*const ::c_void; 0], | ||
98 | #[cfg(not(any(target_env = "musl")))] | ||
99 | __align: [::c_longlong; 0], | ||
100 | size: [u8; __SIZEOF_PTHREAD_COND_T], | ||
101 | } | ||
102 | |||
103 | pub struct pthread_condattr_t { | ||
104 | __align: [::c_int; 0], | ||
105 | size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], | ||
106 | } | ||
107 | |||
108 | pub struct passwd { | ||
109 | pub pw_name: *mut ::c_char, | ||
110 | pub pw_passwd: *mut ::c_char, | ||
111 | pub pw_uid: ::uid_t, | ||
112 | pub pw_gid: ::gid_t, | ||
113 | pub pw_gecos: *mut ::c_char, | ||
114 | pub pw_dir: *mut ::c_char, | ||
115 | pub pw_shell: *mut ::c_char, | ||
116 | } | ||
117 | |||
118 | pub struct statvfs { | ||
119 | pub f_bsize: ::c_ulong, | ||
120 | pub f_frsize: ::c_ulong, | ||
121 | pub f_blocks: ::fsblkcnt_t, | ||
122 | pub f_bfree: ::fsblkcnt_t, | ||
123 | pub f_bavail: ::fsblkcnt_t, | ||
124 | pub f_files: ::fsfilcnt_t, | ||
125 | pub f_ffree: ::fsfilcnt_t, | ||
126 | pub f_favail: ::fsfilcnt_t, | ||
127 | pub f_fsid: ::c_ulong, | ||
128 | #[cfg(target_pointer_width = "32")] | ||
129 | pub __f_unused: ::c_int, | ||
130 | pub f_flag: ::c_ulong, | ||
131 | pub f_namemax: ::c_ulong, | ||
132 | __f_spare: [::c_int; 6], | ||
133 | } | ||
134 | |||
135 | pub struct dqblk { | ||
136 | pub dqb_bhardlimit: ::uint64_t, | ||
137 | pub dqb_bsoftlimit: ::uint64_t, | ||
138 | pub dqb_curspace: ::uint64_t, | ||
139 | pub dqb_ihardlimit: ::uint64_t, | ||
140 | pub dqb_isoftlimit: ::uint64_t, | ||
141 | pub dqb_curinodes: ::uint64_t, | ||
142 | pub dqb_btime: ::uint64_t, | ||
143 | pub dqb_itime: ::uint64_t, | ||
144 | pub dqb_valid: ::uint32_t, | ||
145 | } | ||
146 | |||
147 | pub struct signalfd_siginfo { | ||
148 | pub ssi_signo: ::uint32_t, | ||
149 | pub ssi_errno: ::int32_t, | ||
150 | pub ssi_code: ::int32_t, | ||
151 | pub ssi_pid: ::uint32_t, | ||
152 | pub ssi_uid: ::uint32_t, | ||
153 | pub ssi_fd: ::int32_t, | ||
154 | pub ssi_tid: ::uint32_t, | ||
155 | pub ssi_band: ::uint32_t, | ||
156 | pub ssi_overrun: ::uint32_t, | ||
157 | pub ssi_trapno: ::uint32_t, | ||
158 | pub ssi_status: ::int32_t, | ||
159 | pub ssi_int: ::int32_t, | ||
160 | pub ssi_ptr: ::uint64_t, | ||
161 | pub ssi_utime: ::uint64_t, | ||
162 | pub ssi_stime: ::uint64_t, | ||
163 | pub ssi_addr: ::uint64_t, | ||
164 | _pad: [::uint8_t; 48], | ||
165 | } | ||
166 | |||
167 | pub struct fsid_t { | ||
168 | __val: [::c_int; 2], | ||
169 | } | ||
170 | |||
171 | pub struct mq_attr { | ||
172 | pub mq_flags: ::c_long, | ||
173 | pub mq_maxmsg: ::c_long, | ||
174 | pub mq_msgsize: ::c_long, | ||
175 | pub mq_curmsgs: ::c_long, | ||
176 | pad: [::c_long; 4] | ||
177 | } | ||
178 | |||
179 | pub struct cpu_set_t { | ||
180 | #[cfg(target_pointer_width = "32")] | ||
181 | bits: [u32; 32], | ||
182 | #[cfg(target_pointer_width = "64")] | ||
183 | bits: [u64; 16], | ||
184 | } | ||
185 | |||
186 | pub struct if_nameindex { | ||
187 | pub if_index: ::c_uint, | ||
188 | pub if_name: *mut ::c_char, | ||
189 | } | ||
190 | |||
191 | } | ||
192 | |||
193 | pub const ABDAY_1: ::nl_item = 0x20000; | ||
194 | pub const ABDAY_2: ::nl_item = 0x20001; | ||
195 | pub const ABDAY_3: ::nl_item = 0x20002; | ||
196 | pub const ABDAY_4: ::nl_item = 0x20003; | ||
197 | pub const ABDAY_5: ::nl_item = 0x20004; | ||
198 | pub const ABDAY_6: ::nl_item = 0x20005; | ||
199 | pub const ABDAY_7: ::nl_item = 0x20006; | ||
200 | |||
201 | pub const DAY_1: ::nl_item = 0x20007; | ||
202 | pub const DAY_2: ::nl_item = 0x20008; | ||
203 | pub const DAY_3: ::nl_item = 0x20009; | ||
204 | pub const DAY_4: ::nl_item = 0x2000A; | ||
205 | pub const DAY_5: ::nl_item = 0x2000B; | ||
206 | pub const DAY_6: ::nl_item = 0x2000C; | ||
207 | pub const DAY_7: ::nl_item = 0x2000D; | ||
208 | |||
209 | pub const ABMON_1: ::nl_item = 0x2000E; | ||
210 | pub const ABMON_2: ::nl_item = 0x2000F; | ||
211 | pub const ABMON_3: ::nl_item = 0x20010; | ||
212 | pub const ABMON_4: ::nl_item = 0x20011; | ||
213 | pub const ABMON_5: ::nl_item = 0x20012; | ||
214 | pub const ABMON_6: ::nl_item = 0x20013; | ||
215 | pub const ABMON_7: ::nl_item = 0x20014; | ||
216 | pub const ABMON_8: ::nl_item = 0x20015; | ||
217 | pub const ABMON_9: ::nl_item = 0x20016; | ||
218 | pub const ABMON_10: ::nl_item = 0x20017; | ||
219 | pub const ABMON_11: ::nl_item = 0x20018; | ||
220 | pub const ABMON_12: ::nl_item = 0x20019; | ||
221 | |||
222 | pub const MON_1: ::nl_item = 0x2001A; | ||
223 | pub const MON_2: ::nl_item = 0x2001B; | ||
224 | pub const MON_3: ::nl_item = 0x2001C; | ||
225 | pub const MON_4: ::nl_item = 0x2001D; | ||
226 | pub const MON_5: ::nl_item = 0x2001E; | ||
227 | pub const MON_6: ::nl_item = 0x2001F; | ||
228 | pub const MON_7: ::nl_item = 0x20020; | ||
229 | pub const MON_8: ::nl_item = 0x20021; | ||
230 | pub const MON_9: ::nl_item = 0x20022; | ||
231 | pub const MON_10: ::nl_item = 0x20023; | ||
232 | pub const MON_11: ::nl_item = 0x20024; | ||
233 | pub const MON_12: ::nl_item = 0x20025; | ||
234 | |||
235 | pub const AM_STR: ::nl_item = 0x20026; | ||
236 | pub const PM_STR: ::nl_item = 0x20027; | ||
237 | |||
238 | pub const D_T_FMT: ::nl_item = 0x20028; | ||
239 | pub const D_FMT: ::nl_item = 0x20029; | ||
240 | pub const T_FMT: ::nl_item = 0x2002A; | ||
241 | pub const T_FMT_AMPM: ::nl_item = 0x2002B; | ||
242 | |||
243 | pub const ERA: ::nl_item = 0x2002C; | ||
244 | pub const ERA_D_FMT: ::nl_item = 0x2002E; | ||
245 | pub const ALT_DIGITS: ::nl_item = 0x2002F; | ||
246 | pub const ERA_D_T_FMT: ::nl_item = 0x20030; | ||
247 | pub const ERA_T_FMT: ::nl_item = 0x20031; | ||
248 | |||
249 | pub const CODESET: ::nl_item = 14; | ||
250 | |||
251 | pub const CRNCYSTR: ::nl_item = 0x4000F; | ||
252 | |||
253 | pub const RADIXCHAR: ::nl_item = 0x10000; | ||
254 | pub const THOUSEP: ::nl_item = 0x10001; | ||
255 | |||
256 | pub const YESEXPR: ::nl_item = 0x50000; | ||
257 | pub const NOEXPR: ::nl_item = 0x50001; | ||
258 | pub const YESSTR: ::nl_item = 0x50002; | ||
259 | pub const NOSTR: ::nl_item = 0x50003; | ||
260 | |||
261 | pub const FILENAME_MAX: ::c_uint = 4096; | ||
262 | pub const L_tmpnam: ::c_uint = 20; | ||
263 | pub const _PC_LINK_MAX: ::c_int = 0; | ||
264 | pub const _PC_MAX_CANON: ::c_int = 1; | ||
265 | pub const _PC_MAX_INPUT: ::c_int = 2; | ||
266 | pub const _PC_NAME_MAX: ::c_int = 3; | ||
267 | pub const _PC_PATH_MAX: ::c_int = 4; | ||
268 | pub const _PC_PIPE_BUF: ::c_int = 5; | ||
269 | pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; | ||
270 | pub const _PC_NO_TRUNC: ::c_int = 7; | ||
271 | pub const _PC_VDISABLE: ::c_int = 8; | ||
272 | |||
273 | pub const _SC_ARG_MAX: ::c_int = 0; | ||
274 | pub const _SC_CHILD_MAX: ::c_int = 1; | ||
275 | pub const _SC_CLK_TCK: ::c_int = 2; | ||
276 | pub const _SC_NGROUPS_MAX: ::c_int = 3; | ||
277 | pub const _SC_OPEN_MAX: ::c_int = 4; | ||
278 | pub const _SC_STREAM_MAX: ::c_int = 5; | ||
279 | pub const _SC_TZNAME_MAX: ::c_int = 6; | ||
280 | pub const _SC_JOB_CONTROL: ::c_int = 7; | ||
281 | pub const _SC_SAVED_IDS: ::c_int = 8; | ||
282 | pub const _SC_REALTIME_SIGNALS: ::c_int = 9; | ||
283 | pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; | ||
284 | pub const _SC_TIMERS: ::c_int = 11; | ||
285 | pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; | ||
286 | pub const _SC_PRIORITIZED_IO: ::c_int = 13; | ||
287 | pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; | ||
288 | pub const _SC_FSYNC: ::c_int = 15; | ||
289 | pub const _SC_MAPPED_FILES: ::c_int = 16; | ||
290 | pub const _SC_MEMLOCK: ::c_int = 17; | ||
291 | pub const _SC_MEMLOCK_RANGE: ::c_int = 18; | ||
292 | pub const _SC_MEMORY_PROTECTION: ::c_int = 19; | ||
293 | pub const _SC_MESSAGE_PASSING: ::c_int = 20; | ||
294 | pub const _SC_SEMAPHORES: ::c_int = 21; | ||
295 | pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; | ||
296 | pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; | ||
297 | pub const _SC_AIO_MAX: ::c_int = 24; | ||
298 | pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; | ||
299 | pub const _SC_DELAYTIMER_MAX: ::c_int = 26; | ||
300 | pub const _SC_MQ_OPEN_MAX: ::c_int = 27; | ||
301 | pub const _SC_MQ_PRIO_MAX: ::c_int = 28; | ||
302 | pub const _SC_VERSION: ::c_int = 29; | ||
303 | pub const _SC_PAGESIZE: ::c_int = 30; | ||
304 | pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; | ||
305 | pub const _SC_RTSIG_MAX: ::c_int = 31; | ||
306 | pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; | ||
307 | pub const _SC_SEM_VALUE_MAX: ::c_int = 33; | ||
308 | pub const _SC_SIGQUEUE_MAX: ::c_int = 34; | ||
309 | pub const _SC_TIMER_MAX: ::c_int = 35; | ||
310 | pub const _SC_BC_BASE_MAX: ::c_int = 36; | ||
311 | pub const _SC_BC_DIM_MAX: ::c_int = 37; | ||
312 | pub const _SC_BC_SCALE_MAX: ::c_int = 38; | ||
313 | pub const _SC_BC_STRING_MAX: ::c_int = 39; | ||
314 | pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; | ||
315 | pub const _SC_EXPR_NEST_MAX: ::c_int = 42; | ||
316 | pub const _SC_LINE_MAX: ::c_int = 43; | ||
317 | pub const _SC_RE_DUP_MAX: ::c_int = 44; | ||
318 | pub const _SC_2_VERSION: ::c_int = 46; | ||
319 | pub const _SC_2_C_BIND: ::c_int = 47; | ||
320 | pub const _SC_2_C_DEV: ::c_int = 48; | ||
321 | pub const _SC_2_FORT_DEV: ::c_int = 49; | ||
322 | pub const _SC_2_FORT_RUN: ::c_int = 50; | ||
323 | pub const _SC_2_SW_DEV: ::c_int = 51; | ||
324 | pub const _SC_2_LOCALEDEF: ::c_int = 52; | ||
325 | pub const _SC_IOV_MAX: ::c_int = 60; | ||
326 | pub const _SC_THREADS: ::c_int = 67; | ||
327 | pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; | ||
328 | pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; | ||
329 | pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; | ||
330 | pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; | ||
331 | pub const _SC_TTY_NAME_MAX: ::c_int = 72; | ||
332 | pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; | ||
333 | pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; | ||
334 | pub const _SC_THREAD_STACK_MIN: ::c_int = 75; | ||
335 | pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; | ||
336 | pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; | ||
337 | pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; | ||
338 | pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; | ||
339 | pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; | ||
340 | pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; | ||
341 | pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; | ||
342 | pub const _SC_ATEXIT_MAX: ::c_int = 87; | ||
343 | pub const _SC_XOPEN_VERSION: ::c_int = 89; | ||
344 | pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; | ||
345 | pub const _SC_XOPEN_UNIX: ::c_int = 91; | ||
346 | pub const _SC_XOPEN_CRYPT: ::c_int = 92; | ||
347 | pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; | ||
348 | pub const _SC_XOPEN_SHM: ::c_int = 94; | ||
349 | pub const _SC_2_CHAR_TERM: ::c_int = 95; | ||
350 | pub const _SC_2_UPE: ::c_int = 97; | ||
351 | pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; | ||
352 | pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; | ||
353 | pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; | ||
354 | pub const _SC_XOPEN_LEGACY: ::c_int = 129; | ||
355 | pub const _SC_XOPEN_REALTIME: ::c_int = 130; | ||
356 | pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; | ||
357 | pub const _SC_HOST_NAME_MAX: ::c_int = 180; | ||
358 | |||
359 | pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; | ||
360 | pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; | ||
361 | |||
362 | pub const GLOB_ERR: ::c_int = 1 << 0; | ||
363 | pub const GLOB_MARK: ::c_int = 1 << 1; | ||
364 | pub const GLOB_NOSORT: ::c_int = 1 << 2; | ||
365 | pub const GLOB_DOOFFS: ::c_int = 1 << 3; | ||
366 | pub const GLOB_NOCHECK: ::c_int = 1 << 4; | ||
367 | pub const GLOB_APPEND: ::c_int = 1 << 5; | ||
368 | pub const GLOB_NOESCAPE: ::c_int = 1 << 6; | ||
369 | |||
370 | pub const GLOB_NOSPACE: ::c_int = 1; | ||
371 | pub const GLOB_ABORTED: ::c_int = 2; | ||
372 | pub const GLOB_NOMATCH: ::c_int = 3; | ||
373 | |||
374 | pub const POSIX_MADV_NORMAL: ::c_int = 0; | ||
375 | pub const POSIX_MADV_RANDOM: ::c_int = 1; | ||
376 | pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; | ||
377 | pub const POSIX_MADV_WILLNEED: ::c_int = 3; | ||
378 | |||
379 | pub const S_IEXEC: mode_t = 64; | ||
380 | pub const S_IWRITE: mode_t = 128; | ||
381 | pub const S_IREAD: mode_t = 256; | ||
382 | |||
383 | pub const F_LOCK: ::c_int = 1; | ||
384 | pub const F_TEST: ::c_int = 3; | ||
385 | pub const F_TLOCK: ::c_int = 2; | ||
386 | pub const F_ULOCK: ::c_int = 0; | ||
387 | |||
388 | pub const ST_RDONLY: ::c_ulong = 1; | ||
389 | pub const ST_NOSUID: ::c_ulong = 2; | ||
390 | pub const ST_NODEV: ::c_ulong = 4; | ||
391 | pub const ST_NOEXEC: ::c_ulong = 8; | ||
392 | pub const ST_SYNCHRONOUS: ::c_ulong = 16; | ||
393 | pub const ST_MANDLOCK: ::c_ulong = 64; | ||
394 | pub const ST_WRITE: ::c_ulong = 128; | ||
395 | pub const ST_APPEND: ::c_ulong = 256; | ||
396 | pub const ST_IMMUTABLE: ::c_ulong = 512; | ||
397 | pub const ST_NOATIME: ::c_ulong = 1024; | ||
398 | pub const ST_NODIRATIME: ::c_ulong = 2048; | ||
399 | |||
400 | pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; | ||
401 | pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; | ||
402 | pub const RTLD_NODELETE: ::c_int = 0x1000; | ||
403 | pub const RTLD_NOW: ::c_int = 0x2; | ||
404 | |||
405 | pub const TCP_MD5SIG: ::c_int = 14; | ||
406 | |||
407 | pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { | ||
408 | __align: [], | ||
409 | size: [0; __SIZEOF_PTHREAD_MUTEX_T], | ||
410 | }; | ||
411 | pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { | ||
412 | __align: [], | ||
413 | size: [0; __SIZEOF_PTHREAD_COND_T], | ||
414 | }; | ||
415 | pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { | ||
416 | __align: [], | ||
417 | size: [0; __SIZEOF_PTHREAD_RWLOCK_T], | ||
418 | }; | ||
419 | pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; | ||
420 | pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; | ||
421 | pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; | ||
422 | pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; | ||
423 | pub const __SIZEOF_PTHREAD_COND_T: usize = 48; | ||
424 | |||
425 | pub const SCHED_OTHER: ::c_int = 0; | ||
426 | pub const SCHED_FIFO: ::c_int = 1; | ||
427 | pub const SCHED_RR: ::c_int = 2; | ||
428 | pub const SCHED_BATCH: ::c_int = 3; | ||
429 | pub const SCHED_IDLE: ::c_int = 5; | ||
430 | |||
431 | pub const IPC_CREAT: ::c_int = 0o1000; | ||
432 | pub const IPC_EXCL: ::c_int = 0o2000; | ||
433 | pub const IPC_NOWAIT: ::c_int = 0o4000; | ||
434 | |||
435 | pub const IPC_RMID: ::c_int = 0; | ||
436 | pub const IPC_SET: ::c_int = 1; | ||
437 | pub const IPC_STAT: ::c_int = 2; | ||
438 | pub const IPC_INFO: ::c_int = 3; | ||
439 | |||
440 | pub const SHM_R: ::c_int = 0o400; | ||
441 | pub const SHM_W: ::c_int = 0o200; | ||
442 | |||
443 | pub const SHM_RDONLY: ::c_int = 0o10000; | ||
444 | pub const SHM_RND: ::c_int = 0o20000; | ||
445 | pub const SHM_REMAP: ::c_int = 0o40000; | ||
446 | pub const SHM_EXEC: ::c_int = 0o100000; | ||
447 | |||
448 | pub const SHM_LOCK: ::c_int = 11; | ||
449 | pub const SHM_UNLOCK: ::c_int = 12; | ||
450 | |||
451 | pub const SHM_HUGETLB: ::c_int = 0o4000; | ||
452 | pub const SHM_NORESERVE: ::c_int = 0o10000; | ||
453 | |||
454 | pub const EPOLLRDHUP: ::c_int = 0x2000; | ||
455 | pub const EPOLLONESHOT: ::c_int = 0x40000000; | ||
456 | |||
457 | pub const QFMT_VFS_OLD: ::c_int = 1; | ||
458 | pub const QFMT_VFS_V0: ::c_int = 2; | ||
459 | |||
460 | pub const SFD_CLOEXEC: ::c_int = 0x080000; | ||
461 | |||
462 | pub const EFD_SEMAPHORE: ::c_int = 0x1; | ||
463 | |||
464 | pub const NCCS: usize = 32; | ||
465 | |||
466 | pub const AF_NETLINK: ::c_int = 16; | ||
467 | |||
468 | pub const LOG_NFACILITIES: ::c_int = 24; | ||
469 | |||
470 | pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t; | ||
471 | |||
472 | pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32; | ||
473 | pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32; | ||
474 | pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32; | ||
475 | pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32; | ||
476 | pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32; | ||
477 | pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; | ||
478 | pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; | ||
479 | |||
480 | f! { | ||
481 | pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { | ||
482 | for slot in cpuset.bits.iter_mut() { | ||
483 | *slot = 0; | ||
484 | } | ||
485 | } | ||
486 | |||
487 | pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { | ||
488 | let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc | ||
489 | let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); | ||
490 | cpuset.bits[idx] |= 1 << offset; | ||
491 | () | ||
492 | } | ||
493 | |||
494 | pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { | ||
495 | let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); | ||
496 | let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); | ||
497 | 0 != (cpuset.bits[idx] & (1 << offset)) | ||
498 | } | ||
499 | |||
500 | pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { | ||
501 | set1.bits == set2.bits | ||
502 | } | ||
503 | } | ||
504 | |||
505 | extern { | ||
506 | pub fn setpwent(); | ||
507 | pub fn getpwent() -> *mut passwd; | ||
508 | pub fn shm_open(name: *const c_char, oflag: ::c_int, | ||
509 | mode: mode_t) -> ::c_int; | ||
510 | pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; | ||
511 | pub fn shmat(shmid: ::c_int, | ||
512 | shmaddr: *const ::c_void, | ||
513 | shmflg: ::c_int) -> *mut ::c_void; | ||
514 | pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; | ||
515 | pub fn shmctl(shmid: ::c_int, | ||
516 | cmd: ::c_int, | ||
517 | buf: *mut ::shmid_ds) -> ::c_int; | ||
518 | pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) | ||
519 | -> ::c_int; | ||
520 | pub fn __errno_location() -> *mut ::c_int; | ||
521 | |||
522 | pub fn fopen64(filename: *const c_char, | ||
523 | mode: *const c_char) -> *mut ::FILE; | ||
524 | pub fn freopen64(filename: *const c_char, mode: *const c_char, | ||
525 | file: *mut ::FILE) -> *mut ::FILE; | ||
526 | pub fn tmpfile64() -> *mut ::FILE; | ||
527 | pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; | ||
528 | pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; | ||
529 | pub fn fseeko64(stream: *mut ::FILE, | ||
530 | offset: ::off64_t, | ||
531 | whence: ::c_int) -> ::c_int; | ||
532 | pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; | ||
533 | pub fn fallocate(fd: ::c_int, mode: ::c_int, | ||
534 | offset: ::off_t, len: ::off_t) -> ::c_int; | ||
535 | pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, | ||
536 | len: ::off_t) -> ::c_int; | ||
537 | pub fn readahead(fd: ::c_int, offset: ::off64_t, | ||
538 | count: ::size_t) -> ::ssize_t; | ||
539 | pub fn getxattr(path: *const c_char, name: *const c_char, | ||
540 | value: *mut ::c_void, size: ::size_t) -> ::ssize_t; | ||
541 | pub fn lgetxattr(path: *const c_char, name: *const c_char, | ||
542 | value: *mut ::c_void, size: ::size_t) -> ::ssize_t; | ||
543 | pub fn fgetxattr(filedes: ::c_int, name: *const c_char, | ||
544 | value: *mut ::c_void, size: ::size_t) -> ::ssize_t; | ||
545 | pub fn setxattr(path: *const c_char, name: *const c_char, | ||
546 | value: *const ::c_void, size: ::size_t, | ||
547 | flags: ::c_int) -> ::c_int; | ||
548 | pub fn lsetxattr(path: *const c_char, name: *const c_char, | ||
549 | value: *const ::c_void, size: ::size_t, | ||
550 | flags: ::c_int) -> ::c_int; | ||
551 | pub fn fsetxattr(filedes: ::c_int, name: *const c_char, | ||
552 | value: *const ::c_void, size: ::size_t, | ||
553 | flags: ::c_int) -> ::c_int; | ||
554 | pub fn listxattr(path: *const c_char, list: *mut c_char, | ||
555 | size: ::size_t) -> ::ssize_t; | ||
556 | pub fn llistxattr(path: *const c_char, list: *mut c_char, | ||
557 | size: ::size_t) -> ::ssize_t; | ||
558 | pub fn flistxattr(filedes: ::c_int, list: *mut c_char, | ||
559 | size: ::size_t) -> ::ssize_t; | ||
560 | pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int; | ||
561 | pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int; | ||
562 | pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int; | ||
563 | pub fn signalfd(fd: ::c_int, | ||
564 | mask: *const ::sigset_t, | ||
565 | flags: ::c_int) -> ::c_int; | ||
566 | pub fn pwritev(fd: ::c_int, | ||
567 | iov: *const ::iovec, | ||
568 | iovcnt: ::c_int, | ||
569 | offset: ::off_t) -> ::ssize_t; | ||
570 | pub fn preadv(fd: ::c_int, | ||
571 | iov: *const ::iovec, | ||
572 | iovcnt: ::c_int, | ||
573 | offset: ::off_t) -> ::ssize_t; | ||
574 | pub fn quotactl(cmd: ::c_int, | ||
575 | special: *const ::c_char, | ||
576 | id: ::c_int, | ||
577 | data: *mut ::c_char) -> ::c_int; | ||
578 | pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; | ||
579 | pub fn mq_close(mqd: ::mqd_t) -> ::c_int; | ||
580 | pub fn mq_unlink(name: *const ::c_char) -> ::c_int; | ||
581 | pub fn mq_receive(mqd: ::mqd_t, | ||
582 | msg_ptr: *mut ::c_char, | ||
583 | msg_len: ::size_t, | ||
584 | msq_prio: *mut ::c_uint) -> ::ssize_t; | ||
585 | pub fn mq_send(mqd: ::mqd_t, | ||
586 | msg_ptr: *const ::c_char, | ||
587 | msg_len: ::size_t, | ||
588 | msq_prio: ::c_uint) -> ::c_int; | ||
589 | pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; | ||
590 | pub fn mq_setattr(mqd: ::mqd_t, | ||
591 | newattr: *const ::mq_attr, | ||
592 | oldattr: *mut ::mq_attr) -> ::c_int; | ||
593 | pub fn sched_getaffinity(pid: ::pid_t, | ||
594 | cpusetsize: ::size_t, | ||
595 | cpuset: *mut cpu_set_t) -> ::c_int; | ||
596 | pub fn sched_setaffinity(pid: ::pid_t, | ||
597 | cpusetsize: ::size_t, | ||
598 | cpuset: *const cpu_set_t) -> ::c_int; | ||
599 | pub fn epoll_pwait(epfd: ::c_int, | ||
600 | events: *mut ::epoll_event, | ||
601 | maxevents: ::c_int, | ||
602 | timeout: ::c_int, | ||
603 | sigmask: *const ::sigset_t) -> ::c_int; | ||
604 | pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; | ||
605 | pub fn unshare(flags: ::c_int) -> ::c_int; | ||
606 | pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; | ||
607 | pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; | ||
608 | pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; | ||
609 | pub fn mkostemps(template: *mut ::c_char, | ||
610 | suffixlen: ::c_int, | ||
611 | flags: ::c_int) -> ::c_int; | ||
612 | pub fn sigtimedwait(set: *const sigset_t, | ||
613 | info: *mut siginfo_t, | ||
614 | timeout: *const ::timespec) -> ::c_int; | ||
615 | pub fn sigwaitinfo(set: *const sigset_t, | ||
616 | info: *mut siginfo_t) -> ::c_int; | ||
617 | pub fn openpty(amaster: *mut ::c_int, | ||
618 | aslave: *mut ::c_int, | ||
619 | name: *mut ::c_char, | ||
620 | termp: *const termios, | ||
621 | winp: *const ::winsize) -> ::c_int; | ||
622 | pub fn forkpty(amaster: *mut ::c_int, | ||
623 | name: *mut ::c_char, | ||
624 | termp: *const termios, | ||
625 | winp: *const ::winsize) -> ::pid_t; | ||
626 | pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; | ||
627 | pub fn getnameinfo(sa: *const ::sockaddr, | ||
628 | salen: ::socklen_t, | ||
629 | host: *mut ::c_char, | ||
630 | hostlen: ::socklen_t, | ||
631 | serv: *mut ::c_char, | ||
632 | sevlen: ::socklen_t, | ||
633 | flags: ::c_int) -> ::c_int; | ||
634 | pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit, | ||
635 | old_limit: *mut ::rlimit) -> ::c_int; | ||
636 | pub fn prlimit64(pid: ::pid_t, | ||
637 | resource: ::c_int, | ||
638 | new_limit: *const ::rlimit64, | ||
639 | old_limit: *mut ::rlimit64) -> ::c_int; | ||
640 | pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; | ||
641 | pub fn process_vm_readv(pid: ::pid_t, | ||
642 | local_iov: *const ::iovec, | ||
643 | liovcnt: ::c_ulong, | ||
644 | remote_iov: *const ::iovec, | ||
645 | riovcnt: ::c_ulong, | ||
646 | flags: ::c_ulong) -> isize; | ||
647 | pub fn process_vm_writev(pid: ::pid_t, | ||
648 | local_iov: *const ::iovec, | ||
649 | liovcnt: ::c_ulong, | ||
650 | remote_iov: *const ::iovec, | ||
651 | riovcnt: ::c_ulong, | ||
652 | flags: ::c_ulong) -> isize; | ||
653 | pub fn reboot(how_to: ::c_int) -> ::c_int; | ||
654 | |||
655 | // Not available now on Android | ||
656 | pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, | ||
657 | mode: ::mode_t) -> ::c_int; | ||
658 | pub fn if_nameindex() -> *mut if_nameindex; | ||
659 | pub fn if_freenameindex(ptr: *mut if_nameindex); | ||
660 | } | ||
661 | |||
662 | cfg_if! { | ||
663 | if #[cfg(any(target_env = "musl", | ||
664 | target_os = "emscripten"))] { | ||
665 | mod musl; | ||
666 | pub use self::musl::*; | ||
667 | } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { | ||
668 | mod mips; | ||
669 | pub use self::mips::*; | ||
670 | } else { | ||
671 | mod other; | ||
672 | pub use self::other::*; | ||
673 | } | ||
674 | } | ||