1 use unix::bsd::O_SYNC;
2 
3 pub type clock_t = i64;
4 pub type suseconds_t = ::c_long;
5 pub type dev_t = i32;
6 pub type sigset_t = ::c_uint;
7 pub type blksize_t = i32;
8 pub type fsblkcnt_t = u64;
9 pub type fsfilcnt_t = u64;
10 pub type pthread_attr_t = *mut ::c_void;
11 pub type pthread_mutex_t = *mut ::c_void;
12 pub type pthread_mutexattr_t = *mut ::c_void;
13 pub type pthread_cond_t = *mut ::c_void;
14 pub type pthread_condattr_t = *mut ::c_void;
15 pub type pthread_rwlock_t = *mut ::c_void;
16 pub type pthread_rwlockattr_t = *mut ::c_void;
17 pub type pthread_spinlock_t = ::uintptr_t;
18 pub type caddr_t = *mut ::c_char;
19 
20 // elf.h
21 
22 pub type Elf32_Addr = u32;
23 pub type Elf32_Half = u16;
24 pub type Elf32_Lword = u64;
25 pub type Elf32_Off = u32;
26 pub type Elf32_Sword = i32;
27 pub type Elf32_Word = u32;
28 
29 pub type Elf64_Addr = u64;
30 pub type Elf64_Half = u16;
31 pub type Elf64_Lword = u64;
32 pub type Elf64_Off = u64;
33 pub type Elf64_Sword = i32;
34 pub type Elf64_Sxword = i64;
35 pub type Elf64_Word = u32;
36 pub type Elf64_Xword = u64;
37 
38 // search.h
39 
40 pub type ENTRY = entry;
41 pub type ACTION = ::c_uint;
42 
43 cfg_if! {
44     if #[cfg(target_pointer_width = "64")] {
45         type Elf_Addr = Elf64_Addr;
46         type Elf_Half = Elf64_Half;
47         type Elf_Phdr = Elf64_Phdr;
48     } else if #[cfg(target_pointer_width = "32")] {
49         type Elf_Addr = Elf32_Addr;
50         type Elf_Half = Elf32_Half;
51         type Elf_Phdr = Elf32_Phdr;
52     }
53 }
54 
55 s! {
56     pub struct ip_mreqn {
57         pub imr_multiaddr: in_addr,
58         pub imr_address: in_addr,
59         pub imr_ifindex: ::c_int,
60     }
61 
62     pub struct glob_t {
63         pub gl_pathc:   ::size_t,
64         pub gl_matchc:  ::size_t,
65         pub gl_offs:    ::size_t,
66         pub gl_flags:   ::c_int,
67         pub gl_pathv:   *mut *mut ::c_char,
68         __unused1: *mut ::c_void,
69         __unused2: *mut ::c_void,
70         __unused3: *mut ::c_void,
71         __unused4: *mut ::c_void,
72         __unused5: *mut ::c_void,
73         __unused6: *mut ::c_void,
74         __unused7: *mut ::c_void,
75     }
76 
77     pub struct lconv {
78         pub decimal_point: *mut ::c_char,
79         pub thousands_sep: *mut ::c_char,
80         pub grouping: *mut ::c_char,
81         pub int_curr_symbol: *mut ::c_char,
82         pub currency_symbol: *mut ::c_char,
83         pub mon_decimal_point: *mut ::c_char,
84         pub mon_thousands_sep: *mut ::c_char,
85         pub mon_grouping: *mut ::c_char,
86         pub positive_sign: *mut ::c_char,
87         pub negative_sign: *mut ::c_char,
88         pub int_frac_digits: ::c_char,
89         pub frac_digits: ::c_char,
90         pub p_cs_precedes: ::c_char,
91         pub p_sep_by_space: ::c_char,
92         pub n_cs_precedes: ::c_char,
93         pub n_sep_by_space: ::c_char,
94         pub p_sign_posn: ::c_char,
95         pub n_sign_posn: ::c_char,
96         pub int_p_cs_precedes: ::c_char,
97         pub int_p_sep_by_space: ::c_char,
98         pub int_n_cs_precedes: ::c_char,
99         pub int_n_sep_by_space: ::c_char,
100         pub int_p_sign_posn: ::c_char,
101         pub int_n_sign_posn: ::c_char,
102     }
103 
104     pub struct ufs_args {
105         pub fspec: *mut ::c_char,
106         pub export_info: export_args,
107     }
108 
109     pub struct mfs_args {
110         pub fspec: *mut ::c_char,
111         pub export_info: export_args,
112         // https://github.com/openbsd/src/blob/master/sys/sys/types.h#L134
113         pub base: *mut ::c_char,
114         pub size: ::c_ulong,
115     }
116 
117     pub struct iso_args {
118         pub fspec: *mut ::c_char,
119         pub export_info: export_args,
120         pub flags: ::c_int,
121         pub sess: ::c_int,
122     }
123 
124     pub struct nfs_args {
125         pub version: ::c_int,
126         pub addr: *mut ::sockaddr,
127         pub addrlen: ::c_int,
128         pub sotype: ::c_int,
129         pub proto: ::c_int,
130         pub fh: *mut ::c_uchar,
131         pub fhsize: ::c_int,
132         pub flags: ::c_int,
133         pub wsize: ::c_int,
134         pub rsize: ::c_int,
135         pub readdirsize: ::c_int,
136         pub timeo: ::c_int,
137         pub retrans: ::c_int,
138         pub maxgrouplist: ::c_int,
139         pub readahead: ::c_int,
140         pub leaseterm: ::c_int,
141         pub deadthresh: ::c_int,
142         pub hostname: *mut ::c_char,
143         pub acregmin: ::c_int,
144         pub acregmax: ::c_int,
145         pub acdirmin: ::c_int,
146         pub acdirmax: ::c_int,
147     }
148 
149     pub struct msdosfs_args {
150         pub fspec: *mut ::c_char,
151         pub export_info: export_args,
152         pub uid: ::uid_t,
153         pub gid: ::gid_t,
154         pub mask: ::mode_t,
155         pub flags: ::c_int,
156     }
157 
158     pub struct ntfs_args {
159         pub fspec: *mut ::c_char,
160         pub export_info: export_args,
161         pub uid: ::uid_t,
162         pub gid: ::gid_t,
163         pub mode: ::mode_t,
164         pub flag: ::c_ulong,
165     }
166 
167     pub struct udf_args {
168         pub fspec: *mut ::c_char,
169         pub lastblock: u32,
170     }
171 
172     pub struct tmpfs_args {
173         pub ta_version: ::c_int,
174         pub ta_nodes_max: ::ino_t,
175         pub ta_size_max: ::off_t,
176         pub ta_root_uid: ::uid_t,
177         pub ta_root_gid: ::gid_t,
178         pub ta_root_mode: ::mode_t,
179     }
180 
181     pub struct fusefs_args {
182         pub name: *mut ::c_char,
183         pub fd: ::c_int,
184         pub max_read: ::c_int,
185         pub allow_other: ::c_int,
186     }
187 
188     pub struct xucred {
189         pub cr_uid: ::uid_t,
190         pub cr_gid: ::gid_t,
191         pub cr_ngroups: ::c_short,
192         //https://github.com/openbsd/src/blob/master/sys/sys/syslimits.h#L44
193         pub cr_groups: [::gid_t; 16],
194     }
195 
196     pub struct export_args {
197         pub ex_flags: ::c_int,
198         pub ex_root: ::uid_t,
199         pub ex_anon: xucred,
200         pub ex_addr: *mut ::sockaddr,
201         pub ex_addrlen: ::c_int,
202         pub ex_mask: *mut ::sockaddr,
203         pub ex_masklen: ::c_int,
204     }
205 
206     pub struct ip_mreq {
207         pub imr_multiaddr: in_addr,
208         pub imr_interface: in_addr,
209     }
210 
211     pub struct in_addr {
212         pub s_addr: ::in_addr_t,
213     }
214 
215     pub struct sockaddr_in {
216         pub sin_len: u8,
217         pub sin_family: ::sa_family_t,
218         pub sin_port: ::in_port_t,
219         pub sin_addr: ::in_addr,
220         pub sin_zero: [i8; 8],
221     }
222 
223     pub struct splice {
224         pub sp_fd: ::c_int,
225         pub sp_max: ::off_t,
226         pub sp_idle: ::timeval,
227     }
228 
229     pub struct kevent {
230         pub ident: ::uintptr_t,
231         pub filter: ::c_short,
232         pub flags: ::c_ushort,
233         pub fflags: ::c_uint,
234         pub data: i64,
235         pub udata: *mut ::c_void,
236     }
237 
238     pub struct stat {
239         pub st_mode: ::mode_t,
240         pub st_dev: ::dev_t,
241         pub st_ino: ::ino_t,
242         pub st_nlink: ::nlink_t,
243         pub st_uid: ::uid_t,
244         pub st_gid: ::gid_t,
245         pub st_rdev: ::dev_t,
246         pub st_atime: ::time_t,
247         pub st_atime_nsec: ::c_long,
248         pub st_mtime: ::time_t,
249         pub st_mtime_nsec: ::c_long,
250         pub st_ctime: ::time_t,
251         pub st_ctime_nsec: ::c_long,
252         pub st_size: ::off_t,
253         pub st_blocks: ::blkcnt_t,
254         pub st_blksize: ::blksize_t,
255         pub st_flags: u32,
256         pub st_gen: u32,
257         pub st_birthtime: ::time_t,
258         pub st_birthtime_nsec: ::c_long,
259     }
260 
261     pub struct statvfs {
262         pub f_bsize: ::c_ulong,
263         pub f_frsize: ::c_ulong,
264         pub f_blocks: ::fsblkcnt_t,
265         pub f_bfree: ::fsblkcnt_t,
266         pub f_bavail: ::fsblkcnt_t,
267         pub f_files: ::fsfilcnt_t,
268         pub f_ffree: ::fsfilcnt_t,
269         pub f_favail: ::fsfilcnt_t,
270         pub f_fsid: ::c_ulong,
271         pub f_flag: ::c_ulong,
272         pub f_namemax: ::c_ulong,
273     }
274 
275     pub struct addrinfo {
276         pub ai_flags: ::c_int,
277         pub ai_family: ::c_int,
278         pub ai_socktype: ::c_int,
279         pub ai_protocol: ::c_int,
280         pub ai_addrlen: ::socklen_t,
281         pub ai_addr: *mut ::sockaddr,
282         pub ai_canonname: *mut ::c_char,
283         pub ai_next: *mut ::addrinfo,
284     }
285 
286     pub struct Dl_info {
287         pub dli_fname: *const ::c_char,
288         pub dli_fbase: *mut ::c_void,
289         pub dli_sname: *const ::c_char,
290         pub dli_saddr: *mut ::c_void,
291     }
292 
293     pub struct if_data {
294         pub ifi_type: ::c_uchar,
295         pub ifi_addrlen: ::c_uchar,
296         pub ifi_hdrlen: ::c_uchar,
297         pub ifi_link_state: ::c_uchar,
298         pub ifi_mtu: u32,
299         pub ifi_metric: u32,
300         pub ifi_rdomain: u32,
301         pub ifi_baudrate: u64,
302         pub ifi_ipackets: u64,
303         pub ifi_ierrors: u64,
304         pub ifi_opackets: u64,
305         pub ifi_oerrors: u64,
306         pub ifi_collisions: u64,
307         pub ifi_ibytes: u64,
308         pub ifi_obytes: u64,
309         pub ifi_imcasts: u64,
310         pub ifi_omcasts: u64,
311         pub ifi_iqdrops: u64,
312         pub ifi_oqdrops: u64,
313         pub ifi_noproto: u64,
314         pub ifi_capabilities: u32,
315         pub ifi_lastchange: ::timeval,
316     }
317 
318     pub struct if_msghdr {
319         pub ifm_msglen: ::c_ushort,
320         pub ifm_version: ::c_uchar,
321         pub ifm_type: ::c_uchar,
322         pub ifm_hdrlen: ::c_ushort,
323         pub ifm_index: ::c_ushort,
324         pub ifm_tableid: ::c_ushort,
325         pub ifm_pad1: ::c_uchar,
326         pub ifm_pad2: ::c_uchar,
327         pub ifm_addrs: ::c_int,
328         pub ifm_flags: ::c_int,
329         pub ifm_xflags: ::c_int,
330         pub ifm_data: if_data,
331     }
332 
333     pub struct sockaddr_dl {
334         pub sdl_len: ::c_uchar,
335         pub sdl_family: ::c_uchar,
336         pub sdl_index: ::c_ushort,
337         pub sdl_type: ::c_uchar,
338         pub sdl_nlen: ::c_uchar,
339         pub sdl_alen: ::c_uchar,
340         pub sdl_slen: ::c_uchar,
341         pub sdl_data: [::c_char; 24],
342     }
343 
344     pub struct sockpeercred {
345         pub uid: ::uid_t,
346         pub gid: ::gid_t,
347         pub pid: ::pid_t,
348     }
349 
350     pub struct arphdr {
351         pub ar_hrd: u16,
352         pub ar_pro: u16,
353         pub ar_hln: u8,
354         pub ar_pln: u8,
355         pub ar_op: u16,
356     }
357 
358     pub struct shmid_ds {
359         pub shm_perm: ::ipc_perm,
360         pub shm_segsz: ::c_int,
361         pub shm_lpid: ::pid_t,
362         pub shm_cpid: ::pid_t,
363         pub shm_nattch: ::c_short,
364         pub shm_atime: ::time_t,
365         __shm_atimensec: c_long,
366         pub shm_dtime: ::time_t,
367         __shm_dtimensec: c_long,
368         pub shm_ctime: ::time_t,
369         __shm_ctimensec: c_long,
370         pub shm_internal: *mut ::c_void,
371     }
372 
373     // elf.h
374     pub struct Elf32_Phdr {
375         pub p_type: Elf32_Word,
376         pub p_offset: Elf32_Off,
377         pub p_vaddr: Elf32_Addr,
378         pub p_paddr: Elf32_Addr,
379         pub p_filesz: Elf32_Word,
380         pub p_memsz: Elf32_Word,
381         pub p_flags: Elf32_Word,
382         pub p_align: Elf32_Word,
383     }
384 
385     pub struct Elf64_Phdr {
386         pub p_type: Elf64_Word,
387         pub p_flags: Elf64_Word,
388         pub p_offset: Elf64_Off,
389         pub p_vaddr: Elf64_Addr,
390         pub p_paddr: Elf64_Addr,
391         pub p_filesz: Elf64_Xword,
392         pub p_memsz: Elf64_Xword,
393         pub p_align: Elf64_Xword,
394     }
395 
396     // link.h
397 
398     pub struct dl_phdr_info {
399         pub dlpi_addr: Elf_Addr,
400         pub dlpi_name: *const ::c_char,
401         pub dlpi_phdr: *const Elf_Phdr,
402         pub dlpi_phnum: Elf_Half,
403     }
404 
405     // sys/sysctl.h
406     pub struct kinfo_vmentry {
407         pub kve_start: ::c_ulong,
408         pub kve_end: ::c_ulong,
409         pub kve_guard: ::c_ulong,
410         pub kve_fspace: ::c_ulong,
411         pub kve_fspace_augment: ::c_ulong,
412         pub kve_offset: u64,
413         pub kve_wired_count: ::c_int,
414         pub kve_etype: ::c_int,
415         pub kve_protection: ::c_int,
416         pub kve_max_protection: ::c_int,
417         pub kve_advice: ::c_int,
418         pub kve_inheritance: ::c_int,
419         pub kve_flags: u8,
420     }
421 
422     pub struct ptrace_state {
423         pub pe_report_event: ::c_int,
424         pub pe_other_pid: ::pid_t,
425         pub pe_tid: ::pid_t,
426     }
427 
428     pub struct ptrace_thread_state {
429         pub pts_tid: ::pid_t,
430     }
431 
432     // search.h
433     pub struct entry {
434         pub key: *mut ::c_char,
435         pub data: *mut ::c_void,
436     }
437 }
438 
439 impl siginfo_t {
si_addr(&self) -> *mut ::c_char440     pub unsafe fn si_addr(&self) -> *mut ::c_char {
441         self.si_addr
442     }
443 
si_value(&self) -> ::sigval444     pub unsafe fn si_value(&self) -> ::sigval {
445         #[repr(C)]
446         struct siginfo_timer {
447             _si_signo: ::c_int,
448             _si_errno: ::c_int,
449             _si_code: ::c_int,
450             _pid: ::pid_t,
451             _uid: ::uid_t,
452             value: ::sigval,
453         }
454         (*(self as *const siginfo_t as *const siginfo_timer)).value
455     }
456 }
457 
458 s_no_extra_traits! {
459     pub struct dirent {
460         pub d_fileno: ::ino_t,
461         pub d_off: ::off_t,
462         pub d_reclen: u16,
463         pub d_type: u8,
464         pub d_namlen: u8,
465         __d_padding: [u8; 4],
466         pub d_name: [::c_char; 256],
467     }
468 
469     pub struct sockaddr_storage {
470         pub ss_len: u8,
471         pub ss_family: ::sa_family_t,
472         __ss_pad1: [u8; 6],
473         __ss_pad2: i64,
474         __ss_pad3: [u8; 240],
475     }
476 
477     pub struct siginfo_t {
478         pub si_signo: ::c_int,
479         pub si_code: ::c_int,
480         pub si_errno: ::c_int,
481         pub si_addr: *mut ::c_char,
482         #[cfg(target_pointer_width = "32")]
483         __pad: [u8; 112],
484         #[cfg(target_pointer_width = "64")]
485         __pad: [u8; 108],
486     }
487 
488     pub struct lastlog {
489         ll_time: ::time_t,
490         ll_line: [::c_char; UT_LINESIZE],
491         ll_host: [::c_char; UT_HOSTSIZE],
492     }
493 
494     pub struct utmp {
495         pub ut_line: [::c_char; UT_LINESIZE],
496         pub ut_name: [::c_char; UT_NAMESIZE],
497         pub ut_host: [::c_char; UT_HOSTSIZE],
498         pub ut_time: ::time_t,
499     }
500 
501     pub union mount_info {
502         pub ufs_args: ufs_args,
503         pub mfs_args: mfs_args,
504         pub nfs_args: nfs_args,
505         pub iso_args: iso_args,
506         pub msdosfs_args: msdosfs_args,
507         pub ntfs_args: ntfs_args,
508         pub tmpfs_args: tmpfs_args,
509         align: [::c_char; 160],
510     }
511 
512 }
513 
514 cfg_if! {
515     if #[cfg(feature = "extra_traits")] {
516         impl PartialEq for dirent {
517             fn eq(&self, other: &dirent) -> bool {
518                 self.d_fileno == other.d_fileno
519                     && self.d_off == other.d_off
520                     && self.d_reclen == other.d_reclen
521                     && self.d_type == other.d_type
522                     && self.d_namlen == other.d_namlen
523                     && self
524                     .d_name
525                     .iter()
526                     .zip(other.d_name.iter())
527                     .all(|(a,b)| a == b)
528             }
529         }
530 
531         impl Eq for dirent {}
532 
533         impl ::fmt::Debug for dirent {
534             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
535                 f.debug_struct("dirent")
536                     .field("d_fileno", &self.d_fileno)
537                     .field("d_off", &self.d_off)
538                     .field("d_reclen", &self.d_reclen)
539                     .field("d_type", &self.d_type)
540                     .field("d_namlen", &self.d_namlen)
541                 // FIXME: .field("d_name", &self.d_name)
542                     .finish()
543             }
544         }
545 
546         impl ::hash::Hash for dirent {
547             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
548                 self.d_fileno.hash(state);
549                 self.d_off.hash(state);
550                 self.d_reclen.hash(state);
551                 self.d_type.hash(state);
552                 self.d_namlen.hash(state);
553                 self.d_name.hash(state);
554             }
555         }
556 
557         impl PartialEq for sockaddr_storage {
558             fn eq(&self, other: &sockaddr_storage) -> bool {
559                 self.ss_len == other.ss_len
560                     && self.ss_family == other.ss_family
561             }
562         }
563 
564         impl Eq for sockaddr_storage {}
565 
566         impl ::fmt::Debug for sockaddr_storage {
567             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
568                 f.debug_struct("sockaddr_storage")
569                     .field("ss_len", &self.ss_len)
570                     .field("ss_family", &self.ss_family)
571                     .finish()
572             }
573         }
574 
575         impl ::hash::Hash for sockaddr_storage {
576             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
577                 self.ss_len.hash(state);
578                 self.ss_family.hash(state);
579             }
580         }
581 
582         impl PartialEq for siginfo_t {
583             fn eq(&self, other: &siginfo_t) -> bool {
584                 self.si_signo == other.si_signo
585                     && self.si_code == other.si_code
586                     && self.si_errno == other.si_errno
587                     && self.si_addr == other.si_addr
588             }
589         }
590 
591         impl Eq for siginfo_t {}
592 
593         impl ::fmt::Debug for siginfo_t {
594             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
595                 f.debug_struct("siginfo_t")
596                     .field("si_signo", &self.si_signo)
597                     .field("si_code", &self.si_code)
598                     .field("si_errno", &self.si_errno)
599                     .field("si_addr", &self.si_addr)
600                     .finish()
601             }
602         }
603 
604         impl ::hash::Hash for siginfo_t {
605             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
606                 self.si_signo.hash(state);
607                 self.si_code.hash(state);
608                 self.si_errno.hash(state);
609                 self.si_addr.hash(state);
610             }
611         }
612 
613         impl PartialEq for lastlog {
614             fn eq(&self, other: &lastlog) -> bool {
615                 self.ll_time == other.ll_time
616                     && self
617                     .ll_line
618                     .iter()
619                     .zip(other.ll_line.iter())
620                     .all(|(a,b)| a == b)
621                     && self
622                     .ll_host
623                     .iter()
624                     .zip(other.ll_host.iter())
625                     .all(|(a,b)| a == b)
626             }
627         }
628 
629         impl Eq for lastlog {}
630 
631         impl ::fmt::Debug for lastlog {
632             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
633                 f.debug_struct("lastlog")
634                     .field("ll_time", &self.ll_time)
635                 // FIXME: .field("ll_line", &self.ll_line)
636                 // FIXME: .field("ll_host", &self.ll_host)
637                     .finish()
638             }
639         }
640 
641         impl ::hash::Hash for lastlog {
642             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
643                 self.ll_time.hash(state);
644                 self.ll_line.hash(state);
645                 self.ll_host.hash(state);
646             }
647         }
648 
649         impl PartialEq for utmp {
650             fn eq(&self, other: &utmp) -> bool {
651                 self.ut_time == other.ut_time
652                     && self
653                     .ut_line
654                     .iter()
655                     .zip(other.ut_line.iter())
656                     .all(|(a,b)| a == b)
657                     && self
658                     .ut_name
659                     .iter()
660                     .zip(other.ut_name.iter())
661                     .all(|(a,b)| a == b)
662                     && self
663                     .ut_host
664                     .iter()
665                     .zip(other.ut_host.iter())
666                     .all(|(a,b)| a == b)
667             }
668         }
669 
670         impl Eq for utmp {}
671 
672         impl ::fmt::Debug for utmp {
673             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
674                 f.debug_struct("utmp")
675                 // FIXME: .field("ut_line", &self.ut_line)
676                 // FIXME: .field("ut_name", &self.ut_name)
677                 // FIXME: .field("ut_host", &self.ut_host)
678                     .field("ut_time", &self.ut_time)
679                     .finish()
680             }
681         }
682 
683         impl ::hash::Hash for utmp {
684             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
685                 self.ut_line.hash(state);
686                 self.ut_name.hash(state);
687                 self.ut_host.hash(state);
688                 self.ut_time.hash(state);
689             }
690         }
691 
692         impl PartialEq for mount_info {
693             fn eq(&self, other: &mount_info) -> bool {
694                 unsafe {
695                     self.align
696                         .iter()
697                         .zip(other.align.iter())
698                         .all(|(a,b)| a == b)
699                 }
700             }
701         }
702 
703         impl Eq for mount_info { }
704 
705         impl ::fmt::Debug for mount_info {
706             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
707                 f.debug_struct("mount_info")
708                 // FIXME: .field("align", &self.align)
709                     .finish()
710             }
711         }
712 
713         impl ::hash::Hash for mount_info {
714             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
715                 unsafe { self.align.hash(state) };
716             }
717         }
718     }
719 }
720 
721 cfg_if! {
722     if #[cfg(libc_union)] {
723         s_no_extra_traits! {
724             // This type uses the union mount_info:
725             pub struct statfs {
726                 pub f_flags: u32,
727                 pub f_bsize: u32,
728                 pub f_iosize: u32,
729                 pub f_blocks: u64,
730                 pub f_bfree: u64,
731                 pub f_bavail: i64,
732                 pub f_files: u64,
733                 pub f_ffree: u64,
734                 pub f_favail: i64,
735                 pub f_syncwrites: u64,
736                 pub f_syncreads: u64,
737                 pub f_asyncwrites: u64,
738                 pub f_asyncreads: u64,
739                 pub f_fsid: ::fsid_t,
740                 pub f_namemax: u32,
741                 pub f_owner: ::uid_t,
742                 pub f_ctime: u64,
743                 pub f_fstypename: [::c_char; 16],
744                 pub f_mntonname: [::c_char; 90],
745                 pub f_mntfromname: [::c_char; 90],
746                 pub f_mntfromspec: [::c_char; 90],
747                 pub mount_info: mount_info,
748             }
749         }
750 
751         cfg_if! {
752             if #[cfg(feature = "extra_traits")] {
753                 impl PartialEq for statfs {
754                     fn eq(&self, other: &statfs) -> bool {
755                         self.f_flags == other.f_flags
756                             && self.f_bsize == other.f_bsize
757                             && self.f_iosize == other.f_iosize
758                             && self.f_blocks == other.f_blocks
759                             && self.f_bfree == other.f_bfree
760                             && self.f_bavail == other.f_bavail
761                             && self.f_files == other.f_files
762                             && self.f_ffree == other.f_ffree
763                             && self.f_favail == other.f_favail
764                             && self.f_syncwrites == other.f_syncwrites
765                             && self.f_syncreads == other.f_syncreads
766                             && self.f_asyncwrites == other.f_asyncwrites
767                             && self.f_asyncreads == other.f_asyncreads
768                             && self.f_fsid == other.f_fsid
769                             && self.f_namemax == other.f_namemax
770                             && self.f_owner == other.f_owner
771                             && self.f_ctime == other.f_ctime
772                             && self.f_fstypename
773                             .iter()
774                             .zip(other.f_fstypename.iter())
775                             .all(|(a,b)| a == b)
776                             && self.f_mntonname
777                             .iter()
778                             .zip(other.f_mntonname.iter())
779                             .all(|(a,b)| a == b)
780                             && self.f_mntfromname
781                             .iter()
782                             .zip(other.f_mntfromname.iter())
783                             .all(|(a,b)| a == b)
784                             && self.f_mntfromspec
785                             .iter()
786                             .zip(other.f_mntfromspec.iter())
787                             .all(|(a,b)| a == b)
788                             && self.mount_info == other.mount_info
789                     }
790                 }
791 
792                 impl Eq for statfs { }
793 
794                 impl ::fmt::Debug for statfs {
795                     fn fmt(&self, f: &mut ::fmt::Formatter)
796                            -> ::fmt::Result {
797                         f.debug_struct("statfs")
798                             .field("f_flags", &self.f_flags)
799                             .field("f_bsize", &self.f_bsize)
800                             .field("f_iosize", &self.f_iosize)
801                             .field("f_blocks", &self.f_blocks)
802                             .field("f_bfree", &self.f_bfree)
803                             .field("f_bavail", &self.f_bavail)
804                             .field("f_files", &self.f_files)
805                             .field("f_ffree", &self.f_ffree)
806                             .field("f_favail", &self.f_favail)
807                             .field("f_syncwrites", &self.f_syncwrites)
808                             .field("f_syncreads", &self.f_syncreads)
809                             .field("f_asyncwrites", &self.f_asyncwrites)
810                             .field("f_asyncreads", &self.f_asyncreads)
811                             .field("f_fsid", &self.f_fsid)
812                             .field("f_namemax", &self.f_namemax)
813                             .field("f_owner", &self.f_owner)
814                             .field("f_ctime", &self.f_ctime)
815                         // FIXME: .field("f_fstypename", &self.f_fstypename)
816                         // FIXME: .field("f_mntonname", &self.f_mntonname)
817                         // FIXME: .field("f_mntfromname", &self.f_mntfromname)
818                         // FIXME: .field("f_mntfromspec", &self.f_mntfromspec)
819                             .field("mount_info", &self.mount_info)
820                             .finish()
821                     }
822                 }
823 
824                 impl ::hash::Hash for statfs {
825                     fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
826                         self.f_flags.hash(state);
827                         self.f_bsize.hash(state);
828                         self.f_iosize.hash(state);
829                         self.f_blocks.hash(state);
830                         self.f_bfree.hash(state);
831                         self.f_bavail.hash(state);
832                         self.f_files.hash(state);
833                         self.f_ffree.hash(state);
834                         self.f_favail.hash(state);
835                         self.f_syncwrites.hash(state);
836                         self.f_syncreads.hash(state);
837                         self.f_asyncwrites.hash(state);
838                         self.f_asyncreads.hash(state);
839                         self.f_fsid.hash(state);
840                         self.f_namemax.hash(state);
841                         self.f_owner.hash(state);
842                         self.f_ctime.hash(state);
843                         self.f_fstypename.hash(state);
844                         self.f_mntonname.hash(state);
845                         self.f_mntfromname.hash(state);
846                         self.f_mntfromspec.hash(state);
847                         self.mount_info.hash(state);
848                     }
849                 }
850             }
851         }
852     }
853 }
854 
855 pub const UT_NAMESIZE: usize = 32;
856 pub const UT_LINESIZE: usize = 8;
857 pub const UT_HOSTSIZE: usize = 256;
858 
859 pub const O_CLOEXEC: ::c_int = 0x10000;
860 pub const O_DIRECTORY: ::c_int = 0x20000;
861 pub const O_RSYNC: ::c_int = O_SYNC;
862 
863 pub const MS_SYNC: ::c_int = 0x0002;
864 pub const MS_INVALIDATE: ::c_int = 0x0004;
865 
866 pub const POLLNORM: ::c_short = ::POLLRDNORM;
867 
868 pub const ENOATTR: ::c_int = 83;
869 pub const EILSEQ: ::c_int = 84;
870 pub const EOVERFLOW: ::c_int = 87;
871 pub const ECANCELED: ::c_int = 88;
872 pub const EIDRM: ::c_int = 89;
873 pub const ENOMSG: ::c_int = 90;
874 pub const ENOTSUP: ::c_int = 91;
875 pub const EBADMSG: ::c_int = 92;
876 pub const ENOTRECOVERABLE: ::c_int = 93;
877 pub const EOWNERDEAD: ::c_int = 94;
878 pub const EPROTO: ::c_int = 95;
879 pub const ELAST: ::c_int = 95;
880 
881 pub const F_DUPFD_CLOEXEC: ::c_int = 10;
882 
883 pub const UTIME_OMIT: c_long = -1;
884 pub const UTIME_NOW: c_long = -2;
885 
886 pub const AT_FDCWD: ::c_int = -100;
887 pub const AT_EACCESS: ::c_int = 0x01;
888 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x02;
889 pub const AT_SYMLINK_FOLLOW: ::c_int = 0x04;
890 pub const AT_REMOVEDIR: ::c_int = 0x08;
891 
892 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
893 pub const RLIM_NLIMITS: ::c_int = 9;
894 
895 pub const SO_TIMESTAMP: ::c_int = 0x0800;
896 pub const SO_SNDTIMEO: ::c_int = 0x1005;
897 pub const SO_RCVTIMEO: ::c_int = 0x1006;
898 pub const SO_BINDANY: ::c_int = 0x1000;
899 pub const SO_NETPROC: ::c_int = 0x1020;
900 pub const SO_RTABLE: ::c_int = 0x1021;
901 pub const SO_PEERCRED: ::c_int = 0x1022;
902 pub const SO_SPLICE: ::c_int = 0x1023;
903 
904 // sys/netinet/in.h
905 // Protocols (RFC 1700)
906 // NOTE: These are in addition to the constants defined in src/unix/mod.rs
907 
908 // IPPROTO_IP defined in src/unix/mod.rs
909 /// Hop-by-hop option header
910 pub const IPPROTO_HOPOPTS: ::c_int = 0;
911 // IPPROTO_ICMP defined in src/unix/mod.rs
912 /// group mgmt protocol
913 pub const IPPROTO_IGMP: ::c_int = 2;
914 /// gateway^2 (deprecated)
915 pub const IPPROTO_GGP: ::c_int = 3;
916 /// for compatibility
917 pub const IPPROTO_IPIP: ::c_int = 4;
918 // IPPROTO_TCP defined in src/unix/mod.rs
919 /// exterior gateway protocol
920 pub const IPPROTO_EGP: ::c_int = 8;
921 /// pup
922 pub const IPPROTO_PUP: ::c_int = 12;
923 // IPPROTO_UDP defined in src/unix/mod.rs
924 /// xns idp
925 pub const IPPROTO_IDP: ::c_int = 22;
926 /// tp-4 w/ class negotiation
927 pub const IPPROTO_TP: ::c_int = 29;
928 // IPPROTO_IPV6 defined in src/unix/mod.rs
929 /// IP6 routing header
930 pub const IPPROTO_ROUTING: ::c_int = 43;
931 /// IP6 fragmentation header
932 pub const IPPROTO_FRAGMENT: ::c_int = 44;
933 /// resource reservation
934 pub const IPPROTO_RSVP: ::c_int = 46;
935 /// General Routing Encap.
936 pub const IPPROTO_GRE: ::c_int = 47;
937 /// IP6 Encap Sec. Payload
938 pub const IPPROTO_ESP: ::c_int = 50;
939 /// IP6 Auth Header
940 pub const IPPROTO_AH: ::c_int = 51;
941 /// IP Mobility RFC 2004
942 pub const IPPROTO_MOBILE: ::c_int = 55;
943 // IPPROTO_ICMPV6 defined in src/unix/mod.rs
944 /// IP6 no next header
945 pub const IPPROTO_NONE: ::c_int = 59;
946 /// IP6 destination option
947 pub const IPPROTO_DSTOPTS: ::c_int = 60;
948 /// ISO cnlp
949 pub const IPPROTO_EON: ::c_int = 80;
950 /// Ethernet-in-IP
951 pub const IPPROTO_ETHERIP: ::c_int = 97;
952 /// encapsulation header
953 pub const IPPROTO_ENCAP: ::c_int = 98;
954 /// Protocol indep. multicast
955 pub const IPPROTO_PIM: ::c_int = 103;
956 /// IP Payload Comp. Protocol
957 pub const IPPROTO_IPCOMP: ::c_int = 108;
958 /// CARP
959 pub const IPPROTO_CARP: ::c_int = 112;
960 /// unicast MPLS packet
961 pub const IPPROTO_MPLS: ::c_int = 137;
962 /// PFSYNC
963 pub const IPPROTO_PFSYNC: ::c_int = 240;
964 pub const IPPROTO_MAX: ::c_int = 256;
965 
966 // Only used internally, so it can be outside the range of valid IP protocols
967 pub const IPPROTO_DIVERT: ::c_int = 258;
968 
969 pub const IP_RECVDSTADDR: ::c_int = 7;
970 pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;
971 pub const IP_RECVIF: ::c_int = 30;
972 
973 // sys/netinet/in.h
974 pub const TCP_MD5SIG: ::c_int = 0x04;
975 pub const TCP_NOPUSH: ::c_int = 0x10;
976 
977 pub const AF_ECMA: ::c_int = 8;
978 pub const AF_ROUTE: ::c_int = 17;
979 pub const AF_ENCAP: ::c_int = 28;
980 pub const AF_SIP: ::c_int = 29;
981 pub const AF_KEY: ::c_int = 30;
982 pub const pseudo_AF_HDRCMPLT: ::c_int = 31;
983 pub const AF_BLUETOOTH: ::c_int = 32;
984 pub const AF_MPLS: ::c_int = 33;
985 pub const pseudo_AF_PFLOW: ::c_int = 34;
986 pub const pseudo_AF_PIPEX: ::c_int = 35;
987 pub const NET_RT_DUMP: ::c_int = 1;
988 pub const NET_RT_FLAGS: ::c_int = 2;
989 pub const NET_RT_IFLIST: ::c_int = 3;
990 pub const NET_RT_STATS: ::c_int = 4;
991 pub const NET_RT_TABLE: ::c_int = 5;
992 pub const NET_RT_IFNAMES: ::c_int = 6;
993 #[doc(hidden)]
994 #[deprecated(
995     since = "0.2.95",
996     note = "Possibly increasing over the releases and might not be so used in the field"
997 )]
998 pub const NET_RT_MAXID: ::c_int = 7;
999 
1000 pub const IPV6_JOIN_GROUP: ::c_int = 12;
1001 pub const IPV6_LEAVE_GROUP: ::c_int = 13;
1002 
1003 pub const PF_ROUTE: ::c_int = AF_ROUTE;
1004 pub const PF_ECMA: ::c_int = AF_ECMA;
1005 pub const PF_ENCAP: ::c_int = AF_ENCAP;
1006 pub const PF_SIP: ::c_int = AF_SIP;
1007 pub const PF_KEY: ::c_int = AF_KEY;
1008 pub const PF_BPF: ::c_int = pseudo_AF_HDRCMPLT;
1009 pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
1010 pub const PF_MPLS: ::c_int = AF_MPLS;
1011 pub const PF_PFLOW: ::c_int = pseudo_AF_PFLOW;
1012 pub const PF_PIPEX: ::c_int = pseudo_AF_PIPEX;
1013 
1014 pub const SCM_TIMESTAMP: ::c_int = 0x04;
1015 
1016 pub const O_DSYNC: ::c_int = 128;
1017 
1018 pub const MAP_RENAME: ::c_int = 0x0000;
1019 pub const MAP_NORESERVE: ::c_int = 0x0000;
1020 pub const MAP_HASSEMAPHORE: ::c_int = 0x0000;
1021 
1022 pub const EIPSEC: ::c_int = 82;
1023 pub const ENOMEDIUM: ::c_int = 85;
1024 pub const EMEDIUMTYPE: ::c_int = 86;
1025 
1026 pub const EAI_BADFLAGS: ::c_int = -1;
1027 pub const EAI_NONAME: ::c_int = -2;
1028 pub const EAI_AGAIN: ::c_int = -3;
1029 pub const EAI_FAIL: ::c_int = -4;
1030 pub const EAI_NODATA: ::c_int = -5;
1031 pub const EAI_FAMILY: ::c_int = -6;
1032 pub const EAI_SOCKTYPE: ::c_int = -7;
1033 pub const EAI_SERVICE: ::c_int = -8;
1034 pub const EAI_MEMORY: ::c_int = -10;
1035 pub const EAI_SYSTEM: ::c_int = -11;
1036 pub const EAI_OVERFLOW: ::c_int = -14;
1037 
1038 pub const RUSAGE_THREAD: ::c_int = 1;
1039 
1040 pub const MAP_COPY: ::c_int = 0x0002;
1041 pub const MAP_NOEXTEND: ::c_int = 0x0000;
1042 
1043 pub const _PC_LINK_MAX: ::c_int = 1;
1044 pub const _PC_MAX_CANON: ::c_int = 2;
1045 pub const _PC_MAX_INPUT: ::c_int = 3;
1046 pub const _PC_NAME_MAX: ::c_int = 4;
1047 pub const _PC_PATH_MAX: ::c_int = 5;
1048 pub const _PC_PIPE_BUF: ::c_int = 6;
1049 pub const _PC_CHOWN_RESTRICTED: ::c_int = 7;
1050 pub const _PC_NO_TRUNC: ::c_int = 8;
1051 pub const _PC_VDISABLE: ::c_int = 9;
1052 pub const _PC_2_SYMLINKS: ::c_int = 10;
1053 pub const _PC_ALLOC_SIZE_MIN: ::c_int = 11;
1054 pub const _PC_ASYNC_IO: ::c_int = 12;
1055 pub const _PC_FILESIZEBITS: ::c_int = 13;
1056 pub const _PC_PRIO_IO: ::c_int = 14;
1057 pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 15;
1058 pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 16;
1059 pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 17;
1060 pub const _PC_REC_XFER_ALIGN: ::c_int = 18;
1061 pub const _PC_SYMLINK_MAX: ::c_int = 19;
1062 pub const _PC_SYNC_IO: ::c_int = 20;
1063 pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 21;
1064 
1065 pub const _SC_CLK_TCK: ::c_int = 3;
1066 pub const _SC_SEM_NSEMS_MAX: ::c_int = 31;
1067 pub const _SC_SEM_VALUE_MAX: ::c_int = 32;
1068 pub const _SC_HOST_NAME_MAX: ::c_int = 33;
1069 pub const _SC_MONOTONIC_CLOCK: ::c_int = 34;
1070 pub const _SC_2_PBS: ::c_int = 35;
1071 pub const _SC_2_PBS_ACCOUNTING: ::c_int = 36;
1072 pub const _SC_2_PBS_CHECKPOINT: ::c_int = 37;
1073 pub const _SC_2_PBS_LOCATE: ::c_int = 38;
1074 pub const _SC_2_PBS_MESSAGE: ::c_int = 39;
1075 pub const _SC_2_PBS_TRACK: ::c_int = 40;
1076 pub const _SC_ADVISORY_INFO: ::c_int = 41;
1077 pub const _SC_AIO_LISTIO_MAX: ::c_int = 42;
1078 pub const _SC_AIO_MAX: ::c_int = 43;
1079 pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44;
1080 pub const _SC_ASYNCHRONOUS_IO: ::c_int = 45;
1081 pub const _SC_ATEXIT_MAX: ::c_int = 46;
1082 pub const _SC_BARRIERS: ::c_int = 47;
1083 pub const _SC_CLOCK_SELECTION: ::c_int = 48;
1084 pub const _SC_CPUTIME: ::c_int = 49;
1085 pub const _SC_DELAYTIMER_MAX: ::c_int = 50;
1086 pub const _SC_IOV_MAX: ::c_int = 51;
1087 pub const _SC_IPV6: ::c_int = 52;
1088 pub const _SC_MAPPED_FILES: ::c_int = 53;
1089 pub const _SC_MEMLOCK: ::c_int = 54;
1090 pub const _SC_MEMLOCK_RANGE: ::c_int = 55;
1091 pub const _SC_MEMORY_PROTECTION: ::c_int = 56;
1092 pub const _SC_MESSAGE_PASSING: ::c_int = 57;
1093 pub const _SC_MQ_OPEN_MAX: ::c_int = 58;
1094 pub const _SC_MQ_PRIO_MAX: ::c_int = 59;
1095 pub const _SC_PRIORITIZED_IO: ::c_int = 60;
1096 pub const _SC_PRIORITY_SCHEDULING: ::c_int = 61;
1097 pub const _SC_RAW_SOCKETS: ::c_int = 62;
1098 pub const _SC_READER_WRITER_LOCKS: ::c_int = 63;
1099 pub const _SC_REALTIME_SIGNALS: ::c_int = 64;
1100 pub const _SC_REGEXP: ::c_int = 65;
1101 pub const _SC_RTSIG_MAX: ::c_int = 66;
1102 pub const _SC_SEMAPHORES: ::c_int = 67;
1103 pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 68;
1104 pub const _SC_SHELL: ::c_int = 69;
1105 pub const _SC_SIGQUEUE_MAX: ::c_int = 70;
1106 pub const _SC_SPAWN: ::c_int = 71;
1107 pub const _SC_SPIN_LOCKS: ::c_int = 72;
1108 pub const _SC_SPORADIC_SERVER: ::c_int = 73;
1109 pub const _SC_SS_REPL_MAX: ::c_int = 74;
1110 pub const _SC_SYNCHRONIZED_IO: ::c_int = 75;
1111 pub const _SC_SYMLOOP_MAX: ::c_int = 76;
1112 pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
1113 pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
1114 pub const _SC_THREAD_CPUTIME: ::c_int = 79;
1115 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 80;
1116 pub const _SC_THREAD_KEYS_MAX: ::c_int = 81;
1117 pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 82;
1118 pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 83;
1119 pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 84;
1120 pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 85;
1121 pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 86;
1122 pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 87;
1123 pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 88;
1124 pub const _SC_THREAD_STACK_MIN: ::c_int = 89;
1125 pub const _SC_THREAD_THREADS_MAX: ::c_int = 90;
1126 pub const _SC_THREADS: ::c_int = 91;
1127 pub const _SC_TIMEOUTS: ::c_int = 92;
1128 pub const _SC_TIMER_MAX: ::c_int = 93;
1129 pub const _SC_TIMERS: ::c_int = 94;
1130 pub const _SC_TRACE: ::c_int = 95;
1131 pub const _SC_TRACE_EVENT_FILTER: ::c_int = 96;
1132 pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 97;
1133 pub const _SC_TRACE_INHERIT: ::c_int = 98;
1134 pub const _SC_TRACE_LOG: ::c_int = 99;
1135 pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 100;
1136 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 101;
1137 pub const _SC_LOGIN_NAME_MAX: ::c_int = 102;
1138 pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 103;
1139 pub const _SC_TRACE_NAME_MAX: ::c_int = 104;
1140 pub const _SC_TRACE_SYS_MAX: ::c_int = 105;
1141 pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 106;
1142 pub const _SC_TTY_NAME_MAX: ::c_int = 107;
1143 pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 108;
1144 pub const _SC_V6_ILP32_OFF32: ::c_int = 109;
1145 pub const _SC_V6_ILP32_OFFBIG: ::c_int = 110;
1146 pub const _SC_V6_LP64_OFF64: ::c_int = 111;
1147 pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 112;
1148 pub const _SC_V7_ILP32_OFF32: ::c_int = 113;
1149 pub const _SC_V7_ILP32_OFFBIG: ::c_int = 114;
1150 pub const _SC_V7_LP64_OFF64: ::c_int = 115;
1151 pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 116;
1152 pub const _SC_XOPEN_CRYPT: ::c_int = 117;
1153 pub const _SC_XOPEN_ENH_I18N: ::c_int = 118;
1154 pub const _SC_XOPEN_LEGACY: ::c_int = 119;
1155 pub const _SC_XOPEN_REALTIME: ::c_int = 120;
1156 pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 121;
1157 pub const _SC_XOPEN_STREAMS: ::c_int = 122;
1158 pub const _SC_XOPEN_UNIX: ::c_int = 123;
1159 pub const _SC_XOPEN_UUCP: ::c_int = 124;
1160 pub const _SC_XOPEN_VERSION: ::c_int = 125;
1161 pub const _SC_PHYS_PAGES: ::c_int = 500;
1162 pub const _SC_AVPHYS_PAGES: ::c_int = 501;
1163 pub const _SC_NPROCESSORS_CONF: ::c_int = 502;
1164 pub const _SC_NPROCESSORS_ONLN: ::c_int = 503;
1165 
1166 pub const FD_SETSIZE: usize = 1024;
1167 
1168 pub const ST_NOSUID: ::c_ulong = 2;
1169 
1170 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _;
1171 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _;
1172 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _;
1173 
1174 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
1175 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
1176 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3;
1177 pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4;
1178 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP;
1179 
1180 pub const EVFILT_AIO: i16 = -3;
1181 pub const EVFILT_PROC: i16 = -5;
1182 pub const EVFILT_READ: i16 = -1;
1183 pub const EVFILT_SIGNAL: i16 = -6;
1184 pub const EVFILT_TIMER: i16 = -7;
1185 pub const EVFILT_VNODE: i16 = -4;
1186 pub const EVFILT_WRITE: i16 = -2;
1187 
1188 pub const EV_ADD: u16 = 0x1;
1189 pub const EV_DELETE: u16 = 0x2;
1190 pub const EV_ENABLE: u16 = 0x4;
1191 pub const EV_DISABLE: u16 = 0x8;
1192 pub const EV_ONESHOT: u16 = 0x10;
1193 pub const EV_CLEAR: u16 = 0x20;
1194 pub const EV_RECEIPT: u16 = 0x40;
1195 pub const EV_DISPATCH: u16 = 0x80;
1196 pub const EV_FLAG1: u16 = 0x2000;
1197 pub const EV_ERROR: u16 = 0x4000;
1198 pub const EV_EOF: u16 = 0x8000;
1199 
1200 #[deprecated(since = "0.2.113", note = "Not stable across OS versions")]
1201 pub const EV_SYSFLAGS: u16 = 0xf800;
1202 
1203 pub const NOTE_LOWAT: u32 = 0x00000001;
1204 pub const NOTE_EOF: u32 = 0x00000002;
1205 pub const NOTE_DELETE: u32 = 0x00000001;
1206 pub const NOTE_WRITE: u32 = 0x00000002;
1207 pub const NOTE_EXTEND: u32 = 0x00000004;
1208 pub const NOTE_ATTRIB: u32 = 0x00000008;
1209 pub const NOTE_LINK: u32 = 0x00000010;
1210 pub const NOTE_RENAME: u32 = 0x00000020;
1211 pub const NOTE_REVOKE: u32 = 0x00000040;
1212 pub const NOTE_TRUNCATE: u32 = 0x00000080;
1213 pub const NOTE_EXIT: u32 = 0x80000000;
1214 pub const NOTE_FORK: u32 = 0x40000000;
1215 pub const NOTE_EXEC: u32 = 0x20000000;
1216 pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1217 pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1218 pub const NOTE_TRACK: u32 = 0x00000001;
1219 pub const NOTE_TRACKERR: u32 = 0x00000002;
1220 pub const NOTE_CHILD: u32 = 0x00000004;
1221 
1222 pub const TMP_MAX: ::c_uint = 0x7fffffff;
1223 
1224 pub const AI_PASSIVE: ::c_int = 1;
1225 pub const AI_CANONNAME: ::c_int = 2;
1226 pub const AI_NUMERICHOST: ::c_int = 4;
1227 pub const AI_EXT: ::c_int = 8;
1228 pub const AI_NUMERICSERV: ::c_int = 16;
1229 pub const AI_FQDN: ::c_int = 32;
1230 pub const AI_ADDRCONFIG: ::c_int = 64;
1231 
1232 pub const NI_NUMERICHOST: ::c_int = 1;
1233 pub const NI_NUMERICSERV: ::c_int = 2;
1234 pub const NI_NOFQDN: ::c_int = 4;
1235 pub const NI_NAMEREQD: ::c_int = 8;
1236 pub const NI_DGRAM: ::c_int = 16;
1237 
1238 pub const NI_MAXHOST: ::size_t = 256;
1239 
1240 pub const RTLD_LOCAL: ::c_int = 0;
1241 
1242 pub const CTL_MAXNAME: ::c_int = 12;
1243 
1244 pub const CTLTYPE_NODE: ::c_int = 1;
1245 pub const CTLTYPE_INT: ::c_int = 2;
1246 pub const CTLTYPE_STRING: ::c_int = 3;
1247 pub const CTLTYPE_QUAD: ::c_int = 4;
1248 pub const CTLTYPE_STRUCT: ::c_int = 5;
1249 
1250 pub const CTL_UNSPEC: ::c_int = 0;
1251 pub const CTL_KERN: ::c_int = 1;
1252 pub const CTL_VM: ::c_int = 2;
1253 pub const CTL_FS: ::c_int = 3;
1254 pub const CTL_NET: ::c_int = 4;
1255 pub const CTL_DEBUG: ::c_int = 5;
1256 pub const CTL_HW: ::c_int = 6;
1257 pub const CTL_MACHDEP: ::c_int = 7;
1258 pub const CTL_DDB: ::c_int = 9;
1259 pub const CTL_VFS: ::c_int = 10;
1260 pub const CTL_MAXID: ::c_int = 11;
1261 
1262 pub const HW_NCPUONLINE: ::c_int = 25;
1263 
1264 pub const KERN_OSTYPE: ::c_int = 1;
1265 pub const KERN_OSRELEASE: ::c_int = 2;
1266 pub const KERN_OSREV: ::c_int = 3;
1267 pub const KERN_VERSION: ::c_int = 4;
1268 pub const KERN_MAXVNODES: ::c_int = 5;
1269 pub const KERN_MAXPROC: ::c_int = 6;
1270 pub const KERN_MAXFILES: ::c_int = 7;
1271 pub const KERN_ARGMAX: ::c_int = 8;
1272 pub const KERN_SECURELVL: ::c_int = 9;
1273 pub const KERN_HOSTNAME: ::c_int = 10;
1274 pub const KERN_HOSTID: ::c_int = 11;
1275 pub const KERN_CLOCKRATE: ::c_int = 12;
1276 pub const KERN_PROF: ::c_int = 16;
1277 pub const KERN_POSIX1: ::c_int = 17;
1278 pub const KERN_NGROUPS: ::c_int = 18;
1279 pub const KERN_JOB_CONTROL: ::c_int = 19;
1280 pub const KERN_SAVED_IDS: ::c_int = 20;
1281 pub const KERN_BOOTTIME: ::c_int = 21;
1282 pub const KERN_DOMAINNAME: ::c_int = 22;
1283 pub const KERN_MAXPARTITIONS: ::c_int = 23;
1284 pub const KERN_RAWPARTITION: ::c_int = 24;
1285 pub const KERN_MAXTHREAD: ::c_int = 25;
1286 pub const KERN_NTHREADS: ::c_int = 26;
1287 pub const KERN_OSVERSION: ::c_int = 27;
1288 pub const KERN_SOMAXCONN: ::c_int = 28;
1289 pub const KERN_SOMINCONN: ::c_int = 29;
1290 #[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")]
1291 pub const KERN_USERMOUNT: ::c_int = 30;
1292 pub const KERN_NOSUIDCOREDUMP: ::c_int = 32;
1293 pub const KERN_FSYNC: ::c_int = 33;
1294 pub const KERN_SYSVMSG: ::c_int = 34;
1295 pub const KERN_SYSVSEM: ::c_int = 35;
1296 pub const KERN_SYSVSHM: ::c_int = 36;
1297 #[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")]
1298 pub const KERN_ARND: ::c_int = 37;
1299 pub const KERN_MSGBUFSIZE: ::c_int = 38;
1300 pub const KERN_MALLOCSTATS: ::c_int = 39;
1301 pub const KERN_CPTIME: ::c_int = 40;
1302 pub const KERN_NCHSTATS: ::c_int = 41;
1303 pub const KERN_FORKSTAT: ::c_int = 42;
1304 pub const KERN_NSELCOLL: ::c_int = 43;
1305 pub const KERN_TTY: ::c_int = 44;
1306 pub const KERN_CCPU: ::c_int = 45;
1307 pub const KERN_FSCALE: ::c_int = 46;
1308 pub const KERN_NPROCS: ::c_int = 47;
1309 pub const KERN_MSGBUF: ::c_int = 48;
1310 pub const KERN_POOL: ::c_int = 49;
1311 pub const KERN_STACKGAPRANDOM: ::c_int = 50;
1312 pub const KERN_SYSVIPC_INFO: ::c_int = 51;
1313 pub const KERN_SPLASSERT: ::c_int = 54;
1314 pub const KERN_PROC_ARGS: ::c_int = 55;
1315 pub const KERN_NFILES: ::c_int = 56;
1316 pub const KERN_TTYCOUNT: ::c_int = 57;
1317 pub const KERN_NUMVNODES: ::c_int = 58;
1318 pub const KERN_MBSTAT: ::c_int = 59;
1319 pub const KERN_SEMINFO: ::c_int = 61;
1320 pub const KERN_SHMINFO: ::c_int = 62;
1321 pub const KERN_INTRCNT: ::c_int = 63;
1322 pub const KERN_WATCHDOG: ::c_int = 64;
1323 pub const KERN_PROC: ::c_int = 66;
1324 pub const KERN_MAXCLUSTERS: ::c_int = 67;
1325 pub const KERN_EVCOUNT: ::c_int = 68;
1326 pub const KERN_TIMECOUNTER: ::c_int = 69;
1327 pub const KERN_MAXLOCKSPERUID: ::c_int = 70;
1328 pub const KERN_CPTIME2: ::c_int = 71;
1329 pub const KERN_CACHEPCT: ::c_int = 72;
1330 pub const KERN_FILE: ::c_int = 73;
1331 pub const KERN_CONSDEV: ::c_int = 75;
1332 pub const KERN_NETLIVELOCKS: ::c_int = 76;
1333 pub const KERN_POOL_DEBUG: ::c_int = 77;
1334 pub const KERN_PROC_CWD: ::c_int = 78;
1335 pub const KERN_PROC_NOBROADCASTKILL: ::c_int = 79;
1336 pub const KERN_PROC_VMMAP: ::c_int = 80;
1337 pub const KERN_GLOBAL_PTRACE: ::c_int = 81;
1338 pub const KERN_CONSBUFSIZE: ::c_int = 82;
1339 pub const KERN_CONSBUF: ::c_int = 83;
1340 pub const KERN_AUDIO: ::c_int = 84;
1341 pub const KERN_CPUSTATS: ::c_int = 85;
1342 pub const KERN_PFSTATUS: ::c_int = 86;
1343 pub const KERN_TIMEOUT_STATS: ::c_int = 87;
1344 #[deprecated(
1345     since = "0.2.95",
1346     note = "Possibly increasing over the releases and might not be so used in the field"
1347 )]
1348 pub const KERN_MAXID: ::c_int = 88;
1349 
1350 pub const KERN_PROC_ALL: ::c_int = 0;
1351 pub const KERN_PROC_PID: ::c_int = 1;
1352 pub const KERN_PROC_PGRP: ::c_int = 2;
1353 pub const KERN_PROC_SESSION: ::c_int = 3;
1354 pub const KERN_PROC_TTY: ::c_int = 4;
1355 pub const KERN_PROC_UID: ::c_int = 5;
1356 pub const KERN_PROC_RUID: ::c_int = 6;
1357 pub const KERN_PROC_KTHREAD: ::c_int = 7;
1358 pub const KERN_PROC_SHOW_THREADS: ::c_int = 0x40000000;
1359 
1360 pub const KERN_SYSVIPC_MSG_INFO: ::c_int = 1;
1361 pub const KERN_SYSVIPC_SEM_INFO: ::c_int = 2;
1362 pub const KERN_SYSVIPC_SHM_INFO: ::c_int = 3;
1363 
1364 pub const KERN_PROC_ARGV: ::c_int = 1;
1365 pub const KERN_PROC_NARGV: ::c_int = 2;
1366 pub const KERN_PROC_ENV: ::c_int = 3;
1367 pub const KERN_PROC_NENV: ::c_int = 4;
1368 
1369 pub const KI_NGROUPS: ::c_int = 16;
1370 pub const KI_MAXCOMLEN: ::c_int = 24;
1371 pub const KI_WMESGLEN: ::c_int = 8;
1372 pub const KI_MAXLOGNAME: ::c_int = 32;
1373 pub const KI_EMULNAMELEN: ::c_int = 8;
1374 
1375 pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS;
1376 pub const OLCUC: ::tcflag_t = 0x20;
1377 pub const ONOCR: ::tcflag_t = 0x40;
1378 pub const ONLRET: ::tcflag_t = 0x80;
1379 
1380 //https://github.com/openbsd/src/blob/master/sys/sys/mount.h
1381 pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext
1382 pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers
1383 pub const ISOFSMNT_EXTATT: ::c_int = 0x4; // enable extended attr
1384 pub const ISOFSMNT_NOJOLIET: ::c_int = 0x8; // disable Joliet Ext
1385 pub const ISOFSMNT_SESS: ::c_int = 0x10; // use iso_args.sess
1386 
1387 pub const NFS_ARGSVERSION: ::c_int = 4; // change when nfs_args changes
1388 
1389 pub const NFSMNT_RESVPORT: ::c_int = 0; // always use reserved ports
1390 pub const NFSMNT_SOFT: ::c_int = 0x1; // soft mount (hard is default)
1391 pub const NFSMNT_WSIZE: ::c_int = 0x2; // set write size
1392 pub const NFSMNT_RSIZE: ::c_int = 0x4; // set read size
1393 pub const NFSMNT_TIMEO: ::c_int = 0x8; // set initial timeout
1394 pub const NFSMNT_RETRANS: ::c_int = 0x10; // set number of request retries
1395 pub const NFSMNT_MAXGRPS: ::c_int = 0x20; // set maximum grouplist size
1396 pub const NFSMNT_INT: ::c_int = 0x40; // allow interrupts on hard mount
1397 pub const NFSMNT_NOCONN: ::c_int = 0x80; // Don't Connect the socket
1398 pub const NFSMNT_NQNFS: ::c_int = 0x100; // Use Nqnfs protocol
1399 pub const NFSMNT_NFSV3: ::c_int = 0x200; // Use NFS Version 3 protocol
1400 pub const NFSMNT_KERB: ::c_int = 0x400; // Use Kerberos authentication
1401 pub const NFSMNT_DUMBTIMR: ::c_int = 0x800; // Don't estimate rtt dynamically
1402 pub const NFSMNT_LEASETERM: ::c_int = 0x1000; // set lease term (nqnfs)
1403 pub const NFSMNT_READAHEAD: ::c_int = 0x2000; // set read ahead
1404 pub const NFSMNT_DEADTHRESH: ::c_int = 0x4000; // set dead server retry thresh
1405 pub const NFSMNT_NOAC: ::c_int = 0x8000; // disable attribute cache
1406 pub const NFSMNT_RDIRPLUS: ::c_int = 0x10000; // Use Readdirplus for V3
1407 pub const NFSMNT_READDIRSIZE: ::c_int = 0x20000; // Set readdir size
1408 
1409 /* Flags valid only in mount syscall arguments */
1410 pub const NFSMNT_ACREGMIN: ::c_int = 0x40000; // acregmin field valid
1411 pub const NFSMNT_ACREGMAX: ::c_int = 0x80000; // acregmax field valid
1412 pub const NFSMNT_ACDIRMIN: ::c_int = 0x100000; // acdirmin field valid
1413 pub const NFSMNT_ACDIRMAX: ::c_int = 0x200000; // acdirmax field valid
1414 
1415 /* Flags valid only in kernel */
1416 pub const NFSMNT_INTERNAL: ::c_int = 0xfffc0000; // Bits set internally
1417 pub const NFSMNT_HASWRITEVERF: ::c_int = 0x40000; // Has write verifier for V3
1418 pub const NFSMNT_GOTPATHCONF: ::c_int = 0x80000; // Got the V3 pathconf info
1419 pub const NFSMNT_GOTFSINFO: ::c_int = 0x100000; // Got the V3 fsinfo
1420 pub const NFSMNT_MNTD: ::c_int = 0x200000; // Mnt server for mnt point
1421 pub const NFSMNT_DISMINPROG: ::c_int = 0x400000; // Dismount in progress
1422 pub const NFSMNT_DISMNT: ::c_int = 0x800000; // Dismounted
1423 pub const NFSMNT_SNDLOCK: ::c_int = 0x1000000; // Send socket lock
1424 pub const NFSMNT_WANTSND: ::c_int = 0x2000000; // Want above
1425 pub const NFSMNT_RCVLOCK: ::c_int = 0x4000000; // Rcv socket lock
1426 pub const NFSMNT_WANTRCV: ::c_int = 0x8000000; // Want above
1427 pub const NFSMNT_WAITAUTH: ::c_int = 0x10000000; // Wait for authentication
1428 pub const NFSMNT_HASAUTH: ::c_int = 0x20000000; // Has authenticator
1429 pub const NFSMNT_WANTAUTH: ::c_int = 0x40000000; // Wants an authenticator
1430 pub const NFSMNT_AUTHERR: ::c_int = 0x80000000; // Authentication error
1431 
1432 pub const MSDOSFSMNT_SHORTNAME: ::c_int = 0x1; // Force old DOS short names only
1433 pub const MSDOSFSMNT_LONGNAME: ::c_int = 0x2; // Force Win'95 long names
1434 pub const MSDOSFSMNT_NOWIN95: ::c_int = 0x4; // Completely ignore Win95 entries
1435 
1436 pub const NTFS_MFLAG_CASEINS: ::c_int = 0x1;
1437 pub const NTFS_MFLAG_ALLNAMES: ::c_int = 0x2;
1438 
1439 pub const TMPFS_ARGS_VERSION: ::c_int = 1;
1440 
1441 pub const MAP_STACK: ::c_int = 0x4000;
1442 pub const MAP_CONCEAL: ::c_int = 0x8000;
1443 
1444 // https://github.com/openbsd/src/blob/master/sys/net/if.h#L187
1445 pub const IFF_UP: ::c_int = 0x1; // interface is up
1446 pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
1447 pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
1448 pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
1449 pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
1450 pub const IFF_STATICARP: ::c_int = 0x20; // only static ARP
1451 pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
1452 pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
1453 pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
1454 pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
1455 pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress
1456 pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
1457 pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
1458 pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
1459 pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
1460 pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
1461 
1462 pub const PTHREAD_STACK_MIN: ::size_t = 1_usize << _MAX_PAGE_SHIFT;
1463 pub const MINSIGSTKSZ: ::size_t = 3_usize << _MAX_PAGE_SHIFT;
1464 pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + (1_usize << _MAX_PAGE_SHIFT) * 4;
1465 
1466 pub const PT_SET_EVENT_MASK: ::c_int = 12;
1467 pub const PT_GET_EVENT_MASK: ::c_int = 13;
1468 pub const PT_GET_PROCESS_STATE: ::c_int = 14;
1469 pub const PT_GET_THREAD_FIRST: ::c_int = 15;
1470 pub const PT_GET_THREAD_NEXT: ::c_int = 16;
1471 pub const PT_FIRSTMACH: ::c_int = 32;
1472 
1473 pub const SOCK_CLOEXEC: ::c_int = 0x8000;
1474 pub const SOCK_NONBLOCK: ::c_int = 0x4000;
1475 pub const SOCK_DNS: ::c_int = 0x1000;
1476 
1477 pub const BIOCGRSIG: ::c_ulong = 0x40044273;
1478 pub const BIOCSRSIG: ::c_ulong = 0x80044272;
1479 pub const BIOCSDLT: ::c_ulong = 0x8004427a;
1480 
1481 pub const PTRACE_FORK: ::c_int = 0x0002;
1482 
1483 pub const WCONTINUED: ::c_int = 8;
1484 
1485 // search.h
1486 pub const FIND: ::ACTION = 0;
1487 pub const ENTER: ::ACTION = 1;
1488 
1489 const_fn! {
1490     {const} fn _ALIGN(p: usize) -> usize {
1491         (p + _ALIGNBYTES) & !_ALIGNBYTES
1492     }
1493 }
1494 
1495 f! {
1496     pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
1497         (cmsg as *mut ::c_uchar)
1498             .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
1499     }
1500 
1501     pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1502         _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
1503     }
1504 
1505     pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
1506         -> *mut ::cmsghdr
1507     {
1508         if cmsg.is_null() {
1509             return ::CMSG_FIRSTHDR(mhdr);
1510         };
1511         let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
1512             + _ALIGN(::mem::size_of::<::cmsghdr>());
1513         let max = (*mhdr).msg_control as usize
1514             + (*mhdr).msg_controllen as usize;
1515         if next > max {
1516             0 as *mut ::cmsghdr
1517         } else {
1518             (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
1519                 as *mut ::cmsghdr
1520         }
1521     }
1522 
1523     pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
1524         (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
1525             as ::c_uint
1526     }
1527 }
1528 
1529 safe_f! {
1530     pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
1531         status >> 8
1532     }
1533 
1534     pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
1535         (status & 0o177) != 0o177 && (status & 0o177) != 0
1536     }
1537 
1538     pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
1539         (status & 0xff) == 0o177
1540     }
1541 
1542     pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
1543         (status & 0o177777) == 0o177777
1544     }
1545 }
1546 
1547 extern "C" {
gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int1548     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
settimeofday(tp: *const ::timeval, tz: *const ::timezone) -> ::c_int1549     pub fn settimeofday(tp: *const ::timeval, tz: *const ::timezone) -> ::c_int;
execvpe( file: *const ::c_char, argv: *const *const ::c_char, envp: *const *const ::c_char, ) -> ::c_int1550     pub fn execvpe(
1551         file: *const ::c_char,
1552         argv: *const *const ::c_char,
1553         envp: *const *const ::c_char,
1554     ) -> ::c_int;
pledge(promises: *const ::c_char, execpromises: *const ::c_char) -> ::c_int1555     pub fn pledge(promises: *const ::c_char, execpromises: *const ::c_char) -> ::c_int;
unveil(path: *const ::c_char, permissions: *const ::c_char) -> ::c_int1556     pub fn unveil(path: *const ::c_char, permissions: *const ::c_char) -> ::c_int;
strtonum( nptr: *const ::c_char, minval: ::c_longlong, maxval: ::c_longlong, errstr: *mut *const ::c_char, ) -> ::c_longlong1557     pub fn strtonum(
1558         nptr: *const ::c_char,
1559         minval: ::c_longlong,
1560         maxval: ::c_longlong,
1561         errstr: *mut *const ::c_char,
1562     ) -> ::c_longlong;
dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int1563     pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int1564     pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int;
fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int1565     pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int;
chflagsat( fd: ::c_int, path: *const ::c_char, flags: ::c_uint, atflag: ::c_int, ) -> ::c_int1566     pub fn chflagsat(
1567         fd: ::c_int,
1568         path: *const ::c_char,
1569         flags: ::c_uint,
1570         atflag: ::c_int,
1571     ) -> ::c_int;
dirfd(dirp: *mut ::DIR) -> ::c_int1572     pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
getnameinfo( sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, hostlen: ::size_t, serv: *mut ::c_char, servlen: ::size_t, flags: ::c_int, ) -> ::c_int1573     pub fn getnameinfo(
1574         sa: *const ::sockaddr,
1575         salen: ::socklen_t,
1576         host: *mut ::c_char,
1577         hostlen: ::size_t,
1578         serv: *mut ::c_char,
1579         servlen: ::size_t,
1580         flags: ::c_int,
1581     ) -> ::c_int;
getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int1582     pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int;
getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int1583     pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int;
kevent( kq: ::c_int, changelist: *const ::kevent, nchanges: ::c_int, eventlist: *mut ::kevent, nevents: ::c_int, timeout: *const ::timespec, ) -> ::c_int1584     pub fn kevent(
1585         kq: ::c_int,
1586         changelist: *const ::kevent,
1587         nchanges: ::c_int,
1588         eventlist: *mut ::kevent,
1589         nevents: ::c_int,
1590         timeout: *const ::timespec,
1591     ) -> ::c_int;
mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int1592     pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
getthrid() -> ::pid_t1593     pub fn getthrid() -> ::pid_t;
pthread_attr_getguardsize( attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int1594     pub fn pthread_attr_getguardsize(
1595         attr: *const ::pthread_attr_t,
1596         guardsize: *mut ::size_t,
1597     ) -> ::c_int;
pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, stacksize: *mut ::size_t, ) -> ::c_int1598     pub fn pthread_attr_getstack(
1599         attr: *const ::pthread_attr_t,
1600         stackaddr: *mut *mut ::c_void,
1601         stacksize: *mut ::size_t,
1602     ) -> ::c_int;
pthread_main_np() -> ::c_int1603     pub fn pthread_main_np() -> ::c_int;
pthread_get_name_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t)1604     pub fn pthread_get_name_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t);
pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char)1605     pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
pthread_stackseg_np(thread: ::pthread_t, sinfo: *mut ::stack_t) -> ::c_int1606     pub fn pthread_stackseg_np(thread: ::pthread_t, sinfo: *mut ::stack_t) -> ::c_int;
1607 
sysctl( name: *const ::c_int, namelen: ::c_uint, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t, ) -> ::c_int1608     pub fn sysctl(
1609         name: *const ::c_int,
1610         namelen: ::c_uint,
1611         oldp: *mut ::c_void,
1612         oldlenp: *mut ::size_t,
1613         newp: *mut ::c_void,
1614         newlen: ::size_t,
1615     ) -> ::c_int;
getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int1616     pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int1617     pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int1618     pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
ptrace(request: ::c_int, pid: ::pid_t, addr: caddr_t, data: ::c_int) -> ::c_int1619     pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: caddr_t, data: ::c_int) -> ::c_int;
utrace(label: *const ::c_char, addr: *const ::c_void, len: ::size_t) -> ::c_int1620     pub fn utrace(label: *const ::c_char, addr: *const ::c_void, len: ::size_t) -> ::c_int;
memmem( haystack: *const ::c_void, haystacklen: ::size_t, needle: *const ::c_void, needlelen: ::size_t, ) -> *mut ::c_void1621     pub fn memmem(
1622         haystack: *const ::c_void,
1623         haystacklen: ::size_t,
1624         needle: *const ::c_void,
1625         needlelen: ::size_t,
1626     ) -> *mut ::c_void;
1627     // #include <link.h>
dl_iterate_phdr( callback: ::Option< unsafe extern "C" fn( info: *mut dl_phdr_info, size: usize, data: *mut ::c_void, ) -> ::c_int, >, data: *mut ::c_void, ) -> ::c_int1628     pub fn dl_iterate_phdr(
1629         callback: ::Option<
1630             unsafe extern "C" fn(
1631                 info: *mut dl_phdr_info,
1632                 size: usize,
1633                 data: *mut ::c_void,
1634             ) -> ::c_int,
1635         >,
1636         data: *mut ::c_void,
1637     ) -> ::c_int;
uselocale(loc: ::locale_t) -> ::locale_t1638     pub fn uselocale(loc: ::locale_t) -> ::locale_t;
freelocale(loc: ::locale_t)1639     pub fn freelocale(loc: ::locale_t);
newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t1640     pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
duplocale(base: ::locale_t) -> ::locale_t1641     pub fn duplocale(base: ::locale_t) -> ::locale_t;
1642 
1643     // Added in `OpenBSD` 5.5
explicit_bzero(s: *mut ::c_void, len: ::size_t)1644     pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t);
1645 
setproctitle(fmt: *const ::c_char, ...)1646     pub fn setproctitle(fmt: *const ::c_char, ...);
1647 
freezero(ptr: *mut ::c_void, size: ::size_t)1648     pub fn freezero(ptr: *mut ::c_void, size: ::size_t);
malloc_conceal(size: ::size_t) -> *mut ::c_void1649     pub fn malloc_conceal(size: ::size_t) -> *mut ::c_void;
calloc_conceal(nmemb: ::size_t, size: ::size_t) -> *mut ::c_void1650     pub fn calloc_conceal(nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
1651 
srand48_deterministic(seed: ::c_long)1652     pub fn srand48_deterministic(seed: ::c_long);
seed48_deterministic(xseed: *mut ::c_ushort) -> *mut ::c_ushort1653     pub fn seed48_deterministic(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
lcong48_deterministic(p: *mut ::c_ushort)1654     pub fn lcong48_deterministic(p: *mut ::c_ushort);
1655 
lsearch( key: *const ::c_void, base: *mut ::c_void, nelp: *mut ::size_t, width: ::size_t, compar: ::Option<unsafe extern "C" fn(*const ::c_void, *const ::c_void) -> ::c_int>, ) -> *mut ::c_void1656     pub fn lsearch(
1657         key: *const ::c_void,
1658         base: *mut ::c_void,
1659         nelp: *mut ::size_t,
1660         width: ::size_t,
1661         compar: ::Option<unsafe extern "C" fn(*const ::c_void, *const ::c_void) -> ::c_int>,
1662     ) -> *mut ::c_void;
lfind( key: *const ::c_void, base: *const ::c_void, nelp: *mut ::size_t, width: ::size_t, compar: ::Option<unsafe extern "C" fn(*const ::c_void, *const ::c_void) -> ::c_int>, ) -> *mut ::c_void1663     pub fn lfind(
1664         key: *const ::c_void,
1665         base: *const ::c_void,
1666         nelp: *mut ::size_t,
1667         width: ::size_t,
1668         compar: ::Option<unsafe extern "C" fn(*const ::c_void, *const ::c_void) -> ::c_int>,
1669     ) -> *mut ::c_void;
hcreate(nelt: ::size_t) -> ::c_int1670     pub fn hcreate(nelt: ::size_t) -> ::c_int;
hdestroy()1671     pub fn hdestroy();
hsearch(entry: ::ENTRY, action: ::ACTION) -> *mut ::ENTRY1672     pub fn hsearch(entry: ::ENTRY, action: ::ACTION) -> *mut ::ENTRY;
1673 }
1674 
1675 #[link(name = "execinfo")]
1676 extern "C" {
backtrace(addrlist: *mut *mut ::c_void, len: ::size_t) -> ::size_t1677     pub fn backtrace(addrlist: *mut *mut ::c_void, len: ::size_t) -> ::size_t;
backtrace_symbols(addrlist: *const *mut ::c_void, len: ::size_t) -> *mut *mut ::c_char1678     pub fn backtrace_symbols(addrlist: *const *mut ::c_void, len: ::size_t) -> *mut *mut ::c_char;
backtrace_symbols_fd( addrlist: *const *mut ::c_void, len: ::size_t, fd: ::c_int, ) -> ::c_int1679     pub fn backtrace_symbols_fd(
1680         addrlist: *const *mut ::c_void,
1681         len: ::size_t,
1682         fd: ::c_int,
1683     ) -> ::c_int;
backtrace_symbols_fmt( addrlist: *const *mut ::c_void, len: ::size_t, fmt: *const ::c_char, ) -> *mut *mut ::c_char1684     pub fn backtrace_symbols_fmt(
1685         addrlist: *const *mut ::c_void,
1686         len: ::size_t,
1687         fmt: *const ::c_char,
1688     ) -> *mut *mut ::c_char;
1689 }
1690 
1691 cfg_if! {
1692     if #[cfg(libc_union)] {
1693         extern {
1694             // these functions use statfs which uses the union mount_info:
1695             pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
1696             pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
1697         }
1698     }
1699 }
1700 
1701 cfg_if! {
1702     if #[cfg(target_arch = "aarch64")] {
1703         mod aarch64;
1704         pub use self::aarch64::*;
1705     } else if #[cfg(target_arch = "arm")] {
1706         mod arm;
1707         pub use self::arm::*;
1708     } else if #[cfg(target_arch = "mips64")] {
1709         mod mips64;
1710         pub use self::mips64::*;
1711     } else if #[cfg(target_arch = "powerpc")] {
1712         mod powerpc;
1713         pub use self::powerpc::*;
1714     } else if #[cfg(target_arch = "powerpc64")] {
1715         mod powerpc64;
1716         pub use self::powerpc64::*;
1717     } else if #[cfg(target_arch = "riscv64")] {
1718         mod riscv64;
1719         pub use self::riscv64::*;
1720     } else if #[cfg(target_arch = "sparc64")] {
1721         mod sparc64;
1722         pub use self::sparc64::*;
1723     } else if #[cfg(target_arch = "x86")] {
1724         mod x86;
1725         pub use self::x86::*;
1726     } else if #[cfg(target_arch = "x86_64")] {
1727         mod x86_64;
1728         pub use self::x86_64::*;
1729     } else {
1730         // Unknown target_arch
1731     }
1732 }
1733