Debian Codegraph @

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

raw
1 use crate::prelude::*;
2
3 // This module contains bindings to the native Haiku API. The Haiku API
4 // originates from BeOS, and it was the original way to perform low level
5 // system and IO operations. The POSIX API was in that era was like a
6 // compatibility layer. In current Haiku development, both the POSIX API and
7 // the Haiku API are considered to be co-equal status. However, they are not
8 // integrated like they are on other UNIX platforms, which means that for many
9 // low level concepts there are two versions, like processes (POSIX) and
10 // teams (Haiku), or pthreads and native threads.
11 //
12 // Both the POSIX API and the Haiku API live in libroot.so, the library that is
13 // linked to any binary by default. Additionally, Haiku supports several
14 // non-POSIX APIs from BSD and GNU, which live in libbsd.so and libgnu.so. These
15 // modules are also supported.
16 //
17 // The module is comprised of the following files:
18 // - `mod.rs` (this file) implements the C11 and POSIX API found in
19 // `headers/posix`
20 // - `b32.rs`, `b64.rs` and `x86_64.rs` contain platform-specific definitions
21 // of the C11 and POSIX APIs
22 // - `native.rs` defines the native Haiku API that is implemented in
23 // `libroot.so` and that are found in `headers/os`.
24 // - `bsd.rs` defines the BSD customizations available on Haiku found in
25 // `headers/compatibility/bsd`
26
27 pub type rlim_t = crate::uintptr_t;
28 pub type sa_family_t = u8;
29 pub type pthread_key_t = c_int;
30 pub type nfds_t = c_ulong;
31 pub type tcflag_t = c_uint;
32 pub type speed_t = c_uchar;
33 pub type clock_t = i32;
34 pub type clockid_t = i32;
35 pub type suseconds_t = i32;
36 pub type wchar_t = i32;
37 pub type off_t = i64;
38 pub type ino_t = i64;
39 pub type blkcnt_t = i64;
40 pub type blksize_t = i32;
41 pub type dev_t = i32;
42 pub type mode_t = u32;
43 pub type nlink_t = i32;
44 pub type useconds_t = u32;
45 pub type socklen_t = u32;
46 pub type pthread_t = crate::uintptr_t;
47 pub type pthread_condattr_t = crate::uintptr_t;
48 pub type pthread_mutexattr_t = crate::uintptr_t;
49 pub type pthread_rwlockattr_t = crate::uintptr_t;
50 pub type sigset_t = u64;
51 pub type fsblkcnt_t = i64;
52 pub type fsfilcnt_t = i64;
53 pub type pthread_attr_t = *mut c_void;
54 pub type nl_item = c_int;
55 pub type id_t = i32;
56 pub type idtype_t = c_int;
57 pub type fd_mask = u32;
58 pub type regoff_t = c_int;
59 pub type key_t = i32;
60 pub type msgqnum_t = u32;
61 pub type msglen_t = u32;
62
63 pub type Elf32_Addr = u32;
64 pub type Elf32_Half = u16;
65 pub type Elf32_Off = u32;
66 pub type Elf32_Sword = i32;
67 pub type Elf32_Word = u32;
68
69 pub type Elf64_Addr = u64;
70 pub type Elf64_Half = u16;
71 pub type Elf64_Off = u64;
72 pub type Elf64_Sword = i32;
73 pub type Elf64_Sxword = i64;
74 pub type Elf64_Word = u32;
75 pub type Elf64_Xword = u64;
76
77 pub type ENTRY = entry;
78 pub type ACTION = c_int;
79
80 pub type posix_spawnattr_t = *mut c_void;
81 pub type posix_spawn_file_actions_t = *mut c_void;
82
83 extern_ty! {
84 pub enum timezone {}
85 }
86
87 impl siginfo_t {
88 pub unsafe fn si_addr(&self) -> *mut c_void {
89 self.si_addr
90 }
91
92 pub unsafe fn si_pid(&self) -> crate::pid_t {
93 self.si_pid
94 }
95
96 pub unsafe fn si_uid(&self) -> crate::uid_t {
97 self.si_uid
98 }
99
100 pub unsafe fn si_status(&self) -> c_int {
101 self.si_status
102 }
103 }
104
105 s! {
106 pub struct in_addr {
107 pub s_addr: crate::in_addr_t,
108 }
109
110 pub struct ip_mreq {
111 pub imr_multiaddr: in_addr,
112 pub imr_interface: in_addr,
113 }
114
115 pub struct sockaddr {
116 pub sa_len: u8,
117 pub sa_family: sa_family_t,
118 pub sa_data: [u8; 30],
119 }
120
121 pub struct sockaddr_in {
122 pub sin_len: u8,
123 pub sin_family: sa_family_t,
124 pub sin_port: crate::in_port_t,
125 pub sin_addr: crate::in_addr,
126 pub sin_zero: [i8; 24],
127 }
128
129 pub struct sockaddr_in6 {
130 pub sin6_len: u8,
131 pub sin6_family: u8,
132 pub sin6_port: u16,
133 pub sin6_flowinfo: u32,
134 pub sin6_addr: crate::in6_addr,
135 pub sin6_scope_id: u32,
136 }
137
138 pub struct addrinfo {
139 pub ai_flags: c_int,
140 pub ai_family: c_int,
141 pub ai_socktype: c_int,
142 pub ai_protocol: c_int,
143 pub ai_addrlen: socklen_t,
144 pub ai_canonname: *mut c_char,
145 pub ai_addr: *mut crate::sockaddr,
146 pub ai_next: *mut addrinfo,
147 }
148
149 pub struct ifaddrs {
150 pub ifa_next: *mut ifaddrs,
151 pub ifa_name: *const c_char,
152 pub ifa_flags: c_uint,
153 pub ifa_addr: *mut crate::sockaddr,
154 pub ifa_netmask: *mut crate::sockaddr,
155 pub ifa_dstaddr: *mut crate::sockaddr,
156 pub ifa_data: *mut c_void,
157 }
158
159 pub struct fd_set {
160 // size for 1024 bits, and a fd_mask with size u32
161 fds_bits: [fd_mask; 32],
162 }
163
164 pub struct tm {
165 pub tm_sec: c_int,
166 pub tm_min: c_int,
167 pub tm_hour: c_int,
168 pub tm_mday: c_int,
169 pub tm_mon: c_int,
170 pub tm_year: c_int,
171 pub tm_wday: c_int,
172 pub tm_yday: c_int,
173 pub tm_isdst: c_int,
174 pub tm_gmtoff: c_int,
175 pub tm_zone: *mut c_char,
176 }
177
178 pub struct utsname {
179 pub sysname: [c_char; 32],
180 pub nodename: [c_char; 32],
181 pub release: [c_char; 32],
182 pub version: [c_char; 32],
183 pub machine: [c_char; 32],
184 }
185
186 pub struct lconv {
187 pub decimal_point: *mut c_char,
188 pub thousands_sep: *mut c_char,
189 pub grouping: *mut c_char,
190 pub int_curr_symbol: *mut c_char,
191 pub currency_symbol: *mut c_char,
192 pub mon_decimal_point: *mut c_char,
193 pub mon_thousands_sep: *mut c_char,
194 pub mon_grouping: *mut c_char,
195 pub positive_sign: *mut c_char,
196 pub negative_sign: *mut c_char,
197 pub int_frac_digits: c_char,
198 pub frac_digits: c_char,
199 pub p_cs_precedes: c_char,
200 pub p_sep_by_space: c_char,
201 pub n_cs_precedes: c_char,
202 pub n_sep_by_space: c_char,
203 pub p_sign_posn: c_char,
204 pub n_sign_posn: c_char,
205 pub int_p_cs_precedes: c_char,
206 pub int_p_sep_by_space: c_char,
207 pub int_n_cs_precedes: c_char,
208 pub int_n_sep_by_space: c_char,
209 pub int_p_sign_posn: c_char,
210 pub int_n_sign_posn: c_char,
211 }
212
213 pub struct msghdr {
214 pub msg_name: *mut c_void,
215 pub msg_namelen: socklen_t,
216 pub msg_iov: *mut crate::iovec,
217 pub msg_iovlen: c_int,
218 pub msg_control: *mut c_void,
219 pub msg_controllen: socklen_t,
220 pub msg_flags: c_int,
221 }
222
223 pub struct cmsghdr {
224 pub cmsg_len: crate::socklen_t,
225 pub cmsg_level: c_int,
226 pub cmsg_type: c_int,
227 }
228
229 pub struct Dl_info {
230 pub dli_fname: *const c_char,
231 pub dli_fbase: *mut c_void,
232 pub dli_sname: *const c_char,
233 pub dli_saddr: *mut c_void,
234 }
235
236 pub struct termios {
237 pub c_iflag: crate::tcflag_t,
238 pub c_oflag: crate::tcflag_t,
239 pub c_cflag: crate::tcflag_t,
240 pub c_lflag: crate::tcflag_t,
241 pub c_line: c_char,
242 pub c_ispeed: crate::speed_t,
243 pub c_ospeed: crate::speed_t,
244 pub c_cc: [crate::cc_t; crate::NCCS],
245 }
246
247 pub struct flock {
248 pub l_type: c_short,
249 pub l_whence: c_short,
250 pub l_start: off_t,
251 pub l_len: off_t,
252 pub l_pid: crate::pid_t,
253 }
254
255 pub struct stat {
256 pub st_dev: dev_t,
257 pub st_ino: ino_t,
258 pub st_mode: mode_t,
259 pub st_nlink: nlink_t,
260 pub st_uid: crate::uid_t,
261 pub st_gid: crate::gid_t,
262 pub st_size: off_t,
263 pub st_rdev: dev_t,
264 pub st_blksize: blksize_t,
265 pub st_atime: time_t,
266 pub st_atime_nsec: c_long,
267 pub st_mtime: time_t,
268 pub st_mtime_nsec: c_long,
269 pub st_ctime: time_t,
270 pub st_ctime_nsec: c_long,
271 pub st_crtime: time_t,
272 pub st_crtime_nsec: c_long,
273 pub st_type: u32,
274 pub st_blocks: blkcnt_t,
275 }
276
277 pub struct glob_t {
278 pub gl_pathc: size_t,
279 __unused1: Padding<size_t>,
280 pub gl_offs: size_t,
281 __unused2: Padding<size_t>,
282 pub gl_pathv: *mut *mut c_char,
283
284 __unused3: Padding<*mut c_void>,
285 __unused4: Padding<*mut c_void>,
286 __unused5: Padding<*mut c_void>,
287 __unused6: Padding<*mut c_void>,
288 __unused7: Padding<*mut c_void>,
289 __unused8: Padding<*mut c_void>,
290 }
291
292 pub struct pthread_mutex_t {
293 flags: u32,
294 lock: i32,
295 unused: Padding<i32>,
296 owner: i32,
297 owner_count: i32,
298 }
299
300 pub struct pthread_cond_t {
301 flags: u32,
302 unused: Padding<i32>,
303 mutex: *mut c_void,
304 waiter_count: i32,
305 lock: i32,
306 }
307
308 pub struct pthread_rwlock_t {
309 flags: u32,
310 owner: i32,
311 lock_sem: i32, // this is actually a union
312 lock_count: i32,
313 reader_count: i32,
314 writer_count: i32,
315 waiters: [*mut c_void; 2],
316 }
317
318 pub struct pthread_spinlock_t {
319 lock: u32,
320 }
321
322 pub struct passwd {
323 pub pw_name: *mut c_char,
324 pub pw_passwd: *mut c_char,
325 pub pw_uid: crate::uid_t,
326 pub pw_gid: crate::gid_t,
327 pub pw_dir: *mut c_char,
328 pub pw_shell: *mut c_char,
329 pub pw_gecos: *mut c_char,
330 }
331
332 pub struct statvfs {
333 pub f_bsize: c_ulong,
334 pub f_frsize: c_ulong,
335 pub f_blocks: crate::fsblkcnt_t,
336 pub f_bfree: crate::fsblkcnt_t,
337 pub f_bavail: crate::fsblkcnt_t,
338 pub f_files: crate::fsfilcnt_t,
339 pub f_ffree: crate::fsfilcnt_t,
340 pub f_favail: crate::fsfilcnt_t,
341 pub f_fsid: c_ulong,
342 pub f_flag: c_ulong,
343 pub f_namemax: c_ulong,
344 }
345
346 pub struct stack_t {
347 pub ss_sp: *mut c_void,
348 pub ss_size: size_t,
349 pub ss_flags: c_int,
350 }
351
352 pub struct siginfo_t {
353 pub si_signo: c_int,
354 pub si_code: c_int,
355 pub si_errno: c_int,
356 pub si_pid: crate::pid_t,
357 pub si_uid: crate::uid_t,
358 pub si_addr: *mut c_void,
359 pub si_status: c_int,
360 pub si_band: c_long,
361 pub sigval: *mut c_void,
362 }
363
364 pub struct sigaction {
365 pub sa_sigaction: crate::sighandler_t, //actually a union with sa_handler
366 pub sa_mask: crate::sigset_t,
367 pub sa_flags: c_int,
368 sa_userdata: *mut c_void,
369 }
370
371 pub struct sem_t {
372 pub type_: i32,
373 pub named_sem_id: i32, // actually a union with unnamed_sem (i32)
374 pub padding: [i32; 2],
375 }
376
377 pub struct ucred {
378 pub pid: crate::pid_t,
379 pub uid: crate::uid_t,
380 pub gid: crate::gid_t,
381 }
382
383 pub struct sockaddr_dl {
384 pub sdl_len: u8,
385 pub sdl_family: u8,
386 pub sdl_e_type: u16,
387 pub sdl_index: u32,
388 pub sdl_type: u8,
389 pub sdl_nlen: u8,
390 pub sdl_alen: u8,
391 pub sdl_slen: u8,
392 pub sdl_data: [u8; 46],
393 }
394
395 pub struct spwd {
396 pub sp_namp: *mut c_char,
397 pub sp_pwdp: *mut c_char,
398 pub sp_lstchg: c_int,
399 pub sp_min: c_int,
400 pub sp_max: c_int,
401 pub sp_warn: c_int,
402 pub sp_inact: c_int,
403 pub sp_expire: c_int,
404 pub sp_flag: c_int,
405 }
406
407 pub struct regex_t {
408 __buffer: *mut c_void,
409 __allocated: size_t,
410 __used: size_t,
411 __syntax: c_ulong,
412 __fastmap: *mut c_char,
413 __translate: *mut c_char,
414 __re_nsub: size_t,
415 __bitfield: u8,
416 }
417
418 pub struct regmatch_t {
419 pub rm_so: regoff_t,
420 pub rm_eo: regoff_t,
421 }
422
423 pub struct msqid_ds {
424 pub msg_perm: crate::ipc_perm,
425 pub msg_qnum: crate::msgqnum_t,
426 pub msg_qbytes: crate::msglen_t,
427 pub msg_lspid: crate::pid_t,
428 pub msg_lrpid: crate::pid_t,
429 pub msg_stime: crate::time_t,
430 pub msg_rtime: crate::time_t,
431 pub msg_ctime: crate::time_t,
432 }
433
434 pub struct ipc_perm {
435 pub key: crate::key_t,
436 pub uid: crate::uid_t,
437 pub gid: crate::gid_t,
438 pub cuid: crate::uid_t,
439 pub cgid: crate::gid_t,
440 pub mode: mode_t,
441 }
442
443 pub struct sembuf {
444 pub sem_num: c_ushort,
445 pub sem_op: c_short,
446 pub sem_flg: c_short,
447 }
448
449 pub struct entry {
450 pub key: *mut c_char,
451 pub data: *mut c_void,
452 }
453
454 pub struct option {
455 pub name: *const c_char,
456 pub has_arg: c_int,
457 pub flag: *mut c_int,
458 pub val: c_int,
459 }
460
461 pub struct sockaddr_un {
462 pub sun_len: u8,
463 pub sun_family: sa_family_t,
464 pub sun_path: [c_char; 126],
465 }
466 pub struct sockaddr_storage {
467 pub ss_len: u8,
468 pub ss_family: sa_family_t,
469 __ss_pad1: Padding<[u8; 6]>,
470 __ss_pad2: Padding<u64>,
471 __ss_pad3: Padding<[u8; 112]>,
472 }
473 pub struct dirent {
474 pub d_dev: dev_t,
475 pub d_pdev: dev_t,
476 pub d_ino: ino_t,
477 pub d_pino: i64,
478 pub d_reclen: c_ushort,
479 pub d_name: [c_char; 1024], // Max length is _POSIX_PATH_MAX
480 }
481
482 pub struct sigevent {
483 pub sigev_notify: c_int,
484 pub sigev_signo: c_int,
485 pub sigev_value: crate::sigval,
486 __unused1: Padding<*mut c_void>, // actually a function pointer
487 pub sigev_notify_attributes: *mut crate::pthread_attr_t,
488 }
489
490 pub struct utmpx {
491 pub ut_type: c_short,
492 pub ut_tv: crate::timeval,
493 pub ut_id: [c_char; 8],
494 pub ut_pid: crate::pid_t,
495 pub ut_user: [c_char; 32],
496 pub ut_line: [c_char; 16],
497 pub ut_host: [c_char; 128],
498 __ut_reserved: Padding<[c_char; 64]>,
499 }
500 }
501
502 pub const EXIT_FAILURE: c_int = 1;
503 pub const EXIT_SUCCESS: c_int = 0;
504 pub const RAND_MAX: c_int = 2147483647;
505 pub const EOF: c_int = -1;
506 pub const SEEK_SET: c_int = 0;
507 pub const SEEK_CUR: c_int = 1;
508 pub const SEEK_END: c_int = 2;
509 pub const L_SET: c_int = SEEK_SET;
510 pub const L_INCR: c_int = SEEK_CUR;
511 pub const L_XTND: c_int = SEEK_END;
512 pub const _IOFBF: c_int = 0;
513 pub const _IONBF: c_int = 2;
514 pub const _IOLBF: c_int = 1;
515
516 pub const F_DUPFD: c_int = 0x0001;
517 pub const F_GETFD: c_int = 0x0002;
518 pub const F_SETFD: c_int = 0x0004;
519 pub const F_GETFL: c_int = 0x0008;
520 pub const F_SETFL: c_int = 0x0010;
521 pub const F_GETLK: c_int = 0x0020;
522 pub const F_SETLK: c_int = 0x0080;
523 pub const F_SETLKW: c_int = 0x0100;
524 pub const F_DUPFD_CLOEXEC: c_int = 0x0200;
525
526 pub const F_RDLCK: c_int = 0x0040;
527 pub const F_UNLCK: c_int = 0x0200;
528 pub const F_WRLCK: c_int = 0x0400;
529
530 pub const AT_FDCWD: c_int = -100;
531 pub const AT_SYMLINK_NOFOLLOW: c_int = 0x01;
532 pub const AT_SYMLINK_FOLLOW: c_int = 0x02;
533 pub const AT_REMOVEDIR: c_int = 0x04;
534 pub const AT_EACCESS: c_int = 0x08;
535
536 pub const POLLIN: c_short = 0x0001;
537 pub const POLLOUT: c_short = 0x0002;
538 pub const POLLRDNORM: c_short = POLLIN;
539 pub const POLLWRNORM: c_short = POLLOUT;
540 pub const POLLRDBAND: c_short = 0x0008;
541 pub const POLLWRBAND: c_short = 0x0010;
542 pub const POLLPRI: c_short = 0x0020;
543 pub const POLLERR: c_short = 0x0004;
544 pub const POLLHUP: c_short = 0x0080;
545 pub const POLLNVAL: c_short = 0x1000;
546
547 pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
548 pub const PTHREAD_CREATE_DETACHED: c_int = 1;
549
550 pub const CLOCK_REALTIME: c_int = -1;
551 pub const CLOCK_MONOTONIC: c_int = 0;
552 pub const CLOCK_PROCESS_CPUTIME_ID: c_int = -2;
553 pub const CLOCK_THREAD_CPUTIME_ID: c_int = -3;
554
555 pub const RLIMIT_CORE: c_int = 0;
556 pub const RLIMIT_CPU: c_int = 1;
557 pub const RLIMIT_DATA: c_int = 2;
558 pub const RLIMIT_FSIZE: c_int = 3;
559 pub const RLIMIT_NOFILE: c_int = 4;
560 pub const RLIMIT_STACK: c_int = 5;
561 pub const RLIMIT_AS: c_int = 6;
562 pub const RLIM_INFINITY: crate::rlim_t = 0xffffffff;
563 // Haiku specific
564 pub const RLIMIT_NOVMON: c_int = 7;
565 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
566 pub const RLIM_NLIMITS: c_int = 8;
567
568 pub const RUSAGE_SELF: c_int = 0;
569
570 pub const RTLD_LAZY: c_int = 0;
571
572 pub const NCCS: usize = 11;
573
574 pub const O_RDONLY: c_int = 0x0000;
575 pub const O_WRONLY: c_int = 0x0001;
576 pub const O_RDWR: c_int = 0x0002;
577 pub const O_ACCMODE: c_int = 0x0003;
578
579 pub const O_EXCL: c_int = 0x0100;
580 pub const O_CREAT: c_int = 0x0200;
581 pub const O_TRUNC: c_int = 0x0400;
582 pub const O_NOCTTY: c_int = 0x1000;
583 pub const O_NOTRAVERSE: c_int = 0x2000;
584
585 pub const O_CLOEXEC: c_int = 0x00000040;
586 pub const O_NONBLOCK: c_int = 0x00000080;
587 pub const O_APPEND: c_int = 0x00000800;
588 pub const O_SYNC: c_int = 0x00010000;
589 pub const O_RSYNC: c_int = 0x00020000;
590 pub const O_DSYNC: c_int = 0x00040000;
591 pub const O_NOFOLLOW: c_int = 0x00080000;
592 pub const O_NOCACHE: c_int = 0x00100000;
593 pub const O_DIRECTORY: c_int = 0x00200000;
594
595 pub const S_IFIFO: mode_t = 0o1_0000;
596 pub const S_IFCHR: mode_t = 0o2_0000;
597 pub const S_IFBLK: mode_t = 0o6_0000;
598 pub const S_IFDIR: mode_t = 0o4_0000;
599 pub const S_IFREG: mode_t = 0o10_0000;
600 pub const S_IFLNK: mode_t = 0o12_0000;
601 pub const S_IFSOCK: mode_t = 0o14_0000;
602 pub const S_IFMT: mode_t = 0o17_0000;
603
604 pub const S_IRWXU: mode_t = 0o0700;
605 pub const S_IRUSR: mode_t = 0o0400;
606 pub const S_IWUSR: mode_t = 0o0200;
607 pub const S_IXUSR: mode_t = 0o0100;
608 pub const S_IRWXG: mode_t = 0o0070;
609 pub const S_IRGRP: mode_t = 0o0040;
610 pub const S_IWGRP: mode_t = 0o0020;
611 pub const S_IXGRP: mode_t = 0o0010;
612 pub const S_IRWXO: mode_t = 0o0007;
613 pub const S_IROTH: mode_t = 0o0004;
614 pub const S_IWOTH: mode_t = 0o0002;
615 pub const S_IXOTH: mode_t = 0o0001;
616
617 pub const F_OK: c_int = 0;
618 pub const R_OK: c_int = 4;
619 pub const W_OK: c_int = 2;
620 pub const X_OK: c_int = 1;
621
622 pub const SIGHUP: c_int = 1;
623 pub const SIGINT: c_int = 2;
624 pub const SIGQUIT: c_int = 3;
625 pub const SIGILL: c_int = 4;
626 pub const SIGCHLD: c_int = 5;
627 pub const SIGABRT: c_int = 6;
628 pub const SIGPIPE: c_int = 7;
629 pub const SIGFPE: c_int = 8;
630 pub const SIGKILL: c_int = 9;
631 pub const SIGSTOP: c_int = 10;
632 pub const SIGSEGV: c_int = 11;
633 pub const SIGCONT: c_int = 12;
634 pub const SIGTSTP: c_int = 13;
635 pub const SIGALRM: c_int = 14;
636 pub const SIGTERM: c_int = 15;
637 pub const SIGTTIN: c_int = 16;
638 pub const SIGTTOU: c_int = 17;
639 pub const SIGUSR1: c_int = 18;
640 pub const SIGUSR2: c_int = 19;
641 pub const SIGWINCH: c_int = 20;
642 pub const SIGKILLTHR: c_int = 21;
643 pub const SIGTRAP: c_int = 22;
644 pub const SIGPOLL: c_int = 23;
645 pub const SIGPROF: c_int = 24;
646 pub const SIGSYS: c_int = 25;
647 pub const SIGURG: c_int = 26;
648 pub const SIGVTALRM: c_int = 27;
649 pub const SIGXCPU: c_int = 28;
650 pub const SIGXFSZ: c_int = 29;
651 pub const SIGBUS: c_int = 30;
652
653 pub const SIG_BLOCK: c_int = 1;
654 pub const SIG_UNBLOCK: c_int = 2;
655 pub const SIG_SETMASK: c_int = 3;
656
657 pub const SIGEV_NONE: c_int = 0;
658 pub const SIGEV_SIGNAL: c_int = 1;
659 pub const SIGEV_THREAD: c_int = 2;
660
661 pub const EAI_AGAIN: c_int = 2;
662 pub const EAI_BADFLAGS: c_int = 3;
663 pub const EAI_FAIL: c_int = 4;
664 pub const EAI_FAMILY: c_int = 5;
665 pub const EAI_MEMORY: c_int = 6;
666 pub const EAI_NODATA: c_int = 7;
667 pub const EAI_NONAME: c_int = 8;
668 pub const EAI_SERVICE: c_int = 9;
669 pub const EAI_SOCKTYPE: c_int = 10;
670 pub const EAI_SYSTEM: c_int = 11;
671 pub const EAI_OVERFLOW: c_int = 14;
672
673 pub const PROT_NONE: c_int = 0;
674 pub const PROT_READ: c_int = 1;
675 pub const PROT_WRITE: c_int = 2;
676 pub const PROT_EXEC: c_int = 4;
677
678 pub const LC_ALL: c_int = 0;
679 pub const LC_COLLATE: c_int = 1;
680 pub const LC_CTYPE: c_int = 2;
681 pub const LC_MONETARY: c_int = 3;
682 pub const LC_NUMERIC: c_int = 4;
683 pub const LC_TIME: c_int = 5;
684 pub const LC_MESSAGES: c_int = 6;
685
686 // FIXME(haiku): Haiku does not have MAP_FILE, but library/std/os.rs requires it
687 pub const MAP_FILE: c_int = 0x00;
688 pub const MAP_SHARED: c_int = 0x01;
689 pub const MAP_PRIVATE: c_int = 0x02;
690 pub const MAP_FIXED: c_int = 0x04;
691 pub const MAP_ANONYMOUS: c_int = 0x08;
692 pub const MAP_NORESERVE: c_int = 0x10;
693 pub const MAP_ANON: c_int = MAP_ANONYMOUS;
694
695 pub const MAP_FAILED: *mut c_void = !0 as *mut c_void;
696
697 pub const MS_ASYNC: c_int = 0x01;
698 pub const MS_INVALIDATE: c_int = 0x04;
699 pub const MS_SYNC: c_int = 0x02;
700
701 pub const E2BIG: c_int = -2147454975;
702 pub const ECHILD: c_int = -2147454974;
703 pub const EDEADLK: c_int = -2147454973;
704 pub const EFBIG: c_int = -2147454972;
705 pub const EMLINK: c_int = -2147454971;
706 pub const ENFILE: c_int = -2147454970;
707 pub const ENODEV: c_int = -2147454969;
708 pub const ENOLCK: c_int = -2147454968;
709 pub const ENOSYS: c_int = -2147454967;
710 pub const ENOTTY: c_int = -2147454966;
711 pub const ENXIO: c_int = -2147454965;
712 pub const ESPIPE: c_int = -2147454964;
713 pub const ESRCH: c_int = -2147454963;
714 pub const EFPOS: c_int = -2147454962;
715 pub const ESIGPARM: c_int = -2147454961;
716 pub const EDOM: c_int = -2147454960;
717 pub const ERANGE: c_int = -2147454959;
718 pub const EPROTOTYPE: c_int = -2147454958;
719 pub const EPROTONOSUPPORT: c_int = -2147454957;
720 pub const EPFNOSUPPORT: c_int = -2147454956;
721 pub const EAFNOSUPPORT: c_int = -2147454955;
722 pub const EADDRINUSE: c_int = -2147454954;
723 pub const EADDRNOTAVAIL: c_int = -2147454953;
724 pub const ENETDOWN: c_int = -2147454952;
725 pub const ENETUNREACH: c_int = -2147454951;
726 pub const ENETRESET: c_int = -2147454950;
727 pub const ECONNABORTED: c_int = -2147454949;
728 pub const ECONNRESET: c_int = -2147454948;
729 pub const EISCONN: c_int = -2147454947;
730 pub const ENOTCONN: c_int = -2147454946;
731 pub const ESHUTDOWN: c_int = -2147454945;
732 pub const ECONNREFUSED: c_int = -2147454944;
733 pub const EHOSTUNREACH: c_int = -2147454943;
734 pub const ENOPROTOOPT: c_int = -2147454942;
735 pub const ENOBUFS: c_int = -2147454941;
736 pub const EINPROGRESS: c_int = -2147454940;
737 pub const EALREADY: c_int = -2147454939;
738 pub const EILSEQ: c_int = -2147454938;
739 pub const ENOMSG: c_int = -2147454937;
740 pub const ESTALE: c_int = -2147454936;
741 pub const EOVERFLOW: c_int = -2147454935;
742 pub const EMSGSIZE: c_int = -2147454934;
743 pub const EOPNOTSUPP: c_int = -2147454933;
744 pub const ENOTSOCK: c_int = -2147454932;
745 pub const EHOSTDOWN: c_int = -2147454931;
746 pub const EBADMSG: c_int = -2147454930;
747 pub const ECANCELED: c_int = -2147454929;
748 pub const EDESTADDRREQ: c_int = -2147454928;
749 pub const EDQUOT: c_int = -2147454927;
750 pub const EIDRM: c_int = -2147454926;
751 pub const EMULTIHOP: c_int = -2147454925;
752 pub const ENODATA: c_int = -2147454924;
753 pub const ENOLINK: c_int = -2147454923;
754 pub const ENOSR: c_int = -2147454922;
755 pub const ENOSTR: c_int = -2147454921;
756 pub const ENOTSUP: c_int = -2147454920;
757 pub const EPROTO: c_int = -2147454919;
758 pub const ETIME: c_int = -2147454918;
759 pub const ETXTBSY: c_int = -2147454917;
760 pub const ENOATTR: c_int = -2147454916;
761
762 // INT_MIN
763 pub const ENOMEM: c_int = -2147483648;
764
765 // POSIX errors that can be mapped to BeOS error codes
766 pub const EACCES: c_int = -2147483646;
767 pub const EINTR: c_int = -2147483638;
768 pub const EIO: c_int = -2147483647;
769 pub const EBUSY: c_int = -2147483634;
770 pub const EFAULT: c_int = -2147478783;
771 pub const ETIMEDOUT: c_int = -2147483639;
772 pub const EAGAIN: c_int = -2147483637;
773 pub const EWOULDBLOCK: c_int = -2147483637;
774 pub const EBADF: c_int = -2147459072;
775 pub const EEXIST: c_int = -2147459070;
776 pub const EINVAL: c_int = -2147483643;
777 pub const ENAMETOOLONG: c_int = -2147459068;
778 pub const ENOENT: c_int = -2147459069;
779 pub const EPERM: c_int = -2147483633;
780 pub const ENOTDIR: c_int = -2147459067;
781 pub const EISDIR: c_int = -2147459063;
782 pub const ENOTEMPTY: c_int = -2147459066;
783 pub const ENOSPC: c_int = -2147459065;
784 pub const EROFS: c_int = -2147459064;
785 pub const EMFILE: c_int = -2147459062;
786 pub const EXDEV: c_int = -2147459061;
787 pub const ELOOP: c_int = -2147459060;
788 pub const ENOEXEC: c_int = -2147478782;
789 pub const EPIPE: c_int = -2147459059;
790
791 pub const IPPROTO_RAW: c_int = 255;
792
793 // These are prefixed with POSIX_ on Haiku
794 pub const MADV_NORMAL: c_int = 1;
795 pub const MADV_SEQUENTIAL: c_int = 2;
796 pub const MADV_RANDOM: c_int = 3;
797 pub const MADV_WILLNEED: c_int = 4;
798 pub const MADV_DONTNEED: c_int = 5;
799 pub const MADV_FREE: c_int = 6;
800
801 // https://github.com/haiku/haiku/blob/HEAD/headers/posix/net/if.h#L80
802 pub const IFF_UP: c_int = 0x0001;
803 pub const IFF_BROADCAST: c_int = 0x0002; // valid broadcast address
804 pub const IFF_LOOPBACK: c_int = 0x0008;
805 pub const IFF_POINTOPOINT: c_int = 0x0010; // point-to-point link
806 pub const IFF_NOARP: c_int = 0x0040; // no address resolution
807 pub const IFF_AUTOUP: c_int = 0x0080; // auto dial
808 pub const IFF_PROMISC: c_int = 0x0100; // receive all packets
809 pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets
810 pub const IFF_SIMPLEX: c_int = 0x0800; // doesn't receive own transmissions
811 pub const IFF_LINK: c_int = 0x1000; // has link
812 pub const IFF_AUTO_CONFIGURED: c_int = 0x2000;
813 pub const IFF_CONFIGURING: c_int = 0x4000;
814 pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast
815
816 pub const AF_UNSPEC: c_int = 0;
817 pub const AF_INET: c_int = 1;
818 pub const AF_APPLETALK: c_int = 2;
819 pub const AF_ROUTE: c_int = 3;
820 pub const AF_LINK: c_int = 4;
821 pub const AF_INET6: c_int = 5;
822 pub const AF_DLI: c_int = 6;
823 pub const AF_IPX: c_int = 7;
824 pub const AF_NOTIFY: c_int = 8;
825 pub const AF_LOCAL: c_int = 9;
826 pub const AF_UNIX: c_int = AF_LOCAL;
827 pub const AF_BLUETOOTH: c_int = 10;
828
829 pub const PF_UNSPEC: c_int = AF_UNSPEC;
830 pub const PF_INET: c_int = AF_INET;
831 pub const PF_ROUTE: c_int = AF_ROUTE;
832 pub const PF_LINK: c_int = AF_LINK;
833 pub const PF_INET6: c_int = AF_INET6;
834 pub const PF_LOCAL: c_int = AF_LOCAL;
835 pub const PF_UNIX: c_int = AF_UNIX;
836 pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH;
837
838 pub const IP_OPTIONS: c_int = 1;
839 pub const IP_HDRINCL: c_int = 2;
840 pub const IP_TOS: c_int = 3;
841 pub const IP_TTL: c_int = 4;
842 pub const IP_RECVOPTS: c_int = 5;
843 pub const IP_RECVRETOPTS: c_int = 6;
844 pub const IP_RECVDSTADDR: c_int = 7;
845 pub const IP_RETOPTS: c_int = 8;
846 pub const IP_MULTICAST_IF: c_int = 9;
847 pub const IP_MULTICAST_TTL: c_int = 10;
848 pub const IP_MULTICAST_LOOP: c_int = 11;
849 pub const IP_ADD_MEMBERSHIP: c_int = 12;
850 pub const IP_DROP_MEMBERSHIP: c_int = 13;
851 pub const IP_BLOCK_SOURCE: c_int = 14;
852 pub const IP_UNBLOCK_SOURCE: c_int = 15;
853 pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 16;
854 pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 17;
855
856 pub const TCP_NODELAY: c_int = 0x01;
857 pub const TCP_MAXSEG: c_int = 0x02;
858 pub const TCP_NOPUSH: c_int = 0x04;
859 pub const TCP_NOOPT: c_int = 0x08;
860
861 pub const IF_NAMESIZE: size_t = 32;
862 pub const IFNAMSIZ: size_t = IF_NAMESIZE;
863
864 pub const IPV6_MULTICAST_IF: c_int = 24;
865 pub const IPV6_MULTICAST_HOPS: c_int = 25;
866 pub const IPV6_MULTICAST_LOOP: c_int = 26;
867 pub const IPV6_UNICAST_HOPS: c_int = 27;
868 pub const IPV6_JOIN_GROUP: c_int = 28;
869 pub const IPV6_LEAVE_GROUP: c_int = 29;
870 pub const IPV6_V6ONLY: c_int = 30;
871 pub const IPV6_PKTINFO: c_int = 31;
872 pub const IPV6_RECVPKTINFO: c_int = 32;
873 pub const IPV6_HOPLIMIT: c_int = 33;
874 pub const IPV6_RECVHOPLIMIT: c_int = 34;
875 pub const IPV6_HOPOPTS: c_int = 35;
876 pub const IPV6_DSTOPTS: c_int = 36;
877 pub const IPV6_RTHDR: c_int = 37;
878
879 pub const MSG_OOB: c_int = 0x0001;
880 pub const MSG_PEEK: c_int = 0x0002;
881 pub const MSG_DONTROUTE: c_int = 0x0004;
882 pub const MSG_EOR: c_int = 0x0008;
883 pub const MSG_TRUNC: c_int = 0x0010;
884 pub const MSG_CTRUNC: c_int = 0x0020;
885 pub const MSG_WAITALL: c_int = 0x0040;
886 pub const MSG_DONTWAIT: c_int = 0x0080;
887 pub const MSG_BCAST: c_int = 0x0100;
888 pub const MSG_MCAST: c_int = 0x0200;
889 pub const MSG_EOF: c_int = 0x0400;
890 pub const MSG_NOSIGNAL: c_int = 0x0800;
891
892 pub const SHUT_RD: c_int = 0;
893 pub const SHUT_WR: c_int = 1;
894 pub const SHUT_RDWR: c_int = 2;
895
896 pub const LOCK_SH: c_int = 0x01;
897 pub const LOCK_EX: c_int = 0x02;
898 pub const LOCK_NB: c_int = 0x04;
899 pub const LOCK_UN: c_int = 0x08;
900
901 pub const MINSIGSTKSZ: size_t = 8192;
902 pub const SIGSTKSZ: size_t = 16384;
903
904 pub const IOV_MAX: c_int = 1024;
905 pub const PATH_MAX: c_int = 1024;
906
907 pub const SA_NOCLDSTOP: c_int = 0x01;
908 pub const SA_NOCLDWAIT: c_int = 0x02;
909 pub const SA_RESETHAND: c_int = 0x04;
910 pub const SA_NODEFER: c_int = 0x08;
911 pub const SA_RESTART: c_int = 0x10;
912 pub const SA_ONSTACK: c_int = 0x20;
913 pub const SA_SIGINFO: c_int = 0x40;
914 pub const SA_NOMASK: c_int = SA_NODEFER;
915 pub const SA_STACK: c_int = SA_ONSTACK;
916 pub const SA_ONESHOT: c_int = SA_RESETHAND;
917
918 pub const SS_ONSTACK: c_int = 0x1;
919 pub const SS_DISABLE: c_int = 0x2;
920
921 // DIFF(main): changed to `c_int` in 500365e1
922 pub const FD_SETSIZE: usize = 1024;
923
924 pub const RTLD_LOCAL: c_int = 0x0;
925 pub const RTLD_NOW: c_int = 0x1;
926 pub const RTLD_GLOBAL: c_int = 0x2;
927 pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut();
928
929 pub const BUFSIZ: c_uint = 8192;
930 pub const FILENAME_MAX: c_uint = 256;
931 pub const FOPEN_MAX: c_uint = 128;
932 pub const L_tmpnam: c_uint = 512;
933 pub const TMP_MAX: c_uint = 32768;
934
935 pub const _PC_CHOWN_RESTRICTED: c_int = 1;
936 pub const _PC_MAX_CANON: c_int = 2;
937 pub const _PC_MAX_INPUT: c_int = 3;
938 pub const _PC_NAME_MAX: c_int = 4;
939 pub const _PC_NO_TRUNC: c_int = 5;
940 pub const _PC_PATH_MAX: c_int = 6;
941 pub const _PC_PIPE_BUF: c_int = 7;
942 pub const _PC_VDISABLE: c_int = 8;
943 pub const _PC_LINK_MAX: c_int = 25;
944 pub const _PC_SYNC_IO: c_int = 26;
945 pub const _PC_ASYNC_IO: c_int = 27;
946 pub const _PC_PRIO_IO: c_int = 28;
947 pub const _PC_SOCK_MAXBUF: c_int = 29;
948 pub const _PC_FILESIZEBITS: c_int = 30;
949 pub const _PC_REC_INCR_XFER_SIZE: c_int = 31;
950 pub const _PC_REC_MAX_XFER_SIZE: c_int = 32;
951 pub const _PC_REC_MIN_XFER_SIZE: c_int = 33;
952 pub const _PC_REC_XFER_ALIGN: c_int = 34;
953 pub const _PC_ALLOC_SIZE_MIN: c_int = 35;
954 pub const _PC_SYMLINK_MAX: c_int = 36;
955 pub const _PC_2_SYMLINKS: c_int = 37;
956 pub const _PC_XATTR_EXISTS: c_int = 38;
957 pub const _PC_XATTR_ENABLED: c_int = 39;
958
959 pub const FIONBIO: c_ulong = 0xbe000000;
960 pub const FIONREAD: c_ulong = 0xbe000001;
961 pub const FIOSEEKDATA: c_ulong = 0xbe000002;
962 pub const FIOSEEKHOLE: c_ulong = 0xbe000003;
963
964 pub const _SC_ARG_MAX: c_int = 15;
965 pub const _SC_CHILD_MAX: c_int = 16;
966 pub const _SC_CLK_TCK: c_int = 17;
967 pub const _SC_JOB_CONTROL: c_int = 18;
968 pub const _SC_NGROUPS_MAX: c_int = 19;
969 pub const _SC_OPEN_MAX: c_int = 20;
970 pub const _SC_SAVED_IDS: c_int = 21;
971 pub const _SC_STREAM_MAX: c_int = 22;
972 pub const _SC_TZNAME_MAX: c_int = 23;
973 pub const _SC_VERSION: c_int = 24;
974 pub const _SC_GETGR_R_SIZE_MAX: c_int = 25;
975 pub const _SC_GETPW_R_SIZE_MAX: c_int = 26;
976 pub const _SC_PAGESIZE: c_int = 27;
977 pub const _SC_PAGE_SIZE: c_int = 27;
978 pub const _SC_SEM_NSEMS_MAX: c_int = 28;
979 pub const _SC_SEM_VALUE_MAX: c_int = 29;
980 pub const _SC_SEMAPHORES: c_int = 30;
981 pub const _SC_THREADS: c_int = 31;
982 pub const _SC_IOV_MAX: c_int = 32;
983 pub const _SC_UIO_MAXIOV: c_int = 32;
984 pub const _SC_NPROCESSORS_CONF: c_int = 34;
985 pub const _SC_NPROCESSORS_ONLN: c_int = 35;
986 pub const _SC_ATEXIT_MAX: c_int = 37;
987 pub const _SC_PASS_MAX: c_int = 39;
988 pub const _SC_PHYS_PAGES: c_int = 40;
989 pub const _SC_AVPHYS_PAGES: c_int = 41;
990 pub const _SC_PIPE: c_int = 42;
991 pub const _SC_SELECT: c_int = 43;
992 pub const _SC_POLL: c_int = 44;
993 pub const _SC_MAPPED_FILES: c_int = 45;
994 pub const _SC_THREAD_PROCESS_SHARED: c_int = 46;
995 pub const _SC_THREAD_STACK_MIN: c_int = 47;
996 pub const _SC_THREAD_ATTR_STACKADDR: c_int = 48;
997 pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 49;
998 pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 50;
999 pub const _SC_REALTIME_SIGNALS: c_int = 51;
1000 pub const _SC_MEMORY_PROTECTION: c_int = 52;
1001 pub const _SC_SIGQUEUE_MAX: c_int = 53;
1002 pub const _SC_RTSIG_MAX: c_int = 54;
1003 pub const _SC_MONOTONIC_CLOCK: c_int = 55;
1004 pub const _SC_DELAYTIMER_MAX: c_int = 56;
1005 pub const _SC_TIMER_MAX: c_int = 57;
1006 pub const _SC_TIMERS: c_int = 58;
1007 pub const _SC_CPUTIME: c_int = 59;
1008 pub const _SC_THREAD_CPUTIME: c_int = 60;
1009 pub const _SC_HOST_NAME_MAX: c_int = 61;
1010 pub const _SC_REGEXP: c_int = 62;
1011 pub const _SC_SYMLOOP_MAX: c_int = 63;
1012 pub const _SC_SHELL: c_int = 64;
1013 pub const _SC_TTY_NAME_MAX: c_int = 65;
1014 pub const _SC_ADVISORY_INFO: c_int = 66;
1015 pub const _SC_BARRIERS: c_int = 67;
1016 pub const _SC_CLOCK_SELECTION: c_int = 68;
1017 pub const _SC_FSYNC: c_int = 69;
1018 pub const _SC_IPV6: c_int = 70;
1019 pub const _SC_MEMLOCK: c_int = 71;
1020 pub const _SC_MEMLOCK_RANGE: c_int = 72;
1021 pub const _SC_MESSAGE_PASSING: c_int = 73;
1022 pub const _SC_PRIORITIZED_IO: c_int = 74;
1023 pub const _SC_PRIORITY_SCHEDULING: c_int = 75;
1024 pub const _SC_READER_WRITER_LOCKS: c_int = 76;
1025 pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 77;
1026 pub const _SC_SPAWN: c_int = 78;
1027 pub const _SC_SPIN_LOCKS: c_int = 79;
1028 pub const _SC_SPORADIC_SERVER: c_int = 80;
1029 pub const _SC_SYNCHRONIZED_IO: c_int = 81;
1030 pub const _SC_THREAD_PRIO_INHERIT: c_int = 82;
1031 pub const _SC_THREAD_PRIO_PROTECT: c_int = 83;
1032 pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 84;
1033 pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 85;
1034 pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 86;
1035 pub const _SC_THREAD_SPORADIC_SERVER: c_int = 87;
1036 pub const _SC_TIMEOUTS: c_int = 88;
1037 pub const _SC_TRACE: c_int = 89;
1038 pub const _SC_TRACE_EVENT_FILTER: c_int = 90;
1039 pub const _SC_TRACE_INHERIT: c_int = 91;
1040 pub const _SC_TRACE_LOG: c_int = 92;
1041 pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 93;
1042 pub const _SC_V6_ILP32_OFF32: c_int = 94;
1043 pub const _SC_V6_ILP32_OFFBIG: c_int = 95;
1044 pub const _SC_V6_LP64_OFF64: c_int = 96;
1045 pub const _SC_V6_LPBIG_OFFBIG: c_int = 97;
1046 pub const _SC_V7_ILP32_OFF32: c_int = 98;
1047 pub const _SC_V7_ILP32_OFFBIG: c_int = 99;
1048 pub const _SC_V7_LP64_OFF64: c_int = 100;
1049 pub const _SC_V7_LPBIG_OFFBIG: c_int = 101;
1050 pub const _SC_2_C_BIND: c_int = 102;
1051 pub const _SC_2_C_DEV: c_int = 103;
1052 pub const _SC_2_CHAR_TERM: c_int = 104;
1053 pub const _SC_2_FORT_DEV: c_int = 105;
1054 pub const _SC_2_FORT_RUN: c_int = 106;
1055 pub const _SC_2_LOCALEDEF: c_int = 107;
1056 pub const _SC_2_PBS: c_int = 108;
1057 pub const _SC_2_PBS_ACCOUNTING: c_int = 109;
1058 pub const _SC_2_PBS_CHECKPOINT: c_int = 110;
1059 pub const _SC_2_PBS_LOCATE: c_int = 111;
1060 pub const _SC_2_PBS_MESSAGE: c_int = 112;
1061 pub const _SC_2_PBS_TRACK: c_int = 113;
1062 pub const _SC_2_SW_DEV: c_int = 114;
1063 pub const _SC_2_UPE: c_int = 115;
1064 pub const _SC_2_VERSION: c_int = 116;
1065 pub const _SC_XOPEN_CRYPT: c_int = 117;
1066 pub const _SC_XOPEN_ENH_I18N: c_int = 118;
1067 pub const _SC_XOPEN_REALTIME: c_int = 119;
1068 pub const _SC_XOPEN_REALTIME_THREADS: c_int = 120;
1069 pub const _SC_XOPEN_SHM: c_int = 121;
1070 pub const _SC_XOPEN_STREAMS: c_int = 122;
1071 pub const _SC_XOPEN_UNIX: c_int = 123;
1072 pub const _SC_XOPEN_UUCP: c_int = 124;
1073 pub const _SC_XOPEN_VERSION: c_int = 125;
1074 pub const _SC_BC_BASE_MAX: c_int = 129;
1075 pub const _SC_BC_DIM_MAX: c_int = 130;
1076 pub const _SC_BC_SCALE_MAX: c_int = 131;
1077 pub const _SC_BC_STRING_MAX: c_int = 132;
1078 pub const _SC_COLL_WEIGHTS_MAX: c_int = 133;
1079 pub const _SC_EXPR_NEST_MAX: c_int = 134;
1080 pub const _SC_LINE_MAX: c_int = 135;
1081 pub const _SC_LOGIN_NAME_MAX: c_int = 136;
1082 pub const _SC_MQ_OPEN_MAX: c_int = 137;
1083 pub const _SC_MQ_PRIO_MAX: c_int = 138;
1084 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 139;
1085 pub const _SC_THREAD_KEYS_MAX: c_int = 140;
1086 pub const _SC_THREAD_THREADS_MAX: c_int = 141;
1087 pub const _SC_RE_DUP_MAX: c_int = 142;
1088
1089 pub const PTHREAD_STACK_MIN: size_t = 8192;
1090
1091 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
1092 flags: 0,
1093 lock: 0,
1094 unused: Padding::uninit(),
1095 owner: -1,
1096 owner_count: 0,
1097 };
1098 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1099 flags: 0,
1100 unused: Padding::uninit(),
1101 mutex: 0 as *mut _,
1102 waiter_count: 0,
1103 lock: 0,
1104 };
1105 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1106 flags: 0,
1107 owner: -1,
1108 lock_sem: 0,
1109 lock_count: 0,
1110 reader_count: 0,
1111 writer_count: 0,
1112 waiters: [0 as *mut _; 2],
1113 };
1114
1115 pub const PTHREAD_MUTEX_DEFAULT: c_int = 0;
1116 pub const PTHREAD_MUTEX_NORMAL: c_int = 1;
1117 pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2;
1118 pub const PTHREAD_MUTEX_RECURSIVE: c_int = 3;
1119
1120 pub const FIOCLEX: c_ulong = 0; // FIXME(haiku): does not exist on Haiku!
1121
1122 pub const RUSAGE_CHILDREN: c_int = -1;
1123
1124 pub const SOCK_STREAM: c_int = 1;
1125 pub const SOCK_DGRAM: c_int = 2;
1126 pub const SOCK_RAW: c_int = 3;
1127 pub const SOCK_SEQPACKET: c_int = 5;
1128 pub const SOCK_NONBLOCK: c_int = 0x00040000;
1129 pub const SOCK_CLOEXEC: c_int = 0x00080000;
1130
1131 pub const SOL_SOCKET: c_int = -1;
1132 pub const SO_ACCEPTCONN: c_int = 0x00000001;
1133 pub const SO_BROADCAST: c_int = 0x00000002;
1134 pub const SO_DEBUG: c_int = 0x00000004;
1135 pub const SO_DONTROUTE: c_int = 0x00000008;
1136 pub const SO_KEEPALIVE: c_int = 0x00000010;
1137 pub const SO_OOBINLINE: c_int = 0x00000020;
1138 pub const SO_REUSEADDR: c_int = 0x00000040;
1139 pub const SO_REUSEPORT: c_int = 0x00000080;
1140 pub const SO_USELOOPBACK: c_int = 0x00000100;
1141 pub const SO_LINGER: c_int = 0x00000200;
1142 pub const SO_SNDBUF: c_int = 0x40000001;
1143 pub const SO_SNDLOWAT: c_int = 0x40000002;
1144 pub const SO_SNDTIMEO: c_int = 0x40000003;
1145 pub const SO_RCVBUF: c_int = 0x40000004;
1146 pub const SO_RCVLOWAT: c_int = 0x40000005;
1147 pub const SO_RCVTIMEO: c_int = 0x40000006;
1148 pub const SO_ERROR: c_int = 0x40000007;
1149 pub const SO_TYPE: c_int = 0x40000008;
1150 pub const SO_NONBLOCK: c_int = 0x40000009;
1151 pub const SO_BINDTODEVICE: c_int = 0x4000000a;
1152 pub const SO_PEERCRED: c_int = 0x4000000b;
1153
1154 pub const SCM_RIGHTS: c_int = 0x01;
1155
1156 pub const SOMAXCONN: c_int = 32;
1157
1158 pub const NI_MAXHOST: size_t = 1025;
1159
1160 pub const WNOHANG: c_int = 0x01;
1161 pub const WUNTRACED: c_int = 0x02;
1162 pub const WCONTINUED: c_int = 0x04;
1163 pub const WEXITED: c_int = 0x08;
1164 pub const WSTOPPED: c_int = 0x10;
1165 pub const WNOWAIT: c_int = 0x20;
1166
1167 // si_code values for SIGBUS signal
1168 pub const BUS_ADRALN: c_int = 40;
1169 pub const BUS_ADRERR: c_int = 41;
1170 pub const BUS_OBJERR: c_int = 42;
1171
1172 // si_code values for SIGCHLD signal
1173 pub const CLD_EXITED: c_int = 60;
1174 pub const CLD_KILLED: c_int = 61;
1175 pub const CLD_DUMPED: c_int = 62;
1176 pub const CLD_TRAPPED: c_int = 63;
1177 pub const CLD_STOPPED: c_int = 64;
1178 pub const CLD_CONTINUED: c_int = 65;
1179
1180 pub const P_ALL: idtype_t = 0;
1181 pub const P_PID: idtype_t = 1;
1182 pub const P_PGID: idtype_t = 2;
1183
1184 pub const UTIME_OMIT: c_long = 1000000001;
1185 pub const UTIME_NOW: c_long = 1000000000;
1186
1187 pub const VINTR: usize = 0;
1188 pub const VQUIT: usize = 1;
1189 pub const VERASE: usize = 2;
1190 pub const VKILL: usize = 3;
1191 pub const VEOF: usize = 4;
1192 pub const VEOL: usize = 5;
1193 pub const VMIN: usize = 4;
1194 pub const VTIME: usize = 5;
1195 pub const VEOL2: usize = 6;
1196 pub const VSWTCH: usize = 7;
1197 pub const VSTART: usize = 8;
1198 pub const VSTOP: usize = 9;
1199 pub const VSUSP: usize = 10;
1200
1201 pub const IGNBRK: crate::tcflag_t = 0x01;
1202 pub const BRKINT: crate::tcflag_t = 0x02;
1203 pub const IGNPAR: crate::tcflag_t = 0x04;
1204 pub const PARMRK: crate::tcflag_t = 0x08;
1205 pub const INPCK: crate::tcflag_t = 0x10;
1206 pub const ISTRIP: crate::tcflag_t = 0x20;
1207 pub const INLCR: crate::tcflag_t = 0x40;
1208 pub const IGNCR: crate::tcflag_t = 0x80;
1209 pub const ICRNL: crate::tcflag_t = 0x100;
1210 pub const IUCLC: crate::tcflag_t = 0x200;
1211 pub const IXON: crate::tcflag_t = 0x400;
1212 pub const IXANY: crate::tcflag_t = 0x800;
1213 pub const IXOFF: crate::tcflag_t = 0x1000;
1214
1215 pub const OPOST: crate::tcflag_t = 0x00000001;
1216 pub const OLCUC: crate::tcflag_t = 0x00000002;
1217 pub const ONLCR: crate::tcflag_t = 0x00000004;
1218 pub const OCRNL: crate::tcflag_t = 0x00000008;
1219 pub const ONOCR: crate::tcflag_t = 0x00000010;
1220 pub const ONLRET: crate::tcflag_t = 0x00000020;
1221 pub const OFILL: crate::tcflag_t = 0x00000040;
1222 pub const OFDEL: crate::tcflag_t = 0x00000080;
1223 pub const NLDLY: crate::tcflag_t = 0x00000100;
1224 pub const NL0: crate::tcflag_t = 0x00000000;
1225 pub const NL1: crate::tcflag_t = 0x00000100;
1226 pub const CRDLY: crate::tcflag_t = 0x00000600;
1227 pub const CR0: crate::tcflag_t = 0x00000000;
1228 pub const CR1: crate::tcflag_t = 0x00000200;
1229 pub const CR2: crate::tcflag_t = 0x00000400;
1230 pub const CR3: crate::tcflag_t = 0x00000600;
1231 pub const TABDLY: crate::tcflag_t = 0x00001800;
1232 pub const TAB0: crate::tcflag_t = 0x00000000;
1233 pub const TAB1: crate::tcflag_t = 0x00000800;
1234 pub const TAB2: crate::tcflag_t = 0x00001000;
1235 pub const TAB3: crate::tcflag_t = 0x00001800;
1236 pub const BSDLY: crate::tcflag_t = 0x00002000;
1237 pub const BS0: crate::tcflag_t = 0x00000000;
1238 pub const BS1: crate::tcflag_t = 0x00002000;
1239 pub const VTDLY: crate::tcflag_t = 0x00004000;
1240 pub const VT0: crate::tcflag_t = 0x00000000;
1241 pub const VT1: crate::tcflag_t = 0x00004000;
1242 pub const FFDLY: crate::tcflag_t = 0x00008000;
1243 pub const FF0: crate::tcflag_t = 0x00000000;
1244 pub const FF1: crate::tcflag_t = 0x00008000;
1245
1246 pub const CSIZE: crate::tcflag_t = 0x00000020;
1247 pub const CS5: crate::tcflag_t = 0x00000000;
1248 pub const CS6: crate::tcflag_t = 0x00000000;
1249 pub const CS7: crate::tcflag_t = 0x00000000;
1250 pub const CS8: crate::tcflag_t = 0x00000020;
1251 pub const CSTOPB: crate::tcflag_t = 0x00000040;
1252 pub const CREAD: crate::tcflag_t = 0x00000080;
1253 pub const PARENB: crate::tcflag_t = 0x00000100;
1254 pub const PARODD: crate::tcflag_t = 0x00000200;
1255 pub const HUPCL: crate::tcflag_t = 0x00000400;
1256 pub const CLOCAL: crate::tcflag_t = 0x00000800;
1257 pub const XLOBLK: crate::tcflag_t = 0x00001000;
1258 pub const CTSFLOW: crate::tcflag_t = 0x00002000;
1259 pub const RTSFLOW: crate::tcflag_t = 0x00004000;
1260 pub const CRTSCTS: crate::tcflag_t = RTSFLOW | CTSFLOW;
1261
1262 pub const ISIG: crate::tcflag_t = 0x00000001;
1263 pub const ICANON: crate::tcflag_t = 0x00000002;
1264 pub const XCASE: crate::tcflag_t = 0x00000004;
1265 pub const ECHO: crate::tcflag_t = 0x00000008;
1266 pub const ECHOE: crate::tcflag_t = 0x00000010;
1267 pub const ECHOK: crate::tcflag_t = 0x00000020;
1268 pub const ECHONL: crate::tcflag_t = 0x00000040;
1269 pub const NOFLSH: crate::tcflag_t = 0x00000080;
1270 pub const TOSTOP: crate::tcflag_t = 0x00000100;
1271 pub const IEXTEN: crate::tcflag_t = 0x00000200;
1272 pub const ECHOCTL: crate::tcflag_t = 0x00000400;
1273 pub const ECHOPRT: crate::tcflag_t = 0x00000800;
1274 pub const ECHOKE: crate::tcflag_t = 0x00001000;
1275 pub const FLUSHO: crate::tcflag_t = 0x00002000;
1276 pub const PENDIN: crate::tcflag_t = 0x00004000;
1277
1278 pub const TCGB_CTS: c_int = 0x01;
1279 pub const TCGB_DSR: c_int = 0x02;
1280 pub const TCGB_RI: c_int = 0x04;
1281 pub const TCGB_DCD: c_int = 0x08;
1282 pub const TIOCM_CTS: c_int = TCGB_CTS;
1283 pub const TIOCM_CD: c_int = TCGB_DCD;
1284 pub const TIOCM_CAR: c_int = TCGB_DCD;
1285 pub const TIOCM_RI: c_int = TCGB_RI;
1286 pub const TIOCM_RNG: c_int = TCGB_RI;
1287 pub const TIOCM_DSR: c_int = TCGB_DSR;
1288 pub const TIOCM_DTR: c_int = 0x10;
1289 pub const TIOCM_RTS: c_int = 0x20;
1290
1291 pub const B0: speed_t = 0x00;
1292 pub const B50: speed_t = 0x01;
1293 pub const B75: speed_t = 0x02;
1294 pub const B110: speed_t = 0x03;
1295 pub const B134: speed_t = 0x04;
1296 pub const B150: speed_t = 0x05;
1297 pub const B200: speed_t = 0x06;
1298 pub const B300: speed_t = 0x07;
1299 pub const B600: speed_t = 0x08;
1300 pub const B1200: speed_t = 0x09;
1301 pub const B1800: speed_t = 0x0A;
1302 pub const B2400: speed_t = 0x0B;
1303 pub const B4800: speed_t = 0x0C;
1304 pub const B9600: speed_t = 0x0D;
1305 pub const B19200: speed_t = 0x0E;
1306 pub const B38400: speed_t = 0x0F;
1307 pub const B57600: speed_t = 0x10;
1308 pub const B115200: speed_t = 0x11;
1309 pub const B230400: speed_t = 0x12;
1310 pub const B31250: speed_t = 0x13;
1311
1312 pub const TCSANOW: c_int = 0x01;
1313 pub const TCSADRAIN: c_int = 0x02;
1314 pub const TCSAFLUSH: c_int = 0x04;
1315
1316 pub const TCOOFF: c_int = 0x01;
1317 pub const TCOON: c_int = 0x02;
1318 pub const TCIOFF: c_int = 0x04;
1319 pub const TCION: c_int = 0x08;
1320
1321 pub const TCIFLUSH: c_int = 0x01;
1322 pub const TCOFLUSH: c_int = 0x02;
1323 pub const TCIOFLUSH: c_int = 0x03;
1324
1325 pub const TCGETA: c_ulong = 0x8000;
1326 pub const TCSETA: c_ulong = TCGETA + 1;
1327 pub const TCSETAF: c_ulong = TCGETA + 2;
1328 pub const TCSETAW: c_ulong = TCGETA + 3;
1329 pub const TCSBRK: c_ulong = TCGETA + 5;
1330 pub const TCFLSH: c_ulong = TCGETA + 6;
1331 pub const TCXONC: c_ulong = TCGETA + 7;
1332 pub const TCGETBITS: c_ulong = TCGETA + 9;
1333 pub const TCSETDTR: c_ulong = TCGETA + 10;
1334 pub const TCSETRTS: c_ulong = TCGETA + 11;
1335 pub const TIOCGWINSZ: c_ulong = TCGETA + 12;
1336 pub const TIOCSWINSZ: c_ulong = TCGETA + 13;
1337 pub const TIOCGPGRP: c_ulong = TCGETA + 15;
1338 pub const TIOCSPGRP: c_ulong = TCGETA + 16;
1339 pub const TIOCSCTTY: c_ulong = TCGETA + 17;
1340 pub const TIOCMGET: c_ulong = TCGETA + 18;
1341 pub const TIOCMSET: c_ulong = TCGETA + 19;
1342 pub const TIOCSBRK: c_ulong = TCGETA + 20;
1343 pub const TIOCCBRK: c_ulong = TCGETA + 21;
1344 pub const TIOCMBIS: c_ulong = TCGETA + 22;
1345 pub const TIOCMBIC: c_ulong = TCGETA + 23;
1346 pub const TIOCGSID: c_ulong = TCGETA + 24;
1347 pub const TIOCOUTQ: c_ulong = TCGETA + 25;
1348 pub const TIOCEXCL: c_ulong = TCGETA + 26;
1349 pub const TIOCNXCL: c_ulong = TCGETA + 27;
1350
1351 pub const PRIO_PROCESS: c_int = 0;
1352 pub const PRIO_PGRP: c_int = 1;
1353 pub const PRIO_USER: c_int = 2;
1354
1355 // utmpx entry types
1356 pub const EMPTY: c_short = 0;
1357 pub const BOOT_TIME: c_short = 1;
1358 pub const OLD_TIME: c_short = 2;
1359 pub const NEW_TIME: c_short = 3;
1360 pub const USER_PROCESS: c_short = 4;
1361 pub const INIT_PROCESS: c_short = 5;
1362 pub const LOGIN_PROCESS: c_short = 6;
1363 pub const DEAD_PROCESS: c_short = 7;
1364
1365 pub const LOG_PID: c_int = 1 << 12;
1366 pub const LOG_CONS: c_int = 2 << 12;
1367 pub const LOG_ODELAY: c_int = 4 << 12;
1368 pub const LOG_NDELAY: c_int = 8 << 12;
1369 pub const LOG_SERIAL: c_int = 16 << 12;
1370 pub const LOG_PERROR: c_int = 32 << 12;
1371 pub const LOG_NOWAIT: c_int = 64 << 12;
1372
1373 // spawn.h
1374 // DIFF(main): changed to `c_short` in f62eb023ab
1375 pub const POSIX_SPAWN_RESETIDS: c_int = 0x01;
1376 pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02;
1377 pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10;
1378 pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20;
1379 pub const POSIX_SPAWN_SETSID: c_int = 0x40;
1380
1381 const fn CMSG_ALIGN(len: usize) -> usize {
1382 len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
1383 }
1384
1385 f! {
1386 pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
1387 if (*mhdr).msg_controllen as usize >= size_of::<cmsghdr>() {
1388 (*mhdr).msg_control as *mut cmsghdr
1389 } else {
1390 core::ptr::null_mut::<cmsghdr>()
1391 }
1392 }
1393
1394 pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar {
1395 (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::<cmsghdr>()) as isize)
1396 }
1397
1398 pub const fn CMSG_SPACE(length: c_uint) -> c_uint {
1399 (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::<cmsghdr>())) as c_uint
1400 }
1401
1402 pub const fn CMSG_LEN(length: c_uint) -> c_uint {
1403 CMSG_ALIGN(size_of::<cmsghdr>()) as c_uint + length
1404 }
1405
1406 pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
1407 if cmsg.is_null() {
1408 return crate::CMSG_FIRSTHDR(mhdr);
1409 }
1410 let next = cmsg as usize
1411 + CMSG_ALIGN((*cmsg).cmsg_len as usize)
1412 + CMSG_ALIGN(size_of::<cmsghdr>());
1413 let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
1414 if next > max {
1415 core::ptr::null_mut::<cmsghdr>()
1416 } else {
1417 (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
1418 }
1419 }
1420
1421 pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () {
1422 let fd = fd as usize;
1423 let size = size_of_val(&(*set).fds_bits[0]) * 8;
1424 (*set).fds_bits[fd / size] &= !(1 << (fd % size));
1425 return;
1426 }
1427
1428 pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool {
1429 let fd = fd as usize;
1430 let size = size_of_val(&(*set).fds_bits[0]) * 8;
1431 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0;
1432 }
1433
1434 pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () {
1435 let fd = fd as usize;
1436 let size = size_of_val(&(*set).fds_bits[0]) * 8;
1437 (*set).fds_bits[fd / size] |= 1 << (fd % size);
1438 return;
1439 }
1440
1441 pub fn FD_ZERO(set: *mut fd_set) -> () {
1442 for slot in (*set).fds_bits.iter_mut() {
1443 *slot = 0;
1444 }
1445 }
1446 }
1447
1448 safe_f! {
1449 pub const fn WIFEXITED(status: c_int) -> bool {
1450 (status & !0xff) == 0
1451 }
1452
1453 pub const fn WEXITSTATUS(status: c_int) -> c_int {
1454 status & 0xff
1455 }
1456
1457 pub const fn WIFSIGNALED(status: c_int) -> bool {
1458 ((status >> 8) & 0xff) != 0
1459 }
1460
1461 pub const fn WTERMSIG(status: c_int) -> c_int {
1462 (status >> 8) & 0xff
1463 }
1464
1465 pub const fn WIFSTOPPED(status: c_int) -> bool {
1466 ((status >> 16) & 0xff) != 0
1467 }
1468
1469 pub const fn WSTOPSIG(status: c_int) -> c_int {
1470 (status >> 16) & 0xff
1471 }
1472
1473 // actually WIFCORED, but this is used everywhere else
1474 pub const fn WCOREDUMP(status: c_int) -> bool {
1475 (status & 0x10000) != 0
1476 }
1477
1478 pub const fn WIFCONTINUED(status: c_int) -> bool {
1479 (status & 0x20000) != 0
1480 }
1481 }
1482
1483 extern "C" {
1484 pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int;
1485 pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int;
1486 pub fn getpriority(which: c_int, who: id_t) -> c_int;
1487 pub fn setpriority(which: c_int, who: id_t, priority: c_int) -> c_int;
1488
1489 pub fn endusershell();
1490 pub fn getpass(prompt: *const c_char) -> *mut c_char;
1491 pub fn getusershell() -> *mut c_char;
1492 pub fn issetugid() -> c_int;
1493 pub fn setusershell();
1494
1495 pub fn utimensat(
1496 fd: c_int,
1497 path: *const c_char,
1498 times: *const crate::timespec,
1499 flag: c_int,
1500 ) -> c_int;
1501 pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int;
1502 pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
1503 pub fn _errnop() -> *mut c_int;
1504
1505 pub fn abs(i: c_int) -> c_int;
1506 pub fn labs(i: c_long) -> c_long;
1507 pub fn rand() -> c_int;
1508 pub fn srand(seed: c_uint);
1509 pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int;
1510 pub fn freeifaddrs(ifa: *mut crate::ifaddrs);
1511 pub fn ppoll(
1512 fds: *mut crate::pollfd,
1513 numfds: crate::nfds_t,
1514 timeout: *const crate::timespec,
1515 sigMask: *const sigset_t,
1516 ) -> c_int;
1517
1518 pub fn getspent() -> *mut spwd;
1519 pub fn getspent_r(
1520 pwd: *mut spwd,
1521 buf: *mut c_char,
1522 bufferSize: size_t,
1523 res: *mut *mut spwd,
1524 ) -> c_int;
1525 pub fn setspent();
1526 pub fn endspent();
1527 pub fn getspnam(name: *const c_char) -> *mut spwd;
1528 pub fn getspnam_r(
1529 name: *const c_char,
1530 spwd: *mut spwd,
1531 buffer: *mut c_char,
1532 bufferSize: size_t,
1533 res: *mut *mut spwd,
1534 ) -> c_int;
1535 pub fn sgetspent(line: *const c_char) -> *mut spwd;
1536 pub fn sgetspent_r(
1537 line: *const c_char,
1538 spwd: *mut spwd,
1539 buffer: *mut c_char,
1540 bufferSize: size_t,
1541 res: *mut *mut spwd,
1542 ) -> c_int;
1543 pub fn fgetspent(file: *mut crate::FILE) -> *mut spwd;
1544 pub fn fgetspent_r(
1545 file: *mut crate::FILE,
1546 spwd: *mut spwd,
1547 buffer: *mut c_char,
1548 bufferSize: size_t,
1549 res: *mut *mut spwd,
1550 ) -> c_int;
1551 pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
1552 pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
1553 pub fn sem_destroy(sem: *mut sem_t) -> c_int;
1554 pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;
1555
1556 pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
1557 pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
1558 pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int;
1559 pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int;
1560 pub fn pthread_create(
1561 thread: *mut crate::pthread_t,
1562 attr: *const crate::pthread_attr_t,
1563 f: extern "C" fn(*mut c_void) -> *mut c_void,
1564 value: *mut c_void,
1565 ) -> c_int;
1566 pub fn pthread_attr_getguardsize(
1567 attr: *const crate::pthread_attr_t,
1568 guardsize: *mut size_t,
1569 ) -> c_int;
1570 pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int;
1571 pub fn pthread_attr_getstack(
1572 attr: *const crate::pthread_attr_t,
1573 stackaddr: *mut *mut c_void,
1574 stacksize: *mut size_t,
1575 ) -> c_int;
1576 pub fn pthread_condattr_getclock(
1577 attr: *const pthread_condattr_t,
1578 clock_id: *mut clockid_t,
1579 ) -> c_int;
1580 pub fn pthread_condattr_setclock(
1581 attr: *mut pthread_condattr_t,
1582 clock_id: crate::clockid_t,
1583 ) -> c_int;
1584 pub fn valloc(numBytes: size_t) -> *mut c_void;
1585 pub fn malloc_usable_size(ptr: *mut c_void) -> size_t;
1586 pub fn memalign(align: size_t, size: size_t) -> *mut c_void;
1587 pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int;
1588 pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int;
1589 pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int;
1590 pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
1591 pub fn dirfd(dirp: *mut crate::DIR) -> c_int;
1592 pub fn getnameinfo(
1593 sa: *const crate::sockaddr,
1594 salen: crate::socklen_t,
1595 host: *mut c_char,
1596 hostlen: crate::socklen_t,
1597 serv: *mut c_char,
1598 servlen: crate::socklen_t,
1599 flags: c_int,
1600 ) -> c_int;
1601 pub fn pthread_mutex_timedlock(
1602 lock: *mut pthread_mutex_t,
1603 abstime: *const crate::timespec,
1604 ) -> c_int;
1605 pub fn pthread_sigqueue(thread: crate::pthread_t, sig: c_int, value: crate::sigval) -> c_int;
1606 pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int;
1607 pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int;
1608 pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int;
1609 pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int;
1610 pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int;
1611 pub fn waitid(
1612 idtype: idtype_t,
1613 id: id_t,
1614 infop: *mut crate::siginfo_t,
1615 options: c_int,
1616 ) -> c_int;
1617
1618 pub fn glob(
1619 pattern: *const c_char,
1620 flags: c_int,
1621 errfunc: Option<extern "C" fn(epath: *const c_char, errno: c_int) -> c_int>,
1622 pglob: *mut crate::glob_t,
1623 ) -> c_int;
1624 pub fn globfree(pglob: *mut crate::glob_t);
1625 pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int;
1626 pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
1627 pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int;
1628 pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
1629
1630 pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
1631 pub fn shm_unlink(name: *const c_char) -> c_int;
1632
1633 pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
1634
1635 pub fn telldir(dirp: *mut crate::DIR) -> c_long;
1636 pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
1637
1638 pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int;
1639
1640 pub fn recvfrom(
1641 socket: c_int,
1642 buf: *mut c_void,
1643 len: size_t,
1644 flags: c_int,
1645 addr: *mut crate::sockaddr,
1646 addrlen: *mut crate::socklen_t,
1647 ) -> ssize_t;
1648 pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char;
1649
1650 pub fn bind(
1651 socket: c_int,
1652 address: *const crate::sockaddr,
1653 address_len: crate::socklen_t,
1654 ) -> c_int;
1655
1656 pub fn accept4(
1657 socket: c_int,
1658 address: *mut crate::sockaddr,
1659 addressLength: *mut crate::socklen_t,
1660 flags: c_int,
1661 ) -> c_int;
1662
1663 pub fn writev(fd: c_int, iov: *const crate::iovec, count: c_int) -> ssize_t;
1664 pub fn readv(fd: c_int, iov: *const crate::iovec, count: c_int) -> ssize_t;
1665
1666 pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t;
1667 pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t;
1668
1669 // DIFF(main): changed to `*const *mut` in e77f551de9
1670 pub fn execvpe(
1671 file: *const c_char,
1672 argv: *const *const c_char,
1673 environment: *const *const c_char,
1674 ) -> c_int;
1675
1676 pub fn getgrgid_r(
1677 gid: crate::gid_t,
1678 grp: *mut crate::group,
1679 buf: *mut c_char,
1680 buflen: size_t,
1681 result: *mut *mut crate::group,
1682 ) -> c_int;
1683 pub fn getgrouplist(
1684 user: *const c_char,
1685 basegroup: crate::gid_t,
1686 grouplist: *mut crate::gid_t,
1687 groupcount: *mut c_int,
1688 ) -> c_int;
1689 pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int;
1690 pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int;
1691 pub fn sem_close(sem: *mut sem_t) -> c_int;
1692 pub fn getdtablesize() -> c_int;
1693 pub fn getgrnam_r(
1694 name: *const c_char,
1695 grp: *mut crate::group,
1696 buf: *mut c_char,
1697 buflen: size_t,
1698 result: *mut *mut crate::group,
1699 ) -> c_int;
1700 pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int;
1701 pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t;
1702 pub fn getgrnam(name: *const c_char) -> *mut crate::group;
1703 pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int;
1704 pub fn sem_unlink(name: *const c_char) -> c_int;
1705 pub fn getpwnam_r(
1706 name: *const c_char,
1707 pwd: *mut passwd,
1708 buf: *mut c_char,
1709 buflen: size_t,
1710 result: *mut *mut passwd,
1711 ) -> c_int;
1712 pub fn getpwuid_r(
1713 uid: crate::uid_t,
1714 pwd: *mut passwd,
1715 buf: *mut c_char,
1716 buflen: size_t,
1717 result: *mut *mut passwd,
1718 ) -> c_int;
1719 pub fn getpwent() -> *mut passwd;
1720 pub fn setpwent();
1721 pub fn endpwent();
1722 pub fn endgrent();
1723 pub fn getgrent() -> *mut crate::group;
1724 pub fn setgrent();
1725 pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int;
1726 pub fn pthread_atfork(
1727 prepare: Option<unsafe extern "C" fn()>,
1728 parent: Option<unsafe extern "C" fn()>,
1729 child: Option<unsafe extern "C" fn()>,
1730 ) -> c_int;
1731 pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group;
1732 pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE;
1733 pub fn sethostname(name: *const c_char, len: size_t) -> c_int;
1734 pub fn uname(buf: *mut crate::utsname) -> c_int;
1735 pub fn getutxent() -> *mut utmpx;
1736 pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
1737 pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
1738 pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
1739 pub fn setutxent();
1740 pub fn endutxent();
1741 pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int;
1742
1743 pub fn sigtimedwait(
1744 set: *const sigset_t,
1745 info: *mut siginfo_t,
1746 timeout: *const crate::timespec,
1747 ) -> c_int;
1748 pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int;
1749
1750 pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int;
1751 pub fn setitimer(
1752 which: c_int,
1753 new_value: *const crate::itimerval,
1754 old_value: *mut crate::itimerval,
1755 ) -> c_int;
1756
1757 pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int;
1758
1759 pub fn regexec(
1760 preg: *const regex_t,
1761 input: *const c_char,
1762 nmatch: size_t,
1763 pmatch: *mut regmatch_t,
1764 eflags: c_int,
1765 ) -> c_int;
1766
1767 pub fn regerror(
1768 errcode: c_int,
1769 preg: *const regex_t,
1770 errbuf: *mut c_char,
1771 errbuf_size: size_t,
1772 ) -> size_t;
1773
1774 pub fn regfree(preg: *mut regex_t);
1775
1776 pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int;
1777 pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int;
1778 pub fn msgrcv(
1779 msqid: c_int,
1780 msgp: *mut c_void,
1781 msgsz: size_t,
1782 msgtype: c_long,
1783 msgflg: c_int,
1784 ) -> ssize_t;
1785 pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int;
1786 pub fn semget(key: crate::key_t, nsems: c_int, semflg: c_int) -> c_int;
1787 pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int;
1788 pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int;
1789 pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t;
1790
1791 pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
1792
1793 pub fn lsearch(
1794 key: *const c_void,
1795 base: *mut c_void,
1796 nelp: *mut size_t,
1797 width: size_t,
1798 compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
1799 ) -> *mut c_void;
1800 pub fn lfind(
1801 key: *const c_void,
1802 base: *const c_void,
1803 nelp: *mut size_t,
1804 width: size_t,
1805 compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
1806 ) -> *mut c_void;
1807 pub fn hcreate(nelt: size_t) -> c_int;
1808 pub fn hdestroy();
1809 pub fn hsearch(entry: crate::ENTRY, action: crate::ACTION) -> *mut crate::ENTRY;
1810
1811 pub fn drand48() -> c_double;
1812 pub fn erand48(xseed: *mut c_ushort) -> c_double;
1813 pub fn lrand48() -> c_long;
1814 pub fn nrand48(xseed: *mut c_ushort) -> c_long;
1815 pub fn mrand48() -> c_long;
1816 pub fn jrand48(xseed: *mut c_ushort) -> c_long;
1817 pub fn srand48(seed: c_long);
1818 pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort;
1819 pub fn lcong48(p: *mut c_ushort);
1820
1821 pub fn clearenv() -> c_int;
1822 pub fn ctermid(s: *mut c_char) -> *mut c_char;
1823
1824 pub fn sync();
1825 pub fn getpagesize() -> c_int;
1826
1827 pub fn brk(addr: *mut c_void) -> c_int;
1828 pub fn sbrk(increment: intptr_t) -> *mut c_void;
1829
1830 pub fn posix_spawn(
1831 pid: *mut crate::pid_t,
1832 path: *const c_char,
1833 file_actions: *const crate::posix_spawn_file_actions_t,
1834 attrp: *const crate::posix_spawnattr_t,
1835 argv: *const *mut c_char,
1836 envp: *const *mut c_char,
1837 ) -> c_int;
1838 pub fn posix_spawnp(
1839 pid: *mut crate::pid_t,
1840 file: *const c_char,
1841 file_actions: *const crate::posix_spawn_file_actions_t,
1842 attrp: *const crate::posix_spawnattr_t,
1843 argv: *const *mut c_char,
1844 envp: *const *mut c_char,
1845 ) -> c_int;
1846
1847 pub fn posix_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> c_int;
1848 pub fn posix_spawn_file_actions_destroy(file_actions: *mut posix_spawn_file_actions_t)
1849 -> c_int;
1850 pub fn posix_spawn_file_actions_addopen(
1851 file_actions: *mut posix_spawn_file_actions_t,
1852 fildes: c_int,
1853 path: *const c_char,
1854 oflag: c_int,
1855 mode: mode_t,
1856 ) -> c_int;
1857 pub fn posix_spawn_file_actions_addclose(
1858 file_actions: *mut posix_spawn_file_actions_t,
1859 fildes: c_int,
1860 ) -> c_int;
1861 pub fn posix_spawn_file_actions_adddup2(
1862 file_actions: *mut posix_spawn_file_actions_t,
1863 fildes: c_int,
1864 newfildes: c_int,
1865 ) -> c_int;
1866
1867 pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
1868 pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
1869 pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, _flags: *mut c_short) -> c_int;
1870 pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
1871 pub fn posix_spawnattr_getpgroup(
1872 attr: *const posix_spawnattr_t,
1873 _pgroup: *mut crate::pid_t,
1874 ) -> c_int;
1875 pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: crate::pid_t) -> c_int;
1876 pub fn posix_spawnattr_getsigdefault(
1877 attr: *const posix_spawnattr_t,
1878 sigdefault: *mut crate::sigset_t,
1879 ) -> c_int;
1880 pub fn posix_spawnattr_setsigdefault(
1881 attr: *mut posix_spawnattr_t,
1882 sigdefault: *const crate::sigset_t,
1883 ) -> c_int;
1884 pub fn posix_spawnattr_getsigmask(
1885 attr: *const posix_spawnattr_t,
1886 _sigmask: *mut crate::sigset_t,
1887 ) -> c_int;
1888 pub fn posix_spawnattr_setsigmask(
1889 attr: *mut posix_spawnattr_t,
1890 sigmask: *const crate::sigset_t,
1891 ) -> c_int;
1892 pub fn getopt_long(
1893 argc: c_int,
1894 argv: *const *mut c_char,
1895 optstring: *const c_char,
1896 longopts: *const option,
1897 longindex: *mut c_int,
1898 ) -> c_int;
1899 pub fn strcasecmp_l(
1900 string1: *const c_char,
1901 string2: *const c_char,
1902 locale: crate::locale_t,
1903 ) -> c_int;
1904 pub fn strncasecmp_l(
1905 string1: *const c_char,
1906 string2: *const c_char,
1907 length: size_t,
1908 locale: crate::locale_t,
1909 ) -> c_int;
1910
1911 pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int;
1912 }
1913
1914 #[link(name = "gnu")]
1915 extern "C" {
1916 pub fn memmem(
1917 source: *const c_void,
1918 sourceLength: size_t,
1919 search: *const c_void,
1920 searchLength: size_t,
1921 ) -> *mut c_void;
1922
1923 pub fn pthread_getattr_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int;
1924 pub fn pthread_getname_np(
1925 thread: crate::pthread_t,
1926 buffer: *mut c_char,
1927 length: size_t,
1928 ) -> c_int;
1929 pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int;
1930 }
1931
1932 cfg_if! {
1933 if #[cfg(target_pointer_width = "64")] {
1934 mod b64;
1935 pub use self::b64::*;
1936 } else {
1937 mod b32;
1938 pub use self::b32::*;
1939 }
1940 }
1941
1942 cfg_if! {
1943 if #[cfg(target_arch = "x86")] {
1944 // TODO
1945 // mod x86;
1946 // pub use self::x86::*;
1947 } else if #[cfg(target_arch = "x86_64")] {
1948 mod x86_64;
1949 pub use self::x86_64::*;
1950 } else if #[cfg(target_arch = "aarch64")] {
1951 // TODO
1952 // mod aarch64;
1953 // pub use self::aarch64::*;
1954 }
1955 }
1956
1957 mod bsd;
1958 pub use self::bsd::*;
1959
1960 mod native;
1961 pub use self::native::*;