Debian Codegraph @

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