Debian Codegraph @

vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs

raw
1 use crate::prelude::*;
2 use crate::{
3 cmsghdr,
4 cpuid_t,
5 lwpid_t,
6 off_t,
7 };
8
9 pub type blksize_t = i32;
10 pub type eventfd_t = u64;
11 pub type fsblkcnt_t = u64;
12 pub type fsfilcnt_t = u64;
13 pub type idtype_t = c_int;
14 type __pthread_spin_t = __cpu_simple_lock_nv_t;
15 pub type shmatt_t = c_uint;
16 pub type cpuset_t = _cpuset;
17 pub type pthread_spin_t = __pthread_spin_t;
18
19 // elf.h
20
21 pub type Elf32_Addr = u32;
22 pub type Elf32_Half = u16;
23 pub type Elf32_Lword = u64;
24 pub type Elf32_Off = u32;
25 pub type Elf32_Sword = i32;
26 pub type Elf32_Word = u32;
27
28 pub type Elf64_Addr = u64;
29 pub type Elf64_Half = u16;
30 pub type Elf64_Lword = u64;
31 pub type Elf64_Off = u64;
32 pub type Elf64_Sword = i32;
33 pub type Elf64_Sxword = i64;
34 pub type Elf64_Word = u32;
35 pub type Elf64_Xword = u64;
36
37 pub type iconv_t = *mut c_void;
38
39 e! {
40 #[repr(C)]
41 pub enum fae_action {
42 FAE_OPEN,
43 FAE_DUP2,
44 FAE_CLOSE,
45 }
46 }
47
48 extern_ty! {
49 pub enum _cpuset {}
50 }
51
52 cfg_if! {
53 if #[cfg(target_pointer_width = "64")] {
54 type Elf_Addr = Elf64_Addr;
55 type Elf_Half = Elf64_Half;
56 type Elf_Phdr = Elf64_Phdr;
57 } else if #[cfg(target_pointer_width = "32")] {
58 type Elf_Addr = Elf32_Addr;
59 type Elf_Half = Elf32_Half;
60 type Elf_Phdr = Elf32_Phdr;
61 }
62 }
63
64 impl siginfo_t {
65 pub unsafe fn si_addr(&self) -> *mut c_void {
66 self.si_addr
67 }
68
69 pub unsafe fn si_code(&self) -> c_int {
70 self.si_code
71 }
72
73 pub unsafe fn si_errno(&self) -> c_int {
74 self.si_errno
75 }
76
77 pub unsafe fn si_pid(&self) -> crate::pid_t {
78 #[repr(C)]
79 struct siginfo_timer {
80 _si_signo: c_int,
81 _si_errno: c_int,
82 _si_code: c_int,
83 #[cfg(target_pointer_width = "64")]
84 __pad1: Padding<c_int>,
85 _pid: crate::pid_t,
86 }
87 (*(self as *const siginfo_t as *const siginfo_timer))._pid
88 }
89
90 pub unsafe fn si_uid(&self) -> crate::uid_t {
91 #[repr(C)]
92 struct siginfo_timer {
93 _si_signo: c_int,
94 _si_errno: c_int,
95 _si_code: c_int,
96 #[cfg(target_pointer_width = "64")]
97 __pad1: Padding<c_int>,
98 _pid: crate::pid_t,
99 _uid: crate::uid_t,
100 }
101 (*(self as *const siginfo_t as *const siginfo_timer))._uid
102 }
103
104 pub unsafe fn si_value(&self) -> crate::sigval {
105 #[repr(C)]
106 struct siginfo_timer {
107 _si_signo: c_int,
108 _si_errno: c_int,
109 _si_code: c_int,
110 #[cfg(target_pointer_width = "64")]
111 __pad1: Padding<c_int>,
112 _pid: crate::pid_t,
113 _uid: crate::uid_t,
114 value: crate::sigval,
115 }
116 (*(self as *const siginfo_t as *const siginfo_timer)).value
117 }
118
119 pub unsafe fn si_status(&self) -> c_int {
120 #[repr(C)]
121 struct siginfo_timer {
122 _si_signo: c_int,
123 _si_errno: c_int,
124 _si_code: c_int,
125 #[cfg(target_pointer_width = "64")]
126 __pad1: Padding<c_int>,
127 _pid: crate::pid_t,
128 _uid: crate::uid_t,
129 status: c_int,
130 }
131 (*(self as *const siginfo_t as *const siginfo_timer)).status
132 }
133 }
134
135 s! {
136 pub struct aiocb {
137 pub aio_offset: off_t,
138 pub aio_buf: *mut c_void,
139 pub aio_nbytes: size_t,
140 pub aio_fildes: c_int,
141 pub aio_lio_opcode: c_int,
142 pub aio_reqprio: c_int,
143 pub aio_sigevent: crate::sigevent,
144 _state: c_int,
145 _errno: c_int,
146 _retval: ssize_t,
147 }
148
149 pub struct glob_t {
150 pub gl_pathc: size_t,
151 pub gl_matchc: size_t,
152 pub gl_offs: size_t,
153 pub gl_flags: c_int,
154 pub gl_pathv: *mut *mut c_char,
155
156 __unused3: Padding<*mut c_void>,
157
158 __unused4: Padding<*mut c_void>,
159 __unused5: Padding<*mut c_void>,
160 __unused6: Padding<*mut c_void>,
161 __unused7: Padding<*mut c_void>,
162 __unused8: Padding<*mut c_void>,
163 }
164
165 pub struct tm {
166 pub tm_sec: c_int,
167 pub tm_min: c_int,
168 pub tm_hour: c_int,
169 pub tm_mday: c_int,
170 pub tm_mon: c_int,
171 pub tm_year: c_int,
172 pub tm_wday: c_int,
173 pub tm_yday: c_int,
174 pub tm_isdst: c_int,
175 pub tm_gmtoff: c_long,
176 pub tm_zone: *mut c_char,
177 }
178
179 pub struct mq_attr {
180 pub mq_flags: c_long,
181 pub mq_maxmsg: c_long,
182 pub mq_msgsize: c_long,
183 pub mq_curmsgs: c_long,
184 }
185
186 pub struct sigset_t {
187 __bits: [u32; 4],
188 }
189
190 pub struct stat {
191 pub st_dev: crate::dev_t,
192 pub st_mode: crate::mode_t,
193 pub st_ino: crate::ino_t,
194 pub st_nlink: crate::nlink_t,
195 pub st_uid: crate::uid_t,
196 pub st_gid: crate::gid_t,
197 pub st_rdev: crate::dev_t,
198 pub st_atime: crate::time_t,
199 pub st_atimensec: c_long,
200 pub st_mtime: crate::time_t,
201 pub st_mtimensec: c_long,
202 pub st_ctime: crate::time_t,
203 pub st_ctimensec: c_long,
204 pub st_birthtime: crate::time_t,
205 pub st_birthtimensec: c_long,
206 pub st_size: off_t,
207 pub st_blocks: crate::blkcnt_t,
208 pub st_blksize: crate::blksize_t,
209 pub st_flags: u32,
210 pub st_gen: u32,
211 pub st_spare: [u32; 2],
212 }
213
214 pub struct addrinfo {
215 pub ai_flags: c_int,
216 pub ai_family: c_int,
217 pub ai_socktype: c_int,
218 pub ai_protocol: c_int,
219 pub ai_addrlen: crate::socklen_t,
220 pub ai_canonname: *mut c_char,
221 pub ai_addr: *mut crate::sockaddr,
222 pub ai_next: *mut crate::addrinfo,
223 }
224
225 pub struct siginfo_t {
226 pub si_signo: c_int,
227 pub si_code: c_int,
228 pub si_errno: c_int,
229 #[cfg(target_pointer_width = "64")]
230 __pad1: Padding<c_int>,
231 pub si_addr: *mut c_void,
232 #[cfg(target_pointer_width = "64")]
233 __pad2: Padding<[u64; 13]>,
234 #[cfg(target_pointer_width = "32")]
235 __pad2: Padding<[u64; 14]>,
236 }
237
238 pub struct pthread_attr_t {
239 pta_magic: c_uint,
240 pta_flags: c_int,
241 pta_private: *mut c_void,
242 }
243
244 pub struct pthread_mutex_t {
245 ptm_magic: c_uint,
246 ptm_errorcheck: __pthread_spin_t,
247 #[cfg(any(
248 target_arch = "sparc",
249 target_arch = "sparc64",
250 target_arch = "x86",
251 target_arch = "x86_64"
252 ))]
253 ptm_pad1: Padding<[u8; 3]>,
254 // actually a union with a non-unused, 0-initialized field
255 ptm_unused: Padding<__pthread_spin_t>,
256 #[cfg(any(
257 target_arch = "sparc",
258 target_arch = "sparc64",
259 target_arch = "x86",
260 target_arch = "x86_64"
261 ))]
262 ptm_pad2: Padding<[u8; 3]>,
263 ptm_owner: crate::pthread_t,
264 ptm_waiters: *mut u8,
265 ptm_recursed: c_uint,
266 ptm_spare2: *mut c_void,
267 }
268
269 pub struct pthread_mutexattr_t {
270 ptma_magic: c_uint,
271 ptma_private: *mut c_void,
272 }
273
274 pub struct pthread_rwlockattr_t {
275 ptra_magic: c_uint,
276 ptra_private: *mut c_void,
277 }
278
279 pub struct pthread_cond_t {
280 ptc_magic: c_uint,
281 ptc_lock: __pthread_spin_t,
282 ptc_waiters_first: *mut u8,
283 ptc_waiters_last: *mut u8,
284 ptc_mutex: *mut crate::pthread_mutex_t,
285 ptc_private: *mut c_void,
286 }
287
288 pub struct pthread_condattr_t {
289 ptca_magic: c_uint,
290 ptca_private: *mut c_void,
291 }
292
293 pub struct pthread_rwlock_t {
294 ptr_magic: c_uint,
295 ptr_interlock: __pthread_spin_t,
296 ptr_rblocked_first: *mut u8,
297 ptr_rblocked_last: *mut u8,
298 ptr_wblocked_first: *mut u8,
299 ptr_wblocked_last: *mut u8,
300 ptr_nreaders: c_uint,
301 ptr_owner: crate::pthread_t,
302 ptr_private: *mut c_void,
303 }
304
305 pub struct pthread_spinlock_t {
306 pts_magic: c_uint,
307 pts_spin: crate::pthread_spin_t,
308 pts_flags: c_int,
309 }
310
311 pub struct kevent {
312 pub ident: crate::uintptr_t,
313 pub filter: u32,
314 pub flags: u32,
315 pub fflags: u32,
316 pub data: i64,
317 pub udata: *mut c_void,
318 }
319
320 pub struct dqblk {
321 pub dqb_bhardlimit: u32,
322 pub dqb_bsoftlimit: u32,
323 pub dqb_curblocks: u32,
324 pub dqb_ihardlimit: u32,
325 pub dqb_isoftlimit: u32,
326 pub dqb_curinodes: u32,
327 pub dqb_btime: i32,
328 pub dqb_itime: i32,
329 }
330
331 pub struct Dl_info {
332 pub dli_fname: *const c_char,
333 pub dli_fbase: *mut c_void,
334 pub dli_sname: *const c_char,
335 pub dli_saddr: *const c_void,
336 }
337
338 pub struct lconv {
339 pub decimal_point: *mut c_char,
340 pub thousands_sep: *mut c_char,
341 pub grouping: *mut c_char,
342 pub int_curr_symbol: *mut c_char,
343 pub currency_symbol: *mut c_char,
344 pub mon_decimal_point: *mut c_char,
345 pub mon_thousands_sep: *mut c_char,
346 pub mon_grouping: *mut c_char,
347 pub positive_sign: *mut c_char,
348 pub negative_sign: *mut c_char,
349 pub int_frac_digits: c_char,
350 pub frac_digits: c_char,
351 pub p_cs_precedes: c_char,
352 pub p_sep_by_space: c_char,
353 pub n_cs_precedes: c_char,
354 pub n_sep_by_space: c_char,
355 pub p_sign_posn: c_char,
356 pub n_sign_posn: c_char,
357 pub int_p_cs_precedes: c_char,
358 pub int_n_cs_precedes: c_char,
359 pub int_p_sep_by_space: c_char,
360 pub int_n_sep_by_space: c_char,
361 pub int_p_sign_posn: c_char,
362 pub int_n_sign_posn: c_char,
363 }
364
365 pub struct sockcred {
366 pub sc_pid: crate::pid_t,
367 pub sc_uid: crate::uid_t,
368 pub sc_euid: crate::uid_t,
369 pub sc_gid: crate::gid_t,
370 pub sc_egid: crate::gid_t,
371 pub sc_ngroups: c_int,
372 pub sc_groups: [crate::gid_t; 1],
373 }
374
375 pub struct uucred {
376 cr_unused: Padding<c_ushort>,
377 pub cr_uid: crate::uid_t,
378 pub cr_gid: crate::gid_t,
379 pub cr_ngroups: c_short,
380 pub cr_groups: [crate::gid_t; NGROUPS_MAX as usize],
381 }
382
383 pub struct unpcbid {
384 pub unp_pid: crate::pid_t,
385 pub unp_euid: crate::uid_t,
386 pub unp_egid: crate::gid_t,
387 }
388
389 pub struct sockaddr_dl {
390 pub sdl_len: c_uchar,
391 pub sdl_family: c_uchar,
392 pub sdl_index: c_ushort,
393 pub sdl_type: u8,
394 pub sdl_nlen: u8,
395 pub sdl_alen: u8,
396 pub sdl_slen: u8,
397 pub sdl_data: [c_char; 24],
398 }
399
400 pub struct shmid_ds {
401 pub shm_perm: crate::ipc_perm,
402 pub shm_segsz: size_t,
403 pub shm_lpid: crate::pid_t,
404 pub shm_cpid: crate::pid_t,
405 pub shm_nattch: crate::shmatt_t,
406 pub shm_atime: crate::time_t,
407 pub shm_dtime: crate::time_t,
408 pub shm_ctime: crate::time_t,
409 _shm_internal: *mut c_void,
410 }
411
412 // elf.h
413
414 pub struct Elf32_Phdr {
415 pub p_type: Elf32_Word,
416 pub p_offset: Elf32_Off,
417 pub p_vaddr: Elf32_Addr,
418 pub p_paddr: Elf32_Addr,
419 pub p_filesz: Elf32_Word,
420 pub p_memsz: Elf32_Word,
421 pub p_flags: Elf32_Word,
422 pub p_align: Elf32_Word,
423 }
424
425 pub struct Elf64_Phdr {
426 pub p_type: Elf64_Word,
427 pub p_flags: Elf64_Word,
428 pub p_offset: Elf64_Off,
429 pub p_vaddr: Elf64_Addr,
430 pub p_paddr: Elf64_Addr,
431 pub p_filesz: Elf64_Xword,
432 pub p_memsz: Elf64_Xword,
433 pub p_align: Elf64_Xword,
434 }
435
436 pub struct Aux32Info {
437 pub a_type: Elf32_Word,
438 pub a_v: Elf32_Word,
439 }
440
441 pub struct Aux64Info {
442 pub a_type: Elf64_Word,
443 pub a_v: Elf64_Xword,
444 }
445
446 // link.h
447
448 pub struct dl_phdr_info {
449 pub dlpi_addr: Elf_Addr,
450 pub dlpi_name: *const c_char,
451 pub dlpi_phdr: *const Elf_Phdr,
452 pub dlpi_phnum: Elf_Half,
453 pub dlpi_adds: c_ulonglong,
454 pub dlpi_subs: c_ulonglong,
455 pub dlpi_tls_modid: usize,
456 pub dlpi_tls_data: *mut c_void,
457 }
458
459 pub struct accept_filter_arg {
460 pub af_name: [c_char; 16],
461 af_arg: [c_char; 256 - 16],
462 }
463
464 pub struct ki_sigset_t {
465 pub __bits: [u32; 4],
466 }
467
468 pub struct kinfo_proc2 {
469 pub p_forw: u64,
470 pub p_back: u64,
471 pub p_paddr: u64,
472 pub p_addr: u64,
473 pub p_fd: u64,
474 pub p_cwdi: u64,
475 pub p_stats: u64,
476 pub p_limit: u64,
477 pub p_vmspace: u64,
478 pub p_sigacts: u64,
479 pub p_sess: u64,
480 pub p_tsess: u64,
481 pub p_ru: u64,
482 pub p_eflag: i32,
483 pub p_exitsig: i32,
484 pub p_flag: i32,
485 pub p_pid: i32,
486 pub p_ppid: i32,
487 pub p_sid: i32,
488 pub p__pgid: i32,
489 pub p_tpgid: i32,
490 pub p_uid: u32,
491 pub p_ruid: u32,
492 pub p_gid: u32,
493 pub p_rgid: u32,
494 pub p_groups: [u32; KI_NGROUPS as usize],
495 pub p_ngroups: i16,
496 pub p_jobc: i16,
497 pub p_tdev: u32,
498 pub p_estcpu: u32,
499 pub p_rtime_sec: u32,
500 pub p_rtime_usec: u32,
501 pub p_cpticks: i32,
502 pub p_pctcpu: u32,
503 pub p_swtime: u32,
504 pub p_slptime: u32,
505 pub p_schedflags: i32,
506 pub p_uticks: u64,
507 pub p_sticks: u64,
508 pub p_iticks: u64,
509 pub p_tracep: u64,
510 pub p_traceflag: i32,
511 pub p_holdcnt: i32,
512 pub p_siglist: ki_sigset_t,
513 pub p_sigmask: ki_sigset_t,
514 pub p_sigignore: ki_sigset_t,
515 pub p_sigcatch: ki_sigset_t,
516 pub p_stat: i8,
517 pub p_priority: u8,
518 pub p_usrpri: u8,
519 pub p_nice: u8,
520 pub p_xstat: u16,
521 pub p_acflag: u16,
522 pub p_comm: [c_char; KI_MAXCOMLEN as usize],
523 pub p_wmesg: [c_char; KI_WMESGLEN as usize],
524 pub p_wchan: u64,
525 pub p_login: [c_char; KI_MAXLOGNAME as usize],
526 pub p_vm_rssize: i32,
527 pub p_vm_tsize: i32,
528 pub p_vm_dsize: i32,
529 pub p_vm_ssize: i32,
530 pub p_uvalid: i64,
531 pub p_ustart_sec: u32,
532 pub p_ustart_usec: u32,
533 pub p_uutime_sec: u32,
534 pub p_uutime_usec: u32,
535 pub p_ustime_sec: u32,
536 pub p_ustime_usec: u32,
537 pub p_uru_maxrss: u64,
538 pub p_uru_ixrss: u64,
539 pub p_uru_idrss: u64,
540 pub p_uru_isrss: u64,
541 pub p_uru_minflt: u64,
542 pub p_uru_majflt: u64,
543 pub p_uru_nswap: u64,
544 pub p_uru_inblock: u64,
545 pub p_uru_oublock: u64,
546 pub p_uru_msgsnd: u64,
547 pub p_uru_msgrcv: u64,
548 pub p_uru_nsignals: u64,
549 pub p_uru_nvcsw: u64,
550 pub p_uru_nivcsw: u64,
551 pub p_uctime_sec: u32,
552 pub p_uctime_usec: u32,
553 pub p_cpuid: u64,
554 pub p_realflag: u64,
555 pub p_nlwps: u64,
556 pub p_nrlwps: u64,
557 pub p_realstat: u64,
558 pub p_svuid: u32,
559 pub p_svgid: u32,
560 pub p_ename: [c_char; KI_MAXEMULLEN as usize],
561 pub p_vm_vsize: i64,
562 pub p_vm_msize: i64,
563 }
564
565 pub struct kinfo_lwp {
566 pub l_forw: u64,
567 pub l_back: u64,
568 pub l_laddr: u64,
569 pub l_addr: u64,
570 pub l_lid: i32,
571 pub l_flag: i32,
572 pub l_swtime: u32,
573 pub l_slptime: u32,
574 pub l_schedflags: i32,
575 pub l_holdcnt: i32,
576 pub l_priority: u8,
577 pub l_usrpri: u8,
578 pub l_stat: i8,
579 l_pad1: Padding<i8>,
580 l_pad2: Padding<i32>,
581 pub l_wmesg: [c_char; KI_WMESGLEN as usize],
582 pub l_wchan: u64,
583 pub l_cpuid: u64,
584 pub l_rtime_sec: u32,
585 pub l_rtime_usec: u32,
586 pub l_cpticks: u32,
587 pub l_pctcpu: u32,
588 pub l_pid: u32,
589 pub l_name: [c_char; KI_LNAMELEN as usize],
590 }
591
592 pub struct kinfo_vmentry {
593 pub kve_start: u64,
594 pub kve_end: u64,
595 pub kve_offset: u64,
596 pub kve_type: u32,
597 pub kve_flags: u32,
598 pub kve_count: u32,
599 pub kve_wired_count: u32,
600 pub kve_advice: u32,
601 pub kve_attributes: u32,
602 pub kve_protection: u32,
603 pub kve_max_protection: u32,
604 pub kve_ref_count: u32,
605 pub kve_inheritance: u32,
606 pub kve_vn_fileid: u64,
607 pub kve_vn_size: u64,
608 pub kve_vn_fsid: u64,
609 pub kve_vn_rdev: u64,
610 pub kve_vn_type: u32,
611 pub kve_vn_mode: u32,
612 pub kve_path: [c_char; crate::PATH_MAX as usize],
613 }
614
615 pub struct __c_anonymous_posix_spawn_fae_open {
616 pub path: *mut c_char,
617 pub oflag: c_int,
618 pub mode: crate::mode_t,
619 }
620
621 pub struct __c_anonymous_posix_spawn_fae_dup2 {
622 pub newfildes: c_int,
623 }
624
625 pub struct posix_spawnattr_t {
626 pub sa_flags: c_short,
627 pub sa_pgroup: crate::pid_t,
628 pub sa_schedparam: crate::sched_param,
629 pub sa_schedpolicy: c_int,
630 pub sa_sigdefault: sigset_t,
631 pub sa_sigmask: sigset_t,
632 }
633
634 pub struct posix_spawn_file_actions_entry_t {
635 pub fae_action: fae_action,
636 pub fae_fildes: c_int,
637 pub fae_data: __c_anonymous_posix_spawn_fae,
638 }
639
640 pub struct posix_spawn_file_actions_t {
641 pub size: c_uint,
642 pub len: c_uint,
643 pub fae: *mut posix_spawn_file_actions_entry_t,
644 }
645
646 #[deprecated(since = "0.2.178", note = "obsolete upstream")]
647 pub struct ptrace_lwpinfo {
648 pub pl_lwpid: lwpid_t,
649 pub pl_event: c_int,
650 }
651
652 pub struct ptrace_lwpstatus {
653 pub pl_lwpid: lwpid_t,
654 pub pl_sigpend: sigset_t,
655 pub pl_sigmask: sigset_t,
656 pub pl_name: [c_char; 20],
657 pub pl_private: *mut c_void,
658 }
659
660 pub struct ptrace_siginfo {
661 pub psi_siginfo: siginfo_t,
662 pub psi_lwpid: lwpid_t,
663 }
664
665 pub struct ptrace_event {
666 pub pe_set_event: c_int,
667 }
668
669 pub struct sysctldesc {
670 pub descr_num: i32,
671 pub descr_ver: u32,
672 pub descr_len: u32,
673 pub descr_str: [c_char; 1],
674 }
675
676 pub struct tcp_info {
677 pub tcpi_state: u8,
678 pub __tcpi_ca_state: u8,
679 pub __tcpi_retransmits: u8,
680 pub __tcpi_probes: u8,
681 pub __tcpi_backoff: u8,
682 pub tcpi_options: u8,
683 pub tcp_snd_wscale: u8,
684 pub tcp_rcv_wscale: u8,
685 pub tcpi_rto: u32,
686 pub __tcpi_ato: u32,
687 pub tcpi_snd_mss: u32,
688 pub tcpi_rcv_mss: u32,
689 pub __tcpi_unacked: u32,
690 pub __tcpi_sacked: u32,
691 pub __tcpi_lost: u32,
692 pub __tcpi_retrans: u32,
693 pub __tcpi_fackets: u32,
694 pub __tcpi_last_data_sent: u32,
695 pub __tcpi_last_ack_sent: u32,
696 pub tcpi_last_data_recv: u32,
697 pub __tcpi_last_ack_recv: u32,
698 pub __tcpi_pmtu: u32,
699 pub __tcpi_rcv_ssthresh: u32,
700 pub tcpi_rtt: u32,
701 pub tcpi_rttvar: u32,
702 pub tcpi_snd_ssthresh: u32,
703 pub tcpi_snd_cwnd: u32,
704 pub __tcpi_advmss: u32,
705 pub __tcpi_reordering: u32,
706 pub __tcpi_rcv_rtt: u32,
707 pub tcpi_rcv_space: u32,
708 pub tcpi_snd_wnd: u32,
709 pub tcpi_snd_bwnd: u32,
710 pub tcpi_snd_nxt: u32,
711 pub tcpi_rcv_nxt: u32,
712 pub tcpi_toe_tid: u32,
713 pub tcpi_snd_rexmitpack: u32,
714 pub tcpi_rcv_ooopack: u32,
715 pub tcpi_snd_zerowin: u32,
716 pub __tcpi_pad: [u32; 26],
717 }
718
719 pub struct in_pktinfo {
720 pub ipi_addr: crate::in_addr,
721 pub ipi_ifindex: c_uint,
722 }
723
724 pub struct arphdr {
725 pub ar_hrd: u16,
726 pub ar_pro: u16,
727 pub ar_hln: u8,
728 pub ar_pln: u8,
729 pub ar_op: u16,
730 }
731
732 pub struct in_addr {
733 pub s_addr: crate::in_addr_t,
734 }
735
736 pub struct ip_mreq {
737 pub imr_multiaddr: in_addr,
738 pub imr_interface: in_addr,
739 }
740
741 pub struct sockaddr_in {
742 pub sin_len: u8,
743 pub sin_family: crate::sa_family_t,
744 pub sin_port: crate::in_port_t,
745 pub sin_addr: crate::in_addr,
746 pub sin_zero: [i8; 8],
747 }
748
749 pub struct dirent {
750 pub d_fileno: crate::ino_t,
751 pub d_reclen: u16,
752 pub d_namlen: u16,
753 pub d_type: u8,
754 pub d_name: [c_char; 512],
755 }
756
757 pub struct sockaddr_storage {
758 pub ss_len: u8,
759 pub ss_family: crate::sa_family_t,
760 __ss_pad1: Padding<[u8; 6]>,
761 __ss_pad2: Padding<i64>,
762 __ss_pad3: Padding<[u8; 112]>,
763 }
764
765 pub struct sigevent {
766 pub sigev_notify: c_int,
767 pub sigev_signo: c_int,
768 pub sigev_value: crate::sigval,
769 __unused1: Padding<*mut c_void>, //actually a function pointer
770 pub sigev_notify_attributes: *mut c_void,
771 }
772 }
773
774 s_no_extra_traits! {
775 pub union __c_anonymous_posix_spawn_fae {
776 pub open: __c_anonymous_posix_spawn_fae_open,
777 pub dup2: __c_anonymous_posix_spawn_fae_dup2,
778 }
779 }
780
781 cfg_if! {
782 if #[cfg(feature = "extra_traits")] {
783 impl Eq for __c_anonymous_posix_spawn_fae {}
784 impl PartialEq for __c_anonymous_posix_spawn_fae {
785 fn eq(&self, other: &__c_anonymous_posix_spawn_fae) -> bool {
786 unsafe { self.open == other.open || self.dup2 == other.dup2 }
787 }
788 }
789 impl hash::Hash for __c_anonymous_posix_spawn_fae {
790 fn hash<H: hash::Hasher>(&self, state: &mut H) {
791 unsafe {
792 self.open.hash(state);
793 self.dup2.hash(state);
794 }
795 }
796 }
797 }
798 }
799
800 pub const AT_FDCWD: c_int = -100;
801 pub const AT_EACCESS: c_int = 0x100;
802 pub const AT_SYMLINK_NOFOLLOW: c_int = 0x200;
803 pub const AT_SYMLINK_FOLLOW: c_int = 0x400;
804 pub const AT_REMOVEDIR: c_int = 0x800;
805
806 pub const AT_NULL: c_int = 0;
807 pub const AT_IGNORE: c_int = 1;
808 pub const AT_EXECFD: c_int = 2;
809 pub const AT_PHDR: c_int = 3;
810 pub const AT_PHENT: c_int = 4;
811 pub const AT_PHNUM: c_int = 5;
812 pub const AT_PAGESZ: c_int = 6;
813 pub const AT_BASE: c_int = 7;
814 pub const AT_FLAGS: c_int = 8;
815 pub const AT_ENTRY: c_int = 9;
816 pub const AT_DCACHEBSIZE: c_int = 10;
817 pub const AT_ICACHEBSIZE: c_int = 11;
818 pub const AT_UCACHEBSIZE: c_int = 12;
819 pub const AT_STACKBASE: c_int = 13;
820 pub const AT_EUID: c_int = 2000;
821 pub const AT_RUID: c_int = 2001;
822 pub const AT_EGID: c_int = 2002;
823 pub const AT_RGID: c_int = 2003;
824 pub const AT_SUN_LDELF: c_int = 2004;
825 pub const AT_SUN_LDSHDR: c_int = 2005;
826 pub const AT_SUN_LDNAME: c_int = 2006;
827 pub const AT_SUN_PLATFORM: c_int = 2008;
828 pub const AT_SUN_HWCAP: c_int = 2009;
829 pub const AT_SUN_IFLUSH: c_int = 2010;
830 pub const AT_SUN_CPU: c_int = 2011;
831 pub const AT_SUN_EMUL_ENTRY: c_int = 2012;
832 pub const AT_SUN_EMUL_EXECFD: c_int = 2013;
833 pub const AT_SUN_EXECNAME: c_int = 2014;
834
835 pub const EXTATTR_NAMESPACE_USER: c_int = 1;
836 pub const EXTATTR_NAMESPACE_SYSTEM: c_int = 2;
837
838 pub const LC_COLLATE_MASK: c_int = 1 << crate::LC_COLLATE;
839 pub const LC_CTYPE_MASK: c_int = 1 << crate::LC_CTYPE;
840 pub const LC_MONETARY_MASK: c_int = 1 << crate::LC_MONETARY;
841 pub const LC_NUMERIC_MASK: c_int = 1 << crate::LC_NUMERIC;
842 pub const LC_TIME_MASK: c_int = 1 << crate::LC_TIME;
843 pub const LC_MESSAGES_MASK: c_int = 1 << crate::LC_MESSAGES;
844 pub const LC_ALL_MASK: c_int = !0;
845
846 pub const ERA: crate::nl_item = 52;
847 pub const ERA_D_FMT: crate::nl_item = 53;
848 pub const ERA_D_T_FMT: crate::nl_item = 54;
849 pub const ERA_T_FMT: crate::nl_item = 55;
850 pub const ALT_DIGITS: crate::nl_item = 56;
851
852 pub const O_CLOEXEC: c_int = 0x400000;
853 pub const O_ALT_IO: c_int = 0x40000;
854 pub const O_NOSIGPIPE: c_int = 0x1000000;
855 pub const O_SEARCH: c_int = 0x800000;
856 pub const O_DIRECTORY: c_int = 0x200000;
857 pub const O_DIRECT: c_int = 0x00080000;
858 pub const O_RSYNC: c_int = 0x00020000;
859
860 pub const MS_SYNC: c_int = 0x4;
861 pub const MS_INVALIDATE: c_int = 0x2;
862
863 // Here because they are not present on OpenBSD
864 // (https://github.com/openbsd/src/blob/HEAD/sys/sys/resource.h)
865 pub const RLIMIT_SBSIZE: c_int = 9;
866 pub const RLIMIT_AS: c_int = 10;
867 pub const RLIMIT_NTHR: c_int = 11;
868
869 #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
870 pub const RLIM_NLIMITS: c_int = 12;
871
872 pub const EIDRM: c_int = 82;
873 pub const ENOMSG: c_int = 83;
874 pub const EOVERFLOW: c_int = 84;
875 pub const EILSEQ: c_int = 85;
876 pub const ENOTSUP: c_int = 86;
877 pub const ECANCELED: c_int = 87;
878 pub const EBADMSG: c_int = 88;
879 pub const ENODATA: c_int = 89;
880 pub const ENOSR: c_int = 90;
881 pub const ENOSTR: c_int = 91;
882 pub const ETIME: c_int = 92;
883 pub const ENOATTR: c_int = 93;
884 pub const EMULTIHOP: c_int = 94;
885 pub const ENOLINK: c_int = 95;
886 pub const EPROTO: c_int = 96;
887 pub const EOWNERDEAD: c_int = 97;
888 pub const ENOTRECOVERABLE: c_int = 98;
889 #[deprecated(
890 since = "0.2.143",
891 note = "This value will always match the highest defined error number \
892 and thus is not stable. \
893 See #3040 for more info."
894 )]
895 pub const ELAST: c_int = 98;
896
897 pub const F_DUPFD_CLOEXEC: c_int = 12;
898 pub const F_CLOSEM: c_int = 10;
899 pub const F_GETNOSIGPIPE: c_int = 13;
900 pub const F_SETNOSIGPIPE: c_int = 14;
901 pub const F_MAXFD: c_int = 11;
902 pub const F_GETPATH: c_int = 15;
903
904 pub const FUTEX_WAIT: c_int = 0;
905 pub const FUTEX_WAKE: c_int = 1;
906 pub const FUTEX_FD: c_int = 2;
907 pub const FUTEX_REQUEUE: c_int = 3;
908 pub const FUTEX_CMP_REQUEUE: c_int = 4;
909 pub const FUTEX_WAKE_OP: c_int = 5;
910 pub const FUTEX_LOCK_PI: c_int = 6;
911 pub const FUTEX_UNLOCK_PI: c_int = 7;
912 pub const FUTEX_TRYLOCK_PI: c_int = 8;
913 pub const FUTEX_WAIT_BITSET: c_int = 9;
914 pub const FUTEX_WAKE_BITSET: c_int = 10;
915 pub const FUTEX_WAIT_REQUEUE_PI: c_int = 11;
916 pub const FUTEX_CMP_REQUEUE_PI: c_int = 12;
917 pub const FUTEX_PRIVATE_FLAG: c_int = 1 << 7;
918 pub const FUTEX_CLOCK_REALTIME: c_int = 1 << 8;
919 pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME);
920 pub const FUTEX_WAITERS: u32 = 1 << 31;
921 pub const FUTEX_OWNER_DIED: u32 = 1 << 30;
922 pub const FUTEX_SYNCOBJ_1: u32 = 1 << 29;
923 pub const FUTEX_SYNCOBJ_0: u32 = 1 << 28;
924 pub const FUTEX_TID_MASK: u32 = (1 << 28) - 1;
925 pub const FUTEX_BITSET_MATCH_ANY: u32 = !0;
926
927 pub const IP_RECVDSTADDR: c_int = 7;
928 pub const IP_SENDSRCADDR: c_int = IP_RECVDSTADDR;
929 pub const IP_RECVIF: c_int = 20;
930 pub const IP_PKTINFO: c_int = 25;
931 pub const IP_RECVPKTINFO: c_int = 26;
932 pub const IPV6_JOIN_GROUP: c_int = 12;
933 pub const IPV6_LEAVE_GROUP: c_int = 13;
934
935 pub const TCP_KEEPIDLE: c_int = 3;
936 pub const TCP_KEEPINTVL: c_int = 5;
937 pub const TCP_KEEPCNT: c_int = 6;
938 pub const TCP_KEEPINIT: c_int = 7;
939 pub const TCP_MD5SIG: c_int = 0x10;
940 pub const TCP_CONGCTL: c_int = 0x20;
941
942 pub const SOCK_CONN_DGRAM: c_int = 6;
943 pub const SOCK_DCCP: c_int = SOCK_CONN_DGRAM;
944 pub const SOCK_NOSIGPIPE: c_int = 0x40000000;
945 pub const SOCK_FLAGS_MASK: c_int = 0xf0000000;
946
947 pub const SO_SNDTIMEO: c_int = 0x100b;
948 pub const SO_RCVTIMEO: c_int = 0x100c;
949 pub const SO_NOSIGPIPE: c_int = 0x0800;
950 pub const SO_ACCEPTFILTER: c_int = 0x1000;
951 pub const SO_TIMESTAMP: c_int = 0x2000;
952 pub const SO_OVERFLOWED: c_int = 0x1009;
953 pub const SO_NOHEADER: c_int = 0x100a;
954
955 // http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/un.h?annotate
956 pub const LOCAL_OCREDS: c_int = 0x0001; // pass credentials to receiver
957 pub const LOCAL_CONNWAIT: c_int = 0x0002; // connects block until accepted
958 pub const LOCAL_PEEREID: c_int = 0x0003; // get peer identification
959 pub const LOCAL_CREDS: c_int = 0x0004; // pass credentials to receiver
960
961 // https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373
962
963 // sys/netinet/in.h
964 // Protocols (RFC 1700)
965 // NOTE: These are in addition to the constants defined in src/unix/mod.rs
966
967 // IPPROTO_IP defined in src/unix/mod.rs
968 /// Hop-by-hop option header
969 pub const IPPROTO_HOPOPTS: c_int = 0;
970 // IPPROTO_ICMP defined in src/unix/mod.rs
971 /// group mgmt protocol
972 pub const IPPROTO_IGMP: c_int = 2;
973 /// gateway^2 (deprecated)
974 pub const IPPROTO_GGP: c_int = 3;
975 /// for compatibility
976 pub const IPPROTO_IPIP: c_int = 4;
977 // IPPROTO_TCP defined in src/unix/mod.rs
978 /// exterior gateway protocol
979 pub const IPPROTO_EGP: c_int = 8;
980 /// pup
981 pub const IPPROTO_PUP: c_int = 12;
982 // IPPROTO_UDP defined in src/unix/mod.rs
983 /// xns idp
984 pub const IPPROTO_IDP: c_int = 22;
985 /// tp-4 w/ class negotiation
986 pub const IPPROTO_TP: c_int = 29;
987 /// DCCP
988 pub const IPPROTO_DCCP: c_int = 33;
989 // IPPROTO_IPV6 defined in src/unix/mod.rs
990 /// IP6 routing header
991 pub const IPPROTO_ROUTING: c_int = 43;
992 /// IP6 fragmentation header
993 pub const IPPROTO_FRAGMENT: c_int = 44;
994 /// resource reservation
995 pub const IPPROTO_RSVP: c_int = 46;
996 /// General Routing Encap.
997 pub const IPPROTO_GRE: c_int = 47;
998 /// IP6 Encap Sec. Payload
999 pub const IPPROTO_ESP: c_int = 50;
1000 /// IP6 Auth Header
1001 pub const IPPROTO_AH: c_int = 51;
1002 /// IP Mobility RFC 2004
1003 pub const IPPROTO_MOBILE: c_int = 55;
1004 /// IPv6 ICMP
1005 pub const IPPROTO_IPV6_ICMP: c_int = 58;
1006 // IPPROTO_ICMPV6 defined in src/unix/mod.rs
1007 /// IP6 no next header
1008 pub const IPPROTO_NONE: c_int = 59;
1009 /// IP6 destination option
1010 pub const IPPROTO_DSTOPTS: c_int = 60;
1011 /// ISO cnlp
1012 pub const IPPROTO_EON: c_int = 80;
1013 /// Ethernet-in-IP
1014 pub const IPPROTO_ETHERIP: c_int = 97;
1015 /// encapsulation header
1016 pub const IPPROTO_ENCAP: c_int = 98;
1017 /// Protocol indep. multicast
1018 pub const IPPROTO_PIM: c_int = 103;
1019 /// IP Payload Comp. Protocol
1020 pub const IPPROTO_IPCOMP: c_int = 108;
1021 /// VRRP RFC 2338
1022 pub const IPPROTO_VRRP: c_int = 112;
1023 /// Common Address Resolution Protocol
1024 pub const IPPROTO_CARP: c_int = 112;
1025 /// L2TPv3
1026 pub const IPPROTO_L2TP: c_int = 115;
1027 /// SCTP
1028 pub const IPPROTO_SCTP: c_int = 132;
1029 /// PFSYNC
1030 pub const IPPROTO_PFSYNC: c_int = 240;
1031 pub const IPPROTO_MAX: c_int = 256;
1032
1033 /// last return value of *_input(), meaning "all job for this pkt is done".
1034 pub const IPPROTO_DONE: c_int = 257;
1035
1036 /// sysctl placeholder for (FAST_)IPSEC
1037 pub const CTL_IPPROTO_IPSEC: c_int = 258;
1038
1039 pub const AF_OROUTE: c_int = 17;
1040 pub const AF_ARP: c_int = 28;
1041 pub const pseudo_AF_KEY: c_int = 29;
1042 pub const pseudo_AF_HDRCMPLT: c_int = 30;
1043 pub const AF_BLUETOOTH: c_int = 31;
1044 pub const AF_IEEE80211: c_int = 32;
1045 pub const AF_MPLS: c_int = 33;
1046 pub const AF_ROUTE: c_int = 34;
1047 pub const NET_RT_DUMP: c_int = 1;
1048 pub const NET_RT_FLAGS: c_int = 2;
1049 pub const NET_RT_OOOIFLIST: c_int = 3;
1050 pub const NET_RT_OOIFLIST: c_int = 4;
1051 pub const NET_RT_OIFLIST: c_int = 5;
1052 pub const NET_RT_IFLIST: c_int = 6;
1053
1054 pub const PF_OROUTE: c_int = AF_OROUTE;
1055 pub const PF_ARP: c_int = AF_ARP;
1056 pub const PF_KEY: c_int = pseudo_AF_KEY;
1057 pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH;
1058 pub const PF_MPLS: c_int = AF_MPLS;
1059 pub const PF_ROUTE: c_int = AF_ROUTE;
1060
1061 pub const MSG_NBIO: c_int = 0x1000;
1062 pub const MSG_WAITFORONE: c_int = 0x2000;
1063 pub const MSG_NOTIFICATION: c_int = 0x4000;
1064
1065 pub const SCM_TIMESTAMP: c_int = 0x08;
1066 pub const SCM_CREDS: c_int = 0x10;
1067
1068 pub const O_DSYNC: c_int = 0x10000;
1069
1070 pub const MAP_RENAME: c_int = 0x20;
1071 pub const MAP_NORESERVE: c_int = 0x40;
1072 pub const MAP_HASSEMAPHORE: c_int = 0x200;
1073 pub const MAP_TRYFIXED: c_int = 0x400;
1074 pub const MAP_WIRED: c_int = 0x800;
1075 pub const MAP_STACK: c_int = 0x2000;
1076 // map alignment aliases for MAP_ALIGNED
1077 pub const MAP_ALIGNMENT_SHIFT: c_int = 24;
1078 pub const MAP_ALIGNMENT_MASK: c_int = 0xff << MAP_ALIGNMENT_SHIFT;
1079 pub const MAP_ALIGNMENT_64KB: c_int = 16 << MAP_ALIGNMENT_SHIFT;
1080 pub const MAP_ALIGNMENT_16MB: c_int = 24 << MAP_ALIGNMENT_SHIFT;
1081 pub const MAP_ALIGNMENT_4GB: c_int = 32 << MAP_ALIGNMENT_SHIFT;
1082 pub const MAP_ALIGNMENT_1TB: c_int = 40 << MAP_ALIGNMENT_SHIFT;
1083 pub const MAP_ALIGNMENT_256TB: c_int = 48 << MAP_ALIGNMENT_SHIFT;
1084 pub const MAP_ALIGNMENT_64PB: c_int = 56 << MAP_ALIGNMENT_SHIFT;
1085 // mremap flag
1086 pub const MAP_REMAPDUP: c_int = 0x004;
1087
1088 pub const DCCP_TYPE_REQUEST: c_int = 0;
1089 pub const DCCP_TYPE_RESPONSE: c_int = 1;
1090 pub const DCCP_TYPE_DATA: c_int = 2;
1091 pub const DCCP_TYPE_ACK: c_int = 3;
1092 pub const DCCP_TYPE_DATAACK: c_int = 4;
1093 pub const DCCP_TYPE_CLOSEREQ: c_int = 5;
1094 pub const DCCP_TYPE_CLOSE: c_int = 6;
1095 pub const DCCP_TYPE_RESET: c_int = 7;
1096 pub const DCCP_TYPE_MOVE: c_int = 8;
1097
1098 pub const DCCP_FEATURE_CC: c_int = 1;
1099 pub const DCCP_FEATURE_ECN: c_int = 2;
1100 pub const DCCP_FEATURE_ACKRATIO: c_int = 3;
1101 pub const DCCP_FEATURE_ACKVECTOR: c_int = 4;
1102 pub const DCCP_FEATURE_MOBILITY: c_int = 5;
1103 pub const DCCP_FEATURE_LOSSWINDOW: c_int = 6;
1104 pub const DCCP_FEATURE_CONN_NONCE: c_int = 8;
1105 pub const DCCP_FEATURE_IDENTREG: c_int = 7;
1106
1107 pub const DCCP_OPT_PADDING: c_int = 0;
1108 pub const DCCP_OPT_DATA_DISCARD: c_int = 1;
1109 pub const DCCP_OPT_SLOW_RECV: c_int = 2;
1110 pub const DCCP_OPT_BUF_CLOSED: c_int = 3;
1111 pub const DCCP_OPT_CHANGE_L: c_int = 32;
1112 pub const DCCP_OPT_CONFIRM_L: c_int = 33;
1113 pub const DCCP_OPT_CHANGE_R: c_int = 34;
1114 pub const DCCP_OPT_CONFIRM_R: c_int = 35;
1115 pub const DCCP_OPT_INIT_COOKIE: c_int = 36;
1116 pub const DCCP_OPT_NDP_COUNT: c_int = 37;
1117 pub const DCCP_OPT_ACK_VECTOR0: c_int = 38;
1118 pub const DCCP_OPT_ACK_VECTOR1: c_int = 39;
1119 pub const DCCP_OPT_RECV_BUF_DROPS: c_int = 40;
1120 pub const DCCP_OPT_TIMESTAMP: c_int = 41;
1121 pub const DCCP_OPT_TIMESTAMP_ECHO: c_int = 42;
1122 pub const DCCP_OPT_ELAPSEDTIME: c_int = 43;
1123 pub const DCCP_OPT_DATACHECKSUM: c_int = 44;
1124
1125 pub const DCCP_REASON_UNSPEC: c_int = 0;
1126 pub const DCCP_REASON_CLOSED: c_int = 1;
1127 pub const DCCP_REASON_INVALID: c_int = 2;
1128 pub const DCCP_REASON_OPTION_ERR: c_int = 3;
1129 pub const DCCP_REASON_FEA_ERR: c_int = 4;
1130 pub const DCCP_REASON_CONN_REF: c_int = 5;
1131 pub const DCCP_REASON_BAD_SNAME: c_int = 6;
1132 pub const DCCP_REASON_BAD_COOKIE: c_int = 7;
1133 pub const DCCP_REASON_INV_MOVE: c_int = 8;
1134 pub const DCCP_REASON_UNANSW_CH: c_int = 10;
1135 pub const DCCP_REASON_FRUITLESS_NEG: c_int = 11;
1136
1137 pub const DCCP_CCID: c_int = 1;
1138 pub const DCCP_CSLEN: c_int = 2;
1139 pub const DCCP_MAXSEG: c_int = 4;
1140 pub const DCCP_SERVICE: c_int = 8;
1141
1142 pub const DCCP_NDP_LIMIT: c_int = 16;
1143 pub const DCCP_SEQ_NUM_LIMIT: c_int = 16777216;
1144 pub const DCCP_MAX_OPTIONS: c_int = 32;
1145 pub const DCCP_MAX_PKTS: c_int = 100;
1146
1147 pub const _PC_LINK_MAX: c_int = 1;
1148 pub const _PC_MAX_CANON: c_int = 2;
1149 pub const _PC_MAX_INPUT: c_int = 3;
1150 pub const _PC_NAME_MAX: c_int = 4;
1151 pub const _PC_PATH_MAX: c_int = 5;
1152 pub const _PC_PIPE_BUF: c_int = 6;
1153 pub const _PC_CHOWN_RESTRICTED: c_int = 7;
1154 pub const _PC_NO_TRUNC: c_int = 8;
1155 pub const _PC_VDISABLE: c_int = 9;
1156 pub const _PC_SYNC_IO: c_int = 10;
1157 pub const _PC_FILESIZEBITS: c_int = 11;
1158 pub const _PC_SYMLINK_MAX: c_int = 12;
1159 pub const _PC_2_SYMLINKS: c_int = 13;
1160 pub const _PC_ACL_EXTENDED: c_int = 14;
1161 pub const _PC_MIN_HOLE_SIZE: c_int = 15;
1162
1163 pub const _CS_PATH: c_int = 1;
1164
1165 pub const _SC_SYNCHRONIZED_IO: c_int = 31;
1166 pub const _SC_IOV_MAX: c_int = 32;
1167 pub const _SC_MAPPED_FILES: c_int = 33;
1168 pub const _SC_MEMLOCK: c_int = 34;
1169 pub const _SC_MEMLOCK_RANGE: c_int = 35;
1170 pub const _SC_MEMORY_PROTECTION: c_int = 36;
1171 pub const _SC_LOGIN_NAME_MAX: c_int = 37;
1172 pub const _SC_MONOTONIC_CLOCK: c_int = 38;
1173 pub const _SC_CLK_TCK: c_int = 39;
1174 pub const _SC_ATEXIT_MAX: c_int = 40;
1175 pub const _SC_THREADS: c_int = 41;
1176 pub const _SC_SEMAPHORES: c_int = 42;
1177 pub const _SC_BARRIERS: c_int = 43;
1178 pub const _SC_TIMERS: c_int = 44;
1179 pub const _SC_SPIN_LOCKS: c_int = 45;
1180 pub const _SC_READER_WRITER_LOCKS: c_int = 46;
1181 pub const _SC_GETGR_R_SIZE_MAX: c_int = 47;
1182 pub const _SC_GETPW_R_SIZE_MAX: c_int = 48;
1183 pub const _SC_CLOCK_SELECTION: c_int = 49;
1184 pub const _SC_ASYNCHRONOUS_IO: c_int = 50;
1185 pub const _SC_AIO_LISTIO_MAX: c_int = 51;
1186 pub const _SC_AIO_MAX: c_int = 52;
1187 pub const _SC_MESSAGE_PASSING: c_int = 53;
1188 pub const _SC_MQ_OPEN_MAX: c_int = 54;
1189 pub const _SC_MQ_PRIO_MAX: c_int = 55;
1190 pub const _SC_PRIORITY_SCHEDULING: c_int = 56;
1191 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 57;
1192 pub const _SC_THREAD_KEYS_MAX: c_int = 58;
1193 pub const _SC_THREAD_STACK_MIN: c_int = 59;
1194 pub const _SC_THREAD_THREADS_MAX: c_int = 60;
1195 pub const _SC_THREAD_ATTR_STACKADDR: c_int = 61;
1196 pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 62;
1197 pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 63;
1198 pub const _SC_THREAD_PRIO_INHERIT: c_int = 64;
1199 pub const _SC_THREAD_PRIO_PROTECT: c_int = 65;
1200 pub const _SC_THREAD_PROCESS_SHARED: c_int = 66;
1201 pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 67;
1202 pub const _SC_TTY_NAME_MAX: c_int = 68;
1203 pub const _SC_HOST_NAME_MAX: c_int = 69;
1204 pub const _SC_PASS_MAX: c_int = 70;
1205 pub const _SC_REGEXP: c_int = 71;
1206 pub const _SC_SHELL: c_int = 72;
1207 pub const _SC_SYMLOOP_MAX: c_int = 73;
1208 pub const _SC_V6_ILP32_OFF32: c_int = 74;
1209 pub const _SC_V6_ILP32_OFFBIG: c_int = 75;
1210 pub const _SC_V6_LP64_OFF64: c_int = 76;
1211 pub const _SC_V6_LPBIG_OFFBIG: c_int = 77;
1212 pub const _SC_2_PBS: c_int = 80;
1213 pub const _SC_2_PBS_ACCOUNTING: c_int = 81;
1214 pub const _SC_2_PBS_CHECKPOINT: c_int = 82;
1215 pub const _SC_2_PBS_LOCATE: c_int = 83;
1216 pub const _SC_2_PBS_MESSAGE: c_int = 84;
1217 pub const _SC_2_PBS_TRACK: c_int = 85;
1218 pub const _SC_SPAWN: c_int = 86;
1219 pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 87;
1220 pub const _SC_TIMER_MAX: c_int = 88;
1221 pub const _SC_SEM_NSEMS_MAX: c_int = 89;
1222 pub const _SC_CPUTIME: c_int = 90;
1223 pub const _SC_THREAD_CPUTIME: c_int = 91;
1224 pub const _SC_DELAYTIMER_MAX: c_int = 92;
1225 // These two variables will be supported in NetBSD 8.0
1226 // pub const _SC_SIGQUEUE_MAX : c_int = 93;
1227 // pub const _SC_REALTIME_SIGNALS : c_int = 94;
1228 pub const _SC_PHYS_PAGES: c_int = 121;
1229 pub const _SC_NPROCESSORS_CONF: c_int = 1001;
1230 pub const _SC_NPROCESSORS_ONLN: c_int = 1002;
1231 pub const _SC_SCHED_RT_TS: c_int = 2001;
1232 pub const _SC_SCHED_PRI_MIN: c_int = 2002;
1233 pub const _SC_SCHED_PRI_MAX: c_int = 2003;
1234
1235 pub const FD_SETSIZE: usize = 0x100;
1236
1237 pub const ST_NOSUID: c_ulong = 8;
1238
1239 // <sys/fstypes.h>
1240 pub const MNT_UNION: c_int = 0x00000020;
1241 pub const MNT_NOCOREDUMP: c_int = 0x00008000;
1242 pub const MNT_RELATIME: c_int = 0x00020000;
1243 pub const MNT_IGNORE: c_int = 0x00100000;
1244 pub const MNT_NFS4ACLS: c_int = 0x00200000;
1245 pub const MNT_DISCARD: c_int = 0x00800000;
1246 pub const MNT_EXTATTR: c_int = 0x01000000;
1247 pub const MNT_LOG: c_int = 0x02000000;
1248 pub const MNT_NOATIME: c_int = 0x04000000;
1249 pub const MNT_AUTOMOUNTED: c_int = 0x10000000;
1250 pub const MNT_SYMPERM: c_int = 0x20000000;
1251 pub const MNT_NODEVMTIME: c_int = 0x40000000;
1252 pub const MNT_SOFTDEP: c_int = 0x80000000;
1253 pub const MNT_POSIX1EACLS: c_int = 0x00000800;
1254 pub const MNT_ACLS: c_int = MNT_POSIX1EACLS;
1255 pub const MNT_WAIT: c_int = 1;
1256 pub const MNT_NOWAIT: c_int = 2;
1257 pub const MNT_LAZY: c_int = 3;
1258
1259 // sys/ioccom.h
1260 pub const IOCPARM_SHIFT: u32 = 16;
1261 pub const IOCGROUP_SHIFT: u32 = 8;
1262
1263 pub const fn IOCPARM_LEN(x: u32) -> u32 {
1264 (x >> IOCPARM_SHIFT) & crate::IOCPARM_MASK
1265 }
1266
1267 pub const fn IOCBASECMD(x: u32) -> u32 {
1268 x & (!(crate::IOCPARM_MASK << IOCPARM_SHIFT))
1269 }
1270
1271 pub const fn IOCGROUP(x: u32) -> u32 {
1272 (x >> IOCGROUP_SHIFT) & 0xff
1273 }
1274
1275 pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong {
1276 (inout)
1277 | (((len) & crate::IOCPARM_MASK as c_ulong) << IOCPARM_SHIFT)
1278 | ((group) << IOCGROUP_SHIFT)
1279 | (num)
1280 }
1281
1282 pub const NTP_API: c_int = 4;
1283
1284 pub const LITTLE_ENDIAN: c_int = 1234;
1285 pub const BIG_ENDIAN: c_int = 4321;
1286
1287 #[deprecated(since = "0.2.178", note = "obsolete upstream")]
1288 pub const PL_EVENT_NONE: c_int = 0;
1289 #[deprecated(since = "0.2.178", note = "obsolete upstream")]
1290 pub const PL_EVENT_SIGNAL: c_int = 1;
1291 #[deprecated(since = "0.2.178", note = "obsolete upstream")]
1292 pub const PL_EVENT_SUSPENDED: c_int = 2;
1293
1294 cfg_if! {
1295 if #[cfg(any(
1296 target_arch = "sparc",
1297 target_arch = "sparc64",
1298 target_arch = "x86",
1299 target_arch = "x86_64"
1300 ))] {
1301 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
1302 ptm_magic: 0x33330003,
1303 ptm_errorcheck: 0,
1304 ptm_pad1: Padding::uninit(),
1305 ptm_unused: Padding::uninit(),
1306 ptm_pad2: Padding::uninit(),
1307 ptm_waiters: 0 as *mut _,
1308 ptm_owner: 0,
1309 ptm_recursed: 0,
1310 ptm_spare2: 0 as *mut _,
1311 };
1312 } else {
1313 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
1314 ptm_magic: 0x33330003,
1315 ptm_errorcheck: 0,
1316 ptm_unused: Padding::uninit(),
1317 ptm_waiters: 0 as *mut _,
1318 ptm_owner: 0,
1319 ptm_recursed: 0,
1320 ptm_spare2: 0 as *mut _,
1321 };
1322 }
1323 }
1324
1325 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1326 ptc_magic: 0x55550005,
1327 ptc_lock: 0,
1328 ptc_waiters_first: 0 as *mut _,
1329 ptc_waiters_last: 0 as *mut _,
1330 ptc_mutex: 0 as *mut _,
1331 ptc_private: 0 as *mut _,
1332 };
1333 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1334 ptr_magic: 0x99990009,
1335 ptr_interlock: 0,
1336 ptr_rblocked_first: 0 as *mut _,
1337 ptr_rblocked_last: 0 as *mut _,
1338 ptr_wblocked_first: 0 as *mut _,
1339 ptr_wblocked_last: 0 as *mut _,
1340 ptr_nreaders: 0,
1341 ptr_owner: 0,
1342 ptr_private: 0 as *mut _,
1343 };
1344 pub const PTHREAD_MUTEX_NORMAL: c_int = 0;
1345 pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1;
1346 pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2;
1347 pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL;
1348
1349 pub const SCHED_NONE: c_int = -1;
1350 pub const SCHED_OTHER: c_int = 0;
1351 pub const SCHED_FIFO: c_int = 1;
1352 pub const SCHED_RR: c_int = 2;
1353
1354 pub const EVFILT_AIO: u32 = 2;
1355 pub const EVFILT_PROC: u32 = 4;
1356 pub const EVFILT_READ: u32 = 0;
1357 pub const EVFILT_SIGNAL: u32 = 5;
1358 pub const EVFILT_TIMER: u32 = 6;
1359 pub const EVFILT_VNODE: u32 = 3;
1360 pub const EVFILT_WRITE: u32 = 1;
1361 pub const EVFILT_FS: u32 = 7;
1362 pub const EVFILT_USER: u32 = 8;
1363 pub const EVFILT_EMPTY: u32 = 9;
1364
1365 pub const EV_ADD: u32 = 0x1;
1366 pub const EV_DELETE: u32 = 0x2;
1367 pub const EV_ENABLE: u32 = 0x4;
1368 pub const EV_DISABLE: u32 = 0x8;
1369 pub const EV_ONESHOT: u32 = 0x10;
1370 pub const EV_CLEAR: u32 = 0x20;
1371 pub const EV_RECEIPT: u32 = 0x40;
1372 pub const EV_DISPATCH: u32 = 0x80;
1373 pub const EV_FLAG1: u32 = 0x2000;
1374 pub const EV_ERROR: u32 = 0x4000;
1375 pub const EV_EOF: u32 = 0x8000;
1376 pub const EV_SYSFLAGS: u32 = 0xf000;
1377
1378 pub const NOTE_TRIGGER: u32 = 0x01000000;
1379 pub const NOTE_FFNOP: u32 = 0x00000000;
1380 pub const NOTE_FFAND: u32 = 0x40000000;
1381 pub const NOTE_FFOR: u32 = 0x80000000;
1382 pub const NOTE_FFCOPY: u32 = 0xc0000000;
1383 pub const NOTE_FFCTRLMASK: u32 = 0xc0000000;
1384 pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff;
1385 pub const NOTE_LOWAT: u32 = 0x00000001;
1386 pub const NOTE_DELETE: u32 = 0x00000001;
1387 pub const NOTE_WRITE: u32 = 0x00000002;
1388 pub const NOTE_EXTEND: u32 = 0x00000004;
1389 pub const NOTE_ATTRIB: u32 = 0x00000008;
1390 pub const NOTE_LINK: u32 = 0x00000010;
1391 pub const NOTE_RENAME: u32 = 0x00000020;
1392 pub const NOTE_REVOKE: u32 = 0x00000040;
1393 pub const NOTE_EXIT: u32 = 0x80000000;
1394 pub const NOTE_FORK: u32 = 0x40000000;
1395 pub const NOTE_EXEC: u32 = 0x20000000;
1396 pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1397 pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1398 pub const NOTE_TRACK: u32 = 0x00000001;
1399 pub const NOTE_TRACKERR: u32 = 0x00000002;
1400 pub const NOTE_CHILD: u32 = 0x00000004;
1401 pub const NOTE_MSECONDS: u32 = 0x00000000;
1402 pub const NOTE_SECONDS: u32 = 0x00000001;
1403 pub const NOTE_USECONDS: u32 = 0x00000002;
1404 pub const NOTE_NSECONDS: u32 = 0x00000003;
1405 pub const NOTE_ABSTIME: u32 = 0x000000010;
1406
1407 pub const TMP_MAX: c_uint = 308915776;
1408
1409 pub const AI_PASSIVE: c_int = 0x00000001;
1410 pub const AI_CANONNAME: c_int = 0x00000002;
1411 pub const AI_NUMERICHOST: c_int = 0x00000004;
1412 pub const AI_NUMERICSERV: c_int = 0x00000008;
1413 pub const AI_ADDRCONFIG: c_int = 0x00000400;
1414 pub const AI_SRV: c_int = 0x00000800;
1415
1416 pub const NI_MAXHOST: crate::socklen_t = 1025;
1417 pub const NI_MAXSERV: crate::socklen_t = 32;
1418
1419 pub const NI_NOFQDN: c_int = 0x00000001;
1420 pub const NI_NUMERICHOST: c_int = 0x000000002;
1421 pub const NI_NAMEREQD: c_int = 0x000000004;
1422 pub const NI_NUMERICSERV: c_int = 0x000000008;
1423 pub const NI_DGRAM: c_int = 0x00000010;
1424 pub const NI_WITHSCOPEID: c_int = 0x00000020;
1425 pub const NI_NUMERICSCOPE: c_int = 0x00000040;
1426
1427 pub const RTLD_NOLOAD: c_int = 0x2000;
1428 pub const RTLD_LOCAL: c_int = 0x200;
1429
1430 pub const CTL_MAXNAME: c_int = 12;
1431 pub const SYSCTL_NAMELEN: c_int = 32;
1432 pub const SYSCTL_DEFSIZE: c_int = 8;
1433 pub const CTLTYPE_NODE: c_int = 1;
1434 pub const CTLTYPE_INT: c_int = 2;
1435 pub const CTLTYPE_STRING: c_int = 3;
1436 pub const CTLTYPE_QUAD: c_int = 4;
1437 pub const CTLTYPE_STRUCT: c_int = 5;
1438 pub const CTLTYPE_BOOL: c_int = 6;
1439 pub const CTLFLAG_READONLY: c_int = 0x00000000;
1440 pub const CTLFLAG_READWRITE: c_int = 0x00000070;
1441 pub const CTLFLAG_ANYWRITE: c_int = 0x00000080;
1442 pub const CTLFLAG_PRIVATE: c_int = 0x00000100;
1443 pub const CTLFLAG_PERMANENT: c_int = 0x00000200;
1444 pub const CTLFLAG_OWNDATA: c_int = 0x00000400;
1445 pub const CTLFLAG_IMMEDIATE: c_int = 0x00000800;
1446 pub const CTLFLAG_HEX: c_int = 0x00001000;
1447 pub const CTLFLAG_ROOT: c_int = 0x00002000;
1448 pub const CTLFLAG_ANYNUMBER: c_int = 0x00004000;
1449 pub const CTLFLAG_HIDDEN: c_int = 0x00008000;
1450 pub const CTLFLAG_ALIAS: c_int = 0x00010000;
1451 pub const CTLFLAG_MMAP: c_int = 0x00020000;
1452 pub const CTLFLAG_OWNDESC: c_int = 0x00040000;
1453 pub const CTLFLAG_UNSIGNED: c_int = 0x00080000;
1454 pub const SYSCTL_VERS_MASK: c_int = 0xff000000;
1455 pub const SYSCTL_VERS_0: c_int = 0x00000000;
1456 pub const SYSCTL_VERS_1: c_int = 0x01000000;
1457 pub const SYSCTL_VERSION: c_int = SYSCTL_VERS_1;
1458 pub const CTL_EOL: c_int = -1;
1459 pub const CTL_QUERY: c_int = -2;
1460 pub const CTL_CREATE: c_int = -3;
1461 pub const CTL_CREATESYM: c_int = -4;
1462 pub const CTL_DESTROY: c_int = -5;
1463 pub const CTL_MMAP: c_int = -6;
1464 pub const CTL_DESCRIBE: c_int = -7;
1465 pub const CTL_UNSPEC: c_int = 0;
1466 pub const CTL_KERN: c_int = 1;
1467 pub const CTL_VM: c_int = 2;
1468 pub const CTL_VFS: c_int = 3;
1469 pub const CTL_NET: c_int = 4;
1470 pub const CTL_DEBUG: c_int = 5;
1471 pub const CTL_HW: c_int = 6;
1472 pub const CTL_MACHDEP: c_int = 7;
1473 pub const CTL_USER: c_int = 8;
1474 pub const CTL_DDB: c_int = 9;
1475 pub const CTL_PROC: c_int = 10;
1476 pub const CTL_VENDOR: c_int = 11;
1477 pub const CTL_EMUL: c_int = 12;
1478 pub const CTL_SECURITY: c_int = 13;
1479 pub const KERN_OSTYPE: c_int = 1;
1480 pub const KERN_OSRELEASE: c_int = 2;
1481 pub const KERN_OSREV: c_int = 3;
1482 pub const KERN_VERSION: c_int = 4;
1483 pub const KERN_MAXVNODES: c_int = 5;
1484 pub const KERN_MAXPROC: c_int = 6;
1485 pub const KERN_MAXFILES: c_int = 7;
1486 pub const KERN_ARGMAX: c_int = 8;
1487 pub const KERN_SECURELVL: c_int = 9;
1488 pub const KERN_HOSTNAME: c_int = 10;
1489 pub const KERN_HOSTID: c_int = 11;
1490 pub const KERN_CLOCKRATE: c_int = 12;
1491 pub const KERN_VNODE: c_int = 13;
1492 pub const KERN_PROC: c_int = 14;
1493 pub const KERN_FILE: c_int = 15;
1494 pub const KERN_PROF: c_int = 16;
1495 pub const KERN_POSIX1: c_int = 17;
1496 pub const KERN_NGROUPS: c_int = 18;
1497 pub const KERN_JOB_CONTROL: c_int = 19;
1498 pub const KERN_SAVED_IDS: c_int = 20;
1499 pub const KERN_OBOOTTIME: c_int = 21;
1500 pub const KERN_DOMAINNAME: c_int = 22;
1501 pub const KERN_MAXPARTITIONS: c_int = 23;
1502 pub const KERN_RAWPARTITION: c_int = 24;
1503 pub const KERN_NTPTIME: c_int = 25;
1504 pub const KERN_TIMEX: c_int = 26;
1505 pub const KERN_AUTONICETIME: c_int = 27;
1506 pub const KERN_AUTONICEVAL: c_int = 28;
1507 pub const KERN_RTC_OFFSET: c_int = 29;
1508 pub const KERN_ROOT_DEVICE: c_int = 30;
1509 pub const KERN_MSGBUFSIZE: c_int = 31;
1510 pub const KERN_FSYNC: c_int = 32;
1511 pub const KERN_OLDSYSVMSG: c_int = 33;
1512 pub const KERN_OLDSYSVSEM: c_int = 34;
1513 pub const KERN_OLDSYSVSHM: c_int = 35;
1514 pub const KERN_OLDSHORTCORENAME: c_int = 36;
1515 pub const KERN_SYNCHRONIZED_IO: c_int = 37;
1516 pub const KERN_IOV_MAX: c_int = 38;
1517 pub const KERN_MBUF: c_int = 39;
1518 pub const KERN_MAPPED_FILES: c_int = 40;
1519 pub const KERN_MEMLOCK: c_int = 41;
1520 pub const KERN_MEMLOCK_RANGE: c_int = 42;
1521 pub const KERN_MEMORY_PROTECTION: c_int = 43;
1522 pub const KERN_LOGIN_NAME_MAX: c_int = 44;
1523 pub const KERN_DEFCORENAME: c_int = 45;
1524 pub const KERN_LOGSIGEXIT: c_int = 46;
1525 pub const KERN_PROC2: c_int = 47;
1526 pub const KERN_PROC_ARGS: c_int = 48;
1527 pub const KERN_FSCALE: c_int = 49;
1528 pub const KERN_CCPU: c_int = 50;
1529 pub const KERN_CP_TIME: c_int = 51;
1530 pub const KERN_OLDSYSVIPC_INFO: c_int = 52;
1531 pub const KERN_MSGBUF: c_int = 53;
1532 pub const KERN_CONSDEV: c_int = 54;
1533 pub const KERN_MAXPTYS: c_int = 55;
1534 pub const KERN_PIPE: c_int = 56;
1535 pub const KERN_MAXPHYS: c_int = 57;
1536 pub const KERN_SBMAX: c_int = 58;
1537 pub const KERN_TKSTAT: c_int = 59;
1538 pub const KERN_MONOTONIC_CLOCK: c_int = 60;
1539 pub const KERN_URND: c_int = 61;
1540 pub const KERN_LABELSECTOR: c_int = 62;
1541 pub const KERN_LABELOFFSET: c_int = 63;
1542 pub const KERN_LWP: c_int = 64;
1543 pub const KERN_FORKFSLEEP: c_int = 65;
1544 pub const KERN_POSIX_THREADS: c_int = 66;
1545 pub const KERN_POSIX_SEMAPHORES: c_int = 67;
1546 pub const KERN_POSIX_BARRIERS: c_int = 68;
1547 pub const KERN_POSIX_TIMERS: c_int = 69;
1548 pub const KERN_POSIX_SPIN_LOCKS: c_int = 70;
1549 pub const KERN_POSIX_READER_WRITER_LOCKS: c_int = 71;
1550 pub const KERN_DUMP_ON_PANIC: c_int = 72;
1551 pub const KERN_SOMAXKVA: c_int = 73;
1552 pub const KERN_ROOT_PARTITION: c_int = 74;
1553 pub const KERN_DRIVERS: c_int = 75;
1554 pub const KERN_BUF: c_int = 76;
1555 pub const KERN_FILE2: c_int = 77;
1556 pub const KERN_VERIEXEC: c_int = 78;
1557 pub const KERN_CP_ID: c_int = 79;
1558 pub const KERN_HARDCLOCK_TICKS: c_int = 80;
1559 pub const KERN_ARND: c_int = 81;
1560 pub const KERN_SYSVIPC: c_int = 82;
1561 pub const KERN_BOOTTIME: c_int = 83;
1562 pub const KERN_EVCNT: c_int = 84;
1563 pub const KERN_PROC_ALL: c_int = 0;
1564 pub const KERN_PROC_PID: c_int = 1;
1565 pub const KERN_PROC_PGRP: c_int = 2;
1566 pub const KERN_PROC_SESSION: c_int = 3;
1567 pub const KERN_PROC_TTY: c_int = 4;
1568 pub const KERN_PROC_UID: c_int = 5;
1569 pub const KERN_PROC_RUID: c_int = 6;
1570 pub const KERN_PROC_GID: c_int = 7;
1571 pub const KERN_PROC_RGID: c_int = 8;
1572 pub const KERN_PROC_ARGV: c_int = 1;
1573 pub const KERN_PROC_NARGV: c_int = 2;
1574 pub const KERN_PROC_ENV: c_int = 3;
1575 pub const KERN_PROC_NENV: c_int = 4;
1576 pub const KERN_PROC_PATHNAME: c_int = 5;
1577 pub const VM_PROC: c_int = 16;
1578 pub const VM_PROC_MAP: c_int = 1;
1579
1580 pub const EAI_AGAIN: c_int = 2;
1581 pub const EAI_BADFLAGS: c_int = 3;
1582 pub const EAI_FAIL: c_int = 4;
1583 pub const EAI_FAMILY: c_int = 5;
1584 pub const EAI_MEMORY: c_int = 6;
1585 pub const EAI_NODATA: c_int = 7;
1586 pub const EAI_NONAME: c_int = 8;
1587 pub const EAI_SERVICE: c_int = 9;
1588 pub const EAI_SOCKTYPE: c_int = 10;
1589 pub const EAI_SYSTEM: c_int = 11;
1590 pub const EAI_OVERFLOW: c_int = 14;
1591
1592 pub const AIO_CANCELED: c_int = 1;
1593 pub const AIO_NOTCANCELED: c_int = 2;
1594 pub const AIO_ALLDONE: c_int = 3;
1595 pub const LIO_NOP: c_int = 0;
1596 pub const LIO_WRITE: c_int = 1;
1597 pub const LIO_READ: c_int = 2;
1598 pub const LIO_WAIT: c_int = 1;
1599 pub const LIO_NOWAIT: c_int = 0;
1600
1601 pub const SIGEV_NONE: c_int = 0;
1602 pub const SIGEV_SIGNAL: c_int = 1;
1603 pub const SIGEV_THREAD: c_int = 2;
1604
1605 pub const WSTOPPED: c_int = 0x00000002; // same as WUNTRACED
1606 pub const WCONTINUED: c_int = 0x00000010;
1607 pub const WEXITED: c_int = 0x000000020;
1608 pub const WNOWAIT: c_int = 0x00010000;
1609
1610 pub const WALTSIG: c_int = 0x00000004;
1611 pub const WALLSIG: c_int = 0x00000008;
1612 pub const WTRAPPED: c_int = 0x00000040;
1613 pub const WNOZOMBIE: c_int = 0x00020000;
1614
1615 pub const P_ALL: idtype_t = 0;
1616 pub const P_PID: idtype_t = 1;
1617 pub const P_PGID: idtype_t = 4;
1618
1619 pub const UTIME_OMIT: c_long = 1073741822;
1620 pub const UTIME_NOW: c_long = 1073741823;
1621
1622 pub const B460800: crate::speed_t = 460800;
1623 pub const B921600: crate::speed_t = 921600;
1624
1625 pub const ONOCR: crate::tcflag_t = 0x20;
1626 pub const ONLRET: crate::tcflag_t = 0x40;
1627 pub const CDTRCTS: crate::tcflag_t = 0x00020000;
1628 pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS | crate::CDTRCTS;
1629
1630 pub const SOCK_CLOEXEC: c_int = 0x10000000;
1631 pub const SOCK_NONBLOCK: c_int = 0x20000000;
1632
1633 // Uncomment on next NetBSD release
1634 // pub const FIOSEEKDATA: c_ulong = 0xc0086661;
1635 // pub const FIOSEEKHOLE: c_ulong = 0xc0086662;
1636 pub const OFIOGETBMAP: c_ulong = 0xc004667a;
1637 pub const FIOGETBMAP: c_ulong = 0xc008667a;
1638 pub const FIONWRITE: c_ulong = 0x40046679;
1639 pub const FIONSPACE: c_ulong = 0x40046678;
1640 pub const FIBMAP: c_ulong = 0xc008667a;
1641
1642 pub const SIGSTKSZ: size_t = 40960;
1643
1644 pub const REG_ILLSEQ: c_int = 17;
1645
1646 pub const PT_DUMPCORE: c_int = 12;
1647 #[deprecated(note = "obsolete operation")]
1648 pub const PT_LWPINFO: c_int = 13;
1649 pub const PT_SYSCALL: c_int = 14;
1650 pub const PT_SYSCALLEMU: c_int = 15;
1651 pub const PT_SET_EVENT_MASK: c_int = 16;
1652 pub const PT_GET_EVENT_MASK: c_int = 17;
1653 pub const PT_GET_PROCESS_STATE: c_int = 18;
1654 pub const PT_SET_SIGINFO: c_int = 19;
1655 pub const PT_GET_SIGINFO: c_int = 20;
1656 pub const PT_RESUME: c_int = 21;
1657 pub const PT_SUSPEND: c_int = 22;
1658 pub const PT_STOP: c_int = 23;
1659 pub const PT_LWPSTATUS: c_int = 24;
1660 pub const PT_LWPNEXT: c_int = 25;
1661 pub const PT_SET_SIGPASS: c_int = 26;
1662 pub const PT_GET_SIGPASS: c_int = 27;
1663 pub const PT_FIRSTMACH: c_int = 32;
1664 pub const POSIX_SPAWN_RETURNERROR: c_int = 0x40;
1665
1666 // Flags for chflags(2)
1667 pub const SF_APPEND: c_ulong = 0x00040000;
1668 pub const SF_ARCHIVED: c_ulong = 0x00010000;
1669 pub const SF_IMMUTABLE: c_ulong = 0x00020000;
1670 pub const SF_LOG: c_ulong = 0x00400000;
1671 pub const SF_SETTABLE: c_ulong = 0xffff0000;
1672 pub const SF_SNAPINVAL: c_ulong = 0x00800000;
1673 pub const SF_SNAPSHOT: c_ulong = 0x00200000;
1674 pub const UF_APPEND: c_ulong = 0x00000004;
1675 pub const UF_IMMUTABLE: c_ulong = 0x00000002;
1676 pub const UF_NODUMP: c_ulong = 0x00000001;
1677 pub const UF_OPAQUE: c_ulong = 0x00000008;
1678 pub const UF_SETTABLE: c_ulong = 0x0000ffff;
1679
1680 // sys/sysctl.h
1681 pub const KVME_PROT_READ: c_int = 0x00000001;
1682 pub const KVME_PROT_WRITE: c_int = 0x00000002;
1683 pub const KVME_PROT_EXEC: c_int = 0x00000004;
1684
1685 pub const KVME_FLAG_COW: c_int = 0x00000001;
1686 pub const KVME_FLAG_NEEDS_COPY: c_int = 0x00000002;
1687 pub const KVME_FLAG_NOCOREDUMP: c_int = 0x000000004;
1688 pub const KVME_FLAG_PAGEABLE: c_int = 0x000000008;
1689 pub const KVME_FLAG_GROWS_UP: c_int = 0x000000010;
1690 pub const KVME_FLAG_GROWS_DOWN: c_int = 0x000000020;
1691
1692 pub const NGROUPS_MAX: c_int = 16;
1693
1694 pub const KI_NGROUPS: c_int = 16;
1695 pub const KI_MAXCOMLEN: c_int = 24;
1696 pub const KI_WMESGLEN: c_int = 8;
1697 pub const KI_MAXLOGNAME: c_int = 24;
1698 pub const KI_MAXEMULLEN: c_int = 16;
1699 pub const KI_LNAMELEN: c_int = 20;
1700
1701 // sys/lwp.h
1702 pub const LSIDL: c_int = 1;
1703 pub const LSRUN: c_int = 2;
1704 pub const LSSLEEP: c_int = 3;
1705 pub const LSSTOP: c_int = 4;
1706 pub const LSZOMB: c_int = 5;
1707 pub const LSONPROC: c_int = 7;
1708 pub const LSSUSPENDED: c_int = 8;
1709
1710 // sys/xattr.h
1711 pub const XATTR_CREATE: c_int = 0x01;
1712 pub const XATTR_REPLACE: c_int = 0x02;
1713 // sys/extattr.h
1714 pub const EXTATTR_NAMESPACE_EMPTY: c_int = 0;
1715
1716 // For getrandom()
1717 pub const GRND_NONBLOCK: c_uint = 0x1;
1718 pub const GRND_RANDOM: c_uint = 0x2;
1719 pub const GRND_INSECURE: c_uint = 0x4;
1720
1721 // sys/reboot.h
1722 pub const RB_ASKNAME: c_int = 0x000000001;
1723 pub const RB_SINGLE: c_int = 0x000000002;
1724 pub const RB_NOSYNC: c_int = 0x000000004;
1725 pub const RB_HALT: c_int = 0x000000008;
1726 pub const RB_INITNAME: c_int = 0x000000010;
1727 pub const RB_KDB: c_int = 0x000000040;
1728 pub const RB_RDONLY: c_int = 0x000000080;
1729 pub const RB_DUMP: c_int = 0x000000100;
1730 pub const RB_MINIROOT: c_int = 0x000000200;
1731 pub const RB_STRING: c_int = 0x000000400;
1732 pub const RB_POWERDOWN: c_int = RB_HALT | 0x000000800;
1733 pub const RB_USERCONF: c_int = 0x000001000;
1734
1735 pub const fn MAP_ALIGNED(alignment: c_int) -> c_int {
1736 alignment << MAP_ALIGNMENT_SHIFT
1737 }
1738
1739 // net/route.h
1740 pub const RTF_MASK: c_int = 0x80;
1741 pub const RTF_CONNECTED: c_int = 0x100;
1742 pub const RTF_ANNOUNCE: c_int = 0x20000;
1743 pub const RTF_SRC: c_int = 0x10000;
1744 pub const RTF_LOCAL: c_int = 0x40000;
1745 pub const RTF_BROADCAST: c_int = 0x80000;
1746 pub const RTF_UPDATING: c_int = 0x100000;
1747 pub const RTF_DONTCHANGEIFA: c_int = 0x200000;
1748
1749 pub const RTM_VERSION: c_int = 4;
1750 pub const RTM_LOCK: c_int = 0x8;
1751 pub const RTM_IFANNOUNCE: c_int = 0x10;
1752 pub const RTM_IEEE80211: c_int = 0x11;
1753 pub const RTM_SETGATE: c_int = 0x12;
1754 pub const RTM_LLINFO_UPD: c_int = 0x13;
1755 pub const RTM_IFINFO: c_int = 0x14;
1756 pub const RTM_OCHGADDR: c_int = 0x15;
1757 pub const RTM_NEWADDR: c_int = 0x16;
1758 pub const RTM_DELADDR: c_int = 0x17;
1759 pub const RTM_CHGADDR: c_int = 0x18;
1760
1761 pub const RTA_TAG: c_int = 0x100;
1762
1763 pub const RTAX_TAG: c_int = 8;
1764 pub const RTAX_MAX: c_int = 9;
1765
1766 // For eventfd
1767 pub const EFD_SEMAPHORE: c_int = crate::O_RDWR;
1768 pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK;
1769 pub const EFD_CLOEXEC: c_int = crate::O_CLOEXEC;
1770
1771 // sys/timerfd.h
1772 pub const TFD_CLOEXEC: i32 = crate::O_CLOEXEC;
1773 pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK;
1774 pub const TFD_TIMER_ABSTIME: i32 = crate::O_WRONLY;
1775 pub const TFD_TIMER_CANCEL_ON_SET: i32 = crate::O_RDWR;
1776
1777 const fn _ALIGN(p: usize) -> usize {
1778 (p + _ALIGNBYTES) & !_ALIGNBYTES
1779 }
1780
1781 f! {
1782 pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar {
1783 (cmsg as *mut c_uchar).add(_ALIGN(size_of::<cmsghdr>()))
1784 }
1785
1786 pub const fn CMSG_LEN(length: c_uint) -> c_uint {
1787 _ALIGN(size_of::<cmsghdr>()) as c_uint + length
1788 }
1789
1790 pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
1791 if cmsg.is_null() {
1792 return crate::CMSG_FIRSTHDR(mhdr);
1793 }
1794 let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::<cmsghdr>());
1795 let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
1796 if next > max {
1797 core::ptr::null_mut::<cmsghdr>()
1798 } else {
1799 (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
1800 }
1801 }
1802
1803 pub const fn CMSG_SPACE(length: c_uint) -> c_uint {
1804 (_ALIGN(size_of::<cmsghdr>()) + _ALIGN(length as usize)) as c_uint
1805 }
1806
1807 // dirfd() is a macro on netbsd to access
1808 // the first field of the struct where dirp points to:
1809 // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
1810 pub fn dirfd(dirp: *mut crate::DIR) -> c_int {
1811 *(dirp as *const c_int)
1812 }
1813
1814 pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
1815 let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 };
1816 size_of::<sockcred>() + size_of::<crate::gid_t>() * ngrps
1817 }
1818
1819 pub fn PROT_MPROTECT(x: c_int) -> c_int {
1820 x << 3
1821 }
1822
1823 pub fn PROT_MPROTECT_EXTRACT(x: c_int) -> c_int {
1824 (x >> 3) & 0x7
1825 }
1826 }
1827
1828 safe_f! {
1829 pub const fn WSTOPSIG(status: c_int) -> c_int {
1830 status >> 8
1831 }
1832
1833 pub const fn WIFSIGNALED(status: c_int) -> bool {
1834 (status & 0o177) != 0o177 && (status & 0o177) != 0
1835 }
1836
1837 pub const fn WIFSTOPPED(status: c_int) -> bool {
1838 (status & 0o177) == 0o177
1839 }
1840
1841 pub const fn WIFCONTINUED(status: c_int) -> bool {
1842 status == 0xffff
1843 }
1844
1845 pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
1846 let major = major as crate::dev_t;
1847 let minor = minor as crate::dev_t;
1848 let mut dev = 0;
1849 dev |= (major << 8) & 0x000ff00;
1850 dev |= (minor << 12) & 0xfff00000;
1851 dev |= minor & 0xff;
1852 dev
1853 }
1854
1855 pub const fn major(dev: crate::dev_t) -> c_int {
1856 (((dev as u32) & 0x000fff00) >> 8) as c_int
1857 }
1858
1859 pub const fn minor(dev: crate::dev_t) -> c_int {
1860 let mut res = 0;
1861 res |= ((dev as u32) & 0xfff00000) >> 12;
1862 res |= (dev as u32) & 0x000000ff;
1863 res as c_int
1864 }
1865 }
1866
1867 extern "C" {
1868 pub fn clock_nanosleep(
1869 clk_id: crate::clockid_t,
1870 flags: c_int,
1871 rqtp: *const crate::timespec,
1872 rmtp: *mut crate::timespec,
1873 ) -> c_int;
1874
1875 pub fn reallocarr(ptr: *mut c_void, number: size_t, size: size_t) -> c_int;
1876
1877 pub fn chflags(path: *const c_char, flags: c_ulong) -> c_int;
1878 pub fn fchflags(fd: c_int, flags: c_ulong) -> c_int;
1879 pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int;
1880
1881 pub fn extattr_list_fd(
1882 fd: c_int,
1883 attrnamespace: c_int,
1884 data: *mut c_void,
1885 nbytes: size_t,
1886 ) -> ssize_t;
1887 pub fn extattr_list_file(
1888 path: *const c_char,
1889 attrnamespace: c_int,
1890 data: *mut c_void,
1891 nbytes: size_t,
1892 ) -> ssize_t;
1893 pub fn extattr_list_link(
1894 path: *const c_char,
1895 attrnamespace: c_int,
1896 data: *mut c_void,
1897 nbytes: size_t,
1898 ) -> ssize_t;
1899 pub fn extattr_delete_fd(fd: c_int, attrnamespace: c_int, attrname: *const c_char) -> c_int;
1900 pub fn extattr_delete_file(
1901 path: *const c_char,
1902 attrnamespace: c_int,
1903 attrname: *const c_char,
1904 ) -> c_int;
1905 pub fn extattr_delete_link(
1906 path: *const c_char,
1907 attrnamespace: c_int,
1908 attrname: *const c_char,
1909 ) -> c_int;
1910 pub fn extattr_get_fd(
1911 fd: c_int,
1912 attrnamespace: c_int,
1913 attrname: *const c_char,
1914 data: *mut c_void,
1915 nbytes: size_t,
1916 ) -> ssize_t;
1917 pub fn extattr_get_file(
1918 path: *const c_char,
1919 attrnamespace: c_int,
1920 attrname: *const c_char,
1921 data: *mut c_void,
1922 nbytes: size_t,
1923 ) -> ssize_t;
1924 pub fn extattr_get_link(
1925 path: *const c_char,
1926 attrnamespace: c_int,
1927 attrname: *const c_char,
1928 data: *mut c_void,
1929 nbytes: size_t,
1930 ) -> ssize_t;
1931 pub fn extattr_namespace_to_string(attrnamespace: c_int, string: *mut *mut c_char) -> c_int;
1932 pub fn extattr_set_fd(
1933 fd: c_int,
1934 attrnamespace: c_int,
1935 attrname: *const c_char,
1936 data: *const c_void,
1937 nbytes: size_t,
1938 ) -> c_int;
1939 pub fn extattr_set_file(
1940 path: *const c_char,
1941 attrnamespace: c_int,
1942 attrname: *const c_char,
1943 data: *const c_void,
1944 nbytes: size_t,
1945 ) -> c_int;
1946 pub fn extattr_set_link(
1947 path: *const c_char,
1948 attrnamespace: c_int,
1949 attrname: *const c_char,
1950 data: *const c_void,
1951 nbytes: size_t,
1952 ) -> c_int;
1953 pub fn extattr_string_to_namespace(string: *const c_char, attrnamespace: *mut c_int) -> c_int;
1954
1955 pub fn openpty(
1956 amaster: *mut c_int,
1957 aslave: *mut c_int,
1958 name: *mut c_char,
1959 termp: *mut crate::termios,
1960 winp: *mut crate::winsize,
1961 ) -> c_int;
1962 pub fn forkpty(
1963 amaster: *mut c_int,
1964 name: *mut c_char,
1965 termp: *mut crate::termios,
1966 winp: *mut crate::winsize,
1967 ) -> crate::pid_t;
1968
1969 pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
1970
1971 #[link_name = "__lutimes50"]
1972 pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
1973 #[link_name = "__gettimeofday50"]
1974 pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int;
1975 pub fn getnameinfo(
1976 sa: *const crate::sockaddr,
1977 salen: crate::socklen_t,
1978 host: *mut c_char,
1979 hostlen: crate::socklen_t,
1980 serv: *mut c_char,
1981 servlen: crate::socklen_t,
1982 flags: c_int,
1983 ) -> c_int;
1984 pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
1985 pub fn sysctl(
1986 name: *const c_int,
1987 namelen: c_uint,
1988 oldp: *mut c_void,
1989 oldlenp: *mut size_t,
1990 newp: *const c_void,
1991 newlen: size_t,
1992 ) -> c_int;
1993 pub fn sysctlbyname(
1994 name: *const c_char,
1995 oldp: *mut c_void,
1996 oldlenp: *mut size_t,
1997 newp: *const c_void,
1998 newlen: size_t,
1999 ) -> c_int;
2000 pub fn sysctlnametomib(sname: *const c_char, name: *mut c_int, namelenp: *mut size_t) -> c_int;
2001 #[link_name = "__kevent50"]
2002 pub fn kevent(
2003 kq: c_int,
2004 changelist: *const crate::kevent,
2005 nchanges: size_t,
2006 eventlist: *mut crate::kevent,
2007 nevents: size_t,
2008 timeout: *const crate::timespec,
2009 ) -> c_int;
2010 #[link_name = "__mount50"]
2011 pub fn mount(
2012 src: *const c_char,
2013 target: *const c_char,
2014 flags: c_int,
2015 data: *mut c_void,
2016 size: size_t,
2017 ) -> c_int;
2018 pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t;
2019 pub fn mq_close(mqd: crate::mqd_t) -> c_int;
2020 pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int;
2021 pub fn mq_notify(mqd: crate::mqd_t, notification: *const crate::sigevent) -> c_int;
2022 pub fn mq_receive(
2023 mqd: crate::mqd_t,
2024 msg_ptr: *mut c_char,
2025 msg_len: size_t,
2026 msg_prio: *mut c_uint,
2027 ) -> ssize_t;
2028 pub fn mq_send(
2029 mqd: crate::mqd_t,
2030 msg_ptr: *const c_char,
2031 msg_len: size_t,
2032 msg_prio: c_uint,
2033 ) -> c_int;
2034 pub fn mq_setattr(
2035 mqd: crate::mqd_t,
2036 newattr: *const crate::mq_attr,
2037 oldattr: *mut crate::mq_attr,
2038 ) -> c_int;
2039 #[link_name = "__mq_timedreceive50"]
2040 pub fn mq_timedreceive(
2041 mqd: crate::mqd_t,
2042 msg_ptr: *mut c_char,
2043 msg_len: size_t,
2044 msg_prio: *mut c_uint,
2045 abs_timeout: *const crate::timespec,
2046 ) -> ssize_t;
2047 #[link_name = "__mq_timedsend50"]
2048 pub fn mq_timedsend(
2049 mqd: crate::mqd_t,
2050 msg_ptr: *const c_char,
2051 msg_len: size_t,
2052 msg_prio: c_uint,
2053 abs_timeout: *const crate::timespec,
2054 ) -> c_int;
2055 pub fn mq_unlink(name: *const c_char) -> c_int;
2056 pub fn ptrace(request: c_int, pid: crate::pid_t, addr: *mut c_void, data: c_int) -> c_int;
2057 pub fn utrace(label: *const c_char, addr: *mut c_void, len: size_t) -> c_int;
2058 pub fn pthread_getname_np(t: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int;
2059 pub fn pthread_setname_np(
2060 t: crate::pthread_t,
2061 name: *const c_char,
2062 arg: *const c_void,
2063 ) -> c_int;
2064 pub fn pthread_attr_get_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t)
2065 -> c_int;
2066 pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int;
2067 pub fn pthread_attr_getguardsize(
2068 attr: *const crate::pthread_attr_t,
2069 guardsize: *mut size_t,
2070 ) -> c_int;
2071 pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int;
2072 pub fn pthread_attr_getstack(
2073 attr: *const crate::pthread_attr_t,
2074 stackaddr: *mut *mut c_void,
2075 stacksize: *mut size_t,
2076 ) -> c_int;
2077 pub fn pthread_getaffinity_np(
2078 thread: crate::pthread_t,
2079 size: size_t,
2080 set: *mut cpuset_t,
2081 ) -> c_int;
2082 pub fn pthread_setaffinity_np(
2083 thread: crate::pthread_t,
2084 size: size_t,
2085 set: *mut cpuset_t,
2086 ) -> c_int;
2087
2088 pub fn _cpuset_create() -> *mut cpuset_t;
2089 pub fn _cpuset_destroy(set: *mut cpuset_t);
2090 pub fn _cpuset_clr(cpu: cpuid_t, set: *mut cpuset_t) -> c_int;
2091 pub fn _cpuset_set(cpu: cpuid_t, set: *mut cpuset_t) -> c_int;
2092 pub fn _cpuset_isset(cpu: cpuid_t, set: *const cpuset_t) -> c_int;
2093 pub fn _cpuset_size(set: *const cpuset_t) -> size_t;
2094 pub fn _cpuset_zero(set: *mut cpuset_t);
2095 #[link_name = "__sigtimedwait50"]
2096 pub fn sigtimedwait(
2097 set: *const sigset_t,
2098 info: *mut siginfo_t,
2099 timeout: *const crate::timespec,
2100 ) -> c_int;
2101 pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int;
2102
2103 pub fn duplocale(base: crate::locale_t) -> crate::locale_t;
2104 pub fn freelocale(loc: crate::locale_t);
2105 pub fn localeconv_l(loc: crate::locale_t) -> *mut lconv;
2106 pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t;
2107 #[link_name = "__settimeofday50"]
2108 pub fn settimeofday(tv: *const crate::timeval, tz: *const c_void) -> c_int;
2109
2110 pub fn dup3(src: c_int, dst: c_int, flags: c_int) -> c_int;
2111
2112 pub fn kqueue1(flags: c_int) -> c_int;
2113
2114 pub fn _lwp_self() -> lwpid_t;
2115 pub fn memmem(
2116 haystack: *const c_void,
2117 haystacklen: size_t,
2118 needle: *const c_void,
2119 needlelen: size_t,
2120 ) -> *mut c_void;
2121
2122 // link.h
2123
2124 pub fn dl_iterate_phdr(
2125 callback: Option<
2126 unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int,
2127 >,
2128 data: *mut c_void,
2129 ) -> c_int;
2130
2131 // dlfcn.h
2132
2133 pub fn _dlauxinfo() -> *mut c_void;
2134
2135 pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t;
2136 pub fn iconv(
2137 cd: iconv_t,
2138 inbuf: *mut *mut c_char,
2139 inbytesleft: *mut size_t,
2140 outbuf: *mut *mut c_char,
2141 outbytesleft: *mut size_t,
2142 ) -> size_t;
2143 pub fn iconv_close(cd: iconv_t) -> c_int;
2144
2145 pub fn timer_create(
2146 clockid: crate::clockid_t,
2147 sevp: *mut crate::sigevent,
2148 timerid: *mut crate::timer_t,
2149 ) -> c_int;
2150 pub fn timer_delete(timerid: crate::timer_t) -> c_int;
2151 pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int;
2152 #[link_name = "__timer_gettime50"]
2153 pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int;
2154 #[link_name = "__timer_settime50"]
2155 pub fn timer_settime(
2156 timerid: crate::timer_t,
2157 flags: c_int,
2158 new_value: *const crate::itimerspec,
2159 old_value: *mut crate::itimerspec,
2160 ) -> c_int;
2161 pub fn dlvsym(
2162 handle: *mut c_void,
2163 symbol: *const c_char,
2164 version: *const c_char,
2165 ) -> *mut c_void;
2166
2167 // Added in `NetBSD` 7.0
2168 pub fn explicit_memset(b: *mut c_void, c: c_int, len: size_t);
2169 pub fn consttime_memequal(a: *const c_void, b: *const c_void, len: size_t) -> c_int;
2170
2171 pub fn setproctitle(fmt: *const c_char, ...);
2172 pub fn mremap(
2173 oldp: *mut c_void,
2174 oldsize: size_t,
2175 newp: *mut c_void,
2176 newsize: size_t,
2177 flags: c_int,
2178 ) -> *mut c_void;
2179
2180 #[link_name = "__sched_rr_get_interval50"]
2181 pub fn sched_rr_get_interval(pid: crate::pid_t, t: *mut crate::timespec) -> c_int;
2182 pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int;
2183 pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int;
2184 pub fn sched_getscheduler(pid: crate::pid_t) -> c_int;
2185 pub fn sched_setscheduler(
2186 pid: crate::pid_t,
2187 policy: c_int,
2188 param: *const crate::sched_param,
2189 ) -> c_int;
2190
2191 #[link_name = "__pollts50"]
2192 pub fn pollts(
2193 fds: *mut crate::pollfd,
2194 nfds: crate::nfds_t,
2195 ts: *const crate::timespec,
2196 sigmask: *const crate::sigset_t,
2197 ) -> c_int;
2198 pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t;
2199
2200 pub fn reboot(mode: c_int, bootstr: *mut c_char) -> c_int;
2201
2202 #[link_name = "___lwp_park60"]
2203 pub fn _lwp_park(
2204 clock: crate::clockid_t,
2205 flags: c_int,
2206 ts: *const crate::timespec,
2207 unpark: crate::lwpid_t,
2208 hint: *const c_void,
2209 unparkhint: *mut c_void,
2210 ) -> c_int;
2211 pub fn _lwp_unpark(lwp: crate::lwpid_t, hint: *const c_void) -> c_int;
2212 pub fn _lwp_unpark_all(
2213 targets: *const crate::lwpid_t,
2214 ntargets: size_t,
2215 hint: *const c_void,
2216 ) -> c_int;
2217 pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int;
2218 pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int;
2219
2220 pub fn eventfd(val: c_uint, flags: c_int) -> c_int;
2221 pub fn eventfd_read(efd: c_int, valp: *mut eventfd_t) -> c_int;
2222 pub fn eventfd_write(efd: c_int, val: eventfd_t) -> c_int;
2223
2224 // Added in `NetBSD` 10.0
2225 pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int;
2226 pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int;
2227 pub fn timerfd_settime(
2228 fd: c_int,
2229 flags: c_int,
2230 new_value: *const crate::itimerspec,
2231 old_value: *mut crate::itimerspec,
2232 ) -> c_int;
2233
2234 pub fn qsort_r(
2235 base: *mut c_void,
2236 num: size_t,
2237 size: size_t,
2238 compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
2239 arg: *mut c_void,
2240 );
2241 }
2242
2243 #[link(name = "rt")]
2244 extern "C" {
2245 pub fn aio_read(aiocbp: *mut aiocb) -> c_int;
2246 pub fn aio_write(aiocbp: *mut aiocb) -> c_int;
2247 pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int;
2248 pub fn aio_error(aiocbp: *const aiocb) -> c_int;
2249 pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t;
2250 #[link_name = "__aio_suspend50"]
2251 pub fn aio_suspend(
2252 aiocb_list: *const *const aiocb,
2253 nitems: c_int,
2254 timeout: *const crate::timespec,
2255 ) -> c_int;
2256 pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int;
2257 pub fn lio_listio(
2258 mode: c_int,
2259 aiocb_list: *const *mut aiocb,
2260 nitems: c_int,
2261 sevp: *mut sigevent,
2262 ) -> c_int;
2263 }
2264
2265 #[link(name = "util")]
2266 extern "C" {
2267 #[link_name = "__getpwent_r50"]
2268 pub fn getpwent_r(
2269 pwd: *mut crate::passwd,
2270 buf: *mut c_char,
2271 buflen: size_t,
2272 result: *mut *mut crate::passwd,
2273 ) -> c_int;
2274 pub fn getgrent_r(
2275 grp: *mut crate::group,
2276 buf: *mut c_char,
2277 buflen: size_t,
2278 result: *mut *mut crate::group,
2279 ) -> c_int;
2280
2281 pub fn efopen(p: *const c_char, m: *const c_char) -> crate::FILE;
2282 pub fn emalloc(n: size_t) -> *mut c_void;
2283 pub fn ecalloc(n: size_t, c: size_t) -> *mut c_void;
2284 pub fn erealloc(p: *mut c_void, n: size_t) -> *mut c_void;
2285 pub fn ereallocarr(p: *mut c_void, n: size_t, s: size_t);
2286 pub fn estrdup(s: *const c_char) -> *mut c_char;
2287 pub fn estrndup(s: *const c_char, len: size_t) -> *mut c_char;
2288 pub fn estrlcpy(dst: *mut c_char, src: *const c_char, len: size_t) -> size_t;
2289 pub fn estrlcat(dst: *mut c_char, src: *const c_char, len: size_t) -> size_t;
2290 pub fn estrtoi(
2291 nptr: *const c_char,
2292 base: c_int,
2293 lo: crate::intmax_t,
2294 hi: crate::intmax_t,
2295 ) -> crate::intmax_t;
2296 pub fn estrtou(
2297 nptr: *const c_char,
2298 base: c_int,
2299 lo: crate::uintmax_t,
2300 hi: crate::uintmax_t,
2301 ) -> crate::uintmax_t;
2302 pub fn easprintf(string: *mut *mut c_char, fmt: *const c_char, ...) -> c_int;
2303 pub fn evasprintf(string: *mut *mut c_char, fmt: *const c_char, ...) -> c_int;
2304 pub fn esetfunc(
2305 cb: Option<unsafe extern "C" fn(c_int, *const c_char, ...)>,
2306 ) -> Option<unsafe extern "C" fn(c_int, *const c_char, ...)>;
2307 pub fn secure_path(path: *const c_char) -> c_int;
2308 pub fn snprintb(buf: *mut c_char, buflen: size_t, fmt: *const c_char, val: u64) -> c_int;
2309 pub fn snprintb_m(
2310 buf: *mut c_char,
2311 buflen: size_t,
2312 fmt: *const c_char,
2313 val: u64,
2314 max: size_t,
2315 ) -> c_int;
2316
2317 pub fn getbootfile() -> *const c_char;
2318 pub fn getbyteorder() -> c_int;
2319 pub fn getdiskrawname(buf: *mut c_char, buflen: size_t, name: *const c_char) -> *const c_char;
2320 pub fn getdiskcookedname(
2321 buf: *mut c_char,
2322 buflen: size_t,
2323 name: *const c_char,
2324 ) -> *const c_char;
2325 pub fn getfsspecname(buf: *mut c_char, buflen: size_t, spec: *const c_char) -> *const c_char;
2326
2327 pub fn strpct(
2328 buf: *mut c_char,
2329 bufsiz: size_t,
2330 numerator: crate::uintmax_t,
2331 denominator: crate::uintmax_t,
2332 precision: size_t,
2333 ) -> *mut c_char;
2334 pub fn strspct(
2335 buf: *mut c_char,
2336 bufsiz: size_t,
2337 numerator: crate::intmax_t,
2338 denominator: crate::intmax_t,
2339 precision: size_t,
2340 ) -> *mut c_char;
2341 #[link_name = "__login50"]
2342 pub fn login(ut: *const crate::utmp);
2343 #[link_name = "__loginx50"]
2344 pub fn loginx(ut: *const crate::utmpx);
2345 pub fn logout(line: *const c_char);
2346 pub fn logoutx(line: *const c_char, status: c_int, tpe: c_int);
2347 pub fn logwtmp(line: *const c_char, name: *const c_char, host: *const c_char);
2348 pub fn logwtmpx(
2349 line: *const c_char,
2350 name: *const c_char,
2351 host: *const c_char,
2352 status: c_int,
2353 tpe: c_int,
2354 );
2355
2356 pub fn getxattr(
2357 path: *const c_char,
2358 name: *const c_char,
2359 value: *mut c_void,
2360 size: size_t,
2361 ) -> ssize_t;
2362 pub fn lgetxattr(
2363 path: *const c_char,
2364 name: *const c_char,
2365 value: *mut c_void,
2366 size: size_t,
2367 ) -> ssize_t;
2368 pub fn fgetxattr(
2369 filedes: c_int,
2370 name: *const c_char,
2371 value: *mut c_void,
2372 size: size_t,
2373 ) -> ssize_t;
2374 pub fn setxattr(
2375 path: *const c_char,
2376 name: *const c_char,
2377 value: *const c_void,
2378 size: size_t,
2379 ) -> c_int;
2380 pub fn lsetxattr(
2381 path: *const c_char,
2382 name: *const c_char,
2383 value: *const c_void,
2384 size: size_t,
2385 ) -> c_int;
2386 pub fn fsetxattr(
2387 filedes: c_int,
2388 name: *const c_char,
2389 value: *const c_void,
2390 size: size_t,
2391 flags: c_int,
2392 ) -> c_int;
2393 pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t;
2394 pub fn llistxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t;
2395 pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t) -> ssize_t;
2396 pub fn removexattr(path: *const c_char, name: *const c_char) -> c_int;
2397 pub fn lremovexattr(path: *const c_char, name: *const c_char) -> c_int;
2398 pub fn fremovexattr(fd: c_int, path: *const c_char, name: *const c_char) -> c_int;
2399
2400 pub fn string_to_flags(
2401 string_p: *mut *mut c_char,
2402 setp: *mut c_ulong,
2403 clrp: *mut c_ulong,
2404 ) -> c_int;
2405 pub fn flags_to_string(flags: c_ulong, def: *const c_char) -> c_int;
2406
2407 pub fn kinfo_getvmmap(pid: crate::pid_t, cntp: *mut size_t) -> *mut kinfo_vmentry;
2408 }
2409
2410 #[link(name = "execinfo")]
2411 extern "C" {
2412 pub fn backtrace(addrlist: *mut *mut c_void, len: size_t) -> size_t;
2413 pub fn backtrace_symbols(addrlist: *const *mut c_void, len: size_t) -> *mut *mut c_char;
2414 pub fn backtrace_symbols_fd(addrlist: *const *mut c_void, len: size_t, fd: c_int) -> c_int;
2415 pub fn backtrace_symbols_fmt(
2416 addrlist: *const *mut c_void,
2417 len: size_t,
2418 fmt: *const c_char,
2419 ) -> *mut *mut c_char;
2420 pub fn backtrace_symbols_fd_fmt(
2421 addrlist: *const *mut c_void,
2422 len: size_t,
2423 fd: c_int,
2424 fmt: *const c_char,
2425 ) -> c_int;
2426 }
2427
2428 cfg_if! {
2429 if #[cfg(target_arch = "aarch64")] {
2430 mod aarch64;
2431 pub use self::aarch64::*;
2432 } else if #[cfg(target_arch = "arm")] {
2433 mod arm;
2434 pub use self::arm::*;
2435 } else if #[cfg(target_arch = "powerpc")] {
2436 mod powerpc;
2437 pub use self::powerpc::*;
2438 } else if #[cfg(target_arch = "sparc64")] {
2439 mod sparc64;
2440 pub use self::sparc64::*;
2441 } else if #[cfg(target_arch = "x86_64")] {
2442 mod x86_64;
2443 pub use self::x86_64::*;
2444 } else if #[cfg(target_arch = "x86")] {
2445 mod x86;
2446 pub use self::x86::*;
2447 } else if #[cfg(target_arch = "mips")] {
2448 mod mips;
2449 pub use self::mips::*;
2450 } else if #[cfg(target_arch = "riscv64")] {
2451 mod riscv64;
2452 pub use self::riscv64::*;
2453 } else {
2454 // Unknown target_arch
2455 }
2456 }