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