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