]> git.proxmox.com Git - rustc.git/blame - vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / vendor / libc / src / unix / bsd / netbsdlike / openbsd / mod.rs
CommitLineData
041b39d2
XL
1use unix::bsd::O_SYNC;
2
476ff2be 3pub type clock_t = i64;
8bb4bdeb 4pub type suseconds_t = ::c_long;
476ff2be
SL
5pub type dev_t = i32;
6pub type sigset_t = ::c_uint;
416331ca
XL
7pub type blksize_t = i32;
8pub type fsblkcnt_t = u64;
9pub type fsfilcnt_t = u64;
476ff2be
SL
10pub type pthread_attr_t = *mut ::c_void;
11pub type pthread_mutex_t = *mut ::c_void;
12pub type pthread_mutexattr_t = *mut ::c_void;
13pub type pthread_cond_t = *mut ::c_void;
14pub type pthread_condattr_t = *mut ::c_void;
15pub type pthread_rwlock_t = *mut ::c_void;
041b39d2 16pub type pthread_rwlockattr_t = *mut ::c_void;
136023e0 17pub type pthread_spinlock_t = ::uintptr_t;
69743fb6 18pub type caddr_t = *mut ::c_char;
476ff2be 19
5869c6ff
XL
20// elf.h
21
22pub type Elf32_Addr = u32;
23pub type Elf32_Half = u16;
24pub type Elf32_Lword = u64;
25pub type Elf32_Off = u32;
26pub type Elf32_Sword = i32;
27pub type Elf32_Word = u32;
28
29pub type Elf64_Addr = u64;
30pub type Elf64_Half = u16;
31pub type Elf64_Lword = u64;
32pub type Elf64_Off = u64;
33pub type Elf64_Sword = i32;
34pub type Elf64_Sxword = i64;
35pub type Elf64_Word = u32;
36pub type Elf64_Xword = u64;
37
38cfg_if! {
39 if #[cfg(target_pointer_width = "64")] {
40 type Elf_Addr = Elf64_Addr;
41 type Elf_Half = Elf64_Half;
42 type Elf_Phdr = Elf64_Phdr;
43 } else if #[cfg(target_pointer_width = "32")] {
44 type Elf_Addr = Elf32_Addr;
45 type Elf_Half = Elf32_Half;
46 type Elf_Phdr = Elf32_Phdr;
47 }
48}
49
476ff2be 50s! {
416331ca
XL
51 pub struct glob_t {
52 pub gl_pathc: ::size_t,
53 pub gl_matchc: ::size_t,
54 pub gl_offs: ::size_t,
55 pub gl_flags: ::c_int,
56 pub gl_pathv: *mut *mut ::c_char,
57 __unused1: *mut ::c_void,
58 __unused2: *mut ::c_void,
59 __unused3: *mut ::c_void,
60 __unused4: *mut ::c_void,
61 __unused5: *mut ::c_void,
62 __unused6: *mut ::c_void,
63 __unused7: *mut ::c_void,
64 }
65
66 pub struct lconv {
67 pub decimal_point: *mut ::c_char,
68 pub thousands_sep: *mut ::c_char,
69 pub grouping: *mut ::c_char,
70 pub int_curr_symbol: *mut ::c_char,
71 pub currency_symbol: *mut ::c_char,
72 pub mon_decimal_point: *mut ::c_char,
73 pub mon_thousands_sep: *mut ::c_char,
74 pub mon_grouping: *mut ::c_char,
75 pub positive_sign: *mut ::c_char,
76 pub negative_sign: *mut ::c_char,
77 pub int_frac_digits: ::c_char,
78 pub frac_digits: ::c_char,
79 pub p_cs_precedes: ::c_char,
80 pub p_sep_by_space: ::c_char,
81 pub n_cs_precedes: ::c_char,
82 pub n_sep_by_space: ::c_char,
83 pub p_sign_posn: ::c_char,
84 pub n_sign_posn: ::c_char,
85 pub int_p_cs_precedes: ::c_char,
86 pub int_p_sep_by_space: ::c_char,
87 pub int_n_cs_precedes: ::c_char,
88 pub int_n_sep_by_space: ::c_char,
89 pub int_p_sign_posn: ::c_char,
90 pub int_n_sign_posn: ::c_char,
91 }
92
93 pub struct ufs_args {
94 pub fspec: *mut ::c_char,
95 pub export_info: export_args,
96 }
97
98 pub struct mfs_args {
99 pub fspec: *mut ::c_char,
100 pub export_info: export_args,
101 // https://github.com/openbsd/src/blob/master/sys/sys/types.h#L134
102 pub base: *mut ::c_char,
103 pub size: ::c_ulong,
104 }
105
106 pub struct iso_args {
107 pub fspec: *mut ::c_char,
108 pub export_info: export_args,
109 pub flags: ::c_int,
110 pub sess: ::c_int,
111 }
112
113 pub struct nfs_args {
114 pub version: ::c_int,
115 pub addr: *mut ::sockaddr,
116 pub addrlen: ::c_int,
117 pub sotype: ::c_int,
118 pub proto: ::c_int,
119 pub fh: *mut ::c_uchar,
120 pub fhsize: ::c_int,
121 pub flags: ::c_int,
122 pub wsize: ::c_int,
123 pub rsize: ::c_int,
124 pub readdirsize: ::c_int,
125 pub timeo: ::c_int,
126 pub retrans: ::c_int,
127 pub maxgrouplist: ::c_int,
128 pub readahead: ::c_int,
129 pub leaseterm: ::c_int,
130 pub deadthresh: ::c_int,
131 pub hostname: *mut ::c_char,
132 pub acregmin: ::c_int,
133 pub acregmax: ::c_int,
134 pub acdirmin: ::c_int,
135 pub acdirmax: ::c_int,
136 }
137
138 pub struct msdosfs_args {
139 pub fspec: *mut ::c_char,
140 pub export_info: export_args,
141 pub uid: ::uid_t,
142 pub gid: ::gid_t,
143 pub mask: ::mode_t,
144 pub flags: ::c_int,
145 }
146
147 pub struct ntfs_args {
148 pub fspec: *mut ::c_char,
149 pub export_info: export_args,
150 pub uid: ::uid_t,
151 pub gid: ::gid_t,
152 pub mode: ::mode_t,
153 pub flag: ::c_ulong,
154 }
155
156 pub struct udf_args {
157 pub fspec: *mut ::c_char,
158 pub lastblock: u32,
159 }
160
161 pub struct tmpfs_args {
162 pub ta_version: ::c_int,
163 pub ta_nodes_max: ::ino_t,
164 pub ta_size_max: ::off_t,
165 pub ta_root_uid: ::uid_t,
166 pub ta_root_gid: ::gid_t,
167 pub ta_root_mode: ::mode_t,
168 }
169
170 pub struct fusefs_args {
171 pub name: *mut ::c_char,
172 pub fd: ::c_int,
173 pub max_read: ::c_int,
174 pub allow_other: ::c_int,
175 }
176
177 pub struct xucred {
178 pub cr_uid: ::uid_t,
179 pub cr_gid: ::gid_t,
180 pub cr_ngroups: ::c_short,
181 //https://github.com/openbsd/src/blob/master/sys/sys/syslimits.h#L44
182 pub cr_groups: [::gid_t; 16],
183 }
184
185 pub struct export_args {
186 pub ex_flags: ::c_int,
187 pub ex_root: ::uid_t,
188 pub ex_anon: xucred,
189 pub ex_addr: *mut ::sockaddr,
190 pub ex_addrlen: ::c_int,
191 pub ex_mask: *mut ::sockaddr,
192 pub ex_masklen: ::c_int,
193 }
194
532ac7d7
XL
195 pub struct ip_mreq {
196 pub imr_multiaddr: in_addr,
197 pub imr_interface: in_addr,
198 }
199
200 pub struct in_addr {
201 pub s_addr: ::in_addr_t,
476ff2be
SL
202 }
203
532ac7d7
XL
204 pub struct sockaddr_in {
205 pub sin_len: u8,
206 pub sin_family: ::sa_family_t,
207 pub sin_port: ::in_port_t,
208 pub sin_addr: ::in_addr,
416331ca 209 pub sin_zero: [i8; 8],
476ff2be
SL
210 }
211
212 pub struct kevent {
213 pub ident: ::uintptr_t,
214 pub filter: ::c_short,
215 pub flags: ::c_ushort,
216 pub fflags: ::c_uint,
416331ca 217 pub data: i64,
476ff2be
SL
218 pub udata: *mut ::c_void,
219 }
220
221 pub struct stat {
222 pub st_mode: ::mode_t,
223 pub st_dev: ::dev_t,
224 pub st_ino: ::ino_t,
225 pub st_nlink: ::nlink_t,
226 pub st_uid: ::uid_t,
227 pub st_gid: ::gid_t,
228 pub st_rdev: ::dev_t,
229 pub st_atime: ::time_t,
230 pub st_atime_nsec: ::c_long,
231 pub st_mtime: ::time_t,
232 pub st_mtime_nsec: ::c_long,
233 pub st_ctime: ::time_t,
234 pub st_ctime_nsec: ::c_long,
235 pub st_size: ::off_t,
236 pub st_blocks: ::blkcnt_t,
237 pub st_blksize: ::blksize_t,
416331ca
XL
238 pub st_flags: u32,
239 pub st_gen: u32,
476ff2be
SL
240 pub st_birthtime: ::time_t,
241 pub st_birthtime_nsec: ::c_long,
242 }
243
244 pub struct statvfs {
245 pub f_bsize: ::c_ulong,
246 pub f_frsize: ::c_ulong,
247 pub f_blocks: ::fsblkcnt_t,
248 pub f_bfree: ::fsblkcnt_t,
249 pub f_bavail: ::fsblkcnt_t,
250 pub f_files: ::fsfilcnt_t,
251 pub f_ffree: ::fsfilcnt_t,
252 pub f_favail: ::fsfilcnt_t,
253 pub f_fsid: ::c_ulong,
254 pub f_flag: ::c_ulong,
255 pub f_namemax: ::c_ulong,
256 }
257
258 pub struct addrinfo {
259 pub ai_flags: ::c_int,
260 pub ai_family: ::c_int,
261 pub ai_socktype: ::c_int,
262 pub ai_protocol: ::c_int,
263 pub ai_addrlen: ::socklen_t,
264 pub ai_addr: *mut ::sockaddr,
265 pub ai_canonname: *mut ::c_char,
266 pub ai_next: *mut ::addrinfo,
267 }
268
476ff2be
SL
269 pub struct Dl_info {
270 pub dli_fname: *const ::c_char,
271 pub dli_fbase: *mut ::c_void,
272 pub dli_sname: *const ::c_char,
273 pub dli_saddr: *mut ::c_void,
274 }
275
3b2f2976
XL
276 pub struct if_data {
277 pub ifi_type: ::c_uchar,
278 pub ifi_addrlen: ::c_uchar,
279 pub ifi_hdrlen: ::c_uchar,
280 pub ifi_link_state: ::c_uchar,
281 pub ifi_mtu: u32,
282 pub ifi_metric: u32,
283 pub ifi_rdomain: u32,
284 pub ifi_baudrate: u64,
285 pub ifi_ipackets: u64,
286 pub ifi_ierrors: u64,
287 pub ifi_opackets: u64,
288 pub ifi_oerrors: u64,
289 pub ifi_collisions: u64,
290 pub ifi_ibytes: u64,
291 pub ifi_obytes: u64,
292 pub ifi_imcasts: u64,
293 pub ifi_omcasts: u64,
294 pub ifi_iqdrops: u64,
295 pub ifi_oqdrops: u64,
296 pub ifi_noproto: u64,
297 pub ifi_capabilities: u32,
298 pub ifi_lastchange: ::timeval,
299 }
300
301 pub struct if_msghdr {
302 pub ifm_msglen: ::c_ushort,
303 pub ifm_version: ::c_uchar,
304 pub ifm_type: ::c_uchar,
305 pub ifm_hdrlen: ::c_ushort,
306 pub ifm_index: ::c_ushort,
307 pub ifm_tableid: ::c_ushort,
308 pub ifm_pad1: ::c_uchar,
309 pub ifm_pad2: ::c_uchar,
310 pub ifm_addrs: ::c_int,
311 pub ifm_flags: ::c_int,
312 pub ifm_xflags: ::c_int,
313 pub ifm_data: if_data,
314 }
2c00a5a8
XL
315
316 pub struct sockaddr_dl {
317 pub sdl_len: ::c_uchar,
318 pub sdl_family: ::c_uchar,
319 pub sdl_index: ::c_ushort,
320 pub sdl_type: ::c_uchar,
321 pub sdl_nlen: ::c_uchar,
322 pub sdl_alen: ::c_uchar,
323 pub sdl_slen: ::c_uchar,
324 pub sdl_data: [::c_char; 24],
325 }
0531ce1d
XL
326
327 pub struct sockpeercred {
328 pub uid: ::uid_t,
329 pub gid: ::gid_t,
330 pub pid: ::pid_t,
331 }
b7449926
XL
332
333 pub struct arphdr {
334 pub ar_hrd: u16,
335 pub ar_pro: u16,
336 pub ar_hln: u8,
337 pub ar_pln: u8,
338 pub ar_op: u16,
339 }
dfeec247
XL
340
341 pub struct shmid_ds {
342 pub shm_perm: ::ipc_perm,
343 pub shm_segsz: ::c_int,
344 pub shm_lpid: ::pid_t,
345 pub shm_cpid: ::pid_t,
346 pub shm_nattch: ::c_short,
347 pub shm_atime: ::time_t,
348 __shm_atimensec: c_long,
349 pub shm_dtime: ::time_t,
350 __shm_dtimensec: c_long,
351 pub shm_ctime: ::time_t,
352 __shm_ctimensec: c_long,
353 pub shm_internal: *mut ::c_void,
354 }
5869c6ff
XL
355
356 // elf.h
357 pub struct Elf32_Phdr {
358 pub p_type: Elf32_Word,
359 pub p_offset: Elf32_Off,
360 pub p_vaddr: Elf32_Addr,
361 pub p_paddr: Elf32_Addr,
362 pub p_filesz: Elf32_Word,
363 pub p_memsz: Elf32_Word,
364 pub p_flags: Elf32_Word,
365 pub p_align: Elf32_Word,
366 }
367
368 pub struct Elf64_Phdr {
369 pub p_type: Elf64_Word,
370 pub p_flags: Elf64_Word,
371 pub p_offset: Elf64_Off,
372 pub p_vaddr: Elf64_Addr,
373 pub p_paddr: Elf64_Addr,
374 pub p_filesz: Elf64_Xword,
375 pub p_memsz: Elf64_Xword,
376 pub p_align: Elf64_Xword,
377 }
378
379 // link.h
380
381 pub struct dl_phdr_info {
382 pub dlpi_addr: Elf_Addr,
383 pub dlpi_name: *const ::c_char,
384 pub dlpi_phdr: *const Elf_Phdr,
385 pub dlpi_phnum: Elf_Half,
386 }
476ff2be
SL
387}
388
416331ca 389impl siginfo_t {
136023e0
XL
390 pub unsafe fn si_addr(&self) -> *mut ::c_char {
391 self.si_addr
392 }
393
416331ca
XL
394 pub unsafe fn si_value(&self) -> ::sigval {
395 #[repr(C)]
396 struct siginfo_timer {
397 _si_signo: ::c_int,
398 _si_errno: ::c_int,
399 _si_code: ::c_int,
400 _pid: ::pid_t,
401 _uid: ::uid_t,
402 value: ::sigval,
403 }
404 (*(self as *const siginfo_t as *const siginfo_timer)).value
405 }
406}
407
532ac7d7
XL
408s_no_extra_traits! {
409 pub struct dirent {
410 pub d_fileno: ::ino_t,
411 pub d_off: ::off_t,
412 pub d_reclen: u16,
413 pub d_type: u8,
414 pub d_namlen: u8,
415 __d_padding: [u8; 4],
416 pub d_name: [::c_char; 256],
417 }
418
419 pub struct sockaddr_storage {
420 pub ss_len: u8,
421 pub ss_family: ::sa_family_t,
422 __ss_pad1: [u8; 6],
423 __ss_pad2: i64,
424 __ss_pad3: [u8; 240],
425 }
426
427 pub struct siginfo_t {
428 pub si_signo: ::c_int,
429 pub si_code: ::c_int,
430 pub si_errno: ::c_int,
431 pub si_addr: *mut ::c_char,
432 #[cfg(target_pointer_width = "32")]
433 __pad: [u8; 112],
434 #[cfg(target_pointer_width = "64")]
435 __pad: [u8; 108],
436 }
437
438 pub struct lastlog {
439 ll_time: ::time_t,
440 ll_line: [::c_char; UT_LINESIZE],
441 ll_host: [::c_char; UT_HOSTSIZE],
442 }
443
444 pub struct utmp {
445 pub ut_line: [::c_char; UT_LINESIZE],
446 pub ut_name: [::c_char; UT_NAMESIZE],
447 pub ut_host: [::c_char; UT_HOSTSIZE],
448 pub ut_time: ::time_t,
449 }
416331ca
XL
450
451 pub union mount_info {
452 pub ufs_args: ufs_args,
453 pub mfs_args: mfs_args,
454 pub nfs_args: nfs_args,
455 pub iso_args: iso_args,
456 pub msdosfs_args: msdosfs_args,
457 pub ntfs_args: ntfs_args,
458 pub tmpfs_args: tmpfs_args,
459 align: [::c_char; 160],
460 }
461
532ac7d7
XL
462}
463
464cfg_if! {
465 if #[cfg(feature = "extra_traits")] {
466 impl PartialEq for dirent {
467 fn eq(&self, other: &dirent) -> bool {
468 self.d_fileno == other.d_fileno
469 && self.d_off == other.d_off
470 && self.d_reclen == other.d_reclen
471 && self.d_type == other.d_type
472 && self.d_namlen == other.d_namlen
473 && self
474 .d_name
475 .iter()
476 .zip(other.d_name.iter())
477 .all(|(a,b)| a == b)
478 }
479 }
480
481 impl Eq for dirent {}
482
483 impl ::fmt::Debug for dirent {
484 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
485 f.debug_struct("dirent")
486 .field("d_fileno", &self.d_fileno)
487 .field("d_off", &self.d_off)
488 .field("d_reclen", &self.d_reclen)
489 .field("d_type", &self.d_type)
490 .field("d_namlen", &self.d_namlen)
491 // FIXME: .field("d_name", &self.d_name)
492 .finish()
493 }
494 }
495
496 impl ::hash::Hash for dirent {
497 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
498 self.d_fileno.hash(state);
499 self.d_off.hash(state);
500 self.d_reclen.hash(state);
501 self.d_type.hash(state);
502 self.d_namlen.hash(state);
503 self.d_name.hash(state);
504 }
505 }
506
507 impl PartialEq for sockaddr_storage {
508 fn eq(&self, other: &sockaddr_storage) -> bool {
509 self.ss_len == other.ss_len
510 && self.ss_family == other.ss_family
511 }
512 }
513
514 impl Eq for sockaddr_storage {}
515
516 impl ::fmt::Debug for sockaddr_storage {
517 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
518 f.debug_struct("sockaddr_storage")
519 .field("ss_len", &self.ss_len)
520 .field("ss_family", &self.ss_family)
521 .finish()
522 }
523 }
524
525 impl ::hash::Hash for sockaddr_storage {
526 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
527 self.ss_len.hash(state);
528 self.ss_family.hash(state);
529 }
530 }
531
532 impl PartialEq for siginfo_t {
533 fn eq(&self, other: &siginfo_t) -> bool {
534 self.si_signo == other.si_signo
535 && self.si_code == other.si_code
536 && self.si_errno == other.si_errno
537 && self.si_addr == other.si_addr
538 }
539 }
540
541 impl Eq for siginfo_t {}
542
543 impl ::fmt::Debug for siginfo_t {
544 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
545 f.debug_struct("siginfo_t")
546 .field("si_signo", &self.si_signo)
547 .field("si_code", &self.si_code)
548 .field("si_errno", &self.si_errno)
549 .field("si_addr", &self.si_addr)
550 .finish()
551 }
552 }
553
554 impl ::hash::Hash for siginfo_t {
555 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
556 self.si_signo.hash(state);
557 self.si_code.hash(state);
558 self.si_errno.hash(state);
559 self.si_addr.hash(state);
560 }
561 }
562
563 impl PartialEq for lastlog {
564 fn eq(&self, other: &lastlog) -> bool {
565 self.ll_time == other.ll_time
566 && self
567 .ll_line
568 .iter()
569 .zip(other.ll_line.iter())
570 .all(|(a,b)| a == b)
571 && self
572 .ll_host
573 .iter()
574 .zip(other.ll_host.iter())
575 .all(|(a,b)| a == b)
576 }
577 }
578
579 impl Eq for lastlog {}
580
581 impl ::fmt::Debug for lastlog {
582 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
583 f.debug_struct("lastlog")
584 .field("ll_time", &self.ll_time)
585 // FIXME: .field("ll_line", &self.ll_line)
586 // FIXME: .field("ll_host", &self.ll_host)
587 .finish()
588 }
589 }
590
591 impl ::hash::Hash for lastlog {
592 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
593 self.ll_time.hash(state);
594 self.ll_line.hash(state);
595 self.ll_host.hash(state);
596 }
597 }
598
599 impl PartialEq for utmp {
600 fn eq(&self, other: &utmp) -> bool {
601 self.ut_time == other.ut_time
602 && self
603 .ut_line
604 .iter()
605 .zip(other.ut_line.iter())
606 .all(|(a,b)| a == b)
607 && self
608 .ut_name
609 .iter()
610 .zip(other.ut_name.iter())
611 .all(|(a,b)| a == b)
612 && self
613 .ut_host
614 .iter()
615 .zip(other.ut_host.iter())
616 .all(|(a,b)| a == b)
617 }
618 }
619
620 impl Eq for utmp {}
621
622 impl ::fmt::Debug for utmp {
623 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
624 f.debug_struct("utmp")
625 // FIXME: .field("ut_line", &self.ut_line)
626 // FIXME: .field("ut_name", &self.ut_name)
627 // FIXME: .field("ut_host", &self.ut_host)
628 .field("ut_time", &self.ut_time)
629 .finish()
630 }
631 }
632
633 impl ::hash::Hash for utmp {
634 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
635 self.ut_line.hash(state);
636 self.ut_name.hash(state);
637 self.ut_host.hash(state);
638 self.ut_time.hash(state);
639 }
640 }
416331ca
XL
641
642 impl PartialEq for mount_info {
643 fn eq(&self, other: &mount_info) -> bool {
644 unsafe {
645 self.align
646 .iter()
647 .zip(other.align.iter())
648 .all(|(a,b)| a == b)
649 }
650 }
651 }
652
653 impl Eq for mount_info { }
654
655 impl ::fmt::Debug for mount_info {
656 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
657 f.debug_struct("mount_info")
658 // FIXME: .field("align", &self.align)
659 .finish()
660 }
661 }
662
663 impl ::hash::Hash for mount_info {
664 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
665 unsafe { self.align.hash(state) };
666 }
667 }
668 }
669}
670
671cfg_if! {
672 if #[cfg(libc_union)] {
673 s_no_extra_traits! {
674 // This type uses the union mount_info:
675 pub struct statfs {
676 pub f_flags: u32,
677 pub f_bsize: u32,
678 pub f_iosize: u32,
679 pub f_blocks: u64,
680 pub f_bfree: u64,
681 pub f_bavail: i64,
682 pub f_files: u64,
683 pub f_ffree: u64,
684 pub f_favail: i64,
685 pub f_syncwrites: u64,
686 pub f_syncreads: u64,
687 pub f_asyncwrites: u64,
688 pub f_asyncreads: u64,
689 pub f_fsid: ::fsid_t,
690 pub f_namemax: u32,
691 pub f_owner: ::uid_t,
692 pub f_ctime: u64,
693 pub f_fstypename: [::c_char; 16],
694 pub f_mntonname: [::c_char; 90],
695 pub f_mntfromname: [::c_char; 90],
696 pub f_mntfromspec: [::c_char; 90],
697 pub mount_info: mount_info,
698 }
699 }
700
701 cfg_if! {
702 if #[cfg(feature = "extra_traits")] {
703 impl PartialEq for statfs {
704 fn eq(&self, other: &statfs) -> bool {
705 self.f_flags == other.f_flags
706 && self.f_bsize == other.f_bsize
707 && self.f_iosize == other.f_iosize
708 && self.f_blocks == other.f_blocks
709 && self.f_bfree == other.f_bfree
710 && self.f_bavail == other.f_bavail
711 && self.f_files == other.f_files
712 && self.f_ffree == other.f_ffree
713 && self.f_favail == other.f_favail
714 && self.f_syncwrites == other.f_syncwrites
715 && self.f_syncreads == other.f_syncreads
716 && self.f_asyncwrites == other.f_asyncwrites
717 && self.f_asyncreads == other.f_asyncreads
718 && self.f_fsid == other.f_fsid
719 && self.f_namemax == other.f_namemax
720 && self.f_owner == other.f_owner
721 && self.f_ctime == other.f_ctime
722 && self.f_fstypename
723 .iter()
724 .zip(other.f_fstypename.iter())
725 .all(|(a,b)| a == b)
726 && self.f_mntonname
727 .iter()
728 .zip(other.f_mntonname.iter())
729 .all(|(a,b)| a == b)
730 && self.f_mntfromname
731 .iter()
732 .zip(other.f_mntfromname.iter())
733 .all(|(a,b)| a == b)
734 && self.f_mntfromspec
735 .iter()
736 .zip(other.f_mntfromspec.iter())
737 .all(|(a,b)| a == b)
738 && self.mount_info == other.mount_info
739 }
740 }
741
742 impl Eq for statfs { }
743
744 impl ::fmt::Debug for statfs {
745 fn fmt(&self, f: &mut ::fmt::Formatter)
746 -> ::fmt::Result {
747 f.debug_struct("statfs")
748 .field("f_flags", &self.f_flags)
749 .field("f_bsize", &self.f_bsize)
750 .field("f_iosize", &self.f_iosize)
751 .field("f_blocks", &self.f_blocks)
752 .field("f_bfree", &self.f_bfree)
753 .field("f_bavail", &self.f_bavail)
754 .field("f_files", &self.f_files)
755 .field("f_ffree", &self.f_ffree)
756 .field("f_favail", &self.f_favail)
757 .field("f_syncwrites", &self.f_syncwrites)
758 .field("f_syncreads", &self.f_syncreads)
759 .field("f_asyncwrites", &self.f_asyncwrites)
760 .field("f_asyncreads", &self.f_asyncreads)
761 .field("f_fsid", &self.f_fsid)
762 .field("f_namemax", &self.f_namemax)
763 .field("f_owner", &self.f_owner)
764 .field("f_ctime", &self.f_ctime)
765 // FIXME: .field("f_fstypename", &self.f_fstypename)
766 // FIXME: .field("f_mntonname", &self.f_mntonname)
767 // FIXME: .field("f_mntfromname", &self.f_mntfromname)
768 // FIXME: .field("f_mntfromspec", &self.f_mntfromspec)
769 .field("mount_info", &self.mount_info)
770 .finish()
771 }
772 }
773
774 impl ::hash::Hash for statfs {
775 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
776 self.f_flags.hash(state);
777 self.f_bsize.hash(state);
778 self.f_iosize.hash(state);
779 self.f_blocks.hash(state);
780 self.f_bfree.hash(state);
781 self.f_bavail.hash(state);
782 self.f_files.hash(state);
783 self.f_ffree.hash(state);
784 self.f_favail.hash(state);
785 self.f_syncwrites.hash(state);
786 self.f_syncreads.hash(state);
787 self.f_asyncwrites.hash(state);
788 self.f_asyncreads.hash(state);
789 self.f_fsid.hash(state);
790 self.f_namemax.hash(state);
791 self.f_owner.hash(state);
792 self.f_ctime.hash(state);
793 self.f_fstypename.hash(state);
794 self.f_mntonname.hash(state);
795 self.f_mntfromname.hash(state);
796 self.f_mntfromspec.hash(state);
797 self.mount_info.hash(state);
798 }
799 }
800 }
801 }
532ac7d7
XL
802 }
803}
804
476ff2be
SL
805pub const UT_NAMESIZE: usize = 32;
806pub const UT_LINESIZE: usize = 8;
807pub const UT_HOSTSIZE: usize = 256;
808
809pub const O_CLOEXEC: ::c_int = 0x10000;
041b39d2
XL
810pub const O_DIRECTORY: ::c_int = 0x20000;
811pub const O_RSYNC: ::c_int = O_SYNC;
476ff2be 812
e74abb32
XL
813pub const MS_SYNC: ::c_int = 0x0002;
814pub const MS_INVALIDATE: ::c_int = 0x0004;
476ff2be 815
ea8adc8c
XL
816pub const POLLNORM: ::c_short = ::POLLRDNORM;
817
e74abb32
XL
818pub const ENOATTR: ::c_int = 83;
819pub const EILSEQ: ::c_int = 84;
820pub const EOVERFLOW: ::c_int = 87;
821pub const ECANCELED: ::c_int = 88;
822pub const EIDRM: ::c_int = 89;
823pub const ENOMSG: ::c_int = 90;
824pub const ENOTSUP: ::c_int = 91;
825pub const EBADMSG: ::c_int = 92;
826pub const ENOTRECOVERABLE: ::c_int = 93;
827pub const EOWNERDEAD: ::c_int = 94;
828pub const EPROTO: ::c_int = 95;
829pub const ELAST: ::c_int = 95;
830
831pub const F_DUPFD_CLOEXEC: ::c_int = 10;
832
833pub const UTIME_OMIT: c_long = -1;
834pub const UTIME_NOW: c_long = -2;
476ff2be 835
7cac9316
XL
836pub const AT_FDCWD: ::c_int = -100;
837pub const AT_EACCESS: ::c_int = 0x01;
838pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x02;
839pub const AT_SYMLINK_FOLLOW: ::c_int = 0x04;
840pub const AT_REMOVEDIR: ::c_int = 0x08;
841
e74abb32 842#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
476ff2be
SL
843pub const RLIM_NLIMITS: ::c_int = 9;
844
3b2f2976 845pub const SO_TIMESTAMP: ::c_int = 0x0800;
476ff2be
SL
846pub const SO_SNDTIMEO: ::c_int = 0x1005;
847pub const SO_RCVTIMEO: ::c_int = 0x1006;
8bb4bdeb
XL
848pub const SO_BINDANY: ::c_int = 0x1000;
849pub const SO_NETPROC: ::c_int = 0x1020;
850pub const SO_RTABLE: ::c_int = 0x1021;
851pub const SO_PEERCRED: ::c_int = 0x1022;
852pub const SO_SPLICE: ::c_int = 0x1023;
853
ea8adc8c
XL
854// sys/netinet/in.h
855// Protocols (RFC 1700)
856// NOTE: These are in addition to the constants defined in src/unix/mod.rs
857
858// IPPROTO_IP defined in src/unix/mod.rs
859/// Hop-by-hop option header
860pub const IPPROTO_HOPOPTS: ::c_int = 0;
861// IPPROTO_ICMP defined in src/unix/mod.rs
862/// group mgmt protocol
863pub const IPPROTO_IGMP: ::c_int = 2;
864/// gateway^2 (deprecated)
865pub const IPPROTO_GGP: ::c_int = 3;
866/// for compatibility
867pub const IPPROTO_IPIP: ::c_int = 4;
868// IPPROTO_TCP defined in src/unix/mod.rs
869/// exterior gateway protocol
870pub const IPPROTO_EGP: ::c_int = 8;
871/// pup
872pub const IPPROTO_PUP: ::c_int = 12;
873// IPPROTO_UDP defined in src/unix/mod.rs
874/// xns idp
875pub const IPPROTO_IDP: ::c_int = 22;
876/// tp-4 w/ class negotiation
877pub const IPPROTO_TP: ::c_int = 29;
878// IPPROTO_IPV6 defined in src/unix/mod.rs
879/// IP6 routing header
880pub const IPPROTO_ROUTING: ::c_int = 43;
881/// IP6 fragmentation header
882pub const IPPROTO_FRAGMENT: ::c_int = 44;
883/// resource reservation
884pub const IPPROTO_RSVP: ::c_int = 46;
885/// General Routing Encap.
886pub const IPPROTO_GRE: ::c_int = 47;
887/// IP6 Encap Sec. Payload
888pub const IPPROTO_ESP: ::c_int = 50;
889/// IP6 Auth Header
890pub const IPPROTO_AH: ::c_int = 51;
891/// IP Mobility RFC 2004
892pub const IPPROTO_MOBILE: ::c_int = 55;
893// IPPROTO_ICMPV6 defined in src/unix/mod.rs
894/// IP6 no next header
895pub const IPPROTO_NONE: ::c_int = 59;
896/// IP6 destination option
897pub const IPPROTO_DSTOPTS: ::c_int = 60;
898/// ISO cnlp
899pub const IPPROTO_EON: ::c_int = 80;
900/// Ethernet-in-IP
901pub const IPPROTO_ETHERIP: ::c_int = 97;
902/// encapsulation header
903pub const IPPROTO_ENCAP: ::c_int = 98;
904/// Protocol indep. multicast
905pub const IPPROTO_PIM: ::c_int = 103;
906/// IP Payload Comp. Protocol
907pub const IPPROTO_IPCOMP: ::c_int = 108;
908/// CARP
909pub const IPPROTO_CARP: ::c_int = 112;
910/// unicast MPLS packet
911pub const IPPROTO_MPLS: ::c_int = 137;
912/// PFSYNC
913pub const IPPROTO_PFSYNC: ::c_int = 240;
914pub const IPPROTO_MAX: ::c_int = 256;
915
e74abb32 916// Only used internally, so it can be outside the range of valid IP protocols
ea8adc8c
XL
917pub const IPPROTO_DIVERT: ::c_int = 258;
918
8faf50e0
XL
919pub const IP_RECVDSTADDR: ::c_int = 7;
920pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR;
0731742a 921pub const IP_RECVIF: ::c_int = 30;
8faf50e0 922
69743fb6
XL
923// sys/netinet/in.h
924pub const TCP_MD5SIG: ::c_int = 0x04;
925pub const TCP_NOPUSH: ::c_int = 0x10;
926
8bb4bdeb
XL
927pub const AF_ECMA: ::c_int = 8;
928pub const AF_ROUTE: ::c_int = 17;
929pub const AF_ENCAP: ::c_int = 28;
930pub const AF_SIP: ::c_int = 29;
931pub const AF_KEY: ::c_int = 30;
932pub const pseudo_AF_HDRCMPLT: ::c_int = 31;
933pub const AF_BLUETOOTH: ::c_int = 32;
934pub const AF_MPLS: ::c_int = 33;
935pub const pseudo_AF_PFLOW: ::c_int = 34;
936pub const pseudo_AF_PIPEX: ::c_int = 35;
8bb4bdeb
XL
937pub const NET_RT_DUMP: ::c_int = 1;
938pub const NET_RT_FLAGS: ::c_int = 2;
939pub const NET_RT_IFLIST: ::c_int = 3;
940pub const NET_RT_STATS: ::c_int = 4;
941pub const NET_RT_TABLE: ::c_int = 5;
942pub const NET_RT_IFNAMES: ::c_int = 6;
943#[doc(hidden)]
17df50a5
XL
944#[deprecated(
945 since = "0.2.95",
946 note = "Possibly increasing over the releases and might not be so used in the field"
947)]
8bb4bdeb 948pub const NET_RT_MAXID: ::c_int = 7;
476ff2be
SL
949
950pub const IPV6_JOIN_GROUP: ::c_int = 12;
951pub const IPV6_LEAVE_GROUP: ::c_int = 13;
952
8bb4bdeb
XL
953pub const PF_ROUTE: ::c_int = AF_ROUTE;
954pub const PF_ECMA: ::c_int = AF_ECMA;
955pub const PF_ENCAP: ::c_int = AF_ENCAP;
956pub const PF_SIP: ::c_int = AF_SIP;
957pub const PF_KEY: ::c_int = AF_KEY;
958pub const PF_BPF: ::c_int = pseudo_AF_HDRCMPLT;
959pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
960pub const PF_MPLS: ::c_int = AF_MPLS;
961pub const PF_PFLOW: ::c_int = pseudo_AF_PFLOW;
962pub const PF_PIPEX: ::c_int = pseudo_AF_PIPEX;
8bb4bdeb
XL
963
964pub const SCM_TIMESTAMP: ::c_int = 0x04;
965
e74abb32 966pub const O_DSYNC: ::c_int = 128;
476ff2be 967
e74abb32
XL
968pub const MAP_RENAME: ::c_int = 0x0000;
969pub const MAP_NORESERVE: ::c_int = 0x0000;
970pub const MAP_HASSEMAPHORE: ::c_int = 0x0000;
476ff2be 971
e74abb32
XL
972pub const EIPSEC: ::c_int = 82;
973pub const ENOMEDIUM: ::c_int = 85;
974pub const EMEDIUMTYPE: ::c_int = 86;
476ff2be 975
2c00a5a8
XL
976pub const EAI_BADFLAGS: ::c_int = -1;
977pub const EAI_NONAME: ::c_int = -2;
978pub const EAI_AGAIN: ::c_int = -3;
979pub const EAI_FAIL: ::c_int = -4;
980pub const EAI_NODATA: ::c_int = -5;
981pub const EAI_FAMILY: ::c_int = -6;
982pub const EAI_SOCKTYPE: ::c_int = -7;
983pub const EAI_SERVICE: ::c_int = -8;
984pub const EAI_MEMORY: ::c_int = -10;
476ff2be 985pub const EAI_SYSTEM: ::c_int = -11;
2c00a5a8 986pub const EAI_OVERFLOW: ::c_int = -14;
476ff2be
SL
987
988pub const RUSAGE_THREAD: ::c_int = 1;
989
e74abb32
XL
990pub const MAP_COPY: ::c_int = 0x0002;
991pub const MAP_NOEXTEND: ::c_int = 0x0000;
992
993pub const _PC_LINK_MAX: ::c_int = 1;
994pub const _PC_MAX_CANON: ::c_int = 2;
995pub const _PC_MAX_INPUT: ::c_int = 3;
996pub const _PC_NAME_MAX: ::c_int = 4;
997pub const _PC_PATH_MAX: ::c_int = 5;
998pub const _PC_PIPE_BUF: ::c_int = 6;
999pub const _PC_CHOWN_RESTRICTED: ::c_int = 7;
1000pub const _PC_NO_TRUNC: ::c_int = 8;
1001pub const _PC_VDISABLE: ::c_int = 9;
1002pub const _PC_2_SYMLINKS: ::c_int = 10;
1003pub const _PC_ALLOC_SIZE_MIN: ::c_int = 11;
1004pub const _PC_ASYNC_IO: ::c_int = 12;
1005pub const _PC_FILESIZEBITS: ::c_int = 13;
1006pub const _PC_PRIO_IO: ::c_int = 14;
1007pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 15;
1008pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 16;
1009pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 17;
1010pub const _PC_REC_XFER_ALIGN: ::c_int = 18;
1011pub const _PC_SYMLINK_MAX: ::c_int = 19;
1012pub const _PC_SYNC_IO: ::c_int = 20;
1013pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 21;
1014
1015pub const _SC_CLK_TCK: ::c_int = 3;
1016pub const _SC_SEM_NSEMS_MAX: ::c_int = 31;
1017pub const _SC_SEM_VALUE_MAX: ::c_int = 32;
1018pub const _SC_HOST_NAME_MAX: ::c_int = 33;
1019pub const _SC_MONOTONIC_CLOCK: ::c_int = 34;
1020pub const _SC_2_PBS: ::c_int = 35;
1021pub const _SC_2_PBS_ACCOUNTING: ::c_int = 36;
1022pub const _SC_2_PBS_CHECKPOINT: ::c_int = 37;
1023pub const _SC_2_PBS_LOCATE: ::c_int = 38;
1024pub const _SC_2_PBS_MESSAGE: ::c_int = 39;
1025pub const _SC_2_PBS_TRACK: ::c_int = 40;
1026pub const _SC_ADVISORY_INFO: ::c_int = 41;
1027pub const _SC_AIO_LISTIO_MAX: ::c_int = 42;
1028pub const _SC_AIO_MAX: ::c_int = 43;
1029pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44;
1030pub const _SC_ASYNCHRONOUS_IO: ::c_int = 45;
1031pub const _SC_ATEXIT_MAX: ::c_int = 46;
1032pub const _SC_BARRIERS: ::c_int = 47;
1033pub const _SC_CLOCK_SELECTION: ::c_int = 48;
1034pub const _SC_CPUTIME: ::c_int = 49;
1035pub const _SC_DELAYTIMER_MAX: ::c_int = 50;
1036pub const _SC_IOV_MAX: ::c_int = 51;
1037pub const _SC_IPV6: ::c_int = 52;
1038pub const _SC_MAPPED_FILES: ::c_int = 53;
1039pub const _SC_MEMLOCK: ::c_int = 54;
1040pub const _SC_MEMLOCK_RANGE: ::c_int = 55;
1041pub const _SC_MEMORY_PROTECTION: ::c_int = 56;
1042pub const _SC_MESSAGE_PASSING: ::c_int = 57;
1043pub const _SC_MQ_OPEN_MAX: ::c_int = 58;
1044pub const _SC_MQ_PRIO_MAX: ::c_int = 59;
1045pub const _SC_PRIORITIZED_IO: ::c_int = 60;
1046pub const _SC_PRIORITY_SCHEDULING: ::c_int = 61;
1047pub const _SC_RAW_SOCKETS: ::c_int = 62;
1048pub const _SC_READER_WRITER_LOCKS: ::c_int = 63;
1049pub const _SC_REALTIME_SIGNALS: ::c_int = 64;
1050pub const _SC_REGEXP: ::c_int = 65;
1051pub const _SC_RTSIG_MAX: ::c_int = 66;
1052pub const _SC_SEMAPHORES: ::c_int = 67;
1053pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 68;
1054pub const _SC_SHELL: ::c_int = 69;
1055pub const _SC_SIGQUEUE_MAX: ::c_int = 70;
1056pub const _SC_SPAWN: ::c_int = 71;
1057pub const _SC_SPIN_LOCKS: ::c_int = 72;
1058pub const _SC_SPORADIC_SERVER: ::c_int = 73;
1059pub const _SC_SS_REPL_MAX: ::c_int = 74;
1060pub const _SC_SYNCHRONIZED_IO: ::c_int = 75;
1061pub const _SC_SYMLOOP_MAX: ::c_int = 76;
1062pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
1063pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
1064pub const _SC_THREAD_CPUTIME: ::c_int = 79;
1065pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 80;
1066pub const _SC_THREAD_KEYS_MAX: ::c_int = 81;
1067pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 82;
1068pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 83;
1069pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 84;
1070pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 85;
1071pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 86;
1072pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 87;
1073pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 88;
1074pub const _SC_THREAD_STACK_MIN: ::c_int = 89;
1075pub const _SC_THREAD_THREADS_MAX: ::c_int = 90;
1076pub const _SC_THREADS: ::c_int = 91;
1077pub const _SC_TIMEOUTS: ::c_int = 92;
1078pub const _SC_TIMER_MAX: ::c_int = 93;
1079pub const _SC_TIMERS: ::c_int = 94;
1080pub const _SC_TRACE: ::c_int = 95;
1081pub const _SC_TRACE_EVENT_FILTER: ::c_int = 96;
1082pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 97;
1083pub const _SC_TRACE_INHERIT: ::c_int = 98;
1084pub const _SC_TRACE_LOG: ::c_int = 99;
1085pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 100;
1086pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 101;
1087pub const _SC_LOGIN_NAME_MAX: ::c_int = 102;
1088pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 103;
1089pub const _SC_TRACE_NAME_MAX: ::c_int = 104;
1090pub const _SC_TRACE_SYS_MAX: ::c_int = 105;
1091pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 106;
1092pub const _SC_TTY_NAME_MAX: ::c_int = 107;
1093pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 108;
1094pub const _SC_V6_ILP32_OFF32: ::c_int = 109;
1095pub const _SC_V6_ILP32_OFFBIG: ::c_int = 110;
1096pub const _SC_V6_LP64_OFF64: ::c_int = 111;
1097pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 112;
1098pub const _SC_V7_ILP32_OFF32: ::c_int = 113;
1099pub const _SC_V7_ILP32_OFFBIG: ::c_int = 114;
1100pub const _SC_V7_LP64_OFF64: ::c_int = 115;
1101pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 116;
1102pub const _SC_XOPEN_CRYPT: ::c_int = 117;
1103pub const _SC_XOPEN_ENH_I18N: ::c_int = 118;
1104pub const _SC_XOPEN_LEGACY: ::c_int = 119;
1105pub const _SC_XOPEN_REALTIME: ::c_int = 120;
1106pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 121;
1107pub const _SC_XOPEN_STREAMS: ::c_int = 122;
1108pub const _SC_XOPEN_UNIX: ::c_int = 123;
1109pub const _SC_XOPEN_UUCP: ::c_int = 124;
1110pub const _SC_XOPEN_VERSION: ::c_int = 125;
1111pub const _SC_PHYS_PAGES: ::c_int = 500;
1112pub const _SC_AVPHYS_PAGES: ::c_int = 501;
1113pub const _SC_NPROCESSORS_CONF: ::c_int = 502;
1114pub const _SC_NPROCESSORS_ONLN: ::c_int = 503;
476ff2be
SL
1115
1116pub const FD_SETSIZE: usize = 1024;
1117
1118pub const ST_NOSUID: ::c_ulong = 2;
1119
1120pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _;
1121pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _;
1122pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _;
1123
1124pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
1125pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
1126pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3;
1127pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4;
1128pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP;
1129
416331ca
XL
1130pub const EVFILT_AIO: i16 = -3;
1131pub const EVFILT_PROC: i16 = -5;
1132pub const EVFILT_READ: i16 = -1;
1133pub const EVFILT_SIGNAL: i16 = -6;
1134pub const EVFILT_TIMER: i16 = -7;
1135pub const EVFILT_VNODE: i16 = -4;
1136pub const EVFILT_WRITE: i16 = -2;
1137
1138pub const EV_ADD: u16 = 0x1;
1139pub const EV_DELETE: u16 = 0x2;
1140pub const EV_ENABLE: u16 = 0x4;
1141pub const EV_DISABLE: u16 = 0x8;
1142pub const EV_ONESHOT: u16 = 0x10;
1143pub const EV_CLEAR: u16 = 0x20;
1144pub const EV_RECEIPT: u16 = 0x40;
1145pub const EV_DISPATCH: u16 = 0x80;
1146pub const EV_FLAG1: u16 = 0x2000;
1147pub const EV_ERROR: u16 = 0x4000;
1148pub const EV_EOF: u16 = 0x8000;
1149pub const EV_SYSFLAGS: u16 = 0xf000;
1150
1151pub const NOTE_LOWAT: u32 = 0x00000001;
1152pub const NOTE_EOF: u32 = 0x00000002;
1153pub const NOTE_DELETE: u32 = 0x00000001;
1154pub const NOTE_WRITE: u32 = 0x00000002;
1155pub const NOTE_EXTEND: u32 = 0x00000004;
1156pub const NOTE_ATTRIB: u32 = 0x00000008;
1157pub const NOTE_LINK: u32 = 0x00000010;
1158pub const NOTE_RENAME: u32 = 0x00000020;
1159pub const NOTE_REVOKE: u32 = 0x00000040;
1160pub const NOTE_TRUNCATE: u32 = 0x00000080;
1161pub const NOTE_EXIT: u32 = 0x80000000;
1162pub const NOTE_FORK: u32 = 0x40000000;
1163pub const NOTE_EXEC: u32 = 0x20000000;
1164pub const NOTE_PDATAMASK: u32 = 0x000fffff;
1165pub const NOTE_PCTRLMASK: u32 = 0xf0000000;
1166pub const NOTE_TRACK: u32 = 0x00000001;
1167pub const NOTE_TRACKERR: u32 = 0x00000002;
1168pub const NOTE_CHILD: u32 = 0x00000004;
476ff2be 1169
e74abb32 1170pub const TMP_MAX: ::c_uint = 0x7fffffff;
476ff2be 1171
17df50a5
XL
1172pub const NI_NUMERICHOST: ::c_int = 1;
1173pub const NI_NUMERICSERV: ::c_int = 2;
1174pub const NI_NOFQDN: ::c_int = 4;
1175pub const NI_NAMEREQD: ::c_int = 8;
1176pub const NI_DGRAM: ::c_int = 16;
1177
476ff2be
SL
1178pub const NI_MAXHOST: ::size_t = 256;
1179
1180pub const RTLD_LOCAL: ::c_int = 0;
416331ca 1181
476ff2be 1182pub const CTL_MAXNAME: ::c_int = 12;
416331ca 1183
476ff2be
SL
1184pub const CTLTYPE_NODE: ::c_int = 1;
1185pub const CTLTYPE_INT: ::c_int = 2;
1186pub const CTLTYPE_STRING: ::c_int = 3;
1187pub const CTLTYPE_QUAD: ::c_int = 4;
1188pub const CTLTYPE_STRUCT: ::c_int = 5;
416331ca 1189
476ff2be
SL
1190pub const CTL_UNSPEC: ::c_int = 0;
1191pub const CTL_KERN: ::c_int = 1;
1192pub const CTL_VM: ::c_int = 2;
1193pub const CTL_FS: ::c_int = 3;
1194pub const CTL_NET: ::c_int = 4;
1195pub const CTL_DEBUG: ::c_int = 5;
1196pub const CTL_HW: ::c_int = 6;
1197pub const CTL_MACHDEP: ::c_int = 7;
1198pub const CTL_DDB: ::c_int = 9;
1199pub const CTL_VFS: ::c_int = 10;
1200pub const CTL_MAXID: ::c_int = 11;
416331ca 1201
b7449926 1202pub const HW_NCPUONLINE: ::c_int = 25;
416331ca 1203
476ff2be
SL
1204pub const KERN_OSTYPE: ::c_int = 1;
1205pub const KERN_OSRELEASE: ::c_int = 2;
1206pub const KERN_OSREV: ::c_int = 3;
1207pub const KERN_VERSION: ::c_int = 4;
1208pub const KERN_MAXVNODES: ::c_int = 5;
1209pub const KERN_MAXPROC: ::c_int = 6;
1210pub const KERN_MAXFILES: ::c_int = 7;
1211pub const KERN_ARGMAX: ::c_int = 8;
1212pub const KERN_SECURELVL: ::c_int = 9;
1213pub const KERN_HOSTNAME: ::c_int = 10;
1214pub const KERN_HOSTID: ::c_int = 11;
1215pub const KERN_CLOCKRATE: ::c_int = 12;
1216pub const KERN_PROF: ::c_int = 16;
1217pub const KERN_POSIX1: ::c_int = 17;
1218pub const KERN_NGROUPS: ::c_int = 18;
1219pub const KERN_JOB_CONTROL: ::c_int = 19;
1220pub const KERN_SAVED_IDS: ::c_int = 20;
1221pub const KERN_BOOTTIME: ::c_int = 21;
1222pub const KERN_DOMAINNAME: ::c_int = 22;
1223pub const KERN_MAXPARTITIONS: ::c_int = 23;
1224pub const KERN_RAWPARTITION: ::c_int = 24;
1225pub const KERN_MAXTHREAD: ::c_int = 25;
1226pub const KERN_NTHREADS: ::c_int = 26;
1227pub const KERN_OSVERSION: ::c_int = 27;
1228pub const KERN_SOMAXCONN: ::c_int = 28;
1229pub const KERN_SOMINCONN: ::c_int = 29;
f035d41b 1230#[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")]
476ff2be
SL
1231pub const KERN_USERMOUNT: ::c_int = 30;
1232pub const KERN_NOSUIDCOREDUMP: ::c_int = 32;
1233pub const KERN_FSYNC: ::c_int = 33;
1234pub const KERN_SYSVMSG: ::c_int = 34;
1235pub const KERN_SYSVSEM: ::c_int = 35;
1236pub const KERN_SYSVSHM: ::c_int = 36;
f035d41b 1237#[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")]
476ff2be
SL
1238pub const KERN_ARND: ::c_int = 37;
1239pub const KERN_MSGBUFSIZE: ::c_int = 38;
1240pub const KERN_MALLOCSTATS: ::c_int = 39;
1241pub const KERN_CPTIME: ::c_int = 40;
1242pub const KERN_NCHSTATS: ::c_int = 41;
1243pub const KERN_FORKSTAT: ::c_int = 42;
1244pub const KERN_NSELCOLL: ::c_int = 43;
1245pub const KERN_TTY: ::c_int = 44;
1246pub const KERN_CCPU: ::c_int = 45;
1247pub const KERN_FSCALE: ::c_int = 46;
1248pub const KERN_NPROCS: ::c_int = 47;
1249pub const KERN_MSGBUF: ::c_int = 48;
1250pub const KERN_POOL: ::c_int = 49;
1251pub const KERN_STACKGAPRANDOM: ::c_int = 50;
1252pub const KERN_SYSVIPC_INFO: ::c_int = 51;
1253pub const KERN_SPLASSERT: ::c_int = 54;
1254pub const KERN_PROC_ARGS: ::c_int = 55;
1255pub const KERN_NFILES: ::c_int = 56;
1256pub const KERN_TTYCOUNT: ::c_int = 57;
1257pub const KERN_NUMVNODES: ::c_int = 58;
1258pub const KERN_MBSTAT: ::c_int = 59;
1259pub const KERN_SEMINFO: ::c_int = 61;
1260pub const KERN_SHMINFO: ::c_int = 62;
1261pub const KERN_INTRCNT: ::c_int = 63;
1262pub const KERN_WATCHDOG: ::c_int = 64;
1263pub const KERN_PROC: ::c_int = 66;
1264pub const KERN_MAXCLUSTERS: ::c_int = 67;
1265pub const KERN_EVCOUNT: ::c_int = 68;
1266pub const KERN_TIMECOUNTER: ::c_int = 69;
1267pub const KERN_MAXLOCKSPERUID: ::c_int = 70;
1268pub const KERN_CPTIME2: ::c_int = 71;
1269pub const KERN_CACHEPCT: ::c_int = 72;
1270pub const KERN_FILE: ::c_int = 73;
1271pub const KERN_CONSDEV: ::c_int = 75;
1272pub const KERN_NETLIVELOCKS: ::c_int = 76;
1273pub const KERN_POOL_DEBUG: ::c_int = 77;
1274pub const KERN_PROC_CWD: ::c_int = 78;
1275pub const KERN_PROC_NOBROADCASTKILL: ::c_int = 79;
1276pub const KERN_PROC_VMMAP: ::c_int = 80;
1277pub const KERN_GLOBAL_PTRACE: ::c_int = 81;
1278pub const KERN_CONSBUFSIZE: ::c_int = 82;
1279pub const KERN_CONSBUF: ::c_int = 83;
b7449926 1280pub const KERN_AUDIO: ::c_int = 84;
69743fb6 1281pub const KERN_CPUSTATS: ::c_int = 85;
416331ca 1282pub const KERN_PFSTATUS: ::c_int = 86;
e1599b0c 1283pub const KERN_TIMEOUT_STATS: ::c_int = 87;
17df50a5
XL
1284#[deprecated(
1285 since = "0.2.95",
1286 note = "Possibly increasing over the releases and might not be so used in the field"
1287)]
e1599b0c 1288pub const KERN_MAXID: ::c_int = 88;
416331ca 1289
476ff2be
SL
1290pub const KERN_PROC_ALL: ::c_int = 0;
1291pub const KERN_PROC_PID: ::c_int = 1;
1292pub const KERN_PROC_PGRP: ::c_int = 2;
1293pub const KERN_PROC_SESSION: ::c_int = 3;
1294pub const KERN_PROC_TTY: ::c_int = 4;
1295pub const KERN_PROC_UID: ::c_int = 5;
1296pub const KERN_PROC_RUID: ::c_int = 6;
1297pub const KERN_PROC_KTHREAD: ::c_int = 7;
1298pub const KERN_PROC_SHOW_THREADS: ::c_int = 0x40000000;
416331ca 1299
476ff2be
SL
1300pub const KERN_SYSVIPC_MSG_INFO: ::c_int = 1;
1301pub const KERN_SYSVIPC_SEM_INFO: ::c_int = 2;
1302pub const KERN_SYSVIPC_SHM_INFO: ::c_int = 3;
416331ca 1303
476ff2be
SL
1304pub const KERN_PROC_ARGV: ::c_int = 1;
1305pub const KERN_PROC_NARGV: ::c_int = 2;
1306pub const KERN_PROC_ENV: ::c_int = 3;
1307pub const KERN_PROC_NENV: ::c_int = 4;
416331ca 1308
476ff2be
SL
1309pub const KI_NGROUPS: ::c_int = 16;
1310pub const KI_MAXCOMLEN: ::c_int = 24;
1311pub const KI_WMESGLEN: ::c_int = 8;
1312pub const KI_MAXLOGNAME: ::c_int = 32;
1313pub const KI_EMULNAMELEN: ::c_int = 8;
1314
041b39d2
XL
1315pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS;
1316pub const OLCUC: ::tcflag_t = 0x20;
1317pub const ONOCR: ::tcflag_t = 0x40;
1318pub const ONLRET: ::tcflag_t = 0x80;
1319
416331ca
XL
1320//https://github.com/openbsd/src/blob/master/sys/sys/mount.h
1321pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext
1322pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers
1323pub const ISOFSMNT_EXTATT: ::c_int = 0x4; // enable extended attr
1324pub const ISOFSMNT_NOJOLIET: ::c_int = 0x8; // disable Joliet Ext
1325pub const ISOFSMNT_SESS: ::c_int = 0x10; // use iso_args.sess
1326
1327pub const NFS_ARGSVERSION: ::c_int = 4; // change when nfs_args changes
1328
1329pub const NFSMNT_RESVPORT: ::c_int = 0; // always use reserved ports
1330pub const NFSMNT_SOFT: ::c_int = 0x1; // soft mount (hard is default)
1331pub const NFSMNT_WSIZE: ::c_int = 0x2; // set write size
1332pub const NFSMNT_RSIZE: ::c_int = 0x4; // set read size
1333pub const NFSMNT_TIMEO: ::c_int = 0x8; // set initial timeout
1334pub const NFSMNT_RETRANS: ::c_int = 0x10; // set number of request retries
1335pub const NFSMNT_MAXGRPS: ::c_int = 0x20; // set maximum grouplist size
1336pub const NFSMNT_INT: ::c_int = 0x40; // allow interrupts on hard mount
1337pub const NFSMNT_NOCONN: ::c_int = 0x80; // Don't Connect the socket
1338pub const NFSMNT_NQNFS: ::c_int = 0x100; // Use Nqnfs protocol
1339pub const NFSMNT_NFSV3: ::c_int = 0x200; // Use NFS Version 3 protocol
1340pub const NFSMNT_KERB: ::c_int = 0x400; // Use Kerberos authentication
1341pub const NFSMNT_DUMBTIMR: ::c_int = 0x800; // Don't estimate rtt dynamically
1342pub const NFSMNT_LEASETERM: ::c_int = 0x1000; // set lease term (nqnfs)
1343pub const NFSMNT_READAHEAD: ::c_int = 0x2000; // set read ahead
1344pub const NFSMNT_DEADTHRESH: ::c_int = 0x4000; // set dead server retry thresh
1345pub const NFSMNT_NOAC: ::c_int = 0x8000; // disable attribute cache
1346pub const NFSMNT_RDIRPLUS: ::c_int = 0x10000; // Use Readdirplus for V3
1347pub const NFSMNT_READDIRSIZE: ::c_int = 0x20000; // Set readdir size
1348
1349/* Flags valid only in mount syscall arguments */
1350pub const NFSMNT_ACREGMIN: ::c_int = 0x40000; // acregmin field valid
1351pub const NFSMNT_ACREGMAX: ::c_int = 0x80000; // acregmax field valid
1352pub const NFSMNT_ACDIRMIN: ::c_int = 0x100000; // acdirmin field valid
1353pub const NFSMNT_ACDIRMAX: ::c_int = 0x200000; // acdirmax field valid
1354
1355/* Flags valid only in kernel */
1356pub const NFSMNT_INTERNAL: ::c_int = 0xfffc0000; // Bits set internally
1357pub const NFSMNT_HASWRITEVERF: ::c_int = 0x40000; // Has write verifier for V3
1358pub const NFSMNT_GOTPATHCONF: ::c_int = 0x80000; // Got the V3 pathconf info
1359pub const NFSMNT_GOTFSINFO: ::c_int = 0x100000; // Got the V3 fsinfo
1360pub const NFSMNT_MNTD: ::c_int = 0x200000; // Mnt server for mnt point
1361pub const NFSMNT_DISMINPROG: ::c_int = 0x400000; // Dismount in progress
1362pub const NFSMNT_DISMNT: ::c_int = 0x800000; // Dismounted
1363pub const NFSMNT_SNDLOCK: ::c_int = 0x1000000; // Send socket lock
1364pub const NFSMNT_WANTSND: ::c_int = 0x2000000; // Want above
1365pub const NFSMNT_RCVLOCK: ::c_int = 0x4000000; // Rcv socket lock
1366pub const NFSMNT_WANTRCV: ::c_int = 0x8000000; // Want above
1367pub const NFSMNT_WAITAUTH: ::c_int = 0x10000000; // Wait for authentication
1368pub const NFSMNT_HASAUTH: ::c_int = 0x20000000; // Has authenticator
1369pub const NFSMNT_WANTAUTH: ::c_int = 0x40000000; // Wants an authenticator
1370pub const NFSMNT_AUTHERR: ::c_int = 0x80000000; // Authentication error
1371
1372pub const MSDOSFSMNT_SHORTNAME: ::c_int = 0x1; // Force old DOS short names only
1373pub const MSDOSFSMNT_LONGNAME: ::c_int = 0x2; // Force Win'95 long names
1374pub const MSDOSFSMNT_NOWIN95: ::c_int = 0x4; // Completely ignore Win95 entries
1375
1376pub const NTFS_MFLAG_CASEINS: ::c_int = 0x1;
1377pub const NTFS_MFLAG_ALLNAMES: ::c_int = 0x2;
1378
1379pub const TMPFS_ARGS_VERSION: ::c_int = 1;
1380
e74abb32 1381pub const MAP_STACK: ::c_int = 0x4000;
17df50a5 1382pub const MAP_CONCEAL: ::c_int = 0x8000;
416331ca
XL
1383
1384// https://github.com/openbsd/src/blob/master/sys/net/if.h#L187
1385pub const IFF_UP: ::c_int = 0x1; // interface is up
1386pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
1387pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
1388pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
1389pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
1390pub const IFF_STATICARP: ::c_int = 0x20; // only static ARP
1391pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
1392pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
1393pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
1394pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
1395pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress
1396pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
1397pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
1398pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
1399pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
1400pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
1401
ba9703b0
XL
1402pub const PTHREAD_STACK_MIN: ::size_t = 1_usize << _MAX_PAGE_SHIFT;
1403pub const MINSIGSTKSZ: ::size_t = 3_usize << _MAX_PAGE_SHIFT;
e74abb32 1404pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + (1_usize << _MAX_PAGE_SHIFT) * 4;
416331ca
XL
1405
1406pub const PT_FIRSTMACH: ::c_int = 32;
1407
ea8adc8c
XL
1408pub const SOCK_CLOEXEC: ::c_int = 0x8000;
1409pub const SOCK_NONBLOCK: ::c_int = 0x4000;
1410pub const SOCK_DNS: ::c_int = 0x1000;
1411
e74abb32
XL
1412pub const BIOCGRSIG: ::c_ulong = 0x40044273;
1413pub const BIOCSRSIG: ::c_ulong = 0x80044272;
1414pub const BIOCSDLT: ::c_ulong = 0x8004427a;
1415
69743fb6
XL
1416pub const PTRACE_FORK: ::c_int = 0x0002;
1417
ff7c6d11
XL
1418pub const WCONTINUED: ::c_int = 8;
1419
cdc7bbd5
XL
1420const_fn! {
1421 {const} fn _ALIGN(p: usize) -> usize {
1422 (p + _ALIGNBYTES) & !_ALIGNBYTES
1423 }
416331ca
XL
1424}
1425
ea8adc8c 1426f! {
5869c6ff 1427 pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
416331ca
XL
1428 (cmsg as *mut ::c_uchar)
1429 .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
1430 }
1431
1432 pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1433 _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
1434 }
1435
1436 pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
1437 -> *mut ::cmsghdr
1438 {
1439 if cmsg.is_null() {
1440 return ::CMSG_FIRSTHDR(mhdr);
1441 };
1442 let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
1443 + _ALIGN(::mem::size_of::<::cmsghdr>());
1444 let max = (*mhdr).msg_control as usize
1445 + (*mhdr).msg_controllen as usize;
1446 if next > max {
1447 0 as *mut ::cmsghdr
1448 } else {
1449 (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
1450 as *mut ::cmsghdr
1451 }
1452 }
1453
cdc7bbd5 1454 pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
416331ca
XL
1455 (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
1456 as ::c_uint
1457 }
29967ef6 1458}
416331ca 1459
29967ef6
XL
1460safe_f! {
1461 pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
416331ca
XL
1462 status >> 8
1463 }
1464
29967ef6 1465 pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
416331ca
XL
1466 (status & 0o177) != 0o177 && (status & 0o177) != 0
1467 }
1468
29967ef6 1469 pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
3dfed10e 1470 (status & 0xff) == 0o177
416331ca 1471 }
5869c6ff
XL
1472
1473 pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
1474 (status & 0o177777) == 0o177777
1475 }
ea8adc8c
XL
1476}
1477
e74abb32
XL
1478extern "C" {
1479 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
cdc7bbd5 1480 pub fn settimeofday(tp: *const ::timeval, tz: *const ::timezone) -> ::c_int;
e74abb32
XL
1481 pub fn execvpe(
1482 file: *const ::c_char,
1483 argv: *const *const ::c_char,
1484 envp: *const *const ::c_char,
1485 ) -> ::c_int;
cdc7bbd5 1486 pub fn pledge(promises: *const ::c_char, execpromises: *const ::c_char) -> ::c_int;
17df50a5 1487 pub fn unveil(path: *const ::c_char, permissions: *const ::c_char) -> ::c_int;
e74abb32
XL
1488 pub fn strtonum(
1489 nptr: *const ::c_char,
1490 minval: ::c_longlong,
1491 maxval: ::c_longlong,
1492 errstr: *mut *const ::c_char,
1493 ) -> ::c_longlong;
416331ca 1494 pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
69743fb6
XL
1495 pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int;
1496 pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int;
e74abb32
XL
1497 pub fn chflagsat(
1498 fd: ::c_int,
1499 path: *const ::c_char,
1500 flags: ::c_uint,
1501 atflag: ::c_int,
1502 ) -> ::c_int;
041b39d2 1503 pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
e74abb32
XL
1504 pub fn getnameinfo(
1505 sa: *const ::sockaddr,
1506 salen: ::socklen_t,
1507 host: *mut ::c_char,
1508 hostlen: ::size_t,
1509 serv: *mut ::c_char,
1510 servlen: ::size_t,
1511 flags: ::c_int,
1512 ) -> ::c_int;
1513 pub fn kevent(
1514 kq: ::c_int,
1515 changelist: *const ::kevent,
1516 nchanges: ::c_int,
1517 eventlist: *mut ::kevent,
1518 nevents: ::c_int,
1519 timeout: *const ::timespec,
1520 ) -> ::c_int;
cdc7bbd5 1521 pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
dfeec247
XL
1522 pub fn pthread_attr_getguardsize(
1523 attr: *const ::pthread_attr_t,
1524 guardsize: *mut ::size_t,
1525 ) -> ::c_int;
1526 pub fn pthread_attr_getstack(
1527 attr: *const ::pthread_attr_t,
1528 stackaddr: *mut *mut ::c_void,
1529 stacksize: *mut ::size_t,
1530 ) -> ::c_int;
476ff2be
SL
1531 pub fn pthread_main_np() -> ::c_int;
1532 pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
cdc7bbd5 1533 pub fn pthread_stackseg_np(thread: ::pthread_t, sinfo: *mut ::stack_t) -> ::c_int;
136023e0 1534
e74abb32
XL
1535 pub fn sysctl(
1536 name: *const ::c_int,
1537 namelen: ::c_uint,
1538 oldp: *mut ::c_void,
1539 oldlenp: *mut ::size_t,
1540 newp: *mut ::c_void,
1541 newlen: ::size_t,
1542 ) -> ::c_int;
476ff2be 1543 pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
ea8adc8c
XL
1544 pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
1545 pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
cdc7bbd5 1546 pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: caddr_t, data: ::c_int) -> ::c_int;
ba9703b0
XL
1547 pub fn memmem(
1548 haystack: *const ::c_void,
1549 haystacklen: ::size_t,
1550 needle: *const ::c_void,
1551 needlelen: ::size_t,
1552 ) -> *mut ::c_void;
5869c6ff
XL
1553 // #include <link.h>
1554 pub fn dl_iterate_phdr(
1555 callback: ::Option<
1556 unsafe extern "C" fn(
1557 info: *mut dl_phdr_info,
1558 size: usize,
1559 data: *mut ::c_void,
1560 ) -> ::c_int,
1561 >,
1562 data: *mut ::c_void,
1563 ) -> ::c_int;
17df50a5
XL
1564 pub fn uselocale(loc: ::locale_t) -> ::locale_t;
1565 pub fn freelocale(loc: ::locale_t);
1566 pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
1567 pub fn duplocale(base: ::locale_t) -> ::locale_t;
1568
1569 // Added in `OpenBSD` 5.5
1570 pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t);
136023e0
XL
1571
1572 pub fn setproctitle(fmt: *const ::c_char, ...);
476ff2be
SL
1573}
1574
1575cfg_if! {
416331ca
XL
1576 if #[cfg(libc_union)] {
1577 extern {
1578 // these functions use statfs which uses the union mount_info:
1579 pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
1580 pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
1581 }
1582 }
1583}
1584
1585cfg_if! {
1586 if #[cfg(target_arch = "x86")] {
1587 mod x86;
1588 pub use self::x86::*;
1589 } else if #[cfg(target_arch = "x86_64")] {
1590 mod x86_64;
1591 pub use self::x86_64::*;
1592 } else if #[cfg(target_arch = "aarch64")] {
1593 mod aarch64;
1594 pub use self::aarch64::*;
e74abb32
XL
1595 } else if #[cfg(target_arch = "sparc64")] {
1596 mod sparc64;
1597 pub use self::sparc64::*;
476ff2be 1598 } else {
416331ca 1599 // Unknown target_arch
476ff2be
SL
1600 }
1601}