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