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     pub struct arphdr {
449         pub ar_hrd: u16,
450         pub ar_pro: u16,
451         pub ar_hln: u8,
452         pub ar_pln: u8,
453         pub ar_op: u16,
454     }
455 
456     pub struct in_addr {
457         pub s_addr: ::in_addr_t,
458     }
459 
460     pub struct ip_mreq {
461         pub imr_multiaddr: in_addr,
462         pub imr_interface: in_addr,
463     }
464 
465     pub struct sockaddr_in {
466         pub sin_len: u8,
467         pub sin_family: ::sa_family_t,
468         pub sin_port: ::in_port_t,
469         pub sin_addr: ::in_addr,
470         pub sin_zero: [i8; 8],
471     }
472 
473     pub struct dirent {
474         pub d_fileno: ::ino_t,
475         pub d_reclen: u16,
476         pub d_namlen: u16,
477         pub d_type: u8,
478         pub d_name: [::c_char; 512],
479     }
480 
481     pub struct statvfs {
482         pub f_flag: ::c_ulong,
483         pub f_bsize: ::c_ulong,
484         pub f_frsize: ::c_ulong,
485         pub f_iosize: ::c_ulong,
486 
487         pub f_blocks: ::fsblkcnt_t,
488         pub f_bfree: ::fsblkcnt_t,
489         pub f_bavail: ::fsblkcnt_t,
490         pub f_bresvd: ::fsblkcnt_t,
491 
492         pub f_files: ::fsfilcnt_t,
493         pub f_ffree: ::fsfilcnt_t,
494         pub f_favail: ::fsfilcnt_t,
495         pub f_fresvd: ::fsfilcnt_t,
496 
497         pub f_syncreads: u64,
498         pub f_syncwrites: u64,
499 
500         pub f_asyncreads: u64,
501         pub f_asyncwrites: u64,
502 
503         pub f_fsidx: ::fsid_t,
504         pub f_fsid: ::c_ulong,
505         pub f_namemax: ::c_ulong,
506         pub f_owner: ::uid_t,
507 
508         pub f_spare: [u32; 4],
509 
510         pub f_fstypename: [::c_char; 32],
511         pub f_mntonname: [::c_char; 1024],
512         pub f_mntfromname: [::c_char; 1024],
513     }
514 
515     pub struct sockaddr_storage {
516         pub ss_len: u8,
517         pub ss_family: ::sa_family_t,
518         __ss_pad1: [u8; 6],
519         __ss_pad2: i64,
520         __ss_pad3: [u8; 112],
521     }
522 
523     pub struct sigevent {
524         pub sigev_notify: ::c_int,
525         pub sigev_signo: ::c_int,
526         pub sigev_value: ::sigval,
527         __unused1: *mut ::c_void,       //actually a function pointer
528         pub sigev_notify_attributes: *mut ::c_void
529     }
530 }
531 
532 cfg_if! {
533     if #[cfg(feature = "extra_traits")] {
534         impl PartialEq for utmpx {
535             fn eq(&self, other: &utmpx) -> bool {
536                 self.ut_type == other.ut_type
537                     && self.ut_pid == other.ut_pid
538                     && self.ut_name == other.ut_name
539                     && self.ut_line == other.ut_line
540                     && self.ut_id == other.ut_id
541                     && self.ut_exit == other.ut_exit
542                     && self.ut_session == other.ut_session
543                     && self.ut_tv == other.ut_tv
544                     && self.ut_ss == other.ut_ss
545                     && self
546                     .ut_pad
547                     .iter()
548                     .zip(other.ut_pad.iter())
549                     .all(|(a,b)| a == b)
550                     && self
551                     .ut_host
552                     .iter()
553                     .zip(other.ut_host.iter())
554                     .all(|(a,b)| a == b)
555             }
556         }
557 
558         impl Eq for utmpx {}
559 
560         impl ::fmt::Debug for utmpx {
561             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
562                 f.debug_struct("utmpx")
563                     .field("ut_name", &self.ut_name)
564                     .field("ut_id", &self.ut_id)
565                     .field("ut_line", &self.ut_line)
566                 // FIXME .field("ut_host", &self.ut_host)
567                     .field("ut_session", &self.ut_session)
568                     .field("ut_type", &self.ut_type)
569                     .field("ut_pid", &self.ut_pid)
570                     .field("ut_exit", &self.ut_exit)
571                     .field("ut_ss", &self.ut_ss)
572                     .field("ut_tv", &self.ut_tv)
573                 // FIXME .field("ut_pad", &self.ut_pad)
574                     .finish()
575             }
576         }
577 
578         impl ::hash::Hash for utmpx {
579             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
580                 self.ut_name.hash(state);
581                 self.ut_type.hash(state);
582                 self.ut_pid.hash(state);
583                 self.ut_line.hash(state);
584                 self.ut_id.hash(state);
585                 self.ut_host.hash(state);
586                 self.ut_exit.hash(state);
587                 self.ut_session.hash(state);
588                 self.ut_tv.hash(state);
589                 self.ut_ss.hash(state);
590                 self.ut_pad.hash(state);
591             }
592         }
593 
594         impl PartialEq for lastlogx {
595             fn eq(&self, other: &lastlogx) -> bool {
596                 self.ll_tv == other.ll_tv
597                     && self.ll_line == other.ll_line
598                     && self.ll_ss == other.ll_ss
599                     && self
600                     .ll_host
601                     .iter()
602                     .zip(other.ll_host.iter())
603                     .all(|(a,b)| a == b)
604             }
605         }
606 
607         impl Eq for lastlogx {}
608 
609         impl ::fmt::Debug for lastlogx {
610             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
611                 f.debug_struct("lastlogx")
612                     .field("ll_tv", &self.ll_tv)
613                     .field("ll_line", &self.ll_line)
614                 // FIXME.field("ll_host", &self.ll_host)
615                     .field("ll_ss", &self.ll_ss)
616                     .finish()
617             }
618         }
619 
620         impl ::hash::Hash for lastlogx {
621             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
622                 self.ll_tv.hash(state);
623                 self.ll_line.hash(state);
624                 self.ll_host.hash(state);
625                 self.ll_ss.hash(state);
626             }
627         }
628 
629         impl PartialEq for in_pktinfo {
630             fn eq(&self, other: &in_pktinfo) -> bool {
631                 self.ipi_addr == other.ipi_addr
632                     && self.ipi_ifindex == other.ipi_ifindex
633             }
634         }
635         impl Eq for in_pktinfo {}
636         impl ::fmt::Debug for in_pktinfo {
637             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
638                 f.debug_struct("in_pktinfo")
639                     .field("ipi_addr", &self.ipi_addr)
640                     .field("ipi_ifindex", &self.ipi_ifindex)
641                     .finish()
642             }
643         }
644         impl ::hash::Hash for in_pktinfo {
645             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
646                 self.ipi_addr.hash(state);
647                 self.ipi_ifindex.hash(state);
648             }
649         }
650 
651         impl PartialEq for arphdr {
652             fn eq(&self, other: &arphdr) -> bool {
653                 self.ar_hrd == other.ar_hrd
654                     && self.ar_pro == other.ar_pro
655                     && self.ar_hln == other.ar_hln
656                     && self.ar_pln == other.ar_pln
657                     && self.ar_op == other.ar_op
658             }
659         }
660         impl Eq for arphdr {}
661         impl ::fmt::Debug for arphdr {
662             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
663                 let ar_hrd = self.ar_hrd;
664                 let ar_pro = self.ar_pro;
665                 let ar_op = self.ar_op;
666                 f.debug_struct("arphdr")
667                     .field("ar_hrd", &ar_hrd)
668                     .field("ar_pro", &ar_pro)
669                     .field("ar_hln", &self.ar_hln)
670                     .field("ar_pln", &self.ar_pln)
671                     .field("ar_op", &ar_op)
672                     .finish()
673             }
674         }
675         impl ::hash::Hash for arphdr {
676             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
677                 let ar_hrd = self.ar_hrd;
678                 let ar_pro = self.ar_pro;
679                 let ar_op = self.ar_op;
680                 ar_hrd.hash(state);
681                 ar_pro.hash(state);
682                 self.ar_hln.hash(state);
683                 self.ar_pln.hash(state);
684                 ar_op.hash(state);
685             }
686         }
687 
688         impl PartialEq for in_addr {
689             fn eq(&self, other: &in_addr) -> bool {
690                 self.s_addr == other.s_addr
691             }
692         }
693         impl Eq for in_addr {}
694         impl ::fmt::Debug for in_addr {
695             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
696                 let s_addr = self.s_addr;
697                 f.debug_struct("in_addr")
698                     .field("s_addr", &s_addr)
699                     .finish()
700             }
701         }
702         impl ::hash::Hash for in_addr {
703             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
704                 let s_addr = self.s_addr;
705                 s_addr.hash(state);
706             }
707         }
708 
709         impl PartialEq for ip_mreq {
710             fn eq(&self, other: &ip_mreq) -> bool {
711                 self.imr_multiaddr == other.imr_multiaddr
712                     && self.imr_interface == other.imr_interface
713             }
714         }
715         impl Eq for ip_mreq {}
716         impl ::fmt::Debug for ip_mreq {
717             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
718                 f.debug_struct("ip_mreq")
719                     .field("imr_multiaddr", &self.imr_multiaddr)
720                     .field("imr_interface", &self.imr_interface)
721                     .finish()
722             }
723         }
724         impl ::hash::Hash for ip_mreq {
725             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
726                 self.imr_multiaddr.hash(state);
727                 self.imr_interface.hash(state);
728             }
729         }
730 
731         impl PartialEq for sockaddr_in {
732             fn eq(&self, other: &sockaddr_in) -> bool {
733                 self.sin_len == other.sin_len
734                     && self.sin_family == other.sin_family
735                     && self.sin_port == other.sin_port
736                     && self.sin_addr == other.sin_addr
737                     && self.sin_zero == other.sin_zero
738             }
739         }
740         impl Eq for sockaddr_in {}
741         impl ::fmt::Debug for sockaddr_in {
742             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
743                 f.debug_struct("sockaddr_in")
744                     .field("sin_len", &self.sin_len)
745                     .field("sin_family", &self.sin_family)
746                     .field("sin_port", &self.sin_port)
747                     .field("sin_addr", &self.sin_addr)
748                     .field("sin_zero", &self.sin_zero)
749                     .finish()
750             }
751         }
752         impl ::hash::Hash for sockaddr_in {
753             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
754                 self.sin_len.hash(state);
755                 self.sin_family.hash(state);
756                 self.sin_port.hash(state);
757                 self.sin_addr.hash(state);
758                 self.sin_zero.hash(state);
759             }
760         }
761 
762         impl PartialEq for dirent {
763             fn eq(&self, other: &dirent) -> bool {
764                 self.d_fileno == other.d_fileno
765                     && self.d_reclen == other.d_reclen
766                     && self.d_namlen == other.d_namlen
767                     && self.d_type == other.d_type
768                     && self
769                     .d_name
770                     .iter()
771                     .zip(other.d_name.iter())
772                     .all(|(a,b)| a == b)
773             }
774         }
775         impl Eq for dirent {}
776         impl ::fmt::Debug for dirent {
777             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
778                 f.debug_struct("dirent")
779                     .field("d_fileno", &self.d_fileno)
780                     .field("d_reclen", &self.d_reclen)
781                     .field("d_namlen", &self.d_namlen)
782                     .field("d_type", &self.d_type)
783                     // FIXME: .field("d_name", &self.d_name)
784                     .finish()
785             }
786         }
787         impl ::hash::Hash for dirent {
788             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
789                 self.d_fileno.hash(state);
790                 self.d_reclen.hash(state);
791                 self.d_namlen.hash(state);
792                 self.d_type.hash(state);
793                 self.d_name.hash(state);
794             }
795         }
796 
797         impl PartialEq for statvfs {
798             fn eq(&self, other: &statvfs) -> bool {
799                 self.f_flag == other.f_flag
800                     && self.f_bsize == other.f_bsize
801                     && self.f_frsize == other.f_frsize
802                     && self.f_iosize == other.f_iosize
803                     && self.f_blocks == other.f_blocks
804                     && self.f_bfree == other.f_bfree
805                     && self.f_bavail == other.f_bavail
806                     && self.f_bresvd == other.f_bresvd
807                     && self.f_files == other.f_files
808                     && self.f_ffree == other.f_ffree
809                     && self.f_favail == other.f_favail
810                     && self.f_fresvd == other.f_fresvd
811                     && self.f_syncreads == other.f_syncreads
812                     && self.f_syncwrites == other.f_syncwrites
813                     && self.f_asyncreads == other.f_asyncreads
814                     && self.f_asyncwrites == other.f_asyncwrites
815                     && self.f_fsidx == other.f_fsidx
816                     && self.f_fsid == other.f_fsid
817                     && self.f_namemax == other.f_namemax
818                     && self.f_owner == other.f_owner
819                     && self.f_spare == other.f_spare
820                     && self.f_fstypename == other.f_fstypename
821                     && self
822                     .f_mntonname
823                     .iter()
824                     .zip(other.f_mntonname.iter())
825                     .all(|(a,b)| a == b)
826                     && self
827                     .f_mntfromname
828                     .iter()
829                     .zip(other.f_mntfromname.iter())
830                     .all(|(a,b)| a == b)
831             }
832         }
833         impl Eq for statvfs {}
834         impl ::fmt::Debug for statvfs {
835             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
836                 f.debug_struct("statvfs")
837                     .field("f_flag", &self.f_flag)
838                     .field("f_bsize", &self.f_bsize)
839                     .field("f_frsize", &self.f_frsize)
840                     .field("f_iosize", &self.f_iosize)
841                     .field("f_blocks", &self.f_blocks)
842                     .field("f_bfree", &self.f_bfree)
843                     .field("f_bavail", &self.f_bavail)
844                     .field("f_bresvd", &self.f_bresvd)
845                     .field("f_files", &self.f_files)
846                     .field("f_ffree", &self.f_ffree)
847                     .field("f_favail", &self.f_favail)
848                     .field("f_fresvd", &self.f_fresvd)
849                     .field("f_syncreads", &self.f_syncreads)
850                     .field("f_syncwrites", &self.f_syncwrites)
851                     .field("f_asyncreads", &self.f_asyncreads)
852                     .field("f_asyncwrites", &self.f_asyncwrites)
853                     .field("f_fsidx", &self.f_fsidx)
854                     .field("f_fsid", &self.f_fsid)
855                     .field("f_namemax", &self.f_namemax)
856                     .field("f_owner", &self.f_owner)
857                     .field("f_spare", &self.f_spare)
858                     .field("f_fstypename", &self.f_fstypename)
859                     // FIXME: .field("f_mntonname", &self.f_mntonname)
860                     // FIXME: .field("f_mntfromname", &self.f_mntfromname)
861                     .finish()
862             }
863         }
864         impl ::hash::Hash for statvfs {
865             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
866                 self.f_flag.hash(state);
867                 self.f_bsize.hash(state);
868                 self.f_frsize.hash(state);
869                 self.f_iosize.hash(state);
870                 self.f_blocks.hash(state);
871                 self.f_bfree.hash(state);
872                 self.f_bavail.hash(state);
873                 self.f_bresvd.hash(state);
874                 self.f_files.hash(state);
875                 self.f_ffree.hash(state);
876                 self.f_favail.hash(state);
877                 self.f_fresvd.hash(state);
878                 self.f_syncreads.hash(state);
879                 self.f_syncwrites.hash(state);
880                 self.f_asyncreads.hash(state);
881                 self.f_asyncwrites.hash(state);
882                 self.f_fsidx.hash(state);
883                 self.f_fsid.hash(state);
884                 self.f_namemax.hash(state);
885                 self.f_owner.hash(state);
886                 self.f_spare.hash(state);
887                 self.f_fstypename.hash(state);
888                 self.f_mntonname.hash(state);
889                 self.f_mntfromname.hash(state);
890             }
891         }
892 
893         impl PartialEq for sockaddr_storage {
894             fn eq(&self, other: &sockaddr_storage) -> bool {
895                 self.ss_len == other.ss_len
896                     && self.ss_family == other.ss_family
897                     && self.__ss_pad1 == other.__ss_pad1
898                     && self.__ss_pad2 == other.__ss_pad2
899                     && self
900                     .__ss_pad3
901                     .iter()
902                     .zip(other.__ss_pad3.iter())
903                     .all(|(a,b)| a == b)
904             }
905         }
906         impl Eq for sockaddr_storage {}
907         impl ::fmt::Debug for sockaddr_storage {
908             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
909                 f.debug_struct("sockaddr_storage")
910                     .field("ss_len", &self.ss_len)
911                     .field("ss_family", &self.ss_family)
912                     .field("__ss_pad1", &self.__ss_pad1)
913                     .field("__ss_pad2", &self.__ss_pad2)
914                     // FIXME: .field("__ss_pad3", &self.__ss_pad3)
915                     .finish()
916             }
917         }
918         impl ::hash::Hash for sockaddr_storage {
919             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
920                 self.ss_len.hash(state);
921                 self.ss_family.hash(state);
922                 self.__ss_pad1.hash(state);
923                 self.__ss_pad2.hash(state);
924                 self.__ss_pad3.hash(state);
925             }
926         }
927 
928         impl PartialEq for sigevent {
929             fn eq(&self, other: &sigevent) -> bool {
930                 self.sigev_notify == other.sigev_notify
931                     && self.sigev_signo == other.sigev_signo
932                     && self.sigev_value == other.sigev_value
933                     && self.sigev_notify_attributes
934                         == other.sigev_notify_attributes
935             }
936         }
937         impl Eq for sigevent {}
938         impl ::fmt::Debug for sigevent {
939             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
940                 f.debug_struct("sigevent")
941                     .field("sigev_notify", &self.sigev_notify)
942                     .field("sigev_signo", &self.sigev_signo)
943                     .field("sigev_value", &self.sigev_value)
944                     .field("sigev_notify_attributes",
945                            &self.sigev_notify_attributes)
946                     .finish()
947             }
948         }
949         impl ::hash::Hash for sigevent {
950             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
951                 self.sigev_notify.hash(state);
952                 self.sigev_signo.hash(state);
953                 self.sigev_value.hash(state);
954                 self.sigev_notify_attributes.hash(state);
955             }
956         }
957     }
958 }
959 
960 pub const AT_FDCWD: ::c_int = -100;
961 pub const AT_EACCESS: ::c_int = 0x100;
962 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200;
963 pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
964 pub const AT_REMOVEDIR: ::c_int = 0x800;
965 
966 pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
967 pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
968 
969 pub const LC_COLLATE_MASK: ::c_int = 1 << ::LC_COLLATE;
970 pub const LC_CTYPE_MASK: ::c_int = 1 << ::LC_CTYPE;
971 pub const LC_MONETARY_MASK: ::c_int = 1 << ::LC_MONETARY;
972 pub const LC_NUMERIC_MASK: ::c_int = 1 << ::LC_NUMERIC;
973 pub const LC_TIME_MASK: ::c_int = 1 << ::LC_TIME;
974 pub const LC_MESSAGES_MASK: ::c_int = 1 << ::LC_MESSAGES;
975 pub const LC_ALL_MASK: ::c_int = !0;
976 
977 pub const ERA: ::nl_item = 52;
978 pub const ERA_D_FMT: ::nl_item = 53;
979 pub const ERA_D_T_FMT: ::nl_item = 54;
980 pub const ERA_T_FMT: ::nl_item = 55;
981 pub const ALT_DIGITS: ::nl_item = 56;
982 
983 pub const O_CLOEXEC: ::c_int = 0x400000;
984 pub const O_ALT_IO: ::c_int = 0x40000;
985 pub const O_NOSIGPIPE: ::c_int = 0x1000000;
986 pub const O_SEARCH: ::c_int = 0x800000;
987 pub const O_DIRECTORY: ::c_int = 0x200000;
988 pub const O_DIRECT: ::c_int = 0x00080000;
989 pub const O_RSYNC: ::c_int = 0x00020000;
990 
991 pub const MS_SYNC: ::c_int = 0x4;
992 pub const MS_INVALIDATE: ::c_int = 0x2;
993 
994 // Here because they are not present on OpenBSD
995 // (https://github.com/openbsd/src/blob/master/sys/sys/resource.h)
996 pub const RLIMIT_SBSIZE: ::c_int = 9;
997 pub const RLIMIT_AS: ::c_int = 10;
998 pub const RLIMIT_NTHR: ::c_int = 11;
999 
1000 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
1001 pub const RLIM_NLIMITS: ::c_int = 12;
1002 
1003 pub const EIDRM: ::c_int = 82;
1004 pub const ENOMSG: ::c_int = 83;
1005 pub const EOVERFLOW: ::c_int = 84;
1006 pub const EILSEQ: ::c_int = 85;
1007 pub const ENOTSUP: ::c_int = 86;
1008 pub const ECANCELED: ::c_int = 87;
1009 pub const EBADMSG: ::c_int = 88;
1010 pub const ENODATA: ::c_int = 89;
1011 pub const ENOSR: ::c_int = 90;
1012 pub const ENOSTR: ::c_int = 91;
1013 pub const ETIME: ::c_int = 92;
1014 pub const ENOATTR: ::c_int = 93;
1015 pub const EMULTIHOP: ::c_int = 94;
1016 pub const ENOLINK: ::c_int = 95;
1017 pub const EPROTO: ::c_int = 96;
1018 pub const ELAST: ::c_int = 96;
1019 
1020 pub const F_DUPFD_CLOEXEC: ::c_int = 12;
1021 pub const F_CLOSEM: ::c_int = 10;
1022 pub const F_GETNOSIGPIPE: ::c_int = 13;
1023 pub const F_SETNOSIGPIPE: ::c_int = 14;
1024 pub const F_MAXFD: ::c_int = 11;
1025 
1026 pub const IP_RECVDSTADDR: ::c_int = 7;
1027 pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;
1028 pub const IP_RECVIF: ::c_int = 20;
1029 pub const IP_PKTINFO: ::c_int = 25;
1030 pub const IP_RECVPKTINFO: ::c_int = 26;
1031 pub const IPV6_JOIN_GROUP: ::c_int = 12;
1032 pub const IPV6_LEAVE_GROUP: ::c_int = 13;
1033 
1034 pub const TCP_KEEPIDLE: ::c_int = 3;
1035 pub const TCP_KEEPINTVL: ::c_int = 5;
1036 pub const TCP_KEEPCNT: ::c_int = 6;
1037 pub const TCP_KEEPINIT: ::c_int = 7;
1038 pub const TCP_INFO: ::c_int = 9;
1039 pub const TCP_MD5SIG: ::c_int = 0x10;
1040 pub const TCP_CONGCTL: ::c_int = 0x20;
1041 
1042 pub const SOCK_CONN_DGRAM: ::c_int = 6;
1043 pub const SOCK_DCCP: ::c_int = SOCK_CONN_DGRAM;
1044 pub const SOCK_NOSIGPIPE: ::c_int = 0x40000000;
1045 pub const SOCK_FLAGS_MASK: ::c_int = 0xf0000000;
1046 
1047 pub const SO_SNDTIMEO: ::c_int = 0x100b;
1048 pub const SO_RCVTIMEO: ::c_int = 0x100c;
1049 pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
1050 pub const SO_TIMESTAMP: ::c_int = 0x2000;
1051 pub const SO_OVERFLOWED: ::c_int = 0x1009;
1052 pub const SO_NOHEADER: ::c_int = 0x100a;
1053 
1054 // http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/un.h?annotate
1055 pub const LOCAL_OCREDS: ::c_int = 0x0001; // pass credentials to receiver
1056 pub const LOCAL_CONNWAIT: ::c_int = 0x0002; // connects block until accepted
1057 pub const LOCAL_PEEREID: ::c_int = 0x0003; // get peer identification
1058 pub const LOCAL_CREDS: ::c_int = 0x0004; // pass credentials to receiver
1059 
1060 // https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373
1061 pub const IFF_UP: ::c_int = 0x0001; // interface is up
1062 pub const IFF_BROADCAST: ::c_int = 0x0002; // broadcast address valid
1063 pub const IFF_DEBUG: ::c_int = 0x0004; // turn on debugging
1064 pub const IFF_LOOPBACK: ::c_int = 0x0008; // is a loopback net
1065 pub const IFF_POINTOPOINT: ::c_int = 0x0010; // interface is point-to-point link
1066 pub const IFF_NOTRAILERS: ::c_int = 0x0020; // avoid use of trailers
1067 pub const IFF_RUNNING: ::c_int = 0x0040; // resources allocated
1068 pub const IFF_NOARP: ::c_int = 0x0080; // no address resolution protocol
1069 pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets
1070 pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets
1071 pub const IFF_OACTIVE: ::c_int = 0x0400; // transmission in progress
1072 pub const IFF_SIMPLEX: ::c_int = 0x0800; // can't hear own transmissions
1073 pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
1074 pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
1075 pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
1076 pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
1077 
1078 // sys/netinet/in.h
1079 // Protocols (RFC 1700)
1080 // NOTE: These are in addition to the constants defined in src/unix/mod.rs
1081 
1082 // IPPROTO_IP defined in src/unix/mod.rs
1083 /// Hop-by-hop option header
1084 pub const IPPROTO_HOPOPTS: ::c_int = 0;
1085 // IPPROTO_ICMP defined in src/unix/mod.rs
1086 /// group mgmt protocol
1087 pub const IPPROTO_IGMP: ::c_int = 2;
1088 /// gateway^2 (deprecated)
1089 pub const IPPROTO_GGP: ::c_int = 3;
1090 /// for compatibility
1091 pub const IPPROTO_IPIP: ::c_int = 4;
1092 // IPPROTO_TCP defined in src/unix/mod.rs
1093 /// exterior gateway protocol
1094 pub const IPPROTO_EGP: ::c_int = 8;
1095 /// pup
1096 pub const IPPROTO_PUP: ::c_int = 12;
1097 // IPPROTO_UDP defined in src/unix/mod.rs
1098 /// xns idp
1099 pub const IPPROTO_IDP: ::c_int = 22;
1100 /// tp-4 w/ class negotiation
1101 pub const IPPROTO_TP: ::c_int = 29;
1102 /// DCCP
1103 pub const IPPROTO_DCCP: ::c_int = 33;
1104 // IPPROTO_IPV6 defined in src/unix/mod.rs
1105 /// IP6 routing header
1106 pub const IPPROTO_ROUTING: ::c_int = 43;
1107 /// IP6 fragmentation header
1108 pub const IPPROTO_FRAGMENT: ::c_int = 44;
1109 /// resource reservation
1110 pub const IPPROTO_RSVP: ::c_int = 46;
1111 /// General Routing Encap.
1112 pub const IPPROTO_GRE: ::c_int = 47;
1113 /// IP6 Encap Sec. Payload
1114 pub const IPPROTO_ESP: ::c_int = 50;
1115 /// IP6 Auth Header
1116 pub const IPPROTO_AH: ::c_int = 51;
1117 /// IP Mobility RFC 2004
1118 pub const IPPROTO_MOBILE: ::c_int = 55;
1119 /// IPv6 ICMP
1120 pub const IPPROTO_IPV6_ICMP: ::c_int = 58;
1121 // IPPROTO_ICMPV6 defined in src/unix/mod.rs
1122 /// IP6 no next header
1123 pub const IPPROTO_NONE: ::c_int = 59;
1124 /// IP6 destination option
1125 pub const IPPROTO_DSTOPTS: ::c_int = 60;
1126 /// ISO cnlp
1127 pub const IPPROTO_EON: ::c_int = 80;
1128 /// Ethernet-in-IP
1129 pub const IPPROTO_ETHERIP: ::c_int = 97;
1130 /// encapsulation header
1131 pub const IPPROTO_ENCAP: ::c_int = 98;
1132 /// Protocol indep. multicast
1133 pub const IPPROTO_PIM: ::c_int = 103;
1134 /// IP Payload Comp. Protocol
1135 pub const IPPROTO_IPCOMP: ::c_int = 108;
1136 /// VRRP RFC 2338
1137 pub const IPPROTO_VRRP: ::c_int = 112;
1138 /// Common Address Resolution Protocol
1139 pub const IPPROTO_CARP: ::c_int = 112;
1140 /// L2TPv3
1141 // TEMP: Disabled for now; this constant was added to NetBSD on 2017-02-16,
1142 // but isn't yet supported by the NetBSD rumprun kernel image used for
1143 // libc testing.
1144 //pub const IPPROTO_L2TP: ::c_int = 115;
1145 /// SCTP
1146 pub const IPPROTO_SCTP: ::c_int = 132;
1147 /// PFSYNC
1148 pub const IPPROTO_PFSYNC: ::c_int = 240;
1149 pub const IPPROTO_MAX: ::c_int = 256;
1150 
1151 /// last return value of *_input(), meaning "all job for this pkt is done".
1152 pub const IPPROTO_DONE: ::c_int = 257;
1153 
1154 /// sysctl placeholder for (FAST_)IPSEC
1155 pub const CTL_IPPROTO_IPSEC: ::c_int = 258;
1156 
1157 pub const AF_OROUTE: ::c_int = 17;
1158 pub const AF_ARP: ::c_int = 28;
1159 pub const pseudo_AF_KEY: ::c_int = 29;
1160 pub const pseudo_AF_HDRCMPLT: ::c_int = 30;
1161 pub const AF_BLUETOOTH: ::c_int = 31;
1162 pub const AF_IEEE80211: ::c_int = 32;
1163 pub const AF_MPLS: ::c_int = 33;
1164 pub const AF_ROUTE: ::c_int = 34;
1165 pub const NET_RT_DUMP: ::c_int = 1;
1166 pub const NET_RT_FLAGS: ::c_int = 2;
1167 pub const NET_RT_OOOIFLIST: ::c_int = 3;
1168 pub const NET_RT_OOIFLIST: ::c_int = 4;
1169 pub const NET_RT_OIFLIST: ::c_int = 5;
1170 pub const NET_RT_IFLIST: ::c_int = 6;
1171 pub const NET_RT_MAXID: ::c_int = 7;
1172 
1173 pub const PF_OROUTE: ::c_int = AF_OROUTE;
1174 pub const PF_ARP: ::c_int = AF_ARP;
1175 pub const PF_KEY: ::c_int = pseudo_AF_KEY;
1176 pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
1177 pub const PF_MPLS: ::c_int = AF_MPLS;
1178 pub const PF_ROUTE: ::c_int = AF_ROUTE;
1179 
1180 pub const MSG_NBIO: ::c_int = 0x1000;
1181 pub const MSG_WAITFORONE: ::c_int = 0x2000;
1182 pub const MSG_NOTIFICATION: ::c_int = 0x4000;
1183 
1184 pub const SCM_TIMESTAMP: ::c_int = 0x08;
1185 pub const SCM_CREDS: ::c_int = 0x10;
1186 
1187 pub const O_DSYNC: ::c_int = 0x10000;
1188 
1189 pub const MAP_RENAME: ::c_int = 0x20;
1190 pub const MAP_NORESERVE: ::c_int = 0x40;
1191 pub const MAP_HASSEMAPHORE: ::c_int = 0x200;
1192 pub const MAP_WIRED: ::c_int = 0x800;
1193 
1194 pub const DCCP_TYPE_REQUEST: ::c_int = 0;
1195 pub const DCCP_TYPE_RESPONSE: ::c_int = 1;
1196 pub const DCCP_TYPE_DATA: ::c_int = 2;
1197 pub const DCCP_TYPE_ACK: ::c_int = 3;
1198 pub const DCCP_TYPE_DATAACK: ::c_int = 4;
1199 pub const DCCP_TYPE_CLOSEREQ: ::c_int = 5;
1200 pub const DCCP_TYPE_CLOSE: ::c_int = 6;
1201 pub const DCCP_TYPE_RESET: ::c_int = 7;
1202 pub const DCCP_TYPE_MOVE: ::c_int = 8;
1203 
1204 pub const DCCP_FEATURE_CC: ::c_int = 1;
1205 pub const DCCP_FEATURE_ECN: ::c_int = 2;
1206 pub const DCCP_FEATURE_ACKRATIO: ::c_int = 3;
1207 pub const DCCP_FEATURE_ACKVECTOR: ::c_int = 4;
1208 pub const DCCP_FEATURE_MOBILITY: ::c_int = 5;
1209 pub const DCCP_FEATURE_LOSSWINDOW: ::c_int = 6;
1210 pub const DCCP_FEATURE_CONN_NONCE: ::c_int = 8;
1211 pub const DCCP_FEATURE_IDENTREG: ::c_int = 7;
1212 
1213 pub const DCCP_OPT_PADDING: ::c_int = 0;
1214 pub const DCCP_OPT_DATA_DISCARD: ::c_int = 1;
1215 pub const DCCP_OPT_SLOW_RECV: ::c_int = 2;
1216 pub const DCCP_OPT_BUF_CLOSED: ::c_int = 3;
1217 pub const DCCP_OPT_CHANGE_L: ::c_int = 32;
1218 pub const DCCP_OPT_CONFIRM_L: ::c_int = 33;
1219 pub const DCCP_OPT_CHANGE_R: ::c_int = 34;
1220 pub const DCCP_OPT_CONFIRM_R: ::c_int = 35;
1221 pub const DCCP_OPT_INIT_COOKIE: ::c_int = 36;
1222 pub const DCCP_OPT_NDP_COUNT: ::c_int = 37;
1223 pub const DCCP_OPT_ACK_VECTOR0: ::c_int = 38;
1224 pub const DCCP_OPT_ACK_VECTOR1: ::c_int = 39;
1225 pub const DCCP_OPT_RECV_BUF_DROPS: ::c_int = 40;
1226 pub const DCCP_OPT_TIMESTAMP: ::c_int = 41;
1227 pub const DCCP_OPT_TIMESTAMP_ECHO: ::c_int = 42;
1228 pub const DCCP_OPT_ELAPSEDTIME: ::c_int = 43;
1229 pub const DCCP_OPT_DATACHECKSUM: ::c_int = 44;
1230 
1231 pub const DCCP_REASON_UNSPEC: ::c_int = 0;
1232 pub const DCCP_REASON_CLOSED: ::c_int = 1;
1233 pub const DCCP_REASON_INVALID: ::c_int = 2;
1234 pub const DCCP_REASON_OPTION_ERR: ::c_int = 3;
1235 pub const DCCP_REASON_FEA_ERR: ::c_int = 4;
1236 pub const DCCP_REASON_CONN_REF: ::c_int = 5;
1237 pub const DCCP_REASON_BAD_SNAME: ::c_int = 6;
1238 pub const DCCP_REASON_BAD_COOKIE: ::c_int = 7;
1239 pub const DCCP_REASON_INV_MOVE: ::c_int = 8;
1240 pub const DCCP_REASON_UNANSW_CH: ::c_int = 10;
1241 pub const DCCP_REASON_FRUITLESS_NEG: ::c_int = 11;
1242 
1243 pub const DCCP_CCID: ::c_int = 1;
1244 pub const DCCP_CSLEN: ::c_int = 2;
1245 pub const DCCP_MAXSEG: ::c_int = 4;
1246 pub const DCCP_SERVICE: ::c_int = 8;
1247 
1248 pub const DCCP_NDP_LIMIT: ::c_int = 16;
1249 pub const DCCP_SEQ_NUM_LIMIT: ::c_int = 16777216;
1250 pub const DCCP_MAX_OPTIONS: ::c_int = 32;
1251 pub const DCCP_MAX_PKTS: ::c_int = 100;
1252 
1253 pub const _PC_LINK_MAX: ::c_int = 1;
1254 pub const _PC_MAX_CANON: ::c_int = 2;
1255 pub const _PC_MAX_INPUT: ::c_int = 3;
1256 pub const _PC_NAME_MAX: ::c_int = 4;
1257 pub const _PC_PATH_MAX: ::c_int = 5;
1258 pub const _PC_PIPE_BUF: ::c_int = 6;
1259 pub const _PC_CHOWN_RESTRICTED: ::c_int = 7;
1260 pub const _PC_NO_TRUNC: ::c_int = 8;
1261 pub const _PC_VDISABLE: ::c_int = 9;
1262 pub const _PC_SYNC_IO: ::c_int = 10;
1263 pub const _PC_FILESIZEBITS: ::c_int = 11;
1264 pub const _PC_SYMLINK_MAX: ::c_int = 12;
1265 pub const _PC_2_SYMLINKS: ::c_int = 13;
1266 pub const _PC_ACL_EXTENDED: ::c_int = 14;
1267 pub const _PC_MIN_HOLE_SIZE: ::c_int = 15;
1268 
1269 pub const _SC_SYNCHRONIZED_IO: ::c_int = 31;
1270 pub const _SC_IOV_MAX: ::c_int = 32;
1271 pub const _SC_MAPPED_FILES: ::c_int = 33;
1272 pub const _SC_MEMLOCK: ::c_int = 34;
1273 pub const _SC_MEMLOCK_RANGE: ::c_int = 35;
1274 pub const _SC_MEMORY_PROTECTION: ::c_int = 36;
1275 pub const _SC_LOGIN_NAME_MAX: ::c_int = 37;
1276 pub const _SC_MONOTONIC_CLOCK: ::c_int = 38;
1277 pub const _SC_CLK_TCK: ::c_int = 39;
1278 pub const _SC_ATEXIT_MAX: ::c_int = 40;
1279 pub const _SC_THREADS: ::c_int = 41;
1280 pub const _SC_SEMAPHORES: ::c_int = 42;
1281 pub const _SC_BARRIERS: ::c_int = 43;
1282 pub const _SC_TIMERS: ::c_int = 44;
1283 pub const _SC_SPIN_LOCKS: ::c_int = 45;
1284 pub const _SC_READER_WRITER_LOCKS: ::c_int = 46;
1285 pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 47;
1286 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 48;
1287 pub const _SC_CLOCK_SELECTION: ::c_int = 49;
1288 pub const _SC_ASYNCHRONOUS_IO: ::c_int = 50;
1289 pub const _SC_AIO_LISTIO_MAX: ::c_int = 51;
1290 pub const _SC_AIO_MAX: ::c_int = 52;
1291 pub const _SC_MESSAGE_PASSING: ::c_int = 53;
1292 pub const _SC_MQ_OPEN_MAX: ::c_int = 54;
1293 pub const _SC_MQ_PRIO_MAX: ::c_int = 55;
1294 pub const _SC_PRIORITY_SCHEDULING: ::c_int = 56;
1295 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 57;
1296 pub const _SC_THREAD_KEYS_MAX: ::c_int = 58;
1297 pub const _SC_THREAD_STACK_MIN: ::c_int = 59;
1298 pub const _SC_THREAD_THREADS_MAX: ::c_int = 60;
1299 pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 61;
1300 pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 62;
1301 pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 63;
1302 pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 64;
1303 pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 65;
1304 pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 66;
1305 pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 67;
1306 pub const _SC_TTY_NAME_MAX: ::c_int = 68;
1307 pub const _SC_HOST_NAME_MAX: ::c_int = 69;
1308 pub const _SC_PASS_MAX: ::c_int = 70;
1309 pub const _SC_REGEXP: ::c_int = 71;
1310 pub const _SC_SHELL: ::c_int = 72;
1311 pub const _SC_SYMLOOP_MAX: ::c_int = 73;
1312 pub const _SC_V6_ILP32_OFF32: ::c_int = 74;
1313 pub const _SC_V6_ILP32_OFFBIG: ::c_int = 75;
1314 pub const _SC_V6_LP64_OFF64: ::c_int = 76;
1315 pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 77;
1316 pub const _SC_2_PBS: ::c_int = 80;
1317 pub const _SC_2_PBS_ACCOUNTING: ::c_int = 81;
1318 pub const _SC_2_PBS_CHECKPOINT: ::c_int = 82;
1319 pub const _SC_2_PBS_LOCATE: ::c_int = 83;
1320 pub const _SC_2_PBS_MESSAGE: ::c_int = 84;
1321 pub const _SC_2_PBS_TRACK: ::c_int = 85;
1322 pub const _SC_SPAWN: ::c_int = 86;
1323 pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 87;
1324 pub const _SC_TIMER_MAX: ::c_int = 88;
1325 pub const _SC_SEM_NSEMS_MAX: ::c_int = 89;
1326 pub const _SC_CPUTIME: ::c_int = 90;
1327 pub const _SC_THREAD_CPUTIME: ::c_int = 91;
1328 pub const _SC_DELAYTIMER_MAX: ::c_int = 92;
1329 // These two variables will be supported in NetBSD 8.0
1330 // pub const _SC_SIGQUEUE_MAX : ::c_int = 93;
1331 // pub const _SC_REALTIME_SIGNALS : ::c_int = 94;
1332 pub const _SC_PHYS_PAGES: ::c_int = 121;
1333 pub const _SC_NPROCESSORS_CONF: ::c_int = 1001;
1334 pub const _SC_NPROCESSORS_ONLN: ::c_int = 1002;
1335 pub const _SC_SCHED_RT_TS: ::c_int = 2001;
1336 pub const _SC_SCHED_PRI_MIN: ::c_int = 2002;
1337 pub const _SC_SCHED_PRI_MAX: ::c_int = 2003;
1338 
1339 pub const FD_SETSIZE: usize = 0x100;
1340 
1341 pub const ST_NOSUID: ::c_ulong = 8;
1342 
1343 pub const BIOCGRSIG: ::c_ulong = 0x40044272;
1344 pub const BIOCSRSIG: ::c_ulong = 0x80044273;
1345 pub const BIOCSDLT: ::c_ulong = 0x80044278;
1346 pub const BIOCGSEESENT: ::c_ulong = 0x40044276;
1347 pub const BIOCSSEESENT: ::c_ulong = 0x80044277;
1348 
1349 //<sys/timex.h>
1350 pub const NTP_API: ::c_int = 4;
1351 pub const MAXPHASE: ::c_long = 500000000;
1352 pub const MAXFREQ: ::c_long = 500000;
1353 pub const MINSEC: ::c_int = 256;
1354 pub const MAXSEC: ::c_int = 2048;
1355 pub const NANOSECOND: ::c_long = 1000000000;
1356 pub const SCALE_PPM: ::c_int = 65;
1357 pub const MAXTC: ::c_int = 10;
1358 pub const MOD_OFFSET: ::c_uint = 0x0001;
1359 pub const MOD_FREQUENCY: ::c_uint = 0x0002;
1360 pub const MOD_MAXERROR: ::c_uint = 0x0004;
1361 pub const MOD_ESTERROR: ::c_uint = 0x0008;
1362 pub const MOD_STATUS: ::c_uint = 0x0010;
1363 pub const MOD_TIMECONST: ::c_uint = 0x0020;
1364 pub const MOD_PPSMAX: ::c_uint = 0x0040;
1365 pub const MOD_TAI: ::c_uint = 0x0080;
1366 pub const MOD_MICRO: ::c_uint = 0x1000;
1367 pub const MOD_NANO: ::c_uint = 0x2000;
1368 pub const MOD_CLKB: ::c_uint = 0x4000;
1369 pub const MOD_CLKA: ::c_uint = 0x8000;
1370 pub const STA_PLL: ::c_int = 0x0001;
1371 pub const STA_PPSFREQ: ::c_int = 0x0002;
1372 pub const STA_PPSTIME: ::c_int = 0x0004;
1373 pub const STA_FLL: ::c_int = 0x0008;
1374 pub const STA_INS: ::c_int = 0x0010;
1375 pub const STA_DEL: ::c_int = 0x0020;
1376 pub const STA_UNSYNC: ::c_int = 0x0040;
1377 pub const STA_FREQHOLD: ::c_int = 0x0080;
1378 pub const STA_PPSSIGNAL: ::c_int = 0x0100;
1379 pub const STA_PPSJITTER: ::c_int = 0x0200;
1380 pub const STA_PPSWANDER: ::c_int = 0x0400;
1381 pub const STA_PPSERROR: ::c_int = 0x0800;
1382 pub const STA_CLOCKERR: ::c_int = 0x1000;
1383 pub const STA_NANO: ::c_int = 0x2000;
1384 pub const STA_MODE: ::c_int = 0x4000;
1385 pub const STA_CLK: ::c_int = 0x8000;
1386 pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
1387     | STA_PPSJITTER
1388     | STA_PPSWANDER
1389     | STA_PPSERROR
1390     | STA_CLOCKERR
1391     | STA_NANO
1392     | STA_MODE
1393     | STA_CLK;
1394 pub const TIME_OK: ::c_int = 0;
1395 pub const TIME_INS: ::c_int = 1;
1396 pub const TIME_DEL: ::c_int = 2;
1397 pub const TIME_OOP: ::c_int = 3;
1398 pub const TIME_WAIT: ::c_int = 4;
1399 pub const TIME_ERROR: ::c_int = 5;
1400 
1401 cfg_if! {
1402     if #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
1403                  target_arch = "x86", target_arch = "x86_64"))] {
1404         pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t
1405           = pthread_mutex_t {
1406             ptm_magic: 0x33330003,
1407             ptm_errorcheck: 0,
1408             ptm_pad1: [0; 3],
1409             ptm_unused: 0,
1410             ptm_pad2: [0; 3],
1411             ptm_waiters: 0 as *mut _,
1412             ptm_owner: 0,
1413             ptm_recursed: 0,
1414             ptm_spare2: 0 as *mut _,
1415         };
1416     } else {
1417         pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t
1418           = pthread_mutex_t {
1419             ptm_magic: 0x33330003,
1420             ptm_errorcheck: 0,
1421             ptm_unused: 0,
1422             ptm_waiters: 0 as *mut _,
1423             ptm_owner: 0,
1424             ptm_recursed: 0,
1425             ptm_spare2: 0 as *mut _,
1426         };
1427     }
1428 }
1429 
1430 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1431     ptc_magic: 0x55550005,
1432     ptc_lock: 0,
1433     ptc_waiters_first: 0 as *mut _,
1434     ptc_waiters_last: 0 as *mut _,
1435     ptc_mutex: 0 as *mut _,
1436     ptc_private: 0 as *mut _,
1437 };
1438 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1439     ptr_magic: 0x99990009,
1440     ptr_interlock: 0,
1441     ptr_rblocked_first: 0 as *mut _,
1442     ptr_rblocked_last: 0 as *mut _,
1443     ptr_wblocked_first: 0 as *mut _,
1444     ptr_wblocked_last: 0 as *mut _,
1445     ptr_nreaders: 0,
1446     ptr_owner: 0,
1447     ptr_private: 0 as *mut _,
1448 };
1449 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
1450 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
1451 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
1452 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
1453 
1454 pub const EVFILT_AIO: u32 = 2;
1455 pub const EVFILT_PROC: u32 = 4;
1456 pub const EVFILT_READ: u32 = 0;
1457 pub const EVFILT_SIGNAL: u32 = 5;
1458 pub const EVFILT_TIMER: u32 = 6;
1459 pub const EVFILT_VNODE: u32 = 3;
1460 pub const EVFILT_WRITE: u32 = 1;
1461 
1462 pub const EV_ADD: u32 = 0x1;
1463 pub const EV_DELETE: u32 = 0x2;
1464 pub const EV_ENABLE: u32 = 0x4;
1465 pub const EV_DISABLE: u32 = 0x8;
1466 pub const EV_ONESHOT: u32 = 0x10;
1467 pub const EV_CLEAR: u32 = 0x20;
1468 pub const EV_RECEIPT: u32 = 0x40;
1469 pub const EV_DISPATCH: u32 = 0x80;
1470 pub const EV_FLAG1: u32 = 0x2000;
1471 pub const EV_ERROR: u32 = 0x4000;
1472 pub const EV_EOF: u32 = 0x8000;
1473 pub const EV_SYSFLAGS: u32 = 0xf000;
1474 
1475 pub const NOTE_LOWAT: u32 = 0x00000001;
1476 pub const NOTE_DELETE: u32 = 0x00000001;
1477 pub const NOTE_WRITE: u32 = 0x00000002;
1478 pub const NOTE_EXTEND: u32 = 0x00000004;
1479 pub const NOTE_ATTRIB: u32 = 0x00000008;
1480 pub const NOTE_LINK: u32 = 0x00000010;
1481 pub const NOTE_RENAME: u32 = 0x00000020;
1482 pub const NOTE_REVOKE: u32 = 0x00000040;
1483 pub const NOTE_EXIT: u32 = 0x80000000;
1484 pub const NOTE_FORK: u32 = 0x40000000;
1485 pub const NOTE_EXEC: u32 = 0x20000000;
1486 pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1487 pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1488 pub const NOTE_TRACK: u32 = 0x00000001;
1489 pub const NOTE_TRACKERR: u32 = 0x00000002;
1490 pub const NOTE_CHILD: u32 = 0x00000004;
1491 
1492 pub const TMP_MAX: ::c_uint = 308915776;
1493 
1494 pub const NI_MAXHOST: ::socklen_t = 1025;
1495 
1496 pub const RTLD_NOLOAD: ::c_int = 0x2000;
1497 pub const RTLD_LOCAL: ::c_int = 0x200;
1498 
1499 pub const CTL_MAXNAME: ::c_int = 12;
1500 pub const SYSCTL_NAMELEN: ::c_int = 32;
1501 pub const SYSCTL_DEFSIZE: ::c_int = 8;
1502 pub const CTLTYPE_NODE: ::c_int = 1;
1503 pub const CTLTYPE_INT: ::c_int = 2;
1504 pub const CTLTYPE_STRING: ::c_int = 3;
1505 pub const CTLTYPE_QUAD: ::c_int = 4;
1506 pub const CTLTYPE_STRUCT: ::c_int = 5;
1507 pub const CTLTYPE_BOOL: ::c_int = 6;
1508 pub const CTLFLAG_READONLY: ::c_int = 0x00000000;
1509 pub const CTLFLAG_READWRITE: ::c_int = 0x00000070;
1510 pub const CTLFLAG_ANYWRITE: ::c_int = 0x00000080;
1511 pub const CTLFLAG_PRIVATE: ::c_int = 0x00000100;
1512 pub const CTLFLAG_PERMANENT: ::c_int = 0x00000200;
1513 pub const CTLFLAG_OWNDATA: ::c_int = 0x00000400;
1514 pub const CTLFLAG_IMMEDIATE: ::c_int = 0x00000800;
1515 pub const CTLFLAG_HEX: ::c_int = 0x00001000;
1516 pub const CTLFLAG_ROOT: ::c_int = 0x00002000;
1517 pub const CTLFLAG_ANYNUMBER: ::c_int = 0x00004000;
1518 pub const CTLFLAG_HIDDEN: ::c_int = 0x00008000;
1519 pub const CTLFLAG_ALIAS: ::c_int = 0x00010000;
1520 pub const CTLFLAG_MMAP: ::c_int = 0x00020000;
1521 pub const CTLFLAG_OWNDESC: ::c_int = 0x00040000;
1522 pub const CTLFLAG_UNSIGNED: ::c_int = 0x00080000;
1523 pub const SYSCTL_VERS_MASK: ::c_int = 0xff000000;
1524 pub const SYSCTL_VERS_0: ::c_int = 0x00000000;
1525 pub const SYSCTL_VERS_1: ::c_int = 0x01000000;
1526 pub const SYSCTL_VERSION: ::c_int = SYSCTL_VERS_1;
1527 pub const CTL_EOL: ::c_int = -1;
1528 pub const CTL_QUERY: ::c_int = -2;
1529 pub const CTL_CREATE: ::c_int = -3;
1530 pub const CTL_CREATESYM: ::c_int = -4;
1531 pub const CTL_DESTROY: ::c_int = -5;
1532 pub const CTL_MMAP: ::c_int = -6;
1533 pub const CTL_DESCRIBE: ::c_int = -7;
1534 pub const CTL_UNSPEC: ::c_int = 0;
1535 pub const CTL_KERN: ::c_int = 1;
1536 pub const CTL_VM: ::c_int = 2;
1537 pub const CTL_VFS: ::c_int = 3;
1538 pub const CTL_NET: ::c_int = 4;
1539 pub const CTL_DEBUG: ::c_int = 5;
1540 pub const CTL_HW: ::c_int = 6;
1541 pub const CTL_MACHDEP: ::c_int = 7;
1542 pub const CTL_USER: ::c_int = 8;
1543 pub const CTL_DDB: ::c_int = 9;
1544 pub const CTL_PROC: ::c_int = 10;
1545 pub const CTL_VENDOR: ::c_int = 11;
1546 pub const CTL_EMUL: ::c_int = 12;
1547 pub const CTL_SECURITY: ::c_int = 13;
1548 pub const CTL_MAXID: ::c_int = 14;
1549 pub const KERN_OSTYPE: ::c_int = 1;
1550 pub const KERN_OSRELEASE: ::c_int = 2;
1551 pub const KERN_OSREV: ::c_int = 3;
1552 pub const KERN_VERSION: ::c_int = 4;
1553 pub const KERN_MAXVNODES: ::c_int = 5;
1554 pub const KERN_MAXPROC: ::c_int = 6;
1555 pub const KERN_MAXFILES: ::c_int = 7;
1556 pub const KERN_ARGMAX: ::c_int = 8;
1557 pub const KERN_SECURELVL: ::c_int = 9;
1558 pub const KERN_HOSTNAME: ::c_int = 10;
1559 pub const KERN_HOSTID: ::c_int = 11;
1560 pub const KERN_CLOCKRATE: ::c_int = 12;
1561 pub const KERN_VNODE: ::c_int = 13;
1562 pub const KERN_PROC: ::c_int = 14;
1563 pub const KERN_FILE: ::c_int = 15;
1564 pub const KERN_PROF: ::c_int = 16;
1565 pub const KERN_POSIX1: ::c_int = 17;
1566 pub const KERN_NGROUPS: ::c_int = 18;
1567 pub const KERN_JOB_CONTROL: ::c_int = 19;
1568 pub const KERN_SAVED_IDS: ::c_int = 20;
1569 pub const KERN_OBOOTTIME: ::c_int = 21;
1570 pub const KERN_DOMAINNAME: ::c_int = 22;
1571 pub const KERN_MAXPARTITIONS: ::c_int = 23;
1572 pub const KERN_RAWPARTITION: ::c_int = 24;
1573 pub const KERN_NTPTIME: ::c_int = 25;
1574 pub const KERN_TIMEX: ::c_int = 26;
1575 pub const KERN_AUTONICETIME: ::c_int = 27;
1576 pub const KERN_AUTONICEVAL: ::c_int = 28;
1577 pub const KERN_RTC_OFFSET: ::c_int = 29;
1578 pub const KERN_ROOT_DEVICE: ::c_int = 30;
1579 pub const KERN_MSGBUFSIZE: ::c_int = 31;
1580 pub const KERN_FSYNC: ::c_int = 32;
1581 pub const KERN_OLDSYSVMSG: ::c_int = 33;
1582 pub const KERN_OLDSYSVSEM: ::c_int = 34;
1583 pub const KERN_OLDSYSVSHM: ::c_int = 35;
1584 pub const KERN_OLDSHORTCORENAME: ::c_int = 36;
1585 pub const KERN_SYNCHRONIZED_IO: ::c_int = 37;
1586 pub const KERN_IOV_MAX: ::c_int = 38;
1587 pub const KERN_MBUF: ::c_int = 39;
1588 pub const KERN_MAPPED_FILES: ::c_int = 40;
1589 pub const KERN_MEMLOCK: ::c_int = 41;
1590 pub const KERN_MEMLOCK_RANGE: ::c_int = 42;
1591 pub const KERN_MEMORY_PROTECTION: ::c_int = 43;
1592 pub const KERN_LOGIN_NAME_MAX: ::c_int = 44;
1593 pub const KERN_DEFCORENAME: ::c_int = 45;
1594 pub const KERN_LOGSIGEXIT: ::c_int = 46;
1595 pub const KERN_PROC2: ::c_int = 47;
1596 pub const KERN_PROC_ARGS: ::c_int = 48;
1597 pub const KERN_FSCALE: ::c_int = 49;
1598 pub const KERN_CCPU: ::c_int = 50;
1599 pub const KERN_CP_TIME: ::c_int = 51;
1600 pub const KERN_OLDSYSVIPC_INFO: ::c_int = 52;
1601 pub const KERN_MSGBUF: ::c_int = 53;
1602 pub const KERN_CONSDEV: ::c_int = 54;
1603 pub const KERN_MAXPTYS: ::c_int = 55;
1604 pub const KERN_PIPE: ::c_int = 56;
1605 pub const KERN_MAXPHYS: ::c_int = 57;
1606 pub const KERN_SBMAX: ::c_int = 58;
1607 pub const KERN_TKSTAT: ::c_int = 59;
1608 pub const KERN_MONOTONIC_CLOCK: ::c_int = 60;
1609 pub const KERN_URND: ::c_int = 61;
1610 pub const KERN_LABELSECTOR: ::c_int = 62;
1611 pub const KERN_LABELOFFSET: ::c_int = 63;
1612 pub const KERN_LWP: ::c_int = 64;
1613 pub const KERN_FORKFSLEEP: ::c_int = 65;
1614 pub const KERN_POSIX_THREADS: ::c_int = 66;
1615 pub const KERN_POSIX_SEMAPHORES: ::c_int = 67;
1616 pub const KERN_POSIX_BARRIERS: ::c_int = 68;
1617 pub const KERN_POSIX_TIMERS: ::c_int = 69;
1618 pub const KERN_POSIX_SPIN_LOCKS: ::c_int = 70;
1619 pub const KERN_POSIX_READER_WRITER_LOCKS: ::c_int = 71;
1620 pub const KERN_DUMP_ON_PANIC: ::c_int = 72;
1621 pub const KERN_SOMAXKVA: ::c_int = 73;
1622 pub const KERN_ROOT_PARTITION: ::c_int = 74;
1623 pub const KERN_DRIVERS: ::c_int = 75;
1624 pub const KERN_BUF: ::c_int = 76;
1625 pub const KERN_FILE2: ::c_int = 77;
1626 pub const KERN_VERIEXEC: ::c_int = 78;
1627 pub const KERN_CP_ID: ::c_int = 79;
1628 pub const KERN_HARDCLOCK_TICKS: ::c_int = 80;
1629 pub const KERN_ARND: ::c_int = 81;
1630 pub const KERN_SYSVIPC: ::c_int = 82;
1631 pub const KERN_BOOTTIME: ::c_int = 83;
1632 pub const KERN_EVCNT: ::c_int = 84;
1633 pub const KERN_MAXID: ::c_int = 85;
1634 pub const KERN_PROC_ALL: ::c_int = 0;
1635 pub const KERN_PROC_PID: ::c_int = 1;
1636 pub const KERN_PROC_PGRP: ::c_int = 2;
1637 pub const KERN_PROC_SESSION: ::c_int = 3;
1638 pub const KERN_PROC_TTY: ::c_int = 4;
1639 pub const KERN_PROC_UID: ::c_int = 5;
1640 pub const KERN_PROC_RUID: ::c_int = 6;
1641 pub const KERN_PROC_GID: ::c_int = 7;
1642 pub const KERN_PROC_RGID: ::c_int = 8;
1643 pub const KERN_PROC_ARGV: ::c_int = 1;
1644 pub const KERN_PROC_NARGV: ::c_int = 2;
1645 pub const KERN_PROC_ENV: ::c_int = 3;
1646 pub const KERN_PROC_NENV: ::c_int = 4;
1647 pub const KERN_PROC_PATHNAME: ::c_int = 5;
1648 
1649 pub const EAI_AGAIN: ::c_int = 2;
1650 pub const EAI_BADFLAGS: ::c_int = 3;
1651 pub const EAI_FAIL: ::c_int = 4;
1652 pub const EAI_FAMILY: ::c_int = 5;
1653 pub const EAI_MEMORY: ::c_int = 6;
1654 pub const EAI_NODATA: ::c_int = 7;
1655 pub const EAI_NONAME: ::c_int = 8;
1656 pub const EAI_SERVICE: ::c_int = 9;
1657 pub const EAI_SOCKTYPE: ::c_int = 10;
1658 pub const EAI_SYSTEM: ::c_int = 11;
1659 pub const EAI_OVERFLOW: ::c_int = 14;
1660 
1661 pub const AIO_CANCELED: ::c_int = 1;
1662 pub const AIO_NOTCANCELED: ::c_int = 2;
1663 pub const AIO_ALLDONE: ::c_int = 3;
1664 pub const LIO_NOP: ::c_int = 0;
1665 pub const LIO_WRITE: ::c_int = 1;
1666 pub const LIO_READ: ::c_int = 2;
1667 pub const LIO_WAIT: ::c_int = 1;
1668 pub const LIO_NOWAIT: ::c_int = 0;
1669 
1670 pub const SIGEV_NONE: ::c_int = 0;
1671 pub const SIGEV_SIGNAL: ::c_int = 1;
1672 pub const SIGEV_THREAD: ::c_int = 2;
1673 
1674 pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED
1675 pub const WCONTINUED: ::c_int = 0x00000010;
1676 pub const WEXITED: ::c_int = 0x000000020;
1677 pub const WNOWAIT: ::c_int = 0x00010000;
1678 
1679 pub const P_ALL: idtype_t = 0;
1680 pub const P_PID: idtype_t = 1;
1681 pub const P_PGID: idtype_t = 4;
1682 
1683 pub const UTIME_OMIT: c_long = 1073741822;
1684 pub const UTIME_NOW: c_long = 1073741823;
1685 
1686 pub const B460800: ::speed_t = 460800;
1687 pub const B921600: ::speed_t = 921600;
1688 
1689 pub const ONOCR: ::tcflag_t = 0x20;
1690 pub const ONLRET: ::tcflag_t = 0x40;
1691 pub const CDTRCTS: ::tcflag_t = 0x00020000;
1692 pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS;
1693 
1694 // pub const _PATH_UTMPX: &[::c_char; 14] = b"/var/run/utmpx";
1695 // pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx";
1696 // pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx";
1697 // pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update";
1698 pub const UT_NAMESIZE: usize = 8;
1699 pub const UT_LINESIZE: usize = 8;
1700 pub const UT_HOSTSIZE: usize = 16;
1701 pub const _UTX_USERSIZE: usize = 32;
1702 pub const _UTX_LINESIZE: usize = 32;
1703 pub const _UTX_PADSIZE: usize = 40;
1704 pub const _UTX_IDSIZE: usize = 4;
1705 pub const _UTX_HOSTSIZE: usize = 256;
1706 pub const EMPTY: u16 = 0;
1707 pub const RUN_LVL: u16 = 1;
1708 pub const BOOT_TIME: u16 = 2;
1709 pub const OLD_TIME: u16 = 3;
1710 pub const NEW_TIME: u16 = 4;
1711 pub const INIT_PROCESS: u16 = 5;
1712 pub const LOGIN_PROCESS: u16 = 6;
1713 pub const USER_PROCESS: u16 = 7;
1714 pub const DEAD_PROCESS: u16 = 8;
1715 pub const ACCOUNTING: u16 = 9;
1716 pub const SIGNATURE: u16 = 10;
1717 pub const DOWN_TIME: u16 = 11;
1718 
1719 pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
1720 pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
1721 
1722 // Uncomment on next NetBSD release
1723 // pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
1724 // pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
1725 pub const OFIOGETBMAP: ::c_ulong = 0xc004667a;
1726 pub const FIOGETBMAP: ::c_ulong = 0xc008667a;
1727 pub const FIONWRITE: ::c_ulong = 0x40046679;
1728 pub const FIONSPACE: ::c_ulong = 0x40046678;
1729 pub const FIBMAP: ::c_ulong = 0xc008667a;
1730 
1731 pub const SIGSTKSZ: ::size_t = 40960;
1732 
1733 pub const REG_ENOSYS: ::c_int = 17;
1734 
1735 pub const PT_DUMPCORE: ::c_int = 12;
1736 pub const PT_LWPINFO: ::c_int = 13;
1737 pub const PT_SYSCALL: ::c_int = 14;
1738 pub const PT_SYSCALLEMU: ::c_int = 15;
1739 pub const PT_SET_EVENT_MASK: ::c_int = 16;
1740 pub const PT_GET_EVENT_MASK: ::c_int = 17;
1741 pub const PT_GET_PROCESS_STATE: ::c_int = 18;
1742 pub const PT_FIRSTMACH: ::c_int = 32;
1743 
1744 // Flags for chflags(2)
1745 pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
1746 pub const SF_LOG: ::c_ulong = 0x00400000;
1747 pub const SF_SNAPINVAL: ::c_ulong = 0x00800000;
1748 
1749 const_fn! {
1750     {const} fn _ALIGN(p: usize) -> usize {
1751         (p + _ALIGNBYTES) & !_ALIGNBYTES
1752     }
1753 }
1754 
1755 f! {
1756     pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
1757         (cmsg as *mut ::c_uchar)
1758             .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
1759     }
1760 
1761     pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1762         _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
1763     }
1764 
1765     pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
1766         -> *mut ::cmsghdr
1767     {
1768         if cmsg.is_null() {
1769             return ::CMSG_FIRSTHDR(mhdr);
1770         };
1771         let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
1772             + _ALIGN(::mem::size_of::<::cmsghdr>());
1773         let max = (*mhdr).msg_control as usize
1774             + (*mhdr).msg_controllen as usize;
1775         if next > max {
1776             0 as *mut ::cmsghdr
1777         } else {
1778             (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
1779                 as *mut ::cmsghdr
1780         }
1781     }
1782 
1783     pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
1784         (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
1785             as ::c_uint
1786     }
1787 
1788     // dirfd() is a macro on netbsd to access
1789     // the first field of the struct where dirp points to:
1790     // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
1791     pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
1792         *(dirp as *const ::c_int)
1793     }
1794 
1795     pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
1796         let ngrps = if ngrps > 0 {
1797             ngrps - 1
1798         } else {
1799             0
1800         };
1801         ::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
1802     }
1803 }
1804 
1805 safe_f! {
1806     pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
1807         status >> 8
1808     }
1809 
1810     pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
1811         (status & 0o177) != 0o177 && (status & 0o177) != 0
1812     }
1813 
1814     pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
1815         (status & 0o177) == 0o177
1816     }
1817 
1818     pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
1819         status == 0xffff
1820     }
1821 }
1822 
1823 extern "C" {
ntp_adjtime(buf: *mut timex) -> ::c_int1824     pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
ntp_gettime(buf: *mut ntptimeval) -> ::c_int1825     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_int1826     pub fn clock_nanosleep(
1827         clk_id: ::clockid_t,
1828         flags: ::c_int,
1829         rqtp: *const ::timespec,
1830         rmtp: *mut ::timespec,
1831     ) -> ::c_int;
1832 }
1833 
1834 #[link(name = "rt")]
1835 extern "C" {
aio_read(aiocbp: *mut aiocb) -> ::c_int1836     pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
aio_write(aiocbp: *mut aiocb) -> ::c_int1837     pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int1838     pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
aio_error(aiocbp: *const aiocb) -> ::c_int1839     pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
aio_return(aiocbp: *mut aiocb) -> ::ssize_t1840     pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
1841     #[link_name = "__aio_suspend50"]
aio_suspend( aiocb_list: *const *const aiocb, nitems: ::c_int, timeout: *const ::timespec, ) -> ::c_int1842     pub fn aio_suspend(
1843         aiocb_list: *const *const aiocb,
1844         nitems: ::c_int,
1845         timeout: *const ::timespec,
1846     ) -> ::c_int;
aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int1847     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_int1848     pub fn lio_listio(
1849         mode: ::c_int,
1850         aiocb_list: *const *mut aiocb,
1851         nitems: ::c_int,
1852         sevp: *mut sigevent,
1853     ) -> ::c_int;
1854 }
1855 
1856 extern "C" {
chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int1857     pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int1858     pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int1859     pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
1860 
extattr_delete_fd( fd: ::c_int, attrnamespace: ::c_int, attrname: *const ::c_char, ) -> ::c_int1861     pub fn extattr_delete_fd(
1862         fd: ::c_int,
1863         attrnamespace: ::c_int,
1864         attrname: *const ::c_char,
1865     ) -> ::c_int;
extattr_delete_file( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, ) -> ::c_int1866     pub fn extattr_delete_file(
1867         path: *const ::c_char,
1868         attrnamespace: ::c_int,
1869         attrname: *const ::c_char,
1870     ) -> ::c_int;
extattr_delete_link( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, ) -> ::c_int1871     pub fn extattr_delete_link(
1872         path: *const ::c_char,
1873         attrnamespace: ::c_int,
1874         attrname: *const ::c_char,
1875     ) -> ::c_int;
extattr_get_fd( fd: ::c_int, attrnamespace: ::c_int, attrname: *const ::c_char, data: *mut ::c_void, nbytes: ::size_t, ) -> ::ssize_t1876     pub fn extattr_get_fd(
1877         fd: ::c_int,
1878         attrnamespace: ::c_int,
1879         attrname: *const ::c_char,
1880         data: *mut ::c_void,
1881         nbytes: ::size_t,
1882     ) -> ::ssize_t;
extattr_get_file( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, data: *mut ::c_void, nbytes: ::size_t, ) -> ::ssize_t1883     pub fn extattr_get_file(
1884         path: *const ::c_char,
1885         attrnamespace: ::c_int,
1886         attrname: *const ::c_char,
1887         data: *mut ::c_void,
1888         nbytes: ::size_t,
1889     ) -> ::ssize_t;
extattr_get_link( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, data: *mut ::c_void, nbytes: ::size_t, ) -> ::ssize_t1890     pub fn extattr_get_link(
1891         path: *const ::c_char,
1892         attrnamespace: ::c_int,
1893         attrname: *const ::c_char,
1894         data: *mut ::c_void,
1895         nbytes: ::size_t,
1896     ) -> ::ssize_t;
extattr_namespace_to_string( attrnamespace: ::c_int, string: *mut *mut ::c_char, ) -> ::c_int1897     pub fn extattr_namespace_to_string(
1898         attrnamespace: ::c_int,
1899         string: *mut *mut ::c_char,
1900     ) -> ::c_int;
extattr_set_fd( fd: ::c_int, attrnamespace: ::c_int, attrname: *const ::c_char, data: *const ::c_void, nbytes: ::size_t, ) -> ::c_int1901     pub fn extattr_set_fd(
1902         fd: ::c_int,
1903         attrnamespace: ::c_int,
1904         attrname: *const ::c_char,
1905         data: *const ::c_void,
1906         nbytes: ::size_t,
1907     ) -> ::c_int;
extattr_set_file( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, data: *const ::c_void, nbytes: ::size_t, ) -> ::c_int1908     pub fn extattr_set_file(
1909         path: *const ::c_char,
1910         attrnamespace: ::c_int,
1911         attrname: *const ::c_char,
1912         data: *const ::c_void,
1913         nbytes: ::size_t,
1914     ) -> ::c_int;
extattr_set_link( path: *const ::c_char, attrnamespace: ::c_int, attrname: *const ::c_char, data: *const ::c_void, nbytes: ::size_t, ) -> ::c_int1915     pub fn extattr_set_link(
1916         path: *const ::c_char,
1917         attrnamespace: ::c_int,
1918         attrname: *const ::c_char,
1919         data: *const ::c_void,
1920         nbytes: ::size_t,
1921     ) -> ::c_int;
extattr_string_to_namespace( string: *const ::c_char, attrnamespace: *mut ::c_int, ) -> ::c_int1922     pub fn extattr_string_to_namespace(
1923         string: *const ::c_char,
1924         attrnamespace: *mut ::c_int,
1925     ) -> ::c_int;
1926 
1927     #[link_name = "__lutimes50"]
lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int1928     pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
1929     #[link_name = "__gettimeofday50"]
gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int1930     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_int1931     pub fn getnameinfo(
1932         sa: *const ::sockaddr,
1933         salen: ::socklen_t,
1934         host: *mut ::c_char,
1935         hostlen: ::socklen_t,
1936         serv: *mut ::c_char,
1937         sevlen: ::socklen_t,
1938         flags: ::c_int,
1939     ) -> ::c_int;
mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int1940     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_int1941     pub fn sysctl(
1942         name: *const ::c_int,
1943         namelen: ::c_uint,
1944         oldp: *mut ::c_void,
1945         oldlenp: *mut ::size_t,
1946         newp: *const ::c_void,
1947         newlen: ::size_t,
1948     ) -> ::c_int;
sysctlbyname( name: *const ::c_char, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *const ::c_void, newlen: ::size_t, ) -> ::c_int1949     pub fn sysctlbyname(
1950         name: *const ::c_char,
1951         oldp: *mut ::c_void,
1952         oldlenp: *mut ::size_t,
1953         newp: *const ::c_void,
1954         newlen: ::size_t,
1955     ) -> ::c_int;
1956     #[link_name = "__kevent50"]
kevent( kq: ::c_int, changelist: *const ::kevent, nchanges: ::size_t, eventlist: *mut ::kevent, nevents: ::size_t, timeout: *const ::timespec, ) -> ::c_int1957     pub fn kevent(
1958         kq: ::c_int,
1959         changelist: *const ::kevent,
1960         nchanges: ::size_t,
1961         eventlist: *mut ::kevent,
1962         nevents: ::size_t,
1963         timeout: *const ::timespec,
1964     ) -> ::c_int;
1965     #[link_name = "__mount50"]
mount( src: *const ::c_char, target: *const ::c_char, flags: ::c_int, data: *mut ::c_void, size: ::size_t, ) -> ::c_int1966     pub fn mount(
1967         src: *const ::c_char,
1968         target: *const ::c_char,
1969         flags: ::c_int,
1970         data: *mut ::c_void,
1971         size: ::size_t,
1972     ) -> ::c_int;
mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t1973     pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
mq_close(mqd: ::mqd_t) -> ::c_int1974     pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int1975     pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) -> ::c_int1976     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_t1977     pub fn mq_receive(
1978         mqd: ::mqd_t,
1979         msg_ptr: *mut ::c_char,
1980         msg_len: ::size_t,
1981         msg_prio: *mut ::c_uint,
1982     ) -> ::ssize_t;
mq_send( mqd: ::mqd_t, msg_ptr: *const ::c_char, msg_len: ::size_t, msg_prio: ::c_uint, ) -> ::c_int1983     pub fn mq_send(
1984         mqd: ::mqd_t,
1985         msg_ptr: *const ::c_char,
1986         msg_len: ::size_t,
1987         msg_prio: ::c_uint,
1988     ) -> ::c_int;
mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int1989     pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int;
1990     #[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_t1991     pub fn mq_timedreceive(
1992         mqd: ::mqd_t,
1993         msg_ptr: *mut ::c_char,
1994         msg_len: ::size_t,
1995         msg_prio: *mut ::c_uint,
1996         abs_timeout: *const ::timespec,
1997     ) -> ::ssize_t;
1998     #[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_int1999     pub fn mq_timedsend(
2000         mqd: ::mqd_t,
2001         msg_ptr: *const ::c_char,
2002         msg_len: ::size_t,
2003         msg_prio: ::c_uint,
2004         abs_timeout: *const ::timespec,
2005     ) -> ::c_int;
mq_unlink(name: *const ::c_char) -> ::c_int2006     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_int2007     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_int2008     pub fn pthread_setname_np(
2009         t: ::pthread_t,
2010         name: *const ::c_char,
2011         arg: *const ::c_void,
2012     ) -> ::c_int;
pthread_attr_get_np(thread: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int2013     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_int2014     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_int2015     pub fn pthread_attr_getguardsize(
2016         attr: *const ::pthread_attr_t,
2017         guardsize: *mut ::size_t,
2018     ) -> ::c_int;
pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, stacksize: *mut ::size_t, ) -> ::c_int2019     pub fn pthread_attr_getstack(
2020         attr: *const ::pthread_attr_t,
2021         stackaddr: *mut *mut ::c_void,
2022         stacksize: *mut ::size_t,
2023     ) -> ::c_int;
2024     #[link_name = "__sigtimedwait50"]
sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, timeout: *const ::timespec, ) -> ::c_int2025     pub fn sigtimedwait(
2026         set: *const sigset_t,
2027         info: *mut siginfo_t,
2028         timeout: *const ::timespec,
2029     ) -> ::c_int;
sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int2030     pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int;
duplocale(base: ::locale_t) -> ::locale_t2031     pub fn duplocale(base: ::locale_t) -> ::locale_t;
freelocale(loc: ::locale_t)2032     pub fn freelocale(loc: ::locale_t);
localeconv_l(loc: ::locale_t) -> *mut lconv2033     pub fn localeconv_l(loc: ::locale_t) -> *mut lconv;
newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t2034     pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
2035     #[link_name = "__settimeofday50"]
settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int2036     pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int;
2037 
dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int2038     pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
2039 
sendmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_int, ) -> ::c_int2040     pub fn sendmmsg(
2041         sockfd: ::c_int,
2042         msgvec: *mut ::mmsghdr,
2043         vlen: ::c_uint,
2044         flags: ::c_int,
2045     ) -> ::c_int;
recvmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_int, timeout: *mut ::timespec, ) -> ::c_int2046     pub fn recvmmsg(
2047         sockfd: ::c_int,
2048         msgvec: *mut ::mmsghdr,
2049         vlen: ::c_uint,
2050         flags: ::c_int,
2051         timeout: *mut ::timespec,
2052     ) -> ::c_int;
2053 
_lwp_self() -> lwpid_t2054     pub fn _lwp_self() -> lwpid_t;
memmem( haystack: *const ::c_void, haystacklen: ::size_t, needle: *const ::c_void, needlelen: ::size_t, ) -> *mut ::c_void2055     pub fn memmem(
2056         haystack: *const ::c_void,
2057         haystacklen: ::size_t,
2058         needle: *const ::c_void,
2059         needlelen: ::size_t,
2060     ) -> *mut ::c_void;
2061 
2062     // link.h
2063 
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_int2064     pub fn dl_iterate_phdr(
2065         callback: ::Option<
2066             unsafe extern "C" fn(
2067                 info: *mut dl_phdr_info,
2068                 size: usize,
2069                 data: *mut ::c_void,
2070             ) -> ::c_int,
2071         >,
2072         data: *mut ::c_void,
2073     ) -> ::c_int;
2074 
iconv_open(tocode: *const ::c_char, fromcode: *const ::c_char) -> iconv_t2075     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_t2076     pub fn iconv(
2077         cd: iconv_t,
2078         inbuf: *mut *mut ::c_char,
2079         inbytesleft: *mut ::size_t,
2080         outbuf: *mut *mut ::c_char,
2081         outbytesleft: *mut ::size_t,
2082     ) -> ::size_t;
iconv_close(cd: iconv_t) -> ::c_int2083     pub fn iconv_close(cd: iconv_t) -> ::c_int;
2084 }
2085 
2086 #[link(name = "util")]
2087 extern "C" {
2088     #[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_int2089     pub fn getpwent_r(
2090         pwd: *mut ::passwd,
2091         buf: *mut ::c_char,
2092         buflen: ::size_t,
2093         result: *mut *mut ::passwd,
2094     ) -> ::c_int;
getgrent_r( grp: *mut ::group, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int2095     pub fn getgrent_r(
2096         grp: *mut ::group,
2097         buf: *mut ::c_char,
2098         buflen: ::size_t,
2099         result: *mut *mut ::group,
2100     ) -> ::c_int;
2101 
updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int2102     pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int;
getlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> *mut lastlogx2103     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_int2104     pub fn updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int;
utmpxname(file: *const ::c_char) -> ::c_int2105     pub fn utmpxname(file: *const ::c_char) -> ::c_int;
getutxent() -> *mut utmpx2106     pub fn getutxent() -> *mut utmpx;
getutxid(ut: *const utmpx) -> *mut utmpx2107     pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
getutxline(ut: *const utmpx) -> *mut utmpx2108     pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
pututxline(ut: *const utmpx) -> *mut utmpx2109     pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
setutxent()2110     pub fn setutxent();
endutxent()2111     pub fn endutxent();
2112 
getutmp(ux: *const utmpx, u: *mut utmp)2113     pub fn getutmp(ux: *const utmpx, u: *mut utmp);
getutmpx(u: *const utmp, ux: *mut utmpx)2114     pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
2115 
utpname(file: *const ::c_char) -> ::c_int2116     pub fn utpname(file: *const ::c_char) -> ::c_int;
setutent()2117     pub fn setutent();
endutent()2118     pub fn endutent();
getutent() -> *mut utmp2119     pub fn getutent() -> *mut utmp;
2120 }
2121 
2122 cfg_if! {
2123     if #[cfg(target_arch = "aarch64")] {
2124         mod aarch64;
2125         pub use self::aarch64::*;
2126     } else if #[cfg(target_arch = "arm")] {
2127         mod arm;
2128         pub use self::arm::*;
2129     } else if #[cfg(target_arch = "powerpc")] {
2130         mod powerpc;
2131         pub use self::powerpc::*;
2132     } else if #[cfg(target_arch = "sparc64")] {
2133         mod sparc64;
2134         pub use self::sparc64::*;
2135     } else if #[cfg(target_arch = "x86_64")] {
2136         mod x86_64;
2137         pub use self::x86_64::*;
2138     } else if #[cfg(target_arch = "x86")] {
2139         mod x86;
2140         pub use self::x86::*;
2141     } else {
2142         // Unknown target_arch
2143     }
2144 }
2145