interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / unix / bsd / netbsdlike / openbsd / mod.rs

2116 lines · 68473 bytes Raw Blame History
1use crate::prelude::*;
2use crate::unix::bsd::O_SYNC;
3use crate::{
4 cmsghdr,
5 off_t,
6};
7
8pub type clock_t = i64;
9pub type suseconds_t = c_long;
10pub type dev_t = i32;
11pub type sigset_t = c_uint;
12pub type blksize_t = i32;
13pub type fsblkcnt_t = u64;
14pub type fsfilcnt_t = u64;
15pub type idtype_t = c_uint;
16pub type pthread_attr_t = *mut c_void;
17pub type pthread_mutex_t = *mut c_void;
18pub type pthread_mutexattr_t = *mut c_void;
19pub type pthread_cond_t = *mut c_void;
20pub type pthread_condattr_t = *mut c_void;
21pub type pthread_rwlock_t = *mut c_void;
22pub type pthread_rwlockattr_t = *mut c_void;
23pub type pthread_spinlock_t = crate::uintptr_t;
24pub type caddr_t = *mut c_char;
25
26// elf.h
27
28pub type Elf32_Addr = u32;
29pub type Elf32_Half = u16;
30pub type Elf32_Lword = u64;
31pub type Elf32_Off = u32;
32pub type Elf32_Sword = i32;
33pub type Elf32_Word = u32;
34
35pub type Elf64_Addr = u64;
36pub type Elf64_Half = u16;
37pub type Elf64_Lword = u64;
38pub type Elf64_Off = u64;
39pub type Elf64_Sword = i32;
40pub type Elf64_Sxword = i64;
41pub type Elf64_Word = u32;
42pub type Elf64_Xword = u64;
43
44// search.h
45
46pub type ENTRY = entry;
47pub type ACTION = c_uint;
48
49// spawn.h
50pub type posix_spawnattr_t = *mut c_void;
51pub type posix_spawn_file_actions_t = *mut c_void;
52
53cfg_if! {
54 if #[cfg(target_pointer_width = "64")] {
55 type Elf_Addr = Elf64_Addr;
56 type Elf_Half = Elf64_Half;
57 type Elf_Phdr = Elf64_Phdr;
58 } else if #[cfg(target_pointer_width = "32")] {
59 type Elf_Addr = Elf32_Addr;
60 type Elf_Half = Elf32_Half;
61 type Elf_Phdr = Elf32_Phdr;
62 }
63}
64
65s! {
66 pub struct ip_mreqn {
67 pub imr_multiaddr: in_addr,
68 pub imr_address: in_addr,
69 pub imr_ifindex: c_int,
70 }
71
72 pub struct glob_t {
73 pub gl_pathc: size_t,
74 pub gl_matchc: size_t,
75 pub gl_offs: size_t,
76 pub gl_flags: c_int,
77 pub gl_pathv: *mut *mut c_char,
78 __unused1: Padding<*mut c_void>,
79 __unused2: Padding<*mut c_void>,
80 __unused3: Padding<*mut c_void>,
81 __unused4: Padding<*mut c_void>,
82 __unused5: Padding<*mut c_void>,
83 __unused6: Padding<*mut c_void>,
84 __unused7: Padding<*mut c_void>,
85 }
86
87 pub struct tm {
88 pub tm_sec: c_int,
89 pub tm_min: c_int,
90 pub tm_hour: c_int,
91 pub tm_mday: c_int,
92 pub tm_mon: c_int,
93 pub tm_year: c_int,
94 pub tm_wday: c_int,
95 pub tm_yday: c_int,
96 pub tm_isdst: c_int,
97 pub tm_gmtoff: c_long,
98 pub tm_zone: *const c_char,
99 }
100
101 pub struct lconv {
102 pub decimal_point: *mut c_char,
103 pub thousands_sep: *mut c_char,
104 pub grouping: *mut c_char,
105 pub int_curr_symbol: *mut c_char,
106 pub currency_symbol: *mut c_char,
107 pub mon_decimal_point: *mut c_char,
108 pub mon_thousands_sep: *mut c_char,
109 pub mon_grouping: *mut c_char,
110 pub positive_sign: *mut c_char,
111 pub negative_sign: *mut c_char,
112 pub int_frac_digits: c_char,
113 pub frac_digits: c_char,
114 pub p_cs_precedes: c_char,
115 pub p_sep_by_space: c_char,
116 pub n_cs_precedes: c_char,
117 pub n_sep_by_space: c_char,
118 pub p_sign_posn: c_char,
119 pub n_sign_posn: c_char,
120 pub int_p_cs_precedes: c_char,
121 pub int_p_sep_by_space: c_char,
122 pub int_n_cs_precedes: c_char,
123 pub int_n_sep_by_space: c_char,
124 pub int_p_sign_posn: c_char,
125 pub int_n_sign_posn: c_char,
126 }
127
128 pub struct ufs_args {
129 pub fspec: *mut c_char,
130 pub export_info: export_args,
131 }
132
133 pub struct mfs_args {
134 pub fspec: *mut c_char,
135 pub export_info: export_args,
136 // https://github.com/openbsd/src/blob/HEAD/sys/sys/types.h#L134
137 pub base: *mut c_char,
138 pub size: c_ulong,
139 }
140
141 pub struct iso_args {
142 pub fspec: *mut c_char,
143 pub export_info: export_args,
144 pub flags: c_int,
145 pub sess: c_int,
146 }
147
148 pub struct nfs_args {
149 pub version: c_int,
150 pub addr: *mut crate::sockaddr,
151 pub addrlen: c_int,
152 pub sotype: c_int,
153 pub proto: c_int,
154 pub fh: *mut c_uchar,
155 pub fhsize: c_int,
156 pub flags: c_int,
157 pub wsize: c_int,
158 pub rsize: c_int,
159 pub readdirsize: c_int,
160 pub timeo: c_int,
161 pub retrans: c_int,
162 pub maxgrouplist: c_int,
163 pub readahead: c_int,
164 pub leaseterm: c_int,
165 pub deadthresh: c_int,
166 pub hostname: *mut c_char,
167 pub acregmin: c_int,
168 pub acregmax: c_int,
169 pub acdirmin: c_int,
170 pub acdirmax: c_int,
171 }
172
173 pub struct msdosfs_args {
174 pub fspec: *mut c_char,
175 pub export_info: export_args,
176 pub uid: crate::uid_t,
177 pub gid: crate::gid_t,
178 pub mask: crate::mode_t,
179 pub flags: c_int,
180 }
181
182 pub struct ntfs_args {
183 pub fspec: *mut c_char,
184 pub export_info: export_args,
185 pub uid: crate::uid_t,
186 pub gid: crate::gid_t,
187 pub mode: crate::mode_t,
188 pub flag: c_ulong,
189 }
190
191 pub struct udf_args {
192 pub fspec: *mut c_char,
193 pub lastblock: u32,
194 }
195
196 pub struct tmpfs_args {
197 pub ta_version: c_int,
198 pub ta_nodes_max: crate::ino_t,
199 pub ta_size_max: off_t,
200 pub ta_root_uid: crate::uid_t,
201 pub ta_root_gid: crate::gid_t,
202 pub ta_root_mode: crate::mode_t,
203 }
204
205 pub struct fusefs_args {
206 pub name: *mut c_char,
207 pub fd: c_int,
208 pub max_read: c_int,
209 pub allow_other: c_int,
210 }
211
212 pub struct xucred {
213 pub cr_uid: crate::uid_t,
214 pub cr_gid: crate::gid_t,
215 pub cr_ngroups: c_short,
216 //https://github.com/openbsd/src/blob/HEAD/sys/sys/syslimits.h#L44
217 pub cr_groups: [crate::gid_t; 16],
218 }
219
220 pub struct export_args {
221 pub ex_flags: c_int,
222 pub ex_root: crate::uid_t,
223 pub ex_anon: xucred,
224 pub ex_addr: *mut crate::sockaddr,
225 pub ex_addrlen: c_int,
226 pub ex_mask: *mut crate::sockaddr,
227 pub ex_masklen: c_int,
228 }
229
230 pub struct ip_mreq {
231 pub imr_multiaddr: in_addr,
232 pub imr_interface: in_addr,
233 }
234
235 pub struct in_addr {
236 pub s_addr: crate::in_addr_t,
237 }
238
239 pub struct sockaddr_in {
240 pub sin_len: u8,
241 pub sin_family: crate::sa_family_t,
242 pub sin_port: crate::in_port_t,
243 pub sin_addr: crate::in_addr,
244 pub sin_zero: [i8; 8],
245 }
246
247 pub struct splice {
248 pub sp_fd: c_int,
249 pub sp_max: off_t,
250 pub sp_idle: crate::timeval,
251 }
252
253 pub struct kevent {
254 pub ident: crate::uintptr_t,
255 pub filter: c_short,
256 pub flags: c_ushort,
257 pub fflags: c_uint,
258 pub data: i64,
259 pub udata: *mut c_void,
260 }
261
262 pub struct stat {
263 pub st_mode: crate::mode_t,
264 pub st_dev: crate::dev_t,
265 pub st_ino: crate::ino_t,
266 pub st_nlink: crate::nlink_t,
267 pub st_uid: crate::uid_t,
268 pub st_gid: crate::gid_t,
269 pub st_rdev: crate::dev_t,
270 pub st_atime: crate::time_t,
271 pub st_atime_nsec: c_long,
272 pub st_mtime: crate::time_t,
273 pub st_mtime_nsec: c_long,
274 pub st_ctime: crate::time_t,
275 pub st_ctime_nsec: c_long,
276 pub st_size: off_t,
277 pub st_blocks: crate::blkcnt_t,
278 pub st_blksize: crate::blksize_t,
279 pub st_flags: u32,
280 pub st_gen: u32,
281 pub st_birthtime: crate::time_t,
282 pub st_birthtime_nsec: c_long,
283 }
284
285 pub struct statvfs {
286 pub f_bsize: c_ulong,
287 pub f_frsize: c_ulong,
288 pub f_blocks: crate::fsblkcnt_t,
289 pub f_bfree: crate::fsblkcnt_t,
290 pub f_bavail: crate::fsblkcnt_t,
291 pub f_files: crate::fsfilcnt_t,
292 pub f_ffree: crate::fsfilcnt_t,
293 pub f_favail: crate::fsfilcnt_t,
294 pub f_fsid: c_ulong,
295 pub f_flag: c_ulong,
296 pub f_namemax: c_ulong,
297 }
298
299 pub struct addrinfo {
300 pub ai_flags: c_int,
301 pub ai_family: c_int,
302 pub ai_socktype: c_int,
303 pub ai_protocol: c_int,
304 pub ai_addrlen: crate::socklen_t,
305 pub ai_addr: *mut crate::sockaddr,
306 pub ai_canonname: *mut c_char,
307 pub ai_next: *mut crate::addrinfo,
308 }
309
310 pub struct Dl_info {
311 pub dli_fname: *const c_char,
312 pub dli_fbase: *mut c_void,
313 pub dli_sname: *const c_char,
314 pub dli_saddr: *mut c_void,
315 }
316
317 pub struct if_data {
318 pub ifi_type: c_uchar,
319 pub ifi_addrlen: c_uchar,
320 pub ifi_hdrlen: c_uchar,
321 pub ifi_link_state: c_uchar,
322 pub ifi_mtu: u32,
323 pub ifi_metric: u32,
324 pub ifi_rdomain: u32,
325 pub ifi_baudrate: u64,
326 pub ifi_ipackets: u64,
327 pub ifi_ierrors: u64,
328 pub ifi_opackets: u64,
329 pub ifi_oerrors: u64,
330 pub ifi_collisions: u64,
331 pub ifi_ibytes: u64,
332 pub ifi_obytes: u64,
333 pub ifi_imcasts: u64,
334 pub ifi_omcasts: u64,
335 pub ifi_iqdrops: u64,
336 pub ifi_oqdrops: u64,
337 pub ifi_noproto: u64,
338 pub ifi_capabilities: u32,
339 pub ifi_lastchange: crate::timeval,
340 }
341
342 pub struct if_msghdr {
343 pub ifm_msglen: c_ushort,
344 pub ifm_version: c_uchar,
345 pub ifm_type: c_uchar,
346 pub ifm_hdrlen: c_ushort,
347 pub ifm_index: c_ushort,
348 pub ifm_tableid: c_ushort,
349 pub ifm_pad1: c_uchar,
350 pub ifm_pad2: c_uchar,
351 pub ifm_addrs: c_int,
352 pub ifm_flags: c_int,
353 pub ifm_xflags: c_int,
354 pub ifm_data: if_data,
355 }
356
357 pub struct sockaddr_dl {
358 pub sdl_len: c_uchar,
359 pub sdl_family: c_uchar,
360 pub sdl_index: c_ushort,
361 pub sdl_type: c_uchar,
362 pub sdl_nlen: c_uchar,
363 pub sdl_alen: c_uchar,
364 pub sdl_slen: c_uchar,
365 pub sdl_data: [c_char; 24],
366 }
367
368 pub struct sockpeercred {
369 pub uid: crate::uid_t,
370 pub gid: crate::gid_t,
371 pub pid: crate::pid_t,
372 }
373
374 pub struct arphdr {
375 pub ar_hrd: u16,
376 pub ar_pro: u16,
377 pub ar_hln: u8,
378 pub ar_pln: u8,
379 pub ar_op: u16,
380 }
381
382 pub struct shmid_ds {
383 pub shm_perm: crate::ipc_perm,
384 pub shm_segsz: c_int,
385 pub shm_lpid: crate::pid_t,
386 pub shm_cpid: crate::pid_t,
387 pub shm_nattch: c_short,
388 pub shm_atime: crate::time_t,
389 __shm_atimensec: c_long,
390 pub shm_dtime: crate::time_t,
391 __shm_dtimensec: c_long,
392 pub shm_ctime: crate::time_t,
393 __shm_ctimensec: c_long,
394 pub shm_internal: *mut c_void,
395 }
396
397 // elf.h
398 pub struct Elf32_Phdr {
399 pub p_type: Elf32_Word,
400 pub p_offset: Elf32_Off,
401 pub p_vaddr: Elf32_Addr,
402 pub p_paddr: Elf32_Addr,
403 pub p_filesz: Elf32_Word,
404 pub p_memsz: Elf32_Word,
405 pub p_flags: Elf32_Word,
406 pub p_align: Elf32_Word,
407 }
408
409 pub struct Elf64_Phdr {
410 pub p_type: Elf64_Word,
411 pub p_flags: Elf64_Word,
412 pub p_offset: Elf64_Off,
413 pub p_vaddr: Elf64_Addr,
414 pub p_paddr: Elf64_Addr,
415 pub p_filesz: Elf64_Xword,
416 pub p_memsz: Elf64_Xword,
417 pub p_align: Elf64_Xword,
418 }
419
420 // link.h
421
422 pub struct dl_phdr_info {
423 pub dlpi_addr: Elf_Addr,
424 pub dlpi_name: *const c_char,
425 pub dlpi_phdr: *const Elf_Phdr,
426 pub dlpi_phnum: Elf_Half,
427 }
428
429 // sys/sysctl.h
430 pub struct kinfo_proc {
431 pub p_forw: u64,
432 pub p_back: u64,
433 pub p_paddr: u64,
434 pub p_addr: u64,
435 pub p_fd: u64,
436 pub p_stats: u64,
437 pub p_limit: u64,
438 pub p_vmspace: u64,
439 pub p_sigacts: u64,
440 pub p_sess: u64,
441 pub p_tsess: u64,
442 pub p_ru: u64,
443 pub p_eflag: i32,
444 pub p_exitsig: i32,
445 pub p_flag: i32,
446 pub p_pid: i32,
447 pub p_ppid: i32,
448 pub p_sid: i32,
449 pub p__pgid: i32,
450 pub p_tpgid: i32,
451 pub p_uid: u32,
452 pub p_ruid: u32,
453 pub p_gid: u32,
454 pub p_rgid: u32,
455 pub p_groups: [u32; KI_NGROUPS as usize],
456 pub p_ngroups: i16,
457 pub p_jobc: i16,
458 pub p_tdev: u32,
459 pub p_estcpu: u32,
460 pub p_rtime_sec: u32,
461 pub p_rtime_usec: u32,
462 pub p_cpticks: i32,
463 pub p_pctcpu: u32,
464 pub p_swtime: u32,
465 pub p_slptime: u32,
466 pub p_schedflags: i32,
467 pub p_uticks: u64,
468 pub p_sticks: u64,
469 pub p_iticks: u64,
470 pub p_tracep: u64,
471 pub p_traceflag: i32,
472 pub p_holdcnt: i32,
473 pub p_siglist: i32,
474 pub p_sigmask: u32,
475 pub p_sigignore: u32,
476 pub p_sigcatch: u32,
477 pub p_stat: i8,
478 pub p_priority: u8,
479 pub p_usrpri: u8,
480 pub p_nice: u8,
481 pub p_xstat: u16,
482 pub p_spare: u16,
483 pub p_comm: [c_char; KI_MAXCOMLEN as usize],
484 pub p_wmesg: [c_char; KI_WMESGLEN as usize],
485 pub p_wchan: u64,
486 pub p_login: [c_char; KI_MAXLOGNAME as usize],
487 pub p_vm_rssize: i32,
488 pub p_vm_tsize: i32,
489 pub p_vm_dsize: i32,
490 pub p_vm_ssize: i32,
491 pub p_uvalid: i64,
492 pub p_ustart_sec: u64,
493 pub p_ustart_usec: u32,
494 pub p_uutime_sec: u32,
495 pub p_uutime_usec: u32,
496 pub p_ustime_sec: u32,
497 pub p_ustime_usec: u32,
498 pub p_uru_maxrss: u64,
499 pub p_uru_ixrss: u64,
500 pub p_uru_idrss: u64,
501 pub p_uru_isrss: u64,
502 pub p_uru_minflt: u64,
503 pub p_uru_majflt: u64,
504 pub p_uru_nswap: u64,
505 pub p_uru_inblock: u64,
506 pub p_uru_oublock: u64,
507 pub p_uru_msgsnd: u64,
508 pub p_uru_msgrcv: u64,
509 pub p_uru_nsignals: u64,
510 pub p_uru_nvcsw: u64,
511 pub p_uru_nivcsw: u64,
512 pub p_uctime_sec: u32,
513 pub p_uctime_usec: u32,
514 pub p_psflags: u32,
515 pub p_acflag: u32,
516 pub p_svuid: u32,
517 pub p_svgid: u32,
518 pub p_emul: [c_char; KI_EMULNAMELEN as usize],
519 pub p_rlim_rss_cur: u64,
520 pub p_cpuid: u64,
521 pub p_vm_map_size: u64,
522 pub p_tid: i32,
523 pub p_rtableid: u32,
524 pub p_pledge: u64,
525 pub p_name: [c_char; KI_MAXCOMLEN as usize],
526 }
527
528 pub struct kinfo_file {
529 pub f_fileaddr: u64,
530 pub f_flag: u32,
531 pub f_iflags: u32,
532 pub f_type: u32,
533 pub f_count: u32,
534 pub f_msgcount: u32,
535 pub f_usecount: u32,
536 pub f_ucred: u64,
537 pub f_uid: u32,
538 pub f_gid: u32,
539 pub f_ops: u64,
540 pub f_offset: u64,
541 pub f_data: u64,
542 pub f_rxfer: u64,
543 pub f_rwfer: u64,
544 pub f_seek: u64,
545 pub f_rbytes: u64,
546 pub f_wbytes: u64,
547 pub v_un: u64,
548 pub v_type: u32,
549 pub v_tag: u32,
550 pub v_flag: u32,
551 pub va_rdev: u32,
552 pub v_data: u64,
553 pub v_mount: u64,
554 pub va_fileid: u64,
555 pub va_size: u64,
556 pub va_mode: u32,
557 pub va_fsid: u32,
558 pub f_mntonname: [c_char; KI_MNAMELEN as usize],
559 pub so_type: u32,
560 pub so_state: u32,
561 pub so_pcb: u64,
562 pub so_protocol: u32,
563 pub so_family: u32,
564 pub inp_ppcb: u64,
565 pub inp_lport: u32,
566 pub inp_laddru: [u32; 4],
567 pub inp_fport: u32,
568 pub inp_faddru: [u32; 4],
569 pub unp_conn: u64,
570 pub pipe_peer: u64,
571 pub pipe_state: u32,
572 pub kq_count: u32,
573 pub kq_state: u32,
574 __unused1: Padding<u32>,
575 pub p_pid: u32,
576 pub fd_fd: i32,
577 pub fd_ofileflags: u32,
578 pub p_uid: u32,
579 pub p_gid: u32,
580 pub p_tid: u32,
581 pub p_comm: [c_char; KI_MAXCOMLEN as usize],
582 pub inp_rtableid: u32,
583 pub so_splice: u64,
584 pub so_splicelen: i64,
585 pub so_rcv_cc: u64,
586 pub so_snd_cc: u64,
587 pub unp_refs: u64,
588 pub unp_nextref: u64,
589 pub unp_addr: u64,
590 pub unp_path: [c_char; KI_UNPPATHLEN as usize],
591 pub inp_proto: u32,
592 pub t_state: u32,
593 pub t_rcv_wnd: u64,
594 pub t_snd_wnd: u64,
595 pub t_snd_cwnd: u64,
596 pub va_nlink: u32,
597 }
598
599 pub struct kinfo_vmentry {
600 pub kve_start: c_ulong,
601 pub kve_end: c_ulong,
602 pub kve_guard: c_ulong,
603 pub kve_fspace: c_ulong,
604 pub kve_fspace_augment: c_ulong,
605 pub kve_offset: u64,
606 pub kve_wired_count: c_int,
607 pub kve_etype: c_int,
608 pub kve_protection: c_int,
609 pub kve_max_protection: c_int,
610 pub kve_advice: c_int,
611 pub kve_inheritance: c_int,
612 pub kve_flags: u8,
613 }
614
615 pub struct ptrace_state {
616 pub pe_report_event: c_int,
617 pub pe_other_pid: crate::pid_t,
618 pub pe_tid: crate::pid_t,
619 }
620
621 pub struct ptrace_thread_state {
622 pub pts_tid: crate::pid_t,
623 pub pts_name: [c_char; PT_PTS_NAMELEN as usize],
624 }
625
626 // search.h
627 pub struct entry {
628 pub key: *mut c_char,
629 pub data: *mut c_void,
630 }
631
632 pub struct ifreq {
633 pub ifr_name: [c_char; crate::IFNAMSIZ],
634 pub ifr_ifru: __c_anonymous_ifr_ifru,
635 }
636
637 pub struct tcp_info {
638 pub tcpi_state: u8,
639 pub __tcpi_ca_state: u8,
640 pub __tcpi_retransmits: u8,
641 pub __tcpi_probes: u8,
642 pub __tcpi_backoff: u8,
643 pub tcpi_options: u8,
644 pub tcpi_snd_wscale: u8,
645 pub tcpi_rcv_wscale: u8,
646 pub tcpi_rto: u32,
647 pub __tcpi_ato: u32,
648 pub tcpi_snd_mss: u32,
649 pub tcpi_rcv_mss: u32,
650 pub __tcpi_unacked: u32,
651 pub __tcpi_sacked: u32,
652 pub __tcpi_lost: u32,
653 pub __tcpi_retrans: u32,
654 pub __tcpi_fackets: u32,
655 pub tcpi_last_data_sent: u32,
656 pub tcpi_last_ack_sent: u32,
657 pub tcpi_last_data_recv: u32,
658 pub tcpi_last_ack_recv: u32,
659 pub __tcpi_pmtu: u32,
660 pub __tcpi_rcv_ssthresh: u32,
661 pub tcpi_rtt: u32,
662 pub tcpi_rttvar: u32,
663 pub tcpi_snd_ssthresh: u32,
664 pub tcpi_snd_cwnd: u32,
665 pub __tcpi_advmss: u32,
666 pub __tcpi_reordering: u32,
667 pub __tcpi_rcv_rtt: u32,
668 pub tcpi_rcv_space: u32,
669 pub tcpi_snd_wnd: u32,
670 pub tcpi_snd_nxt: u32,
671 pub tcpi_rcv_nxt: u32,
672 pub tcpi_toe_tid: u32,
673 pub tcpi_snd_rexmitpack: u32,
674 pub tcpi_rcv_ooopack: u32,
675 pub tcpi_snd_zerowin: u32,
676 pub tcpi_rttmin: u32,
677 pub tcpi_max_sndwnd: u32,
678 pub tcpi_rcv_adv: u32,
679 pub tcpi_rcv_up: u32,
680 pub tcpi_snd_una: u32,
681 pub tcpi_snd_up: u32,
682 pub tcpi_snd_wl1: u32,
683 pub tcpi_snd_wl2: u32,
684 pub tcpi_snd_max: u32,
685 pub tcpi_ts_recent: u32,
686 pub tcpi_ts_recent_age: u32,
687 pub tcpi_rfbuf_cnt: u32,
688 pub tcpi_rfbuf_ts: u32,
689 pub tcpi_so_rcv_sb_cc: u32,
690 pub tcpi_so_rcv_sb_hiwat: u32,
691 pub tcpi_so_rcv_sb_lowat: u32,
692 pub tcpi_so_rcv_sb_wat: u32,
693 pub tcpi_so_snd_sb_cc: u32,
694 pub tcpi_so_snd_sb_hiwat: u32,
695 pub tcpi_so_snd_sb_lowat: u32,
696 pub tcpi_so_snd_sb_wat: u32,
697 }
698
699 pub struct dirent {
700 pub d_fileno: crate::ino_t,
701 pub d_off: off_t,
702 pub d_reclen: u16,
703 pub d_type: u8,
704 pub d_namlen: u8,
705 __d_padding: Padding<[u8; 4]>,
706 pub d_name: [c_char; 256],
707 }
708
709 pub struct sockaddr_storage {
710 pub ss_len: u8,
711 pub ss_family: crate::sa_family_t,
712 __ss_pad1: Padding<[u8; 6]>,
713 __ss_pad2: Padding<i64>,
714 __ss_pad3: Padding<[u8; 240]>,
715 }
716
717 pub struct siginfo_t {
718 pub si_signo: c_int,
719 pub si_code: c_int,
720 pub si_errno: c_int,
721 pub si_addr: *mut c_char,
722 #[cfg(target_pointer_width = "32")]
723 __pad: Padding<[u8; 112]>,
724 #[cfg(target_pointer_width = "64")]
725 __pad: Padding<[u8; 108]>,
726 }
727
728 pub struct lastlog {
729 ll_time: crate::time_t,
730 ll_line: [c_char; UT_LINESIZE],
731 ll_host: [c_char; UT_HOSTSIZE],
732 }
733
734 pub struct utmp {
735 pub ut_line: [c_char; UT_LINESIZE],
736 pub ut_name: [c_char; UT_NAMESIZE],
737 pub ut_host: [c_char; UT_HOSTSIZE],
738 pub ut_time: crate::time_t,
739 }
740
741 pub struct statfs {
742 pub f_flags: u32,
743 pub f_bsize: u32,
744 pub f_iosize: u32,
745 pub f_blocks: u64,
746 pub f_bfree: u64,
747 pub f_bavail: i64,
748 pub f_files: u64,
749 pub f_ffree: u64,
750 pub f_favail: i64,
751 pub f_syncwrites: u64,
752 pub f_syncreads: u64,
753 pub f_asyncwrites: u64,
754 pub f_asyncreads: u64,
755 pub f_fsid: crate::fsid_t,
756 pub f_namemax: u32,
757 pub f_owner: crate::uid_t,
758 pub f_ctime: u64,
759 pub f_fstypename: [c_char; 16],
760 pub f_mntonname: [c_char; 90],
761 pub f_mntfromname: [c_char; 90],
762 pub f_mntfromspec: [c_char; 90],
763 pub mount_info: mount_info,
764 }
765}
766
767s_no_extra_traits! {
768 pub union mount_info {
769 pub ufs_args: ufs_args,
770 pub mfs_args: mfs_args,
771 pub nfs_args: nfs_args,
772 pub iso_args: iso_args,
773 pub msdosfs_args: msdosfs_args,
774 pub ntfs_args: ntfs_args,
775 pub tmpfs_args: tmpfs_args,
776 align: [c_char; 160],
777 }
778}
779
780cfg_if! {
781 if #[cfg(feature = "extra_traits")] {
782 impl PartialEq for mount_info {
783 fn eq(&self, other: &mount_info) -> bool {
784 unsafe {
785 self.align
786 .iter()
787 .zip(other.align.iter())
788 .all(|(a, b)| a == b)
789 }
790 }
791 }
792
793 impl Eq for mount_info {}
794
795 impl hash::Hash for mount_info {
796 fn hash<H: hash::Hasher>(&self, state: &mut H) {
797 unsafe { self.align.hash(state) };
798 }
799 }
800 }
801}
802
803impl siginfo_t {
804 pub unsafe fn si_addr(&self) -> *mut c_char {
805 self.si_addr
806 }
807
808 pub unsafe fn si_code(&self) -> c_int {
809 self.si_code
810 }
811
812 pub unsafe fn si_errno(&self) -> c_int {
813 self.si_errno
814 }
815
816 pub unsafe fn si_pid(&self) -> crate::pid_t {
817 #[repr(C)]
818 struct siginfo_timer {
819 _si_signo: c_int,
820 _si_code: c_int,
821 _si_errno: c_int,
822 _pad: Padding<[c_int; SI_PAD]>,
823 _pid: crate::pid_t,
824 }
825 (*(self as *const siginfo_t).cast::<siginfo_timer>())._pid
826 }
827
828 pub unsafe fn si_uid(&self) -> crate::uid_t {
829 #[repr(C)]
830 struct siginfo_timer {
831 _si_signo: c_int,
832 _si_code: c_int,
833 _si_errno: c_int,
834 _pad: Padding<[c_int; SI_PAD]>,
835 _pid: crate::pid_t,
836 _uid: crate::uid_t,
837 }
838 (*(self as *const siginfo_t).cast::<siginfo_timer>())._uid
839 }
840
841 pub unsafe fn si_value(&self) -> crate::sigval {
842 #[repr(C)]
843 struct siginfo_timer {
844 _si_signo: c_int,
845 _si_code: c_int,
846 _si_errno: c_int,
847 _pad: Padding<[c_int; SI_PAD]>,
848 _pid: crate::pid_t,
849 _uid: crate::uid_t,
850 value: crate::sigval,
851 }
852 (*(self as *const siginfo_t).cast::<siginfo_timer>()).value
853 }
854
855 pub unsafe fn si_status(&self) -> c_int {
856 #[repr(C)]
857 struct siginfo_proc {
858 _si_signo: c_int,
859 _si_code: c_int,
860 _si_errno: c_int,
861 _pad: Padding<[c_int; SI_PAD]>,
862 _pid: crate::pid_t,
863 _uid: crate::uid_t,
864 _utime: crate::clock_t,
865 _stime: crate::clock_t,
866 _status: crate::c_int,
867 }
868 (*(self as *const siginfo_t).cast::<siginfo_proc>())._status
869 }
870}
871
872s_no_extra_traits! {
873 pub union __c_anonymous_ifr_ifru {
874 pub ifru_addr: crate::sockaddr,
875 pub ifru_dstaddr: crate::sockaddr,
876 pub ifru_broadaddr: crate::sockaddr,
877 pub ifru_flags: c_short,
878 pub ifru_metric: c_int,
879 pub ifru_vnetid: i64,
880 pub ifru_media: u64,
881 pub ifru_data: crate::caddr_t,
882 pub ifru_index: c_uint,
883 }
884}
885
886cfg_if! {
887 if #[cfg(feature = "extra_traits")] {
888 impl PartialEq for __c_anonymous_ifr_ifru {
889 fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool {
890 unsafe {
891 self.ifru_addr == other.ifru_addr
892 && self.ifru_dstaddr == other.ifru_dstaddr
893 && self.ifru_broadaddr == other.ifru_broadaddr
894 && self.ifru_flags == other.ifru_flags
895 && self.ifru_metric == other.ifru_metric
896 && self.ifru_vnetid == other.ifru_vnetid
897 && self.ifru_media == other.ifru_media
898 && self.ifru_data == other.ifru_data
899 && self.ifru_index == other.ifru_index
900 }
901 }
902 }
903
904 impl Eq for __c_anonymous_ifr_ifru {}
905
906 impl hash::Hash for __c_anonymous_ifr_ifru {
907 fn hash<H: hash::Hasher>(&self, state: &mut H) {
908 unsafe {
909 self.ifru_addr.hash(state);
910 self.ifru_dstaddr.hash(state);
911 self.ifru_broadaddr.hash(state);
912 self.ifru_flags.hash(state);
913 self.ifru_metric.hash(state);
914 self.ifru_vnetid.hash(state);
915 self.ifru_media.hash(state);
916 self.ifru_data.hash(state);
917 self.ifru_index.hash(state);
918 }
919 }
920 }
921 }
922}
923
924pub const UT_NAMESIZE: usize = 32;
925pub const UT_LINESIZE: usize = 8;
926pub const UT_HOSTSIZE: usize = 256;
927
928pub const O_CLOEXEC: c_int = 0x10000;
929pub const O_DIRECTORY: c_int = 0x20000;
930pub const O_RSYNC: c_int = O_SYNC;
931
932pub const MS_SYNC: c_int = 0x0002;
933pub const MS_INVALIDATE: c_int = 0x0004;
934
935pub const POLLNORM: c_short = crate::POLLRDNORM;
936
937pub const ENOATTR: c_int = 83;
938pub const EILSEQ: c_int = 84;
939pub const EOVERFLOW: c_int = 87;
940pub const ECANCELED: c_int = 88;
941pub const EIDRM: c_int = 89;
942pub const ENOMSG: c_int = 90;
943pub const ENOTSUP: c_int = 91;
944pub const EBADMSG: c_int = 92;
945pub const ENOTRECOVERABLE: c_int = 93;
946pub const EOWNERDEAD: c_int = 94;
947pub const EPROTO: c_int = 95;
948
949/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
950/// for details.
951pub const ELAST: c_int = 95;
952
953pub const F_DUPFD_CLOEXEC: c_int = 10;
954
955pub const UTIME_OMIT: c_long = -1;
956pub const UTIME_NOW: c_long = -2;
957
958pub const AT_FDCWD: c_int = -100;
959pub const AT_EACCESS: c_int = 0x01;
960pub const AT_SYMLINK_NOFOLLOW: c_int = 0x02;
961pub const AT_SYMLINK_FOLLOW: c_int = 0x04;
962pub const AT_REMOVEDIR: c_int = 0x08;
963
964pub const AT_NULL: c_int = 0;
965pub const AT_IGNORE: c_int = 1;
966pub const AT_PAGESZ: c_int = 6;
967pub const AT_HWCAP: c_int = 25;
968pub const AT_HWCAP2: c_int = 26;
969
970#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
971pub const RLIM_NLIMITS: c_int = 9;
972
973pub const SO_TIMESTAMP: c_int = 0x0800;
974pub const SO_SNDTIMEO: c_int = 0x1005;
975pub const SO_RCVTIMEO: c_int = 0x1006;
976pub const SO_BINDANY: c_int = 0x1000;
977pub const SO_NETPROC: c_int = 0x1020;
978pub const SO_RTABLE: c_int = 0x1021;
979pub const SO_PEERCRED: c_int = 0x1022;
980pub const SO_SPLICE: c_int = 0x1023;
981pub const SO_DOMAIN: c_int = 0x1024;
982pub const SO_PROTOCOL: c_int = 0x1025;
983
984// sys/netinet/in.h
985// Protocols (RFC 1700)
986// NOTE: These are in addition to the constants defined in src/unix/mod.rs
987
988// IPPROTO_IP defined in src/unix/mod.rs
989/// Hop-by-hop option header
990pub const IPPROTO_HOPOPTS: c_int = 0;
991// IPPROTO_ICMP defined in src/unix/mod.rs
992/// group mgmt protocol
993pub const IPPROTO_IGMP: c_int = 2;
994/// gateway^2 (deprecated)
995pub const IPPROTO_GGP: c_int = 3;
996/// for compatibility
997pub const IPPROTO_IPIP: c_int = 4;
998// IPPROTO_TCP defined in src/unix/mod.rs
999/// exterior gateway protocol
1000pub const IPPROTO_EGP: c_int = 8;
1001/// pup
1002pub const IPPROTO_PUP: c_int = 12;
1003// IPPROTO_UDP defined in src/unix/mod.rs
1004/// xns idp
1005pub const IPPROTO_IDP: c_int = 22;
1006/// tp-4 w/ class negotiation
1007pub const IPPROTO_TP: c_int = 29;
1008// IPPROTO_IPV6 defined in src/unix/mod.rs
1009/// IP6 routing header
1010pub const IPPROTO_ROUTING: c_int = 43;
1011/// IP6 fragmentation header
1012pub const IPPROTO_FRAGMENT: c_int = 44;
1013/// resource reservation
1014pub const IPPROTO_RSVP: c_int = 46;
1015/// General Routing Encap.
1016pub const IPPROTO_GRE: c_int = 47;
1017/// IP6 Encap Sec. Payload
1018pub const IPPROTO_ESP: c_int = 50;
1019/// IP6 Auth Header
1020pub const IPPROTO_AH: c_int = 51;
1021/// IP Mobility RFC 2004
1022pub const IPPROTO_MOBILE: c_int = 55;
1023// IPPROTO_ICMPV6 defined in src/unix/mod.rs
1024/// IP6 no next header
1025pub const IPPROTO_NONE: c_int = 59;
1026/// IP6 destination option
1027pub const IPPROTO_DSTOPTS: c_int = 60;
1028/// ISO cnlp
1029pub const IPPROTO_EON: c_int = 80;
1030/// Ethernet-in-IP
1031pub const IPPROTO_ETHERIP: c_int = 97;
1032/// encapsulation header
1033pub const IPPROTO_ENCAP: c_int = 98;
1034/// Protocol indep. multicast
1035pub const IPPROTO_PIM: c_int = 103;
1036/// IP Payload Comp. Protocol
1037pub const IPPROTO_IPCOMP: c_int = 108;
1038/// CARP
1039pub const IPPROTO_CARP: c_int = 112;
1040/// unicast MPLS packet
1041pub const IPPROTO_MPLS: c_int = 137;
1042/// PFSYNC
1043pub const IPPROTO_PFSYNC: c_int = 240;
1044pub const IPPROTO_MAX: c_int = 256;
1045
1046// Only used internally, so it can be outside the range of valid IP protocols
1047pub const IPPROTO_DIVERT: c_int = 258;
1048
1049pub const IP_RECVDSTADDR: c_int = 7;
1050pub const IP_SENDSRCADDR: c_int = IP_RECVDSTADDR;
1051pub const IP_RECVIF: c_int = 30;
1052
1053// sys/netinet/in.h
1054pub const TCP_MD5SIG: c_int = 0x04;
1055pub const TCP_NOPUSH: c_int = 0x10;
1056
1057pub const MSG_WAITFORONE: c_int = 0x1000;
1058
1059pub const AF_ECMA: c_int = 8;
1060pub const AF_ROUTE: c_int = 17;
1061pub const AF_ENCAP: c_int = 28;
1062pub const AF_SIP: c_int = 29;
1063pub const AF_KEY: c_int = 30;
1064pub const pseudo_AF_HDRCMPLT: c_int = 31;
1065pub const AF_BLUETOOTH: c_int = 32;
1066pub const AF_MPLS: c_int = 33;
1067pub const pseudo_AF_PFLOW: c_int = 34;
1068pub const pseudo_AF_PIPEX: c_int = 35;
1069pub const NET_RT_DUMP: c_int = 1;
1070pub const NET_RT_FLAGS: c_int = 2;
1071pub const NET_RT_IFLIST: c_int = 3;
1072pub const NET_RT_STATS: c_int = 4;
1073pub const NET_RT_TABLE: c_int = 5;
1074pub const NET_RT_IFNAMES: c_int = 6;
1075#[doc(hidden)]
1076#[deprecated(
1077 since = "0.2.95",
1078 note = "Possibly increasing over the releases and might not be so used in the field"
1079)]
1080pub const NET_RT_MAXID: c_int = 7;
1081
1082pub const IPV6_JOIN_GROUP: c_int = 12;
1083pub const IPV6_LEAVE_GROUP: c_int = 13;
1084
1085pub const PF_ROUTE: c_int = AF_ROUTE;
1086pub const PF_ECMA: c_int = AF_ECMA;
1087pub const PF_ENCAP: c_int = AF_ENCAP;
1088pub const PF_SIP: c_int = AF_SIP;
1089pub const PF_KEY: c_int = AF_KEY;
1090pub const PF_BPF: c_int = pseudo_AF_HDRCMPLT;
1091pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH;
1092pub const PF_MPLS: c_int = AF_MPLS;
1093pub const PF_PFLOW: c_int = pseudo_AF_PFLOW;
1094pub const PF_PIPEX: c_int = pseudo_AF_PIPEX;
1095
1096pub const SCM_TIMESTAMP: c_int = 0x04;
1097
1098pub const O_DSYNC: c_int = 128;
1099
1100pub const MAP_RENAME: c_int = 0x0000;
1101pub const MAP_NORESERVE: c_int = 0x0000;
1102pub const MAP_HASSEMAPHORE: c_int = 0x0000;
1103pub const MAP_TRYFIXED: c_int = 0;
1104
1105pub const EIPSEC: c_int = 82;
1106pub const ENOMEDIUM: c_int = 85;
1107pub const EMEDIUMTYPE: c_int = 86;
1108
1109pub const EAI_BADFLAGS: c_int = -1;
1110pub const EAI_NONAME: c_int = -2;
1111pub const EAI_AGAIN: c_int = -3;
1112pub const EAI_FAIL: c_int = -4;
1113pub const EAI_NODATA: c_int = -5;
1114pub const EAI_FAMILY: c_int = -6;
1115pub const EAI_SOCKTYPE: c_int = -7;
1116pub const EAI_SERVICE: c_int = -8;
1117pub const EAI_MEMORY: c_int = -10;
1118pub const EAI_SYSTEM: c_int = -11;
1119pub const EAI_OVERFLOW: c_int = -14;
1120
1121pub const RUSAGE_THREAD: c_int = 1;
1122
1123pub const MAP_COPY: c_int = 0x0002;
1124pub const MAP_NOEXTEND: c_int = 0x0000;
1125
1126pub const _PC_LINK_MAX: c_int = 1;
1127pub const _PC_MAX_CANON: c_int = 2;
1128pub const _PC_MAX_INPUT: c_int = 3;
1129pub const _PC_NAME_MAX: c_int = 4;
1130pub const _PC_PATH_MAX: c_int = 5;
1131pub const _PC_PIPE_BUF: c_int = 6;
1132pub const _PC_CHOWN_RESTRICTED: c_int = 7;
1133pub const _PC_NO_TRUNC: c_int = 8;
1134pub const _PC_VDISABLE: c_int = 9;
1135pub const _PC_2_SYMLINKS: c_int = 10;
1136pub const _PC_ALLOC_SIZE_MIN: c_int = 11;
1137pub const _PC_ASYNC_IO: c_int = 12;
1138pub const _PC_FILESIZEBITS: c_int = 13;
1139pub const _PC_PRIO_IO: c_int = 14;
1140pub const _PC_REC_INCR_XFER_SIZE: c_int = 15;
1141pub const _PC_REC_MAX_XFER_SIZE: c_int = 16;
1142pub const _PC_REC_MIN_XFER_SIZE: c_int = 17;
1143pub const _PC_REC_XFER_ALIGN: c_int = 18;
1144pub const _PC_SYMLINK_MAX: c_int = 19;
1145pub const _PC_SYNC_IO: c_int = 20;
1146pub const _PC_TIMESTAMP_RESOLUTION: c_int = 21;
1147
1148pub const _CS_PATH: c_int = 1;
1149
1150pub const _SC_CLK_TCK: c_int = 3;
1151pub const _SC_SEM_NSEMS_MAX: c_int = 31;
1152pub const _SC_SEM_VALUE_MAX: c_int = 32;
1153pub const _SC_HOST_NAME_MAX: c_int = 33;
1154pub const _SC_MONOTONIC_CLOCK: c_int = 34;
1155pub const _SC_2_PBS: c_int = 35;
1156pub const _SC_2_PBS_ACCOUNTING: c_int = 36;
1157pub const _SC_2_PBS_CHECKPOINT: c_int = 37;
1158pub const _SC_2_PBS_LOCATE: c_int = 38;
1159pub const _SC_2_PBS_MESSAGE: c_int = 39;
1160pub const _SC_2_PBS_TRACK: c_int = 40;
1161pub const _SC_ADVISORY_INFO: c_int = 41;
1162pub const _SC_AIO_LISTIO_MAX: c_int = 42;
1163pub const _SC_AIO_MAX: c_int = 43;
1164pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 44;
1165pub const _SC_ASYNCHRONOUS_IO: c_int = 45;
1166pub const _SC_ATEXIT_MAX: c_int = 46;
1167pub const _SC_BARRIERS: c_int = 47;
1168pub const _SC_CLOCK_SELECTION: c_int = 48;
1169pub const _SC_CPUTIME: c_int = 49;
1170pub const _SC_DELAYTIMER_MAX: c_int = 50;
1171pub const _SC_IOV_MAX: c_int = 51;
1172pub const _SC_IPV6: c_int = 52;
1173pub const _SC_MAPPED_FILES: c_int = 53;
1174pub const _SC_MEMLOCK: c_int = 54;
1175pub const _SC_MEMLOCK_RANGE: c_int = 55;
1176pub const _SC_MEMORY_PROTECTION: c_int = 56;
1177pub const _SC_MESSAGE_PASSING: c_int = 57;
1178pub const _SC_MQ_OPEN_MAX: c_int = 58;
1179pub const _SC_MQ_PRIO_MAX: c_int = 59;
1180pub const _SC_PRIORITIZED_IO: c_int = 60;
1181pub const _SC_PRIORITY_SCHEDULING: c_int = 61;
1182pub const _SC_RAW_SOCKETS: c_int = 62;
1183pub const _SC_READER_WRITER_LOCKS: c_int = 63;
1184pub const _SC_REALTIME_SIGNALS: c_int = 64;
1185pub const _SC_REGEXP: c_int = 65;
1186pub const _SC_RTSIG_MAX: c_int = 66;
1187pub const _SC_SEMAPHORES: c_int = 67;
1188pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 68;
1189pub const _SC_SHELL: c_int = 69;
1190pub const _SC_SIGQUEUE_MAX: c_int = 70;
1191pub const _SC_SPAWN: c_int = 71;
1192pub const _SC_SPIN_LOCKS: c_int = 72;
1193pub const _SC_SPORADIC_SERVER: c_int = 73;
1194pub const _SC_SS_REPL_MAX: c_int = 74;
1195pub const _SC_SYNCHRONIZED_IO: c_int = 75;
1196pub const _SC_SYMLOOP_MAX: c_int = 76;
1197pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77;
1198pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78;
1199pub const _SC_THREAD_CPUTIME: c_int = 79;
1200pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 80;
1201pub const _SC_THREAD_KEYS_MAX: c_int = 81;
1202pub const _SC_THREAD_PRIO_INHERIT: c_int = 82;
1203pub const _SC_THREAD_PRIO_PROTECT: c_int = 83;
1204pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 84;
1205pub const _SC_THREAD_PROCESS_SHARED: c_int = 85;
1206pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 86;
1207pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 87;
1208pub const _SC_THREAD_SPORADIC_SERVER: c_int = 88;
1209pub const _SC_THREAD_STACK_MIN: c_int = 89;
1210pub const _SC_THREAD_THREADS_MAX: c_int = 90;
1211pub const _SC_THREADS: c_int = 91;
1212pub const _SC_TIMEOUTS: c_int = 92;
1213pub const _SC_TIMER_MAX: c_int = 93;
1214pub const _SC_TIMERS: c_int = 94;
1215pub const _SC_TRACE: c_int = 95;
1216pub const _SC_TRACE_EVENT_FILTER: c_int = 96;
1217pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 97;
1218pub const _SC_TRACE_INHERIT: c_int = 98;
1219pub const _SC_TRACE_LOG: c_int = 99;
1220pub const _SC_GETGR_R_SIZE_MAX: c_int = 100;
1221pub const _SC_GETPW_R_SIZE_MAX: c_int = 101;
1222pub const _SC_LOGIN_NAME_MAX: c_int = 102;
1223pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 103;
1224pub const _SC_TRACE_NAME_MAX: c_int = 104;
1225pub const _SC_TRACE_SYS_MAX: c_int = 105;
1226pub const _SC_TRACE_USER_EVENT_MAX: c_int = 106;
1227pub const _SC_TTY_NAME_MAX: c_int = 107;
1228pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 108;
1229pub const _SC_V6_ILP32_OFF32: c_int = 109;
1230pub const _SC_V6_ILP32_OFFBIG: c_int = 110;
1231pub const _SC_V6_LP64_OFF64: c_int = 111;
1232pub const _SC_V6_LPBIG_OFFBIG: c_int = 112;
1233pub const _SC_V7_ILP32_OFF32: c_int = 113;
1234pub const _SC_V7_ILP32_OFFBIG: c_int = 114;
1235pub const _SC_V7_LP64_OFF64: c_int = 115;
1236pub const _SC_V7_LPBIG_OFFBIG: c_int = 116;
1237pub const _SC_XOPEN_CRYPT: c_int = 117;
1238pub const _SC_XOPEN_ENH_I18N: c_int = 118;
1239pub const _SC_XOPEN_LEGACY: c_int = 119;
1240pub const _SC_XOPEN_REALTIME: c_int = 120;
1241pub const _SC_XOPEN_REALTIME_THREADS: c_int = 121;
1242pub const _SC_XOPEN_STREAMS: c_int = 122;
1243pub const _SC_XOPEN_UNIX: c_int = 123;
1244pub const _SC_XOPEN_UUCP: c_int = 124;
1245pub const _SC_XOPEN_VERSION: c_int = 125;
1246pub const _SC_PHYS_PAGES: c_int = 500;
1247pub const _SC_AVPHYS_PAGES: c_int = 501;
1248pub const _SC_NPROCESSORS_CONF: c_int = 502;
1249pub const _SC_NPROCESSORS_ONLN: c_int = 503;
1250
1251pub const FD_SETSIZE: usize = 1024;
1252
1253pub const SCHED_FIFO: c_int = 1;
1254pub const SCHED_OTHER: c_int = 2;
1255pub const SCHED_RR: c_int = 3;
1256
1257pub const ST_NOSUID: c_ulong = 2;
1258
1259pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut();
1260pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut();
1261pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut();
1262
1263pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1;
1264pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2;
1265pub const PTHREAD_MUTEX_NORMAL: c_int = 3;
1266pub const PTHREAD_MUTEX_STRICT_NP: c_int = 4;
1267pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_STRICT_NP;
1268
1269pub const EVFILT_READ: i16 = -1;
1270pub const EVFILT_WRITE: i16 = -2;
1271pub const EVFILT_AIO: i16 = -3;
1272pub const EVFILT_VNODE: i16 = -4;
1273pub const EVFILT_PROC: i16 = -5;
1274pub const EVFILT_SIGNAL: i16 = -6;
1275pub const EVFILT_TIMER: i16 = -7;
1276pub const EVFILT_DEVICE: i16 = -8;
1277pub const EVFILT_EXCEPT: i16 = -9;
1278pub const EVFILT_USER: i16 = -10;
1279pub const EV_ADD: u16 = 0x1;
1280pub const EV_DELETE: u16 = 0x2;
1281pub const EV_ENABLE: u16 = 0x4;
1282pub const EV_DISABLE: u16 = 0x8;
1283pub const EV_ONESHOT: u16 = 0x10;
1284pub const EV_CLEAR: u16 = 0x20;
1285pub const EV_RECEIPT: u16 = 0x40;
1286pub const EV_DISPATCH: u16 = 0x80;
1287pub const EV_FLAG1: u16 = 0x2000;
1288pub const EV_ERROR: u16 = 0x4000;
1289pub const EV_EOF: u16 = 0x8000;
1290
1291#[deprecated(since = "0.2.113", note = "Not stable across OS versions")]
1292pub const EV_SYSFLAGS: u16 = 0xf800;
1293
1294pub const NOTE_TRIGGER: u32 = 0x01000000;
1295pub const NOTE_FFNOP: u32 = 0x00000000;
1296pub const NOTE_FFAND: u32 = 0x40000000;
1297pub const NOTE_FFOR: u32 = 0x80000000;
1298pub const NOTE_FFCOPY: u32 = 0xc0000000;
1299pub const NOTE_FFCTRLMASK: u32 = 0xc0000000;
1300pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff;
1301pub const NOTE_LOWAT: u32 = 0x00000001;
1302pub const NOTE_EOF: u32 = 0x00000002;
1303pub const NOTE_OOB: u32 = 0x00000004;
1304pub const NOTE_DELETE: u32 = 0x00000001;
1305pub const NOTE_WRITE: u32 = 0x00000002;
1306pub const NOTE_EXTEND: u32 = 0x00000004;
1307pub const NOTE_ATTRIB: u32 = 0x00000008;
1308pub const NOTE_LINK: u32 = 0x00000010;
1309pub const NOTE_RENAME: u32 = 0x00000020;
1310pub const NOTE_REVOKE: u32 = 0x00000040;
1311pub const NOTE_TRUNCATE: u32 = 0x00000080;
1312pub const NOTE_EXIT: u32 = 0x80000000;
1313pub const NOTE_FORK: u32 = 0x40000000;
1314pub const NOTE_EXEC: u32 = 0x20000000;
1315pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1316pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1317pub const NOTE_TRACK: u32 = 0x00000001;
1318pub const NOTE_TRACKERR: u32 = 0x00000002;
1319pub const NOTE_CHILD: u32 = 0x00000004;
1320pub const NOTE_CHANGE: u32 = 0x00000001;
1321
1322pub const TMP_MAX: c_uint = 0x7fffffff;
1323
1324pub const AI_PASSIVE: c_int = 1;
1325pub const AI_CANONNAME: c_int = 2;
1326pub const AI_NUMERICHOST: c_int = 4;
1327pub const AI_EXT: c_int = 8;
1328pub const AI_NUMERICSERV: c_int = 16;
1329pub const AI_FQDN: c_int = 32;
1330pub const AI_ADDRCONFIG: c_int = 64;
1331
1332pub const NI_NUMERICHOST: c_int = 1;
1333pub const NI_NUMERICSERV: c_int = 2;
1334pub const NI_NOFQDN: c_int = 4;
1335pub const NI_NAMEREQD: c_int = 8;
1336pub const NI_DGRAM: c_int = 16;
1337
1338pub const NI_MAXHOST: size_t = 256;
1339
1340pub const RTLD_LOCAL: c_int = 0;
1341
1342pub const CTL_MAXNAME: c_int = 12;
1343
1344pub const CTLTYPE_NODE: c_int = 1;
1345pub const CTLTYPE_INT: c_int = 2;
1346pub const CTLTYPE_STRING: c_int = 3;
1347pub const CTLTYPE_QUAD: c_int = 4;
1348pub const CTLTYPE_STRUCT: c_int = 5;
1349
1350pub const CTL_UNSPEC: c_int = 0;
1351pub const CTL_KERN: c_int = 1;
1352pub const CTL_VM: c_int = 2;
1353pub const CTL_FS: c_int = 3;
1354pub const CTL_NET: c_int = 4;
1355pub const CTL_DEBUG: c_int = 5;
1356pub const CTL_HW: c_int = 6;
1357pub const CTL_MACHDEP: c_int = 7;
1358pub const CTL_DDB: c_int = 9;
1359pub const CTL_VFS: c_int = 10;
1360pub const CTL_MAXID: c_int = 11;
1361
1362pub const HW_NCPUONLINE: c_int = 25;
1363
1364pub const KERN_OSTYPE: c_int = 1;
1365pub const KERN_OSRELEASE: c_int = 2;
1366pub const KERN_OSREV: c_int = 3;
1367pub const KERN_VERSION: c_int = 4;
1368pub const KERN_MAXVNODES: c_int = 5;
1369pub const KERN_MAXPROC: c_int = 6;
1370pub const KERN_MAXFILES: c_int = 7;
1371pub const KERN_ARGMAX: c_int = 8;
1372pub const KERN_SECURELVL: c_int = 9;
1373pub const KERN_HOSTNAME: c_int = 10;
1374pub const KERN_HOSTID: c_int = 11;
1375pub const KERN_CLOCKRATE: c_int = 12;
1376pub const KERN_PROF: c_int = 16;
1377pub const KERN_POSIX1: c_int = 17;
1378pub const KERN_NGROUPS: c_int = 18;
1379pub const KERN_JOB_CONTROL: c_int = 19;
1380pub const KERN_SAVED_IDS: c_int = 20;
1381pub const KERN_BOOTTIME: c_int = 21;
1382pub const KERN_DOMAINNAME: c_int = 22;
1383pub const KERN_MAXPARTITIONS: c_int = 23;
1384pub const KERN_RAWPARTITION: c_int = 24;
1385pub const KERN_MAXTHREAD: c_int = 25;
1386pub const KERN_NTHREADS: c_int = 26;
1387pub const KERN_OSVERSION: c_int = 27;
1388pub const KERN_SOMAXCONN: c_int = 28;
1389pub const KERN_SOMINCONN: c_int = 29;
1390#[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")]
1391pub const KERN_USERMOUNT: c_int = 30;
1392pub const KERN_NOSUIDCOREDUMP: c_int = 32;
1393pub const KERN_FSYNC: c_int = 33;
1394pub const KERN_SYSVMSG: c_int = 34;
1395pub const KERN_SYSVSEM: c_int = 35;
1396pub const KERN_SYSVSHM: c_int = 36;
1397#[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")]
1398pub const KERN_ARND: c_int = 37;
1399pub const KERN_MSGBUFSIZE: c_int = 38;
1400pub const KERN_MALLOCSTATS: c_int = 39;
1401pub const KERN_CPTIME: c_int = 40;
1402pub const KERN_NCHSTATS: c_int = 41;
1403pub const KERN_FORKSTAT: c_int = 42;
1404pub const KERN_NSELCOLL: c_int = 43;
1405pub const KERN_TTY: c_int = 44;
1406pub const KERN_CCPU: c_int = 45;
1407pub const KERN_FSCALE: c_int = 46;
1408pub const KERN_NPROCS: c_int = 47;
1409pub const KERN_MSGBUF: c_int = 48;
1410pub const KERN_POOL: c_int = 49;
1411pub const KERN_STACKGAPRANDOM: c_int = 50;
1412pub const KERN_SYSVIPC_INFO: c_int = 51;
1413pub const KERN_SPLASSERT: c_int = 54;
1414pub const KERN_PROC_ARGS: c_int = 55;
1415pub const KERN_NFILES: c_int = 56;
1416pub const KERN_TTYCOUNT: c_int = 57;
1417pub const KERN_NUMVNODES: c_int = 58;
1418pub const KERN_MBSTAT: c_int = 59;
1419pub const KERN_SEMINFO: c_int = 61;
1420pub const KERN_SHMINFO: c_int = 62;
1421pub const KERN_INTRCNT: c_int = 63;
1422pub const KERN_WATCHDOG: c_int = 64;
1423pub const KERN_PROC: c_int = 66;
1424pub const KERN_MAXCLUSTERS: c_int = 67;
1425pub const KERN_EVCOUNT: c_int = 68;
1426pub const KERN_TIMECOUNTER: c_int = 69;
1427pub const KERN_MAXLOCKSPERUID: c_int = 70;
1428pub const KERN_CPTIME2: c_int = 71;
1429pub const KERN_CACHEPCT: c_int = 72;
1430pub const KERN_FILE: c_int = 73;
1431pub const KERN_CONSDEV: c_int = 75;
1432pub const KERN_NETLIVELOCKS: c_int = 76;
1433pub const KERN_POOL_DEBUG: c_int = 77;
1434pub const KERN_PROC_CWD: c_int = 78;
1435pub const KERN_PROC_NOBROADCASTKILL: c_int = 79;
1436pub const KERN_PROC_VMMAP: c_int = 80;
1437pub const KERN_GLOBAL_PTRACE: c_int = 81;
1438pub const KERN_CONSBUFSIZE: c_int = 82;
1439pub const KERN_CONSBUF: c_int = 83;
1440pub const KERN_AUDIO: c_int = 84;
1441pub const KERN_CPUSTATS: c_int = 85;
1442pub const KERN_PFSTATUS: c_int = 86;
1443pub const KERN_TIMEOUT_STATS: c_int = 87;
1444#[deprecated(
1445 since = "0.2.95",
1446 note = "Possibly increasing over the releases and might not be so used in the field"
1447)]
1448pub const KERN_MAXID: c_int = 88;
1449
1450pub const KERN_PROC_ALL: c_int = 0;
1451pub const KERN_PROC_PID: c_int = 1;
1452pub const KERN_PROC_PGRP: c_int = 2;
1453pub const KERN_PROC_SESSION: c_int = 3;
1454pub const KERN_PROC_TTY: c_int = 4;
1455pub const KERN_PROC_UID: c_int = 5;
1456pub const KERN_PROC_RUID: c_int = 6;
1457pub const KERN_PROC_KTHREAD: c_int = 7;
1458pub const KERN_PROC_SHOW_THREADS: c_int = 0x40000000;
1459
1460pub const KERN_SYSVIPC_MSG_INFO: c_int = 1;
1461pub const KERN_SYSVIPC_SEM_INFO: c_int = 2;
1462pub const KERN_SYSVIPC_SHM_INFO: c_int = 3;
1463
1464pub const KERN_PROC_ARGV: c_int = 1;
1465pub const KERN_PROC_NARGV: c_int = 2;
1466pub const KERN_PROC_ENV: c_int = 3;
1467pub const KERN_PROC_NENV: c_int = 4;
1468
1469pub const KI_NGROUPS: c_int = 16;
1470pub const KI_MAXCOMLEN: c_int = 24;
1471pub const KI_WMESGLEN: c_int = 8;
1472pub const KI_MAXLOGNAME: c_int = 32;
1473pub const KI_EMULNAMELEN: c_int = 8;
1474
1475pub const KVE_ET_OBJ: c_int = 0x00000001;
1476pub const KVE_ET_SUBMAP: c_int = 0x00000002;
1477pub const KVE_ET_COPYONWRITE: c_int = 0x00000004;
1478pub const KVE_ET_NEEDSCOPY: c_int = 0x00000008;
1479pub const KVE_ET_HOLE: c_int = 0x00000010;
1480pub const KVE_ET_NOFAULT: c_int = 0x00000020;
1481pub const KVE_ET_STACK: c_int = 0x00000040;
1482pub const KVE_ET_WC: c_int = 0x000000080;
1483pub const KVE_ET_CONCEAL: c_int = 0x000000100;
1484pub const KVE_ET_SYSCALL: c_int = 0x000000200;
1485pub const KVE_ET_FREEMAPPED: c_int = 0x000000800;
1486
1487pub const KVE_PROT_NONE: c_int = 0x00000000;
1488pub const KVE_PROT_READ: c_int = 0x00000001;
1489pub const KVE_PROT_WRITE: c_int = 0x00000002;
1490pub const KVE_PROT_EXEC: c_int = 0x00000004;
1491
1492pub const KVE_ADV_NORMAL: c_int = 0x00000000;
1493pub const KVE_ADV_RANDOM: c_int = 0x00000001;
1494pub const KVE_ADV_SEQUENTIAL: c_int = 0x00000002;
1495
1496pub const KVE_INH_SHARE: c_int = 0x00000000;
1497pub const KVE_INH_COPY: c_int = 0x00000010;
1498pub const KVE_INH_NONE: c_int = 0x00000020;
1499pub const KVE_INH_ZERO: c_int = 0x00000030;
1500
1501pub const KVE_F_STATIC: c_int = 0x1;
1502pub const KVE_F_KMEM: c_int = 0x2;
1503
1504pub const KERN_FILE_BYFILE: c_int = 1;
1505pub const KERN_FILE_BYPID: c_int = 2;
1506pub const KERN_FILE_BYUID: c_int = 3;
1507pub const KERN_FILESLOP: c_int = 10;
1508
1509pub const KERN_FILE_TEXT: c_int = -1;
1510pub const KERN_FILE_CDIR: c_int = -2;
1511pub const KERN_FILE_RDIR: c_int = -3;
1512pub const KERN_FILE_TRACE: c_int = -4;
1513
1514pub const KI_MNAMELEN: c_int = 96;
1515pub const KI_UNPPATHLEN: c_int = 104;
1516
1517pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS;
1518pub const OLCUC: crate::tcflag_t = 0x20;
1519pub const ONOCR: crate::tcflag_t = 0x40;
1520pub const ONLRET: crate::tcflag_t = 0x80;
1521
1522//https://github.com/openbsd/src/blob/HEAD/sys/sys/mount.h
1523pub const ISOFSMNT_NORRIP: c_int = 0x1; // disable Rock Ridge Ext
1524pub const ISOFSMNT_GENS: c_int = 0x2; // enable generation numbers
1525pub const ISOFSMNT_EXTATT: c_int = 0x4; // enable extended attr
1526pub const ISOFSMNT_NOJOLIET: c_int = 0x8; // disable Joliet Ext
1527pub const ISOFSMNT_SESS: c_int = 0x10; // use iso_args.sess
1528
1529/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
1530/// for details.
1531pub const NFS_ARGSVERSION: c_int = 4; // change when nfs_args changes
1532
1533pub const NFSMNT_RESVPORT: c_int = 0; // always use reserved ports
1534pub const NFSMNT_SOFT: c_int = 0x1; // soft mount (hard is default)
1535pub const NFSMNT_WSIZE: c_int = 0x2; // set write size
1536pub const NFSMNT_RSIZE: c_int = 0x4; // set read size
1537pub const NFSMNT_TIMEO: c_int = 0x8; // set initial timeout
1538pub const NFSMNT_RETRANS: c_int = 0x10; // set number of request retries
1539pub const NFSMNT_MAXGRPS: c_int = 0x20; // set maximum grouplist size
1540pub const NFSMNT_INT: c_int = 0x40; // allow interrupts on hard mount
1541pub const NFSMNT_NOCONN: c_int = 0x80; // Don't Connect the socket
1542pub const NFSMNT_NQNFS: c_int = 0x100; // Use Nqnfs protocol
1543pub const NFSMNT_NFSV3: c_int = 0x200; // Use NFS Version 3 protocol
1544pub const NFSMNT_KERB: c_int = 0x400; // Use Kerberos authentication
1545pub const NFSMNT_DUMBTIMR: c_int = 0x800; // Don't estimate rtt dynamically
1546pub const NFSMNT_LEASETERM: c_int = 0x1000; // set lease term (nqnfs)
1547pub const NFSMNT_READAHEAD: c_int = 0x2000; // set read ahead
1548pub const NFSMNT_DEADTHRESH: c_int = 0x4000; // set dead server retry thresh
1549pub const NFSMNT_NOAC: c_int = 0x8000; // disable attribute cache
1550pub const NFSMNT_RDIRPLUS: c_int = 0x10000; // Use Readdirplus for V3
1551pub const NFSMNT_READDIRSIZE: c_int = 0x20000; // Set readdir size
1552
1553/* Flags valid only in mount syscall arguments */
1554pub const NFSMNT_ACREGMIN: c_int = 0x40000; // acregmin field valid
1555pub const NFSMNT_ACREGMAX: c_int = 0x80000; // acregmax field valid
1556pub const NFSMNT_ACDIRMIN: c_int = 0x100000; // acdirmin field valid
1557pub const NFSMNT_ACDIRMAX: c_int = 0x200000; // acdirmax field valid
1558
1559/* Flags valid only in kernel */
1560pub const NFSMNT_INTERNAL: c_int = u32_cast_int(0xfffc0000); // Bits set internally
1561pub const NFSMNT_HASWRITEVERF: c_int = 0x40000; // Has write verifier for V3
1562pub const NFSMNT_GOTPATHCONF: c_int = 0x80000; // Got the V3 pathconf info
1563pub const NFSMNT_GOTFSINFO: c_int = 0x100000; // Got the V3 fsinfo
1564pub const NFSMNT_MNTD: c_int = 0x200000; // Mnt server for mnt point
1565pub const NFSMNT_DISMINPROG: c_int = 0x400000; // Dismount in progress
1566pub const NFSMNT_DISMNT: c_int = 0x800000; // Dismounted
1567pub const NFSMNT_SNDLOCK: c_int = 0x1000000; // Send socket lock
1568pub const NFSMNT_WANTSND: c_int = 0x2000000; // Want above
1569pub const NFSMNT_RCVLOCK: c_int = 0x4000000; // Rcv socket lock
1570pub const NFSMNT_WANTRCV: c_int = 0x8000000; // Want above
1571pub const NFSMNT_WAITAUTH: c_int = 0x10000000; // Wait for authentication
1572pub const NFSMNT_HASAUTH: c_int = 0x20000000; // Has authenticator
1573pub const NFSMNT_WANTAUTH: c_int = 0x40000000; // Wants an authenticator
1574pub const NFSMNT_AUTHERR: c_int = u32_cast_int(0x80000000); // Authentication error
1575
1576pub const MSDOSFSMNT_SHORTNAME: c_int = 0x1; // Force old DOS short names only
1577pub const MSDOSFSMNT_LONGNAME: c_int = 0x2; // Force Win'95 long names
1578pub const MSDOSFSMNT_NOWIN95: c_int = 0x4; // Completely ignore Win95 entries
1579
1580pub const NTFS_MFLAG_CASEINS: c_int = 0x1;
1581pub const NTFS_MFLAG_ALLNAMES: c_int = 0x2;
1582
1583pub const TMPFS_ARGS_VERSION: c_int = 1;
1584
1585const SI_MAXSZ: size_t = 128;
1586const SI_PAD: size_t = (SI_MAXSZ / size_of::<c_int>()) - 3;
1587
1588pub const MAP_STACK: c_int = 0x4000;
1589pub const MAP_CONCEAL: c_int = 0x8000;
1590
1591// https://github.com/openbsd/src/blob/f8a2f73b6503213f5eb24ca315ac7e1f9421c0c9/sys/net/if.h#L135
1592pub const LINK_STATE_UNKNOWN: c_int = 0; // link unknown
1593pub const LINK_STATE_INVALID: c_int = 1; // link invalid
1594pub const LINK_STATE_DOWN: c_int = 2; // link is down
1595pub const LINK_STATE_KALIVE_DOWN: c_int = 3; // keepalive reports down
1596pub const LINK_STATE_UP: c_int = 4; // link is up
1597pub const LINK_STATE_HALF_DUPLEX: c_int = 5; // link is up and half duplex
1598pub const LINK_STATE_FULL_DUPLEX: c_int = 6; // link is up and full duplex
1599
1600// https://github.com/openbsd/src/blob/HEAD/sys/net/if.h#L187
1601pub const IFF_UP: c_int = 0x1; // interface is up
1602pub const IFF_BROADCAST: c_int = 0x2; // broadcast address valid
1603pub const IFF_DEBUG: c_int = 0x4; // turn on debugging
1604pub const IFF_LOOPBACK: c_int = 0x8; // is a loopback net
1605pub const IFF_POINTOPOINT: c_int = 0x10; // interface is point-to-point link
1606pub const IFF_STATICARP: c_int = 0x20; // only static ARP
1607pub const IFF_RUNNING: c_int = 0x40; // resources allocated
1608pub const IFF_NOARP: c_int = 0x80; // no address resolution protocol
1609pub const IFF_PROMISC: c_int = 0x100; // receive all packets
1610pub const IFF_ALLMULTI: c_int = 0x200; // receive all multicast packets
1611pub const IFF_OACTIVE: c_int = 0x400; // transmission in progress
1612pub const IFF_SIMPLEX: c_int = 0x800; // can't hear own transmissions
1613pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit
1614pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit
1615pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit
1616pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast
1617
1618pub const PTHREAD_STACK_MIN: size_t = 1_usize << _MAX_PAGE_SHIFT;
1619pub const MINSIGSTKSZ: size_t = 3_usize << _MAX_PAGE_SHIFT;
1620pub const SIGSTKSZ: size_t = MINSIGSTKSZ + (1_usize << _MAX_PAGE_SHIFT) * 4;
1621
1622pub const PT_SET_EVENT_MASK: c_int = 12;
1623pub const PT_GET_EVENT_MASK: c_int = 13;
1624pub const PT_GET_PROCESS_STATE: c_int = 14;
1625pub const PT_GET_THREAD_FIRST: c_int = 15;
1626pub const PT_GET_THREAD_NEXT: c_int = 16;
1627pub const PT_FIRSTMACH: c_int = 32;
1628
1629pub const PT_PTS_NAMELEN: c_int = 32;
1630
1631pub const SOCK_CLOEXEC: c_int = 0x8000;
1632pub const SOCK_NONBLOCK: c_int = 0x4000;
1633pub const SOCK_DNS: c_int = 0x1000;
1634
1635pub const BIOCGRSIG: c_ulong = 0x40044273;
1636pub const BIOCSRSIG: c_ulong = 0x80044272;
1637pub const BIOCSDLT: c_ulong = 0x8004427a;
1638
1639pub const PTRACE_FORK: c_int = 0x0002;
1640
1641pub const WCONTINUED: c_int = 0x08;
1642pub const WEXITED: c_int = 0x04;
1643pub const WSTOPPED: c_int = 0x02; // same as WUNTRACED
1644pub const WNOWAIT: c_int = 0x10;
1645pub const WTRAPPED: c_int = 0x20;
1646
1647pub const P_ALL: crate::idtype_t = 0;
1648pub const P_PGID: crate::idtype_t = 1;
1649pub const P_PID: crate::idtype_t = 2;
1650
1651// search.h
1652pub const FIND: crate::ACTION = 0;
1653pub const ENTER: crate::ACTION = 1;
1654
1655// futex.h
1656pub const FUTEX_WAIT: c_int = 1;
1657pub const FUTEX_WAKE: c_int = 2;
1658pub const FUTEX_REQUEUE: c_int = 3;
1659pub const FUTEX_PRIVATE_FLAG: c_int = 128;
1660
1661// sys/file.h
1662pub const DTYPE_VNODE: c_int = 1;
1663pub const DTYPE_SOCKET: c_int = 2;
1664pub const DTYPE_PIPE: c_int = 3;
1665pub const DTYPE_KQUEUE: c_int = 4;
1666pub const DTYPE_DMABUF: c_int = 5;
1667pub const DTYPE_SYNC: c_int = 6;
1668
1669// sysctl.h, kinfo_proc p_eflag constants
1670pub const EPROC_CTTY: i32 = 0x01; // controlling tty vnode active
1671pub const EPROC_SLEADER: i32 = 0x02; // session leader
1672pub const EPROC_UNVEIL: i32 = 0x04; // has unveil settings
1673pub const EPROC_LKUNVEIL: i32 = 0x08; // unveil is locked
1674
1675// Flags for chflags(2)
1676pub const UF_SETTABLE: c_uint = 0x0000ffff;
1677pub const UF_NODUMP: c_uint = 0x00000001;
1678pub const UF_IMMUTABLE: c_uint = 0x00000002;
1679pub const UF_APPEND: c_uint = 0x00000004;
1680pub const UF_OPAQUE: c_uint = 0x00000008;
1681pub const SF_SETTABLE: c_uint = 0xffff0000;
1682pub const SF_ARCHIVED: c_uint = 0x00010000;
1683pub const SF_IMMUTABLE: c_uint = 0x00020000;
1684pub const SF_APPEND: c_uint = 0x00040000;
1685
1686// sys/exec_elf.h - Legal values for p_type (segment type).
1687pub const PT_NULL: u32 = 0;
1688pub const PT_LOAD: u32 = 1;
1689pub const PT_DYNAMIC: u32 = 2;
1690pub const PT_INTERP: u32 = 3;
1691pub const PT_NOTE: u32 = 4;
1692pub const PT_SHLIB: u32 = 5;
1693pub const PT_PHDR: u32 = 6;
1694pub const PT_TLS: u32 = 7;
1695pub const PT_LOOS: u32 = 0x60000000;
1696pub const PT_HIOS: u32 = 0x6fffffff;
1697pub const PT_LOPROC: u32 = 0x70000000;
1698pub const PT_HIPROC: u32 = 0x7fffffff;
1699
1700pub const PT_GNU_EH_FRAME: u32 = 0x6474e550;
1701pub const PT_GNU_RELRO: u32 = 0x6474e552;
1702
1703// sys/exec_elf.h - Legal values for p_flags (segment flags).
1704pub const PF_X: u32 = 0x1;
1705pub const PF_W: u32 = 0x2;
1706pub const PF_R: u32 = 0x4;
1707pub const PF_MASKOS: u32 = 0x0ff00000;
1708pub const PF_MASKPROC: u32 = 0xf0000000;
1709
1710// sys/ioccom.h
1711pub const fn IOCPARM_LEN(x: u32) -> u32 {
1712 (x >> 16) & crate::IOCPARM_MASK
1713}
1714
1715pub const fn IOCBASECMD(x: u32) -> u32 {
1716 x & (!(crate::IOCPARM_MASK << 16))
1717}
1718
1719pub const fn IOCGROUP(x: u32) -> u32 {
1720 (x >> 8) & 0xff
1721}
1722
1723pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong {
1724 (inout) | (((len) & crate::IOCPARM_MASK as c_ulong) << 16) | ((group) << 8) | (num)
1725}
1726
1727// sys/mount.h
1728pub const MNT_NOPERM: c_int = 0x00000020;
1729pub const MNT_WXALLOWED: c_int = 0x00000800;
1730pub const MNT_EXRDONLY: c_int = 0x00000080;
1731pub const MNT_DEFEXPORTED: c_int = 0x00000200;
1732pub const MNT_EXPORTANON: c_int = 0x00000400;
1733pub const MNT_ROOTFS: c_int = 0x00004000;
1734pub const MNT_NOATIME: c_int = 0x00008000;
1735pub const MNT_DELEXPORT: c_int = 0x00020000;
1736pub const MNT_STALLED: c_int = 0x00100000;
1737pub const MNT_SWAPPABLE: c_int = 0x00200000;
1738pub const MNT_WANTRDWR: c_int = 0x02000000;
1739pub const MNT_SOFTDEP: c_int = 0x04000000;
1740pub const MNT_DOOMED: c_int = 0x08000000;
1741
1742// For use with vfs_fsync and getfsstat
1743pub const MNT_WAIT: c_int = 1;
1744pub const MNT_NOWAIT: c_int = 2;
1745pub const MNT_LAZY: c_int = 3;
1746
1747// sys/_time.h
1748pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2;
1749pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4;
1750pub const CLOCK_UPTIME: crate::clockid_t = 5;
1751pub const CLOCK_BOOTTIME: crate::clockid_t = 6;
1752
1753pub const LC_COLLATE_MASK: c_int = 1 << crate::LC_COLLATE;
1754pub const LC_CTYPE_MASK: c_int = 1 << crate::LC_CTYPE;
1755pub const LC_MONETARY_MASK: c_int = 1 << crate::LC_MONETARY;
1756pub const LC_NUMERIC_MASK: c_int = 1 << crate::LC_NUMERIC;
1757pub const LC_TIME_MASK: c_int = 1 << crate::LC_TIME;
1758pub const LC_MESSAGES_MASK: c_int = 1 << crate::LC_MESSAGES;
1759
1760/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
1761/// for details.
1762const _LC_LAST: c_int = 7;
1763
1764pub const LC_ALL_MASK: c_int = (1 << _LC_LAST) - 2;
1765
1766pub const LC_GLOBAL_LOCALE: crate::locale_t = -1isize as crate::locale_t;
1767
1768// sys/reboot.h
1769pub const RB_ASKNAME: c_int = 0x00001;
1770pub const RB_SINGLE: c_int = 0x00002;
1771pub const RB_NOSYNC: c_int = 0x00004;
1772pub const RB_HALT: c_int = 0x00008;
1773pub const RB_INITNAME: c_int = 0x00010;
1774pub const RB_KDB: c_int = 0x00040;
1775pub const RB_RDONLY: c_int = 0x00080;
1776pub const RB_DUMP: c_int = 0x00100;
1777pub const RB_MINIROOT: c_int = 0x00200;
1778pub const RB_CONFIG: c_int = 0x00400;
1779pub const RB_TIMEBAD: c_int = 0x00800;
1780pub const RB_POWERDOWN: c_int = 0x01000;
1781pub const RB_SERCONS: c_int = 0x02000;
1782pub const RB_USERREQ: c_int = 0x04000;
1783pub const RB_RESET: c_int = 0x08000;
1784pub const RB_GOODRANDOM: c_int = 0x10000;
1785pub const RB_UNHIBERNATE: c_int = 0x20000;
1786
1787// net/route.h
1788pub const RTF_CLONING: c_int = 0x100;
1789pub const RTF_MULTICAST: c_int = 0x200;
1790pub const RTF_LLINFO: c_int = 0x400;
1791pub const RTF_PROTO3: c_int = 0x2000;
1792pub const RTF_ANNOUNCE: c_int = crate::RTF_PROTO2;
1793
1794pub const RTF_CLONED: c_int = 0x10000;
1795pub const RTF_CACHED: c_int = 0x20000;
1796pub const RTF_MPATH: c_int = 0x40000;
1797pub const RTF_MPLS: c_int = 0x100000;
1798pub const RTF_LOCAL: c_int = 0x200000;
1799pub const RTF_BROADCAST: c_int = 0x400000;
1800pub const RTF_CONNECTED: c_int = 0x800000;
1801pub const RTF_BFD: c_int = 0x1000000;
1802pub const RTF_FMASK: c_int = crate::RTF_LLINFO
1803 | crate::RTF_PROTO1
1804 | crate::RTF_PROTO2
1805 | crate::RTF_PROTO3
1806 | crate::RTF_BLACKHOLE
1807 | crate::RTF_REJECT
1808 | crate::RTF_STATIC
1809 | crate::RTF_MPLS
1810 | crate::RTF_BFD;
1811
1812pub const RTM_VERSION: c_int = 5;
1813pub const RTM_RESOLVE: c_int = 0xb;
1814pub const RTM_NEWADDR: c_int = 0xc;
1815pub const RTM_DELADDR: c_int = 0xd;
1816pub const RTM_IFINFO: c_int = 0xe;
1817pub const RTM_IFANNOUNCE: c_int = 0xf;
1818pub const RTM_DESYNC: c_int = 0x10;
1819pub const RTM_INVALIDATE: c_int = 0x11;
1820pub const RTM_BFD: c_int = 0x12;
1821pub const RTM_PROPOSAL: c_int = 0x13;
1822pub const RTM_CHGADDRATTR: c_int = 0x14;
1823pub const RTM_80211INFO: c_int = 0x15;
1824pub const RTM_SOURCE: c_int = 0x16;
1825
1826pub const RTA_SRC: c_int = 0x100;
1827pub const RTA_SRCMASK: c_int = 0x200;
1828pub const RTA_LABEL: c_int = 0x400;
1829pub const RTA_BFD: c_int = 0x800;
1830pub const RTA_DNS: c_int = 0x1000;
1831pub const RTA_STATIC: c_int = 0x2000;
1832pub const RTA_SEARCH: c_int = 0x4000;
1833
1834pub const RTAX_SRC: c_int = 8;
1835pub const RTAX_SRCMASK: c_int = 9;
1836pub const RTAX_LABEL: c_int = 10;
1837pub const RTAX_BFD: c_int = 11;
1838pub const RTAX_DNS: c_int = 12;
1839pub const RTAX_STATIC: c_int = 13;
1840pub const RTAX_SEARCH: c_int = 14;
1841
1842/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
1843/// for details.
1844pub const RTAX_MAX: c_int = 15;
1845
1846const fn _ALIGN(p: usize) -> usize {
1847 (p + _ALIGNBYTES) & !_ALIGNBYTES
1848}
1849
1850f! {
1851 pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar {
1852 (cmsg as *mut c_uchar).offset(_ALIGN(size_of::<cmsghdr>()) as isize)
1853 }
1854
1855 pub const unsafe fn CMSG_LEN(length: c_uint) -> c_uint {
1856 _ALIGN(size_of::<cmsghdr>()) as c_uint + length
1857 }
1858
1859 pub unsafe fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
1860 if cmsg.is_null() {
1861 return crate::CMSG_FIRSTHDR(mhdr);
1862 }
1863 let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::<cmsghdr>());
1864 let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
1865 if next > max {
1866 ptr::null_mut()
1867 } else {
1868 (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
1869 }
1870 }
1871
1872 pub const unsafe fn CMSG_SPACE(length: c_uint) -> c_uint {
1873 (_ALIGN(size_of::<cmsghdr>()) + _ALIGN(length as usize)) as c_uint
1874 }
1875}
1876
1877safe_f! {
1878 pub const safe fn WSTOPSIG(status: c_int) -> c_int {
1879 status >> 8
1880 }
1881
1882 pub const safe fn WIFSIGNALED(status: c_int) -> bool {
1883 (status & 0o177) != 0o177 && (status & 0o177) != 0
1884 }
1885
1886 pub const safe fn WIFSTOPPED(status: c_int) -> bool {
1887 (status & 0xff) == 0o177
1888 }
1889
1890 pub const safe fn WIFCONTINUED(status: c_int) -> bool {
1891 (status & 0o177777) == 0o177777
1892 }
1893
1894 pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
1895 let major = major as crate::dev_t;
1896 let minor = minor as crate::dev_t;
1897 let mut dev = 0;
1898 dev |= (major & 0xff) << 8;
1899 dev |= minor & 0xff;
1900 dev |= (minor & 0xffff00) << 8;
1901 dev
1902 }
1903
1904 pub const safe fn major(dev: crate::dev_t) -> c_uint {
1905 ((dev as c_uint) >> 8) & 0xff
1906 }
1907
1908 pub const safe fn minor(dev: crate::dev_t) -> c_uint {
1909 let dev = dev as c_uint;
1910 let mut res = 0;
1911 res |= (dev) & 0xff;
1912 res |= ((dev) & 0xffff0000) >> 8;
1913 res
1914 }
1915}
1916
1917extern "C" {
1918 pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int;
1919 pub fn settimeofday(tp: *const crate::timeval, tz: *const crate::timezone) -> c_int;
1920 pub fn pledge(promises: *const c_char, execpromises: *const c_char) -> c_int;
1921 pub fn unveil(path: *const c_char, permissions: *const c_char) -> c_int;
1922 pub fn strtonum(
1923 nptr: *const c_char,
1924 minval: c_longlong,
1925 maxval: c_longlong,
1926 errstr: *mut *const c_char,
1927 ) -> c_longlong;
1928 pub fn dup3(src: c_int, dst: c_int, flags: c_int) -> c_int;
1929 pub fn chflags(path: *const c_char, flags: c_uint) -> c_int;
1930 pub fn fchflags(fd: c_int, flags: c_uint) -> c_int;
1931 pub fn chflagsat(fd: c_int, path: *const c_char, flags: c_uint, atflag: c_int) -> c_int;
1932 pub fn dirfd(dirp: *mut crate::DIR) -> c_int;
1933 pub fn getnameinfo(
1934 sa: *const crate::sockaddr,
1935 salen: crate::socklen_t,
1936 host: *mut c_char,
1937 hostlen: size_t,
1938 serv: *mut c_char,
1939 servlen: size_t,
1940 flags: c_int,
1941 ) -> c_int;
1942 pub fn getresgid(
1943 rgid: *mut crate::gid_t,
1944 egid: *mut crate::gid_t,
1945 sgid: *mut crate::gid_t,
1946 ) -> c_int;
1947 pub fn getresuid(
1948 ruid: *mut crate::uid_t,
1949 euid: *mut crate::uid_t,
1950 suid: *mut crate::uid_t,
1951 ) -> c_int;
1952 pub fn kevent(
1953 kq: c_int,
1954 changelist: *const crate::kevent,
1955 nchanges: c_int,
1956 eventlist: *mut crate::kevent,
1957 nevents: c_int,
1958 timeout: *const crate::timespec,
1959 ) -> c_int;
1960 pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
1961 pub fn getthrid() -> crate::pid_t;
1962 pub fn pthread_attr_getguardsize(
1963 attr: *const crate::pthread_attr_t,
1964 guardsize: *mut size_t,
1965 ) -> c_int;
1966 pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int;
1967 pub fn pthread_attr_getstack(
1968 attr: *const crate::pthread_attr_t,
1969 stackaddr: *mut *mut c_void,
1970 stacksize: *mut size_t,
1971 ) -> c_int;
1972 pub fn pthread_main_np() -> c_int;
1973 pub fn pthread_get_name_np(tid: crate::pthread_t, name: *mut c_char, len: size_t);
1974 pub fn pthread_set_name_np(tid: crate::pthread_t, name: *const c_char);
1975 pub fn pthread_stackseg_np(thread: crate::pthread_t, sinfo: *mut crate::stack_t) -> c_int;
1976
1977 pub fn openpty(
1978 amaster: *mut c_int,
1979 aslave: *mut c_int,
1980 name: *mut c_char,
1981 termp: *const crate::termios,
1982 winp: *const crate::winsize,
1983 ) -> c_int;
1984 pub fn forkpty(
1985 amaster: *mut c_int,
1986 name: *mut c_char,
1987 termp: *const crate::termios,
1988 winp: *const crate::winsize,
1989 ) -> crate::pid_t;
1990
1991 pub fn sysctl(
1992 name: *const c_int,
1993 namelen: c_uint,
1994 oldp: *mut c_void,
1995 oldlenp: *mut size_t,
1996 newp: *mut c_void,
1997 newlen: size_t,
1998 ) -> c_int;
1999 pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int;
2000 pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int;
2001 pub fn ptrace(request: c_int, pid: crate::pid_t, addr: caddr_t, data: c_int) -> c_int;
2002 pub fn utrace(label: *const c_char, addr: *const c_void, len: size_t) -> c_int;
2003 pub fn memmem(
2004 haystack: *const c_void,
2005 haystacklen: size_t,
2006 needle: *const c_void,
2007 needlelen: size_t,
2008 ) -> *mut c_void;
2009 // #include <link.h>
2010 pub fn dl_iterate_phdr(
2011 callback: Option<
2012 unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int,
2013 >,
2014 data: *mut c_void,
2015 ) -> c_int;
2016 pub fn uselocale(loc: crate::locale_t) -> crate::locale_t;
2017 pub fn freelocale(loc: crate::locale_t);
2018 pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t;
2019 pub fn duplocale(base: crate::locale_t) -> crate::locale_t;
2020
2021 // Added in `OpenBSD` 5.5
2022 pub fn explicit_bzero(s: *mut c_void, len: size_t);
2023
2024 pub fn setproctitle(fmt: *const c_char, ...);
2025
2026 pub fn freezero(ptr: *mut c_void, size: size_t);
2027 pub fn malloc_conceal(size: size_t) -> *mut c_void;
2028 pub fn calloc_conceal(nmemb: size_t, size: size_t) -> *mut c_void;
2029
2030 pub fn srand48_deterministic(seed: c_long);
2031 pub fn seed48_deterministic(xseed: *mut c_ushort) -> *mut c_ushort;
2032 pub fn lcong48_deterministic(p: *mut c_ushort);
2033
2034 pub fn lsearch(
2035 key: *const c_void,
2036 base: *mut c_void,
2037 nelp: *mut size_t,
2038 width: size_t,
2039 compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
2040 ) -> *mut c_void;
2041 pub fn lfind(
2042 key: *const c_void,
2043 base: *const c_void,
2044 nelp: *mut size_t,
2045 width: size_t,
2046 compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
2047 ) -> *mut c_void;
2048 pub fn hcreate(nelt: size_t) -> c_int;
2049 pub fn hdestroy();
2050 pub fn hsearch(entry: crate::ENTRY, action: crate::ACTION) -> *mut crate::ENTRY;
2051
2052 // futex.h
2053 pub fn futex(
2054 uaddr: *mut u32,
2055 op: c_int,
2056 val: c_int,
2057 timeout: *const crate::timespec,
2058 uaddr2: *mut u32,
2059 ) -> c_int;
2060
2061 pub fn mimmutable(addr: *mut c_void, len: size_t) -> c_int;
2062
2063 pub fn reboot(mode: c_int) -> c_int;
2064
2065 pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int;
2066 pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int;
2067 pub fn getmntinfo(mntbufp: *mut *mut crate::statfs, flags: c_int) -> c_int;
2068 pub fn getfsstat(buf: *mut statfs, bufsize: size_t, flags: c_int) -> c_int;
2069
2070 pub fn elf_aux_info(aux: c_int, buf: *mut c_void, buflen: c_int) -> c_int;
2071}
2072
2073#[link(name = "execinfo")]
2074extern "C" {
2075 pub fn backtrace(addrlist: *mut *mut c_void, len: size_t) -> size_t;
2076 pub fn backtrace_symbols(addrlist: *const *mut c_void, len: size_t) -> *mut *mut c_char;
2077 pub fn backtrace_symbols_fd(addrlist: *const *mut c_void, len: size_t, fd: c_int) -> c_int;
2078 pub fn backtrace_symbols_fmt(
2079 addrlist: *const *mut c_void,
2080 len: size_t,
2081 fmt: *const c_char,
2082 ) -> *mut *mut c_char;
2083}
2084
2085cfg_if! {
2086 if #[cfg(target_arch = "aarch64")] {
2087 mod aarch64;
2088 pub use self::aarch64::*;
2089 } else if #[cfg(target_arch = "arm")] {
2090 mod arm;
2091 pub use self::arm::*;
2092 } else if #[cfg(target_arch = "mips64")] {
2093 mod mips64;
2094 pub use self::mips64::*;
2095 } else if #[cfg(target_arch = "powerpc")] {
2096 mod powerpc;
2097 pub use self::powerpc::*;
2098 } else if #[cfg(target_arch = "powerpc64")] {
2099 mod powerpc64;
2100 pub use self::powerpc64::*;
2101 } else if #[cfg(target_arch = "riscv64")] {
2102 mod riscv64;
2103 pub use self::riscv64::*;
2104 } else if #[cfg(target_arch = "sparc64")] {
2105 mod sparc64;
2106 pub use self::sparc64::*;
2107 } else if #[cfg(target_arch = "x86")] {
2108 mod x86;
2109 pub use self::x86::*;
2110 } else if #[cfg(target_arch = "x86_64")] {
2111 mod x86_64;
2112 pub use self::x86_64::*;
2113 } else {
2114 // Unknown target_arch
2115 }
2116}