1 pub type clock_t = ::c_uint;
2 pub type suseconds_t = ::c_int;
3 pub type dev_t = u64;
4 pub type blksize_t = i32;
5 pub type fsblkcnt_t = u64;
6 pub type fsfilcnt_t = u64;
7 pub type idtype_t = ::c_int;
8 pub type mqd_t = ::c_int;
9 type __pthread_spin_t = __cpu_simple_lock_nv_t;
10 pub type vm_size_t = ::uintptr_t; // FIXME: deprecated since long time
11 pub type lwpid_t = ::c_uint;
12 pub type shmatt_t = ::c_uint;
13 pub type cpuid_t = u64;
14 pub type cpuset_t = _cpuset;
15 
16 // elf.h
17 
18 pub type Elf32_Addr = u32;
19 pub type Elf32_Half = u16;
20 pub type Elf32_Lword = u64;
21 pub type Elf32_Off = u32;
22 pub type Elf32_Sword = i32;
23 pub type Elf32_Word = u32;
24 
25 pub type Elf64_Addr = u64;
26 pub type Elf64_Half = u16;
27 pub type Elf64_Lword = u64;
28 pub type Elf64_Off = u64;
29 pub type Elf64_Sword = i32;
30 pub type Elf64_Sxword = i64;
31 pub type Elf64_Word = u32;
32 pub type Elf64_Xword = u64;
33 
34 pub type iconv_t = *mut ::c_void;
35 
36 cfg_if! {
37     if #[cfg(target_pointer_width = "64")] {
38         type Elf_Addr = Elf64_Addr;
39         type Elf_Half = Elf64_Half;
40         type Elf_Phdr = Elf64_Phdr;
41     } else if #[cfg(target_pointer_width = "32")] {
42         type Elf_Addr = Elf32_Addr;
43         type Elf_Half = Elf32_Half;
44         type Elf_Phdr = Elf32_Phdr;
45     }
46 }
47 
48 impl siginfo_t {
si_addr(&self) -> *mut ::c_void49     pub unsafe fn si_addr(&self) -> *mut ::c_void {
50         self.si_addr
51     }
52 
si_value(&self) -> ::sigval53     pub unsafe fn si_value(&self) -> ::sigval {
54         #[repr(C)]
55         struct siginfo_timer {
56             _si_signo: ::c_int,
57             _si_errno: ::c_int,
58             _si_code: ::c_int,
59             __pad1: ::c_int,
60             _pid: ::pid_t,
61             _uid: ::uid_t,
62             value: ::sigval,
63         }
64         (*(self as *const siginfo_t as *const siginfo_timer)).value
65     }
66 }
67 
68 s! {
69     pub struct aiocb {
70         pub aio_offset: ::off_t,
71         pub aio_buf: *mut ::c_void,
72         pub aio_nbytes: ::size_t,
73         pub aio_fildes: ::c_int,
74         pub aio_lio_opcode: ::c_int,
75         pub aio_reqprio: ::c_int,
76         pub aio_sigevent: ::sigevent,
77         _state: ::c_int,
78         _errno: ::c_int,
79         _retval: ::ssize_t
80     }
81 
82     pub struct glob_t {
83         pub gl_pathc:   ::size_t,
84         pub gl_matchc:  ::size_t,
85         pub gl_offs:    ::size_t,
86         pub gl_flags:   ::c_int,
87         pub gl_pathv:   *mut *mut ::c_char,
88 
89         __unused3: *mut ::c_void,
90 
91         __unused4: *mut ::c_void,
92         __unused5: *mut ::c_void,
93         __unused6: *mut ::c_void,
94         __unused7: *mut ::c_void,
95         __unused8: *mut ::c_void,
96     }
97 
98     pub struct mq_attr {
99         pub mq_flags: ::c_long,
100         pub mq_maxmsg: ::c_long,
101         pub mq_msgsize: ::c_long,
102         pub mq_curmsgs: ::c_long,
103     }
104 
105     pub struct sigset_t {
106         __bits: [u32; 4],
107     }
108 
109     pub struct stat {
110         pub st_dev: ::dev_t,
111         pub st_mode: ::mode_t,
112         pub st_ino: ::ino_t,
113         pub st_nlink: ::nlink_t,
114         pub st_uid: ::uid_t,
115         pub st_gid: ::gid_t,
116         pub st_rdev: ::dev_t,
117         pub st_atime: ::time_t,
118         pub st_atimensec: ::c_long,
119         pub st_mtime: ::time_t,
120         pub st_mtimensec: ::c_long,
121         pub st_ctime: ::time_t,
122         pub st_ctimensec: ::c_long,
123         pub st_birthtime: ::time_t,
124         pub st_birthtimensec: ::c_long,
125         pub st_size: ::off_t,
126         pub st_blocks: ::blkcnt_t,
127         pub st_blksize: ::blksize_t,
128         pub st_flags: u32,
129         pub st_gen: u32,
130         pub st_spare: [u32; 2],
131     }
132 
133     pub struct addrinfo {
134         pub ai_flags: ::c_int,
135         pub ai_family: ::c_int,
136         pub ai_socktype: ::c_int,
137         pub ai_protocol: ::c_int,
138         pub ai_addrlen: ::socklen_t,
139         pub ai_canonname: *mut ::c_char,
140         pub ai_addr: *mut ::sockaddr,
141         pub ai_next: *mut ::addrinfo,
142     }
143 
144     pub struct siginfo_t {
145         pub si_signo: ::c_int,
146         pub si_code: ::c_int,
147         pub si_errno: ::c_int,
148         __pad1: ::c_int,
149         pub si_addr: *mut ::c_void,
150         __pad2: [u64; 13],
151     }
152 
153     pub struct pthread_attr_t {
154         pta_magic: ::c_uint,
155         pta_flags: ::c_int,
156         pta_private: *mut ::c_void,
157     }
158 
159     pub struct pthread_mutex_t {
160         ptm_magic: ::c_uint,
161         ptm_errorcheck: __pthread_spin_t,
162         #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
163                   target_arch = "x86", target_arch = "x86_64"))]
164         ptm_pad1: [u8; 3],
165         // actually a union with a non-unused, 0-initialized field
166         ptm_unused: __pthread_spin_t,
167         #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
168                   target_arch = "x86", target_arch = "x86_64"))]
169         ptm_pad2: [u8; 3],
170         ptm_owner: ::pthread_t,
171         ptm_waiters: *mut u8,
172         ptm_recursed: ::c_uint,
173         ptm_spare2: *mut ::c_void,
174     }
175 
176     pub struct pthread_mutexattr_t {
177         ptma_magic: ::c_uint,
178         ptma_private: *mut ::c_void,
179     }
180 
181     pub struct pthread_rwlockattr_t {
182         ptra_magic: ::c_uint,
183         ptra_private: *mut ::c_void,
184     }
185 
186     pub struct pthread_cond_t {
187         ptc_magic: ::c_uint,
188         ptc_lock: __pthread_spin_t,
189         ptc_waiters_first: *mut u8,
190         ptc_waiters_last: *mut u8,
191         ptc_mutex: *mut ::pthread_mutex_t,
192         ptc_private: *mut ::c_void,
193     }
194 
195     pub struct pthread_condattr_t {
196         ptca_magic: ::c_uint,
197         ptca_private: *mut ::c_void,
198     }
199 
200     pub struct pthread_rwlock_t {
201         ptr_magic: ::c_uint,
202         ptr_interlock: __pthread_spin_t,
203         ptr_rblocked_first: *mut u8,
204         ptr_rblocked_last: *mut u8,
205         ptr_wblocked_first: *mut u8,
206         ptr_wblocked_last: *mut u8,
207         ptr_nreaders: ::c_uint,
208         ptr_owner: ::pthread_t,
209         ptr_private: *mut ::c_void,
210     }
211 
212     pub struct kevent {
213         pub ident: ::uintptr_t,
214         pub filter: u32,
215         pub flags: u32,
216         pub fflags: u32,
217         pub data: i64,
218         pub udata: ::intptr_t, /* FIXME: NetBSD 10.0 will finally have same layout as other BSD */
219     }
220 
221     pub struct dqblk {
222         pub dqb_bhardlimit: u32,
223         pub dqb_bsoftlimit: u32,
224         pub dqb_curblocks: u32,
225         pub dqb_ihardlimit: u32,
226         pub dqb_isoftlimit: u32,
227         pub dqb_curinodes: u32,
228         pub dqb_btime: i32,
229         pub dqb_itime: i32,
230     }
231 
232     pub struct Dl_info {
233         pub dli_fname: *const ::c_char,
234         pub dli_fbase: *mut ::c_void,
235         pub dli_sname: *const ::c_char,
236         pub dli_saddr: *const ::c_void,
237     }
238 
239     pub struct lconv {
240         pub decimal_point: *mut ::c_char,
241         pub thousands_sep: *mut ::c_char,
242         pub grouping: *mut ::c_char,
243         pub int_curr_symbol: *mut ::c_char,
244         pub currency_symbol: *mut ::c_char,
245         pub mon_decimal_point: *mut ::c_char,
246         pub mon_thousands_sep: *mut ::c_char,
247         pub mon_grouping: *mut ::c_char,
248         pub positive_sign: *mut ::c_char,
249         pub negative_sign: *mut ::c_char,
250         pub int_frac_digits: ::c_char,
251         pub frac_digits: ::c_char,
252         pub p_cs_precedes: ::c_char,
253         pub p_sep_by_space: ::c_char,
254         pub n_cs_precedes: ::c_char,
255         pub n_sep_by_space: ::c_char,
256         pub p_sign_posn: ::c_char,
257         pub n_sign_posn: ::c_char,
258         pub int_p_cs_precedes: ::c_char,
259         pub int_n_cs_precedes: ::c_char,
260         pub int_p_sep_by_space: ::c_char,
261         pub int_n_sep_by_space: ::c_char,
262         pub int_p_sign_posn: ::c_char,
263         pub int_n_sign_posn: ::c_char,
264     }
265 
266     pub struct if_data {
267         pub ifi_type: ::c_uchar,
268         pub ifi_addrlen: ::c_uchar,
269         pub ifi_hdrlen: ::c_uchar,
270         pub ifi_link_state: ::c_int,
271         pub ifi_mtu: u64,
272         pub ifi_metric: u64,
273         pub ifi_baudrate: u64,
274         pub ifi_ipackets: u64,
275         pub ifi_ierrors: u64,
276         pub ifi_opackets: u64,
277         pub ifi_oerrors: u64,
278         pub ifi_collisions: u64,
279         pub ifi_ibytes: u64,
280         pub ifi_obytes: u64,
281         pub ifi_imcasts: u64,
282         pub ifi_omcasts: u64,
283         pub ifi_iqdrops: u64,
284         pub ifi_noproto: u64,
285         pub ifi_lastchange: ::timespec,
286     }
287 
288     pub struct if_msghdr {
289         pub ifm_msglen: ::c_ushort,
290         pub ifm_version: ::c_uchar,
291         pub ifm_type: ::c_uchar,
292         pub ifm_addrs: ::c_int,
293         pub ifm_flags: ::c_int,
294         pub ifm_index: ::c_ushort,
295         pub ifm_data: if_data,
296     }
297 
298     pub struct sockcred {
299         pub sc_pid: ::pid_t,
300         pub sc_uid: ::uid_t,
301         pub sc_euid: ::uid_t,
302         pub sc_gid: ::gid_t,
303         pub sc_egid: ::gid_t,
304         pub sc_ngroups: ::c_int,
305         pub sc_groups: [::gid_t; 1],
306     }
307 
308     pub struct unpcbid {
309         pub unp_pid: ::pid_t,
310         pub unp_euid: ::uid_t,
311         pub unp_egid: ::gid_t,
312     }
313 
314     pub struct sockaddr_dl {
315         pub sdl_len: ::c_uchar,
316         pub sdl_family: ::c_uchar,
317         pub sdl_index: ::c_ushort,
318         pub sdl_type: u8,
319         pub sdl_nlen: u8,
320         pub sdl_alen: u8,
321         pub sdl_slen: u8,
322         pub sdl_data: [::c_char; 12],
323     }
324 
325     pub struct mmsghdr {
326         pub msg_hdr: ::msghdr,
327         pub msg_len: ::c_uint,
328     }
329 
330     pub struct __exit_status {
331         pub e_termination: u16,
332         pub e_exit: u16,
333     }
334 
335     pub struct shmid_ds {
336         pub shm_perm: ::ipc_perm,
337         pub shm_segsz: ::size_t,
338         pub shm_lpid: ::pid_t,
339         pub shm_cpid: ::pid_t,
340         pub shm_nattch: ::shmatt_t,
341         pub shm_atime: ::time_t,
342         pub shm_dtime: ::time_t,
343         pub shm_ctime: ::time_t,
344         _shm_internal: *mut ::c_void,
345     }
346 
347     pub struct utmp {
348         pub ut_line: [::c_char; UT_LINESIZE],
349         pub ut_name: [::c_char; UT_NAMESIZE],
350         pub ut_host: [::c_char; UT_HOSTSIZE],
351         pub ut_time: ::time_t
352     }
353 
354     pub struct lastlog {
355         pub ll_line: [::c_char; UT_LINESIZE],
356         pub ll_host: [::c_char; UT_HOSTSIZE],
357         pub ll_time: ::time_t
358     }
359 
360     pub struct timex {
361         pub modes: ::c_uint,
362         pub offset: ::c_long,
363         pub freq: ::c_long,
364         pub maxerror: ::c_long,
365         pub esterror: ::c_long,
366         pub status: ::c_int,
367         pub constant: ::c_long,
368         pub precision: ::c_long,
369         pub tolerance: ::c_long,
370         pub ppsfreq: ::c_long,
371         pub jitter: ::c_long,
372         pub shift: ::c_int,
373         pub stabil: ::c_long,
374         pub jitcnt: ::c_long,
375         pub calcnt: ::c_long,
376         pub errcnt: ::c_long,
377         pub stbcnt: ::c_long,
378     }
379 
380     pub struct ntptimeval {
381         pub time: ::timespec,
382         pub maxerror: ::c_long,
383         pub esterror: ::c_long,
384         pub tai: ::c_long,
385         pub time_state: ::c_int,
386     }
387 
388     // elf.h
389 
390     pub struct Elf32_Phdr {
391         pub p_type: Elf32_Word,
392         pub p_offset: Elf32_Off,
393         pub p_vaddr: Elf32_Addr,
394         pub p_paddr: Elf32_Addr,
395         pub p_filesz: Elf32_Word,
396         pub p_memsz: Elf32_Word,
397         pub p_flags: Elf32_Word,
398         pub p_align: Elf32_Word,
399     }
400 
401     pub struct Elf64_Phdr {
402         pub p_type: Elf64_Word,
403         pub p_flags: Elf64_Word,
404         pub p_offset: Elf64_Off,
405         pub p_vaddr: Elf64_Addr,
406         pub p_paddr: Elf64_Addr,
407         pub p_filesz: Elf64_Xword,
408         pub p_memsz: Elf64_Xword,
409         pub p_align: Elf64_Xword,
410     }
411 
412     pub struct Aux32Info {
413         pub a_type: Elf32_Word,
414         pub a_v: Elf32_Word,
415     }
416 
417     pub struct Aux64Info {
418         pub a_type: Elf64_Word,
419         pub a_v: Elf64_Xword,
420     }
421 
422     // link.h
423 
424     pub struct dl_phdr_info {
425         pub dlpi_addr: Elf_Addr,
426         pub dlpi_name: *const ::c_char,
427         pub dlpi_phdr: *const Elf_Phdr,
428         pub dlpi_phnum: Elf_Half,
429         pub dlpi_adds: ::c_ulonglong,
430         pub dlpi_subs: ::c_ulonglong,
431         pub dlpi_tls_modid: usize,
432         pub dlpi_tls_data: *mut ::c_void,
433     }
434 
435     pub struct _cpuset {
436         bits: [u32; 0]
437     }
438 
439     pub struct accept_filter_arg {
440         pub af_name: [::c_char; 16],
441         af_arg: [[::c_char; 10]; 24],
442     }
443 }
444 
445 s_no_extra_traits! {
446 
447     pub struct utmpx {
448         pub ut_name: [::c_char; _UTX_USERSIZE],
449         pub ut_id: [::c_char; _UTX_IDSIZE],
450         pub ut_line: [::c_char; _UTX_LINESIZE],
451         pub ut_host: [::c_char; _UTX_HOSTSIZE],
452         pub ut_session: u16,
453         pub ut_type: u16,
454         pub ut_pid: ::pid_t,
455         pub ut_exit: __exit_status, // FIXME: when anonymous struct are supported
456         pub ut_ss: sockaddr_storage,
457         pub ut_tv: ::timeval,
458         pub ut_pad: [u8; _UTX_PADSIZE],
459     }
460 
461     pub struct lastlogx {
462         pub ll_tv: ::timeval,
463         pub ll_line: [::c_char; _UTX_LINESIZE],
464         pub ll_host: [::c_char; _UTX_HOSTSIZE],
465         pub ll_ss: sockaddr_storage,
466     }
467 
468     pub struct in_pktinfo {
469         pub ipi_addr: ::in_addr,
470         pub ipi_ifindex: ::c_uint,
471     }
472 
473     pub struct arphdr {
474         pub ar_hrd: u16,
475         pub ar_pro: u16,
476         pub ar_hln: u8,
477         pub ar_pln: u8,
478         pub ar_op: u16,
479     }
480 
481     pub struct in_addr {
482         pub s_addr: ::in_addr_t,
483     }
484 
485     pub struct ip_mreq {
486         pub imr_multiaddr: in_addr,
487         pub imr_interface: in_addr,
488     }
489 
490     pub struct sockaddr_in {
491         pub sin_len: u8,
492         pub sin_family: ::sa_family_t,
493         pub sin_port: ::in_port_t,
494         pub sin_addr: ::in_addr,
495         pub sin_zero: [i8; 8],
496     }
497 
498     pub struct dirent {
499         pub d_fileno: ::ino_t,
500         pub d_reclen: u16,
501         pub d_namlen: u16,
502         pub d_type: u8,
503         pub d_name: [::c_char; 512],
504     }
505 
506     pub struct statvfs {
507         pub f_flag: ::c_ulong,
508         pub f_bsize: ::c_ulong,
509         pub f_frsize: ::c_ulong,
510         pub f_iosize: ::c_ulong,
511 
512         pub f_blocks: ::fsblkcnt_t,
513         pub f_bfree: ::fsblkcnt_t,
514         pub f_bavail: ::fsblkcnt_t,
515         pub f_bresvd: ::fsblkcnt_t,
516 
517         pub f_files: ::fsfilcnt_t,
518         pub f_ffree: ::fsfilcnt_t,
519         pub f_favail: ::fsfilcnt_t,
520         pub f_fresvd: ::fsfilcnt_t,
521 
522         pub f_syncreads: u64,
523         pub f_syncwrites: u64,
524 
525         pub f_asyncreads: u64,
526         pub f_asyncwrites: u64,
527 
528         pub f_fsidx: ::fsid_t,
529         pub f_fsid: ::c_ulong,
530         pub f_namemax: ::c_ulong,
531         pub f_owner: ::uid_t,
532 
533         pub f_spare: [u32; 4],
534 
535         pub f_fstypename: [::c_char; 32],
536         pub f_mntonname: [::c_char; 1024],
537         pub f_mntfromname: [::c_char; 1024],
538     }
539 
540     pub struct sockaddr_storage {
541         pub ss_len: u8,
542         pub ss_family: ::sa_family_t,
543         __ss_pad1: [u8; 6],
544         __ss_pad2: i64,
545         __ss_pad3: [u8; 112],
546     }
547 
548     pub struct sigevent {
549         pub sigev_notify: ::c_int,
550         pub sigev_signo: ::c_int,
551         pub sigev_value: ::sigval,
552         __unused1: *mut ::c_void,       //actually a function pointer
553         pub sigev_notify_attributes: *mut ::c_void
554     }
555 }
556 
557 cfg_if! {
558     if #[cfg(feature = "extra_traits")] {
559         impl PartialEq for utmpx {
560             fn eq(&self, other: &utmpx) -> bool {
561                 self.ut_type == other.ut_type
562                     && self.ut_pid == other.ut_pid
563                     && self.ut_name == other.ut_name
564                     && self.ut_line == other.ut_line
565                     && self.ut_id == other.ut_id
566                     && self.ut_exit == other.ut_exit
567                     && self.ut_session == other.ut_session
568                     && self.ut_tv == other.ut_tv
569                     && self.ut_ss == other.ut_ss
570                     && self
571                     .ut_pad
572                     .iter()
573                     .zip(other.ut_pad.iter())
574                     .all(|(a,b)| a == b)
575                     && self
576                     .ut_host
577                     .iter()
578                     .zip(other.ut_host.iter())
579                     .all(|(a,b)| a == b)
580             }
581         }
582 
583         impl Eq for utmpx {}
584 
585         impl ::fmt::Debug for utmpx {
586             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
587                 f.debug_struct("utmpx")
588                     .field("ut_name", &self.ut_name)
589                     .field("ut_id", &self.ut_id)
590                     .field("ut_line", &self.ut_line)
591                 // FIXME .field("ut_host", &self.ut_host)
592                     .field("ut_session", &self.ut_session)
593                     .field("ut_type", &self.ut_type)
594                     .field("ut_pid", &self.ut_pid)
595                     .field("ut_exit", &self.ut_exit)
596                     .field("ut_ss", &self.ut_ss)
597                     .field("ut_tv", &self.ut_tv)
598                 // FIXME .field("ut_pad", &self.ut_pad)
599                     .finish()
600             }
601         }
602 
603         impl ::hash::Hash for utmpx {
604             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
605                 self.ut_name.hash(state);
606                 self.ut_type.hash(state);
607                 self.ut_pid.hash(state);
608                 self.ut_line.hash(state);
609                 self.ut_id.hash(state);
610                 self.ut_host.hash(state);
611                 self.ut_exit.hash(state);
612                 self.ut_session.hash(state);
613                 self.ut_tv.hash(state);
614                 self.ut_ss.hash(state);
615                 self.ut_pad.hash(state);
616             }
617         }
618 
619         impl PartialEq for lastlogx {
620             fn eq(&self, other: &lastlogx) -> bool {
621                 self.ll_tv == other.ll_tv
622                     && self.ll_line == other.ll_line
623                     && self.ll_ss == other.ll_ss
624                     && self
625                     .ll_host
626                     .iter()
627                     .zip(other.ll_host.iter())
628                     .all(|(a,b)| a == b)
629             }
630         }
631 
632         impl Eq for lastlogx {}
633 
634         impl ::fmt::Debug for lastlogx {
635             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
636                 f.debug_struct("lastlogx")
637                     .field("ll_tv", &self.ll_tv)
638                     .field("ll_line", &self.ll_line)
639                 // FIXME.field("ll_host", &self.ll_host)
640                     .field("ll_ss", &self.ll_ss)
641                     .finish()
642             }
643         }
644 
645         impl ::hash::Hash for lastlogx {
646             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
647                 self.ll_tv.hash(state);
648                 self.ll_line.hash(state);
649                 self.ll_host.hash(state);
650                 self.ll_ss.hash(state);
651             }
652         }
653 
654         impl PartialEq for in_pktinfo {
655             fn eq(&self, other: &in_pktinfo) -> bool {
656                 self.ipi_addr == other.ipi_addr
657                     && self.ipi_ifindex == other.ipi_ifindex
658             }
659         }
660         impl Eq for in_pktinfo {}
661         impl ::fmt::Debug for in_pktinfo {
662             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
663                 f.debug_struct("in_pktinfo")
664                     .field("ipi_addr", &self.ipi_addr)
665                     .field("ipi_ifindex", &self.ipi_ifindex)
666                     .finish()
667             }
668         }
669         impl ::hash::Hash for in_pktinfo {
670             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
671                 self.ipi_addr.hash(state);
672                 self.ipi_ifindex.hash(state);
673             }
674         }
675 
676         impl PartialEq for arphdr {
677             fn eq(&self, other: &arphdr) -> bool {
678                 self.ar_hrd == other.ar_hrd
679                     && self.ar_pro == other.ar_pro
680                     && self.ar_hln == other.ar_hln
681                     && self.ar_pln == other.ar_pln
682                     && self.ar_op == other.ar_op
683             }
684         }
685         impl Eq for arphdr {}
686         impl ::fmt::Debug for arphdr {
687             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
688                 let ar_hrd = self.ar_hrd;
689                 let ar_pro = self.ar_pro;
690                 let ar_op = self.ar_op;
691                 f.debug_struct("arphdr")
692                     .field("ar_hrd", &ar_hrd)
693                     .field("ar_pro", &ar_pro)
694                     .field("ar_hln", &self.ar_hln)
695                     .field("ar_pln", &self.ar_pln)
696                     .field("ar_op", &ar_op)
697                     .finish()
698             }
699         }
700         impl ::hash::Hash for arphdr {
701             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
702                 let ar_hrd = self.ar_hrd;
703                 let ar_pro = self.ar_pro;
704                 let ar_op = self.ar_op;
705                 ar_hrd.hash(state);
706                 ar_pro.hash(state);
707                 self.ar_hln.hash(state);
708                 self.ar_pln.hash(state);
709                 ar_op.hash(state);
710             }
711         }
712 
713         impl PartialEq for in_addr {
714             fn eq(&self, other: &in_addr) -> bool {
715                 self.s_addr == other.s_addr
716             }
717         }
718         impl Eq for in_addr {}
719         impl ::fmt::Debug for in_addr {
720             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
721                 let s_addr = self.s_addr;
722                 f.debug_struct("in_addr")
723                     .field("s_addr", &s_addr)
724                     .finish()
725             }
726         }
727         impl ::hash::Hash for in_addr {
728             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
729                 let s_addr = self.s_addr;
730                 s_addr.hash(state);
731             }
732         }
733 
734         impl PartialEq for ip_mreq {
735             fn eq(&self, other: &ip_mreq) -> bool {
736                 self.imr_multiaddr == other.imr_multiaddr
737                     && self.imr_interface == other.imr_interface
738             }
739         }
740         impl Eq for ip_mreq {}
741         impl ::fmt::Debug for ip_mreq {
742             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
743                 f.debug_struct("ip_mreq")
744                     .field("imr_multiaddr", &self.imr_multiaddr)
745                     .field("imr_interface", &self.imr_interface)
746                     .finish()
747             }
748         }
749         impl ::hash::Hash for ip_mreq {
750             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
751                 self.imr_multiaddr.hash(state);
752                 self.imr_interface.hash(state);
753             }
754         }
755 
756         impl PartialEq for sockaddr_in {
757             fn eq(&self, other: &sockaddr_in) -> bool {
758                 self.sin_len == other.sin_len
759                     && self.sin_family == other.sin_family
760                     && self.sin_port == other.sin_port
761                     && self.sin_addr == other.sin_addr
762                     && self.sin_zero == other.sin_zero
763             }
764         }
765         impl Eq for sockaddr_in {}
766         impl ::fmt::Debug for sockaddr_in {
767             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
768                 f.debug_struct("sockaddr_in")
769                     .field("sin_len", &self.sin_len)
770                     .field("sin_family", &self.sin_family)
771                     .field("sin_port", &self.sin_port)
772                     .field("sin_addr", &self.sin_addr)
773                     .field("sin_zero", &self.sin_zero)
774                     .finish()
775             }
776         }
777         impl ::hash::Hash for sockaddr_in {
778             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
779                 self.sin_len.hash(state);
780                 self.sin_family.hash(state);
781                 self.sin_port.hash(state);
782                 self.sin_addr.hash(state);
783                 self.sin_zero.hash(state);
784             }
785         }
786 
787         impl PartialEq for dirent {
788             fn eq(&self, other: &dirent) -> bool {
789                 self.d_fileno == other.d_fileno
790                     && self.d_reclen == other.d_reclen
791                     && self.d_namlen == other.d_namlen
792                     && self.d_type == other.d_type
793                     && self
794                     .d_name
795                     .iter()
796                     .zip(other.d_name.iter())
797                     .all(|(a,b)| a == b)
798             }
799         }
800         impl Eq for dirent {}
801         impl ::fmt::Debug for dirent {
802             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
803                 f.debug_struct("dirent")
804                     .field("d_fileno", &self.d_fileno)
805                     .field("d_reclen", &self.d_reclen)
806                     .field("d_namlen", &self.d_namlen)
807                     .field("d_type", &self.d_type)
808                     // FIXME: .field("d_name", &self.d_name)
809                     .finish()
810             }
811         }
812         impl ::hash::Hash for dirent {
813             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
814                 self.d_fileno.hash(state);
815                 self.d_reclen.hash(state);
816                 self.d_namlen.hash(state);
817                 self.d_type.hash(state);
818                 self.d_name.hash(state);
819             }
820         }
821 
822         impl PartialEq for statvfs {
823             fn eq(&self, other: &statvfs) -> bool {
824                 self.f_flag == other.f_flag
825                     && self.f_bsize == other.f_bsize
826                     && self.f_frsize == other.f_frsize
827                     && self.f_iosize == other.f_iosize
828                     && self.f_blocks == other.f_blocks
829                     && self.f_bfree == other.f_bfree
830                     && self.f_bavail == other.f_bavail
831                     && self.f_bresvd == other.f_bresvd
832                     && self.f_files == other.f_files
833                     && self.f_ffree == other.f_ffree
834                     && self.f_favail == other.f_favail
835                     && self.f_fresvd == other.f_fresvd
836                     && self.f_syncreads == other.f_syncreads
837                     && self.f_syncwrites == other.f_syncwrites
838                     && self.f_asyncreads == other.f_asyncreads
839                     && self.f_asyncwrites == other.f_asyncwrites
840                     && self.f_fsidx == other.f_fsidx
841                     && self.f_fsid == other.f_fsid
842                     && self.f_namemax == other.f_namemax
843                     && self.f_owner == other.f_owner
844                     && self.f_spare == other.f_spare
845                     && self.f_fstypename == other.f_fstypename
846                     && self
847                     .f_mntonname
848                     .iter()
849                     .zip(other.f_mntonname.iter())
850                     .all(|(a,b)| a == b)
851                     && self
852                     .f_mntfromname
853                     .iter()
854                     .zip(other.f_mntfromname.iter())
855                     .all(|(a,b)| a == b)
856             }
857         }
858         impl Eq for statvfs {}
859         impl ::fmt::Debug for statvfs {
860             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
861                 f.debug_struct("statvfs")
862                     .field("f_flag", &self.f_flag)
863                     .field("f_bsize", &self.f_bsize)
864                     .field("f_frsize", &self.f_frsize)
865                     .field("f_iosize", &self.f_iosize)
866                     .field("f_blocks", &self.f_blocks)
867                     .field("f_bfree", &self.f_bfree)
868                     .field("f_bavail", &self.f_bavail)
869                     .field("f_bresvd", &self.f_bresvd)
870                     .field("f_files", &self.f_files)
871                     .field("f_ffree", &self.f_ffree)
872                     .field("f_favail", &self.f_favail)
873                     .field("f_fresvd", &self.f_fresvd)
874                     .field("f_syncreads", &self.f_syncreads)
875                     .field("f_syncwrites", &self.f_syncwrites)
876                     .field("f_asyncreads", &self.f_asyncreads)
877                     .field("f_asyncwrites", &self.f_asyncwrites)
878                     .field("f_fsidx", &self.f_fsidx)
879                     .field("f_fsid", &self.f_fsid)
880                     .field("f_namemax", &self.f_namemax)
881                     .field("f_owner", &self.f_owner)
882                     .field("f_spare", &self.f_spare)
883                     .field("f_fstypename", &self.f_fstypename)
884                     // FIXME: .field("f_mntonname", &self.f_mntonname)
885                     // FIXME: .field("f_mntfromname", &self.f_mntfromname)
886                     .finish()
887             }
888         }
889         impl ::hash::Hash for statvfs {
890             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
891                 self.f_flag.hash(state);
892                 self.f_bsize.hash(state);
893                 self.f_frsize.hash(state);
894                 self.f_iosize.hash(state);
895                 self.f_blocks.hash(state);
896                 self.f_bfree.hash(state);
897                 self.f_bavail.hash(state);
898                 self.f_bresvd.hash(state);
899                 self.f_files.hash(state);
900                 self.f_ffree.hash(state);
901                 self.f_favail.hash(state);
902                 self.f_fresvd.hash(state);
903                 self.f_syncreads.hash(state);
904                 self.f_syncwrites.hash(state);
905                 self.f_asyncreads.hash(state);
906                 self.f_asyncwrites.hash(state);
907                 self.f_fsidx.hash(state);
908                 self.f_fsid.hash(state);
909                 self.f_namemax.hash(state);
910                 self.f_owner.hash(state);
911                 self.f_spare.hash(state);
912                 self.f_fstypename.hash(state);
913                 self.f_mntonname.hash(state);
914                 self.f_mntfromname.hash(state);
915             }
916         }
917 
918         impl PartialEq for sockaddr_storage {
919             fn eq(&self, other: &sockaddr_storage) -> bool {
920                 self.ss_len == other.ss_len
921                     && self.ss_family == other.ss_family
922                     && self.__ss_pad1 == other.__ss_pad1
923                     && self.__ss_pad2 == other.__ss_pad2
924                     && self
925                     .__ss_pad3
926                     .iter()
927                     .zip(other.__ss_pad3.iter())
928                     .all(|(a,b)| a == b)
929             }
930         }
931         impl Eq for sockaddr_storage {}
932         impl ::fmt::Debug for sockaddr_storage {
933             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
934                 f.debug_struct("sockaddr_storage")
935                     .field("ss_len", &self.ss_len)
936                     .field("ss_family", &self.ss_family)
937                     .field("__ss_pad1", &self.__ss_pad1)
938                     .field("__ss_pad2", &self.__ss_pad2)
939                     // FIXME: .field("__ss_pad3", &self.__ss_pad3)
940                     .finish()
941             }
942         }
943         impl ::hash::Hash for sockaddr_storage {
944             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
945                 self.ss_len.hash(state);
946                 self.ss_family.hash(state);
947                 self.__ss_pad1.hash(state);
948                 self.__ss_pad2.hash(state);
949                 self.__ss_pad3.hash(state);
950             }
951         }
952 
953         impl PartialEq for sigevent {
954             fn eq(&self, other: &sigevent) -> bool {
955                 self.sigev_notify == other.sigev_notify
956                     && self.sigev_signo == other.sigev_signo
957                     && self.sigev_value == other.sigev_value
958                     && self.sigev_notify_attributes
959                         == other.sigev_notify_attributes
960             }
961         }
962         impl Eq for sigevent {}
963         impl ::fmt::Debug for sigevent {
964             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
965                 f.debug_struct("sigevent")
966                     .field("sigev_notify", &self.sigev_notify)
967                     .field("sigev_signo", &self.sigev_signo)
968                     .field("sigev_value", &self.sigev_value)
969                     .field("sigev_notify_attributes",
970                            &self.sigev_notify_attributes)
971                     .finish()
972             }
973         }
974         impl ::hash::Hash for sigevent {
975             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
976                 self.sigev_notify.hash(state);
977                 self.sigev_signo.hash(state);
978                 self.sigev_value.hash(state);
979                 self.sigev_notify_attributes.hash(state);
980             }
981         }
982     }
983 }
984 
985 pub const AT_FDCWD: ::c_int = -100;
986 pub const AT_EACCESS: ::c_int = 0x100;
987 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200;
988 pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
989 pub const AT_REMOVEDIR: ::c_int = 0x800;
990 
991 pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
992 pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
993 
994 pub const LC_COLLATE_MASK: ::c_int = 1 << ::LC_COLLATE;
995 pub const LC_CTYPE_MASK: ::c_int = 1 << ::LC_CTYPE;
996 pub const LC_MONETARY_MASK: ::c_int = 1 << ::LC_MONETARY;
997 pub const LC_NUMERIC_MASK: ::c_int = 1 << ::LC_NUMERIC;
998 pub const LC_TIME_MASK: ::c_int = 1 << ::LC_TIME;
999 pub const LC_MESSAGES_MASK: ::c_int = 1 << ::LC_MESSAGES;
1000 pub const LC_ALL_MASK: ::c_int = !0;
1001 
1002 pub const ERA: ::nl_item = 52;
1003 pub const ERA_D_FMT: ::nl_item = 53;
1004 pub const ERA_D_T_FMT: ::nl_item = 54;
1005 pub const ERA_T_FMT: ::nl_item = 55;
1006 pub const ALT_DIGITS: ::nl_item = 56;
1007 
1008 pub const O_CLOEXEC: ::c_int = 0x400000;
1009 pub const O_ALT_IO: ::c_int = 0x40000;
1010 pub const O_NOSIGPIPE: ::c_int = 0x1000000;
1011 pub const O_SEARCH: ::c_int = 0x800000;
1012 pub const O_DIRECTORY: ::c_int = 0x200000;
1013 pub const O_DIRECT: ::c_int = 0x00080000;
1014 pub const O_RSYNC: ::c_int = 0x00020000;
1015 
1016 pub const MS_SYNC: ::c_int = 0x4;
1017 pub const MS_INVALIDATE: ::c_int = 0x2;
1018 
1019 // Here because they are not present on OpenBSD
1020 // (https://github.com/openbsd/src/blob/master/sys/sys/resource.h)
1021 pub const RLIMIT_SBSIZE: ::c_int = 9;
1022 pub const RLIMIT_AS: ::c_int = 10;
1023 pub const RLIMIT_NTHR: ::c_int = 11;
1024 
1025 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
1026 pub const RLIM_NLIMITS: ::c_int = 12;
1027 
1028 pub const EIDRM: ::c_int = 82;
1029 pub const ENOMSG: ::c_int = 83;
1030 pub const EOVERFLOW: ::c_int = 84;
1031 pub const EILSEQ: ::c_int = 85;
1032 pub const ENOTSUP: ::c_int = 86;
1033 pub const ECANCELED: ::c_int = 87;
1034 pub const EBADMSG: ::c_int = 88;
1035 pub const ENODATA: ::c_int = 89;
1036 pub const ENOSR: ::c_int = 90;
1037 pub const ENOSTR: ::c_int = 91;
1038 pub const ETIME: ::c_int = 92;
1039 pub const ENOATTR: ::c_int = 93;
1040 pub const EMULTIHOP: ::c_int = 94;
1041 pub const ENOLINK: ::c_int = 95;
1042 pub const EPROTO: ::c_int = 96;
1043 pub const ELAST: ::c_int = 96;
1044 
1045 pub const F_DUPFD_CLOEXEC: ::c_int = 12;
1046 pub const F_CLOSEM: ::c_int = 10;
1047 pub const F_GETNOSIGPIPE: ::c_int = 13;
1048 pub const F_SETNOSIGPIPE: ::c_int = 14;
1049 pub const F_MAXFD: ::c_int = 11;
1050 
1051 pub const IP_RECVDSTADDR: ::c_int = 7;
1052 pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;
1053 pub const IP_RECVIF: ::c_int = 20;
1054 pub const IP_PKTINFO: ::c_int = 25;
1055 pub const IP_RECVPKTINFO: ::c_int = 26;
1056 pub const IPV6_JOIN_GROUP: ::c_int = 12;
1057 pub const IPV6_LEAVE_GROUP: ::c_int = 13;
1058 
1059 pub const TCP_KEEPIDLE: ::c_int = 3;
1060 pub const TCP_KEEPINTVL: ::c_int = 5;
1061 pub const TCP_KEEPCNT: ::c_int = 6;
1062 pub const TCP_KEEPINIT: ::c_int = 7;
1063 pub const TCP_INFO: ::c_int = 9;
1064 pub const TCP_MD5SIG: ::c_int = 0x10;
1065 pub const TCP_CONGCTL: ::c_int = 0x20;
1066 
1067 pub const SOCK_CONN_DGRAM: ::c_int = 6;
1068 pub const SOCK_DCCP: ::c_int = SOCK_CONN_DGRAM;
1069 pub const SOCK_NOSIGPIPE: ::c_int = 0x40000000;
1070 pub const SOCK_FLAGS_MASK: ::c_int = 0xf0000000;
1071 
1072 pub const SO_SNDTIMEO: ::c_int = 0x100b;
1073 pub const SO_RCVTIMEO: ::c_int = 0x100c;
1074 pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
1075 pub const SO_TIMESTAMP: ::c_int = 0x2000;
1076 pub const SO_OVERFLOWED: ::c_int = 0x1009;
1077 pub const SO_NOHEADER: ::c_int = 0x100a;
1078 
1079 // http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/un.h?annotate
1080 pub const LOCAL_OCREDS: ::c_int = 0x0001; // pass credentials to receiver
1081 pub const LOCAL_CONNWAIT: ::c_int = 0x0002; // connects block until accepted
1082 pub const LOCAL_PEEREID: ::c_int = 0x0003; // get peer identification
1083 pub const LOCAL_CREDS: ::c_int = 0x0004; // pass credentials to receiver
1084 
1085 // https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373
1086 pub const IFF_UP: ::c_int = 0x0001; // interface is up
1087 pub const IFF_BROADCAST: ::c_int = 0x0002; // broadcast address valid
1088 pub const IFF_DEBUG: ::c_int = 0x0004; // turn on debugging
1089 pub const IFF_LOOPBACK: ::c_int = 0x0008; // is a loopback net
1090 pub const IFF_POINTOPOINT: ::c_int = 0x0010; // interface is point-to-point link
1091 pub const IFF_NOTRAILERS: ::c_int = 0x0020; // avoid use of trailers
1092 pub const IFF_RUNNING: ::c_int = 0x0040; // resources allocated
1093 pub const IFF_NOARP: ::c_int = 0x0080; // no address resolution protocol
1094 pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets
1095 pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets
1096 pub const IFF_OACTIVE: ::c_int = 0x0400; // transmission in progress
1097 pub const IFF_SIMPLEX: ::c_int = 0x0800; // can't hear own transmissions
1098 pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
1099 pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
1100 pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
1101 pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
1102 
1103 // sys/netinet/in.h
1104 // Protocols (RFC 1700)
1105 // NOTE: These are in addition to the constants defined in src/unix/mod.rs
1106 
1107 // IPPROTO_IP defined in src/unix/mod.rs
1108 /// Hop-by-hop option header
1109 pub const IPPROTO_HOPOPTS: ::c_int = 0;
1110 // IPPROTO_ICMP defined in src/unix/mod.rs
1111 /// group mgmt protocol
1112 pub const IPPROTO_IGMP: ::c_int = 2;
1113 /// gateway^2 (deprecated)
1114 pub const IPPROTO_GGP: ::c_int = 3;
1115 /// for compatibility
1116 pub const IPPROTO_IPIP: ::c_int = 4;
1117 // IPPROTO_TCP defined in src/unix/mod.rs
1118 /// exterior gateway protocol
1119 pub const IPPROTO_EGP: ::c_int = 8;
1120 /// pup
1121 pub const IPPROTO_PUP: ::c_int = 12;
1122 // IPPROTO_UDP defined in src/unix/mod.rs
1123 /// xns idp
1124 pub const IPPROTO_IDP: ::c_int = 22;
1125 /// tp-4 w/ class negotiation
1126 pub const IPPROTO_TP: ::c_int = 29;
1127 /// DCCP
1128 pub const IPPROTO_DCCP: ::c_int = 33;
1129 // IPPROTO_IPV6 defined in src/unix/mod.rs
1130 /// IP6 routing header
1131 pub const IPPROTO_ROUTING: ::c_int = 43;
1132 /// IP6 fragmentation header
1133 pub const IPPROTO_FRAGMENT: ::c_int = 44;
1134 /// resource reservation
1135 pub const IPPROTO_RSVP: ::c_int = 46;
1136 /// General Routing Encap.
1137 pub const IPPROTO_GRE: ::c_int = 47;
1138 /// IP6 Encap Sec. Payload
1139 pub const IPPROTO_ESP: ::c_int = 50;
1140 /// IP6 Auth Header
1141 pub const IPPROTO_AH: ::c_int = 51;
1142 /// IP Mobility RFC 2004
1143 pub const IPPROTO_MOBILE: ::c_int = 55;
1144 /// IPv6 ICMP
1145 pub const IPPROTO_IPV6_ICMP: ::c_int = 58;
1146 // IPPROTO_ICMPV6 defined in src/unix/mod.rs
1147 /// IP6 no next header
1148 pub const IPPROTO_NONE: ::c_int = 59;
1149 /// IP6 destination option
1150 pub const IPPROTO_DSTOPTS: ::c_int = 60;
1151 /// ISO cnlp
1152 pub const IPPROTO_EON: ::c_int = 80;
1153 /// Ethernet-in-IP
1154 pub const IPPROTO_ETHERIP: ::c_int = 97;
1155 /// encapsulation header
1156 pub const IPPROTO_ENCAP: ::c_int = 98;
1157 /// Protocol indep. multicast
1158 pub const IPPROTO_PIM: ::c_int = 103;
1159 /// IP Payload Comp. Protocol
1160 pub const IPPROTO_IPCOMP: ::c_int = 108;
1161 /// VRRP RFC 2338
1162 pub const IPPROTO_VRRP: ::c_int = 112;
1163 /// Common Address Resolution Protocol
1164 pub const IPPROTO_CARP: ::c_int = 112;
1165 /// L2TPv3
1166 // TEMP: Disabled for now; this constant was added to NetBSD on 2017-02-16,
1167 // but isn't yet supported by the NetBSD rumprun kernel image used for
1168 // libc testing.
1169 //pub const IPPROTO_L2TP: ::c_int = 115;
1170 /// SCTP
1171 pub const IPPROTO_SCTP: ::c_int = 132;
1172 /// PFSYNC
1173 pub const IPPROTO_PFSYNC: ::c_int = 240;
1174 pub const IPPROTO_MAX: ::c_int = 256;
1175 
1176 /// last return value of *_input(), meaning "all job for this pkt is done".
1177 pub const IPPROTO_DONE: ::c_int = 257;
1178 
1179 /// sysctl placeholder for (FAST_)IPSEC
1180 pub const CTL_IPPROTO_IPSEC: ::c_int = 258;
1181 
1182 pub const AF_OROUTE: ::c_int = 17;
1183 pub const AF_ARP: ::c_int = 28;
1184 pub const pseudo_AF_KEY: ::c_int = 29;
1185 pub const pseudo_AF_HDRCMPLT: ::c_int = 30;
1186 pub const AF_BLUETOOTH: ::c_int = 31;
1187 pub const AF_IEEE80211: ::c_int = 32;
1188 pub const AF_MPLS: ::c_int = 33;
1189 pub const AF_ROUTE: ::c_int = 34;
1190 pub const NET_RT_DUMP: ::c_int = 1;
1191 pub const NET_RT_FLAGS: ::c_int = 2;
1192 pub const NET_RT_OOOIFLIST: ::c_int = 3;
1193 pub const NET_RT_OOIFLIST: ::c_int = 4;
1194 pub const NET_RT_OIFLIST: ::c_int = 5;
1195 pub const NET_RT_IFLIST: ::c_int = 6;
1196 pub const NET_RT_MAXID: ::c_int = 7;
1197 
1198 pub const PF_OROUTE: ::c_int = AF_OROUTE;
1199 pub const PF_ARP: ::c_int = AF_ARP;
1200 pub const PF_KEY: ::c_int = pseudo_AF_KEY;
1201 pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
1202 pub const PF_MPLS: ::c_int = AF_MPLS;
1203 pub const PF_ROUTE: ::c_int = AF_ROUTE;
1204 
1205 pub const MSG_NBIO: ::c_int = 0x1000;
1206 pub const MSG_WAITFORONE: ::c_int = 0x2000;
1207 pub const MSG_NOTIFICATION: ::c_int = 0x4000;
1208 
1209 pub const SCM_TIMESTAMP: ::c_int = 0x08;
1210 pub const SCM_CREDS: ::c_int = 0x10;
1211 
1212 pub const O_DSYNC: ::c_int = 0x10000;
1213 
1214 pub const MAP_RENAME: ::c_int = 0x20;
1215 pub const MAP_NORESERVE: ::c_int = 0x40;
1216 pub const MAP_HASSEMAPHORE: ::c_int = 0x200;
1217 pub const MAP_WIRED: ::c_int = 0x800;
1218 // mremap flag
1219 pub const MAP_REMAPDUP: ::c_int = 0x004;
1220 
1221 pub const DCCP_TYPE_REQUEST: ::c_int = 0;
1222 pub const DCCP_TYPE_RESPONSE: ::c_int = 1;
1223 pub const DCCP_TYPE_DATA: ::c_int = 2;
1224 pub const DCCP_TYPE_ACK: ::c_int = 3;
1225 pub const DCCP_TYPE_DATAACK: ::c_int = 4;
1226 pub const DCCP_TYPE_CLOSEREQ: ::c_int = 5;
1227 pub const DCCP_TYPE_CLOSE: ::c_int = 6;
1228 pub const DCCP_TYPE_RESET: ::c_int = 7;
1229 pub const DCCP_TYPE_MOVE: ::c_int = 8;
1230 
1231 pub const DCCP_FEATURE_CC: ::c_int = 1;
1232 pub const DCCP_FEATURE_ECN: ::c_int = 2;
1233 pub const DCCP_FEATURE_ACKRATIO: ::c_int = 3;
1234 pub const DCCP_FEATURE_ACKVECTOR: ::c_int = 4;
1235 pub const DCCP_FEATURE_MOBILITY: ::c_int = 5;
1236 pub const DCCP_FEATURE_LOSSWINDOW: ::c_int = 6;
1237 pub const DCCP_FEATURE_CONN_NONCE: ::c_int = 8;
1238 pub const DCCP_FEATURE_IDENTREG: ::c_int = 7;
1239 
1240 pub const DCCP_OPT_PADDING: ::c_int = 0;
1241 pub const DCCP_OPT_DATA_DISCARD: ::c_int = 1;
1242 pub const DCCP_OPT_SLOW_RECV: ::c_int = 2;
1243 pub const DCCP_OPT_BUF_CLOSED: ::c_int = 3;
1244 pub const DCCP_OPT_CHANGE_L: ::c_int = 32;
1245 pub const DCCP_OPT_CONFIRM_L: ::c_int = 33;
1246 pub const DCCP_OPT_CHANGE_R: ::c_int = 34;
1247 pub const DCCP_OPT_CONFIRM_R: ::c_int = 35;
1248 pub const DCCP_OPT_INIT_COOKIE: ::c_int = 36;
1249 pub const DCCP_OPT_NDP_COUNT: ::c_int = 37;
1250 pub const DCCP_OPT_ACK_VECTOR0: ::c_int = 38;
1251 pub const DCCP_OPT_ACK_VECTOR1: ::c_int = 39;
1252 pub const DCCP_OPT_RECV_BUF_DROPS: ::c_int = 40;
1253 pub const DCCP_OPT_TIMESTAMP: ::c_int = 41;
1254 pub const DCCP_OPT_TIMESTAMP_ECHO: ::c_int = 42;
1255 pub const DCCP_OPT_ELAPSEDTIME: ::c_int = 43;
1256 pub const DCCP_OPT_DATACHECKSUM: ::c_int = 44;
1257 
1258 pub const DCCP_REASON_UNSPEC: ::c_int = 0;
1259 pub const DCCP_REASON_CLOSED: ::c_int = 1;
1260 pub const DCCP_REASON_INVALID: ::c_int = 2;
1261 pub const DCCP_REASON_OPTION_ERR: ::c_int = 3;
1262 pub const DCCP_REASON_FEA_ERR: ::c_int = 4;
1263 pub const DCCP_REASON_CONN_REF: ::c_int = 5;
1264 pub const DCCP_REASON_BAD_SNAME: ::c_int = 6;
1265 pub const DCCP_REASON_BAD_COOKIE: ::c_int = 7;
1266 pub const DCCP_REASON_INV_MOVE: ::c_int = 8;
1267 pub const DCCP_REASON_UNANSW_CH: ::c_int = 10;
1268 pub const DCCP_REASON_FRUITLESS_NEG: ::c_int = 11;
1269 
1270 pub const DCCP_CCID: ::c_int = 1;
1271 pub const DCCP_CSLEN: ::c_int = 2;
1272 pub const DCCP_MAXSEG: ::c_int = 4;
1273 pub const DCCP_SERVICE: ::c_int = 8;
1274 
1275 pub const DCCP_NDP_LIMIT: ::c_int = 16;
1276 pub const DCCP_SEQ_NUM_LIMIT: ::c_int = 16777216;
1277 pub const DCCP_MAX_OPTIONS: ::c_int = 32;
1278 pub const DCCP_MAX_PKTS: ::c_int = 100;
1279 
1280 pub const _PC_LINK_MAX: ::c_int = 1;
1281 pub const _PC_MAX_CANON: ::c_int = 2;
1282 pub const _PC_MAX_INPUT: ::c_int = 3;
1283 pub const _PC_NAME_MAX: ::c_int = 4;
1284 pub const _PC_PATH_MAX: ::c_int = 5;
1285 pub const _PC_PIPE_BUF: ::c_int = 6;
1286 pub const _PC_CHOWN_RESTRICTED: ::c_int = 7;
1287 pub const _PC_NO_TRUNC: ::c_int = 8;
1288 pub const _PC_VDISABLE: ::c_int = 9;
1289 pub const _PC_SYNC_IO: ::c_int = 10;
1290 pub const _PC_FILESIZEBITS: ::c_int = 11;
1291 pub const _PC_SYMLINK_MAX: ::c_int = 12;
1292 pub const _PC_2_SYMLINKS: ::c_int = 13;
1293 pub const _PC_ACL_EXTENDED: ::c_int = 14;
1294 pub const _PC_MIN_HOLE_SIZE: ::c_int = 15;
1295 
1296 pub const _SC_SYNCHRONIZED_IO: ::c_int = 31;
1297 pub const _SC_IOV_MAX: ::c_int = 32;
1298 pub const _SC_MAPPED_FILES: ::c_int = 33;
1299 pub const _SC_MEMLOCK: ::c_int = 34;
1300 pub const _SC_MEMLOCK_RANGE: ::c_int = 35;
1301 pub const _SC_MEMORY_PROTECTION: ::c_int = 36;
1302 pub const _SC_LOGIN_NAME_MAX: ::c_int = 37;
1303 pub const _SC_MONOTONIC_CLOCK: ::c_int = 38;
1304 pub const _SC_CLK_TCK: ::c_int = 39;
1305 pub const _SC_ATEXIT_MAX: ::c_int = 40;
1306 pub const _SC_THREADS: ::c_int = 41;
1307 pub const _SC_SEMAPHORES: ::c_int = 42;
1308 pub const _SC_BARRIERS: ::c_int = 43;
1309 pub const _SC_TIMERS: ::c_int = 44;
1310 pub const _SC_SPIN_LOCKS: ::c_int = 45;
1311 pub const _SC_READER_WRITER_LOCKS: ::c_int = 46;
1312 pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 47;
1313 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 48;
1314 pub const _SC_CLOCK_SELECTION: ::c_int = 49;
1315 pub const _SC_ASYNCHRONOUS_IO: ::c_int = 50;
1316 pub const _SC_AIO_LISTIO_MAX: ::c_int = 51;
1317 pub const _SC_AIO_MAX: ::c_int = 52;
1318 pub const _SC_MESSAGE_PASSING: ::c_int = 53;
1319 pub const _SC_MQ_OPEN_MAX: ::c_int = 54;
1320 pub const _SC_MQ_PRIO_MAX: ::c_int = 55;
1321 pub const _SC_PRIORITY_SCHEDULING: ::c_int = 56;
1322 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 57;
1323 pub const _SC_THREAD_KEYS_MAX: ::c_int = 58;
1324 pub const _SC_THREAD_STACK_MIN: ::c_int = 59;
1325 pub const _SC_THREAD_THREADS_MAX: ::c_int = 60;
1326 pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 61;
1327 pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 62;
1328 pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 63;
1329 pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 64;
1330 pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 65;
1331 pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 66;
1332 pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 67;
1333 pub const _SC_TTY_NAME_MAX: ::c_int = 68;
1334 pub const _SC_HOST_NAME_MAX: ::c_int = 69;
1335 pub const _SC_PASS_MAX: ::c_int = 70;
1336 pub const _SC_REGEXP: ::c_int = 71;
1337 pub const _SC_SHELL: ::c_int = 72;
1338 pub const _SC_SYMLOOP_MAX: ::c_int = 73;
1339 pub const _SC_V6_ILP32_OFF32: ::c_int = 74;
1340 pub const _SC_V6_ILP32_OFFBIG: ::c_int = 75;
1341 pub const _SC_V6_LP64_OFF64: ::c_int = 76;
1342 pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 77;
1343 pub const _SC_2_PBS: ::c_int = 80;
1344 pub const _SC_2_PBS_ACCOUNTING: ::c_int = 81;
1345 pub const _SC_2_PBS_CHECKPOINT: ::c_int = 82;
1346 pub const _SC_2_PBS_LOCATE: ::c_int = 83;
1347 pub const _SC_2_PBS_MESSAGE: ::c_int = 84;
1348 pub const _SC_2_PBS_TRACK: ::c_int = 85;
1349 pub const _SC_SPAWN: ::c_int = 86;
1350 pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 87;
1351 pub const _SC_TIMER_MAX: ::c_int = 88;
1352 pub const _SC_SEM_NSEMS_MAX: ::c_int = 89;
1353 pub const _SC_CPUTIME: ::c_int = 90;
1354 pub const _SC_THREAD_CPUTIME: ::c_int = 91;
1355 pub const _SC_DELAYTIMER_MAX: ::c_int = 92;
1356 // These two variables will be supported in NetBSD 8.0
1357 // pub const _SC_SIGQUEUE_MAX : ::c_int = 93;
1358 // pub const _SC_REALTIME_SIGNALS : ::c_int = 94;
1359 pub const _SC_PHYS_PAGES: ::c_int = 121;
1360 pub const _SC_NPROCESSORS_CONF: ::c_int = 1001;
1361 pub const _SC_NPROCESSORS_ONLN: ::c_int = 1002;
1362 pub const _SC_SCHED_RT_TS: ::c_int = 2001;
1363 pub const _SC_SCHED_PRI_MIN: ::c_int = 2002;
1364 pub const _SC_SCHED_PRI_MAX: ::c_int = 2003;
1365 
1366 pub const FD_SETSIZE: usize = 0x100;
1367 
1368 pub const ST_NOSUID: ::c_ulong = 8;
1369 
1370 pub const BIOCGRSIG: ::c_ulong = 0x40044272;
1371 pub const BIOCSRSIG: ::c_ulong = 0x80044273;
1372 pub const BIOCSDLT: ::c_ulong = 0x80044278;
1373 pub const BIOCGSEESENT: ::c_ulong = 0x40044276;
1374 pub const BIOCSSEESENT: ::c_ulong = 0x80044277;
1375 
1376 //<sys/timex.h>
1377 pub const NTP_API: ::c_int = 4;
1378 pub const MAXPHASE: ::c_long = 500000000;
1379 pub const MAXFREQ: ::c_long = 500000;
1380 pub const MINSEC: ::c_int = 256;
1381 pub const MAXSEC: ::c_int = 2048;
1382 pub const NANOSECOND: ::c_long = 1000000000;
1383 pub const SCALE_PPM: ::c_int = 65;
1384 pub const MAXTC: ::c_int = 10;
1385 pub const MOD_OFFSET: ::c_uint = 0x0001;
1386 pub const MOD_FREQUENCY: ::c_uint = 0x0002;
1387 pub const MOD_MAXERROR: ::c_uint = 0x0004;
1388 pub const MOD_ESTERROR: ::c_uint = 0x0008;
1389 pub const MOD_STATUS: ::c_uint = 0x0010;
1390 pub const MOD_TIMECONST: ::c_uint = 0x0020;
1391 pub const MOD_PPSMAX: ::c_uint = 0x0040;
1392 pub const MOD_TAI: ::c_uint = 0x0080;
1393 pub const MOD_MICRO: ::c_uint = 0x1000;
1394 pub const MOD_NANO: ::c_uint = 0x2000;
1395 pub const MOD_CLKB: ::c_uint = 0x4000;
1396 pub const MOD_CLKA: ::c_uint = 0x8000;
1397 pub const STA_PLL: ::c_int = 0x0001;
1398 pub const STA_PPSFREQ: ::c_int = 0x0002;
1399 pub const STA_PPSTIME: ::c_int = 0x0004;
1400 pub const STA_FLL: ::c_int = 0x0008;
1401 pub const STA_INS: ::c_int = 0x0010;
1402 pub const STA_DEL: ::c_int = 0x0020;
1403 pub const STA_UNSYNC: ::c_int = 0x0040;
1404 pub const STA_FREQHOLD: ::c_int = 0x0080;
1405 pub const STA_PPSSIGNAL: ::c_int = 0x0100;
1406 pub const STA_PPSJITTER: ::c_int = 0x0200;
1407 pub const STA_PPSWANDER: ::c_int = 0x0400;
1408 pub const STA_PPSERROR: ::c_int = 0x0800;
1409 pub const STA_CLOCKERR: ::c_int = 0x1000;
1410 pub const STA_NANO: ::c_int = 0x2000;
1411 pub const STA_MODE: ::c_int = 0x4000;
1412 pub const STA_CLK: ::c_int = 0x8000;
1413 pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
1414     | STA_PPSJITTER
1415     | STA_PPSWANDER
1416     | STA_PPSERROR
1417     | STA_CLOCKERR
1418     | STA_NANO
1419     | STA_MODE
1420     | STA_CLK;
1421 pub const TIME_OK: ::c_int = 0;
1422 pub const TIME_INS: ::c_int = 1;
1423 pub const TIME_DEL: ::c_int = 2;
1424 pub const TIME_OOP: ::c_int = 3;
1425 pub const TIME_WAIT: ::c_int = 4;
1426 pub const TIME_ERROR: ::c_int = 5;
1427 
1428 cfg_if! {
1429     if #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
1430                  target_arch = "x86", target_arch = "x86_64"))] {
1431         pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t
1432           = pthread_mutex_t {
1433             ptm_magic: 0x33330003,
1434             ptm_errorcheck: 0,
1435             ptm_pad1: [0; 3],
1436             ptm_unused: 0,
1437             ptm_pad2: [0; 3],
1438             ptm_waiters: 0 as *mut _,
1439             ptm_owner: 0,
1440             ptm_recursed: 0,
1441             ptm_spare2: 0 as *mut _,
1442         };
1443     } else {
1444         pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t
1445           = pthread_mutex_t {
1446             ptm_magic: 0x33330003,
1447             ptm_errorcheck: 0,
1448             ptm_unused: 0,
1449             ptm_waiters: 0 as *mut _,
1450             ptm_owner: 0,
1451             ptm_recursed: 0,
1452             ptm_spare2: 0 as *mut _,
1453         };
1454     }
1455 }
1456 
1457 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1458     ptc_magic: 0x55550005,
1459     ptc_lock: 0,
1460     ptc_waiters_first: 0 as *mut _,
1461     ptc_waiters_last: 0 as *mut _,
1462     ptc_mutex: 0 as *mut _,
1463     ptc_private: 0 as *mut _,
1464 };
1465 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1466     ptr_magic: 0x99990009,
1467     ptr_interlock: 0,
1468     ptr_rblocked_first: 0 as *mut _,
1469     ptr_rblocked_last: 0 as *mut _,
1470     ptr_wblocked_first: 0 as *mut _,
1471     ptr_wblocked_last: 0 as *mut _,
1472     ptr_nreaders: 0,
1473     ptr_owner: 0,
1474     ptr_private: 0 as *mut _,
1475 };
1476 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
1477 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
1478 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
1479 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
1480 
1481 pub const EVFILT_AIO: u32 = 2;
1482 pub const EVFILT_PROC: u32 = 4;
1483 pub const EVFILT_READ: u32 = 0;
1484 pub const EVFILT_SIGNAL: u32 = 5;
1485 pub const EVFILT_TIMER: u32 = 6;
1486 pub const EVFILT_VNODE: u32 = 3;
1487 pub const EVFILT_WRITE: u32 = 1;
1488 
1489 pub const EV_ADD: u32 = 0x1;
1490 pub const EV_DELETE: u32 = 0x2;
1491 pub const EV_ENABLE: u32 = 0x4;
1492 pub const EV_DISABLE: u32 = 0x8;
1493 pub const EV_ONESHOT: u32 = 0x10;
1494 pub const EV_CLEAR: u32 = 0x20;
1495 pub const EV_RECEIPT: u32 = 0x40;
1496 pub const EV_DISPATCH: u32 = 0x80;
1497 pub const EV_FLAG1: u32 = 0x2000;
1498 pub const EV_ERROR: u32 = 0x4000;
1499 pub const EV_EOF: u32 = 0x8000;
1500 pub const EV_SYSFLAGS: u32 = 0xf000;
1501 
1502 pub const NOTE_LOWAT: u32 = 0x00000001;
1503 pub const NOTE_DELETE: u32 = 0x00000001;
1504 pub const NOTE_WRITE: u32 = 0x00000002;
1505 pub const NOTE_EXTEND: u32 = 0x00000004;
1506 pub const NOTE_ATTRIB: u32 = 0x00000008;
1507 pub const NOTE_LINK: u32 = 0x00000010;
1508 pub const NOTE_RENAME: u32 = 0x00000020;
1509 pub const NOTE_REVOKE: u32 = 0x00000040;
1510 pub const NOTE_EXIT: u32 = 0x80000000;
1511 pub const NOTE_FORK: u32 = 0x40000000;
1512 pub const NOTE_EXEC: u32 = 0x20000000;
1513 pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1514 pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1515 pub const NOTE_TRACK: u32 = 0x00000001;
1516 pub const NOTE_TRACKERR: u32 = 0x00000002;
1517 pub const NOTE_CHILD: u32 = 0x00000004;
1518 
1519 pub const TMP_MAX: ::c_uint = 308915776;
1520 
1521 pub const NI_MAXHOST: ::socklen_t = 1025;
1522 pub const NI_MAXSERV: ::socklen_t = 32;
1523 
1524 pub const NI_NOFQDN: ::c_int = 0x00000001;
1525 pub const NI_NUMERICHOST: ::c_int = 0x000000002;
1526 pub const NI_NAMEREQD: ::c_int = 0x000000004;
1527 pub const NI_NUMERICSERV: ::c_int = 0x000000008;
1528 pub const NI_DGRAM: ::c_int = 0x00000010;
1529 pub const NI_WITHSCOPEID: ::c_int = 0x00000020;
1530 pub const NI_NUMERICSCOPE: ::c_int = 0x00000040;
1531 
1532 pub const RTLD_NOLOAD: ::c_int = 0x2000;
1533 pub const RTLD_LOCAL: ::c_int = 0x200;
1534 
1535 pub const CTL_MAXNAME: ::c_int = 12;
1536 pub const SYSCTL_NAMELEN: ::c_int = 32;
1537 pub const SYSCTL_DEFSIZE: ::c_int = 8;
1538 pub const CTLTYPE_NODE: ::c_int = 1;
1539 pub const CTLTYPE_INT: ::c_int = 2;
1540 pub const CTLTYPE_STRING: ::c_int = 3;
1541 pub const CTLTYPE_QUAD: ::c_int = 4;
1542 pub const CTLTYPE_STRUCT: ::c_int = 5;
1543 pub const CTLTYPE_BOOL: ::c_int = 6;
1544 pub const CTLFLAG_READONLY: ::c_int = 0x00000000;
1545 pub const CTLFLAG_READWRITE: ::c_int = 0x00000070;
1546 pub const CTLFLAG_ANYWRITE: ::c_int = 0x00000080;
1547 pub const CTLFLAG_PRIVATE: ::c_int = 0x00000100;
1548 pub const CTLFLAG_PERMANENT: ::c_int = 0x00000200;
1549 pub const CTLFLAG_OWNDATA: ::c_int = 0x00000400;
1550 pub const CTLFLAG_IMMEDIATE: ::c_int = 0x00000800;
1551 pub const CTLFLAG_HEX: ::c_int = 0x00001000;
1552 pub const CTLFLAG_ROOT: ::c_int = 0x00002000;
1553 pub const CTLFLAG_ANYNUMBER: ::c_int = 0x00004000;
1554 pub const CTLFLAG_HIDDEN: ::c_int = 0x00008000;
1555 pub const CTLFLAG_ALIAS: ::c_int = 0x00010000;
1556 pub const CTLFLAG_MMAP: ::c_int = 0x00020000;
1557 pub const CTLFLAG_OWNDESC: ::c_int = 0x00040000;
1558 pub const CTLFLAG_UNSIGNED: ::c_int = 0x00080000;
1559 pub const SYSCTL_VERS_MASK: ::c_int = 0xff000000;
1560 pub const SYSCTL_VERS_0: ::c_int = 0x00000000;
1561 pub const SYSCTL_VERS_1: ::c_int = 0x01000000;
1562 pub const SYSCTL_VERSION: ::c_int = SYSCTL_VERS_1;
1563 pub const CTL_EOL: ::c_int = -1;
1564 pub const CTL_QUERY: ::c_int = -2;
1565 pub const CTL_CREATE: ::c_int = -3;
1566 pub const CTL_CREATESYM: ::c_int = -4;
1567 pub const CTL_DESTROY: ::c_int = -5;
1568 pub const CTL_MMAP: ::c_int = -6;
1569 pub const CTL_DESCRIBE: ::c_int = -7;
1570 pub const CTL_UNSPEC: ::c_int = 0;
1571 pub const CTL_KERN: ::c_int = 1;
1572 pub const CTL_VM: ::c_int = 2;
1573 pub const CTL_VFS: ::c_int = 3;
1574 pub const CTL_NET: ::c_int = 4;
1575 pub const CTL_DEBUG: ::c_int = 5;
1576 pub const CTL_HW: ::c_int = 6;
1577 pub const CTL_MACHDEP: ::c_int = 7;
1578 pub const CTL_USER: ::c_int = 8;
1579 pub const CTL_DDB: ::c_int = 9;
1580 pub const CTL_PROC: ::c_int = 10;
1581 pub const CTL_VENDOR: ::c_int = 11;
1582 pub const CTL_EMUL: ::c_int = 12;
1583 pub const CTL_SECURITY: ::c_int = 13;
1584 pub const CTL_MAXID: ::c_int = 14;
1585 pub const KERN_OSTYPE: ::c_int = 1;
1586 pub const KERN_OSRELEASE: ::c_int = 2;
1587 pub const KERN_OSREV: ::c_int = 3;
1588 pub const KERN_VERSION: ::c_int = 4;
1589 pub const KERN_MAXVNODES: ::c_int = 5;
1590 pub const KERN_MAXPROC: ::c_int = 6;
1591 pub const KERN_MAXFILES: ::c_int = 7;
1592 pub const KERN_ARGMAX: ::c_int = 8;
1593 pub const KERN_SECURELVL: ::c_int = 9;
1594 pub const KERN_HOSTNAME: ::c_int = 10;
1595 pub const KERN_HOSTID: ::c_int = 11;
1596 pub const KERN_CLOCKRATE: ::c_int = 12;
1597 pub const KERN_VNODE: ::c_int = 13;
1598 pub const KERN_PROC: ::c_int = 14;
1599 pub const KERN_FILE: ::c_int = 15;
1600 pub const KERN_PROF: ::c_int = 16;
1601 pub const KERN_POSIX1: ::c_int = 17;
1602 pub const KERN_NGROUPS: ::c_int = 18;
1603 pub const KERN_JOB_CONTROL: ::c_int = 19;
1604 pub const KERN_SAVED_IDS: ::c_int = 20;
1605 pub const KERN_OBOOTTIME: ::c_int = 21;
1606 pub const KERN_DOMAINNAME: ::c_int = 22;
1607 pub const KERN_MAXPARTITIONS: ::c_int = 23;
1608 pub const KERN_RAWPARTITION: ::c_int = 24;
1609 pub const KERN_NTPTIME: ::c_int = 25;
1610 pub const KERN_TIMEX: ::c_int = 26;
1611 pub const KERN_AUTONICETIME: ::c_int = 27;
1612 pub const KERN_AUTONICEVAL: ::c_int = 28;
1613 pub const KERN_RTC_OFFSET: ::c_int = 29;
1614 pub const KERN_ROOT_DEVICE: ::c_int = 30;
1615 pub const KERN_MSGBUFSIZE: ::c_int = 31;
1616 pub const KERN_FSYNC: ::c_int = 32;
1617 pub const KERN_OLDSYSVMSG: ::c_int = 33;
1618 pub const KERN_OLDSYSVSEM: ::c_int = 34;
1619 pub const KERN_OLDSYSVSHM: ::c_int = 35;
1620 pub const KERN_OLDSHORTCORENAME: ::c_int = 36;
1621 pub const KERN_SYNCHRONIZED_IO: ::c_int = 37;
1622 pub const KERN_IOV_MAX: ::c_int = 38;
1623 pub const KERN_MBUF: ::c_int = 39;
1624 pub const KERN_MAPPED_FILES: ::c_int = 40;
1625 pub const KERN_MEMLOCK: ::c_int = 41;
1626 pub const KERN_MEMLOCK_RANGE: ::c_int = 42;
1627 pub const KERN_MEMORY_PROTECTION: ::c_int = 43;
1628 pub const KERN_LOGIN_NAME_MAX: ::c_int = 44;
1629 pub const KERN_DEFCORENAME: ::c_int = 45;
1630 pub const KERN_LOGSIGEXIT: ::c_int = 46;
1631 pub const KERN_PROC2: ::c_int = 47;
1632 pub const KERN_PROC_ARGS: ::c_int = 48;
1633 pub const KERN_FSCALE: ::c_int = 49;
1634 pub const KERN_CCPU: ::c_int = 50;
1635 pub const KERN_CP_TIME: ::c_int = 51;
1636 pub const KERN_OLDSYSVIPC_INFO: ::c_int = 52;
1637 pub const KERN_MSGBUF: ::c_int = 53;
1638 pub const KERN_CONSDEV: ::c_int = 54;
1639 pub const KERN_MAXPTYS: ::c_int = 55;
1640 pub const KERN_PIPE: ::c_int = 56;
1641 pub const KERN_MAXPHYS: ::c_int = 57;
1642 pub const KERN_SBMAX: ::c_int = 58;
1643 pub const KERN_TKSTAT: ::c_int = 59;
1644 pub const KERN_MONOTONIC_CLOCK: ::c_int = 60;
1645 pub const KERN_URND: ::c_int = 61;
1646 pub const KERN_LABELSECTOR: ::c_int = 62;
1647 pub const KERN_LABELOFFSET: ::c_int = 63;
1648 pub const KERN_LWP: ::c_int = 64;
1649 pub const KERN_FORKFSLEEP: ::c_int = 65;
1650 pub const KERN_POSIX_THREADS: ::c_int = 66;
1651 pub const KERN_POSIX_SEMAPHORES: ::c_int = 67;
1652 pub const KERN_POSIX_BARRIERS: ::c_int = 68;
1653 pub const KERN_POSIX_TIMERS: ::c_int = 69;
1654 pub const KERN_POSIX_SPIN_LOCKS: ::c_int = 70;
1655 pub const KERN_POSIX_READER_WRITER_LOCKS: ::c_int = 71;
1656 pub const KERN_DUMP_ON_PANIC: ::c_int = 72;
1657 pub const KERN_SOMAXKVA: ::c_int = 73;
1658 pub const KERN_ROOT_PARTITION: ::c_int = 74;
1659 pub const KERN_DRIVERS: ::c_int = 75;
1660 pub const KERN_BUF: ::c_int = 76;
1661 pub const KERN_FILE2: ::c_int = 77;
1662 pub const KERN_VERIEXEC: ::c_int = 78;
1663 pub const KERN_CP_ID: ::c_int = 79;
1664 pub const KERN_HARDCLOCK_TICKS: ::c_int = 80;
1665 pub const KERN_ARND: ::c_int = 81;
1666 pub const KERN_SYSVIPC: ::c_int = 82;
1667 pub const KERN_BOOTTIME: ::c_int = 83;
1668 pub const KERN_EVCNT: ::c_int = 84;
1669 pub const KERN_MAXID: ::c_int = 85;
1670 pub const KERN_PROC_ALL: ::c_int = 0;
1671 pub const KERN_PROC_PID: ::c_int = 1;
1672 pub const KERN_PROC_PGRP: ::c_int = 2;
1673 pub const KERN_PROC_SESSION: ::c_int = 3;
1674 pub const KERN_PROC_TTY: ::c_int = 4;
1675 pub const KERN_PROC_UID: ::c_int = 5;
1676 pub const KERN_PROC_RUID: ::c_int = 6;
1677 pub const KERN_PROC_GID: ::c_int = 7;
1678 pub const KERN_PROC_RGID: ::c_int = 8;
1679 pub const KERN_PROC_ARGV: ::c_int = 1;
1680 pub const KERN_PROC_NARGV: ::c_int = 2;
1681 pub const KERN_PROC_ENV: ::c_int = 3;
1682 pub const KERN_PROC_NENV: ::c_int = 4;
1683 pub const KERN_PROC_PATHNAME: ::c_int = 5;
1684 
1685 pub const EAI_AGAIN: ::c_int = 2;
1686 pub const EAI_BADFLAGS: ::c_int = 3;
1687 pub const EAI_FAIL: ::c_int = 4;
1688 pub const EAI_FAMILY: ::c_int = 5;
1689 pub const EAI_MEMORY: ::c_int = 6;
1690 pub const EAI_NODATA: ::c_int = 7;
1691 pub const EAI_NONAME: ::c_int = 8;
1692 pub const EAI_SERVICE: ::c_int = 9;
1693 pub const EAI_SOCKTYPE: ::c_int = 10;
1694 pub const EAI_SYSTEM: ::c_int = 11;
1695 pub const EAI_OVERFLOW: ::c_int = 14;
1696 
1697 pub const AIO_CANCELED: ::c_int = 1;
1698 pub const AIO_NOTCANCELED: ::c_int = 2;
1699 pub const AIO_ALLDONE: ::c_int = 3;
1700 pub const LIO_NOP: ::c_int = 0;
1701 pub const LIO_WRITE: ::c_int = 1;
1702 pub const LIO_READ: ::c_int = 2;
1703 pub const LIO_WAIT: ::c_int = 1;
1704 pub const LIO_NOWAIT: ::c_int = 0;
1705 
1706 pub const SIGEV_NONE: ::c_int = 0;
1707 pub const SIGEV_SIGNAL: ::c_int = 1;
1708 pub const SIGEV_THREAD: ::c_int = 2;
1709 
1710 pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED
1711 pub const WCONTINUED: ::c_int = 0x00000010;
1712 pub const WEXITED: ::c_int = 0x000000020;
1713 pub const WNOWAIT: ::c_int = 0x00010000;
1714 
1715 pub const P_ALL: idtype_t = 0;
1716 pub const P_PID: idtype_t = 1;
1717 pub const P_PGID: idtype_t = 4;
1718 
1719 pub const UTIME_OMIT: c_long = 1073741822;
1720 pub const UTIME_NOW: c_long = 1073741823;
1721 
1722 pub const B460800: ::speed_t = 460800;
1723 pub const B921600: ::speed_t = 921600;
1724 
1725 pub const ONOCR: ::tcflag_t = 0x20;
1726 pub const ONLRET: ::tcflag_t = 0x40;
1727 pub const CDTRCTS: ::tcflag_t = 0x00020000;
1728 pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS;
1729 
1730 // pub const _PATH_UTMPX: &[::c_char; 14] = b"/var/run/utmpx";
1731 // pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx";
1732 // pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx";
1733 // pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update";
1734 pub const UT_NAMESIZE: usize = 8;
1735 pub const UT_LINESIZE: usize = 8;
1736 pub const UT_HOSTSIZE: usize = 16;
1737 pub const _UTX_USERSIZE: usize = 32;
1738 pub const _UTX_LINESIZE: usize = 32;
1739 pub const _UTX_PADSIZE: usize = 40;
1740 pub const _UTX_IDSIZE: usize = 4;
1741 pub const _UTX_HOSTSIZE: usize = 256;
1742 pub const EMPTY: u16 = 0;
1743 pub const RUN_LVL: u16 = 1;
1744 pub const BOOT_TIME: u16 = 2;
1745 pub const OLD_TIME: u16 = 3;
1746 pub const NEW_TIME: u16 = 4;
1747 pub const INIT_PROCESS: u16 = 5;
1748 pub const LOGIN_PROCESS: u16 = 6;
1749 pub const USER_PROCESS: u16 = 7;
1750 pub const DEAD_PROCESS: u16 = 8;
1751 pub const ACCOUNTING: u16 = 9;
1752 pub const SIGNATURE: u16 = 10;
1753 pub const DOWN_TIME: u16 = 11;
1754 
1755 pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
1756 pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
1757 
1758 // Uncomment on next NetBSD release
1759 // pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
1760 // pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
1761 pub const OFIOGETBMAP: ::c_ulong = 0xc004667a;
1762 pub const FIOGETBMAP: ::c_ulong = 0xc008667a;
1763 pub const FIONWRITE: ::c_ulong = 0x40046679;
1764 pub const FIONSPACE: ::c_ulong = 0x40046678;
1765 pub const FIBMAP: ::c_ulong = 0xc008667a;
1766 
1767 pub const SIGSTKSZ: ::size_t = 40960;
1768 
1769 pub const REG_ENOSYS: ::c_int = 17;
1770 
1771 pub const PT_DUMPCORE: ::c_int = 12;
1772 pub const PT_LWPINFO: ::c_int = 13;
1773 pub const PT_SYSCALL: ::c_int = 14;
1774 pub const PT_SYSCALLEMU: ::c_int = 15;
1775 pub const PT_SET_EVENT_MASK: ::c_int = 16;
1776 pub const PT_GET_EVENT_MASK: ::c_int = 17;
1777 pub const PT_GET_PROCESS_STATE: ::c_int = 18;
1778 pub const PT_FIRSTMACH: ::c_int = 32;
1779 
1780 // Flags for chflags(2)
1781 pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
1782 pub const SF_LOG: ::c_ulong = 0x00400000;
1783 pub const SF_SNAPINVAL: ::c_ulong = 0x00800000;
1784 
1785 const_fn! {
1786     {const} fn _ALIGN(p: usize) -> usize {
1787         (p + _ALIGNBYTES) & !_ALIGNBYTES
1788     }
1789 }
1790 
1791 f! {
1792     pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
1793         (cmsg as *mut ::c_uchar)
1794             .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
1795     }
1796 
1797     pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1798         _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
1799     }
1800 
1801     pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
1802         -> *mut ::cmsghdr
1803     {
1804         if cmsg.is_null() {
1805             return ::CMSG_FIRSTHDR(mhdr);
1806         };
1807         let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
1808             + _ALIGN(::mem::size_of::<::cmsghdr>());
1809         let max = (*mhdr).msg_control as usize
1810             + (*mhdr).msg_controllen as usize;
1811         if next > max {
1812             0 as *mut ::cmsghdr
1813         } else {
1814             (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
1815                 as *mut ::cmsghdr
1816         }
1817     }
1818 
1819     pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
1820         (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
1821             as ::c_uint
1822     }
1823 
1824     // dirfd() is a macro on netbsd to access
1825     // the first field of the struct where dirp points to:
1826     // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
1827     pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
1828         *(dirp as *const ::c_int)
1829     }
1830 
1831     pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
1832         let ngrps = if ngrps > 0 {
1833             ngrps - 1
1834         } else {
1835             0
1836         };
1837         ::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
1838     }
1839 }
1840 
1841 safe_f! {
1842     pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
1843         status >> 8
1844     }
1845 
1846     pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
1847         (status & 0o177) != 0o177 && (status & 0o177) != 0
1848     }
1849 
1850     pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
1851         (status & 0o177) == 0o177
1852     }
1853 
1854     pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
1855         status == 0xffff
1856     }
1857 }
1858 
1859 extern "C" {
ntp_adjtime(buf: *mut timex) -> ::c_int1860     pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
ntp_gettime(buf: *mut ntptimeval) -> ::c_int1861     pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
clock_nanosleep( clk_id: ::clockid_t, flags: ::c_int, rqtp: *const ::timespec, rmtp: *mut ::timespec, ) -> ::c_int1862     pub fn clock_nanosleep(
1863         clk_id: ::clockid_t,
1864         flags: ::c_int,
1865         rqtp: *const ::timespec,
1866         rmtp: *mut ::timespec,
1867     ) -> ::c_int;
1868 }
1869 
1870 #[link(name = "rt")]
1871 extern "C" {
aio_read(aiocbp: *mut aiocb) -> ::c_int1872     pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
aio_write(aiocbp: *mut aiocb) -> ::c_int1873     pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int1874     pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
aio_error(aiocbp: *const aiocb) -> ::c_int1875     pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
aio_return(aiocbp: *mut aiocb) -> ::ssize_t1876     pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
1877     #[link_name = "__aio_suspend50"]
aio_suspend( aiocb_list: *const *const aiocb, nitems: ::c_int, timeout: *const ::timespec, ) -> ::c_int1878     pub fn aio_suspend(
1879         aiocb_list: *const *const aiocb,
1880         nitems: ::c_int,
1881         timeout: *const ::timespec,
1882     ) -> ::c_int;
aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int1883     pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
lio_listio( mode: ::c_int, aiocb_list: *const *mut aiocb, nitems: ::c_int, sevp: *mut sigevent, ) -> ::c_int1884     pub fn lio_listio(
1885         mode: ::c_int,
1886         aiocb_list: *const *mut aiocb,
1887         nitems: ::c_int,
1888         sevp: *mut sigevent,
1889     ) -> ::c_int;
1890 }
1891 
1892 extern "C" {
chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int1893     pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int1894     pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int1895     pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
1896 
extattr_delete_fd( fd: ::c_int, attrnamespace: ::c_int, attrname: *const ::c_char, ) -> ::c_int1897     pub fn extattr_delete_fd(
1898         fd: ::c_int,
1899         attrnamespace: ::c_int,
1900         attrname: *const ::c_char,
1901     ) -> ::c_int;
extattr_delete_file( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, ) -> ::c_int1902     pub fn extattr_delete_file(
1903         path: *const ::c_char,
1904         attrnamespace: ::c_int,
1905         attrname: *const ::c_char,
1906     ) -> ::c_int;
extattr_delete_link( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, ) -> ::c_int1907     pub fn extattr_delete_link(
1908         path: *const ::c_char,
1909         attrnamespace: ::c_int,
1910         attrname: *const ::c_char,
1911     ) -> ::c_int;
extattr_get_fd( fd: ::c_int, attrnamespace: ::c_int, attrname: *const ::c_char, data: *mut ::c_void, nbytes: ::size_t, ) -> ::ssize_t1912     pub fn extattr_get_fd(
1913         fd: ::c_int,
1914         attrnamespace: ::c_int,
1915         attrname: *const ::c_char,
1916         data: *mut ::c_void,
1917         nbytes: ::size_t,
1918     ) -> ::ssize_t;
extattr_get_file( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, data: *mut ::c_void, nbytes: ::size_t, ) -> ::ssize_t1919     pub fn extattr_get_file(
1920         path: *const ::c_char,
1921         attrnamespace: ::c_int,
1922         attrname: *const ::c_char,
1923         data: *mut ::c_void,
1924         nbytes: ::size_t,
1925     ) -> ::ssize_t;
extattr_get_link( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, data: *mut ::c_void, nbytes: ::size_t, ) -> ::ssize_t1926     pub fn extattr_get_link(
1927         path: *const ::c_char,
1928         attrnamespace: ::c_int,
1929         attrname: *const ::c_char,
1930         data: *mut ::c_void,
1931         nbytes: ::size_t,
1932     ) -> ::ssize_t;
extattr_namespace_to_string( attrnamespace: ::c_int, string: *mut *mut ::c_char, ) -> ::c_int1933     pub fn extattr_namespace_to_string(
1934         attrnamespace: ::c_int,
1935         string: *mut *mut ::c_char,
1936     ) -> ::c_int;
extattr_set_fd( fd: ::c_int, attrnamespace: ::c_int, attrname: *const ::c_char, data: *const ::c_void, nbytes: ::size_t, ) -> ::c_int1937     pub fn extattr_set_fd(
1938         fd: ::c_int,
1939         attrnamespace: ::c_int,
1940         attrname: *const ::c_char,
1941         data: *const ::c_void,
1942         nbytes: ::size_t,
1943     ) -> ::c_int;
extattr_set_file( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, data: *const ::c_void, nbytes: ::size_t, ) -> ::c_int1944     pub fn extattr_set_file(
1945         path: *const ::c_char,
1946         attrnamespace: ::c_int,
1947         attrname: *const ::c_char,
1948         data: *const ::c_void,
1949         nbytes: ::size_t,
1950     ) -> ::c_int;
extattr_set_link( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, data: *const ::c_void, nbytes: ::size_t, ) -> ::c_int1951     pub fn extattr_set_link(
1952         path: *const ::c_char,
1953         attrnamespace: ::c_int,
1954         attrname: *const ::c_char,
1955         data: *const ::c_void,
1956         nbytes: ::size_t,
1957     ) -> ::c_int;
extattr_string_to_namespace( string: *const ::c_char, attrnamespace: *mut ::c_int, ) -> ::c_int1958     pub fn extattr_string_to_namespace(
1959         string: *const ::c_char,
1960         attrnamespace: *mut ::c_int,
1961     ) -> ::c_int;
1962 
1963     #[link_name = "__lutimes50"]
lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int1964     pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
1965     #[link_name = "__gettimeofday50"]
gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int1966     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
getnameinfo( sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, hostlen: ::socklen_t, serv: *mut ::c_char, sevlen: ::socklen_t, flags: ::c_int, ) -> ::c_int1967     pub fn getnameinfo(
1968         sa: *const ::sockaddr,
1969         salen: ::socklen_t,
1970         host: *mut ::c_char,
1971         hostlen: ::socklen_t,
1972         serv: *mut ::c_char,
1973         sevlen: ::socklen_t,
1974         flags: ::c_int,
1975     ) -> ::c_int;
mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int1976     pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
sysctl( name: *const ::c_int, namelen: ::c_uint, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *const ::c_void, newlen: ::size_t, ) -> ::c_int1977     pub fn sysctl(
1978         name: *const ::c_int,
1979         namelen: ::c_uint,
1980         oldp: *mut ::c_void,
1981         oldlenp: *mut ::size_t,
1982         newp: *const ::c_void,
1983         newlen: ::size_t,
1984     ) -> ::c_int;
sysctlbyname( name: *const ::c_char, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *const ::c_void, newlen: ::size_t, ) -> ::c_int1985     pub fn sysctlbyname(
1986         name: *const ::c_char,
1987         oldp: *mut ::c_void,
1988         oldlenp: *mut ::size_t,
1989         newp: *const ::c_void,
1990         newlen: ::size_t,
1991     ) -> ::c_int;
1992     #[link_name = "__kevent50"]
kevent( kq: ::c_int, changelist: *const ::kevent, nchanges: ::size_t, eventlist: *mut ::kevent, nevents: ::size_t, timeout: *const ::timespec, ) -> ::c_int1993     pub fn kevent(
1994         kq: ::c_int,
1995         changelist: *const ::kevent,
1996         nchanges: ::size_t,
1997         eventlist: *mut ::kevent,
1998         nevents: ::size_t,
1999         timeout: *const ::timespec,
2000     ) -> ::c_int;
2001     #[link_name = "__mount50"]
mount( src: *const ::c_char, target: *const ::c_char, flags: ::c_int, data: *mut ::c_void, size: ::size_t, ) -> ::c_int2002     pub fn mount(
2003         src: *const ::c_char,
2004         target: *const ::c_char,
2005         flags: ::c_int,
2006         data: *mut ::c_void,
2007         size: ::size_t,
2008     ) -> ::c_int;
mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t2009     pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
mq_close(mqd: ::mqd_t) -> ::c_int2010     pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int2011     pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) -> ::c_int2012     pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) -> ::c_int;
mq_receive( mqd: ::mqd_t, msg_ptr: *mut ::c_char, msg_len: ::size_t, msg_prio: *mut ::c_uint, ) -> ::ssize_t2013     pub fn mq_receive(
2014         mqd: ::mqd_t,
2015         msg_ptr: *mut ::c_char,
2016         msg_len: ::size_t,
2017         msg_prio: *mut ::c_uint,
2018     ) -> ::ssize_t;
mq_send( mqd: ::mqd_t, msg_ptr: *const ::c_char, msg_len: ::size_t, msg_prio: ::c_uint, ) -> ::c_int2019     pub fn mq_send(
2020         mqd: ::mqd_t,
2021         msg_ptr: *const ::c_char,
2022         msg_len: ::size_t,
2023         msg_prio: ::c_uint,
2024     ) -> ::c_int;
mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int2025     pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int;
2026     #[link_name = "__mq_timedreceive50"]
mq_timedreceive( mqd: ::mqd_t, msg_ptr: *mut ::c_char, msg_len: ::size_t, msg_prio: *mut ::c_uint, abs_timeout: *const ::timespec, ) -> ::ssize_t2027     pub fn mq_timedreceive(
2028         mqd: ::mqd_t,
2029         msg_ptr: *mut ::c_char,
2030         msg_len: ::size_t,
2031         msg_prio: *mut ::c_uint,
2032         abs_timeout: *const ::timespec,
2033     ) -> ::ssize_t;
2034     #[link_name = "__mq_timedsend50"]
mq_timedsend( mqd: ::mqd_t, msg_ptr: *const ::c_char, msg_len: ::size_t, msg_prio: ::c_uint, abs_timeout: *const ::timespec, ) -> ::c_int2035     pub fn mq_timedsend(
2036         mqd: ::mqd_t,
2037         msg_ptr: *const ::c_char,
2038         msg_len: ::size_t,
2039         msg_prio: ::c_uint,
2040         abs_timeout: *const ::timespec,
2041     ) -> ::c_int;
mq_unlink(name: *const ::c_char) -> ::c_int2042     pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_void, data: ::c_int) -> ::c_int2043     pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_void, data: ::c_int) -> ::c_int;
pthread_setname_np( t: ::pthread_t, name: *const ::c_char, arg: *const ::c_void, ) -> ::c_int2044     pub fn pthread_setname_np(
2045         t: ::pthread_t,
2046         name: *const ::c_char,
2047         arg: *const ::c_void,
2048     ) -> ::c_int;
pthread_attr_get_np(thread: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int2049     pub fn pthread_attr_get_np(thread: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int;
pthread_getattr_np(native: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int2050     pub fn pthread_getattr_np(native: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int;
pthread_attr_getguardsize( attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int2051     pub fn pthread_attr_getguardsize(
2052         attr: *const ::pthread_attr_t,
2053         guardsize: *mut ::size_t,
2054     ) -> ::c_int;
pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, stacksize: *mut ::size_t, ) -> ::c_int2055     pub fn pthread_attr_getstack(
2056         attr: *const ::pthread_attr_t,
2057         stackaddr: *mut *mut ::c_void,
2058         stacksize: *mut ::size_t,
2059     ) -> ::c_int;
pthread_getaffinity_np( thread: ::pthread_t, size: ::size_t, set: *mut cpuset_t, ) -> ::c_int2060     pub fn pthread_getaffinity_np(
2061         thread: ::pthread_t,
2062         size: ::size_t,
2063         set: *mut cpuset_t,
2064     ) -> ::c_int;
pthread_setaffinity_np( thread: ::pthread_t, size: ::size_t, set: *mut cpuset_t, ) -> ::c_int2065     pub fn pthread_setaffinity_np(
2066         thread: ::pthread_t,
2067         size: ::size_t,
2068         set: *mut cpuset_t,
2069     ) -> ::c_int;
_cpuset_create() -> *mut cpuset_t2070     pub fn _cpuset_create() -> *mut cpuset_t;
_cpuset_destroy(set: *mut cpuset_t)2071     pub fn _cpuset_destroy(set: *mut cpuset_t);
_cpuset_clr(cpu: cpuid_t, set: *mut cpuset_t) -> ::c_int2072     pub fn _cpuset_clr(cpu: cpuid_t, set: *mut cpuset_t) -> ::c_int;
_cpuset_set(cpu: cpuid_t, set: *mut cpuset_t) -> ::c_int2073     pub fn _cpuset_set(cpu: cpuid_t, set: *mut cpuset_t) -> ::c_int;
_cpuset_isset(cpu: cpuid_t, set: *const cpuset_t) -> ::c_int2074     pub fn _cpuset_isset(cpu: cpuid_t, set: *const cpuset_t) -> ::c_int;
_cpuset_size(set: *const cpuset_t) -> ::size_t2075     pub fn _cpuset_size(set: *const cpuset_t) -> ::size_t;
_cpuset_zero(set: *mut cpuset_t)2076     pub fn _cpuset_zero(set: *mut cpuset_t);
2077     #[link_name = "__sigtimedwait50"]
sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, timeout: *const ::timespec, ) -> ::c_int2078     pub fn sigtimedwait(
2079         set: *const sigset_t,
2080         info: *mut siginfo_t,
2081         timeout: *const ::timespec,
2082     ) -> ::c_int;
sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int2083     pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int;
duplocale(base: ::locale_t) -> ::locale_t2084     pub fn duplocale(base: ::locale_t) -> ::locale_t;
freelocale(loc: ::locale_t)2085     pub fn freelocale(loc: ::locale_t);
localeconv_l(loc: ::locale_t) -> *mut lconv2086     pub fn localeconv_l(loc: ::locale_t) -> *mut lconv;
newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t2087     pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
2088     #[link_name = "__settimeofday50"]
settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int2089     pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int;
2090 
dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int2091     pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
2092 
kqueue1(flags: ::c_int) -> ::c_int2093     pub fn kqueue1(flags: ::c_int) -> ::c_int;
2094 
sendmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_int, ) -> ::c_int2095     pub fn sendmmsg(
2096         sockfd: ::c_int,
2097         msgvec: *mut ::mmsghdr,
2098         vlen: ::c_uint,
2099         flags: ::c_int,
2100     ) -> ::c_int;
recvmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_int, timeout: *mut ::timespec, ) -> ::c_int2101     pub fn recvmmsg(
2102         sockfd: ::c_int,
2103         msgvec: *mut ::mmsghdr,
2104         vlen: ::c_uint,
2105         flags: ::c_int,
2106         timeout: *mut ::timespec,
2107     ) -> ::c_int;
2108 
_lwp_self() -> lwpid_t2109     pub fn _lwp_self() -> lwpid_t;
memmem( haystack: *const ::c_void, haystacklen: ::size_t, needle: *const ::c_void, needlelen: ::size_t, ) -> *mut ::c_void2110     pub fn memmem(
2111         haystack: *const ::c_void,
2112         haystacklen: ::size_t,
2113         needle: *const ::c_void,
2114         needlelen: ::size_t,
2115     ) -> *mut ::c_void;
2116 
2117     // link.h
2118 
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_int2119     pub fn dl_iterate_phdr(
2120         callback: ::Option<
2121             unsafe extern "C" fn(
2122                 info: *mut dl_phdr_info,
2123                 size: usize,
2124                 data: *mut ::c_void,
2125             ) -> ::c_int,
2126         >,
2127         data: *mut ::c_void,
2128     ) -> ::c_int;
2129 
2130     // dlfcn.h
2131 
_dlauxinfo() -> *mut ::c_void2132     pub fn _dlauxinfo() -> *mut ::c_void;
2133 
iconv_open(tocode: *const ::c_char, fromcode: *const ::c_char) -> iconv_t2134     pub fn iconv_open(tocode: *const ::c_char, fromcode: *const ::c_char) -> iconv_t;
iconv( cd: iconv_t, inbuf: *mut *mut ::c_char, inbytesleft: *mut ::size_t, outbuf: *mut *mut ::c_char, outbytesleft: *mut ::size_t, ) -> ::size_t2135     pub fn iconv(
2136         cd: iconv_t,
2137         inbuf: *mut *mut ::c_char,
2138         inbytesleft: *mut ::size_t,
2139         outbuf: *mut *mut ::c_char,
2140         outbytesleft: *mut ::size_t,
2141     ) -> ::size_t;
iconv_close(cd: iconv_t) -> ::c_int2142     pub fn iconv_close(cd: iconv_t) -> ::c_int;
2143 
2144     // Added in `NetBSD` 7.0
explicit_memset(b: *mut ::c_void, c: ::c_int, len: ::size_t)2145     pub fn explicit_memset(b: *mut ::c_void, c: ::c_int, len: ::size_t);
consttime_memequal(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int2146     pub fn consttime_memequal(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
2147 
setproctitle(fmt: *const ::c_char, ...)2148     pub fn setproctitle(fmt: *const ::c_char, ...);
mremap( oldp: *mut ::c_void, oldsize: ::size_t, newp: *mut ::c_void, newsize: ::size_t, flags: ::c_int, ) -> *mut ::c_void2149     pub fn mremap(
2150         oldp: *mut ::c_void,
2151         oldsize: ::size_t,
2152         newp: *mut ::c_void,
2153         newsize: ::size_t,
2154         flags: ::c_int,
2155     ) -> *mut ::c_void;
2156 }
2157 
2158 #[link(name = "util")]
2159 extern "C" {
2160     #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")]
getpwent_r( pwd: *mut ::passwd, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut ::passwd, ) -> ::c_int2161     pub fn getpwent_r(
2162         pwd: *mut ::passwd,
2163         buf: *mut ::c_char,
2164         buflen: ::size_t,
2165         result: *mut *mut ::passwd,
2166     ) -> ::c_int;
getgrent_r( grp: *mut ::group, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int2167     pub fn getgrent_r(
2168         grp: *mut ::group,
2169         buf: *mut ::c_char,
2170         buflen: ::size_t,
2171         result: *mut *mut ::group,
2172     ) -> ::c_int;
2173 
updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int2174     pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int;
getlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> *mut lastlogx2175     pub fn getlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> *mut lastlogx;
updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int2176     pub fn updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int;
utmpxname(file: *const ::c_char) -> ::c_int2177     pub fn utmpxname(file: *const ::c_char) -> ::c_int;
getutxent() -> *mut utmpx2178     pub fn getutxent() -> *mut utmpx;
getutxid(ut: *const utmpx) -> *mut utmpx2179     pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
getutxline(ut: *const utmpx) -> *mut utmpx2180     pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
pututxline(ut: *const utmpx) -> *mut utmpx2181     pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
setutxent()2182     pub fn setutxent();
endutxent()2183     pub fn endutxent();
2184 
getutmp(ux: *const utmpx, u: *mut utmp)2185     pub fn getutmp(ux: *const utmpx, u: *mut utmp);
getutmpx(u: *const utmp, ux: *mut utmpx)2186     pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
2187 
utpname(file: *const ::c_char) -> ::c_int2188     pub fn utpname(file: *const ::c_char) -> ::c_int;
setutent()2189     pub fn setutent();
endutent()2190     pub fn endutent();
getutent() -> *mut utmp2191     pub fn getutent() -> *mut utmp;
2192 
efopen(p: *const ::c_char, m: *const ::c_char) -> ::FILE2193     pub fn efopen(p: *const ::c_char, m: *const ::c_char) -> ::FILE;
emalloc(n: ::size_t) -> *mut ::c_void2194     pub fn emalloc(n: ::size_t) -> *mut ::c_void;
ecalloc(n: ::size_t, c: ::size_t) -> *mut ::c_void2195     pub fn ecalloc(n: ::size_t, c: ::size_t) -> *mut ::c_void;
erealloc(p: *mut ::c_void, n: ::size_t) -> *mut ::c_void2196     pub fn erealloc(p: *mut ::c_void, n: ::size_t) -> *mut ::c_void;
estrdup(s: *const ::c_char) -> *mut ::c_char2197     pub fn estrdup(s: *const ::c_char) -> *mut ::c_char;
estrndup(s: *const ::c_char, len: ::size_t) -> *mut ::c_char2198     pub fn estrndup(s: *const ::c_char, len: ::size_t) -> *mut ::c_char;
estrlcpy(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t2199     pub fn estrlcpy(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t;
estrlcat(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t2200     pub fn estrlcat(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t;
easprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int2201     pub fn easprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int;
evasprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int2202     pub fn evasprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int;
esetfunc( cb: ::Option<unsafe extern "C" fn(::c_int, *const ::c_char, ...)>, ) -> ::Option<unsafe extern "C" fn(::c_int, *const ::c_char, ...)>2203     pub fn esetfunc(
2204         cb: ::Option<unsafe extern "C" fn(::c_int, *const ::c_char, ...)>,
2205     ) -> ::Option<unsafe extern "C" fn(::c_int, *const ::c_char, ...)>;
2206 }
2207 
2208 cfg_if! {
2209     if #[cfg(target_arch = "aarch64")] {
2210         mod aarch64;
2211         pub use self::aarch64::*;
2212     } else if #[cfg(target_arch = "arm")] {
2213         mod arm;
2214         pub use self::arm::*;
2215     } else if #[cfg(target_arch = "powerpc")] {
2216         mod powerpc;
2217         pub use self::powerpc::*;
2218     } else if #[cfg(target_arch = "sparc64")] {
2219         mod sparc64;
2220         pub use self::sparc64::*;
2221     } else if #[cfg(target_arch = "x86_64")] {
2222         mod x86_64;
2223         pub use self::x86_64::*;
2224     } else if #[cfg(target_arch = "x86")] {
2225         mod x86;
2226         pub use self::x86::*;
2227     } else {
2228         // Unknown target_arch
2229     }
2230 }
2231