Debian Codegraph @

debian/missing-sources/libc/src/unix/redox/mod.rs

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