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