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 sigset_t {
50         __bits: [u32; 4],
51     }
52 
53     pub struct stat {
54         pub st_dev: ::dev_t,
55         pub st_mode: ::mode_t,
56         pub st_ino: ::ino_t,
57         pub st_nlink: ::nlink_t,
58         pub st_uid: ::uid_t,
59         pub st_gid: ::gid_t,
60         pub st_rdev: ::dev_t,
61         pub st_atime: ::time_t,
62         pub st_atimensec: ::c_long,
63         pub st_mtime: ::time_t,
64         pub st_mtimensec: ::c_long,
65         pub st_ctime: ::time_t,
66         pub st_ctimensec: ::c_long,
67         pub st_birthtime: ::time_t,
68         pub st_birthtimensec: ::c_long,
69         pub st_size: ::off_t,
70         pub st_blocks: ::blkcnt_t,
71         pub st_blksize: ::blksize_t,
72         pub st_flags: u32,
73         pub st_gen: u32,
74         pub st_spare: [u32; 2],
75     }
76 
77      pub struct addrinfo {
78         pub ai_flags: ::c_int,
79         pub ai_family: ::c_int,
80         pub ai_socktype: ::c_int,
81         pub ai_protocol: ::c_int,
82         pub ai_addrlen: ::socklen_t,
83         pub ai_canonname: *mut ::c_char,
84         pub ai_addr: *mut ::sockaddr,
85         pub ai_next: *mut ::addrinfo,
86     }
87 
88     pub struct siginfo_t {
89         pub si_signo: ::c_int,
90         pub si_code: ::c_int,
91         pub si_errno: ::c_int,
92         __pad1: ::c_int,
93         pub si_addr: *mut ::c_void,
94         __pad2: [u64; 13],
95     }
96 
97     pub struct pthread_attr_t {
98         pta_magic: ::c_uint,
99         pta_flags: ::c_int,
100         pta_private: *mut ::c_void,
101     }
102 
103     pub struct pthread_mutex_t {
104         ptm_magic: ::c_uint,
105         ptm_errorcheck: __pthread_spin_t,
106         #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
107                   target_arch = "x86", target_arch = "x86_64"))]
108         ptm_pad1: [u8; 3],
109         // actually a union with a non-unused, 0-initialized field
110         ptm_unused: __pthread_spin_t,
111         #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
112                   target_arch = "x86", target_arch = "x86_64"))]
113         ptm_pad2: [u8; 3],
114         ptm_owner: ::pthread_t,
115         ptm_waiters: *mut u8,
116         ptm_recursed: ::c_uint,
117         ptm_spare2: *mut ::c_void,
118     }
119 
120     pub struct pthread_mutexattr_t {
121         ptma_magic: ::c_uint,
122         ptma_private: *mut ::c_void,
123     }
124 
125     pub struct pthread_rwlockattr_t {
126         ptra_magic: ::c_uint,
127         ptra_private: *mut ::c_void,
128     }
129 
130     pub struct pthread_cond_t {
131         ptc_magic: ::c_uint,
132         ptc_lock: __pthread_spin_t,
133         ptc_waiters_first: *mut u8,
134         ptc_waiters_last: *mut u8,
135         ptc_mutex: *mut ::pthread_mutex_t,
136         ptc_private: *mut ::c_void,
137     }
138 
139     pub struct pthread_condattr_t {
140         ptca_magic: ::c_uint,
141         ptca_private: *mut ::c_void,
142     }
143 
144     pub struct pthread_rwlock_t {
145         ptr_magic: ::c_uint,
146         ptr_interlock: __pthread_spin_t,
147         ptr_rblocked_first: *mut u8,
148         ptr_rblocked_last: *mut u8,
149         ptr_wblocked_first: *mut u8,
150         ptr_wblocked_last: *mut u8,
151         ptr_nreaders: ::c_uint,
152         ptr_owner: ::pthread_t,
153         ptr_private: *mut ::c_void,
154     }
155 
156     pub struct kevent {
157         pub ident: ::uintptr_t,
158         pub filter: u32,
159         pub flags: u32,
160         pub fflags: u32,
161         pub data: i64,
162         pub udata: ::intptr_t,
163     }
164 
165     pub struct dqblk {
166         pub dqb_bhardlimit: u32,
167         pub dqb_bsoftlimit: u32,
168         pub dqb_curblocks: u32,
169         pub dqb_ihardlimit: u32,
170         pub dqb_isoftlimit: u32,
171         pub dqb_curinodes: u32,
172         pub dqb_btime: i32,
173         pub dqb_itime: i32,
174     }
175 
176     pub struct Dl_info {
177         pub dli_fname: *const ::c_char,
178         pub dli_fbase: *mut ::c_void,
179         pub dli_sname: *const ::c_char,
180         pub dli_saddr: *const ::c_void,
181     }
182 
183     pub struct lconv {
184         pub decimal_point: *mut ::c_char,
185         pub thousands_sep: *mut ::c_char,
186         pub grouping: *mut ::c_char,
187         pub int_curr_symbol: *mut ::c_char,
188         pub currency_symbol: *mut ::c_char,
189         pub mon_decimal_point: *mut ::c_char,
190         pub mon_thousands_sep: *mut ::c_char,
191         pub mon_grouping: *mut ::c_char,
192         pub positive_sign: *mut ::c_char,
193         pub negative_sign: *mut ::c_char,
194         pub int_frac_digits: ::c_char,
195         pub frac_digits: ::c_char,
196         pub p_cs_precedes: ::c_char,
197         pub p_sep_by_space: ::c_char,
198         pub n_cs_precedes: ::c_char,
199         pub n_sep_by_space: ::c_char,
200         pub p_sign_posn: ::c_char,
201         pub n_sign_posn: ::c_char,
202         pub int_p_cs_precedes: ::c_char,
203         pub int_n_cs_precedes: ::c_char,
204         pub int_p_sep_by_space: ::c_char,
205         pub int_n_sep_by_space: ::c_char,
206         pub int_p_sign_posn: ::c_char,
207         pub int_n_sign_posn: ::c_char,
208     }
209 
210     pub struct if_data {
211         pub ifi_type: ::c_uchar,
212         pub ifi_addrlen: ::c_uchar,
213         pub ifi_hdrlen: ::c_uchar,
214         pub ifi_link_state: ::c_int,
215         pub ifi_mtu: u64,
216         pub ifi_metric: u64,
217         pub ifi_baudrate: u64,
218         pub ifi_ipackets: u64,
219         pub ifi_ierrors: u64,
220         pub ifi_opackets: u64,
221         pub ifi_oerrors: u64,
222         pub ifi_collisions: u64,
223         pub ifi_ibytes: u64,
224         pub ifi_obytes: u64,
225         pub ifi_imcasts: u64,
226         pub ifi_omcasts: u64,
227         pub ifi_iqdrops: u64,
228         pub ifi_noproto: u64,
229         pub ifi_lastchange: ::timespec,
230     }
231 
232     pub struct if_msghdr {
233         pub ifm_msglen: ::c_ushort,
234         pub ifm_version: ::c_uchar,
235         pub ifm_type: ::c_uchar,
236         pub ifm_addrs: ::c_int,
237         pub ifm_flags: ::c_int,
238         pub ifm_index: ::c_ushort,
239         pub ifm_data: if_data,
240     }
241 
242     pub struct sockcred {
243         pub sc_pid: ::pid_t,
244         pub sc_uid: ::uid_t,
245         pub sc_euid: ::uid_t,
246         pub sc_gid: ::gid_t,
247         pub sc_egid: ::gid_t,
248         pub sc_ngroups: ::c_int,
249         pub sc_groups: [::gid_t; 1],
250     }
251 
252     pub struct sockaddr_dl {
253         pub sdl_len: ::c_uchar,
254         pub sdl_family: ::c_uchar,
255         pub sdl_index: ::c_ushort,
256         pub sdl_type: u8,
257         pub sdl_nlen: u8,
258         pub sdl_alen: u8,
259         pub sdl_slen: u8,
260         pub sdl_data: [::c_char; 12],
261     }
262 
263     pub struct mmsghdr {
264         pub msg_hdr: ::msghdr,
265         pub msg_len: ::c_uint,
266     }
267 }
268 
269 s_no_extra_traits! {
270     pub struct in_pktinfo {
271         pub ipi_addr: ::in_addr,
272         pub ipi_ifindex: ::c_uint,
273     }
274 
275     #[repr(packed)]
276     pub struct arphdr {
277         pub ar_hrd: u16,
278         pub ar_pro: u16,
279         pub ar_hln: u8,
280         pub ar_pln: u8,
281         pub ar_op: u16,
282     }
283 
284     #[repr(packed)]
285     pub struct in_addr {
286         pub s_addr: ::in_addr_t,
287     }
288 
289     pub struct ip_mreq {
290         pub imr_multiaddr: in_addr,
291         pub imr_interface: in_addr,
292     }
293 
294     pub struct sockaddr_in {
295         pub sin_len: u8,
296         pub sin_family: ::sa_family_t,
297         pub sin_port: ::in_port_t,
298         pub sin_addr: ::in_addr,
299         pub sin_zero: [i8; 8],
300     }
301 
302     pub struct dirent {
303         pub d_fileno: ::ino_t,
304         pub d_reclen: u16,
305         pub d_namlen: u16,
306         pub d_type: u8,
307         pub d_name: [::c_char; 512],
308     }
309 
310     pub struct statvfs {
311         pub f_flag: ::c_ulong,
312         pub f_bsize: ::c_ulong,
313         pub f_frsize: ::c_ulong,
314         pub f_iosize: ::c_ulong,
315 
316         pub f_blocks: ::fsblkcnt_t,
317         pub f_bfree: ::fsblkcnt_t,
318         pub f_bavail: ::fsblkcnt_t,
319         pub f_bresvd: ::fsblkcnt_t,
320 
321         pub f_files: ::fsfilcnt_t,
322         pub f_ffree: ::fsfilcnt_t,
323         pub f_favail: ::fsfilcnt_t,
324         pub f_fresvd: ::fsfilcnt_t,
325 
326         pub f_syncreads: u64,
327         pub f_syncwrites: u64,
328 
329         pub f_asyncreads: u64,
330         pub f_asyncwrites: u64,
331 
332         pub f_fsidx: ::fsid_t,
333         pub f_fsid: ::c_ulong,
334         pub f_namemax: ::c_ulong,
335         pub f_owner: ::uid_t,
336 
337         pub f_spare: [u32; 4],
338 
339         pub f_fstypename: [::c_char; 32],
340         pub f_mntonname: [::c_char; 1024],
341         pub f_mntfromname: [::c_char; 1024],
342     }
343 
344     pub struct sockaddr_storage {
345         pub ss_len: u8,
346         pub ss_family: ::sa_family_t,
347         __ss_pad1: [u8; 6],
348         __ss_pad2: i64,
349         __ss_pad3: [u8; 112],
350     }
351 
352     pub struct sigevent {
353         pub sigev_notify: ::c_int,
354         pub sigev_signo: ::c_int,
355         pub sigev_value: ::sigval,
356         __unused1: *mut ::c_void,       //actually a function pointer
357         pub sigev_notify_attributes: *mut ::c_void
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         impl PartialEq for sigevent {
663             fn eq(&self, other: &sigevent) -> bool {
664                 self.sigev_notify == other.sigev_notify
665                     && self.sigev_signo == other.sigev_signo
666                     && self.sigev_value == other.sigev_value
667                     && self.sigev_notify_attributes
668                         == other.sigev_notify_attributes
669             }
670         }
671         impl Eq for sigevent {}
672         impl ::fmt::Debug for sigevent {
673             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
674                 f.debug_struct("sigevent")
675                     .field("sigev_notify", &self.sigev_notify)
676                     .field("sigev_signo", &self.sigev_signo)
677                     .field("sigev_value", &self.sigev_value)
678                     .field("sigev_notify_attributes",
679                            &self.sigev_notify_attributes)
680                     .finish()
681             }
682         }
683         impl ::hash::Hash for sigevent {
684             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
685                 self.sigev_notify.hash(state);
686                 self.sigev_signo.hash(state);
687                 self.sigev_value.hash(state);
688                 self.sigev_notify_attributes.hash(state);
689             }
690         }
691     }
692 }
693 
694 pub const AT_FDCWD: ::c_int = -100;
695 pub const AT_EACCESS: ::c_int = 0x100;
696 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200;
697 pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
698 pub const AT_REMOVEDIR: ::c_int = 0x800;
699 
700 pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
701 pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
702 
703 pub const LC_COLLATE_MASK: ::c_int = (1 << ::LC_COLLATE);
704 pub const LC_CTYPE_MASK: ::c_int = (1 << ::LC_CTYPE);
705 pub const LC_MONETARY_MASK: ::c_int = (1 << ::LC_MONETARY);
706 pub const LC_NUMERIC_MASK: ::c_int = (1 << ::LC_NUMERIC);
707 pub const LC_TIME_MASK: ::c_int = (1 << ::LC_TIME);
708 pub const LC_MESSAGES_MASK: ::c_int = (1 << ::LC_MESSAGES);
709 pub const LC_ALL_MASK: ::c_int = !0;
710 
711 pub const ERA: ::nl_item = 52;
712 pub const ERA_D_FMT: ::nl_item = 53;
713 pub const ERA_D_T_FMT: ::nl_item = 54;
714 pub const ERA_T_FMT: ::nl_item = 55;
715 pub const ALT_DIGITS: ::nl_item = 56;
716 
717 pub const O_CLOEXEC: ::c_int = 0x400000;
718 pub const O_ALT_IO: ::c_int = 0x40000;
719 pub const O_NOSIGPIPE: ::c_int = 0x1000000;
720 pub const O_SEARCH: ::c_int = 0x800000;
721 pub const O_DIRECTORY: ::c_int = 0x200000;
722 pub const O_DIRECT : ::c_int = 0x00080000;
723 pub const O_RSYNC : ::c_int = 0x00020000;
724 
725 pub const MS_SYNC : ::c_int = 0x4;
726 pub const MS_INVALIDATE : ::c_int = 0x2;
727 
728 pub const RLIM_NLIMITS: ::c_int = 12;
729 
730 pub const EIDRM: ::c_int = 82;
731 pub const ENOMSG: ::c_int = 83;
732 pub const EOVERFLOW: ::c_int = 84;
733 pub const EILSEQ: ::c_int = 85;
734 pub const ENOTSUP: ::c_int = 86;
735 pub const ECANCELED: ::c_int = 87;
736 pub const EBADMSG: ::c_int = 88;
737 pub const ENODATA: ::c_int = 89;
738 pub const ENOSR: ::c_int = 90;
739 pub const ENOSTR: ::c_int = 91;
740 pub const ETIME: ::c_int = 92;
741 pub const ENOATTR: ::c_int = 93;
742 pub const EMULTIHOP: ::c_int = 94;
743 pub const ENOLINK: ::c_int = 95;
744 pub const EPROTO: ::c_int = 96;
745 pub const ELAST: ::c_int = 96;
746 
747 pub const F_DUPFD_CLOEXEC : ::c_int = 12;
748 pub const F_CLOSEM: ::c_int = 10;
749 pub const F_GETNOSIGPIPE: ::c_int = 13;
750 pub const F_SETNOSIGPIPE: ::c_int = 14;
751 pub const F_MAXFD: ::c_int = 11;
752 
753 pub const IP_RECVDSTADDR: ::c_int = 7;
754 pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;
755 pub const IP_RECVIF: ::c_int = 20;
756 pub const IP_PKTINFO: ::c_int = 25;
757 pub const IP_RECVPKTINFO: ::c_int = 26;
758 pub const IPV6_JOIN_GROUP: ::c_int = 12;
759 pub const IPV6_LEAVE_GROUP: ::c_int = 13;
760 
761 pub const TCP_KEEPIDLE:  ::c_int = 3;
762 pub const TCP_KEEPINTVL: ::c_int = 5;
763 pub const TCP_KEEPCNT:   ::c_int = 6;
764 pub const TCP_KEEPINIT:  ::c_int = 7;
765 pub const TCP_INFO:      ::c_int = 9;
766 pub const TCP_MD5SIG:    ::c_int = 0x10;
767 pub const TCP_CONGCTL:   ::c_int = 0x20;
768 
769 pub const SOCK_CONN_DGRAM: ::c_int = 6;
770 pub const SOCK_DCCP: ::c_int = SOCK_CONN_DGRAM;
771 pub const SOCK_NOSIGPIPE: ::c_int = 0x40000000;
772 pub const SOCK_FLAGS_MASK: ::c_int = 0xf0000000;
773 
774 pub const SO_SNDTIMEO: ::c_int = 0x100b;
775 pub const SO_RCVTIMEO: ::c_int = 0x100c;
776 pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
777 pub const SO_TIMESTAMP: ::c_int = 0x2000;
778 pub const SO_OVERFLOWED: ::c_int = 0x1009;
779 pub const SO_NOHEADER: ::c_int = 0x100a;
780 
781 // https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373
782 pub const IFF_UP: ::c_int = 0x0001; // interface is up
783 pub const IFF_BROADCAST: ::c_int = 0x0002; // broadcast address valid
784 pub const IFF_DEBUG: ::c_int = 0x0004; // turn on debugging
785 pub const IFF_LOOPBACK: ::c_int = 0x0008; // is a loopback net
786 pub const IFF_POINTOPOINT: ::c_int = 0x0010; // interface is point-to-point link
787 pub const IFF_NOTRAILERS: ::c_int = 0x0020; // avoid use of trailers
788 pub const IFF_RUNNING: ::c_int = 0x0040; // resources allocated
789 pub const IFF_NOARP: ::c_int = 0x0080; // no address resolution protocol
790 pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets
791 pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets
792 pub const IFF_OACTIVE: ::c_int = 0x0400; // transmission in progress
793 pub const IFF_SIMPLEX: ::c_int = 0x0800; // can't hear own transmissions
794 pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
795 pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
796 pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
797 pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
798 
799 // sys/netinet/in.h
800 // Protocols (RFC 1700)
801 // NOTE: These are in addition to the constants defined in src/unix/mod.rs
802 
803 // IPPROTO_IP defined in src/unix/mod.rs
804 /// Hop-by-hop option header
805 pub const IPPROTO_HOPOPTS: ::c_int = 0;
806 // IPPROTO_ICMP defined in src/unix/mod.rs
807 /// group mgmt protocol
808 pub const IPPROTO_IGMP: ::c_int = 2;
809 /// gateway^2 (deprecated)
810 pub const IPPROTO_GGP: ::c_int = 3;
811 /// for compatibility
812 pub const IPPROTO_IPIP: ::c_int = 4;
813 // IPPROTO_TCP defined in src/unix/mod.rs
814 /// exterior gateway protocol
815 pub const IPPROTO_EGP: ::c_int = 8;
816 /// pup
817 pub const IPPROTO_PUP: ::c_int = 12;
818 // IPPROTO_UDP defined in src/unix/mod.rs
819 /// xns idp
820 pub const IPPROTO_IDP: ::c_int = 22;
821 /// tp-4 w/ class negotiation
822 pub const IPPROTO_TP: ::c_int = 29;
823 /// DCCP
824 pub const IPPROTO_DCCP: ::c_int = 33;
825 // IPPROTO_IPV6 defined in src/unix/mod.rs
826 /// IP6 routing header
827 pub const IPPROTO_ROUTING: ::c_int = 43;
828 /// IP6 fragmentation header
829 pub const IPPROTO_FRAGMENT: ::c_int = 44;
830 /// resource reservation
831 pub const IPPROTO_RSVP: ::c_int = 46;
832 /// General Routing Encap.
833 pub const IPPROTO_GRE: ::c_int = 47;
834 /// IP6 Encap Sec. Payload
835 pub const IPPROTO_ESP: ::c_int = 50;
836 /// IP6 Auth Header
837 pub const IPPROTO_AH: ::c_int = 51;
838 /// IP Mobility RFC 2004
839 pub const IPPROTO_MOBILE: ::c_int = 55;
840 /// IPv6 ICMP
841 pub const IPPROTO_IPV6_ICMP: ::c_int = 58;
842 // IPPROTO_ICMPV6 defined in src/unix/mod.rs
843 /// IP6 no next header
844 pub const IPPROTO_NONE: ::c_int = 59;
845 /// IP6 destination option
846 pub const IPPROTO_DSTOPTS: ::c_int = 60;
847 /// ISO cnlp
848 pub const IPPROTO_EON: ::c_int = 80;
849 /// Ethernet-in-IP
850 pub const IPPROTO_ETHERIP: ::c_int = 97;
851 /// encapsulation header
852 pub const IPPROTO_ENCAP: ::c_int = 98;
853 /// Protocol indep. multicast
854 pub const IPPROTO_PIM: ::c_int = 103;
855 /// IP Payload Comp. Protocol
856 pub const IPPROTO_IPCOMP: ::c_int = 108;
857 /// VRRP RFC 2338
858 pub const IPPROTO_VRRP: ::c_int = 112;
859 /// Common Address Resolution Protocol
860 pub const IPPROTO_CARP: ::c_int = 112;
861 /// L2TPv3
862 // TEMP: Disabled for now; this constant was added to NetBSD on 2017-02-16,
863 // but isn't yet supported by the NetBSD rumprun kernel image used for
864 // libc testing.
865 //pub const IPPROTO_L2TP: ::c_int = 115;
866 /// SCTP
867 pub const IPPROTO_SCTP: ::c_int = 132;
868 /// PFSYNC
869 pub const IPPROTO_PFSYNC: ::c_int = 240;
870 pub const IPPROTO_MAX: ::c_int = 256;
871 
872 /// last return value of *_input(), meaning "all job for this pkt is done".
873 pub const IPPROTO_DONE: ::c_int = 257;
874 
875 /// sysctl placeholder for (FAST_)IPSEC
876 pub const CTL_IPPROTO_IPSEC: ::c_int = 258;
877 
878 pub const AF_OROUTE: ::c_int = 17;
879 pub const AF_ARP: ::c_int = 28;
880 pub const pseudo_AF_KEY: ::c_int = 29;
881 pub const pseudo_AF_HDRCMPLT: ::c_int = 30;
882 pub const AF_BLUETOOTH: ::c_int = 31;
883 pub const AF_IEEE80211: ::c_int = 32;
884 pub const AF_MPLS: ::c_int = 33;
885 pub const AF_ROUTE: ::c_int = 34;
886 pub const NET_RT_DUMP: ::c_int = 1;
887 pub const NET_RT_FLAGS: ::c_int = 2;
888 pub const NET_RT_OOOIFLIST: ::c_int = 3;
889 pub const NET_RT_OOIFLIST: ::c_int = 4;
890 pub const NET_RT_OIFLIST: ::c_int = 5;
891 pub const NET_RT_IFLIST: ::c_int = 6;
892 pub const NET_RT_MAXID: ::c_int = 7;
893 
894 pub const PF_OROUTE: ::c_int = AF_OROUTE;
895 pub const PF_ARP: ::c_int = AF_ARP;
896 pub const PF_KEY: ::c_int = pseudo_AF_KEY;
897 pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
898 pub const PF_MPLS: ::c_int = AF_MPLS;
899 pub const PF_ROUTE: ::c_int = AF_ROUTE;
900 
901 pub const MSG_NBIO: ::c_int = 0x1000;
902 pub const MSG_WAITFORONE: ::c_int = 0x2000;
903 pub const MSG_NOTIFICATION: ::c_int = 0x4000;
904 
905 pub const SCM_TIMESTAMP: ::c_int = 0x08;
906 pub const SCM_CREDS: ::c_int = 0x10;
907 
908 pub const O_DSYNC : ::c_int = 0x10000;
909 
910 pub const MAP_RENAME : ::c_int = 0x20;
911 pub const MAP_NORESERVE : ::c_int = 0x40;
912 pub const MAP_HASSEMAPHORE : ::c_int = 0x200;
913 pub const MAP_WIRED: ::c_int = 0x800;
914 
915 pub const DCCP_TYPE_REQUEST: ::c_int = 0;
916 pub const DCCP_TYPE_RESPONSE: ::c_int = 1;
917 pub const DCCP_TYPE_DATA: ::c_int = 2;
918 pub const DCCP_TYPE_ACK: ::c_int = 3;
919 pub const DCCP_TYPE_DATAACK: ::c_int =  4;
920 pub const DCCP_TYPE_CLOSEREQ: ::c_int = 5;
921 pub const DCCP_TYPE_CLOSE: ::c_int = 6;
922 pub const DCCP_TYPE_RESET: ::c_int = 7;
923 pub const DCCP_TYPE_MOVE: ::c_int = 8;
924 
925 pub const DCCP_FEATURE_CC: ::c_int = 1;
926 pub const DCCP_FEATURE_ECN: ::c_int = 2;
927 pub const DCCP_FEATURE_ACKRATIO: ::c_int =  3;
928 pub const DCCP_FEATURE_ACKVECTOR: ::c_int = 4;
929 pub const DCCP_FEATURE_MOBILITY: ::c_int =  5;
930 pub const DCCP_FEATURE_LOSSWINDOW: ::c_int = 6;
931 pub const DCCP_FEATURE_CONN_NONCE: ::c_int = 8;
932 pub const DCCP_FEATURE_IDENTREG: ::c_int =  7;
933 
934 pub const DCCP_OPT_PADDING: ::c_int = 0;
935 pub const DCCP_OPT_DATA_DISCARD: ::c_int = 1;
936 pub const DCCP_OPT_SLOW_RECV: ::c_int = 2;
937 pub const DCCP_OPT_BUF_CLOSED: ::c_int = 3;
938 pub const DCCP_OPT_CHANGE_L: ::c_int = 32;
939 pub const DCCP_OPT_CONFIRM_L: ::c_int = 33;
940 pub const DCCP_OPT_CHANGE_R: ::c_int = 34;
941 pub const DCCP_OPT_CONFIRM_R: ::c_int = 35;
942 pub const DCCP_OPT_INIT_COOKIE: ::c_int = 36;
943 pub const DCCP_OPT_NDP_COUNT: ::c_int = 37;
944 pub const DCCP_OPT_ACK_VECTOR0: ::c_int = 38;
945 pub const DCCP_OPT_ACK_VECTOR1: ::c_int = 39;
946 pub const DCCP_OPT_RECV_BUF_DROPS: ::c_int = 40;
947 pub const DCCP_OPT_TIMESTAMP: ::c_int = 41;
948 pub const DCCP_OPT_TIMESTAMP_ECHO: ::c_int = 42;
949 pub const DCCP_OPT_ELAPSEDTIME: ::c_int = 43;
950 pub const DCCP_OPT_DATACHECKSUM: ::c_int = 44;
951 
952 pub const DCCP_REASON_UNSPEC: ::c_int = 0;
953 pub const DCCP_REASON_CLOSED: ::c_int = 1;
954 pub const DCCP_REASON_INVALID: ::c_int = 2;
955 pub const DCCP_REASON_OPTION_ERR: ::c_int = 3;
956 pub const DCCP_REASON_FEA_ERR: ::c_int = 4;
957 pub const DCCP_REASON_CONN_REF: ::c_int = 5;
958 pub const DCCP_REASON_BAD_SNAME: ::c_int = 6;
959 pub const DCCP_REASON_BAD_COOKIE: ::c_int = 7;
960 pub const DCCP_REASON_INV_MOVE: ::c_int = 8;
961 pub const DCCP_REASON_UNANSW_CH: ::c_int = 10;
962 pub const DCCP_REASON_FRUITLESS_NEG: ::c_int = 11;
963 
964 pub const DCCP_CCID: ::c_int = 1;
965 pub const DCCP_CSLEN: ::c_int = 2;
966 pub const DCCP_MAXSEG: ::c_int = 4;
967 pub const DCCP_SERVICE: ::c_int = 8;
968 
969 pub const DCCP_NDP_LIMIT: ::c_int = 16;
970 pub const DCCP_SEQ_NUM_LIMIT: ::c_int = 16777216;
971 pub const DCCP_MAX_OPTIONS: ::c_int = 32;
972 pub const DCCP_MAX_PKTS: ::c_int = 100;
973 
974 pub const _PC_LINK_MAX : ::c_int = 1;
975 pub const _PC_MAX_CANON : ::c_int = 2;
976 pub const _PC_MAX_INPUT : ::c_int = 3;
977 pub const _PC_NAME_MAX : ::c_int = 4;
978 pub const _PC_PATH_MAX : ::c_int = 5;
979 pub const _PC_PIPE_BUF : ::c_int = 6;
980 pub const _PC_CHOWN_RESTRICTED : ::c_int = 7;
981 pub const _PC_NO_TRUNC : ::c_int = 8;
982 pub const _PC_VDISABLE : ::c_int = 9;
983 pub const _PC_SYNC_IO : ::c_int = 10;
984 pub const _PC_FILESIZEBITS : ::c_int = 11;
985 pub const _PC_SYMLINK_MAX : ::c_int = 12;
986 pub const _PC_2_SYMLINKS : ::c_int = 13;
987 pub const _PC_ACL_EXTENDED : ::c_int = 14;
988 pub const _PC_MIN_HOLE_SIZE : ::c_int = 15;
989 
990 pub const _SC_SYNCHRONIZED_IO : ::c_int = 31;
991 pub const _SC_IOV_MAX : ::c_int = 32;
992 pub const _SC_MAPPED_FILES : ::c_int = 33;
993 pub const _SC_MEMLOCK : ::c_int = 34;
994 pub const _SC_MEMLOCK_RANGE : ::c_int = 35;
995 pub const _SC_MEMORY_PROTECTION : ::c_int = 36;
996 pub const _SC_LOGIN_NAME_MAX : ::c_int = 37;
997 pub const _SC_MONOTONIC_CLOCK : ::c_int = 38;
998 pub const _SC_CLK_TCK : ::c_int = 39;
999 pub const _SC_ATEXIT_MAX : ::c_int = 40;
1000 pub const _SC_THREADS : ::c_int = 41;
1001 pub const _SC_SEMAPHORES : ::c_int = 42;
1002 pub const _SC_BARRIERS : ::c_int = 43;
1003 pub const _SC_TIMERS : ::c_int = 44;
1004 pub const _SC_SPIN_LOCKS : ::c_int = 45;
1005 pub const _SC_READER_WRITER_LOCKS : ::c_int = 46;
1006 pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 47;
1007 pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 48;
1008 pub const _SC_CLOCK_SELECTION : ::c_int = 49;
1009 pub const _SC_ASYNCHRONOUS_IO : ::c_int = 50;
1010 pub const _SC_AIO_LISTIO_MAX : ::c_int = 51;
1011 pub const _SC_AIO_MAX : ::c_int = 52;
1012 pub const _SC_MESSAGE_PASSING : ::c_int = 53;
1013 pub const _SC_MQ_OPEN_MAX : ::c_int = 54;
1014 pub const _SC_MQ_PRIO_MAX : ::c_int = 55;
1015 pub const _SC_PRIORITY_SCHEDULING : ::c_int = 56;
1016 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 57;
1017 pub const _SC_THREAD_KEYS_MAX : ::c_int = 58;
1018 pub const _SC_THREAD_STACK_MIN : ::c_int = 59;
1019 pub const _SC_THREAD_THREADS_MAX : ::c_int = 60;
1020 pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 61;
1021 pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 62;
1022 pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 63;
1023 pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 64;
1024 pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 65;
1025 pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 66;
1026 pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 67;
1027 pub const _SC_TTY_NAME_MAX : ::c_int = 68;
1028 pub const _SC_HOST_NAME_MAX : ::c_int = 69;
1029 pub const _SC_PASS_MAX : ::c_int = 70;
1030 pub const _SC_REGEXP : ::c_int = 71;
1031 pub const _SC_SHELL : ::c_int = 72;
1032 pub const _SC_SYMLOOP_MAX : ::c_int = 73;
1033 pub const _SC_V6_ILP32_OFF32 : ::c_int = 74;
1034 pub const _SC_V6_ILP32_OFFBIG : ::c_int = 75;
1035 pub const _SC_V6_LP64_OFF64 : ::c_int = 76;
1036 pub const _SC_V6_LPBIG_OFFBIG : ::c_int = 77;
1037 pub const _SC_2_PBS : ::c_int = 80;
1038 pub const _SC_2_PBS_ACCOUNTING : ::c_int = 81;
1039 pub const _SC_2_PBS_CHECKPOINT : ::c_int = 82;
1040 pub const _SC_2_PBS_LOCATE : ::c_int = 83;
1041 pub const _SC_2_PBS_MESSAGE : ::c_int = 84;
1042 pub const _SC_2_PBS_TRACK : ::c_int = 85;
1043 pub const _SC_SPAWN : ::c_int = 86;
1044 pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 87;
1045 pub const _SC_TIMER_MAX : ::c_int = 88;
1046 pub const _SC_SEM_NSEMS_MAX : ::c_int = 89;
1047 pub const _SC_CPUTIME : ::c_int = 90;
1048 pub const _SC_THREAD_CPUTIME : ::c_int = 91;
1049 pub const _SC_DELAYTIMER_MAX : ::c_int = 92;
1050 // These two variables will be supported in NetBSD 8.0
1051 // pub const _SC_SIGQUEUE_MAX : ::c_int = 93;
1052 // pub const _SC_REALTIME_SIGNALS : ::c_int = 94;
1053 pub const _SC_PHYS_PAGES : ::c_int = 121;
1054 pub const _SC_NPROCESSORS_CONF : ::c_int = 1001;
1055 pub const _SC_NPROCESSORS_ONLN : ::c_int = 1002;
1056 pub const _SC_SCHED_RT_TS : ::c_int = 2001;
1057 pub const _SC_SCHED_PRI_MIN : ::c_int = 2002;
1058 pub const _SC_SCHED_PRI_MAX : ::c_int = 2003;
1059 
1060 pub const FD_SETSIZE: usize = 0x100;
1061 
1062 pub const ST_NOSUID: ::c_ulong = 8;
1063 
1064 cfg_if! {
1065     if #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
1066                  target_arch = "x86", target_arch = "x86_64"))] {
1067         pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
1068             ptm_magic: 0x33330003,
1069             ptm_errorcheck: 0,
1070             ptm_pad1: [0; 3],
1071             ptm_unused: 0,
1072             ptm_pad2: [0; 3],
1073             ptm_waiters: 0 as *mut _,
1074             ptm_owner: 0,
1075             ptm_recursed: 0,
1076             ptm_spare2: 0 as *mut _,
1077         };
1078     } else {
1079         pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
1080             ptm_magic: 0x33330003,
1081             ptm_errorcheck: 0,
1082             ptm_unused: 0,
1083             ptm_waiters: 0 as *mut _,
1084             ptm_owner: 0,
1085             ptm_recursed: 0,
1086             ptm_spare2: 0 as *mut _,
1087         };
1088     }
1089 }
1090 
1091 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1092     ptc_magic: 0x55550005,
1093     ptc_lock: 0,
1094     ptc_waiters_first: 0 as *mut _,
1095     ptc_waiters_last: 0 as *mut _,
1096     ptc_mutex: 0 as *mut _,
1097     ptc_private: 0 as *mut _,
1098 };
1099 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1100     ptr_magic: 0x99990009,
1101     ptr_interlock: 0,
1102     ptr_rblocked_first: 0 as *mut _,
1103     ptr_rblocked_last: 0 as *mut _,
1104     ptr_wblocked_first: 0 as *mut _,
1105     ptr_wblocked_last: 0 as *mut _,
1106     ptr_nreaders: 0,
1107     ptr_owner: 0,
1108     ptr_private: 0 as *mut _,
1109 };
1110 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
1111 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
1112 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
1113 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
1114 
1115 pub const EVFILT_AIO: u32 = 2;
1116 pub const EVFILT_PROC: u32 = 4;
1117 pub const EVFILT_READ: u32 = 0;
1118 pub const EVFILT_SIGNAL: u32 = 5;
1119 pub const EVFILT_TIMER: u32 = 6;
1120 pub const EVFILT_VNODE: u32 = 3;
1121 pub const EVFILT_WRITE: u32 = 1;
1122 
1123 pub const EV_ADD: u32 = 0x1;
1124 pub const EV_DELETE: u32 = 0x2;
1125 pub const EV_ENABLE: u32 = 0x4;
1126 pub const EV_DISABLE: u32 = 0x8;
1127 pub const EV_ONESHOT: u32 = 0x10;
1128 pub const EV_CLEAR: u32 = 0x20;
1129 pub const EV_RECEIPT: u32 = 0x40;
1130 pub const EV_DISPATCH: u32 = 0x80;
1131 pub const EV_FLAG1: u32 = 0x2000;
1132 pub const EV_ERROR: u32 = 0x4000;
1133 pub const EV_EOF: u32 = 0x8000;
1134 pub const EV_SYSFLAGS: u32 = 0xf000;
1135 
1136 pub const NOTE_LOWAT: u32 = 0x00000001;
1137 pub const NOTE_DELETE: u32 = 0x00000001;
1138 pub const NOTE_WRITE: u32 = 0x00000002;
1139 pub const NOTE_EXTEND: u32 = 0x00000004;
1140 pub const NOTE_ATTRIB: u32 = 0x00000008;
1141 pub const NOTE_LINK: u32 = 0x00000010;
1142 pub const NOTE_RENAME: u32 = 0x00000020;
1143 pub const NOTE_REVOKE: u32 = 0x00000040;
1144 pub const NOTE_EXIT: u32 = 0x80000000;
1145 pub const NOTE_FORK: u32 = 0x40000000;
1146 pub const NOTE_EXEC: u32 = 0x20000000;
1147 pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1148 pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1149 pub const NOTE_TRACK: u32 = 0x00000001;
1150 pub const NOTE_TRACKERR: u32 = 0x00000002;
1151 pub const NOTE_CHILD: u32 = 0x00000004;
1152 
1153 pub const TMP_MAX : ::c_uint = 308915776;
1154 
1155 pub const NI_MAXHOST: ::socklen_t = 1025;
1156 
1157 pub const RTLD_NOLOAD: ::c_int = 0x2000;
1158 pub const RTLD_LOCAL: ::c_int = 0x200;
1159 
1160 pub const CTL_MAXNAME: ::c_int = 12;
1161 pub const SYSCTL_NAMELEN: ::c_int = 32;
1162 pub const SYSCTL_DEFSIZE: ::c_int = 8;
1163 pub const CTLTYPE_NODE: ::c_int = 1;
1164 pub const CTLTYPE_INT: ::c_int = 2;
1165 pub const CTLTYPE_STRING: ::c_int = 3;
1166 pub const CTLTYPE_QUAD: ::c_int = 4;
1167 pub const CTLTYPE_STRUCT: ::c_int = 5;
1168 pub const CTLTYPE_BOOL: ::c_int = 6;
1169 pub const CTLFLAG_READONLY: ::c_int = 0x00000000;
1170 pub const CTLFLAG_READWRITE: ::c_int = 0x00000070;
1171 pub const CTLFLAG_ANYWRITE: ::c_int = 0x00000080;
1172 pub const CTLFLAG_PRIVATE: ::c_int = 0x00000100;
1173 pub const CTLFLAG_PERMANENT: ::c_int = 0x00000200;
1174 pub const CTLFLAG_OWNDATA: ::c_int = 0x00000400;
1175 pub const CTLFLAG_IMMEDIATE: ::c_int = 0x00000800;
1176 pub const CTLFLAG_HEX: ::c_int = 0x00001000;
1177 pub const CTLFLAG_ROOT: ::c_int = 0x00002000;
1178 pub const CTLFLAG_ANYNUMBER: ::c_int = 0x00004000;
1179 pub const CTLFLAG_HIDDEN: ::c_int = 0x00008000;
1180 pub const CTLFLAG_ALIAS: ::c_int = 0x00010000;
1181 pub const CTLFLAG_MMAP: ::c_int = 0x00020000;
1182 pub const CTLFLAG_OWNDESC: ::c_int = 0x00040000;
1183 pub const CTLFLAG_UNSIGNED: ::c_int = 0x00080000;
1184 pub const SYSCTL_VERS_MASK: ::c_int = 0xff000000;
1185 pub const SYSCTL_VERS_0: ::c_int = 0x00000000;
1186 pub const SYSCTL_VERS_1: ::c_int = 0x01000000;
1187 pub const SYSCTL_VERSION: ::c_int = SYSCTL_VERS_1;
1188 pub const CTL_EOL: ::c_int = -1;
1189 pub const CTL_QUERY: ::c_int = -2;
1190 pub const CTL_CREATE: ::c_int = -3;
1191 pub const CTL_CREATESYM: ::c_int = -4;
1192 pub const CTL_DESTROY: ::c_int = -5;
1193 pub const CTL_MMAP: ::c_int = -6;
1194 pub const CTL_DESCRIBE: ::c_int = -7;
1195 pub const CTL_UNSPEC: ::c_int = 0;
1196 pub const CTL_KERN: ::c_int = 1;
1197 pub const CTL_VM: ::c_int = 2;
1198 pub const CTL_VFS: ::c_int = 3;
1199 pub const CTL_NET: ::c_int = 4;
1200 pub const CTL_DEBUG: ::c_int = 5;
1201 pub const CTL_HW: ::c_int = 6;
1202 pub const CTL_MACHDEP: ::c_int = 7;
1203 pub const CTL_USER: ::c_int = 8;
1204 pub const CTL_DDB: ::c_int = 9;
1205 pub const CTL_PROC: ::c_int = 10;
1206 pub const CTL_VENDOR: ::c_int = 11;
1207 pub const CTL_EMUL: ::c_int = 12;
1208 pub const CTL_SECURITY: ::c_int = 13;
1209 pub const CTL_MAXID: ::c_int = 14;
1210 pub const KERN_OSTYPE: ::c_int = 1;
1211 pub const KERN_OSRELEASE: ::c_int = 2;
1212 pub const KERN_OSREV: ::c_int = 3;
1213 pub const KERN_VERSION: ::c_int = 4;
1214 pub const KERN_MAXVNODES: ::c_int = 5;
1215 pub const KERN_MAXPROC: ::c_int = 6;
1216 pub const KERN_MAXFILES: ::c_int = 7;
1217 pub const KERN_ARGMAX: ::c_int = 8;
1218 pub const KERN_SECURELVL: ::c_int = 9;
1219 pub const KERN_HOSTNAME: ::c_int = 10;
1220 pub const KERN_HOSTID: ::c_int = 11;
1221 pub const KERN_CLOCKRATE: ::c_int = 12;
1222 pub const KERN_VNODE: ::c_int = 13;
1223 pub const KERN_PROC: ::c_int = 14;
1224 pub const KERN_FILE: ::c_int = 15;
1225 pub const KERN_PROF: ::c_int = 16;
1226 pub const KERN_POSIX1: ::c_int = 17;
1227 pub const KERN_NGROUPS: ::c_int = 18;
1228 pub const KERN_JOB_CONTROL: ::c_int = 19;
1229 pub const KERN_SAVED_IDS: ::c_int = 20;
1230 pub const KERN_OBOOTTIME: ::c_int = 21;
1231 pub const KERN_DOMAINNAME: ::c_int = 22;
1232 pub const KERN_MAXPARTITIONS: ::c_int = 23;
1233 pub const KERN_RAWPARTITION: ::c_int = 24;
1234 pub const KERN_NTPTIME: ::c_int = 25;
1235 pub const KERN_TIMEX: ::c_int = 26;
1236 pub const KERN_AUTONICETIME: ::c_int = 27;
1237 pub const KERN_AUTONICEVAL: ::c_int = 28;
1238 pub const KERN_RTC_OFFSET: ::c_int = 29;
1239 pub const KERN_ROOT_DEVICE: ::c_int = 30;
1240 pub const KERN_MSGBUFSIZE: ::c_int = 31;
1241 pub const KERN_FSYNC: ::c_int = 32;
1242 pub const KERN_OLDSYSVMSG: ::c_int = 33;
1243 pub const KERN_OLDSYSVSEM: ::c_int = 34;
1244 pub const KERN_OLDSYSVSHM: ::c_int = 35;
1245 pub const KERN_OLDSHORTCORENAME: ::c_int = 36;
1246 pub const KERN_SYNCHRONIZED_IO: ::c_int = 37;
1247 pub const KERN_IOV_MAX: ::c_int = 38;
1248 pub const KERN_MBUF: ::c_int = 39;
1249 pub const KERN_MAPPED_FILES: ::c_int = 40;
1250 pub const KERN_MEMLOCK: ::c_int = 41;
1251 pub const KERN_MEMLOCK_RANGE: ::c_int = 42;
1252 pub const KERN_MEMORY_PROTECTION: ::c_int = 43;
1253 pub const KERN_LOGIN_NAME_MAX: ::c_int = 44;
1254 pub const KERN_DEFCORENAME: ::c_int = 45;
1255 pub const KERN_LOGSIGEXIT: ::c_int = 46;
1256 pub const KERN_PROC2: ::c_int = 47;
1257 pub const KERN_PROC_ARGS: ::c_int = 48;
1258 pub const KERN_FSCALE: ::c_int = 49;
1259 pub const KERN_CCPU: ::c_int = 50;
1260 pub const KERN_CP_TIME: ::c_int = 51;
1261 pub const KERN_OLDSYSVIPC_INFO: ::c_int = 52;
1262 pub const KERN_MSGBUF: ::c_int = 53;
1263 pub const KERN_CONSDEV: ::c_int = 54;
1264 pub const KERN_MAXPTYS: ::c_int = 55;
1265 pub const KERN_PIPE: ::c_int = 56;
1266 pub const KERN_MAXPHYS: ::c_int = 57;
1267 pub const KERN_SBMAX: ::c_int = 58;
1268 pub const KERN_TKSTAT: ::c_int = 59;
1269 pub const KERN_MONOTONIC_CLOCK: ::c_int = 60;
1270 pub const KERN_URND: ::c_int = 61;
1271 pub const KERN_LABELSECTOR: ::c_int = 62;
1272 pub const KERN_LABELOFFSET: ::c_int = 63;
1273 pub const KERN_LWP: ::c_int = 64;
1274 pub const KERN_FORKFSLEEP: ::c_int = 65;
1275 pub const KERN_POSIX_THREADS: ::c_int = 66;
1276 pub const KERN_POSIX_SEMAPHORES: ::c_int = 67;
1277 pub const KERN_POSIX_BARRIERS: ::c_int = 68;
1278 pub const KERN_POSIX_TIMERS: ::c_int = 69;
1279 pub const KERN_POSIX_SPIN_LOCKS: ::c_int = 70;
1280 pub const KERN_POSIX_READER_WRITER_LOCKS: ::c_int = 71;
1281 pub const KERN_DUMP_ON_PANIC: ::c_int = 72;
1282 pub const KERN_SOMAXKVA: ::c_int = 73;
1283 pub const KERN_ROOT_PARTITION: ::c_int = 74;
1284 pub const KERN_DRIVERS: ::c_int = 75;
1285 pub const KERN_BUF: ::c_int = 76;
1286 pub const KERN_FILE2: ::c_int = 77;
1287 pub const KERN_VERIEXEC: ::c_int = 78;
1288 pub const KERN_CP_ID: ::c_int = 79;
1289 pub const KERN_HARDCLOCK_TICKS: ::c_int = 80;
1290 pub const KERN_ARND: ::c_int = 81;
1291 pub const KERN_SYSVIPC: ::c_int = 82;
1292 pub const KERN_BOOTTIME: ::c_int = 83;
1293 pub const KERN_EVCNT: ::c_int = 84;
1294 pub const KERN_MAXID: ::c_int = 85;
1295 pub const KERN_PROC_ALL: ::c_int = 0;
1296 pub const KERN_PROC_PID: ::c_int = 1;
1297 pub const KERN_PROC_PGRP: ::c_int = 2;
1298 pub const KERN_PROC_SESSION: ::c_int = 3;
1299 pub const KERN_PROC_TTY: ::c_int = 4;
1300 pub const KERN_PROC_UID: ::c_int = 5;
1301 pub const KERN_PROC_RUID: ::c_int = 6;
1302 pub const KERN_PROC_GID: ::c_int = 7;
1303 pub const KERN_PROC_RGID: ::c_int = 8;
1304 pub const KERN_PROC_ARGV: ::c_int = 1;
1305 pub const KERN_PROC_NARGV: ::c_int = 2;
1306 pub const KERN_PROC_ENV: ::c_int = 3;
1307 pub const KERN_PROC_NENV: ::c_int = 4;
1308 pub const KERN_PROC_PATHNAME: ::c_int = 5;
1309 
1310 pub const EAI_AGAIN: ::c_int = 2;
1311 pub const EAI_BADFLAGS: ::c_int = 3;
1312 pub const EAI_FAIL: ::c_int = 4;
1313 pub const EAI_FAMILY: ::c_int = 5;
1314 pub const EAI_MEMORY: ::c_int = 6;
1315 pub const EAI_NODATA: ::c_int = 7;
1316 pub const EAI_NONAME: ::c_int = 8;
1317 pub const EAI_SERVICE: ::c_int = 9;
1318 pub const EAI_SOCKTYPE: ::c_int = 10;
1319 pub const EAI_SYSTEM: ::c_int = 11;
1320 pub const EAI_OVERFLOW: ::c_int = 14;
1321 
1322 pub const AIO_CANCELED: ::c_int = 1;
1323 pub const AIO_NOTCANCELED: ::c_int = 2;
1324 pub const AIO_ALLDONE: ::c_int = 3;
1325 pub const LIO_NOP: ::c_int = 0;
1326 pub const LIO_WRITE: ::c_int = 1;
1327 pub const LIO_READ: ::c_int = 2;
1328 pub const LIO_WAIT: ::c_int = 1;
1329 pub const LIO_NOWAIT: ::c_int = 0;
1330 
1331 pub const SIGEV_NONE: ::c_int = 0;
1332 pub const SIGEV_SIGNAL: ::c_int = 1;
1333 pub const SIGEV_THREAD: ::c_int = 2;
1334 
1335 pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED
1336 pub const WCONTINUED: ::c_int = 0x00000010;
1337 pub const WEXITED: ::c_int = 0x000000020;
1338 pub const WNOWAIT: ::c_int = 0x00010000;
1339 
1340 pub const P_ALL: idtype_t = 0;
1341 pub const P_PID: idtype_t = 1;
1342 pub const P_PGID: idtype_t = 4;
1343 
1344 pub const B460800: ::speed_t = 460800;
1345 pub const B921600: ::speed_t = 921600;
1346 
1347 pub const ONOCR: ::tcflag_t = 0x20;
1348 pub const ONLRET: ::tcflag_t = 0x40;
1349 pub const CDTRCTS: ::tcflag_t = 0x00020000;
1350 pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS;
1351 
1352 pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
1353 pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
1354 
1355 // Uncomment on next NetBSD release
1356 // pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
1357 // pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
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