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