blob: 6f45cc19176ef9f8675ea0ddf2a3c6905c1781c7 [file] [log] [blame]
Taylor Cramerf7f9be32017-11-15 10:22:26 -08001//! Definitions found commonly among almost all Unix derivatives
2//!
3//! More functions and definitions can be found in the more specific modules
4//! according to the platform in question.
5
6use dox::{mem, Option};
7
Taylor Cramerb4cfe882017-11-15 11:29:01 -08008// PUB_TYPE
9
gnzlbg5c1a6b82018-11-21 20:34:50 +010010pub type int8_t = i8;
11pub type int16_t = i16;
12pub type int32_t = i32;
13pub type int64_t = i64;
14pub type uint8_t = u8;
15pub type uint16_t = u16;
16pub type uint32_t = u32;
17pub type uint64_t = u64;
18
19pub type c_schar = i8;
20pub type c_uchar = u8;
21pub type c_short = i16;
22pub type c_ushort = u16;
23pub type c_int = i32;
24pub type c_uint = u32;
25pub type c_float = f32;
26pub type c_double = f64;
27pub type c_longlong = i64;
28pub type c_ulonglong = u64;
29pub type intmax_t = i64;
30pub type uintmax_t = u64;
31
32pub type size_t = usize;
33pub type ptrdiff_t = isize;
34pub type intptr_t = isize;
35pub type uintptr_t = usize;
36pub type ssize_t = isize;
37
Taylor Cramerf7f9be32017-11-15 10:22:26 -080038pub type pid_t = i32;
39pub type uid_t = u32;
40pub type gid_t = u32;
41pub type in_addr_t = u32;
42pub type in_port_t = u16;
43pub type sighandler_t = ::size_t;
44pub type cc_t = ::c_uchar;
Taylor Cramerb4cfe882017-11-15 11:29:01 -080045pub type sa_family_t = u16;
46pub type pthread_key_t = ::c_uint;
47pub type speed_t = ::c_uint;
48pub type tcflag_t = ::c_uint;
49pub type clockid_t = ::c_int;
50pub type key_t = ::c_int;
51pub type id_t = ::c_uint;
52pub type useconds_t = u32;
53pub type dev_t = u64;
54pub type socklen_t = u32;
55pub type pthread_t = c_ulong;
56pub type mode_t = u32;
57pub type ino64_t = u64;
58pub type off64_t = i64;
59pub type blkcnt64_t = i64;
60pub type rlim64_t = u64;
61pub type mqd_t = ::c_int;
62pub type nfds_t = ::c_ulong;
63pub type nl_item = ::c_int;
64pub type idtype_t = ::c_uint;
65pub type loff_t = ::c_longlong;
Taylor Cramerf7f9be32017-11-15 10:22:26 -080066
Taylor Cramerb4cfe882017-11-15 11:29:01 -080067pub type __u8 = ::c_uchar;
68pub type __u16 = ::c_ushort;
69pub type __s16 = ::c_short;
70pub type __u32 = ::c_uint;
71pub type __s32 = ::c_int;
72
73pub type Elf32_Half = u16;
74pub type Elf32_Word = u32;
75pub type Elf32_Off = u32;
76pub type Elf32_Addr = u32;
77
78pub type Elf64_Half = u16;
79pub type Elf64_Word = u32;
80pub type Elf64_Off = u64;
81pub type Elf64_Addr = u64;
82pub type Elf64_Xword = u64;
83
84pub type clock_t = c_long;
85pub type time_t = c_long;
86pub type suseconds_t = c_long;
87pub type ino_t = u64;
88pub type off_t = i64;
89pub type blkcnt_t = i64;
90
91pub type shmatt_t = ::c_ulong;
92pub type msgqnum_t = ::c_ulong;
93pub type msglen_t = ::c_ulong;
94pub type fsblkcnt_t = ::c_ulonglong;
95pub type fsfilcnt_t = ::c_ulonglong;
96pub type rlim_t = ::c_ulonglong;
97
98pub type c_long = i64;
99pub type c_ulong = u64;
100
101// FIXME: why are these uninhabited types? that seems... wrong?
102// Presumably these should be `()` or an `extern type` (when that stabilizes).
Bryant Mairsfa9cb782019-01-23 07:18:32 -0800103#[cfg_attr(feature = "extra_traits", derive(Debug))]
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800104pub enum timezone {}
Bryant Mairsf3684582019-01-23 07:23:09 -0800105impl ::dox::Copy for timezone {}
106impl ::dox::Clone for timezone {
107 fn clone(&self) -> timezone { *self }
108}
Bryant Mairsfa9cb782019-01-23 07:18:32 -0800109#[cfg_attr(feature = "extra_traits", derive(Debug))]
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800110pub enum DIR {}
Bryant Mairsf3684582019-01-23 07:23:09 -0800111impl ::dox::Copy for DIR {}
112impl ::dox::Clone for DIR {
113 fn clone(&self) -> DIR { *self }
114}
Bryant Mairsfa9cb782019-01-23 07:18:32 -0800115#[cfg_attr(feature = "extra_traits", derive(Debug))]
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800116pub enum locale_t {}
Bryant Mairsf3684582019-01-23 07:23:09 -0800117impl ::dox::Copy for locale_t {}
118impl ::dox::Clone for locale_t {
119 fn clone(&self) -> locale_t { *self }
120}
Bryant Mairsfa9cb782019-01-23 07:18:32 -0800121#[cfg_attr(feature = "extra_traits", derive(Debug))]
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800122pub enum fpos64_t {} // TODO: fill this out with a struct
Bryant Mairsf3684582019-01-23 07:23:09 -0800123impl ::dox::Copy for fpos64_t {}
124impl ::dox::Clone for fpos64_t {
125 fn clone(&self) -> fpos64_t { *self }
126}
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800127
128// PUB_STRUCT
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800129
130s! {
131 pub struct group {
132 pub gr_name: *mut ::c_char,
133 pub gr_passwd: *mut ::c_char,
134 pub gr_gid: ::gid_t,
135 pub gr_mem: *mut *mut ::c_char,
136 }
137
138 pub struct utimbuf {
139 pub actime: time_t,
140 pub modtime: time_t,
141 }
142
143 pub struct timeval {
144 pub tv_sec: time_t,
145 pub tv_usec: suseconds_t,
146 }
147
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800148 pub struct timespec {
149 pub tv_sec: time_t,
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800150 pub tv_nsec: ::c_long,
151 }
152
Taylor Cramer2f593702018-08-22 12:29:48 -0700153 // FIXME: the rlimit and rusage related functions and types don't exist
154 // within zircon. Are there reasons for keeping them around?
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800155 pub struct rlimit {
156 pub rlim_cur: rlim_t,
157 pub rlim_max: rlim_t,
158 }
159
160 pub struct rusage {
161 pub ru_utime: timeval,
162 pub ru_stime: timeval,
163 pub ru_maxrss: c_long,
164 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
165 __pad1: u32,
166 pub ru_ixrss: c_long,
167 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
168 __pad2: u32,
169 pub ru_idrss: c_long,
170 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
171 __pad3: u32,
172 pub ru_isrss: c_long,
173 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
174 __pad4: u32,
175 pub ru_minflt: c_long,
176 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
177 __pad5: u32,
178 pub ru_majflt: c_long,
179 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
180 __pad6: u32,
181 pub ru_nswap: c_long,
182 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
183 __pad7: u32,
184 pub ru_inblock: c_long,
185 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
186 __pad8: u32,
187 pub ru_oublock: c_long,
188 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
189 __pad9: u32,
190 pub ru_msgsnd: c_long,
191 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
192 __pad10: u32,
193 pub ru_msgrcv: c_long,
194 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
195 __pad11: u32,
196 pub ru_nsignals: c_long,
197 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
198 __pad12: u32,
199 pub ru_nvcsw: c_long,
200 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
201 __pad13: u32,
202 pub ru_nivcsw: c_long,
203 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
204 __pad14: u32,
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800205 }
206
207 pub struct in_addr {
208 pub s_addr: in_addr_t,
209 }
210
211 pub struct in6_addr {
Taylor Cramera0a4f8c2018-08-24 11:41:02 -0700212 pub s6_addr: [u8; 16],
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800213 }
214
215 pub struct ip_mreq {
216 pub imr_multiaddr: in_addr,
217 pub imr_interface: in_addr,
218 }
219
220 pub struct ipv6_mreq {
221 pub ipv6mr_multiaddr: in6_addr,
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800222 pub ipv6mr_interface: ::c_uint,
223 }
224
225 pub struct hostent {
226 pub h_name: *mut ::c_char,
227 pub h_aliases: *mut *mut ::c_char,
228 pub h_addrtype: ::c_int,
229 pub h_length: ::c_int,
230 pub h_addr_list: *mut *mut ::c_char,
231 }
232
233 pub struct iovec {
234 pub iov_base: *mut ::c_void,
235 pub iov_len: ::size_t,
236 }
237
238 pub struct pollfd {
239 pub fd: ::c_int,
240 pub events: ::c_short,
241 pub revents: ::c_short,
242 }
243
244 pub struct winsize {
245 pub ws_row: ::c_ushort,
246 pub ws_col: ::c_ushort,
247 pub ws_xpixel: ::c_ushort,
248 pub ws_ypixel: ::c_ushort,
249 }
250
251 pub struct linger {
252 pub l_onoff: ::c_int,
253 pub l_linger: ::c_int,
254 }
255
256 pub struct sigval {
257 // Actually a union of an int and a void*
258 pub sival_ptr: *mut ::c_void
259 }
260
261 // <sys/time.h>
262 pub struct itimerval {
263 pub it_interval: ::timeval,
264 pub it_value: ::timeval,
265 }
266
267 // <sys/times.h>
268 pub struct tms {
269 pub tms_utime: ::clock_t,
270 pub tms_stime: ::clock_t,
271 pub tms_cutime: ::clock_t,
272 pub tms_cstime: ::clock_t,
273 }
274
275 pub struct servent {
276 pub s_name: *mut ::c_char,
277 pub s_aliases: *mut *mut ::c_char,
278 pub s_port: ::c_int,
279 pub s_proto: *mut ::c_char,
280 }
281
282 pub struct protoent {
283 pub p_name: *mut ::c_char,
284 pub p_aliases: *mut *mut ::c_char,
285 pub p_proto: ::c_int,
286 }
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800287
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800288 pub struct aiocb {
289 pub aio_fildes: ::c_int,
290 pub aio_lio_opcode: ::c_int,
291 pub aio_reqprio: ::c_int,
292 pub aio_buf: *mut ::c_void,
293 pub aio_nbytes: ::size_t,
294 pub aio_sigevent: ::sigevent,
295 __td: *mut ::c_void,
296 __lock: [::c_int; 2],
297 __err: ::c_int,
298 __ret: ::ssize_t,
299 pub aio_offset: off_t,
300 __next: *mut ::c_void,
301 __prev: *mut ::c_void,
302 #[cfg(target_pointer_width = "32")]
303 __dummy4: [::c_char; 24],
304 #[cfg(target_pointer_width = "64")]
305 __dummy4: [::c_char; 16],
306 }
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800307
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800308 pub struct sigaction {
309 pub sa_sigaction: ::sighandler_t,
310 pub sa_mask: ::sigset_t,
311 pub sa_flags: ::c_int,
312 pub sa_restorer: ::dox::Option<extern fn()>,
313 }
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800314
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800315 pub struct termios {
316 pub c_iflag: ::tcflag_t,
317 pub c_oflag: ::tcflag_t,
318 pub c_cflag: ::tcflag_t,
319 pub c_lflag: ::tcflag_t,
320 pub c_line: ::cc_t,
321 pub c_cc: [::cc_t; ::NCCS],
322 pub __c_ispeed: ::speed_t,
323 pub __c_ospeed: ::speed_t,
324 }
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800325
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800326 pub struct flock {
327 pub l_type: ::c_short,
328 pub l_whence: ::c_short,
329 pub l_start: ::off_t,
330 pub l_len: ::off_t,
331 pub l_pid: ::pid_t,
332 }
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800333
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800334 pub struct ucred {
335 pub pid: ::pid_t,
336 pub uid: ::uid_t,
337 pub gid: ::gid_t,
338 }
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800339
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800340 pub struct sockaddr {
341 pub sa_family: sa_family_t,
342 pub sa_data: [::c_char; 14],
343 }
344
345 pub struct sockaddr_in {
346 pub sin_family: sa_family_t,
347 pub sin_port: ::in_port_t,
348 pub sin_addr: ::in_addr,
349 pub sin_zero: [u8; 8],
350 }
351
352 pub struct sockaddr_in6 {
353 pub sin6_family: sa_family_t,
354 pub sin6_port: ::in_port_t,
355 pub sin6_flowinfo: u32,
356 pub sin6_addr: ::in6_addr,
357 pub sin6_scope_id: u32,
358 }
359
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800360 pub struct addrinfo {
361 pub ai_flags: ::c_int,
362 pub ai_family: ::c_int,
363 pub ai_socktype: ::c_int,
364 pub ai_protocol: ::c_int,
365 pub ai_addrlen: socklen_t,
366
367 pub ai_addr: *mut ::sockaddr,
368
369 pub ai_canonname: *mut c_char,
370
371 pub ai_next: *mut addrinfo,
372 }
373
374 pub struct sockaddr_nl {
375 pub nl_family: ::sa_family_t,
376 nl_pad: ::c_ushort,
377 pub nl_pid: u32,
378 pub nl_groups: u32
379 }
380
381 pub struct sockaddr_ll {
382 pub sll_family: ::c_ushort,
383 pub sll_protocol: ::c_ushort,
384 pub sll_ifindex: ::c_int,
385 pub sll_hatype: ::c_ushort,
386 pub sll_pkttype: ::c_uchar,
387 pub sll_halen: ::c_uchar,
388 pub sll_addr: [::c_uchar; 8]
389 }
390
391 pub struct fd_set {
392 fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
393 }
394
395 pub struct tm {
396 pub tm_sec: ::c_int,
397 pub tm_min: ::c_int,
398 pub tm_hour: ::c_int,
399 pub tm_mday: ::c_int,
400 pub tm_mon: ::c_int,
401 pub tm_year: ::c_int,
402 pub tm_wday: ::c_int,
403 pub tm_yday: ::c_int,
404 pub tm_isdst: ::c_int,
405 pub tm_gmtoff: ::c_long,
406 pub tm_zone: *const ::c_char,
407 }
408
409 pub struct sched_param {
410 pub sched_priority: ::c_int,
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800411 pub sched_ss_low_priority: ::c_int,
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800412 pub sched_ss_repl_period: ::timespec,
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800413 pub sched_ss_init_budget: ::timespec,
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800414 pub sched_ss_max_repl: ::c_int,
415 }
416
417 pub struct Dl_info {
418 pub dli_fname: *const ::c_char,
419 pub dli_fbase: *mut ::c_void,
420 pub dli_sname: *const ::c_char,
421 pub dli_saddr: *mut ::c_void,
422 }
423
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800424 pub struct epoll_event {
425 pub events: ::uint32_t,
426 pub u64: ::uint64_t,
427 }
428
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800429 pub struct lconv {
430 pub decimal_point: *mut ::c_char,
431 pub thousands_sep: *mut ::c_char,
432 pub grouping: *mut ::c_char,
433 pub int_curr_symbol: *mut ::c_char,
434 pub currency_symbol: *mut ::c_char,
435 pub mon_decimal_point: *mut ::c_char,
436 pub mon_thousands_sep: *mut ::c_char,
437 pub mon_grouping: *mut ::c_char,
438 pub positive_sign: *mut ::c_char,
439 pub negative_sign: *mut ::c_char,
440 pub int_frac_digits: ::c_char,
441 pub frac_digits: ::c_char,
442 pub p_cs_precedes: ::c_char,
443 pub p_sep_by_space: ::c_char,
444 pub n_cs_precedes: ::c_char,
445 pub n_sep_by_space: ::c_char,
446 pub p_sign_posn: ::c_char,
447 pub n_sign_posn: ::c_char,
448 pub int_p_cs_precedes: ::c_char,
449 pub int_p_sep_by_space: ::c_char,
450 pub int_n_cs_precedes: ::c_char,
451 pub int_n_sep_by_space: ::c_char,
452 pub int_p_sign_posn: ::c_char,
453 pub int_n_sign_posn: ::c_char,
454 }
455
456 pub struct sigevent {
457 pub sigev_value: ::sigval,
458 pub sigev_signo: ::c_int,
459 pub sigev_notify: ::c_int,
Taylor Cramer2f593702018-08-22 12:29:48 -0700460 pub sigev_notify_function: fn(::sigval),
461 pub sigev_notify_attributes: *mut pthread_attr_t,
462 pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */],
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800463 }
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800464
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800465 pub struct rlimit64 {
466 pub rlim_cur: rlim64_t,
467 pub rlim_max: rlim64_t,
468 }
469
470 pub struct glob_t {
471 pub gl_pathc: ::size_t,
472 pub gl_pathv: *mut *mut c_char,
473 pub gl_offs: ::size_t,
474 pub gl_flags: ::c_int,
475
476 __unused1: *mut ::c_void,
477 __unused2: *mut ::c_void,
478 __unused3: *mut ::c_void,
479 __unused4: *mut ::c_void,
480 __unused5: *mut ::c_void,
481 }
482
483 pub struct ifaddrs {
484 pub ifa_next: *mut ifaddrs,
485 pub ifa_name: *mut c_char,
486 pub ifa_flags: ::c_uint,
487 pub ifa_addr: *mut ::sockaddr,
488 pub ifa_netmask: *mut ::sockaddr,
489 pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union
490 pub ifa_data: *mut ::c_void
491 }
492
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800493 pub struct passwd {
494 pub pw_name: *mut ::c_char,
495 pub pw_passwd: *mut ::c_char,
496 pub pw_uid: ::uid_t,
497 pub pw_gid: ::gid_t,
498 pub pw_gecos: *mut ::c_char,
499 pub pw_dir: *mut ::c_char,
500 pub pw_shell: *mut ::c_char,
501 }
502
503 pub struct spwd {
504 pub sp_namp: *mut ::c_char,
505 pub sp_pwdp: *mut ::c_char,
506 pub sp_lstchg: ::c_long,
507 pub sp_min: ::c_long,
508 pub sp_max: ::c_long,
509 pub sp_warn: ::c_long,
510 pub sp_inact: ::c_long,
511 pub sp_expire: ::c_long,
512 pub sp_flag: ::c_ulong,
513 }
514
515 pub struct statvfs {
516 pub f_bsize: ::c_ulong,
517 pub f_frsize: ::c_ulong,
518 pub f_blocks: ::fsblkcnt_t,
519 pub f_bfree: ::fsblkcnt_t,
520 pub f_bavail: ::fsblkcnt_t,
521 pub f_files: ::fsfilcnt_t,
522 pub f_ffree: ::fsfilcnt_t,
523 pub f_favail: ::fsfilcnt_t,
524 #[cfg(target_endian = "little")]
525 pub f_fsid: ::c_ulong,
526 #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))]
527 __f_unused: ::c_int,
528 #[cfg(target_endian = "big")]
529 pub f_fsid: ::c_ulong,
530 pub f_flag: ::c_ulong,
531 pub f_namemax: ::c_ulong,
532 __f_spare: [::c_int; 6],
533 }
534
535 pub struct dqblk {
536 pub dqb_bhardlimit: ::uint64_t,
537 pub dqb_bsoftlimit: ::uint64_t,
538 pub dqb_curspace: ::uint64_t,
539 pub dqb_ihardlimit: ::uint64_t,
540 pub dqb_isoftlimit: ::uint64_t,
541 pub dqb_curinodes: ::uint64_t,
542 pub dqb_btime: ::uint64_t,
543 pub dqb_itime: ::uint64_t,
544 pub dqb_valid: ::uint32_t,
545 }
546
547 pub struct signalfd_siginfo {
548 pub ssi_signo: ::uint32_t,
549 pub ssi_errno: ::int32_t,
550 pub ssi_code: ::int32_t,
551 pub ssi_pid: ::uint32_t,
552 pub ssi_uid: ::uint32_t,
553 pub ssi_fd: ::int32_t,
554 pub ssi_tid: ::uint32_t,
555 pub ssi_band: ::uint32_t,
556 pub ssi_overrun: ::uint32_t,
557 pub ssi_trapno: ::uint32_t,
558 pub ssi_status: ::int32_t,
559 pub ssi_int: ::int32_t,
560 pub ssi_ptr: ::uint64_t,
561 pub ssi_utime: ::uint64_t,
562 pub ssi_stime: ::uint64_t,
563 pub ssi_addr: ::uint64_t,
Stephen Barber60ab3042018-11-05 16:02:26 -0800564 pub ssi_addr_lsb: ::uint16_t,
565 _pad2: ::uint16_t,
566 pub ssi_syscall: ::int32_t,
567 pub ssi_call_addr: ::uint64_t,
568 pub ssi_arch: ::uint32_t,
569 _pad: [::uint8_t; 28],
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800570 }
571
572 pub struct itimerspec {
573 pub it_interval: ::timespec,
574 pub it_value: ::timespec,
575 }
576
577 pub struct fsid_t {
578 __val: [::c_int; 2],
579 }
580
581 // x32 compatibility
582 // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279
583 pub struct mq_attr {
584 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
585 pub mq_flags: i64,
586 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
587 pub mq_maxmsg: i64,
588 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
589 pub mq_msgsize: i64,
590 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
591 pub mq_curmsgs: i64,
592 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
593 pad: [i64; 4],
594
595 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
596 pub mq_flags: ::c_long,
597 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
598 pub mq_maxmsg: ::c_long,
599 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
600 pub mq_msgsize: ::c_long,
601 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
602 pub mq_curmsgs: ::c_long,
603 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
604 pad: [::c_long; 4],
605 }
606
607 pub struct cpu_set_t {
608 #[cfg(all(target_pointer_width = "32",
609 not(target_arch = "x86_64")))]
610 bits: [u32; 32],
611 #[cfg(not(all(target_pointer_width = "32",
612 not(target_arch = "x86_64"))))]
613 bits: [u64; 16],
614 }
615
616 pub struct if_nameindex {
617 pub if_index: ::c_uint,
618 pub if_name: *mut ::c_char,
619 }
620
621 // System V IPC
622 pub struct msginfo {
623 pub msgpool: ::c_int,
624 pub msgmap: ::c_int,
625 pub msgmax: ::c_int,
626 pub msgmnb: ::c_int,
627 pub msgmni: ::c_int,
628 pub msgssz: ::c_int,
629 pub msgtql: ::c_int,
630 pub msgseg: ::c_ushort,
631 }
632
633 pub struct mmsghdr {
634 pub msg_hdr: ::msghdr,
635 pub msg_len: ::c_uint,
636 }
637
638 pub struct sembuf {
639 pub sem_num: ::c_ushort,
640 pub sem_op: ::c_short,
641 pub sem_flg: ::c_short,
642 }
643
644 pub struct input_event {
645 pub time: ::timeval,
646 pub type_: ::__u16,
647 pub code: ::__u16,
648 pub value: ::__s32,
649 }
650
651 pub struct input_id {
652 pub bustype: ::__u16,
653 pub vendor: ::__u16,
654 pub product: ::__u16,
655 pub version: ::__u16,
656 }
657
658 pub struct input_absinfo {
659 pub value: ::__s32,
660 pub minimum: ::__s32,
661 pub maximum: ::__s32,
662 pub fuzz: ::__s32,
663 pub flat: ::__s32,
664 pub resolution: ::__s32,
665 }
666
667 pub struct input_keymap_entry {
668 pub flags: ::__u8,
669 pub len: ::__u8,
670 pub index: ::__u16,
671 pub keycode: ::__u32,
672 pub scancode: [::__u8; 32],
673 }
674
675 pub struct input_mask {
676 pub type_: ::__u32,
677 pub codes_size: ::__u32,
678 pub codes_ptr: ::__u64,
679 }
680
681 pub struct ff_replay {
682 pub length: ::__u16,
683 pub delay: ::__u16,
684 }
685
686 pub struct ff_trigger {
687 pub button: ::__u16,
688 pub interval: ::__u16,
689 }
690
691 pub struct ff_envelope {
692 pub attack_length: ::__u16,
693 pub attack_level: ::__u16,
694 pub fade_length: ::__u16,
695 pub fade_level: ::__u16,
696 }
697
698 pub struct ff_constant_effect {
699 pub level: ::__s16,
700 pub envelope: ff_envelope,
701 }
702
703 pub struct ff_ramp_effect {
704 pub start_level: ::__s16,
705 pub end_level: ::__s16,
706 pub envelope: ff_envelope,
707 }
708
709 pub struct ff_condition_effect {
710 pub right_saturation: ::__u16,
711 pub left_saturation: ::__u16,
712
713 pub right_coeff: ::__s16,
714 pub left_coeff: ::__s16,
715
716 pub deadband: ::__u16,
717 pub center: ::__s16,
718 }
719
720 pub struct ff_periodic_effect {
721 pub waveform: ::__u16,
722 pub period: ::__u16,
723 pub magnitude: ::__s16,
724 pub offset: ::__s16,
725 pub phase: ::__u16,
726
727 pub envelope: ff_envelope,
728
729 pub custom_len: ::__u32,
730 pub custom_data: *mut ::__s16,
731 }
732
733 pub struct ff_rumble_effect {
734 pub strong_magnitude: ::__u16,
735 pub weak_magnitude: ::__u16,
736 }
737
738 pub struct ff_effect {
739 pub type_: ::__u16,
740 pub id: ::__s16,
741 pub direction: ::__u16,
742 pub trigger: ff_trigger,
743 pub replay: ff_replay,
744 // FIXME this is actually a union
745 #[cfg(target_pointer_width = "64")]
746 pub u: [u64; 4],
747 #[cfg(target_pointer_width = "32")]
748 pub u: [u32; 7],
749 }
750
751 pub struct dl_phdr_info {
752 #[cfg(target_pointer_width = "64")]
753 pub dlpi_addr: Elf64_Addr,
754 #[cfg(target_pointer_width = "32")]
755 pub dlpi_addr: Elf32_Addr,
756
757 pub dlpi_name: *const ::c_char,
758
759 #[cfg(target_pointer_width = "64")]
760 pub dlpi_phdr: *const Elf64_Phdr,
761 #[cfg(target_pointer_width = "32")]
762 pub dlpi_phdr: *const Elf32_Phdr,
763
764 #[cfg(target_pointer_width = "64")]
765 pub dlpi_phnum: Elf64_Half,
766 #[cfg(target_pointer_width = "32")]
767 pub dlpi_phnum: Elf32_Half,
768
769 pub dlpi_adds: ::c_ulonglong,
770 pub dlpi_subs: ::c_ulonglong,
771 pub dlpi_tls_modid: ::size_t,
772 pub dlpi_tls_data: *mut ::c_void,
773 }
774
775 pub struct Elf32_Phdr {
776 pub p_type: Elf32_Word,
777 pub p_offset: Elf32_Off,
778 pub p_vaddr: Elf32_Addr,
779 pub p_paddr: Elf32_Addr,
780 pub p_filesz: Elf32_Word,
781 pub p_memsz: Elf32_Word,
782 pub p_flags: Elf32_Word,
783 pub p_align: Elf32_Word,
784 }
785
786 pub struct Elf64_Phdr {
787 pub p_type: Elf64_Word,
788 pub p_flags: Elf64_Word,
789 pub p_offset: Elf64_Off,
790 pub p_vaddr: Elf64_Addr,
791 pub p_paddr: Elf64_Addr,
792 pub p_filesz: Elf64_Xword,
793 pub p_memsz: Elf64_Xword,
794 pub p_align: Elf64_Xword,
795 }
796
797 pub struct statfs64 {
798 pub f_type: ::c_ulong,
799 pub f_bsize: ::c_ulong,
800 pub f_blocks: ::fsblkcnt_t,
801 pub f_bfree: ::fsblkcnt_t,
802 pub f_bavail: ::fsblkcnt_t,
803 pub f_files: ::fsfilcnt_t,
804 pub f_ffree: ::fsfilcnt_t,
805 pub f_fsid: ::fsid_t,
806 pub f_namelen: ::c_ulong,
807 pub f_frsize: ::c_ulong,
808 pub f_flags: ::c_ulong,
809 pub f_spare: [::c_ulong; 4],
810 }
811
812 pub struct statvfs64 {
813 pub f_bsize: ::c_ulong,
814 pub f_frsize: ::c_ulong,
815 pub f_blocks: u64,
816 pub f_bfree: u64,
817 pub f_bavail: u64,
818 pub f_files: u64,
819 pub f_ffree: u64,
820 pub f_favail: u64,
821 pub f_fsid: ::c_ulong,
822 pub f_flag: ::c_ulong,
823 pub f_namemax: ::c_ulong,
824 __f_spare: [::c_int; 6],
825 }
826
827 pub struct stack_t {
828 pub ss_sp: *mut ::c_void,
829 pub ss_flags: ::c_int,
830 pub ss_size: ::size_t
831 }
832
833 pub struct pthread_attr_t {
834 __size: [u64; 7]
835 }
836
837 pub struct sigset_t {
838 __val: [::c_ulong; 16],
839 }
840
841 pub struct shmid_ds {
842 pub shm_perm: ::ipc_perm,
843 pub shm_segsz: ::size_t,
844 pub shm_atime: ::time_t,
845 pub shm_dtime: ::time_t,
846 pub shm_ctime: ::time_t,
847 pub shm_cpid: ::pid_t,
848 pub shm_lpid: ::pid_t,
849 pub shm_nattch: ::c_ulong,
850 __pad1: ::c_ulong,
851 __pad2: ::c_ulong,
852 }
853
854 pub struct msqid_ds {
855 pub msg_perm: ::ipc_perm,
856 pub msg_stime: ::time_t,
857 pub msg_rtime: ::time_t,
858 pub msg_ctime: ::time_t,
859 __msg_cbytes: ::c_ulong,
860 pub msg_qnum: ::msgqnum_t,
861 pub msg_qbytes: ::msglen_t,
862 pub msg_lspid: ::pid_t,
863 pub msg_lrpid: ::pid_t,
864 __pad1: ::c_ulong,
865 __pad2: ::c_ulong,
866 }
867
868 pub struct statfs {
869 pub f_type: ::c_ulong,
870 pub f_bsize: ::c_ulong,
871 pub f_blocks: ::fsblkcnt_t,
872 pub f_bfree: ::fsblkcnt_t,
873 pub f_bavail: ::fsblkcnt_t,
874 pub f_files: ::fsfilcnt_t,
875 pub f_ffree: ::fsfilcnt_t,
876 pub f_fsid: ::fsid_t,
877 pub f_namelen: ::c_ulong,
878 pub f_frsize: ::c_ulong,
879 pub f_flags: ::c_ulong,
880 pub f_spare: [::c_ulong; 4],
881 }
882
883 pub struct msghdr {
884 pub msg_name: *mut ::c_void,
885 pub msg_namelen: ::socklen_t,
886 pub msg_iov: *mut ::iovec,
887 pub msg_iovlen: ::c_int,
888 __pad1: ::c_int,
889 pub msg_control: *mut ::c_void,
890 pub msg_controllen: ::socklen_t,
891 __pad2: ::socklen_t,
892 pub msg_flags: ::c_int,
893 }
894
895 pub struct cmsghdr {
896 pub cmsg_len: ::socklen_t,
897 pub __pad1: ::c_int,
898 pub cmsg_level: ::c_int,
899 pub cmsg_type: ::c_int,
900 }
901
902 pub struct sem_t {
903 __val: [::c_int; 8],
904 }
905
906 pub struct siginfo_t {
907 pub si_signo: ::c_int,
908 pub si_errno: ::c_int,
909 pub si_code: ::c_int,
910 pub _pad: [::c_int; 29],
911 _align: [usize; 0],
912 }
913
914 pub struct termios2 {
915 pub c_iflag: ::tcflag_t,
916 pub c_oflag: ::tcflag_t,
917 pub c_cflag: ::tcflag_t,
918 pub c_lflag: ::tcflag_t,
919 pub c_line: ::cc_t,
920 pub c_cc: [::cc_t; 19],
921 pub c_ispeed: ::speed_t,
922 pub c_ospeed: ::speed_t,
Taylor Cramerf7f9be32017-11-15 10:22:26 -0800923 }
924}
925
gnzlbga17a91c2019-02-07 11:37:21 +0100926s_no_extra_traits! {
927 #[allow(missing_debug_implementations)]
928 pub struct sysinfo {
929 pub uptime: ::c_ulong,
930 pub loads: [::c_ulong; 3],
931 pub totalram: ::c_ulong,
932 pub freeram: ::c_ulong,
933 pub sharedram: ::c_ulong,
934 pub bufferram: ::c_ulong,
935 pub totalswap: ::c_ulong,
936 pub freeswap: ::c_ulong,
937 pub procs: ::c_ushort,
938 pub pad: ::c_ushort,
939 pub totalhigh: ::c_ulong,
940 pub freehigh: ::c_ulong,
941 pub mem_unit: ::c_uint,
942 pub __reserved: [::c_char; 256],
943 }
944
945 #[allow(missing_debug_implementations)]
946 pub struct sockaddr_un {
947 pub sun_family: sa_family_t,
948 pub sun_path: [::c_char; 108]
949 }
950
951 #[allow(missing_debug_implementations)]
952 pub struct sockaddr_storage {
953 pub ss_family: sa_family_t,
954 __ss_align: ::size_t,
955 __ss_pad2: [u8; 128 - 2 * 8],
956 }
957
958 #[allow(missing_debug_implementations)]
959 pub struct utsname {
960 pub sysname: [::c_char; 65],
961 pub nodename: [::c_char; 65],
962 pub release: [::c_char; 65],
963 pub version: [::c_char; 65],
964 pub machine: [::c_char; 65],
965 pub domainname: [::c_char; 65]
966 }
967
968 #[allow(missing_debug_implementations)]
969 pub struct dirent {
970 pub d_ino: ::ino_t,
971 pub d_off: ::off_t,
972 pub d_reclen: ::c_ushort,
973 pub d_type: ::c_uchar,
974 pub d_name: [::c_char; 256],
975 }
976
977 #[allow(missing_debug_implementations)]
978 pub struct dirent64 {
979 pub d_ino: ::ino64_t,
980 pub d_off: ::off64_t,
981 pub d_reclen: ::c_ushort,
982 pub d_type: ::c_uchar,
983 pub d_name: [::c_char; 256],
984 }
985}
986
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800987// PUB_CONST
988
gnzlbg5c1a6b82018-11-21 20:34:50 +0100989pub const INT_MIN: c_int = -2147483648;
990pub const INT_MAX: c_int = 2147483647;
991
Taylor Cramerb4cfe882017-11-15 11:29:01 -0800992pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
993pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
994pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
995
996pub const DT_FIFO: u8 = 1;
997pub const DT_CHR: u8 = 2;
998pub const DT_DIR: u8 = 4;
999pub const DT_BLK: u8 = 6;
1000pub const DT_REG: u8 = 8;
1001pub const DT_LNK: u8 = 10;
1002pub const DT_SOCK: u8 = 12;
1003
1004pub const FD_CLOEXEC: ::c_int = 0x1;
1005
1006pub const USRQUOTA: ::c_int = 0;
1007pub const GRPQUOTA: ::c_int = 1;
1008
1009pub const SIGIOT: ::c_int = 6;
1010
1011pub const S_ISUID: ::c_int = 0x800;
1012pub const S_ISGID: ::c_int = 0x400;
1013pub const S_ISVTX: ::c_int = 0x200;
1014
1015pub const IF_NAMESIZE: ::size_t = 16;
1016
1017pub const LOG_EMERG: ::c_int = 0;
1018pub const LOG_ALERT: ::c_int = 1;
1019pub const LOG_CRIT: ::c_int = 2;
1020pub const LOG_ERR: ::c_int = 3;
1021pub const LOG_WARNING: ::c_int = 4;
1022pub const LOG_NOTICE: ::c_int = 5;
1023pub const LOG_INFO: ::c_int = 6;
1024pub const LOG_DEBUG: ::c_int = 7;
1025
1026pub const LOG_KERN: ::c_int = 0;
1027pub const LOG_USER: ::c_int = 1 << 3;
1028pub const LOG_MAIL: ::c_int = 2 << 3;
1029pub const LOG_DAEMON: ::c_int = 3 << 3;
1030pub const LOG_AUTH: ::c_int = 4 << 3;
1031pub const LOG_SYSLOG: ::c_int = 5 << 3;
1032pub const LOG_LPR: ::c_int = 6 << 3;
1033pub const LOG_NEWS: ::c_int = 7 << 3;
1034pub const LOG_UUCP: ::c_int = 8 << 3;
1035pub const LOG_LOCAL0: ::c_int = 16 << 3;
1036pub const LOG_LOCAL1: ::c_int = 17 << 3;
1037pub const LOG_LOCAL2: ::c_int = 18 << 3;
1038pub const LOG_LOCAL3: ::c_int = 19 << 3;
1039pub const LOG_LOCAL4: ::c_int = 20 << 3;
1040pub const LOG_LOCAL5: ::c_int = 21 << 3;
1041pub const LOG_LOCAL6: ::c_int = 22 << 3;
1042pub const LOG_LOCAL7: ::c_int = 23 << 3;
1043
1044pub const LOG_PID: ::c_int = 0x01;
1045pub const LOG_CONS: ::c_int = 0x02;
1046pub const LOG_ODELAY: ::c_int = 0x04;
1047pub const LOG_NDELAY: ::c_int = 0x08;
1048pub const LOG_NOWAIT: ::c_int = 0x10;
1049
1050pub const LOG_PRIMASK: ::c_int = 7;
1051pub const LOG_FACMASK: ::c_int = 0x3f8;
1052
1053pub const PRIO_PROCESS: ::c_int = 0;
1054pub const PRIO_PGRP: ::c_int = 1;
1055pub const PRIO_USER: ::c_int = 2;
1056
1057pub const PRIO_MIN: ::c_int = -20;
1058pub const PRIO_MAX: ::c_int = 20;
1059
1060pub const IPPROTO_ICMP: ::c_int = 1;
1061pub const IPPROTO_ICMPV6: ::c_int = 58;
1062pub const IPPROTO_TCP: ::c_int = 6;
1063pub const IPPROTO_UDP: ::c_int = 17;
1064pub const IPPROTO_IP: ::c_int = 0;
1065pub const IPPROTO_IPV6: ::c_int = 41;
1066
1067pub const INADDR_LOOPBACK: in_addr_t = 2130706433;
1068pub const INADDR_ANY: in_addr_t = 0;
1069pub const INADDR_BROADCAST: in_addr_t = 4294967295;
1070pub const INADDR_NONE: in_addr_t = 4294967295;
1071
Taylor Cramerf7f9be32017-11-15 10:22:26 -08001072pub const EXIT_FAILURE: ::c_int = 1;
1073pub const EXIT_SUCCESS: ::c_int = 0;
1074pub const RAND_MAX: ::c_int = 2147483647;
1075pub const EOF: ::c_int = -1;
1076pub const SEEK_SET: ::c_int = 0;
1077pub const SEEK_CUR: ::c_int = 1;
1078pub const SEEK_END: ::c_int = 2;
1079pub const _IOFBF: ::c_int = 0;
1080pub const _IONBF: ::c_int = 2;
1081pub const _IOLBF: ::c_int = 1;
1082
1083pub const F_DUPFD: ::c_int = 0;
1084pub const F_GETFD: ::c_int = 1;
1085pub const F_SETFD: ::c_int = 2;
1086pub const F_GETFL: ::c_int = 3;
1087pub const F_SETFL: ::c_int = 4;
1088
1089// Linux-specific fcntls
1090pub const F_SETLEASE: ::c_int = 1024;
1091pub const F_GETLEASE: ::c_int = 1025;
1092pub const F_NOTIFY: ::c_int = 1026;
1093pub const F_CANCELLK: ::c_int = 1029;
1094pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
1095pub const F_SETPIPE_SZ: ::c_int = 1031;
1096pub const F_GETPIPE_SZ: ::c_int = 1032;
1097pub const F_ADD_SEALS: ::c_int = 1033;
1098pub const F_GET_SEALS: ::c_int = 1034;
1099
1100pub const F_SEAL_SEAL: ::c_int = 0x0001;
1101pub const F_SEAL_SHRINK: ::c_int = 0x0002;
1102pub const F_SEAL_GROW: ::c_int = 0x0004;
1103pub const F_SEAL_WRITE: ::c_int = 0x0008;
1104
1105// TODO(#235): Include file sealing fcntls once we have a way to verify them.
1106
1107pub const SIGTRAP: ::c_int = 5;
1108
1109pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
1110pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
1111
1112pub const CLOCK_REALTIME: ::clockid_t = 0;
1113pub const CLOCK_MONOTONIC: ::clockid_t = 1;
1114pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2;
1115pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3;
1116pub const CLOCK_MONOTONIC_RAW: ::clockid_t = 4;
1117pub const CLOCK_REALTIME_COARSE: ::clockid_t = 5;
1118pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = 6;
1119pub const CLOCK_BOOTTIME: ::clockid_t = 7;
1120pub const CLOCK_REALTIME_ALARM: ::clockid_t = 8;
1121pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9;
1122// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep
1123// 2014.) See also musl/mod.rs
1124// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
1125// pub const CLOCK_TAI: ::clockid_t = 11;
1126pub const TIMER_ABSTIME: ::c_int = 1;
1127
1128pub const RLIMIT_CPU: ::c_int = 0;
1129pub const RLIMIT_FSIZE: ::c_int = 1;
1130pub const RLIMIT_DATA: ::c_int = 2;
1131pub const RLIMIT_STACK: ::c_int = 3;
1132pub const RLIMIT_CORE: ::c_int = 4;
1133pub const RLIMIT_LOCKS: ::c_int = 10;
1134pub const RLIMIT_SIGPENDING: ::c_int = 11;
1135pub const RLIMIT_MSGQUEUE: ::c_int = 12;
1136pub const RLIMIT_NICE: ::c_int = 13;
1137pub const RLIMIT_RTPRIO: ::c_int = 14;
1138
1139pub const RUSAGE_SELF: ::c_int = 0;
1140
1141pub const O_RDONLY: ::c_int = 0;
1142pub const O_WRONLY: ::c_int = 1;
1143pub const O_RDWR: ::c_int = 2;
1144
1145pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
1146
1147pub const S_IFIFO: ::mode_t = 4096;
1148pub const S_IFCHR: ::mode_t = 8192;
1149pub const S_IFBLK: ::mode_t = 24576;
1150pub const S_IFDIR: ::mode_t = 16384;
1151pub const S_IFREG: ::mode_t = 32768;
1152pub const S_IFLNK: ::mode_t = 40960;
1153pub const S_IFSOCK: ::mode_t = 49152;
1154pub const S_IFMT: ::mode_t = 61440;
1155pub const S_IRWXU: ::mode_t = 448;
1156pub const S_IXUSR: ::mode_t = 64;
1157pub const S_IWUSR: ::mode_t = 128;
1158pub const S_IRUSR: ::mode_t = 256;
1159pub const S_IRWXG: ::mode_t = 56;
1160pub const S_IXGRP: ::mode_t = 8;
1161pub const S_IWGRP: ::mode_t = 16;
1162pub const S_IRGRP: ::mode_t = 32;
1163pub const S_IRWXO: ::mode_t = 7;
1164pub const S_IXOTH: ::mode_t = 1;
1165pub const S_IWOTH: ::mode_t = 2;
1166pub const S_IROTH: ::mode_t = 4;
1167pub const F_OK: ::c_int = 0;
1168pub const R_OK: ::c_int = 4;
1169pub const W_OK: ::c_int = 2;
1170pub const X_OK: ::c_int = 1;
1171pub const STDIN_FILENO: ::c_int = 0;
1172pub const STDOUT_FILENO: ::c_int = 1;
1173pub const STDERR_FILENO: ::c_int = 2;
1174pub const SIGHUP: ::c_int = 1;
1175pub const SIGINT: ::c_int = 2;
1176pub const SIGQUIT: ::c_int = 3;
1177pub const SIGILL: ::c_int = 4;
1178pub const SIGABRT: ::c_int = 6;
1179pub const SIGFPE: ::c_int = 8;
1180pub const SIGKILL: ::c_int = 9;
1181pub const SIGSEGV: ::c_int = 11;
1182pub const SIGPIPE: ::c_int = 13;
1183pub const SIGALRM: ::c_int = 14;
1184pub const SIGTERM: ::c_int = 15;
1185
1186pub const PROT_NONE: ::c_int = 0;
1187pub const PROT_READ: ::c_int = 1;
1188pub const PROT_WRITE: ::c_int = 2;
1189pub const PROT_EXEC: ::c_int = 4;
1190
1191pub const LC_CTYPE: ::c_int = 0;
1192pub const LC_NUMERIC: ::c_int = 1;
1193pub const LC_TIME: ::c_int = 2;
1194pub const LC_COLLATE: ::c_int = 3;
1195pub const LC_MONETARY: ::c_int = 4;
1196pub const LC_MESSAGES: ::c_int = 5;
1197pub const LC_ALL: ::c_int = 6;
1198pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE);
1199pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC);
1200pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME);
1201pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE);
1202pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY);
1203pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES);
1204// LC_ALL_MASK defined per platform
1205
1206pub const MAP_FILE: ::c_int = 0x0000;
1207pub const MAP_SHARED: ::c_int = 0x0001;
1208pub const MAP_PRIVATE: ::c_int = 0x0002;
1209pub const MAP_FIXED: ::c_int = 0x0010;
1210
1211pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
1212
1213// MS_ flags for msync(2)
1214pub const MS_ASYNC: ::c_int = 0x0001;
1215pub const MS_INVALIDATE: ::c_int = 0x0002;
1216pub const MS_SYNC: ::c_int = 0x0004;
1217
1218// MS_ flags for mount(2)
1219pub const MS_RDONLY: ::c_ulong = 0x01;
1220pub const MS_NOSUID: ::c_ulong = 0x02;
1221pub const MS_NODEV: ::c_ulong = 0x04;
1222pub const MS_NOEXEC: ::c_ulong = 0x08;
1223pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
1224pub const MS_REMOUNT: ::c_ulong = 0x20;
1225pub const MS_MANDLOCK: ::c_ulong = 0x40;
1226pub const MS_DIRSYNC: ::c_ulong = 0x80;
1227pub const MS_NOATIME: ::c_ulong = 0x0400;
1228pub const MS_NODIRATIME: ::c_ulong = 0x0800;
1229pub const MS_BIND: ::c_ulong = 0x1000;
1230pub const MS_MOVE: ::c_ulong = 0x2000;
1231pub const MS_REC: ::c_ulong = 0x4000;
1232pub const MS_SILENT: ::c_ulong = 0x8000;
1233pub const MS_POSIXACL: ::c_ulong = 0x010000;
1234pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
1235pub const MS_PRIVATE: ::c_ulong = 0x040000;
1236pub const MS_SLAVE: ::c_ulong = 0x080000;
1237pub const MS_SHARED: ::c_ulong = 0x100000;
1238pub const MS_RELATIME: ::c_ulong = 0x200000;
1239pub const MS_KERNMOUNT: ::c_ulong = 0x400000;
1240pub const MS_I_VERSION: ::c_ulong = 0x800000;
1241pub const MS_STRICTATIME: ::c_ulong = 0x1000000;
1242pub const MS_ACTIVE: ::c_ulong = 0x40000000;
1243pub const MS_NOUSER: ::c_ulong = 0x80000000;
1244pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
1245pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
1246pub const MS_RMT_MASK: ::c_ulong = 0x800051;
1247
1248pub const EPERM: ::c_int = 1;
1249pub const ENOENT: ::c_int = 2;
1250pub const ESRCH: ::c_int = 3;
1251pub const EINTR: ::c_int = 4;
1252pub const EIO: ::c_int = 5;
1253pub const ENXIO: ::c_int = 6;
1254pub const E2BIG: ::c_int = 7;
1255pub const ENOEXEC: ::c_int = 8;
1256pub const EBADF: ::c_int = 9;
1257pub const ECHILD: ::c_int = 10;
1258pub const EAGAIN: ::c_int = 11;
1259pub const ENOMEM: ::c_int = 12;
1260pub const EACCES: ::c_int = 13;
1261pub const EFAULT: ::c_int = 14;
1262pub const ENOTBLK: ::c_int = 15;
1263pub const EBUSY: ::c_int = 16;
1264pub const EEXIST: ::c_int = 17;
1265pub const EXDEV: ::c_int = 18;
1266pub const ENODEV: ::c_int = 19;
1267pub const ENOTDIR: ::c_int = 20;
1268pub const EISDIR: ::c_int = 21;
1269pub const EINVAL: ::c_int = 22;
1270pub const ENFILE: ::c_int = 23;
1271pub const EMFILE: ::c_int = 24;
1272pub const ENOTTY: ::c_int = 25;
1273pub const ETXTBSY: ::c_int = 26;
1274pub const EFBIG: ::c_int = 27;
1275pub const ENOSPC: ::c_int = 28;
1276pub const ESPIPE: ::c_int = 29;
1277pub const EROFS: ::c_int = 30;
1278pub const EMLINK: ::c_int = 31;
1279pub const EPIPE: ::c_int = 32;
1280pub const EDOM: ::c_int = 33;
1281pub const ERANGE: ::c_int = 34;
1282pub const EWOULDBLOCK: ::c_int = EAGAIN;
1283
1284pub const SCM_RIGHTS: ::c_int = 0x01;
1285pub const SCM_CREDENTIALS: ::c_int = 0x02;
1286
1287pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
1288pub const PROT_GROWSUP: ::c_int = 0x2000000;
1289
1290pub const MAP_TYPE: ::c_int = 0x000f;
1291
1292pub const MADV_NORMAL: ::c_int = 0;
1293pub const MADV_RANDOM: ::c_int = 1;
1294pub const MADV_SEQUENTIAL: ::c_int = 2;
1295pub const MADV_WILLNEED: ::c_int = 3;
1296pub const MADV_DONTNEED: ::c_int = 4;
1297pub const MADV_FREE: ::c_int = 8;
1298pub const MADV_REMOVE: ::c_int = 9;
1299pub const MADV_DONTFORK: ::c_int = 10;
1300pub const MADV_DOFORK: ::c_int = 11;
1301pub const MADV_MERGEABLE: ::c_int = 12;
1302pub const MADV_UNMERGEABLE: ::c_int = 13;
1303pub const MADV_HUGEPAGE: ::c_int = 14;
1304pub const MADV_NOHUGEPAGE: ::c_int = 15;
1305pub const MADV_DONTDUMP: ::c_int = 16;
1306pub const MADV_DODUMP: ::c_int = 17;
1307pub const MADV_HWPOISON: ::c_int = 100;
1308pub const MADV_SOFT_OFFLINE: ::c_int = 101;
1309
1310pub const IFF_UP: ::c_int = 0x1;
1311pub const IFF_BROADCAST: ::c_int = 0x2;
1312pub const IFF_DEBUG: ::c_int = 0x4;
1313pub const IFF_LOOPBACK: ::c_int = 0x8;
1314pub const IFF_POINTOPOINT: ::c_int = 0x10;
1315pub const IFF_NOTRAILERS: ::c_int = 0x20;
1316pub const IFF_RUNNING: ::c_int = 0x40;
1317pub const IFF_NOARP: ::c_int = 0x80;
1318pub const IFF_PROMISC: ::c_int = 0x100;
1319pub const IFF_ALLMULTI: ::c_int = 0x200;
1320pub const IFF_MASTER: ::c_int = 0x400;
1321pub const IFF_SLAVE: ::c_int = 0x800;
1322pub const IFF_MULTICAST: ::c_int = 0x1000;
1323pub const IFF_PORTSEL: ::c_int = 0x2000;
1324pub const IFF_AUTOMEDIA: ::c_int = 0x4000;
1325pub const IFF_DYNAMIC: ::c_int = 0x8000;
luozijun0f4ae0b2018-02-04 21:39:40 +08001326pub const IFF_TUN: ::c_int = 0x0001;
1327pub const IFF_TAP: ::c_int = 0x0002;
1328pub const IFF_NO_PI: ::c_int = 0x1000;
Taylor Cramerf7f9be32017-11-15 10:22:26 -08001329
1330pub const SOL_IP: ::c_int = 0;
1331pub const SOL_TCP: ::c_int = 6;
1332pub const SOL_UDP: ::c_int = 17;
1333pub const SOL_IPV6: ::c_int = 41;
1334pub const SOL_ICMPV6: ::c_int = 58;
1335pub const SOL_RAW: ::c_int = 255;
1336pub const SOL_DECNET: ::c_int = 261;
1337pub const SOL_X25: ::c_int = 262;
1338pub const SOL_PACKET: ::c_int = 263;
1339pub const SOL_ATM: ::c_int = 264;
1340pub const SOL_AAL: ::c_int = 265;
1341pub const SOL_IRDA: ::c_int = 266;
1342pub const SOL_NETBEUI: ::c_int = 267;
1343pub const SOL_LLC: ::c_int = 268;
1344pub const SOL_DCCP: ::c_int = 269;
1345pub const SOL_NETLINK: ::c_int = 270;
1346pub const SOL_TIPC: ::c_int = 271;
1347
1348pub const AF_UNSPEC: ::c_int = 0;
1349pub const AF_UNIX: ::c_int = 1;
1350pub const AF_LOCAL: ::c_int = 1;
1351pub const AF_INET: ::c_int = 2;
1352pub const AF_AX25: ::c_int = 3;
1353pub const AF_IPX: ::c_int = 4;
1354pub const AF_APPLETALK: ::c_int = 5;
1355pub const AF_NETROM: ::c_int = 6;
1356pub const AF_BRIDGE: ::c_int = 7;
1357pub const AF_ATMPVC: ::c_int = 8;
1358pub const AF_X25: ::c_int = 9;
1359pub const AF_INET6: ::c_int = 10;
1360pub const AF_ROSE: ::c_int = 11;
1361pub const AF_DECnet: ::c_int = 12;
1362pub const AF_NETBEUI: ::c_int = 13;
1363pub const AF_SECURITY: ::c_int = 14;
1364pub const AF_KEY: ::c_int = 15;
1365pub const AF_NETLINK: ::c_int = 16;
1366pub const AF_ROUTE: ::c_int = AF_NETLINK;
1367pub const AF_PACKET: ::c_int = 17;
1368pub const AF_ASH: ::c_int = 18;
1369pub const AF_ECONET: ::c_int = 19;
1370pub const AF_ATMSVC: ::c_int = 20;
1371pub const AF_RDS: ::c_int = 21;
1372pub const AF_SNA: ::c_int = 22;
1373pub const AF_IRDA: ::c_int = 23;
1374pub const AF_PPPOX: ::c_int = 24;
1375pub const AF_WANPIPE: ::c_int = 25;
1376pub const AF_LLC: ::c_int = 26;
1377pub const AF_CAN: ::c_int = 29;
1378pub const AF_TIPC: ::c_int = 30;
1379pub const AF_BLUETOOTH: ::c_int = 31;
1380pub const AF_IUCV: ::c_int = 32;
1381pub const AF_RXRPC: ::c_int = 33;
1382pub const AF_ISDN: ::c_int = 34;
1383pub const AF_PHONET: ::c_int = 35;
1384pub const AF_IEEE802154: ::c_int = 36;
1385pub const AF_CAIF: ::c_int = 37;
1386pub const AF_ALG: ::c_int = 38;
1387
1388pub const PF_UNSPEC: ::c_int = AF_UNSPEC;
1389pub const PF_UNIX: ::c_int = AF_UNIX;
1390pub const PF_LOCAL: ::c_int = AF_LOCAL;
1391pub const PF_INET: ::c_int = AF_INET;
1392pub const PF_AX25: ::c_int = AF_AX25;
1393pub const PF_IPX: ::c_int = AF_IPX;
1394pub const PF_APPLETALK: ::c_int = AF_APPLETALK;
1395pub const PF_NETROM: ::c_int = AF_NETROM;
1396pub const PF_BRIDGE: ::c_int = AF_BRIDGE;
1397pub const PF_ATMPVC: ::c_int = AF_ATMPVC;
1398pub const PF_X25: ::c_int = AF_X25;
1399pub const PF_INET6: ::c_int = AF_INET6;
1400pub const PF_ROSE: ::c_int = AF_ROSE;
1401pub const PF_DECnet: ::c_int = AF_DECnet;
1402pub const PF_NETBEUI: ::c_int = AF_NETBEUI;
1403pub const PF_SECURITY: ::c_int = AF_SECURITY;
1404pub const PF_KEY: ::c_int = AF_KEY;
1405pub const PF_NETLINK: ::c_int = AF_NETLINK;
1406pub const PF_ROUTE: ::c_int = AF_ROUTE;
1407pub const PF_PACKET: ::c_int = AF_PACKET;
1408pub const PF_ASH: ::c_int = AF_ASH;
1409pub const PF_ECONET: ::c_int = AF_ECONET;
1410pub const PF_ATMSVC: ::c_int = AF_ATMSVC;
1411pub const PF_RDS: ::c_int = AF_RDS;
1412pub const PF_SNA: ::c_int = AF_SNA;
1413pub const PF_IRDA: ::c_int = AF_IRDA;
1414pub const PF_PPPOX: ::c_int = AF_PPPOX;
1415pub const PF_WANPIPE: ::c_int = AF_WANPIPE;
1416pub const PF_LLC: ::c_int = AF_LLC;
1417pub const PF_CAN: ::c_int = AF_CAN;
1418pub const PF_TIPC: ::c_int = AF_TIPC;
1419pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
1420pub const PF_IUCV: ::c_int = AF_IUCV;
1421pub const PF_RXRPC: ::c_int = AF_RXRPC;
1422pub const PF_ISDN: ::c_int = AF_ISDN;
1423pub const PF_PHONET: ::c_int = AF_PHONET;
1424pub const PF_IEEE802154: ::c_int = AF_IEEE802154;
1425pub const PF_CAIF: ::c_int = AF_CAIF;
1426pub const PF_ALG: ::c_int = AF_ALG;
1427
1428pub const SOMAXCONN: ::c_int = 128;
1429
1430pub const MSG_OOB: ::c_int = 1;
1431pub const MSG_PEEK: ::c_int = 2;
1432pub const MSG_DONTROUTE: ::c_int = 4;
1433pub const MSG_CTRUNC: ::c_int = 8;
1434pub const MSG_TRUNC: ::c_int = 0x20;
1435pub const MSG_DONTWAIT: ::c_int = 0x40;
1436pub const MSG_EOR: ::c_int = 0x80;
1437pub const MSG_WAITALL: ::c_int = 0x100;
1438pub const MSG_FIN: ::c_int = 0x200;
1439pub const MSG_SYN: ::c_int = 0x400;
1440pub const MSG_CONFIRM: ::c_int = 0x800;
1441pub const MSG_RST: ::c_int = 0x1000;
1442pub const MSG_ERRQUEUE: ::c_int = 0x2000;
1443pub const MSG_NOSIGNAL: ::c_int = 0x4000;
1444pub const MSG_MORE: ::c_int = 0x8000;
1445pub const MSG_WAITFORONE: ::c_int = 0x10000;
1446pub const MSG_FASTOPEN: ::c_int = 0x20000000;
1447pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000;
1448
1449pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
1450
1451pub const SOCK_RAW: ::c_int = 3;
1452pub const SOCK_RDM: ::c_int = 4;
1453pub const IP_MULTICAST_IF: ::c_int = 32;
1454pub const IP_MULTICAST_TTL: ::c_int = 33;
1455pub const IP_MULTICAST_LOOP: ::c_int = 34;
1456pub const IP_TTL: ::c_int = 2;
1457pub const IP_HDRINCL: ::c_int = 3;
1458pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
1459pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
1460pub const IP_TRANSPARENT: ::c_int = 19;
Raph Levien709709d2018-02-28 15:41:50 -08001461pub const IPV6_UNICAST_HOPS: ::c_int = 16;
Benjamin Fry7ed55992018-02-25 10:58:44 -08001462pub const IPV6_MULTICAST_IF: ::c_int = 17;
1463pub const IPV6_MULTICAST_HOPS: ::c_int = 18;
1464pub const IPV6_MULTICAST_LOOP: ::c_int = 19;
Taylor Cramerf7f9be32017-11-15 10:22:26 -08001465pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
1466pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
Benjamin Fry7ed55992018-02-25 10:58:44 -08001467pub const IPV6_V6ONLY: ::c_int = 26;
Taylor Cramerf7f9be32017-11-15 10:22:26 -08001468
1469pub const TCP_NODELAY: ::c_int = 1;
1470pub const TCP_MAXSEG: ::c_int = 2;
1471pub const TCP_CORK: ::c_int = 3;
1472pub const TCP_KEEPIDLE: ::c_int = 4;
1473pub const TCP_KEEPINTVL: ::c_int = 5;
1474pub const TCP_KEEPCNT: ::c_int = 6;
1475pub const TCP_SYNCNT: ::c_int = 7;
1476pub const TCP_LINGER2: ::c_int = 8;
1477pub const TCP_DEFER_ACCEPT: ::c_int = 9;
1478pub const TCP_WINDOW_CLAMP: ::c_int = 10;
1479pub const TCP_INFO: ::c_int = 11;
1480pub const TCP_QUICKACK: ::c_int = 12;
1481pub const TCP_CONGESTION: ::c_int = 13;
1482
Taylor Cramerf7f9be32017-11-15 10:22:26 -08001483pub const SO_DEBUG: ::c_int = 1;
1484
1485pub const SHUT_RD: ::c_int = 0;
1486pub const SHUT_WR: ::c_int = 1;
1487pub const SHUT_RDWR: ::c_int = 2;
1488
1489pub const LOCK_SH: ::c_int = 1;
1490pub const LOCK_EX: ::c_int = 2;
1491pub const LOCK_NB: ::c_int = 4;
1492pub const LOCK_UN: ::c_int = 8;
1493
1494pub const SS_ONSTACK: ::c_int = 1;
1495pub const SS_DISABLE: ::c_int = 2;
1496
1497pub const PATH_MAX: ::c_int = 4096;
1498
1499pub const FD_SETSIZE: usize = 1024;
1500
1501pub const EPOLLIN: ::c_int = 0x1;
1502pub const EPOLLPRI: ::c_int = 0x2;
1503pub const EPOLLOUT: ::c_int = 0x4;
1504pub const EPOLLRDNORM: ::c_int = 0x40;
1505pub const EPOLLRDBAND: ::c_int = 0x80;
1506pub const EPOLLWRNORM: ::c_int = 0x100;
1507pub const EPOLLWRBAND: ::c_int = 0x200;
1508pub const EPOLLMSG: ::c_int = 0x400;
1509pub const EPOLLERR: ::c_int = 0x8;
1510pub const EPOLLHUP: ::c_int = 0x10;
1511pub const EPOLLET: ::c_int = 0x80000000;
1512
1513pub const EPOLL_CTL_ADD: ::c_int = 1;
1514pub const EPOLL_CTL_MOD: ::c_int = 3;
1515pub const EPOLL_CTL_DEL: ::c_int = 2;
1516
1517pub const MNT_DETACH: ::c_int = 0x2;
1518pub const MNT_EXPIRE: ::c_int = 0x4;
1519
1520pub const Q_GETFMT: ::c_int = 0x800004;
1521pub const Q_GETINFO: ::c_int = 0x800005;
1522pub const Q_SETINFO: ::c_int = 0x800006;
1523pub const QIF_BLIMITS: ::uint32_t = 1;
1524pub const QIF_SPACE: ::uint32_t = 2;
1525pub const QIF_ILIMITS: ::uint32_t = 4;
1526pub const QIF_INODES: ::uint32_t = 8;
1527pub const QIF_BTIME: ::uint32_t = 16;
1528pub const QIF_ITIME: ::uint32_t = 32;
1529pub const QIF_LIMITS: ::uint32_t = 5;
1530pub const QIF_USAGE: ::uint32_t = 10;
1531pub const QIF_TIMES: ::uint32_t = 48;
1532pub const QIF_ALL: ::uint32_t = 63;
1533
1534pub const MNT_FORCE: ::c_int = 0x1;
1535
1536pub const Q_SYNC: ::c_int = 0x800001;
1537pub const Q_QUOTAON: ::c_int = 0x800002;
1538pub const Q_QUOTAOFF: ::c_int = 0x800003;
1539pub const Q_GETQUOTA: ::c_int = 0x800007;
1540pub const Q_SETQUOTA: ::c_int = 0x800008;
1541
1542pub const TCIOFF: ::c_int = 2;
1543pub const TCION: ::c_int = 3;
1544pub const TCOOFF: ::c_int = 0;
1545pub const TCOON: ::c_int = 1;
1546pub const TCIFLUSH: ::c_int = 0;
1547pub const TCOFLUSH: ::c_int = 1;
1548pub const TCIOFLUSH: ::c_int = 2;
1549pub const NL0: ::c_int = 0x00000000;
1550pub const NL1: ::c_int = 0x00000100;
1551pub const TAB0: ::c_int = 0x00000000;
1552pub const CR0: ::c_int = 0x00000000;
1553pub const FF0: ::c_int = 0x00000000;
1554pub const BS0: ::c_int = 0x00000000;
1555pub const VT0: ::c_int = 0x00000000;
1556pub const VERASE: usize = 2;
1557pub const VKILL: usize = 3;
1558pub const VINTR: usize = 0;
1559pub const VQUIT: usize = 1;
1560pub const VLNEXT: usize = 15;
1561pub const IGNBRK: ::tcflag_t = 0x00000001;
1562pub const BRKINT: ::tcflag_t = 0x00000002;
1563pub const IGNPAR: ::tcflag_t = 0x00000004;
1564pub const PARMRK: ::tcflag_t = 0x00000008;
1565pub const INPCK: ::tcflag_t = 0x00000010;
1566pub const ISTRIP: ::tcflag_t = 0x00000020;
1567pub const INLCR: ::tcflag_t = 0x00000040;
1568pub const IGNCR: ::tcflag_t = 0x00000080;
1569pub const ICRNL: ::tcflag_t = 0x00000100;
1570pub const IXANY: ::tcflag_t = 0x00000800;
1571pub const IMAXBEL: ::tcflag_t = 0x00002000;
1572pub const OPOST: ::tcflag_t = 0x1;
1573pub const CS5: ::tcflag_t = 0x00000000;
1574pub const CRTSCTS: ::tcflag_t = 0x80000000;
1575pub const ECHO: ::tcflag_t = 0x00000008;
1576pub const OCRNL: ::tcflag_t = 0o000010;
1577pub const ONOCR: ::tcflag_t = 0o000020;
1578pub const ONLRET: ::tcflag_t = 0o000040;
1579pub const OFILL: ::tcflag_t = 0o000100;
1580pub const OFDEL: ::tcflag_t = 0o000200;
1581
1582pub const CLONE_VM: ::c_int = 0x100;
1583pub const CLONE_FS: ::c_int = 0x200;
1584pub const CLONE_FILES: ::c_int = 0x400;
1585pub const CLONE_SIGHAND: ::c_int = 0x800;
1586pub const CLONE_PTRACE: ::c_int = 0x2000;
1587pub const CLONE_VFORK: ::c_int = 0x4000;
1588pub const CLONE_PARENT: ::c_int = 0x8000;
1589pub const CLONE_THREAD: ::c_int = 0x10000;
1590pub const CLONE_NEWNS: ::c_int = 0x20000;
1591pub const CLONE_SYSVSEM: ::c_int = 0x40000;
1592pub const CLONE_SETTLS: ::c_int = 0x80000;
1593pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
1594pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
1595pub const CLONE_DETACHED: ::c_int = 0x400000;
1596pub const CLONE_UNTRACED: ::c_int = 0x800000;
1597pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
1598pub const CLONE_NEWUTS: ::c_int = 0x04000000;
1599pub const CLONE_NEWIPC: ::c_int = 0x08000000;
1600pub const CLONE_NEWUSER: ::c_int = 0x10000000;
1601pub const CLONE_NEWPID: ::c_int = 0x20000000;
1602pub const CLONE_NEWNET: ::c_int = 0x40000000;
1603pub const CLONE_IO: ::c_int = 0x80000000;
1604pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
1605
1606pub const WNOHANG: ::c_int = 0x00000001;
1607pub const WUNTRACED: ::c_int = 0x00000002;
1608pub const WSTOPPED: ::c_int = WUNTRACED;
1609pub const WEXITED: ::c_int = 0x00000004;
1610pub const WCONTINUED: ::c_int = 0x00000008;
1611pub const WNOWAIT: ::c_int = 0x01000000;
1612
1613// Options set using PTRACE_SETOPTIONS.
1614pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001;
1615pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002;
1616pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004;
1617pub const PTRACE_O_TRACECLONE: ::c_int = 0x00000008;
1618pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010;
1619pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020;
1620pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040;
1621pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080;
1622pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000;
1623pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000;
1624pub const PTRACE_O_MASK: ::c_int = 0x003000ff;
1625
1626// Wait extended result codes for the above trace options.
1627pub const PTRACE_EVENT_FORK: ::c_int = 1;
1628pub const PTRACE_EVENT_VFORK: ::c_int = 2;
1629pub const PTRACE_EVENT_CLONE: ::c_int = 3;
1630pub const PTRACE_EVENT_EXEC: ::c_int = 4;
1631pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5;
1632pub const PTRACE_EVENT_EXIT: ::c_int = 6;
1633pub const PTRACE_EVENT_SECCOMP: ::c_int = 7;
1634// PTRACE_EVENT_STOP was added to glibc in 2.26
1635// pub const PTRACE_EVENT_STOP: ::c_int = 128;
1636
1637pub const __WNOTHREAD: ::c_int = 0x20000000;
1638pub const __WALL: ::c_int = 0x40000000;
1639pub const __WCLONE: ::c_int = 0x80000000;
1640
1641pub const SPLICE_F_MOVE: ::c_uint = 0x01;
1642pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
1643pub const SPLICE_F_MORE: ::c_uint = 0x04;
1644pub const SPLICE_F_GIFT: ::c_uint = 0x08;
1645
1646pub const RTLD_LOCAL: ::c_int = 0;
1647pub const RTLD_LAZY: ::c_int = 1;
1648
1649pub const POSIX_FADV_NORMAL: ::c_int = 0;
1650pub const POSIX_FADV_RANDOM: ::c_int = 1;
1651pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
1652pub const POSIX_FADV_WILLNEED: ::c_int = 3;
1653
1654pub const AT_FDCWD: ::c_int = -100;
1655pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
1656pub const AT_REMOVEDIR: ::c_int = 0x200;
1657pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
1658pub const AT_NO_AUTOMOUNT: ::c_int = 0x800;
1659pub const AT_EMPTY_PATH: ::c_int = 0x1000;
1660
1661pub const LOG_CRON: ::c_int = 9 << 3;
1662pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
1663pub const LOG_FTP: ::c_int = 11 << 3;
1664pub const LOG_PERROR: ::c_int = 0x20;
1665
1666pub const PIPE_BUF: usize = 4096;
1667
1668pub const SI_LOAD_SHIFT: ::c_uint = 16;
1669
1670pub const SIGEV_SIGNAL: ::c_int = 0;
1671pub const SIGEV_NONE: ::c_int = 1;
1672pub const SIGEV_THREAD: ::c_int = 2;
1673
1674pub const P_ALL: idtype_t = 0;
1675pub const P_PID: idtype_t = 1;
1676pub const P_PGID: idtype_t = 2;
1677
1678pub const UTIME_OMIT: c_long = 1073741822;
1679pub const UTIME_NOW: c_long = 1073741823;
1680
1681pub const POLLIN: ::c_short = 0x1;
1682pub const POLLPRI: ::c_short = 0x2;
1683pub const POLLOUT: ::c_short = 0x4;
1684pub const POLLERR: ::c_short = 0x8;
1685pub const POLLHUP: ::c_short = 0x10;
1686pub const POLLNVAL: ::c_short = 0x20;
1687pub const POLLRDNORM: ::c_short = 0x040;
1688pub const POLLRDBAND: ::c_short = 0x080;
1689
Taylor Cramerf7f9be32017-11-15 10:22:26 -08001690pub const ABDAY_1: ::nl_item = 0x20000;
1691pub const ABDAY_2: ::nl_item = 0x20001;
1692pub const ABDAY_3: ::nl_item = 0x20002;
1693pub const ABDAY_4: ::nl_item = 0x20003;
1694pub const ABDAY_5: ::nl_item = 0x20004;
1695pub const ABDAY_6: ::nl_item = 0x20005;
1696pub const ABDAY_7: ::nl_item = 0x20006;
1697
1698pub const DAY_1: ::nl_item = 0x20007;
1699pub const DAY_2: ::nl_item = 0x20008;
1700pub const DAY_3: ::nl_item = 0x20009;
1701pub const DAY_4: ::nl_item = 0x2000A;
1702pub const DAY_5: ::nl_item = 0x2000B;
1703pub const DAY_6: ::nl_item = 0x2000C;
1704pub const DAY_7: ::nl_item = 0x2000D;
1705
1706pub const ABMON_1: ::nl_item = 0x2000E;
1707pub const ABMON_2: ::nl_item = 0x2000F;
1708pub const ABMON_3: ::nl_item = 0x20010;
1709pub const ABMON_4: ::nl_item = 0x20011;
1710pub const ABMON_5: ::nl_item = 0x20012;
1711pub const ABMON_6: ::nl_item = 0x20013;
1712pub const ABMON_7: ::nl_item = 0x20014;
1713pub const ABMON_8: ::nl_item = 0x20015;
1714pub const ABMON_9: ::nl_item = 0x20016;
1715pub const ABMON_10: ::nl_item = 0x20017;
1716pub const ABMON_11: ::nl_item = 0x20018;
1717pub const ABMON_12: ::nl_item = 0x20019;
1718
1719pub const MON_1: ::nl_item = 0x2001A;
1720pub const MON_2: ::nl_item = 0x2001B;
1721pub const MON_3: ::nl_item = 0x2001C;
1722pub const MON_4: ::nl_item = 0x2001D;
1723pub const MON_5: ::nl_item = 0x2001E;
1724pub const MON_6: ::nl_item = 0x2001F;
1725pub const MON_7: ::nl_item = 0x20020;
1726pub const MON_8: ::nl_item = 0x20021;
1727pub const MON_9: ::nl_item = 0x20022;
1728pub const MON_10: ::nl_item = 0x20023;
1729pub const MON_11: ::nl_item = 0x20024;
1730pub const MON_12: ::nl_item = 0x20025;
1731
1732pub const AM_STR: ::nl_item = 0x20026;
1733pub const PM_STR: ::nl_item = 0x20027;
1734
1735pub const D_T_FMT: ::nl_item = 0x20028;
1736pub const D_FMT: ::nl_item = 0x20029;
1737pub const T_FMT: ::nl_item = 0x2002A;
1738pub const T_FMT_AMPM: ::nl_item = 0x2002B;
1739
1740pub const ERA: ::nl_item = 0x2002C;
1741pub const ERA_D_FMT: ::nl_item = 0x2002E;
1742pub const ALT_DIGITS: ::nl_item = 0x2002F;
1743pub const ERA_D_T_FMT: ::nl_item = 0x20030;
1744pub const ERA_T_FMT: ::nl_item = 0x20031;
1745
1746pub const CODESET: ::nl_item = 14;
1747
1748pub const CRNCYSTR: ::nl_item = 0x4000F;
1749
1750pub const RUSAGE_THREAD: ::c_int = 1;
1751pub const RUSAGE_CHILDREN: ::c_int = -1;
1752
1753pub const RADIXCHAR: ::nl_item = 0x10000;
1754pub const THOUSEP: ::nl_item = 0x10001;
1755
1756pub const YESEXPR: ::nl_item = 0x50000;
1757pub const NOEXPR: ::nl_item = 0x50001;
1758pub const YESSTR: ::nl_item = 0x50002;
1759pub const NOSTR: ::nl_item = 0x50003;
1760
1761pub const FILENAME_MAX: ::c_uint = 4096;
1762pub const L_tmpnam: ::c_uint = 20;
1763pub const _PC_LINK_MAX: ::c_int = 0;
1764pub const _PC_MAX_CANON: ::c_int = 1;
1765pub const _PC_MAX_INPUT: ::c_int = 2;
1766pub const _PC_NAME_MAX: ::c_int = 3;
1767pub const _PC_PATH_MAX: ::c_int = 4;
1768pub const _PC_PIPE_BUF: ::c_int = 5;
1769pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
1770pub const _PC_NO_TRUNC: ::c_int = 7;
1771pub const _PC_VDISABLE: ::c_int = 8;
1772pub const _PC_SYNC_IO: ::c_int = 9;
1773pub const _PC_ASYNC_IO: ::c_int = 10;
1774pub const _PC_PRIO_IO: ::c_int = 11;
1775pub const _PC_SOCK_MAXBUF: ::c_int = 12;
1776pub const _PC_FILESIZEBITS: ::c_int = 13;
1777pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
1778pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
1779pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
1780pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
1781pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18;
1782pub const _PC_SYMLINK_MAX: ::c_int = 19;
1783pub const _PC_2_SYMLINKS: ::c_int = 20;
1784
1785pub const _SC_ARG_MAX: ::c_int = 0;
1786pub const _SC_CHILD_MAX: ::c_int = 1;
1787pub const _SC_CLK_TCK: ::c_int = 2;
1788pub const _SC_NGROUPS_MAX: ::c_int = 3;
1789pub const _SC_OPEN_MAX: ::c_int = 4;
1790pub const _SC_STREAM_MAX: ::c_int = 5;
1791pub const _SC_TZNAME_MAX: ::c_int = 6;
1792pub const _SC_JOB_CONTROL: ::c_int = 7;
1793pub const _SC_SAVED_IDS: ::c_int = 8;
1794pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
1795pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
1796pub const _SC_TIMERS: ::c_int = 11;
1797pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
1798pub const _SC_PRIORITIZED_IO: ::c_int = 13;
1799pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
1800pub const _SC_FSYNC: ::c_int = 15;
1801pub const _SC_MAPPED_FILES: ::c_int = 16;
1802pub const _SC_MEMLOCK: ::c_int = 17;
1803pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
1804pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
1805pub const _SC_MESSAGE_PASSING: ::c_int = 20;
1806pub const _SC_SEMAPHORES: ::c_int = 21;
1807pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
1808pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
1809pub const _SC_AIO_MAX: ::c_int = 24;
1810pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
1811pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
1812pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
1813pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
1814pub const _SC_VERSION: ::c_int = 29;
1815pub const _SC_PAGESIZE: ::c_int = 30;
1816pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
1817pub const _SC_RTSIG_MAX: ::c_int = 31;
1818pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
1819pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
1820pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
1821pub const _SC_TIMER_MAX: ::c_int = 35;
1822pub const _SC_BC_BASE_MAX: ::c_int = 36;
1823pub const _SC_BC_DIM_MAX: ::c_int = 37;
1824pub const _SC_BC_SCALE_MAX: ::c_int = 38;
1825pub const _SC_BC_STRING_MAX: ::c_int = 39;
1826pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
1827pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
1828pub const _SC_LINE_MAX: ::c_int = 43;
1829pub const _SC_RE_DUP_MAX: ::c_int = 44;
1830pub const _SC_2_VERSION: ::c_int = 46;
1831pub const _SC_2_C_BIND: ::c_int = 47;
1832pub const _SC_2_C_DEV: ::c_int = 48;
1833pub const _SC_2_FORT_DEV: ::c_int = 49;
1834pub const _SC_2_FORT_RUN: ::c_int = 50;
1835pub const _SC_2_SW_DEV: ::c_int = 51;
1836pub const _SC_2_LOCALEDEF: ::c_int = 52;
1837pub const _SC_UIO_MAXIOV: ::c_int = 60;
1838pub const _SC_IOV_MAX: ::c_int = 60;
1839pub const _SC_THREADS: ::c_int = 67;
1840pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
1841pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
1842pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
1843pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
1844pub const _SC_TTY_NAME_MAX: ::c_int = 72;
1845pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
1846pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
1847pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
1848pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
1849pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
1850pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
1851pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
1852pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
1853pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
1854pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82;
1855pub const _SC_NPROCESSORS_CONF: ::c_int = 83;
1856pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
1857pub const _SC_PHYS_PAGES: ::c_int = 85;
1858pub const _SC_AVPHYS_PAGES: ::c_int = 86;
1859pub const _SC_ATEXIT_MAX: ::c_int = 87;
1860pub const _SC_PASS_MAX: ::c_int = 88;
1861pub const _SC_XOPEN_VERSION: ::c_int = 89;
1862pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
1863pub const _SC_XOPEN_UNIX: ::c_int = 91;
1864pub const _SC_XOPEN_CRYPT: ::c_int = 92;
1865pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
1866pub const _SC_XOPEN_SHM: ::c_int = 94;
1867pub const _SC_2_CHAR_TERM: ::c_int = 95;
1868pub const _SC_2_UPE: ::c_int = 97;
1869pub const _SC_XOPEN_XPG2: ::c_int = 98;
1870pub const _SC_XOPEN_XPG3: ::c_int = 99;
1871pub const _SC_XOPEN_XPG4: ::c_int = 100;
1872pub const _SC_NZERO: ::c_int = 109;
1873pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
1874pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
1875pub const _SC_XBS5_LP64_OFF64: ::c_int = 127;
1876pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
1877pub const _SC_XOPEN_LEGACY: ::c_int = 129;
1878pub const _SC_XOPEN_REALTIME: ::c_int = 130;
1879pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
1880pub const _SC_ADVISORY_INFO: ::c_int = 132;
1881pub const _SC_BARRIERS: ::c_int = 133;
1882pub const _SC_CLOCK_SELECTION: ::c_int = 137;
1883pub const _SC_CPUTIME: ::c_int = 138;
1884pub const _SC_THREAD_CPUTIME: ::c_int = 139;
1885pub const _SC_MONOTONIC_CLOCK: ::c_int = 149;
1886pub const _SC_READER_WRITER_LOCKS: ::c_int = 153;
1887pub const _SC_SPIN_LOCKS: ::c_int = 154;
1888pub const _SC_REGEXP: ::c_int = 155;
1889pub const _SC_SHELL: ::c_int = 157;
1890pub const _SC_SPAWN: ::c_int = 159;
1891pub const _SC_SPORADIC_SERVER: ::c_int = 160;
1892pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161;
1893pub const _SC_TIMEOUTS: ::c_int = 164;
1894pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165;
1895pub const _SC_2_PBS: ::c_int = 168;
1896pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169;
1897pub const _SC_2_PBS_LOCATE: ::c_int = 170;
1898pub const _SC_2_PBS_MESSAGE: ::c_int = 171;
1899pub const _SC_2_PBS_TRACK: ::c_int = 172;
1900pub const _SC_SYMLOOP_MAX: ::c_int = 173;
1901pub const _SC_STREAMS: ::c_int = 174;
1902pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175;
1903pub const _SC_V6_ILP32_OFF32: ::c_int = 176;
1904pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177;
1905pub const _SC_V6_LP64_OFF64: ::c_int = 178;
1906pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179;
1907pub const _SC_HOST_NAME_MAX: ::c_int = 180;
1908pub const _SC_TRACE: ::c_int = 181;
1909pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182;
1910pub const _SC_TRACE_INHERIT: ::c_int = 183;
1911pub const _SC_TRACE_LOG: ::c_int = 184;
1912pub const _SC_IPV6: ::c_int = 235;
1913pub const _SC_RAW_SOCKETS: ::c_int = 236;
1914pub const _SC_V7_ILP32_OFF32: ::c_int = 237;
1915pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238;
1916pub const _SC_V7_LP64_OFF64: ::c_int = 239;
1917pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240;
1918pub const _SC_SS_REPL_MAX: ::c_int = 241;
1919pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242;
1920pub const _SC_TRACE_NAME_MAX: ::c_int = 243;
1921pub const _SC_TRACE_SYS_MAX: ::c_int = 244;
1922pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245;
1923pub const _SC_XOPEN_STREAMS: ::c_int = 246;
1924pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247;
1925pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248;
1926
1927pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
1928pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
1929
1930pub const GLOB_ERR: ::c_int = 1 << 0;
1931pub const GLOB_MARK: ::c_int = 1 << 1;
1932pub const GLOB_NOSORT: ::c_int = 1 << 2;
1933pub const GLOB_DOOFFS: ::c_int = 1 << 3;
1934pub const GLOB_NOCHECK: ::c_int = 1 << 4;
1935pub const GLOB_APPEND: ::c_int = 1 << 5;
1936pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
1937
1938pub const GLOB_NOSPACE: ::c_int = 1;
1939pub const GLOB_ABORTED: ::c_int = 2;
1940pub const GLOB_NOMATCH: ::c_int = 3;
1941
1942pub const POSIX_MADV_NORMAL: ::c_int = 0;
1943pub const POSIX_MADV_RANDOM: ::c_int = 1;
1944pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
1945pub const POSIX_MADV_WILLNEED: ::c_int = 3;
1946
1947pub const S_IEXEC: mode_t = 64;
1948pub const S_IWRITE: mode_t = 128;
1949pub const S_IREAD: mode_t = 256;
1950
1951pub const F_LOCK: ::c_int = 1;
1952pub const F_TEST: ::c_int = 3;
1953pub const F_TLOCK: ::c_int = 2;
1954pub const F_ULOCK: ::c_int = 0;
1955
1956pub const IFF_LOWER_UP: ::c_int = 0x10000;
1957pub const IFF_DORMANT: ::c_int = 0x20000;
1958pub const IFF_ECHO: ::c_int = 0x40000;
1959
1960pub const ST_RDONLY: ::c_ulong = 1;
1961pub const ST_NOSUID: ::c_ulong = 2;
1962pub const ST_NODEV: ::c_ulong = 4;
1963pub const ST_NOEXEC: ::c_ulong = 8;
1964pub const ST_SYNCHRONOUS: ::c_ulong = 16;
1965pub const ST_MANDLOCK: ::c_ulong = 64;
1966pub const ST_WRITE: ::c_ulong = 128;
1967pub const ST_APPEND: ::c_ulong = 256;
1968pub const ST_IMMUTABLE: ::c_ulong = 512;
1969pub const ST_NOATIME: ::c_ulong = 1024;
1970pub const ST_NODIRATIME: ::c_ulong = 2048;
1971
1972pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
1973pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
1974pub const RTLD_NODELETE: ::c_int = 0x1000;
1975pub const RTLD_NOW: ::c_int = 0x2;
1976
1977pub const TCP_MD5SIG: ::c_int = 14;
1978
Linus Färnstrand28196342018-07-21 00:47:01 +02001979align_const! {
1980 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
1981 size: [0; __SIZEOF_PTHREAD_MUTEX_T],
1982 };
1983 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1984 size: [0; __SIZEOF_PTHREAD_COND_T],
1985 };
1986 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1987 size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
1988 };
1989}
Taylor Cramerf7f9be32017-11-15 10:22:26 -08001990pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
1991pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
1992pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
1993pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
1994pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
1995pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
1996pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
1997
1998pub const RENAME_NOREPLACE: ::c_int = 1;
1999pub const RENAME_EXCHANGE: ::c_int = 2;
2000pub const RENAME_WHITEOUT: ::c_int = 4;
2001
2002pub const SCHED_OTHER: ::c_int = 0;
2003pub const SCHED_FIFO: ::c_int = 1;
2004pub const SCHED_RR: ::c_int = 2;
2005pub const SCHED_BATCH: ::c_int = 3;
2006pub const SCHED_IDLE: ::c_int = 5;
2007
2008// netinet/in.h
2009// NOTE: These are in addition to the constants defined in src/unix/mod.rs
2010
2011// IPPROTO_IP defined in src/unix/mod.rs
2012/// Hop-by-hop option header
2013pub const IPPROTO_HOPOPTS: ::c_int = 0;
2014// IPPROTO_ICMP defined in src/unix/mod.rs
2015/// group mgmt protocol
2016pub const IPPROTO_IGMP: ::c_int = 2;
2017/// for compatibility
2018pub const IPPROTO_IPIP: ::c_int = 4;
2019// IPPROTO_TCP defined in src/unix/mod.rs
2020/// exterior gateway protocol
2021pub const IPPROTO_EGP: ::c_int = 8;
2022/// pup
2023pub const IPPROTO_PUP: ::c_int = 12;
2024// IPPROTO_UDP defined in src/unix/mod.rs
2025/// xns idp
2026pub const IPPROTO_IDP: ::c_int = 22;
2027/// tp-4 w/ class negotiation
2028pub const IPPROTO_TP: ::c_int = 29;
2029/// DCCP
2030pub const IPPROTO_DCCP: ::c_int = 33;
2031// IPPROTO_IPV6 defined in src/unix/mod.rs
2032/// IP6 routing header
2033pub const IPPROTO_ROUTING: ::c_int = 43;
2034/// IP6 fragmentation header
2035pub const IPPROTO_FRAGMENT: ::c_int = 44;
2036/// resource reservation
2037pub const IPPROTO_RSVP: ::c_int = 46;
2038/// General Routing Encap.
2039pub const IPPROTO_GRE: ::c_int = 47;
2040/// IP6 Encap Sec. Payload
2041pub const IPPROTO_ESP: ::c_int = 50;
2042/// IP6 Auth Header
2043pub const IPPROTO_AH: ::c_int = 51;
2044// IPPROTO_ICMPV6 defined in src/unix/mod.rs
2045/// IP6 no next header
2046pub const IPPROTO_NONE: ::c_int = 59;
2047/// IP6 destination option
2048pub const IPPROTO_DSTOPTS: ::c_int = 60;
2049pub const IPPROTO_MTP: ::c_int = 92;
2050pub const IPPROTO_BEETPH: ::c_int = 94;
2051/// encapsulation header
2052pub const IPPROTO_ENCAP: ::c_int = 98;
2053/// Protocol indep. multicast
2054pub const IPPROTO_PIM: ::c_int = 103;
2055/// IP Payload Comp. Protocol
2056pub const IPPROTO_COMP: ::c_int = 108;
2057/// SCTP
2058pub const IPPROTO_SCTP: ::c_int = 132;
2059pub const IPPROTO_MH: ::c_int = 135;
2060pub const IPPROTO_UDPLITE: ::c_int = 136;
2061pub const IPPROTO_MPLS: ::c_int = 137;
2062/// raw IP packet
2063pub const IPPROTO_RAW: ::c_int = 255;
2064pub const IPPROTO_MAX: ::c_int = 256;
2065
2066pub const AF_IB: ::c_int = 27;
2067pub const AF_MPLS: ::c_int = 28;
2068pub const AF_NFC: ::c_int = 39;
2069pub const AF_VSOCK: ::c_int = 40;
2070pub const PF_IB: ::c_int = AF_IB;
2071pub const PF_MPLS: ::c_int = AF_MPLS;
2072pub const PF_NFC: ::c_int = AF_NFC;
2073pub const PF_VSOCK: ::c_int = AF_VSOCK;
2074
2075// System V IPC
2076pub const IPC_PRIVATE: ::key_t = 0;
2077
2078pub const IPC_CREAT: ::c_int = 0o1000;
2079pub const IPC_EXCL: ::c_int = 0o2000;
2080pub const IPC_NOWAIT: ::c_int = 0o4000;
2081
2082pub const IPC_RMID: ::c_int = 0;
2083pub const IPC_SET: ::c_int = 1;
2084pub const IPC_STAT: ::c_int = 2;
2085pub const IPC_INFO: ::c_int = 3;
2086pub const MSG_STAT: ::c_int = 11;
2087pub const MSG_INFO: ::c_int = 12;
2088
2089pub const MSG_NOERROR: ::c_int = 0o10000;
2090pub const MSG_EXCEPT: ::c_int = 0o20000;
2091pub const MSG_COPY: ::c_int = 0o40000;
2092
2093pub const SHM_R: ::c_int = 0o400;
2094pub const SHM_W: ::c_int = 0o200;
2095
2096pub const SHM_RDONLY: ::c_int = 0o10000;
2097pub const SHM_RND: ::c_int = 0o20000;
2098pub const SHM_REMAP: ::c_int = 0o40000;
2099pub const SHM_EXEC: ::c_int = 0o100000;
2100
2101pub const SHM_LOCK: ::c_int = 11;
2102pub const SHM_UNLOCK: ::c_int = 12;
2103
2104pub const SHM_HUGETLB: ::c_int = 0o4000;
2105pub const SHM_NORESERVE: ::c_int = 0o10000;
2106
2107pub const EPOLLRDHUP: ::c_int = 0x2000;
2108pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
2109pub const EPOLLONESHOT: ::c_int = 0x40000000;
2110
2111pub const QFMT_VFS_OLD: ::c_int = 1;
2112pub const QFMT_VFS_V0: ::c_int = 2;
2113pub const QFMT_VFS_V1: ::c_int = 4;
2114
2115pub const EFD_SEMAPHORE: ::c_int = 0x1;
2116
2117pub const LOG_NFACILITIES: ::c_int = 24;
2118
2119pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
2120
2121pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
2122pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
2123pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
2124pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
2125pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
2126pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
2127pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
2128
2129pub const AI_PASSIVE: ::c_int = 0x0001;
2130pub const AI_CANONNAME: ::c_int = 0x0002;
2131pub const AI_NUMERICHOST: ::c_int = 0x0004;
2132pub const AI_V4MAPPED: ::c_int = 0x0008;
2133pub const AI_ALL: ::c_int = 0x0010;
2134pub const AI_ADDRCONFIG: ::c_int = 0x0020;
2135
2136pub const AI_NUMERICSERV: ::c_int = 0x0400;
2137
2138pub const EAI_BADFLAGS: ::c_int = -1;
2139pub const EAI_NONAME: ::c_int = -2;
2140pub const EAI_AGAIN: ::c_int = -3;
2141pub const EAI_FAIL: ::c_int = -4;
2142pub const EAI_FAMILY: ::c_int = -6;
2143pub const EAI_SOCKTYPE: ::c_int = -7;
2144pub const EAI_SERVICE: ::c_int = -8;
2145pub const EAI_MEMORY: ::c_int = -10;
2146pub const EAI_OVERFLOW: ::c_int = -12;
2147
2148pub const NI_NUMERICHOST: ::c_int = 1;
2149pub const NI_NUMERICSERV: ::c_int = 2;
2150pub const NI_NOFQDN: ::c_int = 4;
2151pub const NI_NAMEREQD: ::c_int = 8;
2152pub const NI_DGRAM: ::c_int = 16;
2153
2154pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
2155pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
2156pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
2157
2158pub const EAI_SYSTEM: ::c_int = -11;
2159
2160pub const AIO_CANCELED: ::c_int = 0;
2161pub const AIO_NOTCANCELED: ::c_int = 1;
2162pub const AIO_ALLDONE: ::c_int = 2;
2163pub const LIO_READ: ::c_int = 0;
2164pub const LIO_WRITE: ::c_int = 1;
2165pub const LIO_NOP: ::c_int = 2;
2166pub const LIO_WAIT: ::c_int = 0;
2167pub const LIO_NOWAIT: ::c_int = 1;
2168
2169pub const MREMAP_MAYMOVE: ::c_int = 1;
2170pub const MREMAP_FIXED: ::c_int = 2;
2171
2172pub const PR_SET_PDEATHSIG: ::c_int = 1;
2173pub const PR_GET_PDEATHSIG: ::c_int = 2;
2174
2175pub const PR_GET_DUMPABLE: ::c_int = 3;
2176pub const PR_SET_DUMPABLE: ::c_int = 4;
2177
2178pub const PR_GET_UNALIGN: ::c_int = 5;
2179pub const PR_SET_UNALIGN: ::c_int = 6;
2180pub const PR_UNALIGN_NOPRINT: ::c_int = 1;
2181pub const PR_UNALIGN_SIGBUS: ::c_int = 2;
2182
2183pub const PR_GET_KEEPCAPS: ::c_int = 7;
2184pub const PR_SET_KEEPCAPS: ::c_int = 8;
2185
2186pub const PR_GET_FPEMU: ::c_int = 9;
2187pub const PR_SET_FPEMU: ::c_int = 10;
2188pub const PR_FPEMU_NOPRINT: ::c_int = 1;
2189pub const PR_FPEMU_SIGFPE: ::c_int = 2;
2190
2191pub const PR_GET_FPEXC: ::c_int = 11;
2192pub const PR_SET_FPEXC: ::c_int = 12;
2193pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80;
2194pub const PR_FP_EXC_DIV: ::c_int = 0x010000;
2195pub const PR_FP_EXC_OVF: ::c_int = 0x020000;
2196pub const PR_FP_EXC_UND: ::c_int = 0x040000;
2197pub const PR_FP_EXC_RES: ::c_int = 0x080000;
2198pub const PR_FP_EXC_INV: ::c_int = 0x100000;
2199pub const PR_FP_EXC_DISABLED: ::c_int = 0;
2200pub const PR_FP_EXC_NONRECOV: ::c_int = 1;
2201pub const PR_FP_EXC_ASYNC: ::c_int = 2;
2202pub const PR_FP_EXC_PRECISE: ::c_int = 3;
2203
2204pub const PR_GET_TIMING: ::c_int = 13;
2205pub const PR_SET_TIMING: ::c_int = 14;
2206pub const PR_TIMING_STATISTICAL: ::c_int = 0;
2207pub const PR_TIMING_TIMESTAMP: ::c_int = 1;
2208
2209pub const PR_SET_NAME: ::c_int = 15;
2210pub const PR_GET_NAME: ::c_int = 16;
2211
2212pub const PR_GET_ENDIAN: ::c_int = 19;
2213pub const PR_SET_ENDIAN: ::c_int = 20;
2214pub const PR_ENDIAN_BIG: ::c_int = 0;
2215pub const PR_ENDIAN_LITTLE: ::c_int = 1;
2216pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2;
2217
2218pub const PR_GET_SECCOMP: ::c_int = 21;
2219pub const PR_SET_SECCOMP: ::c_int = 22;
2220
2221pub const PR_CAPBSET_READ: ::c_int = 23;
2222pub const PR_CAPBSET_DROP: ::c_int = 24;
2223
2224pub const PR_GET_TSC: ::c_int = 25;
2225pub const PR_SET_TSC: ::c_int = 26;
2226pub const PR_TSC_ENABLE: ::c_int = 1;
2227pub const PR_TSC_SIGSEGV: ::c_int = 2;
2228
2229pub const PR_GET_SECUREBITS: ::c_int = 27;
2230pub const PR_SET_SECUREBITS: ::c_int = 28;
2231
2232pub const PR_SET_TIMERSLACK: ::c_int = 29;
2233pub const PR_GET_TIMERSLACK: ::c_int = 30;
2234
2235pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31;
2236pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32;
2237
2238pub const PR_MCE_KILL: ::c_int = 33;
2239pub const PR_MCE_KILL_CLEAR: ::c_int = 0;
2240pub const PR_MCE_KILL_SET: ::c_int = 1;
2241
2242pub const PR_MCE_KILL_LATE: ::c_int = 0;
2243pub const PR_MCE_KILL_EARLY: ::c_int = 1;
2244pub const PR_MCE_KILL_DEFAULT: ::c_int = 2;
2245
2246pub const PR_MCE_KILL_GET: ::c_int = 34;
2247
2248pub const PR_SET_MM: ::c_int = 35;
2249pub const PR_SET_MM_START_CODE: ::c_int = 1;
2250pub const PR_SET_MM_END_CODE: ::c_int = 2;
2251pub const PR_SET_MM_START_DATA: ::c_int = 3;
2252pub const PR_SET_MM_END_DATA: ::c_int = 4;
2253pub const PR_SET_MM_START_STACK: ::c_int = 5;
2254pub const PR_SET_MM_START_BRK: ::c_int = 6;
2255pub const PR_SET_MM_BRK: ::c_int = 7;
2256pub const PR_SET_MM_ARG_START: ::c_int = 8;
2257pub const PR_SET_MM_ARG_END: ::c_int = 9;
2258pub const PR_SET_MM_ENV_START: ::c_int = 10;
2259pub const PR_SET_MM_ENV_END: ::c_int = 11;
2260pub const PR_SET_MM_AUXV: ::c_int = 12;
2261pub const PR_SET_MM_EXE_FILE: ::c_int = 13;
2262pub const PR_SET_MM_MAP: ::c_int = 14;
2263pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
2264
2265pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
2266
2267pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
2268pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
2269
2270pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38;
2271pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39;
2272
2273pub const PR_GET_TID_ADDRESS: ::c_int = 40;
2274
2275pub const PR_SET_THP_DISABLE: ::c_int = 41;
2276pub const PR_GET_THP_DISABLE: ::c_int = 42;
2277
2278pub const PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43;
2279pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44;
2280
2281pub const PR_SET_FP_MODE: ::c_int = 45;
2282pub const PR_GET_FP_MODE: ::c_int = 46;
2283pub const PR_FP_MODE_FR: ::c_int = 1 << 0;
2284pub const PR_FP_MODE_FRE: ::c_int = 1 << 1;
2285
2286pub const PR_CAP_AMBIENT: ::c_int = 47;
2287pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1;
2288pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2;
2289pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3;
2290pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4;
2291
2292pub const GRND_NONBLOCK: ::c_uint = 0x0001;
2293pub const GRND_RANDOM: ::c_uint = 0x0002;
2294
2295pub const ITIMER_REAL: ::c_int = 0;
2296pub const ITIMER_VIRTUAL: ::c_int = 1;
2297pub const ITIMER_PROF: ::c_int = 2;
2298
2299pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
2300pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK;
2301pub const TFD_TIMER_ABSTIME: ::c_int = 1;
2302
2303pub const XATTR_CREATE: ::c_int = 0x1;
2304pub const XATTR_REPLACE: ::c_int = 0x2;
2305
2306pub const _POSIX_VDISABLE: ::cc_t = 0;
2307
2308pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
2309pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
2310pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08;
2311pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10;
2312pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20;
2313pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40;
2314
2315// On Linux, libc doesn't define this constant, libattr does instead.
2316// We still define it for Linux as it's defined by libc on other platforms,
2317// and it's mentioned in the man pages for getxattr and setxattr.
2318pub const ENOATTR: ::c_int = ::ENODATA;
2319
2320pub const SO_ORIGINAL_DST: ::c_int = 80;
2321pub const IUTF8: ::tcflag_t = 0x00004000;
2322pub const CMSPAR: ::tcflag_t = 0o10000000000;
2323
2324pub const MFD_CLOEXEC: ::c_uint = 0x0001;
2325pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
2326
2327// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has
2328// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32
2329// so we can use that type here to avoid having to cast.
2330pub const PT_NULL: u32 = 0;
2331pub const PT_LOAD: u32 = 1;
2332pub const PT_DYNAMIC: u32 = 2;
2333pub const PT_INTERP: u32 = 3;
2334pub const PT_NOTE: u32 = 4;
2335pub const PT_SHLIB: u32 = 5;
2336pub const PT_PHDR: u32 = 6;
2337pub const PT_TLS: u32 = 7;
2338pub const PT_NUM: u32 = 8;
2339pub const PT_LOOS: u32 = 0x60000000;
2340pub const PT_GNU_EH_FRAME: u32 = 0x6474e550;
2341pub const PT_GNU_STACK: u32 = 0x6474e551;
2342pub const PT_GNU_RELRO: u32 = 0x6474e552;
2343
Taylor Cramerb4cfe882017-11-15 11:29:01 -08002344pub const SFD_CLOEXEC: ::c_int = 0x080000;
2345
2346pub const NCCS: usize = 32;
2347
2348pub const O_TRUNC: ::c_int = 0x00040000;
2349pub const O_NOATIME: ::c_int = 0x00002000;
2350pub const O_CLOEXEC: ::c_int = 0x00000100;
2351pub const O_TMPFILE: ::c_int = 0x00004000;
2352
2353pub const EBFONT: ::c_int = 59;
2354pub const ENOSTR: ::c_int = 60;
2355pub const ENODATA: ::c_int = 61;
2356pub const ETIME: ::c_int = 62;
2357pub const ENOSR: ::c_int = 63;
2358pub const ENONET: ::c_int = 64;
2359pub const ENOPKG: ::c_int = 65;
2360pub const EREMOTE: ::c_int = 66;
2361pub const ENOLINK: ::c_int = 67;
2362pub const EADV: ::c_int = 68;
2363pub const ESRMNT: ::c_int = 69;
2364pub const ECOMM: ::c_int = 70;
2365pub const EPROTO: ::c_int = 71;
2366pub const EDOTDOT: ::c_int = 73;
2367
2368pub const SA_NODEFER: ::c_int = 0x40000000;
2369pub const SA_RESETHAND: ::c_int = 0x80000000;
2370pub const SA_RESTART: ::c_int = 0x10000000;
2371pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
2372
2373pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
2374
2375pub const EFD_CLOEXEC: ::c_int = 0x80000;
2376
2377pub const BUFSIZ: ::c_uint = 1024;
2378pub const TMP_MAX: ::c_uint = 10000;
2379pub const FOPEN_MAX: ::c_uint = 1000;
2380pub const O_PATH: ::c_int = 0x00400000;
2381pub const O_EXEC: ::c_int = O_PATH;
2382pub const O_SEARCH: ::c_int = O_PATH;
2383pub const O_ACCMODE: ::c_int = (03 | O_SEARCH);
2384pub const O_NDELAY: ::c_int = O_NONBLOCK;
2385pub const NI_MAXHOST: ::socklen_t = 255;
2386pub const PTHREAD_STACK_MIN: ::size_t = 2048;
2387pub const POSIX_FADV_DONTNEED: ::c_int = 4;
2388pub const POSIX_FADV_NOREUSE: ::c_int = 5;
2389
2390pub const POSIX_MADV_DONTNEED: ::c_int = 4;
2391
2392pub const RLIM_INFINITY: ::rlim_t = !0;
2393pub const RLIMIT_RTTIME: ::c_int = 15;
2394pub const RLIMIT_NLIMITS: ::c_int = 16;
2395
2396pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
2397
2398pub const SOCK_DCCP: ::c_int = 6;
2399pub const SOCK_PACKET: ::c_int = 10;
2400
2401pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
2402pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
2403pub const TCP_THIN_DUPACK: ::c_int = 17;
2404pub const TCP_USER_TIMEOUT: ::c_int = 18;
2405pub const TCP_REPAIR: ::c_int = 19;
2406pub const TCP_REPAIR_QUEUE: ::c_int = 20;
2407pub const TCP_QUEUE_SEQ: ::c_int = 21;
2408pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
2409pub const TCP_FASTOPEN: ::c_int = 23;
2410pub const TCP_TIMESTAMP: ::c_int = 24;
2411
2412pub const SIGUNUSED: ::c_int = ::SIGSYS;
2413
2414pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
2415pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
2416pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
2417
2418pub const CPU_SETSIZE: ::c_int = 128;
2419
2420pub const PTRACE_TRACEME: ::c_int = 0;
2421pub const PTRACE_PEEKTEXT: ::c_int = 1;
2422pub const PTRACE_PEEKDATA: ::c_int = 2;
2423pub const PTRACE_PEEKUSER: ::c_int = 3;
2424pub const PTRACE_POKETEXT: ::c_int = 4;
2425pub const PTRACE_POKEDATA: ::c_int = 5;
2426pub const PTRACE_POKEUSER: ::c_int = 6;
2427pub const PTRACE_CONT: ::c_int = 7;
2428pub const PTRACE_KILL: ::c_int = 8;
2429pub const PTRACE_SINGLESTEP: ::c_int = 9;
2430pub const PTRACE_GETREGS: ::c_int = 12;
2431pub const PTRACE_SETREGS: ::c_int = 13;
2432pub const PTRACE_GETFPREGS: ::c_int = 14;
2433pub const PTRACE_SETFPREGS: ::c_int = 15;
2434pub const PTRACE_ATTACH: ::c_int = 16;
2435pub const PTRACE_DETACH: ::c_int = 17;
2436pub const PTRACE_GETFPXREGS: ::c_int = 18;
2437pub const PTRACE_SETFPXREGS: ::c_int = 19;
2438pub const PTRACE_SYSCALL: ::c_int = 24;
2439pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
2440pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
2441pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
2442pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
2443pub const PTRACE_GETREGSET: ::c_int = 0x4204;
2444pub const PTRACE_SETREGSET: ::c_int = 0x4205;
2445pub const PTRACE_SEIZE: ::c_int = 0x4206;
2446pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
2447pub const PTRACE_LISTEN: ::c_int = 0x4208;
2448pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
2449
2450pub const EPOLLWAKEUP: ::c_int = 0x20000000;
2451
2452pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
2453
2454pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
2455
2456pub const TCSANOW: ::c_int = 0;
2457pub const TCSADRAIN: ::c_int = 1;
2458pub const TCSAFLUSH: ::c_int = 2;
2459
2460pub const TIOCINQ: ::c_int = ::FIONREAD;
2461
2462pub const RTLD_GLOBAL: ::c_int = 0x100;
2463pub const RTLD_NOLOAD: ::c_int = 0x4;
2464
2465// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux
2466// kernel 3.10). See also notbsd/mod.rs
2467pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
2468pub const CLOCK_TAI: ::clockid_t = 11;
2469
2470pub const MCL_CURRENT: ::c_int = 0x0001;
2471pub const MCL_FUTURE: ::c_int = 0x0002;
2472
2473pub const CBAUD: ::tcflag_t = 0o0010017;
2474pub const TAB1: ::c_int = 0x00000800;
2475pub const TAB2: ::c_int = 0x00001000;
2476pub const TAB3: ::c_int = 0x00001800;
2477pub const CR1: ::c_int = 0x00000200;
2478pub const CR2: ::c_int = 0x00000400;
2479pub const CR3: ::c_int = 0x00000600;
2480pub const FF1: ::c_int = 0x00008000;
2481pub const BS1: ::c_int = 0x00002000;
2482pub const VT1: ::c_int = 0x00004000;
2483pub const VWERASE: usize = 14;
2484pub const VREPRINT: usize = 12;
2485pub const VSUSP: usize = 10;
2486pub const VSTART: usize = 8;
2487pub const VSTOP: usize = 9;
2488pub const VDISCARD: usize = 13;
2489pub const VTIME: usize = 5;
2490pub const IXON: ::tcflag_t = 0x00000400;
2491pub const IXOFF: ::tcflag_t = 0x00001000;
2492pub const ONLCR: ::tcflag_t = 0x4;
2493pub const CSIZE: ::tcflag_t = 0x00000030;
2494pub const CS6: ::tcflag_t = 0x00000010;
2495pub const CS7: ::tcflag_t = 0x00000020;
2496pub const CS8: ::tcflag_t = 0x00000030;
2497pub const CSTOPB: ::tcflag_t = 0x00000040;
2498pub const CREAD: ::tcflag_t = 0x00000080;
2499pub const PARENB: ::tcflag_t = 0x00000100;
2500pub const PARODD: ::tcflag_t = 0x00000200;
2501pub const HUPCL: ::tcflag_t = 0x00000400;
2502pub const CLOCAL: ::tcflag_t = 0x00000800;
2503pub const ECHOKE: ::tcflag_t = 0x00000800;
2504pub const ECHOE: ::tcflag_t = 0x00000010;
2505pub const ECHOK: ::tcflag_t = 0x00000020;
2506pub const ECHONL: ::tcflag_t = 0x00000040;
2507pub const ECHOPRT: ::tcflag_t = 0x00000400;
2508pub const ECHOCTL: ::tcflag_t = 0x00000200;
2509pub const ISIG: ::tcflag_t = 0x00000001;
2510pub const ICANON: ::tcflag_t = 0x00000002;
2511pub const PENDIN: ::tcflag_t = 0x00004000;
2512pub const NOFLSH: ::tcflag_t = 0x00000080;
2513pub const CIBAUD: ::tcflag_t = 0o02003600000;
2514pub const CBAUDEX: ::tcflag_t = 0o010000;
2515pub const VSWTC: usize = 7;
2516pub const OLCUC: ::tcflag_t = 0o000002;
2517pub const NLDLY: ::tcflag_t = 0o000400;
2518pub const CRDLY: ::tcflag_t = 0o003000;
2519pub const TABDLY: ::tcflag_t = 0o014000;
2520pub const BSDLY: ::tcflag_t = 0o020000;
2521pub const FFDLY: ::tcflag_t = 0o100000;
2522pub const VTDLY: ::tcflag_t = 0o040000;
2523pub const XTABS: ::tcflag_t = 0o014000;
2524
2525pub const B0: ::speed_t = 0o000000;
2526pub const B50: ::speed_t = 0o000001;
2527pub const B75: ::speed_t = 0o000002;
2528pub const B110: ::speed_t = 0o000003;
2529pub const B134: ::speed_t = 0o000004;
2530pub const B150: ::speed_t = 0o000005;
2531pub const B200: ::speed_t = 0o000006;
2532pub const B300: ::speed_t = 0o000007;
2533pub const B600: ::speed_t = 0o000010;
2534pub const B1200: ::speed_t = 0o000011;
2535pub const B1800: ::speed_t = 0o000012;
2536pub const B2400: ::speed_t = 0o000013;
2537pub const B4800: ::speed_t = 0o000014;
2538pub const B9600: ::speed_t = 0o000015;
2539pub const B19200: ::speed_t = 0o000016;
2540pub const B38400: ::speed_t = 0o000017;
2541pub const EXTA: ::speed_t = B19200;
2542pub const EXTB: ::speed_t = B38400;
2543pub const B57600: ::speed_t = 0o010001;
2544pub const B115200: ::speed_t = 0o010002;
2545pub const B230400: ::speed_t = 0o010003;
2546pub const B460800: ::speed_t = 0o010004;
2547pub const B500000: ::speed_t = 0o010005;
2548pub const B576000: ::speed_t = 0o010006;
2549pub const B921600: ::speed_t = 0o010007;
2550pub const B1000000: ::speed_t = 0o010010;
2551pub const B1152000: ::speed_t = 0o010011;
2552pub const B1500000: ::speed_t = 0o010012;
2553pub const B2000000: ::speed_t = 0o010013;
2554pub const B2500000: ::speed_t = 0o010014;
2555pub const B3000000: ::speed_t = 0o010015;
2556pub const B3500000: ::speed_t = 0o010016;
2557pub const B4000000: ::speed_t = 0o010017;
2558
2559pub const SO_BINDTODEVICE: ::c_int = 25;
2560pub const SO_TIMESTAMP: ::c_int = 29;
2561pub const SO_MARK: ::c_int = 36;
2562pub const SO_RXQ_OVFL: ::c_int = 40;
2563pub const SO_PEEK_OFF: ::c_int = 42;
2564pub const SO_BUSY_POLL: ::c_int = 46;
2565
2566pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
2567pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
2568
2569pub const O_ASYNC: ::c_int = 0x00000400;
2570
2571pub const FIOCLEX: ::c_int = 0x5451;
2572pub const FIONBIO: ::c_int = 0x5421;
2573
2574pub const RLIMIT_RSS: ::c_int = 5;
2575pub const RLIMIT_NOFILE: ::c_int = 7;
2576pub const RLIMIT_AS: ::c_int = 9;
2577pub const RLIMIT_NPROC: ::c_int = 6;
2578pub const RLIMIT_MEMLOCK: ::c_int = 8;
2579
2580pub const O_APPEND: ::c_int = 0x00100000;
2581pub const O_CREAT: ::c_int = 0x00010000;
2582pub const O_EXCL: ::c_int = 0x00020000;
2583pub const O_NOCTTY: ::c_int = 0x00000200;
2584pub const O_NONBLOCK: ::c_int = 0x00000010;
2585pub const O_SYNC: ::c_int = (0x00000040 | O_DSYNC);
2586pub const O_RSYNC: ::c_int = O_SYNC;
2587pub const O_DSYNC: ::c_int = 0x00000020;
2588
2589pub const SOCK_NONBLOCK: ::c_int = 2048;
2590
2591pub const MAP_ANON: ::c_int = 0x0020;
2592pub const MAP_GROWSDOWN: ::c_int = 0x0100;
2593pub const MAP_DENYWRITE: ::c_int = 0x0800;
2594pub const MAP_EXECUTABLE: ::c_int = 0x01000;
2595pub const MAP_LOCKED: ::c_int = 0x02000;
2596pub const MAP_NORESERVE: ::c_int = 0x04000;
2597pub const MAP_POPULATE: ::c_int = 0x08000;
2598pub const MAP_NONBLOCK: ::c_int = 0x010000;
2599pub const MAP_STACK: ::c_int = 0x020000;
2600
2601pub const SOCK_STREAM: ::c_int = 1;
2602pub const SOCK_DGRAM: ::c_int = 2;
2603pub const SOCK_SEQPACKET: ::c_int = 5;
2604
2605pub const SOL_SOCKET: ::c_int = 1;
2606
2607pub const EDEADLK: ::c_int = 35;
2608pub const ENAMETOOLONG: ::c_int = 36;
2609pub const ENOLCK: ::c_int = 37;
2610pub const ENOSYS: ::c_int = 38;
2611pub const ENOTEMPTY: ::c_int = 39;
2612pub const ELOOP: ::c_int = 40;
2613pub const ENOMSG: ::c_int = 42;
2614pub const EIDRM: ::c_int = 43;
2615pub const ECHRNG: ::c_int = 44;
2616pub const EL2NSYNC: ::c_int = 45;
2617pub const EL3HLT: ::c_int = 46;
2618pub const EL3RST: ::c_int = 47;
2619pub const ELNRNG: ::c_int = 48;
2620pub const EUNATCH: ::c_int = 49;
2621pub const ENOCSI: ::c_int = 50;
2622pub const EL2HLT: ::c_int = 51;
2623pub const EBADE: ::c_int = 52;
2624pub const EBADR: ::c_int = 53;
2625pub const EXFULL: ::c_int = 54;
2626pub const ENOANO: ::c_int = 55;
2627pub const EBADRQC: ::c_int = 56;
2628pub const EBADSLT: ::c_int = 57;
2629pub const EDEADLOCK: ::c_int = EDEADLK;
2630pub const EMULTIHOP: ::c_int = 72;
2631pub const EBADMSG: ::c_int = 74;
2632pub const EOVERFLOW: ::c_int = 75;
2633pub const ENOTUNIQ: ::c_int = 76;
2634pub const EBADFD: ::c_int = 77;
2635pub const EREMCHG: ::c_int = 78;
2636pub const ELIBACC: ::c_int = 79;
2637pub const ELIBBAD: ::c_int = 80;
2638pub const ELIBSCN: ::c_int = 81;
2639pub const ELIBMAX: ::c_int = 82;
2640pub const ELIBEXEC: ::c_int = 83;
2641pub const EILSEQ: ::c_int = 84;
2642pub const ERESTART: ::c_int = 85;
2643pub const ESTRPIPE: ::c_int = 86;
2644pub const EUSERS: ::c_int = 87;
2645pub const ENOTSOCK: ::c_int = 88;
2646pub const EDESTADDRREQ: ::c_int = 89;
2647pub const EMSGSIZE: ::c_int = 90;
2648pub const EPROTOTYPE: ::c_int = 91;
2649pub const ENOPROTOOPT: ::c_int = 92;
2650pub const EPROTONOSUPPORT: ::c_int = 93;
2651pub const ESOCKTNOSUPPORT: ::c_int = 94;
2652pub const EOPNOTSUPP: ::c_int = 95;
2653pub const ENOTSUP: ::c_int = EOPNOTSUPP;
2654pub const EPFNOSUPPORT: ::c_int = 96;
2655pub const EAFNOSUPPORT: ::c_int = 97;
2656pub const EADDRINUSE: ::c_int = 98;
2657pub const EADDRNOTAVAIL: ::c_int = 99;
2658pub const ENETDOWN: ::c_int = 100;
2659pub const ENETUNREACH: ::c_int = 101;
2660pub const ENETRESET: ::c_int = 102;
2661pub const ECONNABORTED: ::c_int = 103;
2662pub const ECONNRESET: ::c_int = 104;
2663pub const ENOBUFS: ::c_int = 105;
2664pub const EISCONN: ::c_int = 106;
2665pub const ENOTCONN: ::c_int = 107;
2666pub const ESHUTDOWN: ::c_int = 108;
2667pub const ETOOMANYREFS: ::c_int = 109;
2668pub const ETIMEDOUT: ::c_int = 110;
2669pub const ECONNREFUSED: ::c_int = 111;
2670pub const EHOSTDOWN: ::c_int = 112;
2671pub const EHOSTUNREACH: ::c_int = 113;
2672pub const EALREADY: ::c_int = 114;
2673pub const EINPROGRESS: ::c_int = 115;
2674pub const ESTALE: ::c_int = 116;
2675pub const EUCLEAN: ::c_int = 117;
2676pub const ENOTNAM: ::c_int = 118;
2677pub const ENAVAIL: ::c_int = 119;
2678pub const EISNAM: ::c_int = 120;
2679pub const EREMOTEIO: ::c_int = 121;
2680pub const EDQUOT: ::c_int = 122;
2681pub const ENOMEDIUM: ::c_int = 123;
2682pub const EMEDIUMTYPE: ::c_int = 124;
2683pub const ECANCELED: ::c_int = 125;
2684pub const ENOKEY: ::c_int = 126;
2685pub const EKEYEXPIRED: ::c_int = 127;
2686pub const EKEYREVOKED: ::c_int = 128;
2687pub const EKEYREJECTED: ::c_int = 129;
2688pub const EOWNERDEAD: ::c_int = 130;
2689pub const ENOTRECOVERABLE: ::c_int = 131;
2690pub const ERFKILL: ::c_int = 132;
2691pub const EHWPOISON: ::c_int = 133;
2692
2693pub const SO_REUSEADDR: ::c_int = 2;
2694pub const SO_TYPE: ::c_int = 3;
2695pub const SO_ERROR: ::c_int = 4;
2696pub const SO_DONTROUTE: ::c_int = 5;
2697pub const SO_BROADCAST: ::c_int = 6;
2698pub const SO_SNDBUF: ::c_int = 7;
2699pub const SO_RCVBUF: ::c_int = 8;
2700pub const SO_KEEPALIVE: ::c_int = 9;
2701pub const SO_OOBINLINE: ::c_int = 10;
2702pub const SO_NO_CHECK: ::c_int = 11;
2703pub const SO_PRIORITY: ::c_int = 12;
2704pub const SO_LINGER: ::c_int = 13;
2705pub const SO_BSDCOMPAT: ::c_int = 14;
2706pub const SO_REUSEPORT: ::c_int = 15;
2707pub const SO_PASSCRED: ::c_int = 16;
2708pub const SO_PEERCRED: ::c_int = 17;
2709pub const SO_RCVLOWAT: ::c_int = 18;
2710pub const SO_SNDLOWAT: ::c_int = 19;
2711pub const SO_RCVTIMEO: ::c_int = 20;
2712pub const SO_SNDTIMEO: ::c_int = 21;
2713pub const SO_ACCEPTCONN: ::c_int = 30;
2714pub const SO_SNDBUFFORCE: ::c_int = 32;
2715pub const SO_RCVBUFFORCE: ::c_int = 33;
2716pub const SO_PROTOCOL: ::c_int = 38;
2717pub const SO_DOMAIN: ::c_int = 39;
2718
2719pub const SA_ONSTACK: ::c_int = 0x08000000;
2720pub const SA_SIGINFO: ::c_int = 0x00000004;
2721pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
2722
2723pub const SIGCHLD: ::c_int = 17;
2724pub const SIGBUS: ::c_int = 7;
2725pub const SIGTTIN: ::c_int = 21;
2726pub const SIGTTOU: ::c_int = 22;
2727pub const SIGXCPU: ::c_int = 24;
2728pub const SIGXFSZ: ::c_int = 25;
2729pub const SIGVTALRM: ::c_int = 26;
2730pub const SIGPROF: ::c_int = 27;
2731pub const SIGWINCH: ::c_int = 28;
2732pub const SIGUSR1: ::c_int = 10;
2733pub const SIGUSR2: ::c_int = 12;
2734pub const SIGCONT: ::c_int = 18;
2735pub const SIGSTOP: ::c_int = 19;
2736pub const SIGTSTP: ::c_int = 20;
2737pub const SIGURG: ::c_int = 23;
2738pub const SIGIO: ::c_int = 29;
2739pub const SIGSYS: ::c_int = 31;
2740pub const SIGSTKFLT: ::c_int = 16;
2741pub const SIGPOLL: ::c_int = 29;
2742pub const SIGPWR: ::c_int = 30;
2743pub const SIG_SETMASK: ::c_int = 2;
2744pub const SIG_BLOCK: ::c_int = 0x000000;
2745pub const SIG_UNBLOCK: ::c_int = 0x01;
2746
2747pub const EXTPROC: ::tcflag_t = 0x00010000;
2748
2749pub const MAP_HUGETLB: ::c_int = 0x040000;
2750
2751pub const F_GETLK: ::c_int = 5;
2752pub const F_GETOWN: ::c_int = 9;
2753pub const F_SETLK: ::c_int = 6;
2754pub const F_SETLKW: ::c_int = 7;
2755pub const F_SETOWN: ::c_int = 8;
2756
2757pub const VEOF: usize = 4;
2758pub const VEOL: usize = 11;
2759pub const VEOL2: usize = 16;
2760pub const VMIN: usize = 6;
2761pub const IEXTEN: ::tcflag_t = 0x00008000;
2762pub const TOSTOP: ::tcflag_t = 0x00000100;
2763pub const FLUSHO: ::tcflag_t = 0x00001000;
2764
2765pub const TCGETS: ::c_int = 0x5401;
2766pub const TCSETS: ::c_int = 0x5402;
2767pub const TCSETSW: ::c_int = 0x5403;
2768pub const TCSETSF: ::c_int = 0x5404;
2769pub const TCGETA: ::c_int = 0x5405;
2770pub const TCSETA: ::c_int = 0x5406;
2771pub const TCSETAW: ::c_int = 0x5407;
2772pub const TCSETAF: ::c_int = 0x5408;
2773pub const TCSBRK: ::c_int = 0x5409;
2774pub const TCXONC: ::c_int = 0x540A;
2775pub const TCFLSH: ::c_int = 0x540B;
2776pub const TIOCGSOFTCAR: ::c_int = 0x5419;
2777pub const TIOCSSOFTCAR: ::c_int = 0x541A;
2778pub const TIOCLINUX: ::c_int = 0x541C;
2779pub const TIOCGSERIAL: ::c_int = 0x541E;
2780pub const TIOCEXCL: ::c_int = 0x540C;
2781pub const TIOCNXCL: ::c_int = 0x540D;
2782pub const TIOCSCTTY: ::c_int = 0x540E;
2783pub const TIOCGPGRP: ::c_int = 0x540F;
2784pub const TIOCSPGRP: ::c_int = 0x5410;
2785pub const TIOCOUTQ: ::c_int = 0x5411;
2786pub const TIOCSTI: ::c_int = 0x5412;
2787pub const TIOCGWINSZ: ::c_int = 0x5413;
2788pub const TIOCSWINSZ: ::c_int = 0x5414;
2789pub const TIOCMGET: ::c_int = 0x5415;
2790pub const TIOCMBIS: ::c_int = 0x5416;
2791pub const TIOCMBIC: ::c_int = 0x5417;
2792pub const TIOCMSET: ::c_int = 0x5418;
2793pub const FIONREAD: ::c_int = 0x541B;
2794pub const TIOCCONS: ::c_int = 0x541D;
2795
2796pub const POLLWRNORM: ::c_short = 0x100;
2797pub const POLLWRBAND: ::c_short = 0x200;
2798
2799pub const TIOCM_LE: ::c_int = 0x001;
2800pub const TIOCM_DTR: ::c_int = 0x002;
2801pub const TIOCM_RTS: ::c_int = 0x004;
2802pub const TIOCM_ST: ::c_int = 0x008;
2803pub const TIOCM_SR: ::c_int = 0x010;
2804pub const TIOCM_CTS: ::c_int = 0x020;
2805pub const TIOCM_CAR: ::c_int = 0x040;
2806pub const TIOCM_RNG: ::c_int = 0x080;
2807pub const TIOCM_DSR: ::c_int = 0x100;
2808pub const TIOCM_CD: ::c_int = TIOCM_CAR;
2809pub const TIOCM_RI: ::c_int = TIOCM_RNG;
2810
2811pub const O_DIRECTORY: ::c_int = 0x00080000;
2812pub const O_DIRECT: ::c_int = 0x00000800;
2813pub const O_LARGEFILE: ::c_int = 0x00001000;
2814pub const O_NOFOLLOW: ::c_int = 0x00000080;
2815
2816// intentionally not public, only used for fd_set
2817cfg_if! {
2818 if #[cfg(target_pointer_width = "32")] {
2819 const ULONG_SIZE: usize = 32;
2820 } else if #[cfg(target_pointer_width = "64")] {
2821 const ULONG_SIZE: usize = 64;
2822 } else {
2823 // Unknown target_pointer_width
2824 }
2825}
2826
2827// END_PUB_CONST
2828
Taylor Cramerf7f9be32017-11-15 10:22:26 -08002829f! {
Taylor Cramerb4cfe882017-11-15 11:29:01 -08002830 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
2831 let fd = fd as usize;
2832 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
2833 (*set).fds_bits[fd / size] &= !(1 << (fd % size));
2834 return
2835 }
2836
2837 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
2838 let fd = fd as usize;
2839 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
2840 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
2841 }
2842
2843 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
2844 let fd = fd as usize;
2845 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
2846 (*set).fds_bits[fd / size] |= 1 << (fd % size);
2847 return
2848 }
2849
2850 pub fn FD_ZERO(set: *mut fd_set) -> () {
2851 for slot in (*set).fds_bits.iter_mut() {
2852 *slot = 0;
2853 }
2854 }
2855
2856 pub fn WIFSTOPPED(status: ::c_int) -> bool {
2857 (status & 0xff) == 0x7f
2858 }
2859
2860 pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
2861 (status >> 8) & 0xff
2862 }
2863
2864 pub fn WIFCONTINUED(status: ::c_int) -> bool {
2865 status == 0xffff
2866 }
2867
2868 pub fn WIFSIGNALED(status: ::c_int) -> bool {
2869 ((status & 0x7f) + 1) as i8 >= 2
2870 }
2871
2872 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
2873 status & 0x7f
2874 }
2875
2876 pub fn WIFEXITED(status: ::c_int) -> bool {
2877 (status & 0x7f) == 0
2878 }
2879
2880 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
2881 (status >> 8) & 0xff
2882 }
2883
2884 pub fn WCOREDUMP(status: ::c_int) -> bool {
2885 (status & 0x80) != 0
2886 }
2887
2888 pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
2889 (cmd << 8) | (type_ & 0x00ff)
2890 }
2891
Taylor Cramerf7f9be32017-11-15 10:22:26 -08002892 pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
2893 for slot in cpuset.bits.iter_mut() {
2894 *slot = 0;
2895 }
2896 }
2897
2898 pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
2899 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
2900 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
2901 cpuset.bits[idx] |= 1 << offset;
2902 ()
2903 }
2904
2905 pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
2906 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
2907 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
2908 cpuset.bits[idx] &= !(1 << offset);
2909 ()
2910 }
2911
2912 pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
2913 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
2914 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
2915 0 != (cpuset.bits[idx] & (1 << offset))
2916 }
2917
2918 pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
2919 set1.bits == set2.bits
2920 }
2921
2922 pub fn major(dev: ::dev_t) -> ::c_uint {
2923 let mut major = 0;
2924 major |= (dev & 0x00000000000fff00) >> 8;
2925 major |= (dev & 0xfffff00000000000) >> 32;
2926 major as ::c_uint
2927 }
2928
2929 pub fn minor(dev: ::dev_t) -> ::c_uint {
2930 let mut minor = 0;
2931 minor |= (dev & 0x00000000000000ff) >> 0;
2932 minor |= (dev & 0x00000ffffff00000) >> 12;
2933 minor as ::c_uint
2934 }
2935
2936 pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
2937 let major = major as ::dev_t;
2938 let minor = minor as ::dev_t;
2939 let mut dev = 0;
2940 dev |= (major & 0x00000fff) << 8;
2941 dev |= (major & 0xfffff000) << 32;
2942 dev |= (minor & 0x000000ff) << 0;
2943 dev |= (minor & 0xffffff00) << 12;
2944 dev
2945 }
2946}
2947
Taylor Cramerb4cfe882017-11-15 11:29:01 -08002948// EXTERN_FN
2949
2950#[link(name = "c")]
2951#[link(name = "fdio")]
2952extern {}
2953
Bryant Mairsfa9cb782019-01-23 07:18:32 -08002954#[cfg_attr(feature = "extra_traits", derive(Debug))]
gnzlbg5c1a6b82018-11-21 20:34:50 +01002955pub enum FILE {}
Bryant Mairsf3684582019-01-23 07:23:09 -08002956impl ::dox::Copy for FILE {}
2957impl ::dox::Clone for FILE {
2958 fn clone(&self) -> FILE { *self }
2959}
Bryant Mairsfa9cb782019-01-23 07:18:32 -08002960#[cfg_attr(feature = "extra_traits", derive(Debug))]
gnzlbg5c1a6b82018-11-21 20:34:50 +01002961pub enum fpos_t {} // TODO: fill this out with a struct
Bryant Mairsf3684582019-01-23 07:23:09 -08002962impl ::dox::Copy for fpos_t {}
2963impl ::dox::Clone for fpos_t {
2964 fn clone(&self) -> fpos_t { *self }
2965}
gnzlbg5c1a6b82018-11-21 20:34:50 +01002966
Taylor Cramerf7f9be32017-11-15 10:22:26 -08002967extern {
gnzlbg5c1a6b82018-11-21 20:34:50 +01002968 pub fn isalnum(c: c_int) -> c_int;
2969 pub fn isalpha(c: c_int) -> c_int;
2970 pub fn iscntrl(c: c_int) -> c_int;
2971 pub fn isdigit(c: c_int) -> c_int;
2972 pub fn isgraph(c: c_int) -> c_int;
2973 pub fn islower(c: c_int) -> c_int;
2974 pub fn isprint(c: c_int) -> c_int;
2975 pub fn ispunct(c: c_int) -> c_int;
2976 pub fn isspace(c: c_int) -> c_int;
2977 pub fn isupper(c: c_int) -> c_int;
2978 pub fn isxdigit(c: c_int) -> c_int;
2979 pub fn tolower(c: c_int) -> c_int;
2980 pub fn toupper(c: c_int) -> c_int;
2981 pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
2982 pub fn freopen(filename: *const c_char, mode: *const c_char,
2983 file: *mut FILE) -> *mut FILE;
2984 pub fn fflush(file: *mut FILE) -> c_int;
2985 pub fn fclose(file: *mut FILE) -> c_int;
2986 pub fn remove(filename: *const c_char) -> c_int;
2987 pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
2988 pub fn tmpfile() -> *mut FILE;
2989 pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int,
2990 size: size_t) -> c_int;
2991 pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
2992 pub fn getchar() -> c_int;
2993 pub fn putchar(c: c_int) -> c_int;
2994 pub fn fgetc(stream: *mut FILE) -> c_int;
2995 pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
2996 pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
2997 pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
2998 pub fn puts(s: *const c_char) -> c_int;
2999 pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
3000 pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t,
3001 stream: *mut FILE) -> size_t;
3002 pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t,
3003 stream: *mut FILE) -> size_t;
3004 pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
3005 pub fn ftell(stream: *mut FILE) -> c_long;
3006 pub fn rewind(stream: *mut FILE);
3007 pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
3008 pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
3009 pub fn feof(stream: *mut FILE) -> c_int;
3010 pub fn ferror(stream: *mut FILE) -> c_int;
3011 pub fn perror(s: *const c_char);
3012 pub fn atoi(s: *const c_char) -> c_int;
3013 pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
3014 pub fn strtol(s: *const c_char, endp: *mut *mut c_char,
3015 base: c_int) -> c_long;
3016 pub fn strtoul(s: *const c_char, endp: *mut *mut c_char,
3017 base: c_int) -> c_ulong;
3018 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
3019 pub fn malloc(size: size_t) -> *mut c_void;
3020 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
3021 pub fn free(p: *mut c_void);
3022 pub fn abort() -> !;
3023 pub fn exit(status: c_int) -> !;
3024 pub fn _exit(status: c_int) -> !;
3025 pub fn atexit(cb: extern fn()) -> c_int;
3026 pub fn system(s: *const c_char) -> c_int;
3027 pub fn getenv(s: *const c_char) -> *mut c_char;
3028
3029 pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
3030 pub fn strncpy(dst: *mut c_char, src: *const c_char,
3031 n: size_t) -> *mut c_char;
3032 pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
3033 pub fn strncat(s: *mut c_char, ct: *const c_char,
3034 n: size_t) -> *mut c_char;
3035 pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
3036 pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
3037 pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
3038 pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
3039 pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
3040 pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
3041 pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
3042 pub fn strdup(cs: *const c_char) -> *mut c_char;
3043 pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
3044 pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
3045 pub fn strlen(cs: *const c_char) -> size_t;
3046 pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
3047 pub fn strerror(n: c_int) -> *mut c_char;
3048 pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
3049 pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
3050 pub fn wcslen(buf: *const wchar_t) -> size_t;
3051 pub fn wcstombs(dest: *mut c_char, src: *const wchar_t,
3052 n: size_t) -> ::size_t;
3053
3054 pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
3055 pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
3056 pub fn memcpy(dest: *mut c_void, src: *const c_void,
3057 n: size_t) -> *mut c_void;
3058 pub fn memmove(dest: *mut c_void, src: *const c_void,
3059 n: size_t) -> *mut c_void;
3060 pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
3061
3062 pub fn abs(i: c_int) -> c_int;
3063 pub fn atof(s: *const c_char) -> c_double;
3064 pub fn labs(i: c_long) -> c_long;
3065 pub fn rand() -> c_int;
3066 pub fn srand(seed: c_uint);
3067
Taylor Cramerb4cfe882017-11-15 11:29:01 -08003068 pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
3069 pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
3070
3071 pub fn fprintf(stream: *mut ::FILE,
3072 format: *const ::c_char, ...) -> ::c_int;
3073 pub fn printf(format: *const ::c_char, ...) -> ::c_int;
3074 pub fn snprintf(s: *mut ::c_char, n: ::size_t,
3075 format: *const ::c_char, ...) -> ::c_int;
3076 pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
3077 pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
3078 pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
3079 pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
3080 pub fn getchar_unlocked() -> ::c_int;
3081 pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
3082
3083 pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
3084 pub fn connect(socket: ::c_int, address: *const sockaddr,
3085 len: socklen_t) -> ::c_int;
3086 pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
3087 pub fn accept(socket: ::c_int, address: *mut sockaddr,
3088 address_len: *mut socklen_t) -> ::c_int;
3089 pub fn getpeername(socket: ::c_int, address: *mut sockaddr,
3090 address_len: *mut socklen_t) -> ::c_int;
3091 pub fn getsockname(socket: ::c_int, address: *mut sockaddr,
3092 address_len: *mut socklen_t) -> ::c_int;
3093 pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int,
3094 value: *const ::c_void,
3095 option_len: socklen_t) -> ::c_int;
3096 pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int,
3097 socket_vector: *mut ::c_int) -> ::c_int;
3098 pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
3099 flags: ::c_int, addr: *const sockaddr,
3100 addrlen: socklen_t) -> ::ssize_t;
3101 pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
3102
3103 pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
3104 pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
3105
3106 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
3107
3108 pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
3109
3110 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
3111
3112 pub fn pclose(stream: *mut ::FILE) -> ::c_int;
3113 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
3114 pub fn fileno(stream: *mut ::FILE) -> ::c_int;
3115
3116 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
3117 pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
3118 pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
3119
3120 pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
3121 pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
3122 pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
3123 result: *mut *mut ::dirent) -> ::c_int;
3124 pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
3125 pub fn rewinddir(dirp: *mut ::DIR);
3126
3127 pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
3128 flags: ::c_int, ...) -> ::c_int;
3129 pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char,
3130 mode: ::mode_t, flags: ::c_int) -> ::c_int;
3131 pub fn fchown(fd: ::c_int,
3132 owner: ::uid_t,
3133 group: ::gid_t) -> ::c_int;
3134 pub fn fchownat(dirfd: ::c_int, pathname: *const ::c_char,
3135 owner: ::uid_t, group: ::gid_t,
3136 flags: ::c_int) -> ::c_int;
3137 pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char,
3138 buf: *mut stat, flags: ::c_int) -> ::c_int;
3139 pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char,
3140 newdirfd: ::c_int, newpath: *const ::c_char,
3141 flags: ::c_int) -> ::c_int;
3142 pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
3143 mode: ::mode_t) -> ::c_int;
3144 pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char,
3145 buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t;
3146 pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char,
3147 newdirfd: ::c_int, newpath: *const ::c_char)
3148 -> ::c_int;
3149 pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int,
3150 linkpath: *const ::c_char) -> ::c_int;
3151 pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char,
3152 flags: ::c_int) -> ::c_int;
3153
3154 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
3155 pub fn alarm(seconds: ::c_uint) -> ::c_uint;
3156 pub fn chdir(dir: *const c_char) -> ::c_int;
3157 pub fn fchdir(dirfd: ::c_int) -> ::c_int;
3158 pub fn chown(path: *const c_char, uid: uid_t,
3159 gid: gid_t) -> ::c_int;
3160 pub fn lchown(path: *const c_char, uid: uid_t,
3161 gid: gid_t) -> ::c_int;
3162 pub fn close(fd: ::c_int) -> ::c_int;
3163 pub fn dup(fd: ::c_int) -> ::c_int;
3164 pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
3165 pub fn execl(path: *const c_char,
3166 arg0: *const c_char, ...) -> ::c_int;
3167 pub fn execle(path: *const ::c_char,
3168 arg0: *const ::c_char, ...) -> ::c_int;
3169 pub fn execlp(file: *const ::c_char,
3170 arg0: *const ::c_char, ...) -> ::c_int;
3171 pub fn execv(prog: *const c_char,
3172 argv: *const *const c_char) -> ::c_int;
3173 pub fn execve(prog: *const c_char, argv: *const *const c_char,
3174 envp: *const *const c_char)
3175 -> ::c_int;
3176 pub fn execvp(c: *const c_char,
3177 argv: *const *const c_char) -> ::c_int;
3178 pub fn fork() -> pid_t;
3179 pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
3180 pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
3181 pub fn getegid() -> gid_t;
3182 pub fn geteuid() -> uid_t;
3183 pub fn getgid() -> gid_t;
3184 pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t)
3185 -> ::c_int;
3186 pub fn getlogin() -> *mut c_char;
3187 pub fn getopt(argc: ::c_int, argv: *const *mut c_char,
3188 optstr: *const c_char) -> ::c_int;
3189 pub fn getpgid(pid: pid_t) -> pid_t;
3190 pub fn getpgrp() -> pid_t;
3191 pub fn getpid() -> pid_t;
3192 pub fn getppid() -> pid_t;
3193 pub fn getuid() -> uid_t;
3194 pub fn isatty(fd: ::c_int) -> ::c_int;
3195 pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
3196 pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
3197 pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
3198 pub fn pause() -> ::c_int;
3199 pub fn pipe(fds: *mut ::c_int) -> ::c_int;
3200 pub fn posix_memalign(memptr: *mut *mut ::c_void,
3201 align: ::size_t,
3202 size: ::size_t) -> ::c_int;
3203 pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
3204 -> ::ssize_t;
3205 pub fn rmdir(path: *const c_char) -> ::c_int;
3206 pub fn seteuid(uid: uid_t) -> ::c_int;
xd0096421604cf52018-12-05 17:46:50 +00003207 pub fn setegid(gid: gid_t) -> ::c_int;
Taylor Cramerb4cfe882017-11-15 11:29:01 -08003208 pub fn setgid(gid: gid_t) -> ::c_int;
3209 pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
3210 pub fn setsid() -> pid_t;
3211 pub fn setuid(uid: uid_t) -> ::c_int;
3212 pub fn sleep(secs: ::c_uint) -> ::c_uint;
3213 pub fn nanosleep(rqtp: *const timespec,
3214 rmtp: *mut timespec) -> ::c_int;
3215 pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
3216 pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
3217 pub fn ttyname(fd: ::c_int) -> *mut c_char;
3218 pub fn unlink(c: *const c_char) -> ::c_int;
3219 pub fn wait(status: *mut ::c_int) -> pid_t;
3220 pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
3221 -> pid_t;
3222 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
3223 -> ::ssize_t;
3224 pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
3225 offset: off_t) -> ::ssize_t;
3226 pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
3227 offset: off_t) -> ::ssize_t;
3228 pub fn umask(mask: mode_t) -> mode_t;
3229
3230 pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
3231
3232 pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
3233
3234 pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
3235 pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
3236 pub fn mlockall(flags: ::c_int) -> ::c_int;
3237 pub fn munlockall() -> ::c_int;
3238
3239 pub fn mmap(addr: *mut ::c_void,
3240 len: ::size_t,
3241 prot: ::c_int,
3242 flags: ::c_int,
3243 fd: ::c_int,
3244 offset: off_t)
3245 -> *mut ::c_void;
3246 pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
3247
3248 pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
3249 pub fn if_indextoname(ifindex: ::c_uint,
3250 ifname: *mut ::c_char) -> *mut ::c_char;
3251
3252 pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
3253
3254 pub fn fsync(fd: ::c_int) -> ::c_int;
3255
3256 pub fn setenv(name: *const c_char, val: *const c_char,
3257 overwrite: ::c_int) -> ::c_int;
3258 pub fn unsetenv(name: *const c_char) -> ::c_int;
3259
3260 pub fn symlink(path1: *const c_char,
3261 path2: *const c_char) -> ::c_int;
3262
3263 pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
3264
3265 pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
3266
3267 pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int;
3268 pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int;
3269 pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
3270
3271 pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
3272 -> *mut ::c_char;
3273
3274 pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
3275
3276 pub fn gettimeofday(tp: *mut ::timeval,
3277 tz: *mut ::c_void) -> ::c_int;
3278 pub fn times(buf: *mut ::tms) -> ::clock_t;
3279
3280 pub fn pthread_self() -> ::pthread_t;
3281 pub fn pthread_join(native: ::pthread_t,
3282 value: *mut *mut ::c_void) -> ::c_int;
3283 pub fn pthread_exit(value: *mut ::c_void);
3284 pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
3285 pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
3286 pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t,
3287 stack_size: ::size_t) -> ::c_int;
3288 pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t,
3289 state: ::c_int) -> ::c_int;
3290 pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
3291 pub fn sched_yield() -> ::c_int;
3292 pub fn pthread_key_create(key: *mut pthread_key_t,
3293 dtor: Option<unsafe extern fn(*mut ::c_void)>)
3294 -> ::c_int;
3295 pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
3296 pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
3297 pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void)
3298 -> ::c_int;
3299 pub fn pthread_mutex_init(lock: *mut pthread_mutex_t,
3300 attr: *const pthread_mutexattr_t) -> ::c_int;
3301 pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
3302 pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
3303 pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
3304 pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
3305
3306 pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
3307 pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
3308 pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
3309 _type: ::c_int) -> ::c_int;
3310
3311 pub fn pthread_cond_init(cond: *mut pthread_cond_t,
3312 attr: *const pthread_condattr_t) -> ::c_int;
3313 pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
3314 lock: *mut pthread_mutex_t) -> ::c_int;
3315 pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t,
3316 lock: *mut pthread_mutex_t,
3317 abstime: *const ::timespec) -> ::c_int;
3318 pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
3319 pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
3320 pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
3321 pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
3322 pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
3323 pub fn pthread_rwlock_init(lock: *mut pthread_rwlock_t,
3324 attr: *const pthread_rwlockattr_t) -> ::c_int;
3325 pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
3326 pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
3327 pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
3328 pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
3329 pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
3330 pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
3331 pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int;
3332 pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t)
3333 -> ::c_int;
3334 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
3335 buflen: ::size_t) -> ::c_int;
3336
3337 pub fn getsockopt(sockfd: ::c_int,
3338 level: ::c_int,
3339 optname: ::c_int,
3340 optval: *mut ::c_void,
3341 optlen: *mut ::socklen_t) -> ::c_int;
3342 pub fn raise(signum: ::c_int) -> ::c_int;
3343 pub fn sigaction(signum: ::c_int,
3344 act: *const sigaction,
3345 oldact: *mut sigaction) -> ::c_int;
3346
3347 pub fn utimes(filename: *const ::c_char,
3348 times: *const ::timeval) -> ::c_int;
3349 pub fn dlopen(filename: *const ::c_char,
3350 flag: ::c_int) -> *mut ::c_void;
3351 pub fn dlerror() -> *mut ::c_char;
3352 pub fn dlsym(handle: *mut ::c_void,
3353 symbol: *const ::c_char) -> *mut ::c_void;
3354 pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
3355 pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
3356
3357 pub fn getaddrinfo(node: *const c_char,
3358 service: *const c_char,
3359 hints: *const addrinfo,
3360 res: *mut *mut addrinfo) -> ::c_int;
3361 pub fn freeaddrinfo(res: *mut addrinfo);
3362 pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
3363 pub fn res_init() -> ::c_int;
3364
3365 pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
3366 pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
3367 pub fn mktime(tm: *mut tm) -> time_t;
3368 pub fn time(time: *mut time_t) -> time_t;
3369 pub fn gmtime(time_p: *const time_t) -> *mut tm;
3370 pub fn localtime(time_p: *const time_t) -> *mut tm;
3371
3372 pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
3373 dev: ::dev_t) -> ::c_int;
3374 pub fn uname(buf: *mut ::utsname) -> ::c_int;
3375 pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
3376 pub fn getservbyname(name: *const ::c_char,
3377 proto: *const ::c_char) -> *mut servent;
3378 pub fn getprotobyname(name: *const ::c_char) -> *mut protoent;
3379 pub fn getprotobynumber(proto: ::c_int) -> *mut protoent;
3380 pub fn chroot(name: *const ::c_char) -> ::c_int;
3381 pub fn usleep(secs: ::c_uint) -> ::c_int;
3382 pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
3383 flags: ::c_int) -> ::ssize_t;
3384 pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
3385 flags: ::c_int) -> ::ssize_t;
3386 pub fn putenv(string: *mut c_char) -> ::c_int;
3387 pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
3388 pub fn select(nfds: ::c_int,
3389 readfs: *mut fd_set,
3390 writefds: *mut fd_set,
3391 errorfds: *mut fd_set,
3392 timeout: *mut timeval) -> ::c_int;
3393 pub fn setlocale(category: ::c_int,
3394 locale: *const ::c_char) -> *mut ::c_char;
3395 pub fn localeconv() -> *mut lconv;
3396
3397 pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
3398 pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
3399 pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
3400 pub fn sem_post(sem: *mut sem_t) -> ::c_int;
3401 pub fn sem_init(sem: *mut sem_t,
3402 pshared: ::c_int,
3403 value: ::c_uint)
3404 -> ::c_int;
3405 pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
3406 pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
3407
3408 pub fn readlink(path: *const c_char,
3409 buf: *mut c_char,
3410 bufsz: ::size_t)
3411 -> ::ssize_t;
3412
3413 pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
3414 pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
3415 pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
3416 pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
3417 pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
3418
3419 pub fn sigprocmask(how: ::c_int,
3420 set: *const sigset_t,
3421 oldset: *mut sigset_t)
3422 -> ::c_int;
3423 pub fn sigpending(set: *mut sigset_t) -> ::c_int;
3424
3425 pub fn timegm(tm: *mut ::tm) -> time_t;
3426
3427 pub fn getsid(pid: pid_t) -> pid_t;
3428
3429 pub fn sysconf(name: ::c_int) -> ::c_long;
3430
3431 pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
3432
3433 pub fn pselect(nfds: ::c_int,
3434 readfs: *mut fd_set,
3435 writefds: *mut fd_set,
3436 errorfds: *mut fd_set,
3437 timeout: *const timespec,
3438 sigmask: *const sigset_t) -> ::c_int;
3439 pub fn fseeko(stream: *mut ::FILE,
3440 offset: ::off_t,
3441 whence: ::c_int) -> ::c_int;
3442 pub fn ftello(stream: *mut ::FILE) -> ::off_t;
3443 pub fn tcdrain(fd: ::c_int) -> ::c_int;
3444 pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
3445 pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
3446 pub fn cfmakeraw(termios: *mut ::termios);
3447 pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
3448 pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
3449 pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
3450 pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
3451 pub fn tcsetattr(fd: ::c_int,
3452 optional_actions: ::c_int,
3453 termios: *const ::termios) -> ::c_int;
3454 pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
3455 pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
3456 pub fn tcgetsid(fd: ::c_int) -> ::pid_t;
3457 pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
3458 pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
3459 pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
3460
3461 pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char;
3462
3463 pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
3464 pub fn closelog();
3465 pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
3466 pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
3467 pub fn nice(incr: ::c_int) -> ::c_int;
3468
3469 pub fn grantpt(fd: ::c_int) -> ::c_int;
3470 pub fn posix_openpt(flags: ::c_int) -> ::c_int;
3471 pub fn ptsname(fd: ::c_int) -> *mut ::c_char;
3472 pub fn unlockpt(fd: ::c_int) -> ::c_int;
3473
3474 pub fn fdatasync(fd: ::c_int) -> ::c_int;
3475 pub fn mincore(addr: *mut ::c_void, len: ::size_t,
3476 vec: *mut ::c_uchar) -> ::c_int;
3477 pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
3478 pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
3479 pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
3480 pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
3481
3482 pub fn pthread_getattr_np(native: ::pthread_t,
3483 attr: *mut ::pthread_attr_t) -> ::c_int;
3484 pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
3485 stackaddr: *mut *mut ::c_void,
3486 stacksize: *mut ::size_t) -> ::c_int;
3487 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
3488 pub fn setgroups(ngroups: ::size_t,
3489 ptr: *const ::gid_t) -> ::c_int;
3490 pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
3491 pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
3492 pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int;
3493 pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
3494 pub fn fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int;
3495 pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int;
3496 pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int;
3497 pub fn memrchr(cx: *const ::c_void,
3498 c: ::c_int,
3499 n: ::size_t) -> *mut ::c_void;
3500
3501 pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
3502 advise: ::c_int) -> ::c_int;
3503 pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
3504 pub fn utimensat(dirfd: ::c_int, path: *const ::c_char,
3505 times: *const ::timespec, flag: ::c_int) -> ::c_int;
3506 pub fn duplocale(base: ::locale_t) -> ::locale_t;
3507 pub fn freelocale(loc: ::locale_t);
3508 pub fn newlocale(mask: ::c_int,
3509 locale: *const ::c_char,
3510 base: ::locale_t) -> ::locale_t;
3511 pub fn uselocale(loc: ::locale_t) -> ::locale_t;
3512 pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int;
3513 pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int;
3514 pub fn fstatat64(dirfd: ::c_int, pathname: *const c_char,
3515 buf: *mut stat64, flags: ::c_int) -> ::c_int;
3516 pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int;
3517 pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int;
3518 pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t;
3519 pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
3520 pub fn mmap64(addr: *mut ::c_void,
3521 len: ::size_t,
3522 prot: ::c_int,
3523 flags: ::c_int,
3524 fd: ::c_int,
3525 offset: off64_t)
3526 -> *mut ::c_void;
3527 pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
3528 pub fn openat64(fd: ::c_int,
3529 path: *const c_char,
3530 oflag: ::c_int, ...) -> ::c_int;
3531 pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
3532 offset: off64_t) -> ::ssize_t;
3533 pub fn preadv64(fd: ::c_int,
3534 iov: *const ::iovec,
3535 iovcnt: ::c_int,
3536 offset: ::off64_t) -> ::ssize_t;
3537 pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
3538 offset: off64_t) -> ::ssize_t;
3539 pub fn pwritev64(fd: ::c_int,
3540 iov: *const ::iovec,
3541 iovcnt: ::c_int,
3542 offset: ::off64_t) -> ::ssize_t;
3543 pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
3544 pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64,
3545 result: *mut *mut ::dirent64) -> ::c_int;
3546 pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
3547 pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
3548 pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int;
3549
3550 pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
3551
3552 pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char,
3553 mode: ::mode_t, dev: dev_t) -> ::c_int;
3554 pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t,
3555 clock_id: *mut clockid_t) -> ::c_int;
3556 pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
3557 clock_id: ::clockid_t) -> ::c_int;
3558 pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t,
3559 pshared: ::c_int) -> ::c_int;
3560 pub fn accept4(fd: ::c_int, addr: *mut ::sockaddr, len: *mut ::socklen_t,
3561 flg: ::c_int) -> ::c_int;
3562 pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t,
3563 pshared: ::c_int) -> ::c_int;
3564 pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t,
3565 val: *mut ::c_int) -> ::c_int;
3566 pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t,
3567 val: ::c_int) -> ::c_int;
3568 pub fn ptsname_r(fd: ::c_int,
3569 buf: *mut ::c_char,
3570 buflen: ::size_t) -> ::c_int;
3571 pub fn clearenv() -> ::c_int;
3572 pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
3573 options: ::c_int) -> ::c_int;
3574 pub fn setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int;
3575 pub fn setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int;
3576 pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t,
3577 suid: *mut ::uid_t) -> ::c_int;
3578 pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t,
3579 sgid: *mut ::gid_t) -> ::c_int;
3580 pub fn acct(filename: *const ::c_char) -> ::c_int;
3581 pub fn brk(addr: *mut ::c_void) -> ::c_int;
3582 pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
3583 pub fn vfork() -> ::pid_t;
3584 pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
3585 pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
3586 pub fn wait4(pid: ::pid_t, status: *mut ::c_int, options: ::c_int,
3587 rusage: *mut ::rusage) -> ::pid_t;
3588 pub fn openpty(amaster: *mut ::c_int,
3589 aslave: *mut ::c_int,
3590 name: *mut ::c_char,
3591 termp: *const termios,
3592 winp: *const ::winsize) -> ::c_int;
3593 pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char,
3594 envp: *const *const ::c_char) -> ::c_int;
3595 pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
3596 envp: *const *const ::c_char)
3597 -> ::c_int;
3598
3599 pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
3600 pub fn ptrace(request: ::c_int, ...) -> ::c_long;
3601 pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
3602 pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
3603
Taylor Cramerf7f9be32017-11-15 10:22:26 -08003604 pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
3605 pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
3606 pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
3607 pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
3608 pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
3609 pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int,
3610 timeout: *const ::timespec) -> ::c_int;
3611 pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
3612 pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
3613 nitems: ::c_int, sevp: *mut ::sigevent) -> ::c_int;
3614
3615 pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
3616
3617 pub fn setpwent();
3618 pub fn endpwent();
3619 pub fn getpwent() -> *mut passwd;
3620 pub fn setspent();
3621 pub fn endspent();
3622 pub fn getspent() -> *mut spwd;
3623 pub fn getspnam(__name: *const ::c_char) -> *mut spwd;
3624
3625 pub fn shm_open(name: *const c_char, oflag: ::c_int,
3626 mode: mode_t) -> ::c_int;
3627
3628 // System V IPC
3629 pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
3630 pub fn shmat(shmid: ::c_int,
3631 shmaddr: *const ::c_void,
3632 shmflg: ::c_int) -> *mut ::c_void;
3633 pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
3634 pub fn shmctl(shmid: ::c_int,
3635 cmd: ::c_int,
3636 buf: *mut ::shmid_ds) -> ::c_int;
3637 pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
3638 pub fn semget(key: ::key_t, nsems: ::c_int, semflag: ::c_int) -> ::c_int;
3639 pub fn semop(semid: ::c_int,
3640 sops: *mut ::sembuf, nsops: ::size_t) -> ::c_int;
3641 pub fn semctl(semid: ::c_int,
3642 semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int;
3643 pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int;
3644 pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
3645 pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
3646 msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
3647 pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
3648 msgflg: ::c_int) -> ::c_int;
3649
3650 pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
3651 -> ::c_int;
3652 pub fn __errno_location() -> *mut ::c_int;
3653
3654 pub fn fopen64(filename: *const c_char,
3655 mode: *const c_char) -> *mut ::FILE;
3656 pub fn freopen64(filename: *const c_char, mode: *const c_char,
3657 file: *mut ::FILE) -> *mut ::FILE;
3658 pub fn tmpfile64() -> *mut ::FILE;
3659 pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
3660 pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
3661 pub fn fseeko64(stream: *mut ::FILE,
3662 offset: ::off64_t,
3663 whence: ::c_int) -> ::c_int;
3664 pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
3665 pub fn fallocate(fd: ::c_int, mode: ::c_int,
3666 offset: ::off_t, len: ::off_t) -> ::c_int;
3667 pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
3668 len: ::off_t) -> ::c_int;
3669 pub fn readahead(fd: ::c_int, offset: ::off64_t,
3670 count: ::size_t) -> ::ssize_t;
3671 pub fn getxattr(path: *const c_char, name: *const c_char,
3672 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
3673 pub fn lgetxattr(path: *const c_char, name: *const c_char,
3674 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
3675 pub fn fgetxattr(filedes: ::c_int, name: *const c_char,
3676 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
3677 pub fn setxattr(path: *const c_char, name: *const c_char,
3678 value: *const ::c_void, size: ::size_t,
3679 flags: ::c_int) -> ::c_int;
3680 pub fn lsetxattr(path: *const c_char, name: *const c_char,
3681 value: *const ::c_void, size: ::size_t,
3682 flags: ::c_int) -> ::c_int;
3683 pub fn fsetxattr(filedes: ::c_int, name: *const c_char,
3684 value: *const ::c_void, size: ::size_t,
3685 flags: ::c_int) -> ::c_int;
3686 pub fn listxattr(path: *const c_char, list: *mut c_char,
3687 size: ::size_t) -> ::ssize_t;
3688 pub fn llistxattr(path: *const c_char, list: *mut c_char,
3689 size: ::size_t) -> ::ssize_t;
3690 pub fn flistxattr(filedes: ::c_int, list: *mut c_char,
3691 size: ::size_t) -> ::ssize_t;
3692 pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
3693 pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
3694 pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
3695 pub fn signalfd(fd: ::c_int,
3696 mask: *const ::sigset_t,
3697 flags: ::c_int) -> ::c_int;
3698 pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int;
3699 pub fn timerfd_gettime(fd: ::c_int,
3700 curr_value: *mut itimerspec) -> ::c_int;
3701 pub fn timerfd_settime(fd: ::c_int,
3702 flags: ::c_int,
3703 new_value: *const itimerspec,
3704 old_value: *mut itimerspec) -> ::c_int;
3705 pub fn pwritev(fd: ::c_int,
3706 iov: *const ::iovec,
3707 iovcnt: ::c_int,
3708 offset: ::off_t) -> ::ssize_t;
3709 pub fn preadv(fd: ::c_int,
3710 iov: *const ::iovec,
3711 iovcnt: ::c_int,
3712 offset: ::off_t) -> ::ssize_t;
3713 pub fn quotactl(cmd: ::c_int,
3714 special: *const ::c_char,
3715 id: ::c_int,
3716 data: *mut ::c_char) -> ::c_int;
3717 pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
3718 pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
3719 pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
3720 pub fn mq_receive(mqd: ::mqd_t,
3721 msg_ptr: *mut ::c_char,
3722 msg_len: ::size_t,
3723 msq_prio: *mut ::c_uint) -> ::ssize_t;
3724 pub fn mq_send(mqd: ::mqd_t,
3725 msg_ptr: *const ::c_char,
3726 msg_len: ::size_t,
3727 msq_prio: ::c_uint) -> ::c_int;
3728 pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
3729 pub fn mq_setattr(mqd: ::mqd_t,
3730 newattr: *const ::mq_attr,
3731 oldattr: *mut ::mq_attr) -> ::c_int;
3732 pub fn epoll_pwait(epfd: ::c_int,
3733 events: *mut ::epoll_event,
3734 maxevents: ::c_int,
3735 timeout: ::c_int,
3736 sigmask: *const ::sigset_t) -> ::c_int;
3737 pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
3738 pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
3739 pub fn mkostemps(template: *mut ::c_char,
3740 suffixlen: ::c_int,
3741 flags: ::c_int) -> ::c_int;
3742 pub fn sigtimedwait(set: *const sigset_t,
3743 info: *mut siginfo_t,
3744 timeout: *const ::timespec) -> ::c_int;
3745 pub fn sigwaitinfo(set: *const sigset_t,
3746 info: *mut siginfo_t) -> ::c_int;
3747 pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
3748 pub fn getnameinfo(sa: *const ::sockaddr,
3749 salen: ::socklen_t,
3750 host: *mut ::c_char,
3751 hostlen: ::socklen_t,
3752 serv: *mut ::c_char,
3753 sevlen: ::socklen_t,
3754 flags: ::c_int) -> ::c_int;
3755 pub fn pthread_setschedprio(native: ::pthread_t,
3756 priority: ::c_int) -> ::c_int;
3757 pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit,
3758 old_limit: *mut ::rlimit) -> ::c_int;
3759 pub fn prlimit64(pid: ::pid_t,
3760 resource: ::c_int,
3761 new_limit: *const ::rlimit64,
3762 old_limit: *mut ::rlimit64) -> ::c_int;
3763 pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
3764 pub fn process_vm_readv(pid: ::pid_t,
3765 local_iov: *const ::iovec,
3766 liovcnt: ::c_ulong,
3767 remote_iov: *const ::iovec,
3768 riovcnt: ::c_ulong,
3769 flags: ::c_ulong) -> isize;
3770 pub fn process_vm_writev(pid: ::pid_t,
3771 local_iov: *const ::iovec,
3772 liovcnt: ::c_ulong,
3773 remote_iov: *const ::iovec,
3774 riovcnt: ::c_ulong,
3775 flags: ::c_ulong) -> isize;
3776 pub fn reboot(how_to: ::c_int) -> ::c_int;
3777 pub fn setfsgid(gid: ::gid_t) -> ::c_int;
3778 pub fn setfsuid(uid: ::uid_t) -> ::c_int;
3779
3780 // Not available now on Android
3781 pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
3782 mode: ::mode_t) -> ::c_int;
3783 pub fn if_nameindex() -> *mut if_nameindex;
3784 pub fn if_freenameindex(ptr: *mut if_nameindex);
3785 pub fn sync_file_range(fd: ::c_int, offset: ::off64_t,
3786 nbytes: ::off64_t, flags: ::c_uint) -> ::c_int;
3787 pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
3788 pub fn freeifaddrs(ifa: *mut ::ifaddrs);
3789
3790 pub fn mremap(addr: *mut ::c_void,
3791 len: ::size_t,
3792 new_len: ::size_t,
3793 flags: ::c_int,
3794 ...) -> *mut ::c_void;
3795
3796 pub fn glob(pattern: *const c_char,
3797 flags: ::c_int,
3798 errfunc: Option<extern fn(epath: *const c_char,
3799 errno: ::c_int) -> ::c_int>,
3800 pglob: *mut ::glob_t) -> ::c_int;
3801 pub fn globfree(pglob: *mut ::glob_t);
3802
3803 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
3804 -> ::c_int;
3805
3806 pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
3807
3808 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
3809
3810 pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
3811 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
3812 -> ::c_int;
3813
3814 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
3815
3816 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
3817 flags: ::c_int, addr: *mut ::sockaddr,
3818 addrlen: *mut ::socklen_t) -> ::ssize_t;
3819 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
3820 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
3821 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
3822
3823 pub fn bind(socket: ::c_int, address: *const ::sockaddr,
3824 address_len: ::socklen_t) -> ::c_int;
3825
3826 pub fn writev(fd: ::c_int,
3827 iov: *const ::iovec,
3828 iovcnt: ::c_int) -> ::ssize_t;
3829 pub fn readv(fd: ::c_int,
3830 iov: *const ::iovec,
3831 iovcnt: ::c_int) -> ::ssize_t;
3832
3833 pub fn sendmsg(fd: ::c_int,
3834 msg: *const ::msghdr,
3835 flags: ::c_int) -> ::ssize_t;
3836 pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
3837 -> ::ssize_t;
3838 pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
3839 pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
3840 pub fn vhangup() -> ::c_int;
3841 pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
3842 flags: ::c_int) -> ::c_int;
3843 pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
3844 flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
3845 pub fn sync();
3846 pub fn syscall(num: ::c_long, ...) -> ::c_long;
3847 pub fn sched_getaffinity(pid: ::pid_t,
3848 cpusetsize: ::size_t,
3849 cpuset: *mut cpu_set_t) -> ::c_int;
3850 pub fn sched_setaffinity(pid: ::pid_t,
3851 cpusetsize: ::size_t,
3852 cpuset: *const cpu_set_t) -> ::c_int;
3853 pub fn epoll_create(size: ::c_int) -> ::c_int;
3854 pub fn epoll_create1(flags: ::c_int) -> ::c_int;
3855 pub fn epoll_wait(epfd: ::c_int,
3856 events: *mut ::epoll_event,
3857 maxevents: ::c_int,
3858 timeout: ::c_int) -> ::c_int;
3859 pub fn epoll_ctl(epfd: ::c_int,
3860 op: ::c_int,
3861 fd: ::c_int,
3862 event: *mut ::epoll_event) -> ::c_int;
3863 pub fn pthread_getschedparam(native: ::pthread_t,
3864 policy: *mut ::c_int,
3865 param: *mut ::sched_param) -> ::c_int;
3866 pub fn unshare(flags: ::c_int) -> ::c_int;
3867 pub fn umount(target: *const ::c_char) -> ::c_int;
3868 pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
3869 pub fn tee(fd_in: ::c_int,
3870 fd_out: ::c_int,
3871 len: ::size_t,
3872 flags: ::c_uint) -> ::ssize_t;
3873 pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int;
3874 pub fn splice(fd_in: ::c_int,
3875 off_in: *mut ::loff_t,
3876 fd_out: ::c_int,
3877 off_out: *mut ::loff_t,
3878 len: ::size_t,
3879 flags: ::c_uint) -> ::ssize_t;
3880 pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
3881 pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int;
3882 pub fn sem_timedwait(sem: *mut sem_t,
3883 abstime: *const ::timespec) -> ::c_int;
Jason Longshore18ff6832018-05-10 11:04:14 -05003884 pub fn sem_getvalue(sem: *mut sem_t,
3885 sval: *mut ::c_int) -> ::c_int;
Taylor Cramerf7f9be32017-11-15 10:22:26 -08003886 pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int;
3887 pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int;
3888 pub fn swapoff(puath: *const ::c_char) -> ::c_int;
3889 pub fn vmsplice(fd: ::c_int,
3890 iov: *const ::iovec,
3891 nr_segs: ::size_t,
3892 flags: ::c_uint) -> ::ssize_t;
3893 pub fn mount(src: *const ::c_char,
3894 target: *const ::c_char,
3895 fstype: *const ::c_char,
3896 flags: ::c_ulong,
3897 data: *const ::c_void) -> ::c_int;
3898 pub fn personality(persona: ::c_ulong) -> ::c_int;
3899 pub fn prctl(option: ::c_int, ...) -> ::c_int;
3900 pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;
3901 pub fn ppoll(fds: *mut ::pollfd,
3902 nfds: nfds_t,
3903 timeout: *const ::timespec,
3904 sigmask: *const sigset_t) -> ::c_int;
3905 pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
3906 abstime: *const ::timespec) -> ::c_int;
3907 pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
3908 child_stack: *mut ::c_void,
3909 flags: ::c_int,
3910 arg: *mut ::c_void, ...) -> ::c_int;
3911 pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
3912 pub fn clock_nanosleep(clk_id: ::clockid_t,
3913 flags: ::c_int,
3914 rqtp: *const ::timespec,
3915 rmtp: *mut ::timespec) -> ::c_int;
3916 pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
3917 guardsize: *mut ::size_t) -> ::c_int;
3918 pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
3919 pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
3920 pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
3921 pshared: *mut ::c_int) -> ::c_int;
3922 pub fn sysinfo(info: *mut ::sysinfo) -> ::c_int;
3923 pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
3924 pub fn pthread_setschedparam(native: ::pthread_t,
3925 policy: ::c_int,
3926 param: *const ::sched_param) -> ::c_int;
3927 pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int;
3928 pub fn sched_setscheduler(pid: ::pid_t,
3929 policy: ::c_int,
3930 param: *const ::sched_param) -> ::c_int;
3931 pub fn sendfile(out_fd: ::c_int,
3932 in_fd: ::c_int,
3933 offset: *mut off_t,
3934 count: ::size_t) -> ::ssize_t;
3935 pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
3936 pub fn getgrgid_r(uid: ::uid_t,
3937 grp: *mut ::group,
3938 buf: *mut ::c_char,
3939 buflen: ::size_t,
3940 result: *mut *mut ::group) -> ::c_int;
3941 pub fn sigaltstack(ss: *const stack_t,
3942 oss: *mut stack_t) -> ::c_int;
3943 pub fn sem_close(sem: *mut sem_t) -> ::c_int;
3944 pub fn getdtablesize() -> ::c_int;
3945 pub fn getgrnam_r(name: *const ::c_char,
3946 grp: *mut ::group,
3947 buf: *mut ::c_char,
3948 buflen: ::size_t,
3949 result: *mut *mut ::group) -> ::c_int;
3950 pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int;
3951 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
3952 oldset: *mut sigset_t) -> ::c_int;
3953 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
3954 pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
3955 pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
3956 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
3957 pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
3958 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
3959 pub fn getpwnam_r(name: *const ::c_char,
3960 pwd: *mut passwd,
3961 buf: *mut ::c_char,
3962 buflen: ::size_t,
3963 result: *mut *mut passwd) -> ::c_int;
3964 pub fn getpwuid_r(uid: ::uid_t,
3965 pwd: *mut passwd,
3966 buf: *mut ::c_char,
3967 buflen: ::size_t,
3968 result: *mut *mut passwd) -> ::c_int;
3969 pub fn sigwait(set: *const sigset_t,
3970 sig: *mut ::c_int) -> ::c_int;
3971 pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
3972 parent: Option<unsafe extern fn()>,
3973 child: Option<unsafe extern fn()>) -> ::c_int;
3974 pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
3975 pub fn getgrouplist(user: *const ::c_char,
3976 group: ::gid_t,
3977 groups: *mut ::gid_t,
3978 ngroups: *mut ::c_int) -> ::c_int;
3979 pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t,
3980 pshared: *mut ::c_int) -> ::c_int;
3981 pub fn popen(command: *const c_char,
3982 mode: *const c_char) -> *mut ::FILE;
3983 pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
3984 mode: ::c_int, flags: ::c_int) -> ::c_int;
3985 pub fn pthread_create(native: *mut ::pthread_t,
3986 attr: *const ::pthread_attr_t,
3987 f: extern fn(*mut ::c_void) -> *mut ::c_void,
3988 value: *mut ::c_void) -> ::c_int;
3989 pub fn dl_iterate_phdr(
3990 callback: Option<unsafe extern fn(
3991 info: *mut ::dl_phdr_info,
3992 size: ::size_t,
3993 data: *mut ::c_void
3994 ) -> ::c_int>,
3995 data: *mut ::c_void
3996 ) -> ::c_int;
3997}
3998
Taylor Cramerf7f9be32017-11-15 10:22:26 -08003999cfg_if! {
4000 if #[cfg(target_arch = "aarch64")] {
4001 mod aarch64;
4002 pub use self::aarch64::*;
Taylor Cramerf7f9be32017-11-15 10:22:26 -08004003 } else if #[cfg(any(target_arch = "x86_64"))] {
4004 mod x86_64;
4005 pub use self::x86_64::*;
4006 } else {
4007 // Unknown target_arch
4008 }
4009}
gnzlbg5c1a6b82018-11-21 20:34:50 +01004010
4011cfg_if! {
gnzlbga17a91c2019-02-07 11:37:21 +01004012 if #[cfg(libc_align)] {
4013 #[macro_use]
4014 mod align;
4015 } else {
4016 #[macro_use]
4017 mod no_align;
4018 }
4019}
4020expand_align!();
4021
4022cfg_if! {
4023 if #[cfg(libc_core_cvoid)] {
4024 pub use ::ffi::c_void;
gnzlbg5c1a6b82018-11-21 20:34:50 +01004025 } else {
4026 // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
4027 // enable more optimization opportunities around it recognizing things
4028 // like malloc/free.
4029 #[repr(u8)]
Bryant Mairsf3684582019-01-23 07:23:09 -08004030 #[allow(missing_copy_implementations)]
gnzlbga17a91c2019-02-07 11:37:21 +01004031 #[allow(missing_debug_implementations)]
gnzlbg5c1a6b82018-11-21 20:34:50 +01004032 pub enum c_void {
4033 // Two dummy variants so the #[repr] attribute can be used.
4034 #[doc(hidden)]
4035 __variant1,
4036 #[doc(hidden)]
4037 __variant2,
4038 }
4039 }
4040}