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