Debian Codegraph @

debian/missing-sources/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs

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