Debian Codegraph @

third_party/rust/libc/src/unix/haiku/mod.rs

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