]>
Commit | Line | Data |
---|---|---|
92a42be0 SL |
1 | use dox::mem; |
2 | ||
92a42be0 SL |
3 | pub type sa_family_t = u16; |
4 | pub type pthread_key_t = ::c_uint; | |
9cc50fc6 SL |
5 | pub type speed_t = ::c_uint; |
6 | pub type tcflag_t = ::c_uint; | |
7453a54e | 7 | pub type loff_t = ::c_longlong; |
54a0048b | 8 | pub type clockid_t = ::c_int; |
9e0c209e | 9 | pub type key_t = ::c_int; |
3157f602 | 10 | pub type id_t = ::c_uint; |
92a42be0 SL |
11 | |
12 | pub enum timezone {} | |
13 | ||
14 | s! { | |
15 | pub struct sockaddr { | |
16 | pub sa_family: sa_family_t, | |
17 | pub sa_data: [::c_char; 14], | |
18 | } | |
19 | ||
20 | pub struct sockaddr_in { | |
21 | pub sin_family: sa_family_t, | |
22 | pub sin_port: ::in_port_t, | |
23 | pub sin_addr: ::in_addr, | |
24 | pub sin_zero: [u8; 8], | |
25 | } | |
26 | ||
27 | pub struct sockaddr_in6 { | |
28 | pub sin6_family: sa_family_t, | |
29 | pub sin6_port: ::in_port_t, | |
30 | pub sin6_flowinfo: u32, | |
31 | pub sin6_addr: ::in6_addr, | |
32 | pub sin6_scope_id: u32, | |
33 | } | |
34 | ||
35 | pub struct sockaddr_un { | |
36 | pub sun_family: sa_family_t, | |
37 | pub sun_path: [::c_char; 108] | |
38 | } | |
39 | ||
40 | pub struct sockaddr_storage { | |
41 | pub ss_family: sa_family_t, | |
42 | __ss_align: ::size_t, | |
43 | #[cfg(target_pointer_width = "32")] | |
44 | __ss_pad2: [u8; 128 - 2 * 4], | |
45 | #[cfg(target_pointer_width = "64")] | |
46 | __ss_pad2: [u8; 128 - 2 * 8], | |
47 | } | |
48 | ||
49 | pub struct addrinfo { | |
50 | pub ai_flags: ::c_int, | |
51 | pub ai_family: ::c_int, | |
52 | pub ai_socktype: ::c_int, | |
53 | pub ai_protocol: ::c_int, | |
54 | pub ai_addrlen: socklen_t, | |
55 | ||
c30ab7b3 SL |
56 | #[cfg(any(target_os = "linux", |
57 | target_os = "emscripten", | |
58 | target_os = "fuchsia"))] | |
92a42be0 SL |
59 | pub ai_addr: *mut ::sockaddr, |
60 | ||
61 | pub ai_canonname: *mut c_char, | |
62 | ||
63 | #[cfg(target_os = "android")] | |
64 | pub ai_addr: *mut ::sockaddr, | |
65 | ||
66 | pub ai_next: *mut addrinfo, | |
67 | } | |
68 | ||
54a0048b SL |
69 | pub struct sockaddr_nl { |
70 | pub nl_family: ::sa_family_t, | |
71 | nl_pad: ::c_ushort, | |
72 | pub nl_pid: u32, | |
73 | pub nl_groups: u32 | |
74 | } | |
75 | ||
92a42be0 SL |
76 | pub struct sockaddr_ll { |
77 | pub sll_family: ::c_ushort, | |
78 | pub sll_protocol: ::c_ushort, | |
79 | pub sll_ifindex: ::c_int, | |
80 | pub sll_hatype: ::c_ushort, | |
81 | pub sll_pkttype: ::c_uchar, | |
82 | pub sll_halen: ::c_uchar, | |
83 | pub sll_addr: [::c_uchar; 8] | |
84 | } | |
85 | ||
86 | pub struct fd_set { | |
87 | fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], | |
88 | } | |
89 | ||
90 | pub struct tm { | |
91 | pub tm_sec: ::c_int, | |
92 | pub tm_min: ::c_int, | |
93 | pub tm_hour: ::c_int, | |
94 | pub tm_mday: ::c_int, | |
95 | pub tm_mon: ::c_int, | |
96 | pub tm_year: ::c_int, | |
97 | pub tm_wday: ::c_int, | |
98 | pub tm_yday: ::c_int, | |
99 | pub tm_isdst: ::c_int, | |
100 | pub tm_gmtoff: ::c_long, | |
101 | pub tm_zone: *const ::c_char, | |
102 | } | |
9cc50fc6 SL |
103 | |
104 | pub struct sched_param { | |
105 | pub sched_priority: ::c_int, | |
5bcae85e | 106 | #[cfg(any(target_env = "musl"))] |
9cc50fc6 | 107 | pub sched_ss_low_priority: ::c_int, |
5bcae85e | 108 | #[cfg(any(target_env = "musl"))] |
9cc50fc6 | 109 | pub sched_ss_repl_period: ::timespec, |
5bcae85e | 110 | #[cfg(any(target_env = "musl"))] |
9cc50fc6 | 111 | pub sched_ss_init_budget: ::timespec, |
5bcae85e | 112 | #[cfg(any(target_env = "musl"))] |
9cc50fc6 SL |
113 | pub sched_ss_max_repl: ::c_int, |
114 | } | |
115 | ||
116 | pub struct Dl_info { | |
117 | pub dli_fname: *const ::c_char, | |
118 | pub dli_fbase: *mut ::c_void, | |
119 | pub dli_sname: *const ::c_char, | |
120 | pub dli_saddr: *mut ::c_void, | |
121 | } | |
122 | ||
cc61c64b XL |
123 | #[cfg_attr(any(all(target_arch = "x86", |
124 | not(target_env = "musl"), | |
125 | not(target_os = "android")), | |
7453a54e | 126 | target_arch = "x86_64"), |
9cc50fc6 SL |
127 | repr(packed))] |
128 | pub struct epoll_event { | |
129 | pub events: ::uint32_t, | |
130 | pub u64: ::uint64_t, | |
131 | } | |
132 | ||
133 | pub struct utsname { | |
134 | pub sysname: [::c_char; 65], | |
135 | pub nodename: [::c_char; 65], | |
136 | pub release: [::c_char; 65], | |
137 | pub version: [::c_char; 65], | |
138 | pub machine: [::c_char; 65], | |
139 | pub domainname: [::c_char; 65] | |
140 | } | |
54a0048b SL |
141 | |
142 | pub struct lconv { | |
143 | pub decimal_point: *mut ::c_char, | |
144 | pub thousands_sep: *mut ::c_char, | |
145 | pub grouping: *mut ::c_char, | |
146 | pub int_curr_symbol: *mut ::c_char, | |
147 | pub currency_symbol: *mut ::c_char, | |
148 | pub mon_decimal_point: *mut ::c_char, | |
149 | pub mon_thousands_sep: *mut ::c_char, | |
150 | pub mon_grouping: *mut ::c_char, | |
151 | pub positive_sign: *mut ::c_char, | |
152 | pub negative_sign: *mut ::c_char, | |
153 | pub int_frac_digits: ::c_char, | |
154 | pub frac_digits: ::c_char, | |
155 | pub p_cs_precedes: ::c_char, | |
156 | pub p_sep_by_space: ::c_char, | |
157 | pub n_cs_precedes: ::c_char, | |
158 | pub n_sep_by_space: ::c_char, | |
159 | pub p_sign_posn: ::c_char, | |
160 | pub n_sign_posn: ::c_char, | |
161 | pub int_p_cs_precedes: ::c_char, | |
162 | pub int_p_sep_by_space: ::c_char, | |
163 | pub int_n_cs_precedes: ::c_char, | |
164 | pub int_n_sep_by_space: ::c_char, | |
165 | pub int_p_sign_posn: ::c_char, | |
166 | pub int_n_sign_posn: ::c_char, | |
167 | } | |
476ff2be SL |
168 | |
169 | pub struct sigevent { | |
170 | pub sigev_value: ::sigval, | |
171 | pub sigev_signo: ::c_int, | |
172 | pub sigev_notify: ::c_int, | |
173 | // Actually a union. We only expose sigev_notify_thread_id because it's | |
174 | // the most useful member | |
175 | pub sigev_notify_thread_id: ::c_int, | |
176 | #[cfg(target_pointer_width = "64")] | |
177 | __unused1: [::c_int; 11], | |
178 | #[cfg(target_pointer_width = "32")] | |
179 | __unused1: [::c_int; 12] | |
180 | } | |
92a42be0 SL |
181 | } |
182 | ||
183 | // intentionally not public, only used for fd_set | |
54a0048b SL |
184 | cfg_if! { |
185 | if #[cfg(target_pointer_width = "32")] { | |
186 | const ULONG_SIZE: usize = 32; | |
187 | } else if #[cfg(target_pointer_width = "64")] { | |
188 | const ULONG_SIZE: usize = 64; | |
189 | } else { | |
190 | // Unknown target_pointer_width | |
191 | } | |
192 | } | |
92a42be0 SL |
193 | |
194 | pub const EXIT_FAILURE: ::c_int = 1; | |
195 | pub const EXIT_SUCCESS: ::c_int = 0; | |
196 | pub const RAND_MAX: ::c_int = 2147483647; | |
197 | pub const EOF: ::c_int = -1; | |
198 | pub const SEEK_SET: ::c_int = 0; | |
199 | pub const SEEK_CUR: ::c_int = 1; | |
200 | pub const SEEK_END: ::c_int = 2; | |
201 | pub const _IOFBF: ::c_int = 0; | |
202 | pub const _IONBF: ::c_int = 2; | |
203 | pub const _IOLBF: ::c_int = 1; | |
204 | ||
205 | pub const F_DUPFD: ::c_int = 0; | |
206 | pub const F_GETFD: ::c_int = 1; | |
207 | pub const F_SETFD: ::c_int = 2; | |
208 | pub const F_GETFL: ::c_int = 3; | |
209 | pub const F_SETFL: ::c_int = 4; | |
210 | ||
54a0048b SL |
211 | // Linux-specific fcntls |
212 | pub const F_SETLEASE: ::c_int = 1024; | |
213 | pub const F_GETLEASE: ::c_int = 1025; | |
214 | pub const F_NOTIFY: ::c_int = 1026; | |
215 | pub const F_DUPFD_CLOEXEC: ::c_int = 1030; | |
216 | pub const F_SETPIPE_SZ: ::c_int = 1031; | |
217 | pub const F_GETPIPE_SZ: ::c_int = 1032; | |
218 | ||
219 | // TODO(#235): Include file sealing fcntls once we have a way to verify them. | |
220 | ||
92a42be0 SL |
221 | pub const SIGTRAP: ::c_int = 5; |
222 | ||
223 | pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; | |
224 | pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; | |
225 | ||
54a0048b SL |
226 | pub const CLOCK_REALTIME: clockid_t = 0; |
227 | pub const CLOCK_MONOTONIC: clockid_t = 1; | |
228 | pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2; | |
229 | pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3; | |
230 | pub const CLOCK_MONOTONIC_RAW: clockid_t = 4; | |
231 | pub const CLOCK_REALTIME_COARSE: clockid_t = 5; | |
232 | pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6; | |
233 | pub const CLOCK_BOOTTIME: clockid_t = 7; | |
234 | pub const CLOCK_REALTIME_ALARM: clockid_t = 8; | |
235 | pub const CLOCK_BOOTTIME_ALARM: clockid_t = 9; | |
236 | // TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep | |
237 | // 2014.) See also musl/mod.rs | |
238 | // pub const CLOCK_SGI_CYCLE: clockid_t = 10; | |
239 | // pub const CLOCK_TAI: clockid_t = 11; | |
9e0c209e | 240 | pub const TIMER_ABSTIME: ::c_int = 1; |
92a42be0 SL |
241 | |
242 | pub const RLIMIT_CPU: ::c_int = 0; | |
243 | pub const RLIMIT_FSIZE: ::c_int = 1; | |
244 | pub const RLIMIT_DATA: ::c_int = 2; | |
245 | pub const RLIMIT_STACK: ::c_int = 3; | |
246 | pub const RLIMIT_CORE: ::c_int = 4; | |
247 | pub const RLIMIT_LOCKS: ::c_int = 10; | |
248 | pub const RLIMIT_SIGPENDING: ::c_int = 11; | |
249 | pub const RLIMIT_MSGQUEUE: ::c_int = 12; | |
250 | pub const RLIMIT_NICE: ::c_int = 13; | |
251 | pub const RLIMIT_RTPRIO: ::c_int = 14; | |
252 | ||
253 | pub const RUSAGE_SELF: ::c_int = 0; | |
254 | ||
255 | pub const O_RDONLY: ::c_int = 0; | |
256 | pub const O_WRONLY: ::c_int = 1; | |
257 | pub const O_RDWR: ::c_int = 2; | |
8bb4bdeb | 258 | pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; |
7453a54e SL |
259 | |
260 | pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; | |
261 | ||
92a42be0 SL |
262 | pub const S_IFIFO: ::mode_t = 4096; |
263 | pub const S_IFCHR: ::mode_t = 8192; | |
264 | pub const S_IFBLK: ::mode_t = 24576; | |
265 | pub const S_IFDIR: ::mode_t = 16384; | |
266 | pub const S_IFREG: ::mode_t = 32768; | |
267 | pub const S_IFLNK: ::mode_t = 40960; | |
268 | pub const S_IFSOCK: ::mode_t = 49152; | |
269 | pub const S_IFMT: ::mode_t = 61440; | |
270 | pub const S_IRWXU: ::mode_t = 448; | |
271 | pub const S_IXUSR: ::mode_t = 64; | |
272 | pub const S_IWUSR: ::mode_t = 128; | |
273 | pub const S_IRUSR: ::mode_t = 256; | |
274 | pub const S_IRWXG: ::mode_t = 56; | |
275 | pub const S_IXGRP: ::mode_t = 8; | |
276 | pub const S_IWGRP: ::mode_t = 16; | |
277 | pub const S_IRGRP: ::mode_t = 32; | |
278 | pub const S_IRWXO: ::mode_t = 7; | |
279 | pub const S_IXOTH: ::mode_t = 1; | |
280 | pub const S_IWOTH: ::mode_t = 2; | |
281 | pub const S_IROTH: ::mode_t = 4; | |
282 | pub const F_OK: ::c_int = 0; | |
283 | pub const R_OK: ::c_int = 4; | |
284 | pub const W_OK: ::c_int = 2; | |
285 | pub const X_OK: ::c_int = 1; | |
286 | pub const STDIN_FILENO: ::c_int = 0; | |
287 | pub const STDOUT_FILENO: ::c_int = 1; | |
288 | pub const STDERR_FILENO: ::c_int = 2; | |
289 | pub const SIGHUP: ::c_int = 1; | |
290 | pub const SIGINT: ::c_int = 2; | |
291 | pub const SIGQUIT: ::c_int = 3; | |
292 | pub const SIGILL: ::c_int = 4; | |
293 | pub const SIGABRT: ::c_int = 6; | |
294 | pub const SIGFPE: ::c_int = 8; | |
295 | pub const SIGKILL: ::c_int = 9; | |
296 | pub const SIGSEGV: ::c_int = 11; | |
297 | pub const SIGPIPE: ::c_int = 13; | |
298 | pub const SIGALRM: ::c_int = 14; | |
299 | pub const SIGTERM: ::c_int = 15; | |
300 | ||
301 | pub const PROT_NONE: ::c_int = 0; | |
302 | pub const PROT_READ: ::c_int = 1; | |
303 | pub const PROT_WRITE: ::c_int = 2; | |
304 | pub const PROT_EXEC: ::c_int = 4; | |
305 | ||
54a0048b SL |
306 | pub const LC_CTYPE: ::c_int = 0; |
307 | pub const LC_NUMERIC: ::c_int = 1; | |
308 | pub const LC_TIME: ::c_int = 2; | |
309 | pub const LC_COLLATE: ::c_int = 3; | |
310 | pub const LC_MONETARY: ::c_int = 4; | |
311 | pub const LC_MESSAGES: ::c_int = 5; | |
312 | pub const LC_ALL: ::c_int = 6; | |
a7813a04 XL |
313 | pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE); |
314 | pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC); | |
315 | pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME); | |
316 | pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE); | |
317 | pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY); | |
318 | pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES); | |
319 | // LC_ALL_MASK defined per platform | |
54a0048b | 320 | |
92a42be0 SL |
321 | pub const MAP_FILE: ::c_int = 0x0000; |
322 | pub const MAP_SHARED: ::c_int = 0x0001; | |
323 | pub const MAP_PRIVATE: ::c_int = 0x0002; | |
324 | pub const MAP_FIXED: ::c_int = 0x0010; | |
325 | ||
326 | pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; | |
327 | ||
54a0048b | 328 | // MS_ flags for msync(2) |
92a42be0 SL |
329 | pub const MS_ASYNC: ::c_int = 0x0001; |
330 | pub const MS_INVALIDATE: ::c_int = 0x0002; | |
331 | pub const MS_SYNC: ::c_int = 0x0004; | |
54a0048b SL |
332 | |
333 | // MS_ flags for mount(2) | |
9cc50fc6 SL |
334 | pub const MS_RDONLY: ::c_ulong = 0x01; |
335 | pub const MS_NOSUID: ::c_ulong = 0x02; | |
336 | pub const MS_NODEV: ::c_ulong = 0x04; | |
337 | pub const MS_NOEXEC: ::c_ulong = 0x08; | |
338 | pub const MS_SYNCHRONOUS: ::c_ulong = 0x10; | |
339 | pub const MS_REMOUNT: ::c_ulong = 0x20; | |
340 | pub const MS_MANDLOCK: ::c_ulong = 0x40; | |
341 | pub const MS_DIRSYNC: ::c_ulong = 0x80; | |
342 | pub const MS_NOATIME: ::c_ulong = 0x0400; | |
343 | pub const MS_NODIRATIME: ::c_ulong = 0x0800; | |
344 | pub const MS_BIND: ::c_ulong = 0x1000; | |
345 | pub const MS_MOVE: ::c_ulong = 0x2000; | |
346 | pub const MS_REC: ::c_ulong = 0x4000; | |
347 | pub const MS_SILENT: ::c_ulong = 0x8000; | |
348 | pub const MS_POSIXACL: ::c_ulong = 0x010000; | |
349 | pub const MS_UNBINDABLE: ::c_ulong = 0x020000; | |
350 | pub const MS_PRIVATE: ::c_ulong = 0x040000; | |
351 | pub const MS_SLAVE: ::c_ulong = 0x080000; | |
352 | pub const MS_SHARED: ::c_ulong = 0x100000; | |
54a0048b SL |
353 | pub const MS_RELATIME: ::c_ulong = 0x200000; |
354 | pub const MS_KERNMOUNT: ::c_ulong = 0x400000; | |
355 | pub const MS_I_VERSION: ::c_ulong = 0x800000; | |
356 | pub const MS_STRICTATIME: ::c_ulong = 0x1000000; | |
9cc50fc6 SL |
357 | pub const MS_ACTIVE: ::c_ulong = 0x40000000; |
358 | pub const MS_NOUSER: ::c_ulong = 0x80000000; | |
359 | pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; | |
360 | pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; | |
361 | pub const MS_RMT_MASK: ::c_ulong = 0x800051; | |
92a42be0 SL |
362 | |
363 | pub const EPERM: ::c_int = 1; | |
364 | pub const ENOENT: ::c_int = 2; | |
365 | pub const ESRCH: ::c_int = 3; | |
366 | pub const EINTR: ::c_int = 4; | |
367 | pub const EIO: ::c_int = 5; | |
368 | pub const ENXIO: ::c_int = 6; | |
369 | pub const E2BIG: ::c_int = 7; | |
370 | pub const ENOEXEC: ::c_int = 8; | |
371 | pub const EBADF: ::c_int = 9; | |
372 | pub const ECHILD: ::c_int = 10; | |
373 | pub const EAGAIN: ::c_int = 11; | |
374 | pub const ENOMEM: ::c_int = 12; | |
375 | pub const EACCES: ::c_int = 13; | |
376 | pub const EFAULT: ::c_int = 14; | |
377 | pub const ENOTBLK: ::c_int = 15; | |
378 | pub const EBUSY: ::c_int = 16; | |
379 | pub const EEXIST: ::c_int = 17; | |
380 | pub const EXDEV: ::c_int = 18; | |
381 | pub const ENODEV: ::c_int = 19; | |
382 | pub const ENOTDIR: ::c_int = 20; | |
383 | pub const EISDIR: ::c_int = 21; | |
384 | pub const EINVAL: ::c_int = 22; | |
385 | pub const ENFILE: ::c_int = 23; | |
386 | pub const EMFILE: ::c_int = 24; | |
387 | pub const ENOTTY: ::c_int = 25; | |
388 | pub const ETXTBSY: ::c_int = 26; | |
389 | pub const EFBIG: ::c_int = 27; | |
390 | pub const ENOSPC: ::c_int = 28; | |
391 | pub const ESPIPE: ::c_int = 29; | |
392 | pub const EROFS: ::c_int = 30; | |
393 | pub const EMLINK: ::c_int = 31; | |
394 | pub const EPIPE: ::c_int = 32; | |
395 | pub const EDOM: ::c_int = 33; | |
396 | pub const ERANGE: ::c_int = 34; | |
397 | pub const EWOULDBLOCK: ::c_int = EAGAIN; | |
398 | ||
cc61c64b XL |
399 | pub const SCM_RIGHTS: ::c_int = 0x01; |
400 | pub const SCM_CREDENTIALS: ::c_int = 0x02; | |
401 | ||
92a42be0 SL |
402 | pub const IPPROTO_RAW: ::c_int = 255; |
403 | ||
404 | pub const PROT_GROWSDOWN: ::c_int = 0x1000000; | |
405 | pub const PROT_GROWSUP: ::c_int = 0x2000000; | |
406 | ||
407 | pub const MAP_TYPE: ::c_int = 0x000f; | |
408 | ||
409 | pub const MADV_NORMAL: ::c_int = 0; | |
410 | pub const MADV_RANDOM: ::c_int = 1; | |
411 | pub const MADV_SEQUENTIAL: ::c_int = 2; | |
412 | pub const MADV_WILLNEED: ::c_int = 3; | |
413 | pub const MADV_DONTNEED: ::c_int = 4; | |
414 | pub const MADV_REMOVE: ::c_int = 9; | |
415 | pub const MADV_DONTFORK: ::c_int = 10; | |
416 | pub const MADV_DOFORK: ::c_int = 11; | |
417 | pub const MADV_MERGEABLE: ::c_int = 12; | |
418 | pub const MADV_UNMERGEABLE: ::c_int = 13; | |
419 | pub const MADV_HWPOISON: ::c_int = 100; | |
420 | ||
9e0c209e SL |
421 | pub const IFF_UP: ::c_int = 0x1; |
422 | pub const IFF_BROADCAST: ::c_int = 0x2; | |
423 | pub const IFF_DEBUG: ::c_int = 0x4; | |
92a42be0 | 424 | pub const IFF_LOOPBACK: ::c_int = 0x8; |
9e0c209e SL |
425 | pub const IFF_POINTOPOINT: ::c_int = 0x10; |
426 | pub const IFF_NOTRAILERS: ::c_int = 0x20; | |
427 | pub const IFF_RUNNING: ::c_int = 0x40; | |
428 | pub const IFF_NOARP: ::c_int = 0x80; | |
429 | pub const IFF_PROMISC: ::c_int = 0x100; | |
430 | pub const IFF_ALLMULTI: ::c_int = 0x200; | |
431 | pub const IFF_MASTER: ::c_int = 0x400; | |
432 | pub const IFF_SLAVE: ::c_int = 0x800; | |
433 | pub const IFF_MULTICAST: ::c_int = 0x1000; | |
434 | pub const IFF_PORTSEL: ::c_int = 0x2000; | |
435 | pub const IFF_AUTOMEDIA: ::c_int = 0x4000; | |
436 | pub const IFF_DYNAMIC: ::c_int = 0x8000; | |
92a42be0 | 437 | |
cc61c64b XL |
438 | pub const SOL_IP: ::c_int = 0; |
439 | pub const SOL_TCP: ::c_int = 6; | |
440 | pub const SOL_IPV6: ::c_int = 41; | |
441 | pub const SOL_ICMPV6: ::c_int = 58; | |
442 | pub const SOL_RAW: ::c_int = 255; | |
443 | pub const SOL_DECNET: ::c_int = 261; | |
444 | pub const SOL_X25: ::c_int = 262; | |
445 | pub const SOL_PACKET: ::c_int = 263; | |
446 | pub const SOL_ATM: ::c_int = 264; | |
447 | pub const SOL_AAL: ::c_int = 265; | |
448 | pub const SOL_IRDA: ::c_int = 266; | |
449 | pub const SOL_NETBEUI: ::c_int = 267; | |
450 | pub const SOL_LLC: ::c_int = 268; | |
451 | pub const SOL_DCCP: ::c_int = 269; | |
452 | pub const SOL_NETLINK: ::c_int = 270; | |
453 | pub const SOL_TIPC: ::c_int = 271; | |
454 | ||
455 | pub const AF_UNSPEC: ::c_int = 0; | |
92a42be0 | 456 | pub const AF_UNIX: ::c_int = 1; |
cc61c64b | 457 | pub const AF_LOCAL: ::c_int = 1; |
92a42be0 | 458 | pub const AF_INET: ::c_int = 2; |
cc61c64b XL |
459 | pub const AF_AX25: ::c_int = 3; |
460 | pub const AF_IPX: ::c_int = 4; | |
461 | pub const AF_APPLETALK: ::c_int = 5; | |
462 | pub const AF_NETROM: ::c_int = 6; | |
463 | pub const AF_BRIDGE: ::c_int = 7; | |
464 | pub const AF_ATMPVC: ::c_int = 8; | |
465 | pub const AF_X25: ::c_int = 9; | |
92a42be0 | 466 | pub const AF_INET6: ::c_int = 10; |
cc61c64b XL |
467 | pub const AF_ROSE: ::c_int = 11; |
468 | pub const AF_DECnet: ::c_int = 12; | |
469 | pub const AF_NETBEUI: ::c_int = 13; | |
470 | pub const AF_SECURITY: ::c_int = 14; | |
471 | pub const AF_KEY: ::c_int = 15; | |
9e0c209e | 472 | pub const AF_NETLINK: ::c_int = 16; |
cc61c64b XL |
473 | pub const AF_ROUTE: ::c_int = AF_NETLINK; |
474 | pub const AF_PACKET: ::c_int = 17; | |
475 | pub const AF_ASH: ::c_int = 18; | |
476 | pub const AF_ECONET: ::c_int = 19; | |
477 | pub const AF_ATMSVC: ::c_int = 20; | |
478 | pub const AF_RDS: ::c_int = 21; | |
479 | pub const AF_SNA: ::c_int = 22; | |
480 | pub const AF_IRDA: ::c_int = 23; | |
481 | pub const AF_PPPOX: ::c_int = 24; | |
482 | pub const AF_WANPIPE: ::c_int = 25; | |
483 | pub const AF_LLC: ::c_int = 26; | |
484 | pub const AF_CAN: ::c_int = 29; | |
485 | pub const AF_TIPC: ::c_int = 30; | |
486 | pub const AF_BLUETOOTH: ::c_int = 31; | |
487 | pub const AF_IUCV: ::c_int = 32; | |
488 | pub const AF_RXRPC: ::c_int = 33; | |
489 | pub const AF_ISDN: ::c_int = 34; | |
490 | pub const AF_PHONET: ::c_int = 35; | |
491 | pub const AF_IEEE802154: ::c_int = 36; | |
492 | pub const AF_CAIF: ::c_int = 37; | |
493 | pub const AF_ALG: ::c_int = 38; | |
494 | ||
495 | pub const PF_UNSPEC: ::c_int = AF_UNSPEC; | |
496 | pub const PF_UNIX: ::c_int = AF_UNIX; | |
497 | pub const PF_LOCAL: ::c_int = AF_LOCAL; | |
498 | pub const PF_INET: ::c_int = AF_INET; | |
499 | pub const PF_AX25: ::c_int = AF_AX25; | |
500 | pub const PF_IPX: ::c_int = AF_IPX; | |
501 | pub const PF_APPLETALK: ::c_int = AF_APPLETALK; | |
502 | pub const PF_NETROM: ::c_int = AF_NETROM; | |
503 | pub const PF_BRIDGE: ::c_int = AF_BRIDGE; | |
504 | pub const PF_ATMPVC: ::c_int = AF_ATMPVC; | |
505 | pub const PF_X25: ::c_int = AF_X25; | |
506 | pub const PF_INET6: ::c_int = AF_INET6; | |
507 | pub const PF_ROSE: ::c_int = AF_ROSE; | |
508 | pub const PF_DECnet: ::c_int = AF_DECnet; | |
509 | pub const PF_NETBEUI: ::c_int = AF_NETBEUI; | |
510 | pub const PF_SECURITY: ::c_int = AF_SECURITY; | |
511 | pub const PF_KEY: ::c_int = AF_KEY; | |
512 | pub const PF_NETLINK: ::c_int = AF_NETLINK; | |
513 | pub const PF_ROUTE: ::c_int = AF_ROUTE; | |
514 | pub const PF_PACKET: ::c_int = AF_PACKET; | |
515 | pub const PF_ASH: ::c_int = AF_ASH; | |
516 | pub const PF_ECONET: ::c_int = AF_ECONET; | |
517 | pub const PF_ATMSVC: ::c_int = AF_ATMSVC; | |
518 | pub const PF_RDS: ::c_int = AF_RDS; | |
519 | pub const PF_SNA: ::c_int = AF_SNA; | |
520 | pub const PF_IRDA: ::c_int = AF_IRDA; | |
521 | pub const PF_PPPOX: ::c_int = AF_PPPOX; | |
522 | pub const PF_WANPIPE: ::c_int = AF_WANPIPE; | |
523 | pub const PF_LLC: ::c_int = AF_LLC; | |
524 | pub const PF_CAN: ::c_int = AF_CAN; | |
525 | pub const PF_TIPC: ::c_int = AF_TIPC; | |
526 | pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; | |
527 | pub const PF_IUCV: ::c_int = AF_IUCV; | |
528 | pub const PF_RXRPC: ::c_int = AF_RXRPC; | |
529 | pub const PF_ISDN: ::c_int = AF_ISDN; | |
530 | pub const PF_PHONET: ::c_int = AF_PHONET; | |
531 | pub const PF_IEEE802154: ::c_int = AF_IEEE802154; | |
532 | pub const PF_CAIF: ::c_int = AF_CAIF; | |
533 | pub const PF_ALG: ::c_int = AF_ALG; | |
534 | ||
535 | pub const SOMAXCONN: ::c_int = 128; | |
536 | ||
537 | pub const MSG_OOB: ::c_int = 1; | |
538 | pub const MSG_PEEK: ::c_int = 2; | |
539 | pub const MSG_DONTROUTE: ::c_int = 4; | |
540 | pub const MSG_CTRUNC: ::c_int = 8; | |
541 | pub const MSG_TRUNC: ::c_int = 0x20; | |
542 | pub const MSG_DONTWAIT: ::c_int = 0x40; | |
543 | pub const MSG_EOR: ::c_int = 0x80; | |
544 | pub const MSG_WAITALL: ::c_int = 0x100; | |
545 | pub const MSG_FIN: ::c_int = 0x200; | |
546 | pub const MSG_SYN: ::c_int = 0x400; | |
547 | pub const MSG_CONFIRM: ::c_int = 0x800; | |
548 | pub const MSG_RST: ::c_int = 0x1000; | |
549 | pub const MSG_ERRQUEUE: ::c_int = 0x2000; | |
550 | pub const MSG_NOSIGNAL: ::c_int = 0x4000; | |
551 | pub const MSG_MORE: ::c_int = 0x8000; | |
552 | pub const MSG_WAITFORONE: ::c_int = 0x10000; | |
553 | pub const MSG_FASTOPEN: ::c_int = 0x20000000; | |
554 | pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000; | |
555 | ||
92a42be0 | 556 | pub const SOCK_RAW: ::c_int = 3; |
8bb4bdeb XL |
557 | pub const IPPROTO_ICMP: ::c_int = 1; |
558 | pub const IPPROTO_ICMPV6: ::c_int = 58; | |
92a42be0 SL |
559 | pub const IPPROTO_TCP: ::c_int = 6; |
560 | pub const IPPROTO_IP: ::c_int = 0; | |
561 | pub const IPPROTO_IPV6: ::c_int = 41; | |
562 | pub const IP_MULTICAST_TTL: ::c_int = 33; | |
563 | pub const IP_MULTICAST_LOOP: ::c_int = 34; | |
564 | pub const IP_TTL: ::c_int = 2; | |
565 | pub const IP_HDRINCL: ::c_int = 3; | |
566 | pub const IP_ADD_MEMBERSHIP: ::c_int = 35; | |
567 | pub const IP_DROP_MEMBERSHIP: ::c_int = 36; | |
7453a54e | 568 | pub const IP_TRANSPARENT: ::c_int = 19; |
92a42be0 SL |
569 | pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; |
570 | pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; | |
571 | ||
572 | pub const TCP_NODELAY: ::c_int = 1; | |
573 | pub const TCP_MAXSEG: ::c_int = 2; | |
574 | pub const TCP_CORK: ::c_int = 3; | |
575 | pub const TCP_KEEPIDLE: ::c_int = 4; | |
576 | pub const TCP_KEEPINTVL: ::c_int = 5; | |
577 | pub const TCP_KEEPCNT: ::c_int = 6; | |
578 | pub const TCP_SYNCNT: ::c_int = 7; | |
579 | pub const TCP_LINGER2: ::c_int = 8; | |
580 | pub const TCP_DEFER_ACCEPT: ::c_int = 9; | |
581 | pub const TCP_WINDOW_CLAMP: ::c_int = 10; | |
582 | pub const TCP_INFO: ::c_int = 11; | |
583 | pub const TCP_QUICKACK: ::c_int = 12; | |
584 | pub const TCP_CONGESTION: ::c_int = 13; | |
585 | ||
586 | pub const IPV6_MULTICAST_LOOP: ::c_int = 19; | |
587 | pub const IPV6_V6ONLY: ::c_int = 26; | |
588 | ||
589 | pub const SO_DEBUG: ::c_int = 1; | |
590 | ||
591 | pub const SHUT_RD: ::c_int = 0; | |
592 | pub const SHUT_WR: ::c_int = 1; | |
593 | pub const SHUT_RDWR: ::c_int = 2; | |
594 | ||
595 | pub const LOCK_SH: ::c_int = 1; | |
596 | pub const LOCK_EX: ::c_int = 2; | |
597 | pub const LOCK_NB: ::c_int = 4; | |
598 | pub const LOCK_UN: ::c_int = 8; | |
599 | ||
7453a54e SL |
600 | pub const SS_ONSTACK: ::c_int = 1; |
601 | pub const SS_DISABLE: ::c_int = 2; | |
602 | ||
9cc50fc6 SL |
603 | pub const PATH_MAX: ::c_int = 4096; |
604 | ||
92a42be0 SL |
605 | pub const FD_SETSIZE: usize = 1024; |
606 | ||
9cc50fc6 SL |
607 | pub const EPOLLIN: ::c_int = 0x1; |
608 | pub const EPOLLPRI: ::c_int = 0x2; | |
609 | pub const EPOLLOUT: ::c_int = 0x4; | |
610 | pub const EPOLLRDNORM: ::c_int = 0x40; | |
611 | pub const EPOLLRDBAND: ::c_int = 0x80; | |
612 | pub const EPOLLWRNORM: ::c_int = 0x100; | |
613 | pub const EPOLLWRBAND: ::c_int = 0x200; | |
614 | pub const EPOLLMSG: ::c_int = 0x400; | |
615 | pub const EPOLLERR: ::c_int = 0x8; | |
616 | pub const EPOLLHUP: ::c_int = 0x10; | |
617 | pub const EPOLLET: ::c_int = 0x80000000; | |
618 | ||
619 | pub const EPOLL_CTL_ADD: ::c_int = 1; | |
620 | pub const EPOLL_CTL_MOD: ::c_int = 3; | |
621 | pub const EPOLL_CTL_DEL: ::c_int = 2; | |
622 | ||
623 | pub const MNT_DETACH: ::c_int = 0x2; | |
624 | pub const MNT_EXPIRE: ::c_int = 0x4; | |
625 | ||
626 | pub const Q_GETFMT: ::c_int = 0x800004; | |
627 | pub const Q_GETINFO: ::c_int = 0x800005; | |
628 | pub const Q_SETINFO: ::c_int = 0x800006; | |
629 | pub const QIF_BLIMITS: ::uint32_t = 1; | |
630 | pub const QIF_SPACE: ::uint32_t = 2; | |
631 | pub const QIF_ILIMITS: ::uint32_t = 4; | |
632 | pub const QIF_INODES: ::uint32_t = 8; | |
633 | pub const QIF_BTIME: ::uint32_t = 16; | |
634 | pub const QIF_ITIME: ::uint32_t = 32; | |
635 | pub const QIF_LIMITS: ::uint32_t = 5; | |
636 | pub const QIF_USAGE: ::uint32_t = 10; | |
637 | pub const QIF_TIMES: ::uint32_t = 48; | |
638 | pub const QIF_ALL: ::uint32_t = 63; | |
639 | ||
9cc50fc6 SL |
640 | pub const MNT_FORCE: ::c_int = 0x1; |
641 | ||
642 | pub const Q_SYNC: ::c_int = 0x800001; | |
643 | pub const Q_QUOTAON: ::c_int = 0x800002; | |
644 | pub const Q_QUOTAOFF: ::c_int = 0x800003; | |
645 | pub const Q_GETQUOTA: ::c_int = 0x800007; | |
646 | pub const Q_SETQUOTA: ::c_int = 0x800008; | |
647 | ||
648 | pub const TCIOFF: ::c_int = 2; | |
649 | pub const TCION: ::c_int = 3; | |
650 | pub const TCOOFF: ::c_int = 0; | |
651 | pub const TCOON: ::c_int = 1; | |
652 | pub const TCIFLUSH: ::c_int = 0; | |
653 | pub const TCOFLUSH: ::c_int = 1; | |
654 | pub const TCIOFLUSH: ::c_int = 2; | |
655 | pub const NL0: ::c_int = 0x00000000; | |
656 | pub const NL1: ::c_int = 0x00000100; | |
657 | pub const TAB0: ::c_int = 0x00000000; | |
9cc50fc6 | 658 | pub const CR0: ::c_int = 0x00000000; |
9cc50fc6 | 659 | pub const FF0: ::c_int = 0x00000000; |
9cc50fc6 | 660 | pub const BS0: ::c_int = 0x00000000; |
9cc50fc6 | 661 | pub const VT0: ::c_int = 0x00000000; |
9cc50fc6 | 662 | pub const VERASE: usize = 2; |
9cc50fc6 | 663 | pub const VKILL: usize = 3; |
9cc50fc6 SL |
664 | pub const VINTR: usize = 0; |
665 | pub const VQUIT: usize = 1; | |
9cc50fc6 | 666 | pub const VLNEXT: usize = 15; |
9cc50fc6 SL |
667 | pub const IGNBRK: ::tcflag_t = 0x00000001; |
668 | pub const BRKINT: ::tcflag_t = 0x00000002; | |
669 | pub const IGNPAR: ::tcflag_t = 0x00000004; | |
670 | pub const PARMRK: ::tcflag_t = 0x00000008; | |
671 | pub const INPCK: ::tcflag_t = 0x00000010; | |
672 | pub const ISTRIP: ::tcflag_t = 0x00000020; | |
673 | pub const INLCR: ::tcflag_t = 0x00000040; | |
674 | pub const IGNCR: ::tcflag_t = 0x00000080; | |
675 | pub const ICRNL: ::tcflag_t = 0x00000100; | |
9cc50fc6 SL |
676 | pub const IXANY: ::tcflag_t = 0x00000800; |
677 | pub const IMAXBEL: ::tcflag_t = 0x00002000; | |
cc61c64b | 678 | pub const IUTF8: ::tcflag_t = 0x00004000; |
9cc50fc6 | 679 | pub const OPOST: ::tcflag_t = 0x1; |
9cc50fc6 | 680 | pub const CS5: ::tcflag_t = 0x00000000; |
9cc50fc6 | 681 | pub const CRTSCTS: ::tcflag_t = 0x80000000; |
9cc50fc6 | 682 | pub const ECHO: ::tcflag_t = 0x00000008; |
9cc50fc6 SL |
683 | |
684 | pub const CLONE_VM: ::c_int = 0x100; | |
685 | pub const CLONE_FS: ::c_int = 0x200; | |
686 | pub const CLONE_FILES: ::c_int = 0x400; | |
687 | pub const CLONE_SIGHAND: ::c_int = 0x800; | |
688 | pub const CLONE_PTRACE: ::c_int = 0x2000; | |
689 | pub const CLONE_VFORK: ::c_int = 0x4000; | |
690 | pub const CLONE_PARENT: ::c_int = 0x8000; | |
691 | pub const CLONE_THREAD: ::c_int = 0x10000; | |
692 | pub const CLONE_NEWNS: ::c_int = 0x20000; | |
693 | pub const CLONE_SYSVSEM: ::c_int = 0x40000; | |
694 | pub const CLONE_SETTLS: ::c_int = 0x80000; | |
695 | pub const CLONE_PARENT_SETTID: ::c_int = 0x100000; | |
696 | pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; | |
697 | pub const CLONE_DETACHED: ::c_int = 0x400000; | |
698 | pub const CLONE_UNTRACED: ::c_int = 0x800000; | |
699 | pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; | |
54a0048b SL |
700 | pub const CLONE_NEWUTS: ::c_int = 0x04000000; |
701 | pub const CLONE_NEWIPC: ::c_int = 0x08000000; | |
702 | pub const CLONE_NEWUSER: ::c_int = 0x10000000; | |
703 | pub const CLONE_NEWPID: ::c_int = 0x20000000; | |
704 | pub const CLONE_NEWNET: ::c_int = 0x40000000; | |
705 | pub const CLONE_IO: ::c_int = 0x80000000; | |
9cc50fc6 | 706 | |
5bcae85e SL |
707 | pub const WNOHANG: ::c_int = 0x00000001; |
708 | pub const WUNTRACED: ::c_int = 0x00000002; | |
709 | pub const WSTOPPED: ::c_int = WUNTRACED; | |
710 | pub const WEXITED: ::c_int = 0x00000004; | |
711 | pub const WCONTINUED: ::c_int = 0x00000008; | |
712 | pub const WNOWAIT: ::c_int = 0x01000000; | |
713 | ||
714 | pub const __WNOTHREAD: ::c_int = 0x20000000; | |
715 | pub const __WALL: ::c_int = 0x40000000; | |
716 | pub const __WCLONE: ::c_int = 0x80000000; | |
7453a54e SL |
717 | |
718 | pub const SPLICE_F_MOVE: ::c_uint = 0x01; | |
719 | pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02; | |
720 | pub const SPLICE_F_MORE: ::c_uint = 0x04; | |
721 | pub const SPLICE_F_GIFT: ::c_uint = 0x08; | |
722 | ||
723 | pub const RTLD_LOCAL: ::c_int = 0; | |
724 | ||
725 | pub const POSIX_FADV_NORMAL: ::c_int = 0; | |
726 | pub const POSIX_FADV_RANDOM: ::c_int = 1; | |
727 | pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; | |
728 | pub const POSIX_FADV_WILLNEED: ::c_int = 3; | |
7453a54e | 729 | |
54a0048b SL |
730 | pub const AT_FDCWD: ::c_int = -100; |
731 | pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100; | |
cc61c64b XL |
732 | pub const AT_REMOVEDIR: ::c_int = 0x200; |
733 | pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; | |
734 | pub const AT_NO_AUTOMOUNT: ::c_int = 0x800; | |
735 | pub const AT_EMPTY_PATH: ::c_int = 0x1000; | |
54a0048b | 736 | |
a7813a04 XL |
737 | pub const LOG_CRON: ::c_int = 9 << 3; |
738 | pub const LOG_AUTHPRIV: ::c_int = 10 << 3; | |
739 | pub const LOG_FTP: ::c_int = 11 << 3; | |
740 | pub const LOG_PERROR: ::c_int = 0x20; | |
741 | ||
742 | pub const PIPE_BUF: usize = 4096; | |
743 | ||
3157f602 XL |
744 | pub const SI_LOAD_SHIFT: ::c_uint = 16; |
745 | ||
476ff2be SL |
746 | pub const SIGEV_SIGNAL: ::c_int = 0; |
747 | pub const SIGEV_NONE: ::c_int = 1; | |
748 | pub const SIGEV_THREAD: ::c_int = 2; | |
749 | ||
8bb4bdeb XL |
750 | pub const P_ALL: idtype_t = 0; |
751 | pub const P_PID: idtype_t = 1; | |
752 | pub const P_PGID: idtype_t = 2; | |
753 | ||
cc61c64b XL |
754 | pub const UTIME_OMIT: c_long = 1073741822; |
755 | pub const UTIME_NOW: c_long = 1073741823; | |
756 | ||
92a42be0 SL |
757 | f! { |
758 | pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { | |
759 | let fd = fd as usize; | |
760 | let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; | |
761 | (*set).fds_bits[fd / size] &= !(1 << (fd % size)); | |
762 | return | |
763 | } | |
764 | ||
765 | pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { | |
766 | let fd = fd as usize; | |
767 | let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; | |
768 | return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 | |
769 | } | |
770 | ||
771 | pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { | |
772 | let fd = fd as usize; | |
773 | let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; | |
774 | (*set).fds_bits[fd / size] |= 1 << (fd % size); | |
775 | return | |
776 | } | |
777 | ||
778 | pub fn FD_ZERO(set: *mut fd_set) -> () { | |
779 | for slot in (*set).fds_bits.iter_mut() { | |
780 | *slot = 0; | |
781 | } | |
782 | } | |
783 | ||
5bcae85e SL |
784 | pub fn WIFSTOPPED(status: ::c_int) -> bool { |
785 | (status & 0xff) == 0x7f | |
92a42be0 SL |
786 | } |
787 | ||
5bcae85e | 788 | pub fn WSTOPSIG(status: ::c_int) -> ::c_int { |
92a42be0 SL |
789 | (status >> 8) & 0xff |
790 | } | |
791 | ||
8bb4bdeb XL |
792 | pub fn WIFCONTINUED(status: ::c_int) -> bool { |
793 | status == 0xffff | |
794 | } | |
795 | ||
5bcae85e | 796 | pub fn WIFSIGNALED(status: ::c_int) -> bool { |
32a655c1 | 797 | ((status & 0x7f) + 1) as i8 >= 2 |
5bcae85e SL |
798 | } |
799 | ||
92a42be0 SL |
800 | pub fn WTERMSIG(status: ::c_int) -> ::c_int { |
801 | status & 0x7f | |
802 | } | |
5bcae85e SL |
803 | |
804 | pub fn WIFEXITED(status: ::c_int) -> bool { | |
805 | (status & 0x7f) == 0 | |
806 | } | |
807 | ||
808 | pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { | |
809 | (status >> 8) & 0xff | |
810 | } | |
811 | ||
812 | pub fn WCOREDUMP(status: ::c_int) -> bool { | |
813 | (status & 0x80) != 0 | |
814 | } | |
92a42be0 SL |
815 | } |
816 | ||
817 | extern { | |
9e0c209e SL |
818 | pub fn getpwnam_r(name: *const ::c_char, |
819 | pwd: *mut passwd, | |
820 | buf: *mut ::c_char, | |
821 | buflen: ::size_t, | |
822 | result: *mut *mut passwd) -> ::c_int; | |
7453a54e SL |
823 | pub fn getpwuid_r(uid: ::uid_t, |
824 | pwd: *mut passwd, | |
825 | buf: *mut ::c_char, | |
826 | buflen: ::size_t, | |
827 | result: *mut *mut passwd) -> ::c_int; | |
92a42be0 SL |
828 | pub fn fdatasync(fd: ::c_int) -> ::c_int; |
829 | pub fn mincore(addr: *mut ::c_void, len: ::size_t, | |
830 | vec: *mut ::c_uchar) -> ::c_int; | |
54a0048b SL |
831 | pub fn clock_getres(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int; |
832 | pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int; | |
9e0c209e SL |
833 | pub fn clock_nanosleep(clk_id: clockid_t, |
834 | flags: ::c_int, | |
835 | rqtp: *const ::timespec, | |
836 | rmtp: *mut ::timespec) -> ::c_int; | |
32a655c1 | 837 | pub fn clock_settime(clk_id: clockid_t, tp: *const ::timespec) -> ::c_int; |
92a42be0 SL |
838 | pub fn prctl(option: ::c_int, ...) -> ::c_int; |
839 | pub fn pthread_getattr_np(native: ::pthread_t, | |
840 | attr: *mut ::pthread_attr_t) -> ::c_int; | |
841 | pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, | |
842 | guardsize: *mut ::size_t) -> ::c_int; | |
843 | pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, | |
844 | stackaddr: *mut *mut ::c_void, | |
845 | stacksize: *mut ::size_t) -> ::c_int; | |
846 | pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; | |
847 | pub fn setgroups(ngroups: ::size_t, | |
848 | ptr: *const ::gid_t) -> ::c_int; | |
32a655c1 | 849 | pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; |
54a0048b SL |
850 | pub fn sched_setscheduler(pid: ::pid_t, |
851 | policy: ::c_int, | |
852 | param: *const sched_param) -> ::c_int; | |
9cc50fc6 SL |
853 | pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; |
854 | pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; | |
855 | pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; | |
856 | pub fn epoll_create(size: ::c_int) -> ::c_int; | |
5bcae85e | 857 | pub fn epoll_create1(flags: ::c_int) -> ::c_int; |
9cc50fc6 SL |
858 | pub fn epoll_ctl(epfd: ::c_int, |
859 | op: ::c_int, | |
860 | fd: ::c_int, | |
861 | event: *mut epoll_event) -> ::c_int; | |
862 | pub fn epoll_wait(epfd: ::c_int, | |
863 | events: *mut epoll_event, | |
864 | maxevents: ::c_int, | |
865 | timeout: ::c_int) -> ::c_int; | |
866 | pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; | |
867 | pub fn mount(src: *const ::c_char, | |
868 | target: *const ::c_char, | |
869 | fstype: *const ::c_char, | |
870 | flags: ::c_ulong, | |
871 | data: *const ::c_void) -> ::c_int; | |
872 | pub fn umount(target: *const ::c_char) -> ::c_int; | |
873 | pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; | |
874 | pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int, | |
875 | child_stack: *mut ::c_void, | |
876 | flags: ::c_int, | |
877 | arg: *mut ::c_void, ...) -> ::c_int; | |
878 | pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; | |
879 | pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; | |
54a0048b SL |
880 | pub fn memrchr(cx: *const ::c_void, |
881 | c: ::c_int, | |
882 | n: ::size_t) -> *mut ::c_void; | |
9cc50fc6 | 883 | pub fn syscall(num: ::c_long, ...) -> ::c_long; |
7453a54e SL |
884 | pub fn sendfile(out_fd: ::c_int, |
885 | in_fd: ::c_int, | |
886 | offset: *mut off_t, | |
887 | count: ::size_t) -> ::ssize_t; | |
888 | pub fn splice(fd_in: ::c_int, | |
889 | off_in: *mut ::loff_t, | |
890 | fd_out: ::c_int, | |
891 | off_out: *mut ::loff_t, | |
892 | len: ::size_t, | |
893 | flags: ::c_uint) -> ::ssize_t; | |
894 | pub fn tee(fd_in: ::c_int, | |
895 | fd_out: ::c_int, | |
896 | len: ::size_t, | |
897 | flags: ::c_uint) -> ::ssize_t; | |
898 | pub fn vmsplice(fd: ::c_int, | |
899 | iov: *const ::iovec, | |
900 | nr_segs: ::size_t, | |
901 | flags: ::c_uint) -> ::ssize_t; | |
902 | ||
54a0048b | 903 | pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, |
7453a54e | 904 | advise: ::c_int) -> ::c_int; |
54a0048b SL |
905 | pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; |
906 | pub fn utimensat(dirfd: ::c_int, path: *const ::c_char, | |
907 | times: *const ::timespec, flag: ::c_int) -> ::c_int; | |
a7813a04 XL |
908 | pub fn duplocale(base: ::locale_t) -> ::locale_t; |
909 | pub fn freelocale(loc: ::locale_t); | |
910 | pub fn newlocale(mask: ::c_int, | |
911 | locale: *const ::c_char, | |
912 | base: ::locale_t) -> ::locale_t; | |
913 | pub fn uselocale(loc: ::locale_t) -> ::locale_t; | |
914 | pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; | |
915 | pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; | |
916 | pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; | |
917 | pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; | |
918 | pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; | |
919 | pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int; | |
920 | pub fn mmap64(addr: *mut ::c_void, | |
921 | len: ::size_t, | |
922 | prot: ::c_int, | |
923 | flags: ::c_int, | |
924 | fd: ::c_int, | |
925 | offset: off64_t) | |
926 | -> *mut ::c_void; | |
927 | pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; | |
cc61c64b XL |
928 | pub fn openat64(fd: ::c_int, |
929 | path: *const c_char, | |
930 | oflag: ::c_int, ...) -> ::c_int; | |
a7813a04 XL |
931 | pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, |
932 | offset: off64_t) -> ::ssize_t; | |
933 | pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t, | |
934 | offset: off64_t) -> ::ssize_t; | |
cc61c64b | 935 | pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64; |
a7813a04 XL |
936 | pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64, |
937 | result: *mut *mut ::dirent64) -> ::c_int; | |
938 | pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; | |
939 | pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; | |
cc61c64b | 940 | pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; |
a7813a04 | 941 | pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; |
3157f602 | 942 | pub fn sysinfo (info: *mut ::sysinfo) -> ::c_int; |
5bcae85e | 943 | |
cc61c64b XL |
944 | pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; |
945 | ||
5bcae85e SL |
946 | pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, |
947 | mode: ::mode_t, dev: dev_t) -> ::c_int; | |
cc61c64b XL |
948 | pub fn ppoll(fds: *mut ::pollfd, |
949 | nfds: nfds_t, | |
950 | timeout: *const ::timespec, | |
951 | sigmask: *const sigset_t) -> ::c_int; | |
5bcae85e SL |
952 | pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, |
953 | clock_id: *mut clockid_t) -> ::c_int; | |
954 | pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, | |
955 | clock_id: clockid_t) -> ::c_int; | |
8bb4bdeb XL |
956 | pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, |
957 | pshared: ::c_int) -> ::c_int; | |
958 | pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, | |
959 | pshared: *mut ::c_int) -> ::c_int; | |
9e0c209e SL |
960 | pub fn sched_getaffinity(pid: ::pid_t, |
961 | cpusetsize: ::size_t, | |
962 | cpuset: *mut cpu_set_t) -> ::c_int; | |
963 | pub fn sched_setaffinity(pid: ::pid_t, | |
964 | cpusetsize: ::size_t, | |
965 | cpuset: *const cpu_set_t) -> ::c_int; | |
966 | pub fn unshare(flags: ::c_int) -> ::c_int; | |
967 | pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; | |
968 | pub fn sem_timedwait(sem: *mut sem_t, | |
969 | abstime: *const ::timespec) -> ::c_int; | |
970 | pub fn accept4(fd: ::c_int, addr: *mut ::sockaddr, len: *mut ::socklen_t, | |
971 | flg: ::c_int) -> ::c_int; | |
972 | pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, | |
973 | abstime: *const ::timespec) -> ::c_int; | |
8bb4bdeb XL |
974 | pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, |
975 | pshared: ::c_int) -> ::c_int; | |
976 | pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, | |
977 | pshared: *mut ::c_int) -> ::c_int; | |
c30ab7b3 SL |
978 | pub fn ptsname_r(fd: ::c_int, |
979 | buf: *mut ::c_char, | |
980 | buflen: ::size_t) -> ::c_int; | |
32a655c1 | 981 | pub fn clearenv() -> ::c_int; |
8bb4bdeb XL |
982 | pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, |
983 | options: ::c_int) -> ::c_int; | |
92a42be0 SL |
984 | } |
985 | ||
986 | cfg_if! { | |
9cc50fc6 | 987 | if #[cfg(any(target_os = "linux", |
c30ab7b3 SL |
988 | target_os = "emscripten", |
989 | target_os = "fuchsia"))] { | |
92a42be0 SL |
990 | mod linux; |
991 | pub use self::linux::*; | |
992 | } else if #[cfg(target_os = "android")] { | |
993 | mod android; | |
994 | pub use self::android::*; | |
995 | } else { | |
54a0048b | 996 | // Unknown target_os |
92a42be0 SL |
997 | } |
998 | } |