]> git.proxmox.com Git - rustc.git/blame - vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / vendor / libc / src / unix / bsd / netbsdlike / netbsd / mod.rs
CommitLineData
476ff2be
SL
1pub type clock_t = ::c_uint;
2pub type suseconds_t = ::c_int;
3pub type dev_t = u64;
416331ca
XL
4pub type blksize_t = i32;
5pub type fsblkcnt_t = u64;
6pub type fsfilcnt_t = u64;
8bb4bdeb 7pub type idtype_t = ::c_int;
2c00a5a8 8pub type mqd_t = ::c_int;
69743fb6 9type __pthread_spin_t = __cpu_simple_lock_nv_t;
17df50a5 10pub type vm_size_t = ::uintptr_t; // FIXME: deprecated since long time
e74abb32 11pub type lwpid_t = ::c_uint;
dfeec247 12pub type shmatt_t = ::c_uint;
136023e0
XL
13pub type cpuid_t = u64;
14pub type cpuset_t = _cpuset;
15pub type pthread_spin_t = ::c_uchar;
476ff2be 16
5869c6ff
XL
17// elf.h
18
19pub type Elf32_Addr = u32;
20pub type Elf32_Half = u16;
21pub type Elf32_Lword = u64;
22pub type Elf32_Off = u32;
23pub type Elf32_Sword = i32;
24pub type Elf32_Word = u32;
25
26pub type Elf64_Addr = u64;
27pub type Elf64_Half = u16;
28pub type Elf64_Lword = u64;
29pub type Elf64_Off = u64;
30pub type Elf64_Sword = i32;
31pub type Elf64_Sxword = i64;
32pub type Elf64_Word = u32;
33pub type Elf64_Xword = u64;
34
6a06907d
XL
35pub type iconv_t = *mut ::c_void;
36
5869c6ff
XL
37cfg_if! {
38 if #[cfg(target_pointer_width = "64")] {
39 type Elf_Addr = Elf64_Addr;
40 type Elf_Half = Elf64_Half;
41 type Elf_Phdr = Elf64_Phdr;
42 } else if #[cfg(target_pointer_width = "32")] {
43 type Elf_Addr = Elf32_Addr;
44 type Elf_Half = Elf32_Half;
45 type Elf_Phdr = Elf32_Phdr;
46 }
47}
48
416331ca 49impl siginfo_t {
136023e0
XL
50 pub unsafe fn si_addr(&self) -> *mut ::c_void {
51 self.si_addr
52 }
53
416331ca
XL
54 pub unsafe fn si_value(&self) -> ::sigval {
55 #[repr(C)]
56 struct siginfo_timer {
57 _si_signo: ::c_int,
58 _si_errno: ::c_int,
59 _si_code: ::c_int,
60 __pad1: ::c_int,
61 _pid: ::pid_t,
62 _uid: ::uid_t,
63 value: ::sigval,
64 }
65 (*(self as *const siginfo_t as *const siginfo_timer)).value
66 }
136023e0
XL
67
68 pub unsafe fn si_status(&self) -> ::c_int {
69 #[repr(C)]
70 struct siginfo_timer {
71 _si_signo: ::c_int,
72 _si_errno: ::c_int,
73 _si_code: ::c_int,
74 __pad1: ::c_int,
75 _pid: ::pid_t,
76 _uid: ::uid_t,
77 _value: ::sigval,
78 _cpid: ::pid_t,
79 _cuid: ::uid_t,
80 status: ::c_int,
81 }
82 (*(self as *const siginfo_t as *const siginfo_timer)).status
83 }
416331ca
XL
84}
85
476ff2be 86s! {
8bb4bdeb
XL
87 pub struct aiocb {
88 pub aio_offset: ::off_t,
89 pub aio_buf: *mut ::c_void,
90 pub aio_nbytes: ::size_t,
91 pub aio_fildes: ::c_int,
92 pub aio_lio_opcode: ::c_int,
93 pub aio_reqprio: ::c_int,
94 pub aio_sigevent: ::sigevent,
95 _state: ::c_int,
96 _errno: ::c_int,
97 _retval: ::ssize_t
98 }
99
476ff2be
SL
100 pub struct glob_t {
101 pub gl_pathc: ::size_t,
102 pub gl_matchc: ::size_t,
103 pub gl_offs: ::size_t,
104 pub gl_flags: ::c_int,
105 pub gl_pathv: *mut *mut ::c_char,
106
107 __unused3: *mut ::c_void,
108
109 __unused4: *mut ::c_void,
110 __unused5: *mut ::c_void,
111 __unused6: *mut ::c_void,
112 __unused7: *mut ::c_void,
113 __unused8: *mut ::c_void,
114 }
115
2c00a5a8
XL
116 pub struct mq_attr {
117 pub mq_flags: ::c_long,
118 pub mq_maxmsg: ::c_long,
119 pub mq_msgsize: ::c_long,
120 pub mq_curmsgs: ::c_long,
121 }
122
476ff2be
SL
123 pub struct sigset_t {
124 __bits: [u32; 4],
125 }
126
127 pub struct stat {
128 pub st_dev: ::dev_t,
129 pub st_mode: ::mode_t,
130 pub st_ino: ::ino_t,
131 pub st_nlink: ::nlink_t,
132 pub st_uid: ::uid_t,
133 pub st_gid: ::gid_t,
134 pub st_rdev: ::dev_t,
135 pub st_atime: ::time_t,
136 pub st_atimensec: ::c_long,
137 pub st_mtime: ::time_t,
138 pub st_mtimensec: ::c_long,
139 pub st_ctime: ::time_t,
140 pub st_ctimensec: ::c_long,
141 pub st_birthtime: ::time_t,
142 pub st_birthtimensec: ::c_long,
143 pub st_size: ::off_t,
144 pub st_blocks: ::blkcnt_t,
145 pub st_blksize: ::blksize_t,
416331ca
XL
146 pub st_flags: u32,
147 pub st_gen: u32,
148 pub st_spare: [u32; 2],
476ff2be
SL
149 }
150
3dfed10e 151 pub struct addrinfo {
476ff2be
SL
152 pub ai_flags: ::c_int,
153 pub ai_family: ::c_int,
154 pub ai_socktype: ::c_int,
155 pub ai_protocol: ::c_int,
156 pub ai_addrlen: ::socklen_t,
157 pub ai_canonname: *mut ::c_char,
158 pub ai_addr: *mut ::sockaddr,
159 pub ai_next: *mut ::addrinfo,
160 }
161
476ff2be
SL
162 pub struct siginfo_t {
163 pub si_signo: ::c_int,
164 pub si_code: ::c_int,
165 pub si_errno: ::c_int,
166 __pad1: ::c_int,
167 pub si_addr: *mut ::c_void,
168 __pad2: [u64; 13],
169 }
170
171 pub struct pthread_attr_t {
172 pta_magic: ::c_uint,
173 pta_flags: ::c_int,
174 pta_private: *mut ::c_void,
175 }
176
177 pub struct pthread_mutex_t {
178 ptm_magic: ::c_uint,
69743fb6
XL
179 ptm_errorcheck: __pthread_spin_t,
180 #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
181 target_arch = "x86", target_arch = "x86_64"))]
476ff2be 182 ptm_pad1: [u8; 3],
69743fb6
XL
183 // actually a union with a non-unused, 0-initialized field
184 ptm_unused: __pthread_spin_t,
185 #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
186 target_arch = "x86", target_arch = "x86_64"))]
476ff2be
SL
187 ptm_pad2: [u8; 3],
188 ptm_owner: ::pthread_t,
189 ptm_waiters: *mut u8,
190 ptm_recursed: ::c_uint,
191 ptm_spare2: *mut ::c_void,
192 }
193
194 pub struct pthread_mutexattr_t {
195 ptma_magic: ::c_uint,
196 ptma_private: *mut ::c_void,
197 }
198
041b39d2
XL
199 pub struct pthread_rwlockattr_t {
200 ptra_magic: ::c_uint,
201 ptra_private: *mut ::c_void,
202 }
203
476ff2be
SL
204 pub struct pthread_cond_t {
205 ptc_magic: ::c_uint,
69743fb6 206 ptc_lock: __pthread_spin_t,
476ff2be
SL
207 ptc_waiters_first: *mut u8,
208 ptc_waiters_last: *mut u8,
209 ptc_mutex: *mut ::pthread_mutex_t,
210 ptc_private: *mut ::c_void,
211 }
212
213 pub struct pthread_condattr_t {
214 ptca_magic: ::c_uint,
215 ptca_private: *mut ::c_void,
216 }
217
218 pub struct pthread_rwlock_t {
219 ptr_magic: ::c_uint,
69743fb6 220 ptr_interlock: __pthread_spin_t,
476ff2be
SL
221 ptr_rblocked_first: *mut u8,
222 ptr_rblocked_last: *mut u8,
223 ptr_wblocked_first: *mut u8,
224 ptr_wblocked_last: *mut u8,
225 ptr_nreaders: ::c_uint,
226 ptr_owner: ::pthread_t,
227 ptr_private: *mut ::c_void,
228 }
229
136023e0
XL
230 pub struct pthread_spinlock_t {
231 pts_magic: ::c_uint,
232 pts_spin: ::pthread_spin_t,
233 pts_flags: ::c_int,
234 }
235
476ff2be
SL
236 pub struct kevent {
237 pub ident: ::uintptr_t,
416331ca
XL
238 pub filter: u32,
239 pub flags: u32,
240 pub fflags: u32,
241 pub data: i64,
136023e0 242 pub udata: ::intptr_t, /* FIXME: NetBSD 10.0 will finally have same layout as other BSD */
476ff2be
SL
243 }
244
245 pub struct dqblk {
416331ca
XL
246 pub dqb_bhardlimit: u32,
247 pub dqb_bsoftlimit: u32,
248 pub dqb_curblocks: u32,
249 pub dqb_ihardlimit: u32,
250 pub dqb_isoftlimit: u32,
251 pub dqb_curinodes: u32,
252 pub dqb_btime: i32,
253 pub dqb_itime: i32,
476ff2be
SL
254 }
255
256 pub struct Dl_info {
257 pub dli_fname: *const ::c_char,
258 pub dli_fbase: *mut ::c_void,
259 pub dli_sname: *const ::c_char,
260 pub dli_saddr: *const ::c_void,
261 }
262
263 pub struct lconv {
264 pub decimal_point: *mut ::c_char,
265 pub thousands_sep: *mut ::c_char,
266 pub grouping: *mut ::c_char,
267 pub int_curr_symbol: *mut ::c_char,
268 pub currency_symbol: *mut ::c_char,
269 pub mon_decimal_point: *mut ::c_char,
270 pub mon_thousands_sep: *mut ::c_char,
271 pub mon_grouping: *mut ::c_char,
272 pub positive_sign: *mut ::c_char,
273 pub negative_sign: *mut ::c_char,
274 pub int_frac_digits: ::c_char,
275 pub frac_digits: ::c_char,
276 pub p_cs_precedes: ::c_char,
277 pub p_sep_by_space: ::c_char,
278 pub n_cs_precedes: ::c_char,
279 pub n_sep_by_space: ::c_char,
280 pub p_sign_posn: ::c_char,
281 pub n_sign_posn: ::c_char,
282 pub int_p_cs_precedes: ::c_char,
283 pub int_n_cs_precedes: ::c_char,
284 pub int_p_sep_by_space: ::c_char,
285 pub int_n_sep_by_space: ::c_char,
286 pub int_p_sign_posn: ::c_char,
287 pub int_n_sign_posn: ::c_char,
288 }
3b2f2976
XL
289
290 pub struct if_data {
291 pub ifi_type: ::c_uchar,
292 pub ifi_addrlen: ::c_uchar,
293 pub ifi_hdrlen: ::c_uchar,
294 pub ifi_link_state: ::c_int,
295 pub ifi_mtu: u64,
296 pub ifi_metric: u64,
297 pub ifi_baudrate: u64,
298 pub ifi_ipackets: u64,
299 pub ifi_ierrors: u64,
300 pub ifi_opackets: u64,
301 pub ifi_oerrors: u64,
302 pub ifi_collisions: u64,
303 pub ifi_ibytes: u64,
304 pub ifi_obytes: u64,
305 pub ifi_imcasts: u64,
306 pub ifi_omcasts: u64,
307 pub ifi_iqdrops: u64,
308 pub ifi_noproto: u64,
309 pub ifi_lastchange: ::timespec,
310 }
311
312 pub struct if_msghdr {
313 pub ifm_msglen: ::c_ushort,
314 pub ifm_version: ::c_uchar,
315 pub ifm_type: ::c_uchar,
316 pub ifm_addrs: ::c_int,
317 pub ifm_flags: ::c_int,
318 pub ifm_index: ::c_ushort,
319 pub ifm_data: if_data,
320 }
2c00a5a8
XL
321
322 pub struct sockcred {
323 pub sc_pid: ::pid_t,
324 pub sc_uid: ::uid_t,
325 pub sc_euid: ::uid_t,
326 pub sc_gid: ::gid_t,
327 pub sc_egid: ::gid_t,
328 pub sc_ngroups: ::c_int,
329 pub sc_groups: [::gid_t; 1],
330 }
331
cdc7bbd5
XL
332 pub struct unpcbid {
333 pub unp_pid: ::pid_t,
334 pub unp_euid: ::uid_t,
335 pub unp_egid: ::gid_t,
336 }
337
2c00a5a8
XL
338 pub struct sockaddr_dl {
339 pub sdl_len: ::c_uchar,
340 pub sdl_family: ::c_uchar,
341 pub sdl_index: ::c_ushort,
416331ca
XL
342 pub sdl_type: u8,
343 pub sdl_nlen: u8,
344 pub sdl_alen: u8,
345 pub sdl_slen: u8,
2c00a5a8
XL
346 pub sdl_data: [::c_char; 12],
347 }
8faf50e0 348
532ac7d7
XL
349 pub struct mmsghdr {
350 pub msg_hdr: ::msghdr,
351 pub msg_len: ::c_uint,
352 }
dfeec247
XL
353
354 pub struct __exit_status {
355 pub e_termination: u16,
356 pub e_exit: u16,
3dfed10e 357 }
dfeec247
XL
358
359 pub struct shmid_ds {
360 pub shm_perm: ::ipc_perm,
361 pub shm_segsz: ::size_t,
362 pub shm_lpid: ::pid_t,
363 pub shm_cpid: ::pid_t,
364 pub shm_nattch: ::shmatt_t,
365 pub shm_atime: ::time_t,
366 pub shm_dtime: ::time_t,
367 pub shm_ctime: ::time_t,
368 _shm_internal: *mut ::c_void,
369 }
370
371 pub struct utmp {
372 pub ut_line: [::c_char; UT_LINESIZE],
373 pub ut_name: [::c_char; UT_NAMESIZE],
374 pub ut_host: [::c_char; UT_HOSTSIZE],
375 pub ut_time: ::time_t
376 }
377
378 pub struct lastlog {
379 pub ll_line: [::c_char; UT_LINESIZE],
380 pub ll_host: [::c_char; UT_HOSTSIZE],
381 pub ll_time: ::time_t
382 }
ba9703b0
XL
383
384 pub struct timex {
385 pub modes: ::c_uint,
386 pub offset: ::c_long,
387 pub freq: ::c_long,
388 pub maxerror: ::c_long,
389 pub esterror: ::c_long,
390 pub status: ::c_int,
391 pub constant: ::c_long,
392 pub precision: ::c_long,
393 pub tolerance: ::c_long,
394 pub ppsfreq: ::c_long,
395 pub jitter: ::c_long,
396 pub shift: ::c_int,
397 pub stabil: ::c_long,
398 pub jitcnt: ::c_long,
399 pub calcnt: ::c_long,
400 pub errcnt: ::c_long,
401 pub stbcnt: ::c_long,
402 }
403
404 pub struct ntptimeval {
405 pub time: ::timespec,
406 pub maxerror: ::c_long,
407 pub esterror: ::c_long,
408 pub tai: ::c_long,
409 pub time_state: ::c_int,
410 }
411
5869c6ff
XL
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
17df50a5
XL
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
5869c6ff
XL
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 }
136023e0
XL
458
459 pub struct _cpuset {
460 bits: [u32; 0]
461 }
462
463 pub struct accept_filter_arg {
464 pub af_name: [::c_char; 16],
465 af_arg: [[::c_char; 10]; 24],
466 }
467
468 pub struct sched_param {
469 pub sched_priority: ::c_int,
470 }
532ac7d7
XL
471}
472
473s_no_extra_traits! {
dfeec247
XL
474
475 pub struct utmpx {
476 pub ut_name: [::c_char; _UTX_USERSIZE],
477 pub ut_id: [::c_char; _UTX_IDSIZE],
478 pub ut_line: [::c_char; _UTX_LINESIZE],
479 pub ut_host: [::c_char; _UTX_HOSTSIZE],
480 pub ut_session: u16,
481 pub ut_type: u16,
482 pub ut_pid: ::pid_t,
17df50a5 483 pub ut_exit: __exit_status, // FIXME: when anonymous struct are supported
dfeec247
XL
484 pub ut_ss: sockaddr_storage,
485 pub ut_tv: ::timeval,
486 pub ut_pad: [u8; _UTX_PADSIZE],
487 }
488
489 pub struct lastlogx {
490 pub ll_tv: ::timeval,
491 pub ll_line: [::c_char; _UTX_LINESIZE],
492 pub ll_host: [::c_char; _UTX_HOSTSIZE],
493 pub ll_ss: sockaddr_storage,
494 }
495
8faf50e0
XL
496 pub struct in_pktinfo {
497 pub ipi_addr: ::in_addr,
498 pub ipi_ifindex: ::c_uint,
499 }
b7449926 500
b7449926
XL
501 pub struct arphdr {
502 pub ar_hrd: u16,
503 pub ar_pro: u16,
504 pub ar_hln: u8,
505 pub ar_pln: u8,
506 pub ar_op: u16,
507 }
532ac7d7 508
532ac7d7
XL
509 pub struct in_addr {
510 pub s_addr: ::in_addr_t,
511 }
512
513 pub struct ip_mreq {
514 pub imr_multiaddr: in_addr,
515 pub imr_interface: in_addr,
516 }
517
518 pub struct sockaddr_in {
519 pub sin_len: u8,
520 pub sin_family: ::sa_family_t,
521 pub sin_port: ::in_port_t,
522 pub sin_addr: ::in_addr,
416331ca 523 pub sin_zero: [i8; 8],
532ac7d7
XL
524 }
525
526 pub struct dirent {
527 pub d_fileno: ::ino_t,
528 pub d_reclen: u16,
529 pub d_namlen: u16,
530 pub d_type: u8,
531 pub d_name: [::c_char; 512],
532 }
533
534 pub struct statvfs {
535 pub f_flag: ::c_ulong,
536 pub f_bsize: ::c_ulong,
537 pub f_frsize: ::c_ulong,
538 pub f_iosize: ::c_ulong,
539
540 pub f_blocks: ::fsblkcnt_t,
541 pub f_bfree: ::fsblkcnt_t,
542 pub f_bavail: ::fsblkcnt_t,
543 pub f_bresvd: ::fsblkcnt_t,
544
545 pub f_files: ::fsfilcnt_t,
546 pub f_ffree: ::fsfilcnt_t,
547 pub f_favail: ::fsfilcnt_t,
548 pub f_fresvd: ::fsfilcnt_t,
549
416331ca
XL
550 pub f_syncreads: u64,
551 pub f_syncwrites: u64,
532ac7d7 552
416331ca
XL
553 pub f_asyncreads: u64,
554 pub f_asyncwrites: u64,
532ac7d7
XL
555
556 pub f_fsidx: ::fsid_t,
557 pub f_fsid: ::c_ulong,
558 pub f_namemax: ::c_ulong,
559 pub f_owner: ::uid_t,
560
416331ca 561 pub f_spare: [u32; 4],
532ac7d7
XL
562
563 pub f_fstypename: [::c_char; 32],
564 pub f_mntonname: [::c_char; 1024],
565 pub f_mntfromname: [::c_char; 1024],
566 }
567
568 pub struct sockaddr_storage {
569 pub ss_len: u8,
570 pub ss_family: ::sa_family_t,
571 __ss_pad1: [u8; 6],
572 __ss_pad2: i64,
573 __ss_pad3: [u8; 112],
574 }
416331ca
XL
575
576 pub struct sigevent {
577 pub sigev_notify: ::c_int,
578 pub sigev_signo: ::c_int,
579 pub sigev_value: ::sigval,
580 __unused1: *mut ::c_void, //actually a function pointer
581 pub sigev_notify_attributes: *mut ::c_void
582 }
532ac7d7
XL
583}
584
585cfg_if! {
586 if #[cfg(feature = "extra_traits")] {
dfeec247
XL
587 impl PartialEq for utmpx {
588 fn eq(&self, other: &utmpx) -> bool {
589 self.ut_type == other.ut_type
590 && self.ut_pid == other.ut_pid
591 && self.ut_name == other.ut_name
592 && self.ut_line == other.ut_line
593 && self.ut_id == other.ut_id
594 && self.ut_exit == other.ut_exit
595 && self.ut_session == other.ut_session
596 && self.ut_tv == other.ut_tv
597 && self.ut_ss == other.ut_ss
598 && self
599 .ut_pad
600 .iter()
601 .zip(other.ut_pad.iter())
602 .all(|(a,b)| a == b)
603 && self
604 .ut_host
605 .iter()
606 .zip(other.ut_host.iter())
607 .all(|(a,b)| a == b)
608 }
609 }
610
611 impl Eq for utmpx {}
612
613 impl ::fmt::Debug for utmpx {
614 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
615 f.debug_struct("utmpx")
616 .field("ut_name", &self.ut_name)
617 .field("ut_id", &self.ut_id)
618 .field("ut_line", &self.ut_line)
619 // FIXME .field("ut_host", &self.ut_host)
620 .field("ut_session", &self.ut_session)
621 .field("ut_type", &self.ut_type)
622 .field("ut_pid", &self.ut_pid)
623 .field("ut_exit", &self.ut_exit)
624 .field("ut_ss", &self.ut_ss)
625 .field("ut_tv", &self.ut_tv)
626 // FIXME .field("ut_pad", &self.ut_pad)
627 .finish()
628 }
629 }
630
631 impl ::hash::Hash for utmpx {
632 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
633 self.ut_name.hash(state);
634 self.ut_type.hash(state);
635 self.ut_pid.hash(state);
636 self.ut_line.hash(state);
637 self.ut_id.hash(state);
638 self.ut_host.hash(state);
639 self.ut_exit.hash(state);
640 self.ut_session.hash(state);
641 self.ut_tv.hash(state);
642 self.ut_ss.hash(state);
643 self.ut_pad.hash(state);
644 }
645 }
646
647 impl PartialEq for lastlogx {
648 fn eq(&self, other: &lastlogx) -> bool {
649 self.ll_tv == other.ll_tv
650 && self.ll_line == other.ll_line
651 && self.ll_ss == other.ll_ss
652 && self
653 .ll_host
654 .iter()
655 .zip(other.ll_host.iter())
656 .all(|(a,b)| a == b)
657 }
658 }
659
660 impl Eq for lastlogx {}
661
662 impl ::fmt::Debug for lastlogx {
663 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
664 f.debug_struct("lastlogx")
665 .field("ll_tv", &self.ll_tv)
666 .field("ll_line", &self.ll_line)
667 // FIXME.field("ll_host", &self.ll_host)
668 .field("ll_ss", &self.ll_ss)
669 .finish()
670 }
671 }
672
673 impl ::hash::Hash for lastlogx {
674 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
675 self.ll_tv.hash(state);
676 self.ll_line.hash(state);
677 self.ll_host.hash(state);
678 self.ll_ss.hash(state);
679 }
680 }
681
532ac7d7
XL
682 impl PartialEq for in_pktinfo {
683 fn eq(&self, other: &in_pktinfo) -> bool {
684 self.ipi_addr == other.ipi_addr
685 && self.ipi_ifindex == other.ipi_ifindex
686 }
687 }
688 impl Eq for in_pktinfo {}
689 impl ::fmt::Debug for in_pktinfo {
690 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
691 f.debug_struct("in_pktinfo")
692 .field("ipi_addr", &self.ipi_addr)
693 .field("ipi_ifindex", &self.ipi_ifindex)
694 .finish()
695 }
696 }
697 impl ::hash::Hash for in_pktinfo {
698 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
699 self.ipi_addr.hash(state);
700 self.ipi_ifindex.hash(state);
701 }
702 }
703
704 impl PartialEq for arphdr {
705 fn eq(&self, other: &arphdr) -> bool {
706 self.ar_hrd == other.ar_hrd
707 && self.ar_pro == other.ar_pro
708 && self.ar_hln == other.ar_hln
709 && self.ar_pln == other.ar_pln
710 && self.ar_op == other.ar_op
711 }
712 }
713 impl Eq for arphdr {}
714 impl ::fmt::Debug for arphdr {
715 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
716 let ar_hrd = self.ar_hrd;
717 let ar_pro = self.ar_pro;
718 let ar_op = self.ar_op;
719 f.debug_struct("arphdr")
720 .field("ar_hrd", &ar_hrd)
721 .field("ar_pro", &ar_pro)
722 .field("ar_hln", &self.ar_hln)
723 .field("ar_pln", &self.ar_pln)
724 .field("ar_op", &ar_op)
725 .finish()
726 }
727 }
728 impl ::hash::Hash for arphdr {
729 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
730 let ar_hrd = self.ar_hrd;
731 let ar_pro = self.ar_pro;
732 let ar_op = self.ar_op;
733 ar_hrd.hash(state);
734 ar_pro.hash(state);
735 self.ar_hln.hash(state);
736 self.ar_pln.hash(state);
737 ar_op.hash(state);
738 }
739 }
740
741 impl PartialEq for in_addr {
742 fn eq(&self, other: &in_addr) -> bool {
743 self.s_addr == other.s_addr
744 }
745 }
746 impl Eq for in_addr {}
747 impl ::fmt::Debug for in_addr {
748 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
749 let s_addr = self.s_addr;
750 f.debug_struct("in_addr")
751 .field("s_addr", &s_addr)
752 .finish()
753 }
754 }
755 impl ::hash::Hash for in_addr {
756 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
757 let s_addr = self.s_addr;
758 s_addr.hash(state);
759 }
760 }
761
762 impl PartialEq for ip_mreq {
763 fn eq(&self, other: &ip_mreq) -> bool {
764 self.imr_multiaddr == other.imr_multiaddr
765 && self.imr_interface == other.imr_interface
766 }
767 }
768 impl Eq for ip_mreq {}
769 impl ::fmt::Debug for ip_mreq {
770 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
771 f.debug_struct("ip_mreq")
772 .field("imr_multiaddr", &self.imr_multiaddr)
773 .field("imr_interface", &self.imr_interface)
774 .finish()
775 }
776 }
777 impl ::hash::Hash for ip_mreq {
778 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
779 self.imr_multiaddr.hash(state);
780 self.imr_interface.hash(state);
781 }
782 }
783
784 impl PartialEq for sockaddr_in {
785 fn eq(&self, other: &sockaddr_in) -> bool {
786 self.sin_len == other.sin_len
787 && self.sin_family == other.sin_family
788 && self.sin_port == other.sin_port
789 && self.sin_addr == other.sin_addr
790 && self.sin_zero == other.sin_zero
791 }
792 }
793 impl Eq for sockaddr_in {}
794 impl ::fmt::Debug for sockaddr_in {
795 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
796 f.debug_struct("sockaddr_in")
797 .field("sin_len", &self.sin_len)
798 .field("sin_family", &self.sin_family)
799 .field("sin_port", &self.sin_port)
800 .field("sin_addr", &self.sin_addr)
801 .field("sin_zero", &self.sin_zero)
802 .finish()
803 }
804 }
805 impl ::hash::Hash for sockaddr_in {
806 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
807 self.sin_len.hash(state);
808 self.sin_family.hash(state);
809 self.sin_port.hash(state);
810 self.sin_addr.hash(state);
811 self.sin_zero.hash(state);
812 }
813 }
814
815 impl PartialEq for dirent {
816 fn eq(&self, other: &dirent) -> bool {
817 self.d_fileno == other.d_fileno
818 && self.d_reclen == other.d_reclen
819 && self.d_namlen == other.d_namlen
820 && self.d_type == other.d_type
821 && self
822 .d_name
823 .iter()
824 .zip(other.d_name.iter())
825 .all(|(a,b)| a == b)
826 }
827 }
828 impl Eq for dirent {}
829 impl ::fmt::Debug for dirent {
830 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
831 f.debug_struct("dirent")
832 .field("d_fileno", &self.d_fileno)
833 .field("d_reclen", &self.d_reclen)
834 .field("d_namlen", &self.d_namlen)
835 .field("d_type", &self.d_type)
836 // FIXME: .field("d_name", &self.d_name)
837 .finish()
838 }
839 }
840 impl ::hash::Hash for dirent {
841 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
842 self.d_fileno.hash(state);
843 self.d_reclen.hash(state);
844 self.d_namlen.hash(state);
845 self.d_type.hash(state);
846 self.d_name.hash(state);
847 }
848 }
849
850 impl PartialEq for statvfs {
851 fn eq(&self, other: &statvfs) -> bool {
852 self.f_flag == other.f_flag
853 && self.f_bsize == other.f_bsize
854 && self.f_frsize == other.f_frsize
855 && self.f_iosize == other.f_iosize
856 && self.f_blocks == other.f_blocks
857 && self.f_bfree == other.f_bfree
858 && self.f_bavail == other.f_bavail
859 && self.f_bresvd == other.f_bresvd
860 && self.f_files == other.f_files
861 && self.f_ffree == other.f_ffree
862 && self.f_favail == other.f_favail
863 && self.f_fresvd == other.f_fresvd
864 && self.f_syncreads == other.f_syncreads
865 && self.f_syncwrites == other.f_syncwrites
866 && self.f_asyncreads == other.f_asyncreads
867 && self.f_asyncwrites == other.f_asyncwrites
868 && self.f_fsidx == other.f_fsidx
869 && self.f_fsid == other.f_fsid
870 && self.f_namemax == other.f_namemax
871 && self.f_owner == other.f_owner
872 && self.f_spare == other.f_spare
873 && self.f_fstypename == other.f_fstypename
874 && self
875 .f_mntonname
876 .iter()
877 .zip(other.f_mntonname.iter())
878 .all(|(a,b)| a == b)
879 && self
880 .f_mntfromname
881 .iter()
882 .zip(other.f_mntfromname.iter())
883 .all(|(a,b)| a == b)
884 }
885 }
886 impl Eq for statvfs {}
887 impl ::fmt::Debug for statvfs {
888 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
889 f.debug_struct("statvfs")
890 .field("f_flag", &self.f_flag)
891 .field("f_bsize", &self.f_bsize)
892 .field("f_frsize", &self.f_frsize)
893 .field("f_iosize", &self.f_iosize)
894 .field("f_blocks", &self.f_blocks)
895 .field("f_bfree", &self.f_bfree)
896 .field("f_bavail", &self.f_bavail)
897 .field("f_bresvd", &self.f_bresvd)
898 .field("f_files", &self.f_files)
899 .field("f_ffree", &self.f_ffree)
900 .field("f_favail", &self.f_favail)
901 .field("f_fresvd", &self.f_fresvd)
902 .field("f_syncreads", &self.f_syncreads)
903 .field("f_syncwrites", &self.f_syncwrites)
904 .field("f_asyncreads", &self.f_asyncreads)
905 .field("f_asyncwrites", &self.f_asyncwrites)
906 .field("f_fsidx", &self.f_fsidx)
907 .field("f_fsid", &self.f_fsid)
908 .field("f_namemax", &self.f_namemax)
909 .field("f_owner", &self.f_owner)
910 .field("f_spare", &self.f_spare)
911 .field("f_fstypename", &self.f_fstypename)
912 // FIXME: .field("f_mntonname", &self.f_mntonname)
913 // FIXME: .field("f_mntfromname", &self.f_mntfromname)
914 .finish()
915 }
916 }
917 impl ::hash::Hash for statvfs {
918 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
919 self.f_flag.hash(state);
920 self.f_bsize.hash(state);
921 self.f_frsize.hash(state);
922 self.f_iosize.hash(state);
923 self.f_blocks.hash(state);
924 self.f_bfree.hash(state);
925 self.f_bavail.hash(state);
926 self.f_bresvd.hash(state);
927 self.f_files.hash(state);
928 self.f_ffree.hash(state);
929 self.f_favail.hash(state);
930 self.f_fresvd.hash(state);
931 self.f_syncreads.hash(state);
932 self.f_syncwrites.hash(state);
933 self.f_asyncreads.hash(state);
934 self.f_asyncwrites.hash(state);
935 self.f_fsidx.hash(state);
936 self.f_fsid.hash(state);
937 self.f_namemax.hash(state);
938 self.f_owner.hash(state);
939 self.f_spare.hash(state);
940 self.f_fstypename.hash(state);
941 self.f_mntonname.hash(state);
942 self.f_mntfromname.hash(state);
943 }
944 }
945
946 impl PartialEq for sockaddr_storage {
947 fn eq(&self, other: &sockaddr_storage) -> bool {
948 self.ss_len == other.ss_len
949 && self.ss_family == other.ss_family
950 && self.__ss_pad1 == other.__ss_pad1
951 && self.__ss_pad2 == other.__ss_pad2
952 && self
953 .__ss_pad3
954 .iter()
955 .zip(other.__ss_pad3.iter())
956 .all(|(a,b)| a == b)
957 }
958 }
959 impl Eq for sockaddr_storage {}
960 impl ::fmt::Debug for sockaddr_storage {
961 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
962 f.debug_struct("sockaddr_storage")
963 .field("ss_len", &self.ss_len)
964 .field("ss_family", &self.ss_family)
965 .field("__ss_pad1", &self.__ss_pad1)
966 .field("__ss_pad2", &self.__ss_pad2)
967 // FIXME: .field("__ss_pad3", &self.__ss_pad3)
968 .finish()
969 }
970 }
971 impl ::hash::Hash for sockaddr_storage {
972 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
973 self.ss_len.hash(state);
974 self.ss_family.hash(state);
975 self.__ss_pad1.hash(state);
976 self.__ss_pad2.hash(state);
977 self.__ss_pad3.hash(state);
978 }
979 }
416331ca
XL
980
981 impl PartialEq for sigevent {
982 fn eq(&self, other: &sigevent) -> bool {
983 self.sigev_notify == other.sigev_notify
984 && self.sigev_signo == other.sigev_signo
985 && self.sigev_value == other.sigev_value
986 && self.sigev_notify_attributes
987 == other.sigev_notify_attributes
988 }
989 }
990 impl Eq for sigevent {}
991 impl ::fmt::Debug for sigevent {
992 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
993 f.debug_struct("sigevent")
994 .field("sigev_notify", &self.sigev_notify)
995 .field("sigev_signo", &self.sigev_signo)
996 .field("sigev_value", &self.sigev_value)
997 .field("sigev_notify_attributes",
998 &self.sigev_notify_attributes)
999 .finish()
1000 }
1001 }
1002 impl ::hash::Hash for sigevent {
1003 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1004 self.sigev_notify.hash(state);
1005 self.sigev_signo.hash(state);
1006 self.sigev_value.hash(state);
1007 self.sigev_notify_attributes.hash(state);
1008 }
1009 }
532ac7d7 1010 }
476ff2be
SL
1011}
1012
7cac9316
XL
1013pub const AT_FDCWD: ::c_int = -100;
1014pub const AT_EACCESS: ::c_int = 0x100;
1015pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200;
1016pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
1017pub const AT_REMOVEDIR: ::c_int = 0x800;
1018
69743fb6
XL
1019pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
1020pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
1021
ba9703b0
XL
1022pub const LC_COLLATE_MASK: ::c_int = 1 << ::LC_COLLATE;
1023pub const LC_CTYPE_MASK: ::c_int = 1 << ::LC_CTYPE;
1024pub const LC_MONETARY_MASK: ::c_int = 1 << ::LC_MONETARY;
1025pub const LC_NUMERIC_MASK: ::c_int = 1 << ::LC_NUMERIC;
1026pub const LC_TIME_MASK: ::c_int = 1 << ::LC_TIME;
1027pub const LC_MESSAGES_MASK: ::c_int = 1 << ::LC_MESSAGES;
476ff2be
SL
1028pub const LC_ALL_MASK: ::c_int = !0;
1029
1030pub const ERA: ::nl_item = 52;
1031pub const ERA_D_FMT: ::nl_item = 53;
1032pub const ERA_D_T_FMT: ::nl_item = 54;
1033pub const ERA_T_FMT: ::nl_item = 55;
1034pub const ALT_DIGITS: ::nl_item = 56;
1035
1036pub const O_CLOEXEC: ::c_int = 0x400000;
1037pub const O_ALT_IO: ::c_int = 0x40000;
1038pub const O_NOSIGPIPE: ::c_int = 0x1000000;
1039pub const O_SEARCH: ::c_int = 0x800000;
476ff2be 1040pub const O_DIRECTORY: ::c_int = 0x200000;
e74abb32
XL
1041pub const O_DIRECT: ::c_int = 0x00080000;
1042pub const O_RSYNC: ::c_int = 0x00020000;
476ff2be 1043
e74abb32
XL
1044pub const MS_SYNC: ::c_int = 0x4;
1045pub const MS_INVALIDATE: ::c_int = 0x2;
476ff2be 1046
fc512014
XL
1047// Here because they are not present on OpenBSD
1048// (https://github.com/openbsd/src/blob/master/sys/sys/resource.h)
1049pub const RLIMIT_SBSIZE: ::c_int = 9;
1050pub const RLIMIT_AS: ::c_int = 10;
1051pub const RLIMIT_NTHR: ::c_int = 11;
1052
e74abb32 1053#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
476ff2be
SL
1054pub const RLIM_NLIMITS: ::c_int = 12;
1055
2c00a5a8
XL
1056pub const EIDRM: ::c_int = 82;
1057pub const ENOMSG: ::c_int = 83;
1058pub const EOVERFLOW: ::c_int = 84;
1059pub const EILSEQ: ::c_int = 85;
1060pub const ENOTSUP: ::c_int = 86;
1061pub const ECANCELED: ::c_int = 87;
1062pub const EBADMSG: ::c_int = 88;
1063pub const ENODATA: ::c_int = 89;
1064pub const ENOSR: ::c_int = 90;
1065pub const ENOSTR: ::c_int = 91;
1066pub const ETIME: ::c_int = 92;
1067pub const ENOATTR: ::c_int = 93;
1068pub const EMULTIHOP: ::c_int = 94;
1069pub const ENOLINK: ::c_int = 95;
1070pub const EPROTO: ::c_int = 96;
1071pub const ELAST: ::c_int = 96;
476ff2be 1072
e74abb32 1073pub const F_DUPFD_CLOEXEC: ::c_int = 12;
476ff2be
SL
1074pub const F_CLOSEM: ::c_int = 10;
1075pub const F_GETNOSIGPIPE: ::c_int = 13;
1076pub const F_SETNOSIGPIPE: ::c_int = 14;
1077pub const F_MAXFD: ::c_int = 11;
1078
0731742a
XL
1079pub const IP_RECVDSTADDR: ::c_int = 7;
1080pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;
1081pub const IP_RECVIF: ::c_int = 20;
8faf50e0
XL
1082pub const IP_PKTINFO: ::c_int = 25;
1083pub const IP_RECVPKTINFO: ::c_int = 26;
476ff2be
SL
1084pub const IPV6_JOIN_GROUP: ::c_int = 12;
1085pub const IPV6_LEAVE_GROUP: ::c_int = 13;
1086
e74abb32 1087pub const TCP_KEEPIDLE: ::c_int = 3;
b7449926 1088pub const TCP_KEEPINTVL: ::c_int = 5;
e74abb32
XL
1089pub const TCP_KEEPCNT: ::c_int = 6;
1090pub const TCP_KEEPINIT: ::c_int = 7;
1091pub const TCP_INFO: ::c_int = 9;
1092pub const TCP_MD5SIG: ::c_int = 0x10;
1093pub const TCP_CONGCTL: ::c_int = 0x20;
b7449926 1094
8bb4bdeb
XL
1095pub const SOCK_CONN_DGRAM: ::c_int = 6;
1096pub const SOCK_DCCP: ::c_int = SOCK_CONN_DGRAM;
1097pub const SOCK_NOSIGPIPE: ::c_int = 0x40000000;
1098pub const SOCK_FLAGS_MASK: ::c_int = 0xf0000000;
1099
476ff2be
SL
1100pub const SO_SNDTIMEO: ::c_int = 0x100b;
1101pub const SO_RCVTIMEO: ::c_int = 0x100c;
8bb4bdeb
XL
1102pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
1103pub const SO_TIMESTAMP: ::c_int = 0x2000;
1104pub const SO_OVERFLOWED: ::c_int = 0x1009;
1105pub const SO_NOHEADER: ::c_int = 0x100a;
1106
cdc7bbd5
XL
1107// http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/un.h?annotate
1108pub const LOCAL_OCREDS: ::c_int = 0x0001; // pass credentials to receiver
1109pub const LOCAL_CONNWAIT: ::c_int = 0x0002; // connects block until accepted
1110pub const LOCAL_PEEREID: ::c_int = 0x0003; // get peer identification
1111pub const LOCAL_CREDS: ::c_int = 0x0004; // pass credentials to receiver
1112
ff7c6d11
XL
1113// https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373
1114pub const IFF_UP: ::c_int = 0x0001; // interface is up
1115pub const IFF_BROADCAST: ::c_int = 0x0002; // broadcast address valid
1116pub const IFF_DEBUG: ::c_int = 0x0004; // turn on debugging
1117pub const IFF_LOOPBACK: ::c_int = 0x0008; // is a loopback net
1118pub const IFF_POINTOPOINT: ::c_int = 0x0010; // interface is point-to-point link
1119pub const IFF_NOTRAILERS: ::c_int = 0x0020; // avoid use of trailers
1120pub const IFF_RUNNING: ::c_int = 0x0040; // resources allocated
1121pub const IFF_NOARP: ::c_int = 0x0080; // no address resolution protocol
1122pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets
1123pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets
1124pub const IFF_OACTIVE: ::c_int = 0x0400; // transmission in progress
1125pub const IFF_SIMPLEX: ::c_int = 0x0800; // can't hear own transmissions
1126pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
1127pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
1128pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
1129pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
1130
ea8adc8c
XL
1131// sys/netinet/in.h
1132// Protocols (RFC 1700)
1133// NOTE: These are in addition to the constants defined in src/unix/mod.rs
1134
1135// IPPROTO_IP defined in src/unix/mod.rs
1136/// Hop-by-hop option header
1137pub const IPPROTO_HOPOPTS: ::c_int = 0;
1138// IPPROTO_ICMP defined in src/unix/mod.rs
1139/// group mgmt protocol
1140pub const IPPROTO_IGMP: ::c_int = 2;
1141/// gateway^2 (deprecated)
1142pub const IPPROTO_GGP: ::c_int = 3;
1143/// for compatibility
1144pub const IPPROTO_IPIP: ::c_int = 4;
1145// IPPROTO_TCP defined in src/unix/mod.rs
1146/// exterior gateway protocol
1147pub const IPPROTO_EGP: ::c_int = 8;
1148/// pup
1149pub const IPPROTO_PUP: ::c_int = 12;
1150// IPPROTO_UDP defined in src/unix/mod.rs
1151/// xns idp
1152pub const IPPROTO_IDP: ::c_int = 22;
1153/// tp-4 w/ class negotiation
1154pub const IPPROTO_TP: ::c_int = 29;
1155/// DCCP
1156pub const IPPROTO_DCCP: ::c_int = 33;
1157// IPPROTO_IPV6 defined in src/unix/mod.rs
1158/// IP6 routing header
1159pub const IPPROTO_ROUTING: ::c_int = 43;
1160/// IP6 fragmentation header
1161pub const IPPROTO_FRAGMENT: ::c_int = 44;
1162/// resource reservation
1163pub const IPPROTO_RSVP: ::c_int = 46;
1164/// General Routing Encap.
1165pub const IPPROTO_GRE: ::c_int = 47;
1166/// IP6 Encap Sec. Payload
1167pub const IPPROTO_ESP: ::c_int = 50;
1168/// IP6 Auth Header
1169pub const IPPROTO_AH: ::c_int = 51;
1170/// IP Mobility RFC 2004
1171pub const IPPROTO_MOBILE: ::c_int = 55;
1172/// IPv6 ICMP
1173pub const IPPROTO_IPV6_ICMP: ::c_int = 58;
1174// IPPROTO_ICMPV6 defined in src/unix/mod.rs
1175/// IP6 no next header
1176pub const IPPROTO_NONE: ::c_int = 59;
1177/// IP6 destination option
1178pub const IPPROTO_DSTOPTS: ::c_int = 60;
1179/// ISO cnlp
1180pub const IPPROTO_EON: ::c_int = 80;
1181/// Ethernet-in-IP
1182pub const IPPROTO_ETHERIP: ::c_int = 97;
1183/// encapsulation header
1184pub const IPPROTO_ENCAP: ::c_int = 98;
1185/// Protocol indep. multicast
1186pub const IPPROTO_PIM: ::c_int = 103;
1187/// IP Payload Comp. Protocol
1188pub const IPPROTO_IPCOMP: ::c_int = 108;
1189/// VRRP RFC 2338
1190pub const IPPROTO_VRRP: ::c_int = 112;
1191/// Common Address Resolution Protocol
1192pub const IPPROTO_CARP: ::c_int = 112;
1193/// L2TPv3
1194// TEMP: Disabled for now; this constant was added to NetBSD on 2017-02-16,
1195// but isn't yet supported by the NetBSD rumprun kernel image used for
1196// libc testing.
1197//pub const IPPROTO_L2TP: ::c_int = 115;
1198/// SCTP
1199pub const IPPROTO_SCTP: ::c_int = 132;
1200/// PFSYNC
1201pub const IPPROTO_PFSYNC: ::c_int = 240;
1202pub const IPPROTO_MAX: ::c_int = 256;
1203
1204/// last return value of *_input(), meaning "all job for this pkt is done".
1205pub const IPPROTO_DONE: ::c_int = 257;
1206
1207/// sysctl placeholder for (FAST_)IPSEC
1208pub const CTL_IPPROTO_IPSEC: ::c_int = 258;
1209
8bb4bdeb
XL
1210pub const AF_OROUTE: ::c_int = 17;
1211pub const AF_ARP: ::c_int = 28;
1212pub const pseudo_AF_KEY: ::c_int = 29;
1213pub const pseudo_AF_HDRCMPLT: ::c_int = 30;
1214pub const AF_BLUETOOTH: ::c_int = 31;
1215pub const AF_IEEE80211: ::c_int = 32;
1216pub const AF_MPLS: ::c_int = 33;
1217pub const AF_ROUTE: ::c_int = 34;
8bb4bdeb
XL
1218pub const NET_RT_DUMP: ::c_int = 1;
1219pub const NET_RT_FLAGS: ::c_int = 2;
532ac7d7
XL
1220pub const NET_RT_OOOIFLIST: ::c_int = 3;
1221pub const NET_RT_OOIFLIST: ::c_int = 4;
1222pub const NET_RT_OIFLIST: ::c_int = 5;
1223pub const NET_RT_IFLIST: ::c_int = 6;
1224pub const NET_RT_MAXID: ::c_int = 7;
8bb4bdeb
XL
1225
1226pub const PF_OROUTE: ::c_int = AF_OROUTE;
1227pub const PF_ARP: ::c_int = AF_ARP;
1228pub const PF_KEY: ::c_int = pseudo_AF_KEY;
1229pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
1230pub const PF_MPLS: ::c_int = AF_MPLS;
1231pub const PF_ROUTE: ::c_int = AF_ROUTE;
8bb4bdeb
XL
1232
1233pub const MSG_NBIO: ::c_int = 0x1000;
1234pub const MSG_WAITFORONE: ::c_int = 0x2000;
1235pub const MSG_NOTIFICATION: ::c_int = 0x4000;
1236
1237pub const SCM_TIMESTAMP: ::c_int = 0x08;
1238pub const SCM_CREDS: ::c_int = 0x10;
476ff2be 1239
e74abb32 1240pub const O_DSYNC: ::c_int = 0x10000;
476ff2be 1241
e74abb32
XL
1242pub const MAP_RENAME: ::c_int = 0x20;
1243pub const MAP_NORESERVE: ::c_int = 0x40;
1244pub const MAP_HASSEMAPHORE: ::c_int = 0x200;
476ff2be 1245pub const MAP_WIRED: ::c_int = 0x800;
136023e0
XL
1246// mremap flag
1247pub const MAP_REMAPDUP: ::c_int = 0x004;
476ff2be 1248
abe05a73
XL
1249pub const DCCP_TYPE_REQUEST: ::c_int = 0;
1250pub const DCCP_TYPE_RESPONSE: ::c_int = 1;
1251pub const DCCP_TYPE_DATA: ::c_int = 2;
1252pub const DCCP_TYPE_ACK: ::c_int = 3;
e74abb32 1253pub const DCCP_TYPE_DATAACK: ::c_int = 4;
abe05a73
XL
1254pub const DCCP_TYPE_CLOSEREQ: ::c_int = 5;
1255pub const DCCP_TYPE_CLOSE: ::c_int = 6;
1256pub const DCCP_TYPE_RESET: ::c_int = 7;
1257pub const DCCP_TYPE_MOVE: ::c_int = 8;
1258
1259pub const DCCP_FEATURE_CC: ::c_int = 1;
1260pub const DCCP_FEATURE_ECN: ::c_int = 2;
e74abb32 1261pub const DCCP_FEATURE_ACKRATIO: ::c_int = 3;
abe05a73 1262pub const DCCP_FEATURE_ACKVECTOR: ::c_int = 4;
e74abb32 1263pub const DCCP_FEATURE_MOBILITY: ::c_int = 5;
abe05a73
XL
1264pub const DCCP_FEATURE_LOSSWINDOW: ::c_int = 6;
1265pub const DCCP_FEATURE_CONN_NONCE: ::c_int = 8;
e74abb32 1266pub const DCCP_FEATURE_IDENTREG: ::c_int = 7;
abe05a73
XL
1267
1268pub const DCCP_OPT_PADDING: ::c_int = 0;
1269pub const DCCP_OPT_DATA_DISCARD: ::c_int = 1;
1270pub const DCCP_OPT_SLOW_RECV: ::c_int = 2;
1271pub const DCCP_OPT_BUF_CLOSED: ::c_int = 3;
1272pub const DCCP_OPT_CHANGE_L: ::c_int = 32;
1273pub const DCCP_OPT_CONFIRM_L: ::c_int = 33;
1274pub const DCCP_OPT_CHANGE_R: ::c_int = 34;
1275pub const DCCP_OPT_CONFIRM_R: ::c_int = 35;
1276pub const DCCP_OPT_INIT_COOKIE: ::c_int = 36;
1277pub const DCCP_OPT_NDP_COUNT: ::c_int = 37;
1278pub const DCCP_OPT_ACK_VECTOR0: ::c_int = 38;
1279pub const DCCP_OPT_ACK_VECTOR1: ::c_int = 39;
1280pub const DCCP_OPT_RECV_BUF_DROPS: ::c_int = 40;
1281pub const DCCP_OPT_TIMESTAMP: ::c_int = 41;
1282pub const DCCP_OPT_TIMESTAMP_ECHO: ::c_int = 42;
1283pub const DCCP_OPT_ELAPSEDTIME: ::c_int = 43;
1284pub const DCCP_OPT_DATACHECKSUM: ::c_int = 44;
1285
1286pub const DCCP_REASON_UNSPEC: ::c_int = 0;
1287pub const DCCP_REASON_CLOSED: ::c_int = 1;
1288pub const DCCP_REASON_INVALID: ::c_int = 2;
1289pub const DCCP_REASON_OPTION_ERR: ::c_int = 3;
1290pub const DCCP_REASON_FEA_ERR: ::c_int = 4;
1291pub const DCCP_REASON_CONN_REF: ::c_int = 5;
1292pub const DCCP_REASON_BAD_SNAME: ::c_int = 6;
1293pub const DCCP_REASON_BAD_COOKIE: ::c_int = 7;
1294pub const DCCP_REASON_INV_MOVE: ::c_int = 8;
1295pub const DCCP_REASON_UNANSW_CH: ::c_int = 10;
1296pub const DCCP_REASON_FRUITLESS_NEG: ::c_int = 11;
1297
1298pub const DCCP_CCID: ::c_int = 1;
1299pub const DCCP_CSLEN: ::c_int = 2;
1300pub const DCCP_MAXSEG: ::c_int = 4;
1301pub const DCCP_SERVICE: ::c_int = 8;
1302
1303pub const DCCP_NDP_LIMIT: ::c_int = 16;
1304pub const DCCP_SEQ_NUM_LIMIT: ::c_int = 16777216;
1305pub const DCCP_MAX_OPTIONS: ::c_int = 32;
1306pub const DCCP_MAX_PKTS: ::c_int = 100;
1307
e74abb32
XL
1308pub const _PC_LINK_MAX: ::c_int = 1;
1309pub const _PC_MAX_CANON: ::c_int = 2;
1310pub const _PC_MAX_INPUT: ::c_int = 3;
1311pub const _PC_NAME_MAX: ::c_int = 4;
1312pub const _PC_PATH_MAX: ::c_int = 5;
1313pub const _PC_PIPE_BUF: ::c_int = 6;
1314pub const _PC_CHOWN_RESTRICTED: ::c_int = 7;
1315pub const _PC_NO_TRUNC: ::c_int = 8;
1316pub const _PC_VDISABLE: ::c_int = 9;
1317pub const _PC_SYNC_IO: ::c_int = 10;
1318pub const _PC_FILESIZEBITS: ::c_int = 11;
1319pub const _PC_SYMLINK_MAX: ::c_int = 12;
1320pub const _PC_2_SYMLINKS: ::c_int = 13;
1321pub const _PC_ACL_EXTENDED: ::c_int = 14;
1322pub const _PC_MIN_HOLE_SIZE: ::c_int = 15;
1323
1324pub const _SC_SYNCHRONIZED_IO: ::c_int = 31;
1325pub const _SC_IOV_MAX: ::c_int = 32;
1326pub const _SC_MAPPED_FILES: ::c_int = 33;
1327pub const _SC_MEMLOCK: ::c_int = 34;
1328pub const _SC_MEMLOCK_RANGE: ::c_int = 35;
1329pub const _SC_MEMORY_PROTECTION: ::c_int = 36;
1330pub const _SC_LOGIN_NAME_MAX: ::c_int = 37;
1331pub const _SC_MONOTONIC_CLOCK: ::c_int = 38;
1332pub const _SC_CLK_TCK: ::c_int = 39;
1333pub const _SC_ATEXIT_MAX: ::c_int = 40;
1334pub const _SC_THREADS: ::c_int = 41;
1335pub const _SC_SEMAPHORES: ::c_int = 42;
1336pub const _SC_BARRIERS: ::c_int = 43;
1337pub const _SC_TIMERS: ::c_int = 44;
1338pub const _SC_SPIN_LOCKS: ::c_int = 45;
1339pub const _SC_READER_WRITER_LOCKS: ::c_int = 46;
1340pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 47;
1341pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 48;
1342pub const _SC_CLOCK_SELECTION: ::c_int = 49;
1343pub const _SC_ASYNCHRONOUS_IO: ::c_int = 50;
1344pub const _SC_AIO_LISTIO_MAX: ::c_int = 51;
1345pub const _SC_AIO_MAX: ::c_int = 52;
1346pub const _SC_MESSAGE_PASSING: ::c_int = 53;
1347pub const _SC_MQ_OPEN_MAX: ::c_int = 54;
1348pub const _SC_MQ_PRIO_MAX: ::c_int = 55;
1349pub const _SC_PRIORITY_SCHEDULING: ::c_int = 56;
1350pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 57;
1351pub const _SC_THREAD_KEYS_MAX: ::c_int = 58;
1352pub const _SC_THREAD_STACK_MIN: ::c_int = 59;
1353pub const _SC_THREAD_THREADS_MAX: ::c_int = 60;
1354pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 61;
1355pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 62;
1356pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 63;
1357pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 64;
1358pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 65;
1359pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 66;
1360pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 67;
1361pub const _SC_TTY_NAME_MAX: ::c_int = 68;
1362pub const _SC_HOST_NAME_MAX: ::c_int = 69;
1363pub const _SC_PASS_MAX: ::c_int = 70;
1364pub const _SC_REGEXP: ::c_int = 71;
1365pub const _SC_SHELL: ::c_int = 72;
1366pub const _SC_SYMLOOP_MAX: ::c_int = 73;
1367pub const _SC_V6_ILP32_OFF32: ::c_int = 74;
1368pub const _SC_V6_ILP32_OFFBIG: ::c_int = 75;
1369pub const _SC_V6_LP64_OFF64: ::c_int = 76;
1370pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 77;
1371pub const _SC_2_PBS: ::c_int = 80;
1372pub const _SC_2_PBS_ACCOUNTING: ::c_int = 81;
1373pub const _SC_2_PBS_CHECKPOINT: ::c_int = 82;
1374pub const _SC_2_PBS_LOCATE: ::c_int = 83;
1375pub const _SC_2_PBS_MESSAGE: ::c_int = 84;
1376pub const _SC_2_PBS_TRACK: ::c_int = 85;
1377pub const _SC_SPAWN: ::c_int = 86;
1378pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 87;
1379pub const _SC_TIMER_MAX: ::c_int = 88;
1380pub const _SC_SEM_NSEMS_MAX: ::c_int = 89;
1381pub const _SC_CPUTIME: ::c_int = 90;
1382pub const _SC_THREAD_CPUTIME: ::c_int = 91;
1383pub const _SC_DELAYTIMER_MAX: ::c_int = 92;
041b39d2
XL
1384// These two variables will be supported in NetBSD 8.0
1385// pub const _SC_SIGQUEUE_MAX : ::c_int = 93;
1386// pub const _SC_REALTIME_SIGNALS : ::c_int = 94;
e74abb32
XL
1387pub const _SC_PHYS_PAGES: ::c_int = 121;
1388pub const _SC_NPROCESSORS_CONF: ::c_int = 1001;
1389pub const _SC_NPROCESSORS_ONLN: ::c_int = 1002;
1390pub const _SC_SCHED_RT_TS: ::c_int = 2001;
1391pub const _SC_SCHED_PRI_MIN: ::c_int = 2002;
1392pub const _SC_SCHED_PRI_MAX: ::c_int = 2003;
476ff2be
SL
1393
1394pub const FD_SETSIZE: usize = 0x100;
1395
1396pub const ST_NOSUID: ::c_ulong = 8;
1397
e74abb32
XL
1398pub const BIOCGRSIG: ::c_ulong = 0x40044272;
1399pub const BIOCSRSIG: ::c_ulong = 0x80044273;
1400pub const BIOCSDLT: ::c_ulong = 0x80044278;
1401pub const BIOCGSEESENT: ::c_ulong = 0x40044276;
1402pub const BIOCSSEESENT: ::c_ulong = 0x80044277;
1403
ba9703b0
XL
1404//<sys/timex.h>
1405pub const NTP_API: ::c_int = 4;
1406pub const MAXPHASE: ::c_long = 500000000;
1407pub const MAXFREQ: ::c_long = 500000;
1408pub const MINSEC: ::c_int = 256;
1409pub const MAXSEC: ::c_int = 2048;
1410pub const NANOSECOND: ::c_long = 1000000000;
1411pub const SCALE_PPM: ::c_int = 65;
1412pub const MAXTC: ::c_int = 10;
1413pub const MOD_OFFSET: ::c_uint = 0x0001;
1414pub const MOD_FREQUENCY: ::c_uint = 0x0002;
1415pub const MOD_MAXERROR: ::c_uint = 0x0004;
1416pub const MOD_ESTERROR: ::c_uint = 0x0008;
1417pub const MOD_STATUS: ::c_uint = 0x0010;
1418pub const MOD_TIMECONST: ::c_uint = 0x0020;
1419pub const MOD_PPSMAX: ::c_uint = 0x0040;
1420pub const MOD_TAI: ::c_uint = 0x0080;
1421pub const MOD_MICRO: ::c_uint = 0x1000;
1422pub const MOD_NANO: ::c_uint = 0x2000;
1423pub const MOD_CLKB: ::c_uint = 0x4000;
1424pub const MOD_CLKA: ::c_uint = 0x8000;
1425pub const STA_PLL: ::c_int = 0x0001;
1426pub const STA_PPSFREQ: ::c_int = 0x0002;
1427pub const STA_PPSTIME: ::c_int = 0x0004;
1428pub const STA_FLL: ::c_int = 0x0008;
1429pub const STA_INS: ::c_int = 0x0010;
1430pub const STA_DEL: ::c_int = 0x0020;
1431pub const STA_UNSYNC: ::c_int = 0x0040;
1432pub const STA_FREQHOLD: ::c_int = 0x0080;
1433pub const STA_PPSSIGNAL: ::c_int = 0x0100;
1434pub const STA_PPSJITTER: ::c_int = 0x0200;
1435pub const STA_PPSWANDER: ::c_int = 0x0400;
1436pub const STA_PPSERROR: ::c_int = 0x0800;
1437pub const STA_CLOCKERR: ::c_int = 0x1000;
1438pub const STA_NANO: ::c_int = 0x2000;
1439pub const STA_MODE: ::c_int = 0x4000;
1440pub const STA_CLK: ::c_int = 0x8000;
1441pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
1442 | STA_PPSJITTER
1443 | STA_PPSWANDER
1444 | STA_PPSERROR
1445 | STA_CLOCKERR
1446 | STA_NANO
1447 | STA_MODE
1448 | STA_CLK;
1449pub const TIME_OK: ::c_int = 0;
1450pub const TIME_INS: ::c_int = 1;
1451pub const TIME_DEL: ::c_int = 2;
1452pub const TIME_OOP: ::c_int = 3;
1453pub const TIME_WAIT: ::c_int = 4;
1454pub const TIME_ERROR: ::c_int = 5;
1455
532ac7d7
XL
1456cfg_if! {
1457 if #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
1458 target_arch = "x86", target_arch = "x86_64"))] {
e74abb32
XL
1459 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t
1460 = pthread_mutex_t {
532ac7d7
XL
1461 ptm_magic: 0x33330003,
1462 ptm_errorcheck: 0,
1463 ptm_pad1: [0; 3],
1464 ptm_unused: 0,
1465 ptm_pad2: [0; 3],
1466 ptm_waiters: 0 as *mut _,
1467 ptm_owner: 0,
1468 ptm_recursed: 0,
1469 ptm_spare2: 0 as *mut _,
1470 };
1471 } else {
e74abb32
XL
1472 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t
1473 = pthread_mutex_t {
532ac7d7
XL
1474 ptm_magic: 0x33330003,
1475 ptm_errorcheck: 0,
1476 ptm_unused: 0,
1477 ptm_waiters: 0 as *mut _,
1478 ptm_owner: 0,
1479 ptm_recursed: 0,
1480 ptm_spare2: 0 as *mut _,
1481 };
1482 }
1483}
69743fb6 1484
476ff2be
SL
1485pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1486 ptc_magic: 0x55550005,
1487 ptc_lock: 0,
1488 ptc_waiters_first: 0 as *mut _,
1489 ptc_waiters_last: 0 as *mut _,
1490 ptc_mutex: 0 as *mut _,
1491 ptc_private: 0 as *mut _,
1492};
1493pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1494 ptr_magic: 0x99990009,
1495 ptr_interlock: 0,
1496 ptr_rblocked_first: 0 as *mut _,
1497 ptr_rblocked_last: 0 as *mut _,
1498 ptr_wblocked_first: 0 as *mut _,
1499 ptr_wblocked_last: 0 as *mut _,
1500 ptr_nreaders: 0,
1501 ptr_owner: 0,
1502 ptr_private: 0 as *mut _,
1503};
1504pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
1505pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
1506pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
1507pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
1508
416331ca
XL
1509pub const EVFILT_AIO: u32 = 2;
1510pub const EVFILT_PROC: u32 = 4;
1511pub const EVFILT_READ: u32 = 0;
1512pub const EVFILT_SIGNAL: u32 = 5;
1513pub const EVFILT_TIMER: u32 = 6;
1514pub const EVFILT_VNODE: u32 = 3;
1515pub const EVFILT_WRITE: u32 = 1;
1516
1517pub const EV_ADD: u32 = 0x1;
1518pub const EV_DELETE: u32 = 0x2;
1519pub const EV_ENABLE: u32 = 0x4;
1520pub const EV_DISABLE: u32 = 0x8;
1521pub const EV_ONESHOT: u32 = 0x10;
1522pub const EV_CLEAR: u32 = 0x20;
1523pub const EV_RECEIPT: u32 = 0x40;
1524pub const EV_DISPATCH: u32 = 0x80;
1525pub const EV_FLAG1: u32 = 0x2000;
1526pub const EV_ERROR: u32 = 0x4000;
1527pub const EV_EOF: u32 = 0x8000;
1528pub const EV_SYSFLAGS: u32 = 0xf000;
1529
1530pub const NOTE_LOWAT: u32 = 0x00000001;
1531pub const NOTE_DELETE: u32 = 0x00000001;
1532pub const NOTE_WRITE: u32 = 0x00000002;
1533pub const NOTE_EXTEND: u32 = 0x00000004;
1534pub const NOTE_ATTRIB: u32 = 0x00000008;
1535pub const NOTE_LINK: u32 = 0x00000010;
1536pub const NOTE_RENAME: u32 = 0x00000020;
1537pub const NOTE_REVOKE: u32 = 0x00000040;
1538pub const NOTE_EXIT: u32 = 0x80000000;
1539pub const NOTE_FORK: u32 = 0x40000000;
1540pub const NOTE_EXEC: u32 = 0x20000000;
1541pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1542pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1543pub const NOTE_TRACK: u32 = 0x00000001;
1544pub const NOTE_TRACKERR: u32 = 0x00000002;
1545pub const NOTE_CHILD: u32 = 0x00000004;
476ff2be 1546
e74abb32 1547pub const TMP_MAX: ::c_uint = 308915776;
476ff2be
SL
1548
1549pub const NI_MAXHOST: ::socklen_t = 1025;
136023e0
XL
1550pub const NI_MAXSERV: ::socklen_t = 32;
1551
1552pub const NI_NOFQDN: ::c_int = 0x00000001;
1553pub const NI_NUMERICHOST: ::c_int = 0x000000002;
1554pub const NI_NAMEREQD: ::c_int = 0x000000004;
1555pub const NI_NUMERICSERV: ::c_int = 0x000000008;
1556pub const NI_DGRAM: ::c_int = 0x00000010;
1557pub const NI_WITHSCOPEID: ::c_int = 0x00000020;
1558pub const NI_NUMERICSCOPE: ::c_int = 0x00000040;
476ff2be
SL
1559
1560pub const RTLD_NOLOAD: ::c_int = 0x2000;
1561pub const RTLD_LOCAL: ::c_int = 0x200;
1562
1563pub const CTL_MAXNAME: ::c_int = 12;
1564pub const SYSCTL_NAMELEN: ::c_int = 32;
1565pub const SYSCTL_DEFSIZE: ::c_int = 8;
1566pub const CTLTYPE_NODE: ::c_int = 1;
1567pub const CTLTYPE_INT: ::c_int = 2;
1568pub const CTLTYPE_STRING: ::c_int = 3;
1569pub const CTLTYPE_QUAD: ::c_int = 4;
1570pub const CTLTYPE_STRUCT: ::c_int = 5;
1571pub const CTLTYPE_BOOL: ::c_int = 6;
1572pub const CTLFLAG_READONLY: ::c_int = 0x00000000;
1573pub const CTLFLAG_READWRITE: ::c_int = 0x00000070;
1574pub const CTLFLAG_ANYWRITE: ::c_int = 0x00000080;
1575pub const CTLFLAG_PRIVATE: ::c_int = 0x00000100;
1576pub const CTLFLAG_PERMANENT: ::c_int = 0x00000200;
1577pub const CTLFLAG_OWNDATA: ::c_int = 0x00000400;
1578pub const CTLFLAG_IMMEDIATE: ::c_int = 0x00000800;
1579pub const CTLFLAG_HEX: ::c_int = 0x00001000;
1580pub const CTLFLAG_ROOT: ::c_int = 0x00002000;
1581pub const CTLFLAG_ANYNUMBER: ::c_int = 0x00004000;
1582pub const CTLFLAG_HIDDEN: ::c_int = 0x00008000;
1583pub const CTLFLAG_ALIAS: ::c_int = 0x00010000;
1584pub const CTLFLAG_MMAP: ::c_int = 0x00020000;
1585pub const CTLFLAG_OWNDESC: ::c_int = 0x00040000;
1586pub const CTLFLAG_UNSIGNED: ::c_int = 0x00080000;
1587pub const SYSCTL_VERS_MASK: ::c_int = 0xff000000;
1588pub const SYSCTL_VERS_0: ::c_int = 0x00000000;
1589pub const SYSCTL_VERS_1: ::c_int = 0x01000000;
1590pub const SYSCTL_VERSION: ::c_int = SYSCTL_VERS_1;
1591pub const CTL_EOL: ::c_int = -1;
1592pub const CTL_QUERY: ::c_int = -2;
1593pub const CTL_CREATE: ::c_int = -3;
1594pub const CTL_CREATESYM: ::c_int = -4;
1595pub const CTL_DESTROY: ::c_int = -5;
1596pub const CTL_MMAP: ::c_int = -6;
1597pub const CTL_DESCRIBE: ::c_int = -7;
1598pub const CTL_UNSPEC: ::c_int = 0;
1599pub const CTL_KERN: ::c_int = 1;
1600pub const CTL_VM: ::c_int = 2;
1601pub const CTL_VFS: ::c_int = 3;
1602pub const CTL_NET: ::c_int = 4;
1603pub const CTL_DEBUG: ::c_int = 5;
1604pub const CTL_HW: ::c_int = 6;
1605pub const CTL_MACHDEP: ::c_int = 7;
1606pub const CTL_USER: ::c_int = 8;
1607pub const CTL_DDB: ::c_int = 9;
1608pub const CTL_PROC: ::c_int = 10;
1609pub const CTL_VENDOR: ::c_int = 11;
1610pub const CTL_EMUL: ::c_int = 12;
1611pub const CTL_SECURITY: ::c_int = 13;
1612pub const CTL_MAXID: ::c_int = 14;
1613pub const KERN_OSTYPE: ::c_int = 1;
1614pub const KERN_OSRELEASE: ::c_int = 2;
1615pub const KERN_OSREV: ::c_int = 3;
1616pub const KERN_VERSION: ::c_int = 4;
1617pub const KERN_MAXVNODES: ::c_int = 5;
1618pub const KERN_MAXPROC: ::c_int = 6;
1619pub const KERN_MAXFILES: ::c_int = 7;
1620pub const KERN_ARGMAX: ::c_int = 8;
1621pub const KERN_SECURELVL: ::c_int = 9;
1622pub const KERN_HOSTNAME: ::c_int = 10;
1623pub const KERN_HOSTID: ::c_int = 11;
1624pub const KERN_CLOCKRATE: ::c_int = 12;
1625pub const KERN_VNODE: ::c_int = 13;
1626pub const KERN_PROC: ::c_int = 14;
1627pub const KERN_FILE: ::c_int = 15;
1628pub const KERN_PROF: ::c_int = 16;
1629pub const KERN_POSIX1: ::c_int = 17;
1630pub const KERN_NGROUPS: ::c_int = 18;
1631pub const KERN_JOB_CONTROL: ::c_int = 19;
1632pub const KERN_SAVED_IDS: ::c_int = 20;
1633pub const KERN_OBOOTTIME: ::c_int = 21;
1634pub const KERN_DOMAINNAME: ::c_int = 22;
1635pub const KERN_MAXPARTITIONS: ::c_int = 23;
1636pub const KERN_RAWPARTITION: ::c_int = 24;
1637pub const KERN_NTPTIME: ::c_int = 25;
1638pub const KERN_TIMEX: ::c_int = 26;
1639pub const KERN_AUTONICETIME: ::c_int = 27;
1640pub const KERN_AUTONICEVAL: ::c_int = 28;
1641pub const KERN_RTC_OFFSET: ::c_int = 29;
1642pub const KERN_ROOT_DEVICE: ::c_int = 30;
1643pub const KERN_MSGBUFSIZE: ::c_int = 31;
1644pub const KERN_FSYNC: ::c_int = 32;
1645pub const KERN_OLDSYSVMSG: ::c_int = 33;
1646pub const KERN_OLDSYSVSEM: ::c_int = 34;
1647pub const KERN_OLDSYSVSHM: ::c_int = 35;
1648pub const KERN_OLDSHORTCORENAME: ::c_int = 36;
1649pub const KERN_SYNCHRONIZED_IO: ::c_int = 37;
1650pub const KERN_IOV_MAX: ::c_int = 38;
1651pub const KERN_MBUF: ::c_int = 39;
1652pub const KERN_MAPPED_FILES: ::c_int = 40;
1653pub const KERN_MEMLOCK: ::c_int = 41;
1654pub const KERN_MEMLOCK_RANGE: ::c_int = 42;
1655pub const KERN_MEMORY_PROTECTION: ::c_int = 43;
1656pub const KERN_LOGIN_NAME_MAX: ::c_int = 44;
1657pub const KERN_DEFCORENAME: ::c_int = 45;
1658pub const KERN_LOGSIGEXIT: ::c_int = 46;
1659pub const KERN_PROC2: ::c_int = 47;
1660pub const KERN_PROC_ARGS: ::c_int = 48;
1661pub const KERN_FSCALE: ::c_int = 49;
1662pub const KERN_CCPU: ::c_int = 50;
1663pub const KERN_CP_TIME: ::c_int = 51;
1664pub const KERN_OLDSYSVIPC_INFO: ::c_int = 52;
1665pub const KERN_MSGBUF: ::c_int = 53;
1666pub const KERN_CONSDEV: ::c_int = 54;
1667pub const KERN_MAXPTYS: ::c_int = 55;
1668pub const KERN_PIPE: ::c_int = 56;
1669pub const KERN_MAXPHYS: ::c_int = 57;
1670pub const KERN_SBMAX: ::c_int = 58;
1671pub const KERN_TKSTAT: ::c_int = 59;
1672pub const KERN_MONOTONIC_CLOCK: ::c_int = 60;
1673pub const KERN_URND: ::c_int = 61;
1674pub const KERN_LABELSECTOR: ::c_int = 62;
1675pub const KERN_LABELOFFSET: ::c_int = 63;
1676pub const KERN_LWP: ::c_int = 64;
1677pub const KERN_FORKFSLEEP: ::c_int = 65;
1678pub const KERN_POSIX_THREADS: ::c_int = 66;
1679pub const KERN_POSIX_SEMAPHORES: ::c_int = 67;
1680pub const KERN_POSIX_BARRIERS: ::c_int = 68;
1681pub const KERN_POSIX_TIMERS: ::c_int = 69;
1682pub const KERN_POSIX_SPIN_LOCKS: ::c_int = 70;
1683pub const KERN_POSIX_READER_WRITER_LOCKS: ::c_int = 71;
1684pub const KERN_DUMP_ON_PANIC: ::c_int = 72;
1685pub const KERN_SOMAXKVA: ::c_int = 73;
1686pub const KERN_ROOT_PARTITION: ::c_int = 74;
1687pub const KERN_DRIVERS: ::c_int = 75;
1688pub const KERN_BUF: ::c_int = 76;
1689pub const KERN_FILE2: ::c_int = 77;
1690pub const KERN_VERIEXEC: ::c_int = 78;
1691pub const KERN_CP_ID: ::c_int = 79;
1692pub const KERN_HARDCLOCK_TICKS: ::c_int = 80;
1693pub const KERN_ARND: ::c_int = 81;
1694pub const KERN_SYSVIPC: ::c_int = 82;
1695pub const KERN_BOOTTIME: ::c_int = 83;
1696pub const KERN_EVCNT: ::c_int = 84;
1697pub const KERN_MAXID: ::c_int = 85;
1698pub const KERN_PROC_ALL: ::c_int = 0;
1699pub const KERN_PROC_PID: ::c_int = 1;
1700pub const KERN_PROC_PGRP: ::c_int = 2;
1701pub const KERN_PROC_SESSION: ::c_int = 3;
1702pub const KERN_PROC_TTY: ::c_int = 4;
1703pub const KERN_PROC_UID: ::c_int = 5;
1704pub const KERN_PROC_RUID: ::c_int = 6;
1705pub const KERN_PROC_GID: ::c_int = 7;
1706pub const KERN_PROC_RGID: ::c_int = 8;
abe05a73
XL
1707pub const KERN_PROC_ARGV: ::c_int = 1;
1708pub const KERN_PROC_NARGV: ::c_int = 2;
1709pub const KERN_PROC_ENV: ::c_int = 3;
1710pub const KERN_PROC_NENV: ::c_int = 4;
1711pub const KERN_PROC_PATHNAME: ::c_int = 5;
476ff2be 1712
2c00a5a8
XL
1713pub const EAI_AGAIN: ::c_int = 2;
1714pub const EAI_BADFLAGS: ::c_int = 3;
1715pub const EAI_FAIL: ::c_int = 4;
1716pub const EAI_FAMILY: ::c_int = 5;
1717pub const EAI_MEMORY: ::c_int = 6;
1718pub const EAI_NODATA: ::c_int = 7;
1719pub const EAI_NONAME: ::c_int = 8;
1720pub const EAI_SERVICE: ::c_int = 9;
1721pub const EAI_SOCKTYPE: ::c_int = 10;
476ff2be 1722pub const EAI_SYSTEM: ::c_int = 11;
2c00a5a8 1723pub const EAI_OVERFLOW: ::c_int = 14;
476ff2be 1724
8bb4bdeb
XL
1725pub const AIO_CANCELED: ::c_int = 1;
1726pub const AIO_NOTCANCELED: ::c_int = 2;
1727pub const AIO_ALLDONE: ::c_int = 3;
1728pub const LIO_NOP: ::c_int = 0;
1729pub const LIO_WRITE: ::c_int = 1;
1730pub const LIO_READ: ::c_int = 2;
1731pub const LIO_WAIT: ::c_int = 1;
1732pub const LIO_NOWAIT: ::c_int = 0;
1733
1734pub const SIGEV_NONE: ::c_int = 0;
1735pub const SIGEV_SIGNAL: ::c_int = 1;
1736pub const SIGEV_THREAD: ::c_int = 2;
1737
1738pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED
1739pub const WCONTINUED: ::c_int = 0x00000010;
1740pub const WEXITED: ::c_int = 0x000000020;
1741pub const WNOWAIT: ::c_int = 0x00010000;
1742
1743pub const P_ALL: idtype_t = 0;
1744pub const P_PID: idtype_t = 1;
1745pub const P_PGID: idtype_t = 4;
1746
e74abb32
XL
1747pub const UTIME_OMIT: c_long = 1073741822;
1748pub const UTIME_NOW: c_long = 1073741823;
1749
7cac9316
XL
1750pub const B460800: ::speed_t = 460800;
1751pub const B921600: ::speed_t = 921600;
1752
041b39d2
XL
1753pub const ONOCR: ::tcflag_t = 0x20;
1754pub const ONLRET: ::tcflag_t = 0x40;
1755pub const CDTRCTS: ::tcflag_t = 0x00020000;
1756pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS;
1757
dfeec247
XL
1758// pub const _PATH_UTMPX: &[::c_char; 14] = b"/var/run/utmpx";
1759// pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx";
1760// pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx";
1761// pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update";
1762pub const UT_NAMESIZE: usize = 8;
1763pub const UT_LINESIZE: usize = 8;
1764pub const UT_HOSTSIZE: usize = 16;
1765pub const _UTX_USERSIZE: usize = 32;
1766pub const _UTX_LINESIZE: usize = 32;
1767pub const _UTX_PADSIZE: usize = 40;
1768pub const _UTX_IDSIZE: usize = 4;
1769pub const _UTX_HOSTSIZE: usize = 256;
1770pub const EMPTY: u16 = 0;
1771pub const RUN_LVL: u16 = 1;
1772pub const BOOT_TIME: u16 = 2;
1773pub const OLD_TIME: u16 = 3;
1774pub const NEW_TIME: u16 = 4;
1775pub const INIT_PROCESS: u16 = 5;
1776pub const LOGIN_PROCESS: u16 = 6;
1777pub const USER_PROCESS: u16 = 7;
1778pub const DEAD_PROCESS: u16 = 8;
1779pub const ACCOUNTING: u16 = 9;
1780pub const SIGNATURE: u16 = 10;
1781pub const DOWN_TIME: u16 = 11;
1782
ea8adc8c
XL
1783pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
1784pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
1785
532ac7d7
XL
1786// Uncomment on next NetBSD release
1787// pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
1788// pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
532ac7d7
XL
1789pub const OFIOGETBMAP: ::c_ulong = 0xc004667a;
1790pub const FIOGETBMAP: ::c_ulong = 0xc008667a;
1791pub const FIONWRITE: ::c_ulong = 0x40046679;
1792pub const FIONSPACE: ::c_ulong = 0x40046678;
1793pub const FIBMAP: ::c_ulong = 0xc008667a;
1794
e74abb32 1795pub const SIGSTKSZ: ::size_t = 40960;
8faf50e0 1796
f035d41b
XL
1797pub const REG_ENOSYS: ::c_int = 17;
1798
69743fb6
XL
1799pub const PT_DUMPCORE: ::c_int = 12;
1800pub const PT_LWPINFO: ::c_int = 13;
1801pub const PT_SYSCALL: ::c_int = 14;
1802pub const PT_SYSCALLEMU: ::c_int = 15;
1803pub const PT_SET_EVENT_MASK: ::c_int = 16;
1804pub const PT_GET_EVENT_MASK: ::c_int = 17;
1805pub const PT_GET_PROCESS_STATE: ::c_int = 18;
1806pub const PT_FIRSTMACH: ::c_int = 32;
1807
1808// Flags for chflags(2)
e74abb32
XL
1809pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
1810pub const SF_LOG: ::c_ulong = 0x00400000;
69743fb6
XL
1811pub const SF_SNAPINVAL: ::c_ulong = 0x00800000;
1812
cdc7bbd5
XL
1813const_fn! {
1814 {const} fn _ALIGN(p: usize) -> usize {
1815 (p + _ALIGNBYTES) & !_ALIGNBYTES
1816 }
532ac7d7
XL
1817}
1818
041b39d2 1819f! {
532ac7d7
XL
1820 pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
1821 (cmsg as *mut ::c_uchar)
1822 .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
1823 }
1824
1825 pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1826 _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
1827 }
1828
1829 pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
1830 -> *mut ::cmsghdr
1831 {
1832 if cmsg.is_null() {
1833 return ::CMSG_FIRSTHDR(mhdr);
1834 };
1835 let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
1836 + _ALIGN(::mem::size_of::<::cmsghdr>());
1837 let max = (*mhdr).msg_control as usize
1838 + (*mhdr).msg_controllen as usize;
1839 if next > max {
1840 0 as *mut ::cmsghdr
1841 } else {
1842 (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
1843 as *mut ::cmsghdr
1844 }
1845 }
1846
cdc7bbd5 1847 pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
532ac7d7
XL
1848 (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
1849 as ::c_uint
1850 }
1851
532ac7d7
XL
1852 // dirfd() is a macro on netbsd to access
1853 // the first field of the struct where dirp points to:
1854 // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
041b39d2 1855 pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
2c00a5a8 1856 *(dirp as *const ::c_int)
041b39d2 1857 }
ea8adc8c 1858
2c00a5a8
XL
1859 pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
1860 let ngrps = if ngrps > 0 {
1861 ngrps - 1
1862 } else {
1863 0
1864 };
532ac7d7 1865 ::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
2c00a5a8 1866 }
041b39d2
XL
1867}
1868
29967ef6
XL
1869safe_f! {
1870 pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
1871 status >> 8
1872 }
1873
1874 pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
1875 (status & 0o177) != 0o177 && (status & 0o177) != 0
1876 }
1877
1878 pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
1879 (status & 0o177) == 0o177
1880 }
1881
1882 pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
1883 status == 0xffff
1884 }
1885}
1886
ba9703b0
XL
1887extern "C" {
1888 pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
1889 pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
fc512014
XL
1890 pub fn clock_nanosleep(
1891 clk_id: ::clockid_t,
1892 flags: ::c_int,
1893 rqtp: *const ::timespec,
1894 rmtp: *mut ::timespec,
1895 ) -> ::c_int;
136023e0
XL
1896
1897 pub fn reallocarr(ptr: *mut ::c_void, number: ::size_t, size: ::size_t) -> ::c_int;
ba9703b0
XL
1898}
1899
532ac7d7 1900#[link(name = "rt")]
e74abb32 1901extern "C" {
8bb4bdeb
XL
1902 pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
1903 pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
1904 pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
1905 pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
1906 pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
1907 #[link_name = "__aio_suspend50"]
e74abb32
XL
1908 pub fn aio_suspend(
1909 aiocb_list: *const *const aiocb,
1910 nitems: ::c_int,
1911 timeout: *const ::timespec,
1912 ) -> ::c_int;
8bb4bdeb 1913 pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
e74abb32
XL
1914 pub fn lio_listio(
1915 mode: ::c_int,
1916 aiocb_list: *const *mut aiocb,
1917 nitems: ::c_int,
1918 sevp: *mut sigevent,
1919 ) -> ::c_int;
532ac7d7 1920}
8bb4bdeb 1921
e74abb32 1922extern "C" {
69743fb6
XL
1923 pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
1924 pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
1925 pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
1926
e74abb32
XL
1927 pub fn extattr_delete_fd(
1928 fd: ::c_int,
1929 attrnamespace: ::c_int,
1930 attrname: *const ::c_char,
1931 ) -> ::c_int;
1932 pub fn extattr_delete_file(
1933 path: *const ::c_char,
1934 attrnamespace: ::c_int,
1935 attrname: *const ::c_char,
1936 ) -> ::c_int;
1937 pub fn extattr_delete_link(
1938 path: *const ::c_char,
1939 attrnamespace: ::c_int,
1940 attrname: *const ::c_char,
1941 ) -> ::c_int;
1942 pub fn extattr_get_fd(
1943 fd: ::c_int,
1944 attrnamespace: ::c_int,
1945 attrname: *const ::c_char,
1946 data: *mut ::c_void,
1947 nbytes: ::size_t,
1948 ) -> ::ssize_t;
1949 pub fn extattr_get_file(
1950 path: *const ::c_char,
1951 attrnamespace: ::c_int,
1952 attrname: *const ::c_char,
1953 data: *mut ::c_void,
1954 nbytes: ::size_t,
1955 ) -> ::ssize_t;
1956 pub fn extattr_get_link(
1957 path: *const ::c_char,
1958 attrnamespace: ::c_int,
1959 attrname: *const ::c_char,
1960 data: *mut ::c_void,
1961 nbytes: ::size_t,
1962 ) -> ::ssize_t;
1963 pub fn extattr_namespace_to_string(
1964 attrnamespace: ::c_int,
1965 string: *mut *mut ::c_char,
1966 ) -> ::c_int;
1967 pub fn extattr_set_fd(
1968 fd: ::c_int,
1969 attrnamespace: ::c_int,
1970 attrname: *const ::c_char,
1971 data: *const ::c_void,
1972 nbytes: ::size_t,
1973 ) -> ::c_int;
1974 pub fn extattr_set_file(
1975 path: *const ::c_char,
1976 attrnamespace: ::c_int,
1977 attrname: *const ::c_char,
1978 data: *const ::c_void,
1979 nbytes: ::size_t,
1980 ) -> ::c_int;
1981 pub fn extattr_set_link(
1982 path: *const ::c_char,
1983 attrnamespace: ::c_int,
1984 attrname: *const ::c_char,
1985 data: *const ::c_void,
1986 nbytes: ::size_t,
1987 ) -> ::c_int;
1988 pub fn extattr_string_to_namespace(
1989 string: *const ::c_char,
1990 attrnamespace: *mut ::c_int,
1991 ) -> ::c_int;
69743fb6
XL
1992
1993 #[link_name = "__lutimes50"]
476ff2be 1994 pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
416331ca 1995 #[link_name = "__gettimeofday50"]
e74abb32
XL
1996 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
1997 pub fn getnameinfo(
1998 sa: *const ::sockaddr,
1999 salen: ::socklen_t,
2000 host: *mut ::c_char,
2001 hostlen: ::socklen_t,
2002 serv: *mut ::c_char,
2003 sevlen: ::socklen_t,
2004 flags: ::c_int,
2005 ) -> ::c_int;
cdc7bbd5 2006 pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
e74abb32
XL
2007 pub fn sysctl(
2008 name: *const ::c_int,
2009 namelen: ::c_uint,
2010 oldp: *mut ::c_void,
2011 oldlenp: *mut ::size_t,
2012 newp: *const ::c_void,
2013 newlen: ::size_t,
2014 ) -> ::c_int;
2015 pub fn sysctlbyname(
2016 name: *const ::c_char,
2017 oldp: *mut ::c_void,
2018 oldlenp: *mut ::size_t,
2019 newp: *const ::c_void,
2020 newlen: ::size_t,
2021 ) -> ::c_int;
476ff2be 2022 #[link_name = "__kevent50"]
e74abb32
XL
2023 pub fn kevent(
2024 kq: ::c_int,
2025 changelist: *const ::kevent,
2026 nchanges: ::size_t,
2027 eventlist: *mut ::kevent,
2028 nevents: ::size_t,
2029 timeout: *const ::timespec,
2030 ) -> ::c_int;
476ff2be 2031 #[link_name = "__mount50"]
e74abb32
XL
2032 pub fn mount(
2033 src: *const ::c_char,
2034 target: *const ::c_char,
2035 flags: ::c_int,
2036 data: *mut ::c_void,
2037 size: ::size_t,
2038 ) -> ::c_int;
2c00a5a8
XL
2039 pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
2040 pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
2041 pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
cdc7bbd5 2042 pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) -> ::c_int;
e74abb32
XL
2043 pub fn mq_receive(
2044 mqd: ::mqd_t,
2045 msg_ptr: *mut ::c_char,
2046 msg_len: ::size_t,
2047 msg_prio: *mut ::c_uint,
2048 ) -> ::ssize_t;
2049 pub fn mq_send(
2050 mqd: ::mqd_t,
2051 msg_ptr: *const ::c_char,
2052 msg_len: ::size_t,
2053 msg_prio: ::c_uint,
2054 ) -> ::c_int;
cdc7bbd5 2055 pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int;
69743fb6 2056 #[link_name = "__mq_timedreceive50"]
e74abb32
XL
2057 pub fn mq_timedreceive(
2058 mqd: ::mqd_t,
2059 msg_ptr: *mut ::c_char,
2060 msg_len: ::size_t,
2061 msg_prio: *mut ::c_uint,
2062 abs_timeout: *const ::timespec,
2063 ) -> ::ssize_t;
69743fb6 2064 #[link_name = "__mq_timedsend50"]
e74abb32
XL
2065 pub fn mq_timedsend(
2066 mqd: ::mqd_t,
2067 msg_ptr: *const ::c_char,
2068 msg_len: ::size_t,
2069 msg_prio: ::c_uint,
2070 abs_timeout: *const ::timespec,
2071 ) -> ::c_int;
2c00a5a8 2072 pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
cdc7bbd5 2073 pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_void, data: ::c_int) -> ::c_int;
e74abb32
XL
2074 pub fn pthread_setname_np(
2075 t: ::pthread_t,
2076 name: *const ::c_char,
dfeec247
XL
2077 arg: *const ::c_void,
2078 ) -> ::c_int;
cdc7bbd5
XL
2079 pub fn pthread_attr_get_np(thread: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int;
2080 pub fn pthread_getattr_np(native: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int;
e74abb32
XL
2081 pub fn pthread_attr_getguardsize(
2082 attr: *const ::pthread_attr_t,
2083 guardsize: *mut ::size_t,
2084 ) -> ::c_int;
2085 pub fn pthread_attr_getstack(
2086 attr: *const ::pthread_attr_t,
2087 stackaddr: *mut *mut ::c_void,
2088 stacksize: *mut ::size_t,
2089 ) -> ::c_int;
136023e0
XL
2090 pub fn pthread_getaffinity_np(
2091 thread: ::pthread_t,
2092 size: ::size_t,
2093 set: *mut cpuset_t,
2094 ) -> ::c_int;
2095 pub fn pthread_setaffinity_np(
2096 thread: ::pthread_t,
2097 size: ::size_t,
2098 set: *mut cpuset_t,
2099 ) -> ::c_int;
2100
2101 pub fn _cpuset_create() -> *mut cpuset_t;
2102 pub fn _cpuset_destroy(set: *mut cpuset_t);
2103 pub fn _cpuset_clr(cpu: cpuid_t, set: *mut cpuset_t) -> ::c_int;
2104 pub fn _cpuset_set(cpu: cpuid_t, set: *mut cpuset_t) -> ::c_int;
2105 pub fn _cpuset_isset(cpu: cpuid_t, set: *const cpuset_t) -> ::c_int;
2106 pub fn _cpuset_size(set: *const cpuset_t) -> ::size_t;
2107 pub fn _cpuset_zero(set: *mut cpuset_t);
476ff2be 2108 #[link_name = "__sigtimedwait50"]
e74abb32
XL
2109 pub fn sigtimedwait(
2110 set: *const sigset_t,
2111 info: *mut siginfo_t,
2112 timeout: *const ::timespec,
2113 ) -> ::c_int;
2114 pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int;
136023e0
XL
2115 pub fn waitid(
2116 idtype: idtype_t,
2117 id: ::id_t,
2118 infop: *mut ::siginfo_t,
2119 options: ::c_int,
2120 ) -> ::c_int;
2121
476ff2be
SL
2122 pub fn duplocale(base: ::locale_t) -> ::locale_t;
2123 pub fn freelocale(loc: ::locale_t);
2124 pub fn localeconv_l(loc: ::locale_t) -> *mut lconv;
cdc7bbd5 2125 pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
041b39d2
XL
2126 #[link_name = "__settimeofday50"]
2127 pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int;
69743fb6
XL
2128
2129 pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
532ac7d7 2130
17df50a5
XL
2131 pub fn kqueue1(flags: ::c_int) -> ::c_int;
2132
e74abb32
XL
2133 pub fn sendmmsg(
2134 sockfd: ::c_int,
2135 msgvec: *mut ::mmsghdr,
2136 vlen: ::c_uint,
2137 flags: ::c_int,
2138 ) -> ::c_int;
2139 pub fn recvmmsg(
2140 sockfd: ::c_int,
2141 msgvec: *mut ::mmsghdr,
2142 vlen: ::c_uint,
2143 flags: ::c_int,
2144 timeout: *mut ::timespec,
2145 ) -> ::c_int;
2146
2147 pub fn _lwp_self() -> lwpid_t;
ba9703b0
XL
2148 pub fn memmem(
2149 haystack: *const ::c_void,
2150 haystacklen: ::size_t,
2151 needle: *const ::c_void,
2152 needlelen: ::size_t,
2153 ) -> *mut ::c_void;
5869c6ff
XL
2154
2155 // link.h
2156
2157 pub fn dl_iterate_phdr(
2158 callback: ::Option<
2159 unsafe extern "C" fn(
2160 info: *mut dl_phdr_info,
2161 size: usize,
2162 data: *mut ::c_void,
2163 ) -> ::c_int,
2164 >,
2165 data: *mut ::c_void,
2166 ) -> ::c_int;
6a06907d 2167
17df50a5
XL
2168 // dlfcn.h
2169
2170 pub fn _dlauxinfo() -> *mut ::c_void;
2171
cdc7bbd5 2172 pub fn iconv_open(tocode: *const ::c_char, fromcode: *const ::c_char) -> iconv_t;
6a06907d
XL
2173 pub fn iconv(
2174 cd: iconv_t,
2175 inbuf: *mut *mut ::c_char,
2176 inbytesleft: *mut ::size_t,
2177 outbuf: *mut *mut ::c_char,
2178 outbytesleft: *mut ::size_t,
2179 ) -> ::size_t;
2180 pub fn iconv_close(cd: iconv_t) -> ::c_int;
17df50a5
XL
2181
2182 // Added in `NetBSD` 7.0
2183 pub fn explicit_memset(b: *mut ::c_void, c: ::c_int, len: ::size_t);
136023e0
XL
2184 pub fn consttime_memequal(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
2185
2186 pub fn setproctitle(fmt: *const ::c_char, ...);
2187 pub fn mremap(
2188 oldp: *mut ::c_void,
2189 oldsize: ::size_t,
2190 newp: *mut ::c_void,
2191 newsize: ::size_t,
2192 flags: ::c_int,
2193 ) -> *mut ::c_void;
2194
2195 pub fn sched_setparam(pid: ::pid_t, param: *const sched_param) -> ::c_int;
2196 pub fn sched_getparam(pid: ::pid_t, param: *mut sched_param) -> ::c_int;
476ff2be
SL
2197}
2198
0531ce1d 2199#[link(name = "util")]
e74abb32 2200extern "C" {
0531ce1d 2201 #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")]
e74abb32
XL
2202 pub fn getpwent_r(
2203 pwd: *mut ::passwd,
2204 buf: *mut ::c_char,
2205 buflen: ::size_t,
2206 result: *mut *mut ::passwd,
2207 ) -> ::c_int;
2208 pub fn getgrent_r(
2209 grp: *mut ::group,
2210 buf: *mut ::c_char,
2211 buflen: ::size_t,
2212 result: *mut *mut ::group,
2213 ) -> ::c_int;
dfeec247
XL
2214
2215 pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int;
cdc7bbd5
XL
2216 pub fn getlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> *mut lastlogx;
2217 pub fn updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int;
dfeec247
XL
2218 pub fn utmpxname(file: *const ::c_char) -> ::c_int;
2219 pub fn getutxent() -> *mut utmpx;
2220 pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
2221 pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
2222 pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
2223 pub fn setutxent();
2224 pub fn endutxent();
2225
2226 pub fn getutmp(ux: *const utmpx, u: *mut utmp);
2227 pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
2228
2229 pub fn utpname(file: *const ::c_char) -> ::c_int;
2230 pub fn setutent();
2231 pub fn endutent();
2232 pub fn getutent() -> *mut utmp;
136023e0
XL
2233
2234 pub fn efopen(p: *const ::c_char, m: *const ::c_char) -> ::FILE;
2235 pub fn emalloc(n: ::size_t) -> *mut ::c_void;
2236 pub fn ecalloc(n: ::size_t, c: ::size_t) -> *mut ::c_void;
2237 pub fn erealloc(p: *mut ::c_void, n: ::size_t) -> *mut ::c_void;
2238 pub fn estrdup(s: *const ::c_char) -> *mut ::c_char;
2239 pub fn estrndup(s: *const ::c_char, len: ::size_t) -> *mut ::c_char;
2240 pub fn estrlcpy(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t;
2241 pub fn estrlcat(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t;
2242 pub fn easprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int;
2243 pub fn evasprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int;
2244 pub fn esetfunc(
2245 cb: ::Option<unsafe extern "C" fn(::c_int, *const ::c_char, ...)>,
2246 ) -> ::Option<unsafe extern "C" fn(::c_int, *const ::c_char, ...)>;
2247 pub fn secure_path(path: *const ::c_char) -> ::c_int;
2248 pub fn snprintb(
2249 buf: *mut ::c_char,
2250 buflen: ::size_t,
2251 fmt: *const ::c_char,
2252 val: u64,
2253 ) -> ::c_int;
2254 pub fn snprintb_m(
2255 buf: *mut ::c_char,
2256 buflen: ::size_t,
2257 fmt: *const ::c_char,
2258 val: u64,
2259 max: ::size_t,
2260 ) -> ::c_int;
0531ce1d
XL
2261}
2262
69743fb6
XL
2263cfg_if! {
2264 if #[cfg(target_arch = "aarch64")] {
2265 mod aarch64;
2266 pub use self::aarch64::*;
2267 } else if #[cfg(target_arch = "arm")] {
2268 mod arm;
2269 pub use self::arm::*;
2270 } else if #[cfg(target_arch = "powerpc")] {
2271 mod powerpc;
2272 pub use self::powerpc::*;
2273 } else if #[cfg(target_arch = "sparc64")] {
2274 mod sparc64;
2275 pub use self::sparc64::*;
2276 } else if #[cfg(target_arch = "x86_64")] {
2277 mod x86_64;
2278 pub use self::x86_64::*;
2279 } else if #[cfg(target_arch = "x86")] {
2280 mod x86;
2281 pub use self::x86::*;
2282 } else {
2283 // Unknown target_arch
2284 }
2285}