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