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