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