1 pub type dev_t = u32;
2 pub type c_char = i8;
3 pub type wchar_t = i32;
4 pub type clock_t = u64;
5 pub type ino_t = u64;
6 pub type lwpid_t = i32;
7 pub type nlink_t = u32;
8 pub type blksize_t = i64;
9 pub type clockid_t = ::c_ulong;
10 
11 pub type c_long = i64;
12 pub type c_ulong = u64;
13 pub type time_t = i64;
14 pub type suseconds_t = i64;
15 
16 pub type uuid_t = ::uuid;
17 
18 pub type fsblkcnt_t = u64;
19 pub type fsfilcnt_t = u64;
20 pub type idtype_t = ::c_uint;
21 pub type shmatt_t = ::c_uint;
22 
23 pub type mqd_t = ::c_int;
24 pub type sem_t = *mut sem;
25 
26 pub type cpuset_t = cpumask_t;
27 pub type cpu_set_t = cpumask_t;
28 
29 pub type register_t = ::c_long;
30 pub type umtx_t = ::c_int;
31 pub type pthread_barrierattr_t = ::c_int;
32 pub type pthread_barrier_t = ::uintptr_t;
33 pub type pthread_spinlock_t = ::uintptr_t;
34 
35 pub type segsz_t = usize;
36 
37 pub type vm_prot_t = u8;
38 pub type vm_maptype_t = u8;
39 pub type vm_inherit_t = i8;
40 pub type vm_subsys_t = ::c_int;
41 pub type vm_eflags_t = ::c_uint;
42 
43 pub type vm_map_t = *mut __c_anonymous_vm_map;
44 pub type vm_map_entry_t = *mut vm_map_entry;
45 
46 pub type pmap = __c_anonymous_pmap;
47 
48 #[cfg_attr(feature = "extra_traits", derive(Debug))]
49 pub enum sem {}
50 impl ::Copy for sem {}
51 impl ::Clone for sem {
clone(&self) -> sem52     fn clone(&self) -> sem {
53         *self
54     }
55 }
56 
57 e! {
58     #[repr(u32)]
59     pub enum lwpstat {
60         LSRUN = 1,
61         LSSTOP = 2,
62         LSSLEEP = 3,
63     }
64 
65     #[repr(u32)]
66     pub enum procstat {
67         SIDL = 1,
68         SACTIVE = 2,
69         SSTOP = 3,
70         SZOMB = 4,
71         SCORE = 5,
72     }
73 }
74 
75 s! {
76     pub struct kevent {
77         pub ident: ::uintptr_t,
78         pub filter: ::c_short,
79         pub flags: ::c_ushort,
80         pub fflags: ::c_uint,
81         pub data: ::intptr_t,
82         pub udata: *mut ::c_void,
83     }
84 
85     pub struct exit_status {
86         pub e_termination: u16,
87         pub e_exit: u16
88     }
89 
90     pub struct aiocb {
91         pub aio_fildes: ::c_int,
92         pub aio_offset: ::off_t,
93         pub aio_buf: *mut ::c_void,
94         pub aio_nbytes: ::size_t,
95         pub aio_sigevent: sigevent,
96         pub aio_lio_opcode: ::c_int,
97         pub aio_reqprio: ::c_int,
98         _aio_val: ::c_int,
99         _aio_err: ::c_int
100     }
101 
102     pub struct uuid {
103         pub time_low: u32,
104         pub time_mid: u16,
105         pub time_hi_and_version: u16,
106         pub clock_seq_hi_and_reserved: u8,
107         pub clock_seq_low: u8,
108         pub node: [u8; 6],
109     }
110 
111     pub struct mq_attr {
112         pub mq_flags: ::c_long,
113         pub mq_maxmsg: ::c_long,
114         pub mq_msgsize: ::c_long,
115         pub mq_curmsgs: ::c_long,
116     }
117 
118     pub struct statvfs {
119         pub f_bsize: ::c_ulong,
120         pub f_frsize: ::c_ulong,
121         pub f_blocks: ::fsblkcnt_t,
122         pub f_bfree: ::fsblkcnt_t,
123         pub f_bavail: ::fsblkcnt_t,
124         pub f_files: ::fsfilcnt_t,
125         pub f_ffree: ::fsfilcnt_t,
126         pub f_favail: ::fsfilcnt_t,
127         pub f_fsid: ::c_ulong,
128         pub f_flag: ::c_ulong,
129         pub f_namemax: ::c_ulong,
130         pub f_owner: ::uid_t,
131         pub f_type: ::c_uint,
132         pub f_syncreads: u64,
133         pub f_syncwrites: u64,
134         pub f_asyncreads: u64,
135         pub f_asyncwrites: u64,
136         pub f_fsid_uuid: ::uuid_t,
137         pub f_uid_uuid: ::uuid_t,
138     }
139 
140     pub struct stat {
141         pub st_ino: ::ino_t,
142         pub st_nlink: ::nlink_t,
143         pub st_dev: ::dev_t,
144         pub st_mode: ::mode_t,
145         pub st_padding1: u16,
146         pub st_uid: ::uid_t,
147         pub st_gid: ::gid_t,
148         pub st_rdev: ::dev_t,
149         pub st_atime: ::time_t,
150         pub st_atime_nsec: ::c_long,
151         pub st_mtime: ::time_t,
152         pub st_mtime_nsec: ::c_long,
153         pub st_ctime: ::time_t,
154         pub st_ctime_nsec: ::c_long,
155         pub st_size: ::off_t,
156         pub st_blocks: i64,
157         pub __old_st_blksize: u32,
158         pub st_flags: u32,
159         pub st_gen: u32,
160         pub st_lspare: i32,
161         pub st_blksize: i64,
162         pub st_qspare2: i64,
163     }
164 
165     pub struct if_data {
166         pub ifi_type: ::c_uchar,
167         pub ifi_physical: ::c_uchar,
168         pub ifi_addrlen: ::c_uchar,
169         pub ifi_hdrlen: ::c_uchar,
170         pub ifi_recvquota: ::c_uchar,
171         pub ifi_xmitquota: ::c_uchar,
172         pub ifi_mtu: ::c_ulong,
173         pub ifi_metric: ::c_ulong,
174         pub ifi_link_state: ::c_ulong,
175         pub ifi_baudrate: u64,
176         pub ifi_ipackets: ::c_ulong,
177         pub ifi_ierrors: ::c_ulong,
178         pub ifi_opackets: ::c_ulong,
179         pub ifi_oerrors: ::c_ulong,
180         pub ifi_collisions: ::c_ulong,
181         pub ifi_ibytes: ::c_ulong,
182         pub ifi_obytes: ::c_ulong,
183         pub ifi_imcasts: ::c_ulong,
184         pub ifi_omcasts: ::c_ulong,
185         pub ifi_iqdrops: ::c_ulong,
186         pub ifi_noproto: ::c_ulong,
187         pub ifi_hwassist: ::c_ulong,
188         pub ifi_oqdrops: ::c_ulong,
189         pub ifi_lastchange: ::timeval,
190     }
191 
192     pub struct if_msghdr {
193         pub ifm_msglen: ::c_ushort,
194         pub ifm_version: ::c_uchar,
195         pub ifm_type: ::c_uchar,
196         pub ifm_addrs: ::c_int,
197         pub ifm_flags: ::c_int,
198         pub ifm_index: ::c_ushort,
199         pub ifm_data: if_data,
200     }
201 
202     pub struct sockaddr_dl {
203         pub sdl_len: ::c_uchar,
204         pub sdl_family: ::c_uchar,
205         pub sdl_index: ::c_ushort,
206         pub sdl_type: ::c_uchar,
207         pub sdl_nlen: ::c_uchar,
208         pub sdl_alen: ::c_uchar,
209         pub sdl_slen: ::c_uchar,
210         pub sdl_data: [::c_char; 12],
211         pub sdl_rcf: ::c_ushort,
212         pub sdl_route: [::c_ushort; 16],
213     }
214 
215     pub struct xucred {
216         pub cr_version: ::c_uint,
217         pub cr_uid: ::uid_t,
218         pub cr_ngroups: ::c_short,
219         pub cr_groups: [::gid_t; 16],
220         __cr_unused1: *mut ::c_void,
221     }
222 
223     pub struct stack_t {
224         pub ss_sp: *mut ::c_void,
225         pub ss_size: ::size_t,
226         pub ss_flags: ::c_int,
227     }
228 
229     pub struct cpumask_t {
230         ary: [u64; 4],
231     }
232 
233     pub struct shmid_ds {
234         pub shm_perm: ::ipc_perm,
235         pub shm_segsz: ::size_t,
236         pub shm_lpid: ::pid_t,
237         pub shm_cpid: ::pid_t,
238         pub shm_nattch: ::shmatt_t,
239         pub shm_atime: ::time_t,
240         pub shm_dtime: ::time_t,
241         pub shm_ctime: ::time_t,
242         shm_internal: *mut ::c_void,
243     }
244 
245     pub struct kinfo_file {
246         pub f_size: ::size_t,
247         pub f_pid: ::pid_t,
248         pub f_uid: ::uid_t,
249         pub f_fd: ::c_int,
250         pub f_file: *mut ::c_void,
251         pub f_type: ::c_short,
252         pub f_count: ::c_int,
253         pub f_msgcount: ::c_int,
254         pub f_offset: ::off_t,
255         pub f_data: *mut ::c_void,
256         pub f_flag: ::c_uint,
257     }
258 
259     pub struct kinfo_cputime {
260         pub cp_user: u64,
261         pub cp_nice: u64,
262         pub cp_sys: u64,
263         pub cp_intr: u64,
264         pub cp_idel: u64,
265         cp_unused01: u64,
266         cp_unused02: u64,
267         pub cp_sample_pc: u64,
268         pub cp_sample_sp: u64,
269         pub cp_msg: [::c_char; 32],
270     }
271 
272     pub struct kinfo_lwp {
273         pub kl_pid: ::pid_t,
274         pub kl_tid: ::lwpid_t,
275         pub kl_flags: ::c_int,
276         pub kl_stat: ::lwpstat,
277         pub kl_lock: ::c_int,
278         pub kl_tdflags: ::c_int,
279         pub kl_mpcount: ::c_int,
280         pub kl_prio: ::c_int,
281         pub kl_tdprio: ::c_int,
282         pub kl_rtprio: ::rtprio,
283         pub kl_uticks: u64,
284         pub kl_sticks: u64,
285         pub kl_iticks: u64,
286         pub kl_cpticks: u64,
287         pub kl_pctcpu: ::c_uint,
288         pub kl_slptime: ::c_uint,
289         pub kl_origcpu: ::c_int,
290         pub kl_estcpu: ::c_int,
291         pub kl_cpuid: ::c_int,
292         pub kl_ru: ::rusage,
293         pub kl_siglist: ::sigset_t,
294         pub kl_sigmask: ::sigset_t,
295         pub kl_wchan: ::uintptr_t,
296         pub kl_wmesg: [::c_char; 9],
297         pub kl_comm: [::c_char; MAXCOMLEN+1],
298     }
299 
300     pub struct kinfo_proc {
301         pub kp_paddr: ::uintptr_t,
302         pub kp_flags: ::c_int,
303         pub kp_stat: ::procstat,
304         pub kp_lock: ::c_int,
305         pub kp_acflag: ::c_int,
306         pub kp_traceflag: ::c_int,
307         pub kp_fd: ::uintptr_t,
308         pub kp_siglist: ::sigset_t,
309         pub kp_sigignore: ::sigset_t,
310         pub kp_sigcatch: ::sigset_t,
311         pub kp_sigflag: ::c_int,
312         pub kp_start: ::timeval,
313         pub kp_comm: [::c_char; MAXCOMLEN+1],
314         pub kp_uid: ::uid_t,
315         pub kp_ngroups: ::c_short,
316         pub kp_groups: [::gid_t; NGROUPS],
317         pub kp_ruid: ::uid_t,
318         pub kp_svuid: ::uid_t,
319         pub kp_rgid: ::gid_t,
320         pub kp_svgid: ::gid_t,
321         pub kp_pid: ::pid_t,
322         pub kp_ppid: ::pid_t,
323         pub kp_pgid: ::pid_t,
324         pub kp_jobc: ::c_int,
325         pub kp_sid: ::pid_t,
326         pub kp_login: [::c_char; 40], // MAXNAMELEN rounded up to the nearest sizeof(long)
327         pub kp_tdev: ::dev_t,
328         pub kp_tpgid: ::pid_t,
329         pub kp_tsid: ::pid_t,
330         pub kp_exitstat: ::c_ushort,
331         pub kp_nthreads: ::c_int,
332         pub kp_nice: ::c_int,
333         pub kp_swtime: ::c_uint,
334         pub kp_vm_map_size: ::size_t,
335         pub kp_vm_rssize: ::segsz_t,
336         pub kp_vm_swrss: ::segsz_t,
337         pub kp_vm_tsize: ::segsz_t,
338         pub kp_vm_dsize: ::segsz_t,
339         pub kp_vm_ssize: ::segsz_t,
340         pub kp_vm_prssize: ::c_uint,
341         pub kp_jailid: ::c_int,
342         pub kp_ru: ::rusage,
343         pub kp_cru: ::rusage,
344         pub kp_auxflags: ::c_int,
345         pub kp_lwp: ::kinfo_lwp,
346         pub kp_ktaddr: ::uintptr_t,
347         kp_spare: [::c_int; 2],
348     }
349 
350     pub struct __c_anonymous_vm_map {
351         _priv: [::uintptr_t; 36],
352     }
353 
354     pub struct vm_map_entry {
355         _priv: [::uintptr_t; 15],
356         pub eflags: ::vm_eflags_t,
357         pub maptype: ::vm_maptype_t,
358         pub protection: ::vm_prot_t,
359         pub max_protection: ::vm_prot_t,
360         pub inheritance: ::vm_inherit_t,
361         pub wired_count: ::c_int,
362         pub id: ::vm_subsys_t,
363     }
364 
365     pub struct __c_anonymous_pmap {
366         _priv1: [::uintptr_t; 32],
367         _priv2: [::uintptr_t; 32],
368         _priv3: [::uintptr_t; 32],
369         _priv4: [::uintptr_t; 32],
370         _priv5: [::uintptr_t; 8],
371     }
372 
373     pub struct vmspace {
374         vm_map: __c_anonymous_vm_map,
375         vm_pmap: __c_anonymous_pmap,
376         pub vm_flags: ::c_int,
377         pub vm_shm: *mut ::c_char,
378         pub vm_rssize: ::segsz_t,
379         pub vm_swrss: ::segsz_t,
380         pub vm_tsize: ::segsz_t,
381         pub vm_dsize: ::segsz_t,
382         pub vm_ssize: ::segsz_t,
383         pub vm_taddr: *mut ::c_char,
384         pub vm_daddr: *mut ::c_char,
385         pub vm_maxsaddr: *mut ::c_char,
386         pub vm_minsaddr: *mut ::c_char,
387         _unused1: ::c_int,
388         _unused2: ::c_int,
389         pub vm_pagesupply: ::c_int,
390         pub vm_holdcnt: ::c_uint,
391         pub vm_refcnt: ::c_uint,
392     }
393 
394     pub struct cpuctl_msr_args_t {
395         pub msr: ::c_int,
396         pub data: u64,
397     }
398 
399     pub struct cpuctl_cpuid_args_t {
400         pub level: ::c_int,
401         pub data: [u32; 4],
402     }
403 
404     pub struct cpuctl_cpuid_count_args_t {
405         pub level: ::c_int,
406         pub level_type: ::c_int,
407         pub data: [u32; 4],
408     }
409 
410     pub struct cpuctl_update_args_t {
411         pub data: *mut ::c_void,
412         pub size: ::size_t,
413     }
414 }
415 
416 s_no_extra_traits! {
417     pub struct utmpx {
418         pub ut_name: [::c_char; 32],
419         pub ut_id: [::c_char; 4],
420 
421         pub ut_line: [::c_char; 32],
422         pub ut_host: [::c_char; 256],
423 
424         pub ut_unused: [u8; 16],
425         pub ut_session: u16,
426         pub ut_type: u16,
427         pub ut_pid: ::pid_t,
428         ut_exit: exit_status,
429         ut_ss: ::sockaddr_storage,
430         pub ut_tv: ::timeval,
431         pub ut_unused2: [u8; 16],
432     }
433 
434     pub struct lastlogx {
435         pub ll_tv: ::timeval,
436         pub ll_line: [::c_char; _UTX_LINESIZE],
437         pub ll_host: [::c_char; _UTX_HOSTSIZE],
438         pub ll_ss: ::sockaddr_storage,
439     }
440 
441     pub struct dirent {
442         pub d_fileno: ::ino_t,
443         pub d_namlen: u16,
444         pub d_type: u8,
445         __unused1: u8,
446         __unused2: u32,
447         pub d_name: [::c_char; 256],
448     }
449 
450     pub struct statfs {
451         __spare2: ::c_long,
452         pub f_bsize: ::c_long,
453         pub f_iosize: ::c_long,
454         pub f_blocks: ::c_long,
455         pub f_bfree: ::c_long,
456         pub f_bavail: ::c_long,
457         pub f_files: ::c_long,
458         pub f_ffree: ::c_long,
459         pub f_fsid: ::fsid_t,
460         pub f_owner: ::uid_t,
461         pub f_type: ::c_int,
462         pub f_flags: ::c_int,
463         pub f_syncwrites: ::c_long,
464         pub f_asyncwrites: ::c_long,
465         pub f_fstypename: [::c_char; 16],
466         pub f_mntonname: [::c_char; 80],
467         pub f_syncreads: ::c_long,
468         pub f_asyncreads: ::c_long,
469         __spares1: ::c_short,
470         pub f_mntfromname: [::c_char; 80],
471         __spares2: ::c_short,
472         __spare: [::c_long; 2],
473     }
474 
475     pub struct sigevent {
476         pub sigev_notify: ::c_int,
477         // The union is 8-byte in size, so it is aligned at a 8-byte offset.
478         #[cfg(target_pointer_width = "64")]
479         __unused1: ::c_int,
480         pub sigev_signo: ::c_int,       //actually a union
481         // pad the union
482         #[cfg(target_pointer_width = "64")]
483         __unused2: ::c_int,
484         pub sigev_value: ::sigval,
485         __unused3: *mut ::c_void        //actually a function pointer
486     }
487 
488     pub struct mcontext_t {
489         pub mc_onstack: register_t,
490         pub mc_rdi: register_t,
491         pub mc_rsi: register_t,
492         pub mc_rdx: register_t,
493         pub mc_rcx: register_t,
494         pub mc_r8: register_t,
495         pub mc_r9: register_t,
496         pub mc_rax: register_t,
497         pub mc_rbx: register_t,
498         pub mc_rbp: register_t,
499         pub mc_r10: register_t,
500         pub mc_r11: register_t,
501         pub mc_r12: register_t,
502         pub mc_r13: register_t,
503         pub mc_r14: register_t,
504         pub mc_r15: register_t,
505         pub mc_xflags: register_t,
506         pub mc_trapno: register_t,
507         pub mc_addr: register_t,
508         pub mc_flags: register_t,
509         pub mc_err: register_t,
510         pub mc_rip: register_t,
511         pub mc_cs: register_t,
512         pub mc_rflags: register_t,
513         pub mc_rsp: register_t,
514         pub mc_ss: register_t,
515         pub mc_len: ::c_uint,
516         pub mc_fpformat: ::c_uint,
517         pub mc_ownedfp: ::c_uint,
518         __reserved: ::c_uint,
519         __unused: [::c_uint; 8],
520         pub mc_fpregs: [[::c_uint; 8]; 32],
521     }
522 
523     pub struct ucontext_t {
524         pub uc_sigmask: ::sigset_t,
525         pub uc_mcontext: mcontext_t,
526         pub uc_link: *mut ucontext_t,
527         pub uc_stack: stack_t,
528         pub uc_cofunc: ::Option<unsafe extern "C" fn(uc: *mut ucontext_t, arg: *mut ::c_void)>,
529         pub uc_arg: *mut ::c_void,
530         __pad: [::c_int; 4],
531     }
532 }
533 
534 cfg_if! {
535     if #[cfg(feature = "extra_traits")] {
536         impl PartialEq for utmpx {
537             fn eq(&self, other: &utmpx) -> bool {
538                 self.ut_name == other.ut_name
539                     && self.ut_id == other.ut_id
540                     && self.ut_line == other.ut_line
541                     && self
542                     .ut_host
543                     .iter()
544                     .zip(other.ut_host.iter())
545                     .all(|(a,b)| a == b)
546                     && self.ut_unused == other.ut_unused
547                     && self.ut_session == other.ut_session
548                     && self.ut_type == other.ut_type
549                     && self.ut_pid == other.ut_pid
550                     && self.ut_exit == other.ut_exit
551                     && self.ut_ss == other.ut_ss
552                     && self.ut_tv == other.ut_tv
553                     && self.ut_unused2 == other.ut_unused2
554             }
555         }
556         impl Eq for utmpx {}
557         impl ::fmt::Debug for utmpx {
558             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
559                 f.debug_struct("utmpx")
560                     .field("ut_name", &self.ut_name)
561                     .field("ut_id", &self.ut_id)
562                     .field("ut_line", &self.ut_line)
563                     // FIXME: .field("ut_host", &self.ut_host)
564                     .field("ut_unused", &self.ut_unused)
565                     .field("ut_session", &self.ut_session)
566                     .field("ut_type", &self.ut_type)
567                     .field("ut_pid", &self.ut_pid)
568                     .field("ut_exit", &self.ut_exit)
569                     .field("ut_ss", &self.ut_ss)
570                     .field("ut_tv", &self.ut_tv)
571                     .field("ut_unused2", &self.ut_unused2)
572                     .finish()
573             }
574         }
575         impl ::hash::Hash for utmpx {
576             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
577                 self.ut_name.hash(state);
578                 self.ut_id.hash(state);
579                 self.ut_line.hash(state);
580                 self.ut_host.hash(state);
581                 self.ut_unused.hash(state);
582                 self.ut_session.hash(state);
583                 self.ut_type.hash(state);
584                 self.ut_pid.hash(state);
585                 self.ut_exit.hash(state);
586                 self.ut_ss.hash(state);
587                 self.ut_tv.hash(state);
588                 self.ut_unused2.hash(state);
589             }
590         }
591         impl PartialEq for lastlogx {
592             fn eq(&self, other: &lastlogx) -> bool {
593                 self.ll_tv == other.ll_tv
594                     && self.ll_line == other.ll_line
595                     && self.ll_host == other.ll_host
596                     && self.ll_ss == other.ll_ss
597             }
598         }
599         impl Eq for lastlogx {}
600         impl ::fmt::Debug for lastlogx {
601             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
602                 f.debug_struct("lastlogx")
603                     .field("ll_tv", &self.ll_tv)
604                     .field("ll_line", &self.ll_line)
605                     .field("ll_host", &self.ll_host)
606                     .field("ll_ss", &self.ll_ss)
607                     .finish()
608             }
609         }
610         impl ::hash::Hash for lastlogx {
611             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
612                 self.ll_tv.hash(state);
613                 self.ll_line.hash(state);
614                 self.ll_host.hash(state);
615                 self.ll_ss.hash(state);
616             }
617         }
618 
619         impl PartialEq for dirent {
620             fn eq(&self, other: &dirent) -> bool {
621                 self.d_fileno == other.d_fileno
622                     && self.d_namlen == other.d_namlen
623                     && self.d_type == other.d_type
624                     // Ignore __unused1
625                     // Ignore __unused2
626                     && self
627                     .d_name
628                     .iter()
629                     .zip(other.d_name.iter())
630                     .all(|(a,b)| a == b)
631             }
632         }
633         impl Eq for dirent {}
634         impl ::fmt::Debug for dirent {
635             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
636                 f.debug_struct("dirent")
637                     .field("d_fileno", &self.d_fileno)
638                     .field("d_namlen", &self.d_namlen)
639                     .field("d_type", &self.d_type)
640                     // Ignore __unused1
641                     // Ignore __unused2
642                     // FIXME: .field("d_name", &self.d_name)
643                     .finish()
644             }
645         }
646         impl ::hash::Hash for dirent {
647             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
648                 self.d_fileno.hash(state);
649                 self.d_namlen.hash(state);
650                 self.d_type.hash(state);
651                     // Ignore __unused1
652                     // Ignore __unused2
653                 self.d_name.hash(state);
654             }
655         }
656 
657         impl PartialEq for statfs {
658             fn eq(&self, other: &statfs) -> bool {
659                 self.f_bsize == other.f_bsize
660                     && self.f_iosize == other.f_iosize
661                     && self.f_blocks == other.f_blocks
662                     && self.f_bfree == other.f_bfree
663                     && self.f_bavail == other.f_bavail
664                     && self.f_files == other.f_files
665                     && self.f_ffree == other.f_ffree
666                     && self.f_fsid == other.f_fsid
667                     && self.f_owner == other.f_owner
668                     && self.f_type == other.f_type
669                     && self.f_flags == other.f_flags
670                     && self.f_syncwrites == other.f_syncwrites
671                     && self.f_asyncwrites == other.f_asyncwrites
672                     && self.f_fstypename == other.f_fstypename
673                     && self
674                     .f_mntonname
675                     .iter()
676                     .zip(other.f_mntonname.iter())
677                     .all(|(a,b)| a == b)
678                     && self.f_syncreads == other.f_syncreads
679                     && self.f_asyncreads == other.f_asyncreads
680                     && self
681                     .f_mntfromname
682                     .iter()
683                     .zip(other.f_mntfromname.iter())
684                     .all(|(a,b)| a == b)
685             }
686         }
687         impl Eq for statfs {}
688         impl ::fmt::Debug for statfs {
689             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
690                 f.debug_struct("statfs")
691                     .field("f_bsize", &self.f_bsize)
692                     .field("f_iosize", &self.f_iosize)
693                     .field("f_blocks", &self.f_blocks)
694                     .field("f_bfree", &self.f_bfree)
695                     .field("f_bavail", &self.f_bavail)
696                     .field("f_files", &self.f_files)
697                     .field("f_ffree", &self.f_ffree)
698                     .field("f_fsid", &self.f_fsid)
699                     .field("f_owner", &self.f_owner)
700                     .field("f_type", &self.f_type)
701                     .field("f_flags", &self.f_flags)
702                     .field("f_syncwrites", &self.f_syncwrites)
703                     .field("f_asyncwrites", &self.f_asyncwrites)
704                     // FIXME: .field("f_mntonname", &self.f_mntonname)
705                     .field("f_syncreads", &self.f_syncreads)
706                     .field("f_asyncreads", &self.f_asyncreads)
707                     // FIXME: .field("f_mntfromname", &self.f_mntfromname)
708                     .finish()
709             }
710         }
711         impl ::hash::Hash for statfs {
712             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
713                 self.f_bsize.hash(state);
714                 self.f_iosize.hash(state);
715                 self.f_blocks.hash(state);
716                 self.f_bfree.hash(state);
717                 self.f_bavail.hash(state);
718                 self.f_files.hash(state);
719                 self.f_ffree.hash(state);
720                 self.f_fsid.hash(state);
721                 self.f_owner.hash(state);
722                 self.f_type.hash(state);
723                 self.f_flags.hash(state);
724                 self.f_syncwrites.hash(state);
725                 self.f_asyncwrites.hash(state);
726                 self.f_fstypename.hash(state);
727                 self.f_mntonname.hash(state);
728                 self.f_syncreads.hash(state);
729                 self.f_asyncreads.hash(state);
730                 self.f_mntfromname.hash(state);
731             }
732         }
733 
734         impl PartialEq for sigevent {
735             fn eq(&self, other: &sigevent) -> bool {
736                 self.sigev_notify == other.sigev_notify
737                     && self.sigev_signo == other.sigev_signo
738                     && self.sigev_value == other.sigev_value
739             }
740         }
741         impl Eq for sigevent {}
742         impl ::fmt::Debug for sigevent {
743             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
744                 f.debug_struct("sigevent")
745                     .field("sigev_notify", &self.sigev_notify)
746                     .field("sigev_signo", &self.sigev_signo)
747                     .field("sigev_value", &self.sigev_value)
748                     .finish()
749             }
750         }
751         impl ::hash::Hash for sigevent {
752             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
753                 self.sigev_notify.hash(state);
754                 self.sigev_signo.hash(state);
755                 self.sigev_value.hash(state);
756             }
757         }
758         impl PartialEq for mcontext_t {
759             fn eq(&self, other: &mcontext_t) -> bool {
760                 self.mc_onstack == other.mc_onstack &&
761                 self.mc_rdi == other.mc_rdi &&
762                 self.mc_rsi == other.mc_rsi &&
763                 self.mc_rdx == other.mc_rdx &&
764                 self.mc_rcx == other.mc_rcx &&
765                 self.mc_r8 == other.mc_r8 &&
766                 self.mc_r9 == other.mc_r9 &&
767                 self.mc_rax == other.mc_rax &&
768                 self.mc_rbx == other.mc_rbx &&
769                 self.mc_rbp == other.mc_rbp &&
770                 self.mc_r10 == other.mc_r10 &&
771                 self.mc_r11 == other.mc_r11 &&
772                 self.mc_r12 == other.mc_r12 &&
773                 self.mc_r13 == other.mc_r13 &&
774                 self.mc_r14 == other.mc_r14 &&
775                 self.mc_r15 == other.mc_r15 &&
776                 self.mc_xflags == other.mc_xflags &&
777                 self.mc_trapno == other.mc_trapno &&
778                 self.mc_addr == other.mc_addr &&
779                 self.mc_flags == other.mc_flags &&
780                 self.mc_err == other.mc_err &&
781                 self.mc_rip == other.mc_rip &&
782                 self.mc_cs == other.mc_cs &&
783                 self.mc_rflags == other.mc_rflags &&
784                 self.mc_rsp == other.mc_rsp &&
785                 self.mc_ss == other.mc_ss &&
786                 self.mc_len == other.mc_len &&
787                 self.mc_fpformat == other.mc_fpformat &&
788                 self.mc_ownedfp == other.mc_ownedfp &&
789                 self.mc_fpregs.iter().zip(other.mc_fpregs.iter()).
790                 all(|(a, b)| a == b)
791             }
792         }
793         impl Eq for mcontext_t {}
794         impl ::fmt::Debug for mcontext_t {
795             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
796                 f.debug_struct("mcontext_t")
797                     .field("mc_onstack", &self.mc_onstack)
798                     .field("mc_rdi", &self.mc_rdi)
799                     .field("mc_rsi", &self.mc_rsi)
800                     .field("mc_rdx", &self.mc_rdx)
801                     .field("mc_rcx", &self.mc_rcx)
802                     .field("mc_r8", &self.mc_r8)
803                     .field("mc_r9", &self.mc_r9)
804                     .field("mc_rax", &self.mc_rax)
805                     .field("mc_rbx", &self.mc_rbx)
806                     .field("mc_rbp", &self.mc_rbp)
807                     .field("mc_r10", &self.mc_r10)
808                     .field("mc_r11", &self.mc_r11)
809                     .field("mc_r12", &self.mc_r12)
810                     .field("mc_r13", &self.mc_r13)
811                     .field("mc_r14", &self.mc_r14)
812                     .field("mc_r15", &self.mc_r15)
813                     .field("mc_xflags", &self.mc_xflags)
814                     .field("mc_trapno", &self.mc_trapno)
815                     .field("mc_addr", &self.mc_addr)
816                     .field("mc_flags", &self.mc_flags)
817                     .field("mc_err", &self.mc_err)
818                     .field("mc_rip", &self.mc_rip)
819                     .field("mc_cs", &self.mc_cs)
820                     .field("mc_rflags", &self.mc_rflags)
821                     .field("mc_rsp", &self.mc_rsp)
822                     .field("mc_ss", &self.mc_ss)
823                     .field("mc_len", &self.mc_len)
824                     .field("mc_fpformat", &self.mc_fpformat)
825                     .field("mc_ownedfp", &self.mc_ownedfp)
826                     .field("mc_fpregs", &self.mc_fpregs)
827                     .finish()
828             }
829         }
830         impl ::hash::Hash for mcontext_t {
831             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
832                 self.mc_onstack.hash(state);
833                 self.mc_rdi.hash(state);
834                 self.mc_rsi.hash(state);
835                 self.mc_rdx.hash(state);
836                 self.mc_rcx.hash(state);
837                 self.mc_r8.hash(state);
838                 self.mc_r9.hash(state);
839                 self.mc_rax.hash(state);
840                 self.mc_rbx.hash(state);
841                 self.mc_rbp.hash(state);
842                 self.mc_r10.hash(state);
843                 self.mc_r11.hash(state);
844                 self.mc_r10.hash(state);
845                 self.mc_r11.hash(state);
846                 self.mc_r12.hash(state);
847                 self.mc_r13.hash(state);
848                 self.mc_r14.hash(state);
849                 self.mc_r15.hash(state);
850                 self.mc_xflags.hash(state);
851                 self.mc_trapno.hash(state);
852                 self.mc_addr.hash(state);
853                 self.mc_flags.hash(state);
854                 self.mc_err.hash(state);
855                 self.mc_rip.hash(state);
856                 self.mc_cs.hash(state);
857                 self.mc_rflags.hash(state);
858                 self.mc_rsp.hash(state);
859                 self.mc_ss.hash(state);
860                 self.mc_len.hash(state);
861                 self.mc_fpformat.hash(state);
862                 self.mc_ownedfp.hash(state);
863                 self.mc_fpregs.hash(state);
864             }
865         }
866         impl PartialEq for ucontext_t {
867             fn eq(&self, other: &ucontext_t) -> bool {
868                 self.uc_sigmask == other.uc_sigmask
869                     && self.uc_mcontext == other.uc_mcontext
870                     && self.uc_link == other.uc_link
871                     && self.uc_stack == other.uc_stack
872                     && self.uc_cofunc == other.uc_cofunc
873                     && self.uc_arg == other.uc_arg
874             }
875         }
876         impl Eq for ucontext_t {}
877         impl ::fmt::Debug for ucontext_t {
878             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
879                 f.debug_struct("ucontext_t")
880                     .field("uc_sigmask", &self.uc_sigmask)
881                     .field("uc_mcontext", &self.uc_mcontext)
882                     .field("uc_link", &self.uc_link)
883                     .field("uc_stack", &self.uc_stack)
884                     .field("uc_cofunc", &self.uc_cofunc)
885                     .field("uc_arg", &self.uc_arg)
886                     .finish()
887             }
888         }
889         impl ::hash::Hash for ucontext_t {
890             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
891                 self.uc_sigmask.hash(state);
892                 self.uc_mcontext.hash(state);
893                 self.uc_link.hash(state);
894                 self.uc_stack.hash(state);
895                 self.uc_cofunc.hash(state);
896                 self.uc_arg.hash(state);
897             }
898         }
899     }
900 }
901 
902 pub const RAND_MAX: ::c_int = 0x7fff_ffff;
903 pub const PTHREAD_STACK_MIN: ::size_t = 16384;
904 pub const SIGSTKSZ: ::size_t = 40960;
905 pub const SIGCKPT: ::c_int = 33;
906 pub const SIGCKPTEXIT: ::c_int = 34;
907 pub const CKPT_FREEZE: ::c_int = 0x1;
908 pub const CKPT_THAW: ::c_int = 0x2;
909 pub const MADV_INVAL: ::c_int = 10;
910 pub const MADV_SETMAP: ::c_int = 11;
911 pub const O_CLOEXEC: ::c_int = 0x00020000;
912 pub const O_DIRECTORY: ::c_int = 0x08000000;
913 pub const F_GETLK: ::c_int = 7;
914 pub const F_SETLK: ::c_int = 8;
915 pub const F_SETLKW: ::c_int = 9;
916 pub const F_GETPATH: ::c_int = 19;
917 pub const ENOMEDIUM: ::c_int = 93;
918 pub const ENOTRECOVERABLE: ::c_int = 94;
919 pub const EOWNERDEAD: ::c_int = 95;
920 pub const EASYNC: ::c_int = 99;
921 pub const ELAST: ::c_int = 99;
922 pub const RLIMIT_POSIXLOCKS: ::c_int = 11;
923 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
924 pub const RLIM_NLIMITS: ::rlim_t = 12;
925 
926 pub const Q_GETQUOTA: ::c_int = 0x300;
927 pub const Q_SETQUOTA: ::c_int = 0x400;
928 
929 pub const CTL_UNSPEC: ::c_int = 0;
930 pub const CTL_KERN: ::c_int = 1;
931 pub const CTL_VM: ::c_int = 2;
932 pub const CTL_VFS: ::c_int = 3;
933 pub const CTL_NET: ::c_int = 4;
934 pub const CTL_DEBUG: ::c_int = 5;
935 pub const CTL_HW: ::c_int = 6;
936 pub const CTL_MACHDEP: ::c_int = 7;
937 pub const CTL_USER: ::c_int = 8;
938 pub const CTL_P1003_1B: ::c_int = 9;
939 pub const CTL_LWKT: ::c_int = 10;
940 pub const CTL_MAXID: ::c_int = 11;
941 pub const KERN_OSTYPE: ::c_int = 1;
942 pub const KERN_OSRELEASE: ::c_int = 2;
943 pub const KERN_OSREV: ::c_int = 3;
944 pub const KERN_VERSION: ::c_int = 4;
945 pub const KERN_MAXVNODES: ::c_int = 5;
946 pub const KERN_MAXPROC: ::c_int = 6;
947 pub const KERN_MAXFILES: ::c_int = 7;
948 pub const KERN_ARGMAX: ::c_int = 8;
949 pub const KERN_SECURELVL: ::c_int = 9;
950 pub const KERN_HOSTNAME: ::c_int = 10;
951 pub const KERN_HOSTID: ::c_int = 11;
952 pub const KERN_CLOCKRATE: ::c_int = 12;
953 pub const KERN_VNODE: ::c_int = 13;
954 pub const KERN_PROC: ::c_int = 14;
955 pub const KERN_FILE: ::c_int = 15;
956 pub const KERN_PROF: ::c_int = 16;
957 pub const KERN_POSIX1: ::c_int = 17;
958 pub const KERN_NGROUPS: ::c_int = 18;
959 pub const KERN_JOB_CONTROL: ::c_int = 19;
960 pub const KERN_SAVED_IDS: ::c_int = 20;
961 pub const KERN_BOOTTIME: ::c_int = 21;
962 pub const KERN_NISDOMAINNAME: ::c_int = 22;
963 pub const KERN_UPDATEINTERVAL: ::c_int = 23;
964 pub const KERN_OSRELDATE: ::c_int = 24;
965 pub const KERN_NTP_PLL: ::c_int = 25;
966 pub const KERN_BOOTFILE: ::c_int = 26;
967 pub const KERN_MAXFILESPERPROC: ::c_int = 27;
968 pub const KERN_MAXPROCPERUID: ::c_int = 28;
969 pub const KERN_DUMPDEV: ::c_int = 29;
970 pub const KERN_IPC: ::c_int = 30;
971 pub const KERN_DUMMY: ::c_int = 31;
972 pub const KERN_PS_STRINGS: ::c_int = 32;
973 pub const KERN_USRSTACK: ::c_int = 33;
974 pub const KERN_LOGSIGEXIT: ::c_int = 34;
975 pub const KERN_IOV_MAX: ::c_int = 35;
976 pub const KERN_MAXPOSIXLOCKSPERUID: ::c_int = 36;
977 pub const KERN_MAXID: ::c_int = 37;
978 pub const KERN_PROC_ALL: ::c_int = 0;
979 pub const KERN_PROC_PID: ::c_int = 1;
980 pub const KERN_PROC_PGRP: ::c_int = 2;
981 pub const KERN_PROC_SESSION: ::c_int = 3;
982 pub const KERN_PROC_TTY: ::c_int = 4;
983 pub const KERN_PROC_UID: ::c_int = 5;
984 pub const KERN_PROC_RUID: ::c_int = 6;
985 pub const KERN_PROC_ARGS: ::c_int = 7;
986 pub const KERN_PROC_CWD: ::c_int = 8;
987 pub const KERN_PROC_PATHNAME: ::c_int = 9;
988 pub const KERN_PROC_FLAGMASK: ::c_int = 0x10;
989 pub const KERN_PROC_FLAG_LWP: ::c_int = 0x10;
990 pub const KIPC_MAXSOCKBUF: ::c_int = 1;
991 pub const KIPC_SOCKBUF_WASTE: ::c_int = 2;
992 pub const KIPC_SOMAXCONN: ::c_int = 3;
993 pub const KIPC_MAX_LINKHDR: ::c_int = 4;
994 pub const KIPC_MAX_PROTOHDR: ::c_int = 5;
995 pub const KIPC_MAX_HDR: ::c_int = 6;
996 pub const KIPC_MAX_DATALEN: ::c_int = 7;
997 pub const KIPC_MBSTAT: ::c_int = 8;
998 pub const KIPC_NMBCLUSTERS: ::c_int = 9;
999 pub const HW_MACHINE: ::c_int = 1;
1000 pub const HW_MODEL: ::c_int = 2;
1001 pub const HW_NCPU: ::c_int = 3;
1002 pub const HW_BYTEORDER: ::c_int = 4;
1003 pub const HW_PHYSMEM: ::c_int = 5;
1004 pub const HW_USERMEM: ::c_int = 6;
1005 pub const HW_PAGESIZE: ::c_int = 7;
1006 pub const HW_DISKNAMES: ::c_int = 8;
1007 pub const HW_DISKSTATS: ::c_int = 9;
1008 pub const HW_FLOATINGPT: ::c_int = 10;
1009 pub const HW_MACHINE_ARCH: ::c_int = 11;
1010 pub const HW_MACHINE_PLATFORM: ::c_int = 12;
1011 pub const HW_SENSORS: ::c_int = 13;
1012 pub const HW_MAXID: ::c_int = 14;
1013 pub const USER_CS_PATH: ::c_int = 1;
1014 pub const USER_BC_BASE_MAX: ::c_int = 2;
1015 pub const USER_BC_DIM_MAX: ::c_int = 3;
1016 pub const USER_BC_SCALE_MAX: ::c_int = 4;
1017 pub const USER_BC_STRING_MAX: ::c_int = 5;
1018 pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6;
1019 pub const USER_EXPR_NEST_MAX: ::c_int = 7;
1020 pub const USER_LINE_MAX: ::c_int = 8;
1021 pub const USER_RE_DUP_MAX: ::c_int = 9;
1022 pub const USER_POSIX2_VERSION: ::c_int = 10;
1023 pub const USER_POSIX2_C_BIND: ::c_int = 11;
1024 pub const USER_POSIX2_C_DEV: ::c_int = 12;
1025 pub const USER_POSIX2_CHAR_TERM: ::c_int = 13;
1026 pub const USER_POSIX2_FORT_DEV: ::c_int = 14;
1027 pub const USER_POSIX2_FORT_RUN: ::c_int = 15;
1028 pub const USER_POSIX2_LOCALEDEF: ::c_int = 16;
1029 pub const USER_POSIX2_SW_DEV: ::c_int = 17;
1030 pub const USER_POSIX2_UPE: ::c_int = 18;
1031 pub const USER_STREAM_MAX: ::c_int = 19;
1032 pub const USER_TZNAME_MAX: ::c_int = 20;
1033 pub const USER_MAXID: ::c_int = 21;
1034 pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1;
1035 pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2;
1036 pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3;
1037 pub const CTL_P1003_1B_MEMLOCK_RANGE: ::c_int = 4;
1038 pub const CTL_P1003_1B_MEMORY_PROTECTION: ::c_int = 5;
1039 pub const CTL_P1003_1B_MESSAGE_PASSING: ::c_int = 6;
1040 pub const CTL_P1003_1B_PRIORITIZED_IO: ::c_int = 7;
1041 pub const CTL_P1003_1B_PRIORITY_SCHEDULING: ::c_int = 8;
1042 pub const CTL_P1003_1B_REALTIME_SIGNALS: ::c_int = 9;
1043 pub const CTL_P1003_1B_SEMAPHORES: ::c_int = 10;
1044 pub const CTL_P1003_1B_FSYNC: ::c_int = 11;
1045 pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: ::c_int = 12;
1046 pub const CTL_P1003_1B_SYNCHRONIZED_IO: ::c_int = 13;
1047 pub const CTL_P1003_1B_TIMERS: ::c_int = 14;
1048 pub const CTL_P1003_1B_AIO_LISTIO_MAX: ::c_int = 15;
1049 pub const CTL_P1003_1B_AIO_MAX: ::c_int = 16;
1050 pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: ::c_int = 17;
1051 pub const CTL_P1003_1B_DELAYTIMER_MAX: ::c_int = 18;
1052 pub const CTL_P1003_1B_UNUSED1: ::c_int = 19;
1053 pub const CTL_P1003_1B_PAGESIZE: ::c_int = 20;
1054 pub const CTL_P1003_1B_RTSIG_MAX: ::c_int = 21;
1055 pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22;
1056 pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23;
1057 pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24;
1058 pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25;
1059 pub const CTL_P1003_1B_MAXID: ::c_int = 26;
1060 
1061 pub const CPUCTL_RSMSR: ::c_int = 0xc0106301;
1062 pub const CPUCTL_WRMSR: ::c_int = 0xc0106302;
1063 pub const CPUCTL_CPUID: ::c_int = 0xc0106303;
1064 pub const CPUCTL_UPDATE: ::c_int = 0xc0106304;
1065 pub const CPUCTL_MSRSBIT: ::c_int = 0xc0106305;
1066 pub const CPUCTL_MSRCBIT: ::c_int = 0xc0106306;
1067 pub const CPUCTL_CPUID_COUNT: ::c_int = 0xc0106307;
1068 
1069 pub const CPU_SETSIZE: ::size_t = ::mem::size_of::<::cpumask_t>() * 8;
1070 
1071 pub const EVFILT_READ: i16 = -1;
1072 pub const EVFILT_WRITE: i16 = -2;
1073 pub const EVFILT_AIO: i16 = -3;
1074 pub const EVFILT_VNODE: i16 = -4;
1075 pub const EVFILT_PROC: i16 = -5;
1076 pub const EVFILT_SIGNAL: i16 = -6;
1077 pub const EVFILT_TIMER: i16 = -7;
1078 pub const EVFILT_EXCEPT: i16 = -8;
1079 pub const EVFILT_USER: i16 = -9;
1080 pub const EVFILT_FS: i16 = -10;
1081 
1082 pub const EV_ADD: u16 = 0x1;
1083 pub const EV_DELETE: u16 = 0x2;
1084 pub const EV_ENABLE: u16 = 0x4;
1085 pub const EV_DISABLE: u16 = 0x8;
1086 pub const EV_ONESHOT: u16 = 0x10;
1087 pub const EV_CLEAR: u16 = 0x20;
1088 pub const EV_RECEIPT: u16 = 0x40;
1089 pub const EV_DISPATCH: u16 = 0x80;
1090 pub const EV_NODATA: u16 = 0x1000;
1091 pub const EV_FLAG1: u16 = 0x2000;
1092 pub const EV_ERROR: u16 = 0x4000;
1093 pub const EV_EOF: u16 = 0x8000;
1094 pub const EV_HUP: u16 = 0x8000;
1095 pub const EV_SYSFLAGS: u16 = 0xf000;
1096 
1097 pub const FIODNAME: ::c_ulong = 0x80106678;
1098 
1099 pub const NOTE_TRIGGER: u32 = 0x01000000;
1100 pub const NOTE_FFNOP: u32 = 0x00000000;
1101 pub const NOTE_FFAND: u32 = 0x40000000;
1102 pub const NOTE_FFOR: u32 = 0x80000000;
1103 pub const NOTE_FFCOPY: u32 = 0xc0000000;
1104 pub const NOTE_FFCTRLMASK: u32 = 0xc0000000;
1105 pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff;
1106 pub const NOTE_LOWAT: u32 = 0x00000001;
1107 pub const NOTE_OOB: u32 = 0x00000002;
1108 pub const NOTE_DELETE: u32 = 0x00000001;
1109 pub const NOTE_WRITE: u32 = 0x00000002;
1110 pub const NOTE_EXTEND: u32 = 0x00000004;
1111 pub const NOTE_ATTRIB: u32 = 0x00000008;
1112 pub const NOTE_LINK: u32 = 0x00000010;
1113 pub const NOTE_RENAME: u32 = 0x00000020;
1114 pub const NOTE_REVOKE: u32 = 0x00000040;
1115 pub const NOTE_EXIT: u32 = 0x80000000;
1116 pub const NOTE_FORK: u32 = 0x40000000;
1117 pub const NOTE_EXEC: u32 = 0x20000000;
1118 pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1119 pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1120 pub const NOTE_TRACK: u32 = 0x00000001;
1121 pub const NOTE_TRACKERR: u32 = 0x00000002;
1122 pub const NOTE_CHILD: u32 = 0x00000004;
1123 
1124 pub const SO_SNDSPACE: ::c_int = 0x100a;
1125 pub const SO_CPUHINT: ::c_int = 0x1030;
1126 pub const SO_PASSCRED: ::c_int = 0x4000;
1127 
1128 pub const PT_FIRSTMACH: ::c_int = 32;
1129 
1130 pub const PROC_REAP_ACQUIRE: ::c_int = 0x0001;
1131 pub const PROC_REAP_RELEASE: ::c_int = 0x0002;
1132 pub const PROC_REAP_STATUS: ::c_int = 0x0003;
1133 pub const PROC_PDEATHSIG_CTL: ::c_int = 0x0004;
1134 pub const PROC_PDEATHSIG_STATUS: ::c_int = 0x0005;
1135 
1136 // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/HEAD/sys/net/if.h#L101
1137 pub const IFF_UP: ::c_int = 0x1; // interface is up
1138 pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
1139 pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
1140 pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
1141 pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
1142 pub const IFF_SMART: ::c_int = 0x20; // interface manages own routes
1143 pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
1144 pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
1145 pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
1146 pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
1147 pub const IFF_OACTIVE_COMPAT: ::c_int = 0x400; // was transmission in progress
1148 pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
1149 pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
1150 pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
1151 pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
1152 pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
1153 pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
1154                                            // was interface is in polling mode
1155 pub const IFF_POLLING_COMPAT: ::c_int = 0x10000;
1156 pub const IFF_PPROMISC: ::c_int = 0x20000; // user-requested promisc mode
1157 pub const IFF_MONITOR: ::c_int = 0x40000; // user-requested monitor mode
1158 pub const IFF_STATICARP: ::c_int = 0x80000; // static ARP
1159 pub const IFF_NPOLLING: ::c_int = 0x100000; // interface is in polling mode
1160 pub const IFF_IDIRECT: ::c_int = 0x200000; // direct input
1161 
1162 //
1163 // sys/netinet/in.h
1164 // Protocols (RFC 1700)
1165 // NOTE: These are in addition to the constants defined in src/unix/mod.rs
1166 
1167 // IPPROTO_IP defined in src/unix/mod.rs
1168 /// IP6 hop-by-hop options
1169 pub const IPPROTO_HOPOPTS: ::c_int = 0;
1170 // IPPROTO_ICMP defined in src/unix/mod.rs
1171 /// group mgmt protocol
1172 pub const IPPROTO_IGMP: ::c_int = 2;
1173 /// gateway^2 (deprecated)
1174 pub const IPPROTO_GGP: ::c_int = 3;
1175 /// for compatibility
1176 pub const IPPROTO_IPIP: ::c_int = 4;
1177 // IPPROTO_TCP defined in src/unix/mod.rs
1178 /// Stream protocol II.
1179 pub const IPPROTO_ST: ::c_int = 7;
1180 /// exterior gateway protocol
1181 pub const IPPROTO_EGP: ::c_int = 8;
1182 /// private interior gateway
1183 pub const IPPROTO_PIGP: ::c_int = 9;
1184 /// BBN RCC Monitoring
1185 pub const IPPROTO_RCCMON: ::c_int = 10;
1186 /// network voice protocol
1187 pub const IPPROTO_NVPII: ::c_int = 11;
1188 /// pup
1189 pub const IPPROTO_PUP: ::c_int = 12;
1190 /// Argus
1191 pub const IPPROTO_ARGUS: ::c_int = 13;
1192 /// EMCON
1193 pub const IPPROTO_EMCON: ::c_int = 14;
1194 /// Cross Net Debugger
1195 pub const IPPROTO_XNET: ::c_int = 15;
1196 /// Chaos
1197 pub const IPPROTO_CHAOS: ::c_int = 16;
1198 // IPPROTO_UDP defined in src/unix/mod.rs
1199 /// Multiplexing
1200 pub const IPPROTO_MUX: ::c_int = 18;
1201 /// DCN Measurement Subsystems
1202 pub const IPPROTO_MEAS: ::c_int = 19;
1203 /// Host Monitoring
1204 pub const IPPROTO_HMP: ::c_int = 20;
1205 /// Packet Radio Measurement
1206 pub const IPPROTO_PRM: ::c_int = 21;
1207 /// xns idp
1208 pub const IPPROTO_IDP: ::c_int = 22;
1209 /// Trunk-1
1210 pub const IPPROTO_TRUNK1: ::c_int = 23;
1211 /// Trunk-2
1212 pub const IPPROTO_TRUNK2: ::c_int = 24;
1213 /// Leaf-1
1214 pub const IPPROTO_LEAF1: ::c_int = 25;
1215 /// Leaf-2
1216 pub const IPPROTO_LEAF2: ::c_int = 26;
1217 /// Reliable Data
1218 pub const IPPROTO_RDP: ::c_int = 27;
1219 /// Reliable Transaction
1220 pub const IPPROTO_IRTP: ::c_int = 28;
1221 /// tp-4 w/ class negotiation
1222 pub const IPPROTO_TP: ::c_int = 29;
1223 /// Bulk Data Transfer
1224 pub const IPPROTO_BLT: ::c_int = 30;
1225 /// Network Services
1226 pub const IPPROTO_NSP: ::c_int = 31;
1227 /// Merit Internodal
1228 pub const IPPROTO_INP: ::c_int = 32;
1229 /// Sequential Exchange
1230 pub const IPPROTO_SEP: ::c_int = 33;
1231 /// Third Party Connect
1232 pub const IPPROTO_3PC: ::c_int = 34;
1233 /// InterDomain Policy Routing
1234 pub const IPPROTO_IDPR: ::c_int = 35;
1235 /// XTP
1236 pub const IPPROTO_XTP: ::c_int = 36;
1237 /// Datagram Delivery
1238 pub const IPPROTO_DDP: ::c_int = 37;
1239 /// Control Message Transport
1240 pub const IPPROTO_CMTP: ::c_int = 38;
1241 /// TP++ Transport
1242 pub const IPPROTO_TPXX: ::c_int = 39;
1243 /// IL transport protocol
1244 pub const IPPROTO_IL: ::c_int = 40;
1245 // IPPROTO_IPV6 defined in src/unix/mod.rs
1246 /// Source Demand Routing
1247 pub const IPPROTO_SDRP: ::c_int = 42;
1248 /// IP6 routing header
1249 pub const IPPROTO_ROUTING: ::c_int = 43;
1250 /// IP6 fragmentation header
1251 pub const IPPROTO_FRAGMENT: ::c_int = 44;
1252 /// InterDomain Routing
1253 pub const IPPROTO_IDRP: ::c_int = 45;
1254 /// resource reservation
1255 pub const IPPROTO_RSVP: ::c_int = 46;
1256 /// General Routing Encap.
1257 pub const IPPROTO_GRE: ::c_int = 47;
1258 /// Mobile Host Routing
1259 pub const IPPROTO_MHRP: ::c_int = 48;
1260 /// BHA
1261 pub const IPPROTO_BHA: ::c_int = 49;
1262 /// IP6 Encap Sec. Payload
1263 pub const IPPROTO_ESP: ::c_int = 50;
1264 /// IP6 Auth Header
1265 pub const IPPROTO_AH: ::c_int = 51;
1266 /// Integ. Net Layer Security
1267 pub const IPPROTO_INLSP: ::c_int = 52;
1268 /// IP with encryption
1269 pub const IPPROTO_SWIPE: ::c_int = 53;
1270 /// Next Hop Resolution
1271 pub const IPPROTO_NHRP: ::c_int = 54;
1272 /// IP Mobility
1273 pub const IPPROTO_MOBILE: ::c_int = 55;
1274 /// Transport Layer Security
1275 pub const IPPROTO_TLSP: ::c_int = 56;
1276 /// SKIP
1277 pub const IPPROTO_SKIP: ::c_int = 57;
1278 // IPPROTO_ICMPV6 defined in src/unix/mod.rs
1279 /// IP6 no next header
1280 pub const IPPROTO_NONE: ::c_int = 59;
1281 /// IP6 destination option
1282 pub const IPPROTO_DSTOPTS: ::c_int = 60;
1283 /// any host internal protocol
1284 pub const IPPROTO_AHIP: ::c_int = 61;
1285 /// CFTP
1286 pub const IPPROTO_CFTP: ::c_int = 62;
1287 /// "hello" routing protocol
1288 pub const IPPROTO_HELLO: ::c_int = 63;
1289 /// SATNET/Backroom EXPAK
1290 pub const IPPROTO_SATEXPAK: ::c_int = 64;
1291 /// Kryptolan
1292 pub const IPPROTO_KRYPTOLAN: ::c_int = 65;
1293 /// Remote Virtual Disk
1294 pub const IPPROTO_RVD: ::c_int = 66;
1295 /// Pluribus Packet Core
1296 pub const IPPROTO_IPPC: ::c_int = 67;
1297 /// Any distributed FS
1298 pub const IPPROTO_ADFS: ::c_int = 68;
1299 /// Satnet Monitoring
1300 pub const IPPROTO_SATMON: ::c_int = 69;
1301 /// VISA Protocol
1302 pub const IPPROTO_VISA: ::c_int = 70;
1303 /// Packet Core Utility
1304 pub const IPPROTO_IPCV: ::c_int = 71;
1305 /// Comp. Prot. Net. Executive
1306 pub const IPPROTO_CPNX: ::c_int = 72;
1307 /// Comp. Prot. HeartBeat
1308 pub const IPPROTO_CPHB: ::c_int = 73;
1309 /// Wang Span Network
1310 pub const IPPROTO_WSN: ::c_int = 74;
1311 /// Packet Video Protocol
1312 pub const IPPROTO_PVP: ::c_int = 75;
1313 /// BackRoom SATNET Monitoring
1314 pub const IPPROTO_BRSATMON: ::c_int = 76;
1315 /// Sun net disk proto (temp.)
1316 pub const IPPROTO_ND: ::c_int = 77;
1317 /// WIDEBAND Monitoring
1318 pub const IPPROTO_WBMON: ::c_int = 78;
1319 /// WIDEBAND EXPAK
1320 pub const IPPROTO_WBEXPAK: ::c_int = 79;
1321 /// ISO cnlp
1322 pub const IPPROTO_EON: ::c_int = 80;
1323 /// VMTP
1324 pub const IPPROTO_VMTP: ::c_int = 81;
1325 /// Secure VMTP
1326 pub const IPPROTO_SVMTP: ::c_int = 82;
1327 /// Banyon VINES
1328 pub const IPPROTO_VINES: ::c_int = 83;
1329 /// TTP
1330 pub const IPPROTO_TTP: ::c_int = 84;
1331 /// NSFNET-IGP
1332 pub const IPPROTO_IGP: ::c_int = 85;
1333 /// dissimilar gateway prot.
1334 pub const IPPROTO_DGP: ::c_int = 86;
1335 /// TCF
1336 pub const IPPROTO_TCF: ::c_int = 87;
1337 /// Cisco/GXS IGRP
1338 pub const IPPROTO_IGRP: ::c_int = 88;
1339 /// OSPFIGP
1340 pub const IPPROTO_OSPFIGP: ::c_int = 89;
1341 /// Strite RPC protocol
1342 pub const IPPROTO_SRPC: ::c_int = 90;
1343 /// Locus Address Resoloution
1344 pub const IPPROTO_LARP: ::c_int = 91;
1345 /// Multicast Transport
1346 pub const IPPROTO_MTP: ::c_int = 92;
1347 /// AX.25 Frames
1348 pub const IPPROTO_AX25: ::c_int = 93;
1349 /// IP encapsulated in IP
1350 pub const IPPROTO_IPEIP: ::c_int = 94;
1351 /// Mobile Int.ing control
1352 pub const IPPROTO_MICP: ::c_int = 95;
1353 /// Semaphore Comm. security
1354 pub const IPPROTO_SCCSP: ::c_int = 96;
1355 /// Ethernet IP encapsulation
1356 pub const IPPROTO_ETHERIP: ::c_int = 97;
1357 /// encapsulation header
1358 pub const IPPROTO_ENCAP: ::c_int = 98;
1359 /// any private encr. scheme
1360 pub const IPPROTO_APES: ::c_int = 99;
1361 /// GMTP
1362 pub const IPPROTO_GMTP: ::c_int = 100;
1363 /// payload compression (IPComp)
1364 pub const IPPROTO_IPCOMP: ::c_int = 108;
1365 
1366 /* 101-254: Partly Unassigned */
1367 /// Protocol Independent Mcast
1368 pub const IPPROTO_PIM: ::c_int = 103;
1369 /// CARP
1370 pub const IPPROTO_CARP: ::c_int = 112;
1371 /// PGM
1372 pub const IPPROTO_PGM: ::c_int = 113;
1373 /// PFSYNC
1374 pub const IPPROTO_PFSYNC: ::c_int = 240;
1375 
1376 /* 255: Reserved */
1377 /* BSD Private, local use, namespace incursion, no longer used */
1378 /// divert pseudo-protocol
1379 pub const IPPROTO_DIVERT: ::c_int = 254;
1380 pub const IPPROTO_MAX: ::c_int = 256;
1381 /// last return value of *_input(), meaning "all job for this pkt is done".
1382 pub const IPPROTO_DONE: ::c_int = 257;
1383 
1384 /// Used by RSS: the layer3 protocol is unknown
1385 pub const IPPROTO_UNKNOWN: ::c_int = 258;
1386 
1387 // sys/netinet/tcp.h
1388 pub const TCP_SIGNATURE_ENABLE: ::c_int = 16;
1389 pub const TCP_KEEPINIT: ::c_int = 32;
1390 pub const TCP_FASTKEEP: ::c_int = 128;
1391 
1392 pub const AF_BLUETOOTH: ::c_int = 33;
1393 pub const AF_MPLS: ::c_int = 34;
1394 pub const AF_IEEE80211: ::c_int = 35;
1395 
1396 pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
1397 
1398 pub const NET_RT_DUMP: ::c_int = 1;
1399 pub const NET_RT_FLAGS: ::c_int = 2;
1400 pub const NET_RT_IFLIST: ::c_int = 3;
1401 pub const NET_RT_MAXID: ::c_int = 4;
1402 
1403 pub const SOMAXOPT_SIZE: ::c_int = 65536;
1404 
1405 pub const MSG_UNUSED09: ::c_int = 0x00000200;
1406 pub const MSG_NOSIGNAL: ::c_int = 0x00000400;
1407 pub const MSG_SYNC: ::c_int = 0x00000800;
1408 pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00001000;
1409 pub const MSG_FBLOCKING: ::c_int = 0x00010000;
1410 pub const MSG_FNONBLOCKING: ::c_int = 0x00020000;
1411 pub const MSG_FMASK: ::c_int = 0xFFFF0000;
1412 
1413 // sys/mount.h
1414 pub const MNT_NODEV: ::c_int = 0x00000010;
1415 pub const MNT_AUTOMOUNTED: ::c_int = 0x00000020;
1416 pub const MNT_TRIM: ::c_int = 0x01000000;
1417 pub const MNT_LOCAL: ::c_int = 0x00001000;
1418 pub const MNT_QUOTA: ::c_int = 0x00002000;
1419 pub const MNT_ROOTFS: ::c_int = 0x00004000;
1420 pub const MNT_USER: ::c_int = 0x00008000;
1421 pub const MNT_IGNORE: ::c_int = 0x00800000;
1422 
1423 // utmpx entry types
1424 pub const EMPTY: ::c_short = 0;
1425 pub const RUN_LVL: ::c_short = 1;
1426 pub const BOOT_TIME: ::c_short = 2;
1427 pub const OLD_TIME: ::c_short = 3;
1428 pub const NEW_TIME: ::c_short = 4;
1429 pub const INIT_PROCESS: ::c_short = 5;
1430 pub const LOGIN_PROCESS: ::c_short = 6;
1431 pub const USER_PROCESS: ::c_short = 7;
1432 pub const DEAD_PROCESS: ::c_short = 8;
1433 pub const ACCOUNTING: ::c_short = 9;
1434 pub const SIGNATURE: ::c_short = 10;
1435 pub const DOWNTIME: ::c_short = 11;
1436 // utmpx database types
1437 pub const UTX_DB_UTMPX: ::c_uint = 0;
1438 pub const UTX_DB_WTMPX: ::c_uint = 1;
1439 pub const UTX_DB_LASTLOG: ::c_uint = 2;
1440 pub const _UTX_LINESIZE: usize = 32;
1441 pub const _UTX_USERSIZE: usize = 32;
1442 pub const _UTX_IDSIZE: usize = 4;
1443 pub const _UTX_HOSTSIZE: usize = 256;
1444 
1445 pub const LC_COLLATE_MASK: ::c_int = 1 << 0;
1446 pub const LC_CTYPE_MASK: ::c_int = 1 << 1;
1447 pub const LC_MONETARY_MASK: ::c_int = 1 << 2;
1448 pub const LC_NUMERIC_MASK: ::c_int = 1 << 3;
1449 pub const LC_TIME_MASK: ::c_int = 1 << 4;
1450 pub const LC_MESSAGES_MASK: ::c_int = 1 << 5;
1451 pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
1452     | LC_CTYPE_MASK
1453     | LC_MESSAGES_MASK
1454     | LC_MONETARY_MASK
1455     | LC_NUMERIC_MASK
1456     | LC_TIME_MASK;
1457 
1458 pub const TIOCSIG: ::c_ulong = 0x2000745f;
1459 pub const BTUARTDISC: ::c_int = 0x7;
1460 pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458;
1461 pub const TIOCISPTMASTER: ::c_ulong = 0x20007455;
1462 pub const TIOCMODG: ::c_ulong = 0x40047403;
1463 pub const TIOCMODS: ::c_ulong = 0x80047404;
1464 pub const TIOCREMOTE: ::c_ulong = 0x80047469;
1465 
1466 // Constants used by "at" family of system calls.
1467 pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor
1468 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 1;
1469 pub const AT_REMOVEDIR: ::c_int = 2;
1470 pub const AT_EACCESS: ::c_int = 4;
1471 pub const AT_SYMLINK_FOLLOW: ::c_int = 8;
1472 
1473 pub const VCHECKPT: usize = 19;
1474 
1475 pub const _PC_2_SYMLINKS: ::c_int = 22;
1476 pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 23;
1477 
1478 pub const _SC_V7_ILP32_OFF32: ::c_int = 122;
1479 pub const _SC_V7_ILP32_OFFBIG: ::c_int = 123;
1480 pub const _SC_V7_LP64_OFF64: ::c_int = 124;
1481 pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 125;
1482 pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 126;
1483 pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 127;
1484 
1485 pub const WCONTINUED: ::c_int = 0x4;
1486 pub const WSTOPPED: ::c_int = 0x2;
1487 pub const WNOWAIT: ::c_int = 0x8;
1488 pub const WEXITED: ::c_int = 0x10;
1489 pub const WTRAPPED: ::c_int = 0x20;
1490 
1491 // Similar to FreeBSD, only the standardized ones are exposed.
1492 // There are more.
1493 pub const P_PID: idtype_t = 0;
1494 pub const P_PGID: idtype_t = 2;
1495 pub const P_ALL: idtype_t = 7;
1496 
1497 // Values for struct rtprio (type_ field)
1498 pub const RTP_PRIO_REALTIME: ::c_ushort = 0;
1499 pub const RTP_PRIO_NORMAL: ::c_ushort = 1;
1500 pub const RTP_PRIO_IDLE: ::c_ushort = 2;
1501 pub const RTP_PRIO_THREAD: ::c_ushort = 3;
1502 
1503 // Flags for chflags(2)
1504 pub const UF_NOHISTORY: ::c_ulong = 0x00000040;
1505 pub const UF_CACHE: ::c_ulong = 0x00000080;
1506 pub const UF_XLINK: ::c_ulong = 0x00000100;
1507 pub const SF_NOHISTORY: ::c_ulong = 0x00400000;
1508 pub const SF_CACHE: ::c_ulong = 0x00800000;
1509 pub const SF_XLINK: ::c_ulong = 0x01000000;
1510 
1511 // timespec constants
1512 pub const UTIME_OMIT: c_long = -2;
1513 pub const UTIME_NOW: c_long = -1;
1514 
1515 pub const MINCORE_SUPER: ::c_int = 0x20;
1516 
1517 // kinfo_proc constants
1518 pub const MAXCOMLEN: usize = 16;
1519 pub const MAXLOGNAME: usize = 33;
1520 pub const NGROUPS: usize = 16;
1521 
1522 pub const RB_PAUSE: ::c_int = 0x40000;
1523 pub const RB_VIDEO: ::c_int = 0x20000000;
1524 
1525 const_fn! {
1526     {const} fn _CMSG_ALIGN(n: usize) -> usize {
1527         (n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1)
1528     }
1529 }
1530 
1531 f! {
1532     pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
1533         (cmsg as *mut ::c_uchar)
1534             .offset(_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
1535     }
1536 
1537     pub {const} fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1538         (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + length as usize)
1539             as ::c_uint
1540     }
1541 
1542     pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
1543         -> *mut ::cmsghdr
1544     {
1545         let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)
1546             + _CMSG_ALIGN(::mem::size_of::<::cmsghdr>());
1547         let max = (*mhdr).msg_control as usize
1548             + (*mhdr).msg_controllen as usize;
1549         if next <= max {
1550             (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize))
1551                 as *mut ::cmsghdr
1552         } else {
1553             0 as *mut ::cmsghdr
1554         }
1555     }
1556 
1557     pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
1558         (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) +
1559             _CMSG_ALIGN(length as usize)) as ::c_uint
1560     }
1561 
1562     pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
1563         for slot in cpuset.ary.iter_mut() {
1564             *slot = 0;
1565         }
1566     }
1567 
1568     pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
1569         let (idx, offset) = ((cpu >> 6) & 3, cpu & 63);
1570         cpuset.ary[idx] |= 1 << offset;
1571         ()
1572     }
1573 
1574     pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
1575         let (idx, offset) = ((cpu >> 6) & 3, cpu & 63);
1576         cpuset.ary[idx] &= !(1 << offset);
1577         ()
1578     }
1579 
1580     pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
1581         let (idx, offset) = ((cpu >> 6) & 3, cpu & 63);
1582         0 != cpuset.ary[idx] & (1 << offset)
1583     }
1584 
1585     pub fn major(dev: ::dev_t) -> ::c_int {
1586          ((dev >> 8) & 0xff) as ::c_int
1587     }
1588 
1589     pub fn minor(dev: ::dev_t) -> ::c_int {
1590         (dev & 0xffff00ff) as ::c_int
1591     }
1592 }
1593 
1594 safe_f! {
1595     pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
1596         (status & 0o177) != 0o177 && (status & 0o177) != 0
1597     }
1598 
1599     pub {const} fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
1600         let major = major as ::dev_t;
1601         let minor = minor as ::dev_t;
1602         let mut dev = 0;
1603         dev |= major << 8;
1604         dev |= minor;
1605         dev
1606     }
1607 }
1608 
1609 extern "C" {
__errno_location() -> *mut ::c_int1610     pub fn __errno_location() -> *mut ::c_int;
setgrent()1611     pub fn setgrent();
mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int1612     pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
1613 
setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int1614     pub fn setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int;
1615 
aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut ::timespec) -> ::c_int1616     pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut ::timespec) -> ::c_int;
1617 
devname_r( dev: ::dev_t, mode: ::mode_t, buf: *mut ::c_char, len: ::size_t, ) -> *mut ::c_char1618     pub fn devname_r(
1619         dev: ::dev_t,
1620         mode: ::mode_t,
1621         buf: *mut ::c_char,
1622         len: ::size_t,
1623     ) -> *mut ::c_char;
1624 
waitid( idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t, options: ::c_int, ) -> ::c_int1625     pub fn waitid(
1626         idtype: idtype_t,
1627         id: ::id_t,
1628         infop: *mut ::siginfo_t,
1629         options: ::c_int,
1630     ) -> ::c_int;
1631 
freelocale(loc: ::locale_t)1632     pub fn freelocale(loc: ::locale_t);
1633 
lwp_rtprio( function: ::c_int, pid: ::pid_t, lwpid: lwpid_t, rtp: *mut super::rtprio, ) -> ::c_int1634     pub fn lwp_rtprio(
1635         function: ::c_int,
1636         pid: ::pid_t,
1637         lwpid: lwpid_t,
1638         rtp: *mut super::rtprio,
1639     ) -> ::c_int;
1640 
statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int1641     pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int1642     pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
uname(buf: *mut ::utsname) -> ::c_int1643     pub fn uname(buf: *mut ::utsname) -> ::c_int;
memmem( haystack: *const ::c_void, haystacklen: ::size_t, needle: *const ::c_void, needlelen: ::size_t, ) -> *mut ::c_void1644     pub fn memmem(
1645         haystack: *const ::c_void,
1646         haystacklen: ::size_t,
1647         needle: *const ::c_void,
1648         needlelen: ::size_t,
1649     ) -> *mut ::c_void;
pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: ::c_int) -> ::c_int1650     pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: ::c_int) -> ::c_int;
pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> ::c_int1651     pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> ::c_int;
pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int1652     pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int;
pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> ::c_int1653     pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> ::c_int;
pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> ::c_int1654     pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> ::c_int;
1655 
sched_getaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *mut cpu_set_t) -> ::c_int1656     pub fn sched_getaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *mut cpu_set_t) -> ::c_int;
sched_setaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *const cpu_set_t) -> ::c_int1657     pub fn sched_setaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *const cpu_set_t)
1658         -> ::c_int;
sched_getcpu() -> ::c_int1659     pub fn sched_getcpu() -> ::c_int;
setproctitle(fmt: *const ::c_char, ...)1660     pub fn setproctitle(fmt: *const ::c_char, ...);
1661 
shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int1662     pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void1663     pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void;
shmdt(shmaddr: *const ::c_void) -> ::c_int1664     pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int1665     pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int;
procctl(idtype: ::idtype_t, id: ::id_t, cmd: ::c_int, data: *mut ::c_void) -> ::c_int1666     pub fn procctl(idtype: ::idtype_t, id: ::id_t, cmd: ::c_int, data: *mut ::c_void) -> ::c_int;
1667 
updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int1668     pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int;
getlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> *mut lastlogx1669     pub fn getlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> *mut lastlogx;
updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int1670     pub fn updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int;
getutxuser(name: *const ::c_char) -> utmpx1671     pub fn getutxuser(name: *const ::c_char) -> utmpx;
utmpxname(file: *const ::c_char) -> ::c_int1672     pub fn utmpxname(file: *const ::c_char) -> ::c_int;
1673 
sys_checkpoint(tpe: ::c_int, fd: ::c_int, pid: ::pid_t, retval: ::c_int) -> ::c_int1674     pub fn sys_checkpoint(tpe: ::c_int, fd: ::c_int, pid: ::pid_t, retval: ::c_int) -> ::c_int;
1675 
umtx_sleep(ptr: *const ::c_int, value: ::c_int, timeout: ::c_int) -> ::c_int1676     pub fn umtx_sleep(ptr: *const ::c_int, value: ::c_int, timeout: ::c_int) -> ::c_int;
umtx_wakeup(ptr: *const ::c_int, count: ::c_int) -> ::c_int1677     pub fn umtx_wakeup(ptr: *const ::c_int, count: ::c_int) -> ::c_int;
1678 
dirname(path: *mut ::c_char) -> *mut ::c_char1679     pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
basename(path: *mut ::c_char) -> *mut ::c_char1680     pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
getmntinfo(mntbufp: *mut *mut ::statfs, flags: ::c_int) -> ::c_int1681     pub fn getmntinfo(mntbufp: *mut *mut ::statfs, flags: ::c_int) -> ::c_int;
getmntvinfo( mntbufp: *mut *mut ::statfs, mntvbufp: *mut *mut ::statvfs, flags: ::c_int, ) -> ::c_int1682     pub fn getmntvinfo(
1683         mntbufp: *mut *mut ::statfs,
1684         mntvbufp: *mut *mut ::statvfs,
1685         flags: ::c_int,
1686     ) -> ::c_int;
1687 }
1688 
1689 #[link(name = "rt")]
1690 extern "C" {
aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int1691     pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
aio_error(aiocbp: *const aiocb) -> ::c_int1692     pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int1693     pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
aio_read(aiocbp: *mut aiocb) -> ::c_int1694     pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
aio_return(aiocbp: *mut aiocb) -> ::ssize_t1695     pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
aio_suspend( aiocb_list: *const *const aiocb, nitems: ::c_int, timeout: *const ::timespec, ) -> ::c_int1696     pub fn aio_suspend(
1697         aiocb_list: *const *const aiocb,
1698         nitems: ::c_int,
1699         timeout: *const ::timespec,
1700     ) -> ::c_int;
aio_write(aiocbp: *mut aiocb) -> ::c_int1701     pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
lio_listio( mode: ::c_int, aiocb_list: *const *mut aiocb, nitems: ::c_int, sevp: *mut sigevent, ) -> ::c_int1702     pub fn lio_listio(
1703         mode: ::c_int,
1704         aiocb_list: *const *mut aiocb,
1705         nitems: ::c_int,
1706         sevp: *mut sigevent,
1707     ) -> ::c_int;
1708 
reallocf(ptr: *mut ::c_void, size: ::size_t) -> *mut ::c_void1709     pub fn reallocf(ptr: *mut ::c_void, size: ::size_t) -> *mut ::c_void;
freezero(ptr: *mut ::c_void, size: ::size_t)1710     pub fn freezero(ptr: *mut ::c_void, size: ::size_t);
1711 }
1712 
1713 #[link(name = "kvm")]
1714 extern "C" {
kvm_vm_map_entry_first( kvm: *mut ::kvm_t, map: vm_map_t, entry: vm_map_entry_t, ) -> vm_map_entry_t1715     pub fn kvm_vm_map_entry_first(
1716         kvm: *mut ::kvm_t,
1717         map: vm_map_t,
1718         entry: vm_map_entry_t,
1719     ) -> vm_map_entry_t;
kvm_vm_map_entry_next( kvm: *mut ::kvm_t, map: vm_map_entry_t, entry: vm_map_entry_t, ) -> vm_map_entry_t1720     pub fn kvm_vm_map_entry_next(
1721         kvm: *mut ::kvm_t,
1722         map: vm_map_entry_t,
1723         entry: vm_map_entry_t,
1724     ) -> vm_map_entry_t;
1725 }
1726 
1727 cfg_if! {
1728     if #[cfg(libc_thread_local)] {
1729         mod errno;
1730         pub use self::errno::*;
1731     }
1732 }
1733