interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / unix / haiku / mod.rs

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