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