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