Debian Codegraph @

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