Debian Codegraph @

debian/missing-sources/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs

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