xref: /third_party/rust/crates/libc/src/unix/redox/mod.rs (revision 2add0d91)
1pub type c_char = i8;
2pub type wchar_t = i32;
3
4cfg_if! {
5    if #[cfg(target_pointer_width = "32")] {
6        pub type c_long = i32;
7        pub type c_ulong = u32;
8    }
9}
10
11cfg_if! {
12    if #[cfg(target_pointer_width = "64")] {
13        pub type c_long = i64;
14        pub type c_ulong = u64;
15    }
16}
17
18pub type blkcnt_t = ::c_ulong;
19pub type blksize_t = ::c_long;
20pub type clock_t = ::c_long;
21pub type clockid_t = ::c_int;
22pub type dev_t = ::c_long;
23pub type fsblkcnt_t = ::c_ulong;
24pub type fsfilcnt_t = ::c_ulong;
25pub type ino_t = ::c_ulong;
26pub type mode_t = ::c_int;
27pub type nfds_t = ::c_ulong;
28pub type nlink_t = ::c_ulong;
29pub type off_t = ::c_longlong;
30pub type pthread_t = *mut ::c_void;
31pub type pthread_attr_t = *mut ::c_void;
32pub type pthread_cond_t = *mut ::c_void;
33pub type pthread_condattr_t = *mut ::c_void;
34// Must be usize due to libstd/sys_common/thread_local.rs,
35// should technically be *mut ::c_void
36pub type pthread_key_t = usize;
37pub type pthread_mutex_t = *mut ::c_void;
38pub type pthread_mutexattr_t = *mut ::c_void;
39pub type pthread_rwlock_t = *mut ::c_void;
40pub type pthread_rwlockattr_t = *mut ::c_void;
41pub type rlim_t = ::c_ulonglong;
42pub type sa_family_t = u16;
43pub type sem_t = *mut ::c_void;
44pub type sigset_t = ::c_ulong;
45pub type socklen_t = u32;
46pub type speed_t = u32;
47pub type suseconds_t = ::c_int;
48pub type tcflag_t = u32;
49pub type time_t = ::c_longlong;
50
51#[cfg_attr(feature = "extra_traits", derive(Debug))]
52pub enum timezone {}
53impl ::Copy for timezone {}
54impl ::Clone for timezone {
55    fn clone(&self) -> timezone {
56        *self
57    }
58}
59
60s_no_extra_traits! {
61    #[repr(C)]
62    pub struct utsname {
63        pub sysname: [::c_char; UTSLENGTH],
64        pub nodename: [::c_char; UTSLENGTH],
65        pub release: [::c_char; UTSLENGTH],
66        pub version: [::c_char; UTSLENGTH],
67        pub machine: [::c_char; UTSLENGTH],
68        pub domainname: [::c_char; UTSLENGTH],
69    }
70
71    pub struct dirent {
72        pub d_ino: ::ino_t,
73        pub d_off: ::off_t,
74        pub d_reclen: ::c_ushort,
75        pub d_type: ::c_uchar,
76        pub d_name: [::c_char; 256],
77    }
78
79    pub struct sockaddr_un {
80        pub sun_family: ::sa_family_t,
81        pub sun_path: [::c_char; 108]
82    }
83
84    pub struct sockaddr_storage {
85        pub ss_family: ::sa_family_t,
86        __ss_padding: [
87            u8;
88            128 -
89            ::core::mem::size_of::<sa_family_t>() -
90            ::core::mem::size_of::<c_ulong>()
91        ],
92        __ss_align: ::c_ulong,
93    }
94}
95
96s! {
97    pub struct addrinfo {
98        pub ai_flags: ::c_int,
99        pub ai_family: ::c_int,
100        pub ai_socktype: ::c_int,
101        pub ai_protocol: ::c_int,
102        pub ai_addrlen: ::size_t,
103        pub ai_canonname: *mut ::c_char,
104        pub ai_addr: *mut ::sockaddr,
105        pub ai_next: *mut ::addrinfo,
106    }
107
108    pub struct Dl_info {
109        pub dli_fname: *const ::c_char,
110        pub dli_fbase: *mut ::c_void,
111        pub dli_sname: *const ::c_char,
112        pub dli_saddr: *mut ::c_void,
113    }
114
115    pub struct epoll_event {
116        pub events: u32,
117        pub u64: u64,
118        pub _pad: u64,
119    }
120
121    pub struct fd_set {
122        fds_bits: [::c_ulong; ::FD_SETSIZE / ULONG_SIZE],
123    }
124
125    pub struct in_addr {
126        pub s_addr: ::in_addr_t,
127    }
128
129    pub struct ip_mreq {
130        pub imr_multiaddr: ::in_addr,
131        pub imr_interface: ::in_addr,
132    }
133
134    pub struct lconv {
135        pub currency_symbol: *const ::c_char,
136        pub decimal_point: *const ::c_char,
137        pub frac_digits: ::c_char,
138        pub grouping: *const ::c_char,
139        pub int_curr_symbol: *const ::c_char,
140        pub int_frac_digits: ::c_char,
141        pub mon_decimal_point: *const ::c_char,
142        pub mon_grouping: *const ::c_char,
143        pub mon_thousands_sep: *const ::c_char,
144        pub negative_sign: *const ::c_char,
145        pub n_cs_precedes: ::c_char,
146        pub n_sep_by_space: ::c_char,
147        pub n_sign_posn: ::c_char,
148        pub positive_sign: *const ::c_char,
149        pub p_cs_precedes: ::c_char,
150        pub p_sep_by_space: ::c_char,
151        pub p_sign_posn: ::c_char,
152        pub thousands_sep: *const ::c_char,
153    }
154
155    pub struct passwd {
156        pub pw_name: *mut ::c_char,
157        pub pw_passwd: *mut ::c_char,
158        pub pw_uid: ::uid_t,
159        pub pw_gid: ::gid_t,
160        pub pw_gecos: *mut ::c_char,
161        pub pw_dir: *mut ::c_char,
162        pub pw_shell: *mut ::c_char,
163    }
164
165    pub struct sigaction {
166        pub sa_sigaction: ::sighandler_t,
167        pub sa_flags: ::c_ulong,
168        pub sa_restorer: ::Option<extern fn()>,
169        pub sa_mask: ::sigset_t,
170    }
171
172    pub struct siginfo_t {
173        pub si_signo: ::c_int,
174        pub si_errno: ::c_int,
175        pub si_code: ::c_int,
176        _pad: [::c_int; 29],
177        _align: [usize; 0],
178    }
179
180    pub struct sockaddr {
181        pub sa_family: ::sa_family_t,
182        pub sa_data: [::c_char; 14],
183    }
184
185    pub struct sockaddr_in {
186        pub sin_family: ::sa_family_t,
187        pub sin_port: ::in_port_t,
188        pub sin_addr: ::in_addr,
189        pub sin_zero: [::c_char; 8],
190    }
191
192    pub struct sockaddr_in6 {
193        pub sin6_family: ::sa_family_t,
194        pub sin6_port: ::in_port_t,
195        pub sin6_flowinfo: u32,
196        pub sin6_addr: ::in6_addr,
197        pub sin6_scope_id: u32,
198    }
199
200    pub struct stat {
201        pub st_dev: ::dev_t,
202        pub st_ino: ::ino_t,
203        pub st_nlink: ::nlink_t,
204        pub st_mode: ::mode_t,
205        pub st_uid: ::uid_t,
206        pub st_gid: ::gid_t,
207        pub st_rdev: ::dev_t,
208        pub st_size: ::off_t,
209        pub st_blksize: ::blksize_t,
210        pub st_blocks: ::blkcnt_t,
211        pub st_atime: ::time_t,
212        pub st_atime_nsec: ::c_long,
213        pub st_mtime: ::time_t,
214        pub st_mtime_nsec: ::c_long,
215        pub st_ctime: ::time_t,
216        pub st_ctime_nsec: ::c_long,
217        _pad: [::c_char; 24],
218    }
219
220    pub struct statvfs {
221        pub f_bsize: ::c_ulong,
222        pub f_frsize: ::c_ulong,
223        pub f_blocks: ::fsblkcnt_t,
224        pub f_bfree: ::fsblkcnt_t,
225        pub f_bavail: ::fsblkcnt_t,
226        pub f_files: ::fsfilcnt_t,
227        pub f_ffree: ::fsfilcnt_t,
228        pub f_favail: ::fsfilcnt_t,
229        pub f_fsid: ::c_ulong,
230        pub f_flag: ::c_ulong,
231        pub f_namemax: ::c_ulong,
232    }
233
234    pub struct termios {
235        pub c_iflag: ::tcflag_t,
236        pub c_oflag: ::tcflag_t,
237        pub c_cflag: ::tcflag_t,
238        pub c_lflag: ::tcflag_t,
239        pub c_line: ::cc_t,
240        pub c_cc: [::cc_t; ::NCCS],
241        pub c_ispeed: ::speed_t,
242        pub c_ospeed: ::speed_t,
243    }
244
245    pub struct tm {
246        pub tm_sec: ::c_int,
247        pub tm_min: ::c_int,
248        pub tm_hour: ::c_int,
249        pub tm_mday: ::c_int,
250        pub tm_mon: ::c_int,
251        pub tm_year: ::c_int,
252        pub tm_wday: ::c_int,
253        pub tm_yday: ::c_int,
254        pub tm_isdst: ::c_int,
255        pub tm_gmtoff: ::c_long,
256        pub tm_zone: *const ::c_char,
257    }
258}
259
260pub const UTSLENGTH: usize = 65;
261
262// intentionally not public, only used for fd_set
263cfg_if! {
264    if #[cfg(target_pointer_width = "32")] {
265        const ULONG_SIZE: usize = 32;
266    } else if #[cfg(target_pointer_width = "64")] {
267        const ULONG_SIZE: usize = 64;
268    } else {
269        // Unknown target_pointer_width
270    }
271}
272
273// limits.h
274pub const PATH_MAX: ::c_int = 4096;
275
276// fcntl.h
277pub const F_GETLK: ::c_int = 5;
278pub const F_SETLK: ::c_int = 6;
279pub const F_SETLKW: ::c_int = 7;
280
281// FIXME: relibc {
282pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
283// }
284
285// dlfcn.h
286pub const RTLD_LAZY: ::c_int = 0x0001;
287pub const RTLD_NOW: ::c_int = 0x0002;
288pub const RTLD_GLOBAL: ::c_int = 0x0100;
289pub const RTLD_LOCAL: ::c_int = 0x0000;
290
291// errno.h
292pub const EPERM: ::c_int = 1; /* Operation not permitted */
293pub const ENOENT: ::c_int = 2; /* No such file or directory */
294pub const ESRCH: ::c_int = 3; /* No such process */
295pub const EINTR: ::c_int = 4; /* Interrupted system call */
296pub const EIO: ::c_int = 5; /* I/O error */
297pub const ENXIO: ::c_int = 6; /* No such device or address */
298pub const E2BIG: ::c_int = 7; /* Argument list too long */
299pub const ENOEXEC: ::c_int = 8; /* Exec format error */
300pub const EBADF: ::c_int = 9; /* Bad file number */
301pub const ECHILD: ::c_int = 10; /* No child processes */
302pub const EAGAIN: ::c_int = 11; /* Try again */
303pub const ENOMEM: ::c_int = 12; /* Out of memory */
304pub const EACCES: ::c_int = 13; /* Permission denied */
305pub const EFAULT: ::c_int = 14; /* Bad address */
306pub const ENOTBLK: ::c_int = 15; /* Block device required */
307pub const EBUSY: ::c_int = 16; /* Device or resource busy */
308pub const EEXIST: ::c_int = 17; /* File exists */
309pub const EXDEV: ::c_int = 18; /* Cross-device link */
310pub const ENODEV: ::c_int = 19; /* No such device */
311pub const ENOTDIR: ::c_int = 20; /* Not a directory */
312pub const EISDIR: ::c_int = 21; /* Is a directory */
313pub const EINVAL: ::c_int = 22; /* Invalid argument */
314pub const ENFILE: ::c_int = 23; /* File table overflow */
315pub const EMFILE: ::c_int = 24; /* Too many open files */
316pub const ENOTTY: ::c_int = 25; /* Not a typewriter */
317pub const ETXTBSY: ::c_int = 26; /* Text file busy */
318pub const EFBIG: ::c_int = 27; /* File too large */
319pub const ENOSPC: ::c_int = 28; /* No space left on device */
320pub const ESPIPE: ::c_int = 29; /* Illegal seek */
321pub const EROFS: ::c_int = 30; /* Read-only file system */
322pub const EMLINK: ::c_int = 31; /* Too many links */
323pub const EPIPE: ::c_int = 32; /* Broken pipe */
324pub const EDOM: ::c_int = 33; /* Math argument out of domain of func */
325pub const ERANGE: ::c_int = 34; /* Math result not representable */
326pub const EDEADLK: ::c_int = 35; /* Resource deadlock would occur */
327pub const ENAMETOOLONG: ::c_int = 36; /* File name too long */
328pub const ENOLCK: ::c_int = 37; /* No record locks available */
329pub const ENOSYS: ::c_int = 38; /* Function not implemented */
330pub const ENOTEMPTY: ::c_int = 39; /* Directory not empty */
331pub const ELOOP: ::c_int = 40; /* Too many symbolic links encountered */
332pub const EWOULDBLOCK: ::c_int = 41; /* Operation would block */
333pub const ENOMSG: ::c_int = 42; /* No message of desired type */
334pub const EIDRM: ::c_int = 43; /* Identifier removed */
335pub const ECHRNG: ::c_int = 44; /* Channel number out of range */
336pub const EL2NSYNC: ::c_int = 45; /* Level 2 not synchronized */
337pub const EL3HLT: ::c_int = 46; /* Level 3 halted */
338pub const EL3RST: ::c_int = 47; /* Level 3 reset */
339pub const ELNRNG: ::c_int = 48; /* Link number out of range */
340pub const EUNATCH: ::c_int = 49; /* Protocol driver not attached */
341pub const ENOCSI: ::c_int = 50; /* No CSI structure available */
342pub const EL2HLT: ::c_int = 51; /* Level 2 halted */
343pub const EBADE: ::c_int = 52; /* Invalid exchange */
344pub const EBADR: ::c_int = 53; /* Invalid request descriptor */
345pub const EXFULL: ::c_int = 54; /* Exchange full */
346pub const ENOANO: ::c_int = 55; /* No anode */
347pub const EBADRQC: ::c_int = 56; /* Invalid request code */
348pub const EBADSLT: ::c_int = 57; /* Invalid slot */
349pub const EDEADLOCK: ::c_int = 58; /* Resource deadlock would occur */
350pub const EBFONT: ::c_int = 59; /* Bad font file format */
351pub const ENOSTR: ::c_int = 60; /* Device not a stream */
352pub const ENODATA: ::c_int = 61; /* No data available */
353pub const ETIME: ::c_int = 62; /* Timer expired */
354pub const ENOSR: ::c_int = 63; /* Out of streams resources */
355pub const ENONET: ::c_int = 64; /* Machine is not on the network */
356pub const ENOPKG: ::c_int = 65; /* Package not installed */
357pub const EREMOTE: ::c_int = 66; /* Object is remote */
358pub const ENOLINK: ::c_int = 67; /* Link has been severed */
359pub const EADV: ::c_int = 68; /* Advertise error */
360pub const ESRMNT: ::c_int = 69; /* Srmount error */
361pub const ECOMM: ::c_int = 70; /* Communication error on send */
362pub const EPROTO: ::c_int = 71; /* Protocol error */
363pub const EMULTIHOP: ::c_int = 72; /* Multihop attempted */
364pub const EDOTDOT: ::c_int = 73; /* RFS specific error */
365pub const EBADMSG: ::c_int = 74; /* Not a data message */
366pub const EOVERFLOW: ::c_int = 75; /* Value too large for defined data type */
367pub const ENOTUNIQ: ::c_int = 76; /* Name not unique on network */
368pub const EBADFD: ::c_int = 77; /* File descriptor in bad state */
369pub const EREMCHG: ::c_int = 78; /* Remote address changed */
370pub const ELIBACC: ::c_int = 79; /* Can not access a needed shared library */
371pub const ELIBBAD: ::c_int = 80; /* Accessing a corrupted shared library */
372pub const ELIBSCN: ::c_int = 81; /* .lib section in a.out corrupted */
373/* Attempting to link in too many shared libraries */
374pub const ELIBMAX: ::c_int = 82;
375pub const ELIBEXEC: ::c_int = 83; /* Cannot exec a shared library directly */
376pub const EILSEQ: ::c_int = 84; /* Illegal byte sequence */
377/* Interrupted system call should be restarted */
378pub const ERESTART: ::c_int = 85;
379pub const ESTRPIPE: ::c_int = 86; /* Streams pipe error */
380pub const EUSERS: ::c_int = 87; /* Too many users */
381pub const ENOTSOCK: ::c_int = 88; /* Socket operation on non-socket */
382pub const EDESTADDRREQ: ::c_int = 89; /* Destination address required */
383pub const EMSGSIZE: ::c_int = 90; /* Message too long */
384pub const EPROTOTYPE: ::c_int = 91; /* Protocol wrong type for socket */
385pub const ENOPROTOOPT: ::c_int = 92; /* Protocol not available */
386pub const EPROTONOSUPPORT: ::c_int = 93; /* Protocol not supported */
387pub const ESOCKTNOSUPPORT: ::c_int = 94; /* Socket type not supported */
388/* Operation not supported on transport endpoint */
389pub const EOPNOTSUPP: ::c_int = 95;
390pub const ENOTSUP: ::c_int = EOPNOTSUPP;
391pub const EPFNOSUPPORT: ::c_int = 96; /* Protocol family not supported */
392/* Address family not supported by protocol */
393pub const EAFNOSUPPORT: ::c_int = 97;
394pub const EADDRINUSE: ::c_int = 98; /* Address already in use */
395pub const EADDRNOTAVAIL: ::c_int = 99; /* Cannot assign requested address */
396pub const ENETDOWN: ::c_int = 100; /* Network is down */
397pub const ENETUNREACH: ::c_int = 101; /* Network is unreachable */
398/* Network dropped connection because of reset */
399pub const ENETRESET: ::c_int = 102;
400pub const ECONNABORTED: ::c_int = 103; /* Software caused connection abort */
401pub const ECONNRESET: ::c_int = 104; /* Connection reset by peer */
402pub const ENOBUFS: ::c_int = 105; /* No buffer space available */
403pub const EISCONN: ::c_int = 106; /* Transport endpoint is already connected */
404pub const ENOTCONN: ::c_int = 107; /* Transport endpoint is not connected */
405/* Cannot send after transport endpoint shutdown */
406pub const ESHUTDOWN: ::c_int = 108;
407pub const ETOOMANYREFS: ::c_int = 109; /* Too many references: cannot splice */
408pub const ETIMEDOUT: ::c_int = 110; /* Connection timed out */
409pub const ECONNREFUSED: ::c_int = 111; /* Connection refused */
410pub const EHOSTDOWN: ::c_int = 112; /* Host is down */
411pub const EHOSTUNREACH: ::c_int = 113; /* No route to host */
412pub const EALREADY: ::c_int = 114; /* Operation already in progress */
413pub const EINPROGRESS: ::c_int = 115; /* Operation now in progress */
414pub const ESTALE: ::c_int = 116; /* Stale NFS file handle */
415pub const EUCLEAN: ::c_int = 117; /* Structure needs cleaning */
416pub const ENOTNAM: ::c_int = 118; /* Not a XENIX named type file */
417pub const ENAVAIL: ::c_int = 119; /* No XENIX semaphores available */
418pub const EISNAM: ::c_int = 120; /* Is a named type file */
419pub const EREMOTEIO: ::c_int = 121; /* Remote I/O error */
420pub const EDQUOT: ::c_int = 122; /* Quota exceeded */
421pub const ENOMEDIUM: ::c_int = 123; /* No medium found */
422pub const EMEDIUMTYPE: ::c_int = 124; /* Wrong medium type */
423pub const ECANCELED: ::c_int = 125; /* Operation Canceled */
424pub const ENOKEY: ::c_int = 126; /* Required key not available */
425pub const EKEYEXPIRED: ::c_int = 127; /* Key has expired */
426pub const EKEYREVOKED: ::c_int = 128; /* Key has been revoked */
427pub const EKEYREJECTED: ::c_int = 129; /* Key was rejected by service */
428pub const EOWNERDEAD: ::c_int = 130; /* Owner died */
429pub const ENOTRECOVERABLE: ::c_int = 131; /* State not recoverable */
430
431// fcntl.h
432pub const F_DUPFD: ::c_int = 0;
433pub const F_GETFD: ::c_int = 1;
434pub const F_SETFD: ::c_int = 2;
435pub const F_GETFL: ::c_int = 3;
436pub const F_SETFL: ::c_int = 4;
437// FIXME: relibc {
438pub const F_DUPFD_CLOEXEC: ::c_int = ::F_DUPFD;
439// }
440pub const FD_CLOEXEC: ::c_int = 0x0100_0000;
441pub const O_RDONLY: ::c_int = 0x0001_0000;
442pub const O_WRONLY: ::c_int = 0x0002_0000;
443pub const O_RDWR: ::c_int = 0x0003_0000;
444pub const O_ACCMODE: ::c_int = 0x0003_0000;
445pub const O_NONBLOCK: ::c_int = 0x0004_0000;
446pub const O_APPEND: ::c_int = 0x0008_0000;
447pub const O_SHLOCK: ::c_int = 0x0010_0000;
448pub const O_EXLOCK: ::c_int = 0x0020_0000;
449pub const O_ASYNC: ::c_int = 0x0040_0000;
450pub const O_FSYNC: ::c_int = 0x0080_0000;
451pub const O_CLOEXEC: ::c_int = 0x0100_0000;
452pub const O_CREAT: ::c_int = 0x0200_0000;
453pub const O_TRUNC: ::c_int = 0x0400_0000;
454pub const O_EXCL: ::c_int = 0x0800_0000;
455pub const O_DIRECTORY: ::c_int = 0x1000_0000;
456pub const O_PATH: ::c_int = 0x2000_0000;
457pub const O_SYMLINK: ::c_int = 0x4000_0000;
458// Negative to allow it to be used as int
459// FIXME: Fix negative values missing from includes
460pub const O_NOFOLLOW: ::c_int = -0x8000_0000;
461
462// netdb.h
463pub const AI_PASSIVE: ::c_int = 0x0001;
464pub const AI_CANONNAME: ::c_int = 0x0002;
465pub const AI_NUMERICHOST: ::c_int = 0x0004;
466pub const AI_V4MAPPED: ::c_int = 0x0008;
467pub const AI_ALL: ::c_int = 0x0010;
468pub const AI_ADDRCONFIG: ::c_int = 0x0020;
469pub const AI_NUMERICSERV: ::c_int = 0x0400;
470pub const EAI_BADFLAGS: ::c_int = -1;
471pub const EAI_NONAME: ::c_int = -2;
472pub const EAI_AGAIN: ::c_int = -3;
473pub const EAI_FAIL: ::c_int = -4;
474pub const EAI_NODATA: ::c_int = -5;
475pub const EAI_FAMILY: ::c_int = -6;
476pub const EAI_SOCKTYPE: ::c_int = -7;
477pub const EAI_SERVICE: ::c_int = -8;
478pub const EAI_ADDRFAMILY: ::c_int = -9;
479pub const EAI_MEMORY: ::c_int = -10;
480pub const EAI_SYSTEM: ::c_int = -11;
481pub const EAI_OVERFLOW: ::c_int = -12;
482pub const NI_MAXHOST: ::c_int = 1025;
483pub const NI_MAXSERV: ::c_int = 32;
484pub const NI_NUMERICHOST: ::c_int = 0x0001;
485pub const NI_NUMERICSERV: ::c_int = 0x0002;
486pub const NI_NOFQDN: ::c_int = 0x0004;
487pub const NI_NAMEREQD: ::c_int = 0x0008;
488pub const NI_DGRAM: ::c_int = 0x0010;
489
490// netinet/in.h
491// FIXME: relibc {
492pub const IP_TTL: ::c_int = 2;
493pub const IPV6_UNICAST_HOPS: ::c_int = 16;
494pub const IPV6_MULTICAST_IF: ::c_int = 17;
495pub const IPV6_MULTICAST_HOPS: ::c_int = 18;
496pub const IPV6_MULTICAST_LOOP: ::c_int = 19;
497pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
498pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
499pub const IPV6_V6ONLY: ::c_int = 26;
500pub const IP_MULTICAST_IF: ::c_int = 32;
501pub const IP_MULTICAST_TTL: ::c_int = 33;
502pub const IP_MULTICAST_LOOP: ::c_int = 34;
503pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
504pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
505// }
506
507// netinet/tcp.h
508pub const TCP_NODELAY: ::c_int = 1;
509// FIXME: relibc {
510pub const TCP_KEEPIDLE: ::c_int = 1;
511// }
512
513// poll.h
514pub const POLLIN: ::c_short = 0x001;
515pub const POLLPRI: ::c_short = 0x002;
516pub const POLLOUT: ::c_short = 0x004;
517pub const POLLERR: ::c_short = 0x008;
518pub const POLLHUP: ::c_short = 0x010;
519pub const POLLNVAL: ::c_short = 0x020;
520
521// pthread.h
522pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
523pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
524pub const PTHREAD_MUTEX_INITIALIZER: ::pthread_mutex_t = -1isize as *mut _;
525pub const PTHREAD_COND_INITIALIZER: ::pthread_cond_t = -1isize as *mut _;
526pub const PTHREAD_RWLOCK_INITIALIZER: ::pthread_rwlock_t = -1isize as *mut _;
527pub const PTHREAD_STACK_MIN: ::size_t = 4096;
528
529// signal.h
530pub const SIG_BLOCK: ::c_int = 0;
531pub const SIG_UNBLOCK: ::c_int = 1;
532pub const SIG_SETMASK: ::c_int = 2;
533pub const SIGHUP: ::c_int = 1;
534pub const SIGINT: ::c_int = 2;
535pub const SIGQUIT: ::c_int = 3;
536pub const SIGILL: ::c_int = 4;
537pub const SIGTRAP: ::c_int = 5;
538pub const SIGABRT: ::c_int = 6;
539pub const SIGBUS: ::c_int = 7;
540pub const SIGFPE: ::c_int = 8;
541pub const SIGKILL: ::c_int = 9;
542pub const SIGUSR1: ::c_int = 10;
543pub const SIGSEGV: ::c_int = 11;
544pub const SIGUSR2: ::c_int = 12;
545pub const SIGPIPE: ::c_int = 13;
546pub const SIGALRM: ::c_int = 14;
547pub const SIGTERM: ::c_int = 15;
548pub const SIGSTKFLT: ::c_int = 16;
549pub const SIGCHLD: ::c_int = 17;
550pub const SIGCONT: ::c_int = 18;
551pub const SIGSTOP: ::c_int = 19;
552pub const SIGTSTP: ::c_int = 20;
553pub const SIGTTIN: ::c_int = 21;
554pub const SIGTTOU: ::c_int = 22;
555pub const SIGURG: ::c_int = 23;
556pub const SIGXCPU: ::c_int = 24;
557pub const SIGXFSZ: ::c_int = 25;
558pub const SIGVTALRM: ::c_int = 26;
559pub const SIGPROF: ::c_int = 27;
560pub const SIGWINCH: ::c_int = 28;
561pub const SIGIO: ::c_int = 29;
562pub const SIGPWR: ::c_int = 30;
563pub const SIGSYS: ::c_int = 31;
564pub const NSIG: ::c_int = 32;
565
566pub const SA_NOCLDSTOP: ::c_ulong = 0x00000001;
567pub const SA_NOCLDWAIT: ::c_ulong = 0x00000002;
568pub const SA_SIGINFO: ::c_ulong = 0x00000004;
569pub const SA_RESTORER: ::c_ulong = 0x04000000;
570pub const SA_ONSTACK: ::c_ulong = 0x08000000;
571pub const SA_RESTART: ::c_ulong = 0x10000000;
572pub const SA_NODEFER: ::c_ulong = 0x40000000;
573pub const SA_RESETHAND: ::c_ulong = 0x80000000;
574
575// sys/file.h
576pub const LOCK_SH: ::c_int = 1;
577pub const LOCK_EX: ::c_int = 2;
578pub const LOCK_NB: ::c_int = 4;
579pub const LOCK_UN: ::c_int = 8;
580
581// sys/epoll.h
582pub const EPOLL_CLOEXEC: ::c_int = 0x0100_0000;
583pub const EPOLL_CTL_ADD: ::c_int = 1;
584pub const EPOLL_CTL_DEL: ::c_int = 2;
585pub const EPOLL_CTL_MOD: ::c_int = 3;
586pub const EPOLLIN: ::c_int = 1;
587pub const EPOLLPRI: ::c_int = 0;
588pub const EPOLLOUT: ::c_int = 2;
589pub const EPOLLRDNORM: ::c_int = 0;
590pub const EPOLLNVAL: ::c_int = 0;
591pub const EPOLLRDBAND: ::c_int = 0;
592pub const EPOLLWRNORM: ::c_int = 0;
593pub const EPOLLWRBAND: ::c_int = 0;
594pub const EPOLLMSG: ::c_int = 0;
595pub const EPOLLERR: ::c_int = 0;
596pub const EPOLLHUP: ::c_int = 0;
597pub const EPOLLRDHUP: ::c_int = 0;
598pub const EPOLLEXCLUSIVE: ::c_int = 0;
599pub const EPOLLWAKEUP: ::c_int = 0;
600pub const EPOLLONESHOT: ::c_int = 0;
601pub const EPOLLET: ::c_int = 0;
602
603// sys/stat.h
604pub const S_IFMT: ::c_int = 0o0_170_000;
605pub const S_IFDIR: ::c_int = 0o040_000;
606pub const S_IFCHR: ::c_int = 0o020_000;
607pub const S_IFBLK: ::c_int = 0o060_000;
608pub const S_IFREG: ::c_int = 0o100_000;
609pub const S_IFIFO: ::c_int = 0o010_000;
610pub const S_IFLNK: ::c_int = 0o120_000;
611pub const S_IFSOCK: ::c_int = 0o140_000;
612pub const S_IRWXU: ::c_int = 0o0_700;
613pub const S_IRUSR: ::c_int = 0o0_400;
614pub const S_IWUSR: ::c_int = 0o0_200;
615pub const S_IXUSR: ::c_int = 0o0_100;
616pub const S_IRWXG: ::c_int = 0o0_070;
617pub const S_IRGRP: ::c_int = 0o0_040;
618pub const S_IWGRP: ::c_int = 0o0_020;
619pub const S_IXGRP: ::c_int = 0o0_010;
620pub const S_IRWXO: ::c_int = 0o0_007;
621pub const S_IROTH: ::c_int = 0o0_004;
622pub const S_IWOTH: ::c_int = 0o0_002;
623pub const S_IXOTH: ::c_int = 0o0_001;
624
625// stdlib.h
626pub const EXIT_SUCCESS: ::c_int = 0;
627pub const EXIT_FAILURE: ::c_int = 1;
628
629// sys/ioctl.h
630// FIXME: relibc {
631pub const FIONREAD: ::c_ulong = 0x541B;
632pub const FIONBIO: ::c_ulong = 0x5421;
633pub const FIOCLEX: ::c_ulong = 0x5451;
634// }
635pub const TCGETS: ::c_ulong = 0x5401;
636pub const TCSETS: ::c_ulong = 0x5402;
637pub const TCFLSH: ::c_ulong = 0x540B;
638pub const TIOCGPGRP: ::c_ulong = 0x540F;
639pub const TIOCSPGRP: ::c_ulong = 0x5410;
640pub const TIOCGWINSZ: ::c_ulong = 0x5413;
641pub const TIOCSWINSZ: ::c_ulong = 0x5414;
642
643// sys/mman.h
644pub const PROT_NONE: ::c_int = 0x0000;
645pub const PROT_READ: ::c_int = 0x0004;
646pub const PROT_WRITE: ::c_int = 0x0002;
647pub const PROT_EXEC: ::c_int = 0x0001;
648
649pub const MADV_NORMAL: ::c_int = 0;
650pub const MADV_RANDOM: ::c_int = 1;
651pub const MADV_SEQUENTIAL: ::c_int = 2;
652pub const MADV_WILLNEED: ::c_int = 3;
653pub const MADV_DONTNEED: ::c_int = 4;
654
655pub const MAP_SHARED: ::c_int = 0x0001;
656pub const MAP_PRIVATE: ::c_int = 0x0002;
657pub const MAP_ANON: ::c_int = 0x0020;
658pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
659pub const MAP_FIXED: ::c_int = 0x0010;
660pub const MAP_FAILED: *mut ::c_void = !0 as _;
661
662pub const MS_ASYNC: ::c_int = 0x0001;
663pub const MS_INVALIDATE: ::c_int = 0x0002;
664pub const MS_SYNC: ::c_int = 0x0004;
665
666// sys/select.h
667pub const FD_SETSIZE: usize = 1024;
668
669// sys/socket.h
670pub const AF_INET: ::c_int = 2;
671pub const AF_INET6: ::c_int = 10;
672pub const AF_UNIX: ::c_int = 1;
673pub const AF_UNSPEC: ::c_int = 0;
674pub const PF_INET: ::c_int = 2;
675pub const PF_INET6: ::c_int = 10;
676pub const PF_UNIX: ::c_int = 1;
677pub const PF_UNSPEC: ::c_int = 0;
678pub const MSG_CTRUNC: ::c_int = 8;
679pub const MSG_DONTROUTE: ::c_int = 4;
680pub const MSG_EOR: ::c_int = 128;
681pub const MSG_OOB: ::c_int = 1;
682pub const MSG_PEEK: ::c_int = 2;
683pub const MSG_TRUNC: ::c_int = 32;
684pub const MSG_DONTWAIT: ::c_int = 64;
685pub const MSG_WAITALL: ::c_int = 256;
686pub const SHUT_RD: ::c_int = 0;
687pub const SHUT_WR: ::c_int = 1;
688pub const SHUT_RDWR: ::c_int = 2;
689pub const SO_DEBUG: ::c_int = 1;
690pub const SO_REUSEADDR: ::c_int = 2;
691pub const SO_TYPE: ::c_int = 3;
692pub const SO_ERROR: ::c_int = 4;
693pub const SO_DONTROUTE: ::c_int = 5;
694pub const SO_BROADCAST: ::c_int = 6;
695pub const SO_SNDBUF: ::c_int = 7;
696pub const SO_RCVBUF: ::c_int = 8;
697pub const SO_KEEPALIVE: ::c_int = 9;
698pub const SO_OOBINLINE: ::c_int = 10;
699pub const SO_NO_CHECK: ::c_int = 11;
700pub const SO_PRIORITY: ::c_int = 12;
701pub const SO_LINGER: ::c_int = 13;
702pub const SO_BSDCOMPAT: ::c_int = 14;
703pub const SO_REUSEPORT: ::c_int = 15;
704pub const SO_PASSCRED: ::c_int = 16;
705pub const SO_PEERCRED: ::c_int = 17;
706pub const SO_RCVLOWAT: ::c_int = 18;
707pub const SO_SNDLOWAT: ::c_int = 19;
708pub const SO_RCVTIMEO: ::c_int = 20;
709pub const SO_SNDTIMEO: ::c_int = 21;
710pub const SO_ACCEPTCONN: ::c_int = 30;
711pub const SO_PEERSEC: ::c_int = 31;
712pub const SO_SNDBUFFORCE: ::c_int = 32;
713pub const SO_RCVBUFFORCE: ::c_int = 33;
714pub const SO_PROTOCOL: ::c_int = 38;
715pub const SO_DOMAIN: ::c_int = 39;
716pub const SOCK_STREAM: ::c_int = 1;
717pub const SOCK_DGRAM: ::c_int = 2;
718pub const SOCK_NONBLOCK: ::c_int = 0o4_000;
719pub const SOCK_CLOEXEC: ::c_int = 0o2_000_000;
720pub const SOCK_SEQPACKET: ::c_int = 5;
721pub const SOL_SOCKET: ::c_int = 1;
722
723// sys/termios.h
724pub const VEOF: usize = 0;
725pub const VEOL: usize = 1;
726pub const VEOL2: usize = 2;
727pub const VERASE: usize = 3;
728pub const VWERASE: usize = 4;
729pub const VKILL: usize = 5;
730pub const VREPRINT: usize = 6;
731pub const VSWTC: usize = 7;
732pub const VINTR: usize = 8;
733pub const VQUIT: usize = 9;
734pub const VSUSP: usize = 10;
735pub const VSTART: usize = 12;
736pub const VSTOP: usize = 13;
737pub const VLNEXT: usize = 14;
738pub const VDISCARD: usize = 15;
739pub const VMIN: usize = 16;
740pub const VTIME: usize = 17;
741pub const NCCS: usize = 32;
742
743pub const IGNBRK: ::tcflag_t = 0o000_001;
744pub const BRKINT: ::tcflag_t = 0o000_002;
745pub const IGNPAR: ::tcflag_t = 0o000_004;
746pub const PARMRK: ::tcflag_t = 0o000_010;
747pub const INPCK: ::tcflag_t = 0o000_020;
748pub const ISTRIP: ::tcflag_t = 0o000_040;
749pub const INLCR: ::tcflag_t = 0o000_100;
750pub const IGNCR: ::tcflag_t = 0o000_200;
751pub const ICRNL: ::tcflag_t = 0o000_400;
752pub const IXON: ::tcflag_t = 0o001_000;
753pub const IXOFF: ::tcflag_t = 0o002_000;
754
755pub const OPOST: ::tcflag_t = 0o000_001;
756pub const ONLCR: ::tcflag_t = 0o000_002;
757pub const OLCUC: ::tcflag_t = 0o000_004;
758pub const OCRNL: ::tcflag_t = 0o000_010;
759pub const ONOCR: ::tcflag_t = 0o000_020;
760pub const ONLRET: ::tcflag_t = 0o000_040;
761pub const OFILL: ::tcflag_t = 0o0000_100;
762pub const OFDEL: ::tcflag_t = 0o0000_200;
763
764pub const B0: speed_t = 0o000_000;
765pub const B50: speed_t = 0o000_001;
766pub const B75: speed_t = 0o000_002;
767pub const B110: speed_t = 0o000_003;
768pub const B134: speed_t = 0o000_004;
769pub const B150: speed_t = 0o000_005;
770pub const B200: speed_t = 0o000_006;
771pub const B300: speed_t = 0o000_007;
772pub const B600: speed_t = 0o000_010;
773pub const B1200: speed_t = 0o000_011;
774pub const B1800: speed_t = 0o000_012;
775pub const B2400: speed_t = 0o000_013;
776pub const B4800: speed_t = 0o000_014;
777pub const B9600: speed_t = 0o000_015;
778pub const B19200: speed_t = 0o000_016;
779pub const B38400: speed_t = 0o000_017;
780
781pub const B57600: speed_t = 0o0_020;
782pub const B115200: speed_t = 0o0_021;
783pub const B230400: speed_t = 0o0_022;
784pub const B460800: speed_t = 0o0_023;
785pub const B500000: speed_t = 0o0_024;
786pub const B576000: speed_t = 0o0_025;
787pub const B921600: speed_t = 0o0_026;
788pub const B1000000: speed_t = 0o0_027;
789pub const B1152000: speed_t = 0o0_030;
790pub const B1500000: speed_t = 0o0_031;
791pub const B2000000: speed_t = 0o0_032;
792pub const B2500000: speed_t = 0o0_033;
793pub const B3000000: speed_t = 0o0_034;
794pub const B3500000: speed_t = 0o0_035;
795pub const B4000000: speed_t = 0o0_036;
796
797pub const CSIZE: ::tcflag_t = 0o001_400;
798pub const CS5: ::tcflag_t = 0o000_000;
799pub const CS6: ::tcflag_t = 0o000_400;
800pub const CS7: ::tcflag_t = 0o001_000;
801pub const CS8: ::tcflag_t = 0o001_400;
802
803pub const CSTOPB: ::tcflag_t = 0o002_000;
804pub const CREAD: ::tcflag_t = 0o004_000;
805pub const PARENB: ::tcflag_t = 0o010_000;
806pub const PARODD: ::tcflag_t = 0o020_000;
807pub const HUPCL: ::tcflag_t = 0o040_000;
808
809pub const CLOCAL: ::tcflag_t = 0o0100000;
810
811pub const ISIG: ::tcflag_t = 0x0000_0080;
812pub const ICANON: ::tcflag_t = 0x0000_0100;
813pub const ECHO: ::tcflag_t = 0x0000_0008;
814pub const ECHOE: ::tcflag_t = 0x0000_0002;
815pub const ECHOK: ::tcflag_t = 0x0000_0004;
816pub const ECHONL: ::tcflag_t = 0x0000_0010;
817pub const NOFLSH: ::tcflag_t = 0x8000_0000;
818pub const TOSTOP: ::tcflag_t = 0x0040_0000;
819pub const IEXTEN: ::tcflag_t = 0x0000_0400;
820
821pub const TCOOFF: ::c_int = 0;
822pub const TCOON: ::c_int = 1;
823pub const TCIOFF: ::c_int = 2;
824pub const TCION: ::c_int = 3;
825
826pub const TCIFLUSH: ::c_int = 0;
827pub const TCOFLUSH: ::c_int = 1;
828pub const TCIOFLUSH: ::c_int = 2;
829
830pub const TCSANOW: ::c_int = 0;
831pub const TCSADRAIN: ::c_int = 1;
832pub const TCSAFLUSH: ::c_int = 2;
833
834// sys/wait.h
835pub const WNOHANG: ::c_int = 1;
836pub const WUNTRACED: ::c_int = 2;
837
838pub const WSTOPPED: ::c_int = 2;
839pub const WEXITED: ::c_int = 4;
840pub const WCONTINUED: ::c_int = 8;
841pub const WNOWAIT: ::c_int = 0x0100_0000;
842
843pub const __WNOTHREAD: ::c_int = 0x2000_0000;
844pub const __WALL: ::c_int = 0x4000_0000;
845#[allow(overflowing_literals)]
846pub const __WCLONE: ::c_int = 0x8000_0000;
847
848// time.h
849pub const CLOCK_REALTIME: ::c_int = 1;
850pub const CLOCK_MONOTONIC: ::c_int = 4;
851pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2;
852pub const CLOCKS_PER_SEC: ::clock_t = 1_000_000;
853
854// unistd.h
855// POSIX.1 {
856pub const _SC_ARG_MAX: ::c_int = 0;
857pub const _SC_CHILD_MAX: ::c_int = 1;
858pub const _SC_CLK_TCK: ::c_int = 2;
859pub const _SC_NGROUPS_MAX: ::c_int = 3;
860pub const _SC_OPEN_MAX: ::c_int = 4;
861pub const _SC_STREAM_MAX: ::c_int = 5;
862pub const _SC_TZNAME_MAX: ::c_int = 6;
863// ...
864pub const _SC_VERSION: ::c_int = 29;
865pub const _SC_PAGESIZE: ::c_int = 30;
866pub const _SC_PAGE_SIZE: ::c_int = 30;
867// ...
868pub const _SC_RE_DUP_MAX: ::c_int = 44;
869// ...
870pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
871pub const _SC_TTY_NAME_MAX: ::c_int = 72;
872// ...
873pub const _SC_SYMLOOP_MAX: ::c_int = 173;
874// ...
875pub const _SC_HOST_NAME_MAX: ::c_int = 180;
876// } POSIX.1
877
878pub const F_OK: ::c_int = 0;
879pub const R_OK: ::c_int = 4;
880pub const W_OK: ::c_int = 2;
881pub const X_OK: ::c_int = 1;
882
883pub const SEEK_SET: ::c_int = 0;
884pub const SEEK_CUR: ::c_int = 1;
885pub const SEEK_END: ::c_int = 2;
886pub const STDIN_FILENO: ::c_int = 0;
887pub const STDOUT_FILENO: ::c_int = 1;
888pub const STDERR_FILENO: ::c_int = 2;
889
890pub const _PC_LINK_MAX: ::c_int = 0;
891pub const _PC_MAX_CANON: ::c_int = 1;
892pub const _PC_MAX_INPUT: ::c_int = 2;
893pub const _PC_NAME_MAX: ::c_int = 3;
894pub const _PC_PATH_MAX: ::c_int = 4;
895pub const _PC_PIPE_BUF: ::c_int = 5;
896pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
897pub const _PC_NO_TRUNC: ::c_int = 7;
898pub const _PC_VDISABLE: ::c_int = 8;
899pub const _PC_SYNC_IO: ::c_int = 9;
900pub const _PC_ASYNC_IO: ::c_int = 10;
901pub const _PC_PRIO_IO: ::c_int = 11;
902pub const _PC_SOCK_MAXBUF: ::c_int = 12;
903pub const _PC_FILESIZEBITS: ::c_int = 13;
904pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
905pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
906pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
907pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
908pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18;
909pub const _PC_SYMLINK_MAX: ::c_int = 19;
910pub const _PC_2_SYMLINKS: ::c_int = 20;
911
912pub const PRIO_PROCESS: ::c_int = 0;
913pub const PRIO_PGRP: ::c_int = 1;
914pub const PRIO_USER: ::c_int = 2;
915
916// wait.h
917f! {
918    pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
919        let fd = fd as usize;
920        let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
921        (*set).fds_bits[fd / size] &= !(1 << (fd % size));
922        return
923    }
924
925    pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
926        let fd = fd as usize;
927        let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
928        return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
929    }
930
931    pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
932        let fd = fd as usize;
933        let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
934        (*set).fds_bits[fd / size] |= 1 << (fd % size);
935        return
936    }
937
938    pub fn FD_ZERO(set: *mut fd_set) -> () {
939        for slot in (*set).fds_bits.iter_mut() {
940            *slot = 0;
941        }
942    }
943}
944
945safe_f! {
946    pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
947        (status & 0xff) == 0x7f
948    }
949
950    pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
951        (status >> 8) & 0xff
952    }
953
954    pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
955        status == 0xffff
956    }
957
958    pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
959        ((status & 0x7f) + 1) as i8 >= 2
960    }
961
962    pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int {
963        status & 0x7f
964    }
965
966    pub {const} fn WIFEXITED(status: ::c_int) -> bool {
967        (status & 0x7f) == 0
968    }
969
970    pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int {
971        (status >> 8) & 0xff
972    }
973
974    pub {const} fn WCOREDUMP(status: ::c_int) -> bool {
975        (status & 0x80) != 0
976    }
977}
978
979extern "C" {
980    // errno.h
981    pub fn __errno_location() -> *mut ::c_int;
982    pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
983
984    // unistd.h
985    pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
986
987    // malloc.h
988    pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
989
990    // netdb.h
991    pub fn getnameinfo(
992        addr: *const ::sockaddr,
993        addrlen: ::socklen_t,
994        host: *mut ::c_char,
995        hostlen: ::socklen_t,
996        serv: *mut ::c_char,
997        servlen: ::socklen_t,
998        flags: ::c_int,
999    ) -> ::c_int;
1000
1001    // pthread.h
1002    pub fn pthread_atfork(
1003        prepare: ::Option<unsafe extern "C" fn()>,
1004        parent: ::Option<unsafe extern "C" fn()>,
1005        child: ::Option<unsafe extern "C" fn()>,
1006    ) -> ::c_int;
1007    pub fn pthread_create(
1008        tid: *mut ::pthread_t,
1009        attr: *const ::pthread_attr_t,
1010        start: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
1011        arg: *mut ::c_void,
1012    ) -> ::c_int;
1013    pub fn pthread_condattr_setclock(
1014        attr: *mut pthread_condattr_t,
1015        clock_id: ::clockid_t,
1016    ) -> ::c_int;
1017
1018    // pwd.h
1019    pub fn getpwuid_r(
1020        uid: ::uid_t,
1021        pwd: *mut passwd,
1022        buf: *mut ::c_char,
1023        buflen: ::size_t,
1024        result: *mut *mut passwd,
1025    ) -> ::c_int;
1026
1027    // signal.h
1028    pub fn pthread_sigmask(
1029        how: ::c_int,
1030        set: *const ::sigset_t,
1031        oldset: *mut ::sigset_t,
1032    ) -> ::c_int;
1033    pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
1034    pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
1035
1036    // sys/epoll.h
1037    pub fn epoll_create(size: ::c_int) -> ::c_int;
1038    pub fn epoll_create1(flags: ::c_int) -> ::c_int;
1039    pub fn epoll_wait(
1040        epfd: ::c_int,
1041        events: *mut ::epoll_event,
1042        maxevents: ::c_int,
1043        timeout: ::c_int,
1044    ) -> ::c_int;
1045    pub fn epoll_ctl(epfd: ::c_int, op: ::c_int, fd: ::c_int, event: *mut ::epoll_event)
1046        -> ::c_int;
1047
1048    // sys/ioctl.h
1049    pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
1050
1051    // sys/mman.h
1052    pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
1053    pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
1054    pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
1055    pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int;
1056    pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
1057
1058    // sys/resource.h
1059    pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
1060    pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
1061
1062    // sys/socket.h
1063    pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int;
1064    pub fn recvfrom(
1065        socket: ::c_int,
1066        buf: *mut ::c_void,
1067        len: ::size_t,
1068        flags: ::c_int,
1069        addr: *mut ::sockaddr,
1070        addrlen: *mut ::socklen_t,
1071    ) -> ::ssize_t;
1072
1073    // sys/stat.h
1074    pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
1075
1076    // sys/uio.h
1077    pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
1078    pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
1079
1080    // sys/utsname.h
1081    pub fn uname(utsname: *mut utsname) -> ::c_int;
1082
1083    // time.h
1084    pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
1085    pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
1086}
1087
1088cfg_if! {
1089    if #[cfg(feature = "extra_traits")] {
1090        impl PartialEq for dirent {
1091            fn eq(&self, other: &dirent) -> bool {
1092                self.d_ino == other.d_ino
1093                    && self.d_off == other.d_off
1094                    && self.d_reclen == other.d_reclen
1095                    && self.d_type == other.d_type
1096                    && self
1097                    .d_name
1098                    .iter()
1099                    .zip(other.d_name.iter())
1100                    .all(|(a,b)| a == b)
1101            }
1102        }
1103
1104        impl Eq for dirent {}
1105
1106        impl ::fmt::Debug for dirent {
1107            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1108                f.debug_struct("dirent")
1109                    .field("d_ino", &self.d_ino)
1110                    .field("d_off", &self.d_off)
1111                    .field("d_reclen", &self.d_reclen)
1112                    .field("d_type", &self.d_type)
1113                // FIXME: .field("d_name", &self.d_name)
1114                    .finish()
1115            }
1116        }
1117
1118        impl ::hash::Hash for dirent {
1119            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1120                self.d_ino.hash(state);
1121                self.d_off.hash(state);
1122                self.d_reclen.hash(state);
1123                self.d_type.hash(state);
1124                self.d_name.hash(state);
1125            }
1126        }
1127
1128        impl PartialEq for sockaddr_un {
1129            fn eq(&self, other: &sockaddr_un) -> bool {
1130                self.sun_family == other.sun_family
1131                    && self
1132                    .sun_path
1133                    .iter()
1134                    .zip(other.sun_path.iter())
1135                    .all(|(a,b)| a == b)
1136            }
1137        }
1138
1139        impl Eq for sockaddr_un {}
1140
1141        impl ::fmt::Debug for sockaddr_un {
1142            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1143                f.debug_struct("sockaddr_un")
1144                    .field("sun_family", &self.sun_family)
1145                // FIXME: .field("sun_path", &self.sun_path)
1146                    .finish()
1147            }
1148        }
1149
1150        impl ::hash::Hash for sockaddr_un {
1151            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1152                self.sun_family.hash(state);
1153                self.sun_path.hash(state);
1154            }
1155        }
1156
1157        impl PartialEq for sockaddr_storage {
1158            fn eq(&self, other: &sockaddr_storage) -> bool {
1159                self.ss_family == other.ss_family
1160                    && self.__ss_align == self.__ss_align
1161                    && self
1162                    .__ss_padding
1163                    .iter()
1164                    .zip(other.__ss_padding.iter())
1165                    .all(|(a,b)| a == b)
1166            }
1167        }
1168
1169        impl Eq for sockaddr_storage {}
1170
1171        impl ::fmt::Debug for sockaddr_storage {
1172            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1173                f.debug_struct("sockaddr_storage")
1174                    .field("ss_family", &self.ss_family)
1175                    .field("__ss_align", &self.__ss_align)
1176                // FIXME: .field("__ss_padding", &self.__ss_padding)
1177                    .finish()
1178            }
1179        }
1180
1181        impl ::hash::Hash for sockaddr_storage {
1182            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1183                self.ss_family.hash(state);
1184                self.__ss_padding.hash(state);
1185                self.__ss_align.hash(state);
1186            }
1187        }
1188
1189        impl PartialEq for utsname {
1190            fn eq(&self, other: &utsname) -> bool {
1191                self.sysname
1192                    .iter()
1193                    .zip(other.sysname.iter())
1194                    .all(|(a, b)| a == b)
1195                    && self
1196                    .nodename
1197                    .iter()
1198                    .zip(other.nodename.iter())
1199                    .all(|(a, b)| a == b)
1200                    && self
1201                    .release
1202                    .iter()
1203                    .zip(other.release.iter())
1204                    .all(|(a, b)| a == b)
1205                    && self
1206                    .version
1207                    .iter()
1208                    .zip(other.version.iter())
1209                    .all(|(a, b)| a == b)
1210                    && self
1211                    .machine
1212                    .iter()
1213                    .zip(other.machine.iter())
1214                    .all(|(a, b)| a == b)
1215                    && self
1216                    .domainname
1217                    .iter()
1218                    .zip(other.domainname.iter())
1219                    .all(|(a, b)| a == b)
1220            }
1221        }
1222
1223        impl Eq for utsname {}
1224
1225        impl ::fmt::Debug for utsname {
1226            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1227                f.debug_struct("utsname")
1228                // FIXME: .field("sysname", &self.sysname)
1229                // FIXME: .field("nodename", &self.nodename)
1230                // FIXME: .field("release", &self.release)
1231                // FIXME: .field("version", &self.version)
1232                // FIXME: .field("machine", &self.machine)
1233                // FIXME: .field("domainname", &self.domainname)
1234                    .finish()
1235            }
1236        }
1237
1238        impl ::hash::Hash for utsname {
1239            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1240                self.sysname.hash(state);
1241                self.nodename.hash(state);
1242                self.release.hash(state);
1243                self.version.hash(state);
1244                self.machine.hash(state);
1245                self.domainname.hash(state);
1246            }
1247        }
1248    }
1249}
1250