libc/unix/bsd/freebsdlike/
mod.rs

1use crate::off_t;
2use crate::prelude::*;
3
4pub type mode_t = u16;
5pub type pthread_attr_t = *mut c_void;
6pub type rlim_t = i64;
7pub type pthread_mutex_t = *mut c_void;
8pub type pthread_mutexattr_t = *mut c_void;
9pub type pthread_cond_t = *mut c_void;
10pub type pthread_condattr_t = *mut c_void;
11pub type pthread_rwlock_t = *mut c_void;
12pub type pthread_rwlockattr_t = *mut c_void;
13pub type pthread_key_t = c_int;
14pub type tcflag_t = c_uint;
15pub type speed_t = c_uint;
16pub type nl_item = c_int;
17pub type id_t = i64;
18pub type vm_size_t = crate::uintptr_t;
19pub type key_t = c_long;
20
21// elf.h
22
23pub type Elf32_Addr = u32;
24pub type Elf32_Half = u16;
25pub type Elf32_Lword = u64;
26pub type Elf32_Off = u32;
27pub type Elf32_Sword = i32;
28pub type Elf32_Word = u32;
29
30pub type Elf64_Addr = u64;
31pub type Elf64_Half = u16;
32pub type Elf64_Lword = u64;
33pub type Elf64_Off = u64;
34pub type Elf64_Sword = i32;
35pub type Elf64_Sxword = i64;
36pub type Elf64_Word = u32;
37pub type Elf64_Xword = u64;
38
39pub type iconv_t = *mut c_void;
40
41// It's an alias over "struct __kvm_t". However, its fields aren't supposed to be used directly,
42// making the type definition system dependent. Better not bind it exactly.
43pub type kvm_t = c_void;
44
45pub type posix_spawnattr_t = *mut c_void;
46pub type posix_spawn_file_actions_t = *mut c_void;
47
48cfg_if! {
49    if #[cfg(target_pointer_width = "64")] {
50        type Elf_Addr = Elf64_Addr;
51        type Elf_Half = Elf64_Half;
52        type Elf_Phdr = Elf64_Phdr;
53    } else if #[cfg(target_pointer_width = "32")] {
54        type Elf_Addr = Elf32_Addr;
55        type Elf_Half = Elf32_Half;
56        type Elf_Phdr = Elf32_Phdr;
57    }
58}
59
60// link.h
61
62extern_ty! {
63    pub enum timezone {}
64}
65
66impl siginfo_t {
67    pub unsafe fn si_addr(&self) -> *mut c_void {
68        self.si_addr
69    }
70
71    pub unsafe fn si_value(&self) -> crate::sigval {
72        self.si_value
73    }
74
75    pub unsafe fn si_pid(&self) -> crate::pid_t {
76        self.si_pid
77    }
78
79    pub unsafe fn si_uid(&self) -> crate::uid_t {
80        self.si_uid
81    }
82
83    pub unsafe fn si_status(&self) -> c_int {
84        self.si_status
85    }
86}
87
88s! {
89    pub struct in_addr {
90        pub s_addr: crate::in_addr_t,
91    }
92
93    pub struct ip_mreq {
94        pub imr_multiaddr: in_addr,
95        pub imr_interface: in_addr,
96    }
97
98    pub struct ip_mreqn {
99        pub imr_multiaddr: in_addr,
100        pub imr_address: in_addr,
101        pub imr_ifindex: c_int,
102    }
103
104    pub struct ip_mreq_source {
105        pub imr_multiaddr: in_addr,
106        pub imr_sourceaddr: in_addr,
107        pub imr_interface: in_addr,
108    }
109
110    pub struct glob_t {
111        pub gl_pathc: size_t,
112        pub gl_matchc: size_t,
113        pub gl_offs: size_t,
114        pub gl_flags: c_int,
115        pub gl_pathv: *mut *mut c_char,
116        __unused3: Padding<*mut c_void>,
117        __unused4: Padding<*mut c_void>,
118        __unused5: Padding<*mut c_void>,
119        __unused6: Padding<*mut c_void>,
120        __unused7: Padding<*mut c_void>,
121        __unused8: Padding<*mut c_void>,
122    }
123
124    pub struct addrinfo {
125        pub ai_flags: c_int,
126        pub ai_family: c_int,
127        pub ai_socktype: c_int,
128        pub ai_protocol: c_int,
129        pub ai_addrlen: crate::socklen_t,
130        pub ai_canonname: *mut c_char,
131        pub ai_addr: *mut crate::sockaddr,
132        pub ai_next: *mut addrinfo,
133    }
134
135    pub struct sigset_t {
136        bits: [u32; 4],
137    }
138
139    pub struct siginfo_t {
140        pub si_signo: c_int,
141        pub si_errno: c_int,
142        pub si_code: c_int,
143        pub si_pid: crate::pid_t,
144        pub si_uid: crate::uid_t,
145        pub si_status: c_int,
146        pub si_addr: *mut c_void,
147        pub si_value: crate::sigval,
148        _pad1: Padding<c_long>,
149        _pad2: Padding<[c_int; 7]>,
150    }
151
152    pub struct sigaction {
153        pub sa_sigaction: crate::sighandler_t,
154        pub sa_flags: c_int,
155        pub sa_mask: sigset_t,
156    }
157
158    pub struct sched_param {
159        pub sched_priority: c_int,
160    }
161
162    pub struct Dl_info {
163        pub dli_fname: *const c_char,
164        pub dli_fbase: *mut c_void,
165        pub dli_sname: *const c_char,
166        pub dli_saddr: *mut c_void,
167    }
168
169    pub struct sockaddr_in {
170        pub sin_len: u8,
171        pub sin_family: crate::sa_family_t,
172        pub sin_port: crate::in_port_t,
173        pub sin_addr: crate::in_addr,
174        pub sin_zero: [c_char; 8],
175    }
176
177    pub struct termios {
178        pub c_iflag: crate::tcflag_t,
179        pub c_oflag: crate::tcflag_t,
180        pub c_cflag: crate::tcflag_t,
181        pub c_lflag: crate::tcflag_t,
182        pub c_cc: [crate::cc_t; crate::NCCS],
183        pub c_ispeed: crate::speed_t,
184        pub c_ospeed: crate::speed_t,
185    }
186
187    pub struct flock {
188        pub l_start: off_t,
189        pub l_len: off_t,
190        pub l_pid: crate::pid_t,
191        pub l_type: c_short,
192        pub l_whence: c_short,
193        #[cfg(not(target_os = "dragonfly"))]
194        pub l_sysid: c_int,
195    }
196
197    pub struct sf_hdtr {
198        pub headers: *mut crate::iovec,
199        pub hdr_cnt: c_int,
200        pub trailers: *mut crate::iovec,
201        pub trl_cnt: c_int,
202    }
203
204    pub struct lconv {
205        pub decimal_point: *mut c_char,
206        pub thousands_sep: *mut c_char,
207        pub grouping: *mut c_char,
208        pub int_curr_symbol: *mut c_char,
209        pub currency_symbol: *mut c_char,
210        pub mon_decimal_point: *mut c_char,
211        pub mon_thousands_sep: *mut c_char,
212        pub mon_grouping: *mut c_char,
213        pub positive_sign: *mut c_char,
214        pub negative_sign: *mut c_char,
215        pub int_frac_digits: c_char,
216        pub frac_digits: c_char,
217        pub p_cs_precedes: c_char,
218        pub p_sep_by_space: c_char,
219        pub n_cs_precedes: c_char,
220        pub n_sep_by_space: c_char,
221        pub p_sign_posn: c_char,
222        pub n_sign_posn: c_char,
223        pub int_p_cs_precedes: c_char,
224        pub int_n_cs_precedes: c_char,
225        pub int_p_sep_by_space: c_char,
226        pub int_n_sep_by_space: c_char,
227        pub int_p_sign_posn: c_char,
228        pub int_n_sign_posn: c_char,
229    }
230
231    pub struct cmsgcred {
232        pub cmcred_pid: crate::pid_t,
233        pub cmcred_uid: crate::uid_t,
234        pub cmcred_euid: crate::uid_t,
235        pub cmcred_gid: crate::gid_t,
236        pub cmcred_ngroups: c_short,
237        pub cmcred_groups: [crate::gid_t; CMGROUP_MAX],
238    }
239
240    pub struct rtprio {
241        pub type_: c_ushort,
242        pub prio: c_ushort,
243    }
244
245    pub struct in6_pktinfo {
246        pub ipi6_addr: crate::in6_addr,
247        pub ipi6_ifindex: c_uint,
248    }
249
250    pub struct arphdr {
251        pub ar_hrd: u16,
252        pub ar_pro: u16,
253        pub ar_hln: u8,
254        pub ar_pln: u8,
255        pub ar_op: u16,
256    }
257
258    pub struct timex {
259        pub modes: c_uint,
260        pub offset: c_long,
261        pub freq: c_long,
262        pub maxerror: c_long,
263        pub esterror: c_long,
264        pub status: c_int,
265        pub constant: c_long,
266        pub precision: c_long,
267        pub tolerance: c_long,
268        pub ppsfreq: c_long,
269        pub jitter: c_long,
270        pub shift: c_int,
271        pub stabil: c_long,
272        pub jitcnt: c_long,
273        pub calcnt: c_long,
274        pub errcnt: c_long,
275        pub stbcnt: c_long,
276    }
277
278    pub struct ntptimeval {
279        pub time: crate::timespec,
280        pub maxerror: c_long,
281        pub esterror: c_long,
282        pub tai: c_long,
283        pub time_state: c_int,
284    }
285
286    pub struct accept_filter_arg {
287        pub af_name: [c_char; 16],
288        af_arg: [c_char; 256 - 16],
289    }
290
291    pub struct ptrace_io_desc {
292        pub piod_op: c_int,
293        pub piod_offs: *mut c_void,
294        pub piod_addr: *mut c_void,
295        pub piod_len: size_t,
296    }
297
298    // bpf.h
299
300    pub struct bpf_program {
301        pub bf_len: c_uint,
302        pub bf_insns: *mut bpf_insn,
303    }
304
305    pub struct bpf_stat {
306        pub bs_recv: c_uint,
307        pub bs_drop: c_uint,
308    }
309
310    pub struct bpf_version {
311        pub bv_major: c_ushort,
312        pub bv_minor: c_ushort,
313    }
314
315    pub struct bpf_hdr {
316        pub bh_tstamp: crate::timeval,
317        pub bh_caplen: u32,
318        pub bh_datalen: u32,
319        pub bh_hdrlen: c_ushort,
320    }
321
322    pub struct bpf_insn {
323        pub code: c_ushort,
324        pub jt: c_uchar,
325        pub jf: c_uchar,
326        pub k: u32,
327    }
328
329    pub struct bpf_dltlist {
330        bfl_len: c_uint,
331        bfl_list: *mut c_uint,
332    }
333
334    // elf.h
335
336    pub struct Elf32_Phdr {
337        pub p_type: Elf32_Word,
338        pub p_offset: Elf32_Off,
339        pub p_vaddr: Elf32_Addr,
340        pub p_paddr: Elf32_Addr,
341        pub p_filesz: Elf32_Word,
342        pub p_memsz: Elf32_Word,
343        pub p_flags: Elf32_Word,
344        pub p_align: Elf32_Word,
345    }
346
347    pub struct Elf64_Phdr {
348        pub p_type: Elf64_Word,
349        pub p_flags: Elf64_Word,
350        pub p_offset: Elf64_Off,
351        pub p_vaddr: Elf64_Addr,
352        pub p_paddr: Elf64_Addr,
353        pub p_filesz: Elf64_Xword,
354        pub p_memsz: Elf64_Xword,
355        pub p_align: Elf64_Xword,
356    }
357
358    // link.h
359
360    pub struct dl_phdr_info {
361        pub dlpi_addr: Elf_Addr,
362        pub dlpi_name: *const c_char,
363        pub dlpi_phdr: *const Elf_Phdr,
364        pub dlpi_phnum: Elf_Half,
365        pub dlpi_adds: c_ulonglong,
366        pub dlpi_subs: c_ulonglong,
367        pub dlpi_tls_modid: usize,
368        pub dlpi_tls_data: *mut c_void,
369    }
370
371    pub struct ipc_perm {
372        pub cuid: crate::uid_t,
373        pub cgid: crate::gid_t,
374        pub uid: crate::uid_t,
375        pub gid: crate::gid_t,
376        pub mode: mode_t,
377        pub seq: c_ushort,
378        pub key: crate::key_t,
379    }
380
381    pub struct eui64 {
382        pub octet: [u8; EUI64_LEN],
383    }
384
385    pub struct sockaddr_storage {
386        pub ss_len: u8,
387        pub ss_family: crate::sa_family_t,
388        __ss_pad1: Padding<[u8; 6]>,
389        __ss_align: i64,
390        __ss_pad2: Padding<[u8; 112]>,
391    }
392}
393
394// Non-public helper constant
395const SIZEOF_LONG: usize = size_of::<c_long>();
396
397#[deprecated(
398    since = "0.2.64",
399    note = "Can vary at runtime.  Use sysconf(3) instead"
400)]
401pub const AIO_LISTIO_MAX: c_int = 16;
402pub const AIO_CANCELED: c_int = 1;
403pub const AIO_NOTCANCELED: c_int = 2;
404pub const AIO_ALLDONE: c_int = 3;
405pub const LIO_NOP: c_int = 0;
406pub const LIO_WRITE: c_int = 1;
407pub const LIO_READ: c_int = 2;
408pub const LIO_WAIT: c_int = 1;
409pub const LIO_NOWAIT: c_int = 0;
410
411pub const SIGEV_NONE: c_int = 0;
412pub const SIGEV_SIGNAL: c_int = 1;
413pub const SIGEV_THREAD: c_int = 2;
414pub const SIGEV_KEVENT: c_int = 3;
415
416pub const CODESET: crate::nl_item = 0;
417pub const D_T_FMT: crate::nl_item = 1;
418pub const D_FMT: crate::nl_item = 2;
419pub const T_FMT: crate::nl_item = 3;
420pub const T_FMT_AMPM: crate::nl_item = 4;
421pub const AM_STR: crate::nl_item = 5;
422pub const PM_STR: crate::nl_item = 6;
423
424pub const DAY_1: crate::nl_item = 7;
425pub const DAY_2: crate::nl_item = 8;
426pub const DAY_3: crate::nl_item = 9;
427pub const DAY_4: crate::nl_item = 10;
428pub const DAY_5: crate::nl_item = 11;
429pub const DAY_6: crate::nl_item = 12;
430pub const DAY_7: crate::nl_item = 13;
431
432pub const ABDAY_1: crate::nl_item = 14;
433pub const ABDAY_2: crate::nl_item = 15;
434pub const ABDAY_3: crate::nl_item = 16;
435pub const ABDAY_4: crate::nl_item = 17;
436pub const ABDAY_5: crate::nl_item = 18;
437pub const ABDAY_6: crate::nl_item = 19;
438pub const ABDAY_7: crate::nl_item = 20;
439
440pub const MON_1: crate::nl_item = 21;
441pub const MON_2: crate::nl_item = 22;
442pub const MON_3: crate::nl_item = 23;
443pub const MON_4: crate::nl_item = 24;
444pub const MON_5: crate::nl_item = 25;
445pub const MON_6: crate::nl_item = 26;
446pub const MON_7: crate::nl_item = 27;
447pub const MON_8: crate::nl_item = 28;
448pub const MON_9: crate::nl_item = 29;
449pub const MON_10: crate::nl_item = 30;
450pub const MON_11: crate::nl_item = 31;
451pub const MON_12: crate::nl_item = 32;
452
453pub const ABMON_1: crate::nl_item = 33;
454pub const ABMON_2: crate::nl_item = 34;
455pub const ABMON_3: crate::nl_item = 35;
456pub const ABMON_4: crate::nl_item = 36;
457pub const ABMON_5: crate::nl_item = 37;
458pub const ABMON_6: crate::nl_item = 38;
459pub const ABMON_7: crate::nl_item = 39;
460pub const ABMON_8: crate::nl_item = 40;
461pub const ABMON_9: crate::nl_item = 41;
462pub const ABMON_10: crate::nl_item = 42;
463pub const ABMON_11: crate::nl_item = 43;
464pub const ABMON_12: crate::nl_item = 44;
465
466pub const ERA: crate::nl_item = 45;
467pub const ERA_D_FMT: crate::nl_item = 46;
468pub const ERA_D_T_FMT: crate::nl_item = 47;
469pub const ERA_T_FMT: crate::nl_item = 48;
470pub const ALT_DIGITS: crate::nl_item = 49;
471
472pub const RADIXCHAR: crate::nl_item = 50;
473pub const THOUSEP: crate::nl_item = 51;
474
475pub const YESEXPR: crate::nl_item = 52;
476pub const NOEXPR: crate::nl_item = 53;
477
478pub const YESSTR: crate::nl_item = 54;
479pub const NOSTR: crate::nl_item = 55;
480
481pub const CRNCYSTR: crate::nl_item = 56;
482
483pub const D_MD_ORDER: crate::nl_item = 57;
484
485pub const ALTMON_1: crate::nl_item = 58;
486pub const ALTMON_2: crate::nl_item = 59;
487pub const ALTMON_3: crate::nl_item = 60;
488pub const ALTMON_4: crate::nl_item = 61;
489pub const ALTMON_5: crate::nl_item = 62;
490pub const ALTMON_6: crate::nl_item = 63;
491pub const ALTMON_7: crate::nl_item = 64;
492pub const ALTMON_8: crate::nl_item = 65;
493pub const ALTMON_9: crate::nl_item = 66;
494pub const ALTMON_10: crate::nl_item = 67;
495pub const ALTMON_11: crate::nl_item = 68;
496pub const ALTMON_12: crate::nl_item = 69;
497
498pub const EXIT_FAILURE: c_int = 1;
499pub const EXIT_SUCCESS: c_int = 0;
500pub const EOF: c_int = -1;
501pub const SEEK_SET: c_int = 0;
502pub const SEEK_CUR: c_int = 1;
503pub const SEEK_END: c_int = 2;
504pub const SEEK_DATA: c_int = 3;
505pub const SEEK_HOLE: c_int = 4;
506pub const _IOFBF: c_int = 0;
507pub const _IONBF: c_int = 2;
508pub const _IOLBF: c_int = 1;
509pub const BUFSIZ: c_uint = 1024;
510pub const FOPEN_MAX: c_uint = 20;
511pub const FILENAME_MAX: c_uint = 1024;
512pub const L_tmpnam: c_uint = 1024;
513pub const TMP_MAX: c_uint = 308915776;
514
515pub const O_NOCTTY: c_int = 32768;
516pub const O_DIRECT: c_int = 0x00010000;
517
518pub const S_IFIFO: mode_t = 0o1_0000;
519pub const S_IFCHR: mode_t = 0o2_0000;
520pub const S_IFBLK: mode_t = 0o6_0000;
521pub const S_IFDIR: mode_t = 0o4_0000;
522pub const S_IFREG: mode_t = 0o10_0000;
523pub const S_IFLNK: mode_t = 0o12_0000;
524pub const S_IFSOCK: mode_t = 0o14_0000;
525pub const S_IFMT: mode_t = 0o17_0000;
526pub const S_IEXEC: mode_t = 0o0100;
527pub const S_IWRITE: mode_t = 0o0200;
528pub const S_IREAD: mode_t = 0o0400;
529pub const S_IRWXU: mode_t = 0o0700;
530pub const S_IXUSR: mode_t = 0o0100;
531pub const S_IWUSR: mode_t = 0o0200;
532pub const S_IRUSR: mode_t = 0o0400;
533pub const S_IRWXG: mode_t = 0o0070;
534pub const S_IXGRP: mode_t = 0o0010;
535pub const S_IWGRP: mode_t = 0o0020;
536pub const S_IRGRP: mode_t = 0o0040;
537pub const S_IRWXO: mode_t = 0o0007;
538pub const S_IXOTH: mode_t = 0o0001;
539pub const S_IWOTH: mode_t = 0o0002;
540pub const S_IROTH: mode_t = 0o0004;
541pub const F_OK: c_int = 0;
542pub const R_OK: c_int = 4;
543pub const W_OK: c_int = 2;
544pub const X_OK: c_int = 1;
545pub const F_LOCK: c_int = 1;
546pub const F_TEST: c_int = 3;
547pub const F_TLOCK: c_int = 2;
548pub const F_ULOCK: c_int = 0;
549pub const F_DUPFD_CLOEXEC: c_int = 17;
550pub const F_DUP2FD: c_int = 10;
551pub const F_DUP2FD_CLOEXEC: c_int = 18;
552pub const SIGHUP: c_int = 1;
553pub const SIGINT: c_int = 2;
554pub const SIGQUIT: c_int = 3;
555pub const SIGILL: c_int = 4;
556pub const SIGABRT: c_int = 6;
557pub const SIGEMT: c_int = 7;
558pub const SIGFPE: c_int = 8;
559pub const SIGKILL: c_int = 9;
560pub const SIGSEGV: c_int = 11;
561pub const SIGPIPE: c_int = 13;
562pub const SIGALRM: c_int = 14;
563pub const SIGTERM: c_int = 15;
564
565pub const PROT_NONE: c_int = 0;
566pub const PROT_READ: c_int = 1;
567pub const PROT_WRITE: c_int = 2;
568pub const PROT_EXEC: c_int = 4;
569
570pub const MAP_FILE: c_int = 0x0000;
571pub const MAP_SHARED: c_int = 0x0001;
572pub const MAP_PRIVATE: c_int = 0x0002;
573pub const MAP_FIXED: c_int = 0x0010;
574pub const MAP_ANON: c_int = 0x1000;
575pub const MAP_ANONYMOUS: c_int = MAP_ANON;
576
577pub const MAP_FAILED: *mut c_void = !0 as *mut c_void;
578
579pub const MCL_CURRENT: c_int = 0x0001;
580pub const MCL_FUTURE: c_int = 0x0002;
581
582pub const MNT_EXPUBLIC: c_int = 0x20000000;
583pub const MNT_NOATIME: c_int = 0x10000000;
584pub const MNT_NOCLUSTERR: c_int = 0x40000000;
585pub const MNT_NOCLUSTERW: c_int = 0x80000000;
586pub const MNT_NOSYMFOLLOW: c_int = 0x00400000;
587pub const MNT_SOFTDEP: c_int = 0x00200000;
588pub const MNT_SUIDDIR: c_int = 0x00100000;
589pub const MNT_EXRDONLY: c_int = 0x00000080;
590pub const MNT_DEFEXPORTED: c_int = 0x00000200;
591pub const MNT_EXPORTANON: c_int = 0x00000400;
592pub const MNT_EXKERB: c_int = 0x00000800;
593pub const MNT_DELEXPORT: c_int = 0x00020000;
594
595pub const MS_SYNC: c_int = 0x0000;
596pub const MS_ASYNC: c_int = 0x0001;
597pub const MS_INVALIDATE: c_int = 0x0002;
598
599pub const EPERM: c_int = 1;
600pub const ENOENT: c_int = 2;
601pub const ESRCH: c_int = 3;
602pub const EINTR: c_int = 4;
603pub const EIO: c_int = 5;
604pub const ENXIO: c_int = 6;
605pub const E2BIG: c_int = 7;
606pub const ENOEXEC: c_int = 8;
607pub const EBADF: c_int = 9;
608pub const ECHILD: c_int = 10;
609pub const EDEADLK: c_int = 11;
610pub const ENOMEM: c_int = 12;
611pub const EACCES: c_int = 13;
612pub const EFAULT: c_int = 14;
613pub const ENOTBLK: c_int = 15;
614pub const EBUSY: c_int = 16;
615pub const EEXIST: c_int = 17;
616pub const EXDEV: c_int = 18;
617pub const ENODEV: c_int = 19;
618pub const ENOTDIR: c_int = 20;
619pub const EISDIR: c_int = 21;
620pub const EINVAL: c_int = 22;
621pub const ENFILE: c_int = 23;
622pub const EMFILE: c_int = 24;
623pub const ENOTTY: c_int = 25;
624pub const ETXTBSY: c_int = 26;
625pub const EFBIG: c_int = 27;
626pub const ENOSPC: c_int = 28;
627pub const ESPIPE: c_int = 29;
628pub const EROFS: c_int = 30;
629pub const EMLINK: c_int = 31;
630pub const EPIPE: c_int = 32;
631pub const EDOM: c_int = 33;
632pub const ERANGE: c_int = 34;
633pub const EAGAIN: c_int = 35;
634pub const EWOULDBLOCK: c_int = 35;
635pub const EINPROGRESS: c_int = 36;
636pub const EALREADY: c_int = 37;
637pub const ENOTSOCK: c_int = 38;
638pub const EDESTADDRREQ: c_int = 39;
639pub const EMSGSIZE: c_int = 40;
640pub const EPROTOTYPE: c_int = 41;
641pub const ENOPROTOOPT: c_int = 42;
642pub const EPROTONOSUPPORT: c_int = 43;
643pub const ESOCKTNOSUPPORT: c_int = 44;
644pub const EOPNOTSUPP: c_int = 45;
645pub const ENOTSUP: c_int = EOPNOTSUPP;
646pub const EPFNOSUPPORT: c_int = 46;
647pub const EAFNOSUPPORT: c_int = 47;
648pub const EADDRINUSE: c_int = 48;
649pub const EADDRNOTAVAIL: c_int = 49;
650pub const ENETDOWN: c_int = 50;
651pub const ENETUNREACH: c_int = 51;
652pub const ENETRESET: c_int = 52;
653pub const ECONNABORTED: c_int = 53;
654pub const ECONNRESET: c_int = 54;
655pub const ENOBUFS: c_int = 55;
656pub const EISCONN: c_int = 56;
657pub const ENOTCONN: c_int = 57;
658pub const ESHUTDOWN: c_int = 58;
659pub const ETOOMANYREFS: c_int = 59;
660pub const ETIMEDOUT: c_int = 60;
661pub const ECONNREFUSED: c_int = 61;
662pub const ELOOP: c_int = 62;
663pub const ENAMETOOLONG: c_int = 63;
664pub const EHOSTDOWN: c_int = 64;
665pub const EHOSTUNREACH: c_int = 65;
666pub const ENOTEMPTY: c_int = 66;
667pub const EPROCLIM: c_int = 67;
668pub const EUSERS: c_int = 68;
669pub const EDQUOT: c_int = 69;
670pub const ESTALE: c_int = 70;
671pub const EREMOTE: c_int = 71;
672pub const EBADRPC: c_int = 72;
673pub const ERPCMISMATCH: c_int = 73;
674pub const EPROGUNAVAIL: c_int = 74;
675pub const EPROGMISMATCH: c_int = 75;
676pub const EPROCUNAVAIL: c_int = 76;
677pub const ENOLCK: c_int = 77;
678pub const ENOSYS: c_int = 78;
679pub const EFTYPE: c_int = 79;
680pub const EAUTH: c_int = 80;
681pub const ENEEDAUTH: c_int = 81;
682pub const EIDRM: c_int = 82;
683pub const ENOMSG: c_int = 83;
684pub const EOVERFLOW: c_int = 84;
685pub const ECANCELED: c_int = 85;
686pub const EILSEQ: c_int = 86;
687pub const ENOATTR: c_int = 87;
688pub const EDOOFUS: c_int = 88;
689pub const EBADMSG: c_int = 89;
690pub const EMULTIHOP: c_int = 90;
691pub const ENOLINK: c_int = 91;
692pub const EPROTO: c_int = 92;
693
694pub const POLLSTANDARD: c_short = crate::POLLIN
695    | crate::POLLPRI
696    | crate::POLLOUT
697    | crate::POLLRDNORM
698    | crate::POLLRDBAND
699    | crate::POLLWRBAND
700    | crate::POLLERR
701    | crate::POLLHUP
702    | crate::POLLNVAL;
703
704pub const AI_PASSIVE: c_int = 0x00000001;
705pub const AI_CANONNAME: c_int = 0x00000002;
706pub const AI_NUMERICHOST: c_int = 0x00000004;
707pub const AI_NUMERICSERV: c_int = 0x00000008;
708pub const AI_ALL: c_int = 0x00000100;
709pub const AI_ADDRCONFIG: c_int = 0x00000400;
710pub const AI_V4MAPPED: c_int = 0x00000800;
711
712pub const EAI_AGAIN: c_int = 2;
713pub const EAI_BADFLAGS: c_int = 3;
714pub const EAI_FAIL: c_int = 4;
715pub const EAI_FAMILY: c_int = 5;
716pub const EAI_MEMORY: c_int = 6;
717pub const EAI_NONAME: c_int = 8;
718pub const EAI_SERVICE: c_int = 9;
719pub const EAI_SOCKTYPE: c_int = 10;
720pub const EAI_SYSTEM: c_int = 11;
721pub const EAI_OVERFLOW: c_int = 14;
722
723pub const F_DUPFD: c_int = 0;
724pub const F_GETFD: c_int = 1;
725pub const F_SETFD: c_int = 2;
726pub const F_GETFL: c_int = 3;
727pub const F_SETFL: c_int = 4;
728
729pub const SIGTRAP: c_int = 5;
730
731pub const GLOB_APPEND: c_int = 0x0001;
732pub const GLOB_DOOFFS: c_int = 0x0002;
733pub const GLOB_ERR: c_int = 0x0004;
734pub const GLOB_MARK: c_int = 0x0008;
735pub const GLOB_NOCHECK: c_int = 0x0010;
736pub const GLOB_NOSORT: c_int = 0x0020;
737pub const GLOB_NOESCAPE: c_int = 0x2000;
738
739pub const GLOB_NOSPACE: c_int = -1;
740pub const GLOB_ABORTED: c_int = -2;
741pub const GLOB_NOMATCH: c_int = -3;
742
743pub const POSIX_MADV_NORMAL: c_int = 0;
744pub const POSIX_MADV_RANDOM: c_int = 1;
745pub const POSIX_MADV_SEQUENTIAL: c_int = 2;
746pub const POSIX_MADV_WILLNEED: c_int = 3;
747pub const POSIX_MADV_DONTNEED: c_int = 4;
748
749pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1;
750pub const PTHREAD_PROCESS_PRIVATE: c_int = 0;
751pub const PTHREAD_PROCESS_SHARED: c_int = 1;
752pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
753pub const PTHREAD_CREATE_DETACHED: c_int = 1;
754
755pub const RLIMIT_CPU: c_int = 0;
756pub const RLIMIT_FSIZE: c_int = 1;
757pub const RLIMIT_DATA: c_int = 2;
758pub const RLIMIT_STACK: c_int = 3;
759pub const RLIMIT_CORE: c_int = 4;
760pub const RLIMIT_RSS: c_int = 5;
761pub const RLIMIT_MEMLOCK: c_int = 6;
762pub const RLIMIT_NPROC: c_int = 7;
763pub const RLIMIT_NOFILE: c_int = 8;
764pub const RLIMIT_SBSIZE: c_int = 9;
765pub const RLIMIT_VMEM: c_int = 10;
766pub const RLIMIT_AS: c_int = RLIMIT_VMEM;
767pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
768
769pub const RUSAGE_SELF: c_int = 0;
770pub const RUSAGE_CHILDREN: c_int = -1;
771
772pub const CLOCK_REALTIME: crate::clockid_t = 0;
773pub const CLOCK_VIRTUAL: crate::clockid_t = 1;
774pub const CLOCK_PROF: crate::clockid_t = 2;
775pub const CLOCK_MONOTONIC: crate::clockid_t = 4;
776pub const CLOCK_UPTIME: crate::clockid_t = 5;
777pub const CLOCK_UPTIME_PRECISE: crate::clockid_t = 7;
778pub const CLOCK_UPTIME_FAST: crate::clockid_t = 8;
779pub const CLOCK_REALTIME_PRECISE: crate::clockid_t = 9;
780pub const CLOCK_REALTIME_FAST: crate::clockid_t = 10;
781pub const CLOCK_MONOTONIC_PRECISE: crate::clockid_t = 11;
782pub const CLOCK_MONOTONIC_FAST: crate::clockid_t = 12;
783pub const CLOCK_SECOND: crate::clockid_t = 13;
784pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 14;
785pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 15;
786
787pub const MADV_NORMAL: c_int = 0;
788pub const MADV_RANDOM: c_int = 1;
789pub const MADV_SEQUENTIAL: c_int = 2;
790pub const MADV_WILLNEED: c_int = 3;
791pub const MADV_DONTNEED: c_int = 4;
792pub const MADV_FREE: c_int = 5;
793pub const MADV_NOSYNC: c_int = 6;
794pub const MADV_AUTOSYNC: c_int = 7;
795pub const MADV_NOCORE: c_int = 8;
796pub const MADV_CORE: c_int = 9;
797
798pub const MINCORE_INCORE: c_int = 0x1;
799pub const MINCORE_REFERENCED: c_int = 0x2;
800pub const MINCORE_MODIFIED: c_int = 0x4;
801pub const MINCORE_REFERENCED_OTHER: c_int = 0x8;
802pub const MINCORE_MODIFIED_OTHER: c_int = 0x10;
803
804pub const AF_UNSPEC: c_int = 0;
805pub const AF_LOCAL: c_int = 1;
806pub const AF_UNIX: c_int = AF_LOCAL;
807pub const AF_INET: c_int = 2;
808pub const AF_IMPLINK: c_int = 3;
809pub const AF_PUP: c_int = 4;
810pub const AF_CHAOS: c_int = 5;
811pub const AF_NETBIOS: c_int = 6;
812pub const AF_ISO: c_int = 7;
813pub const AF_OSI: c_int = AF_ISO;
814pub const AF_ECMA: c_int = 8;
815pub const AF_DATAKIT: c_int = 9;
816pub const AF_CCITT: c_int = 10;
817pub const AF_SNA: c_int = 11;
818pub const AF_DECnet: c_int = 12;
819pub const AF_DLI: c_int = 13;
820pub const AF_LAT: c_int = 14;
821pub const AF_HYLINK: c_int = 15;
822pub const AF_APPLETALK: c_int = 16;
823pub const AF_ROUTE: c_int = 17;
824pub const AF_LINK: c_int = 18;
825pub const pseudo_AF_XTP: c_int = 19;
826pub const AF_COIP: c_int = 20;
827pub const AF_CNT: c_int = 21;
828pub const pseudo_AF_RTIP: c_int = 22;
829pub const AF_IPX: c_int = 23;
830pub const AF_SIP: c_int = 24;
831pub const pseudo_AF_PIP: c_int = 25;
832pub const AF_ISDN: c_int = 26;
833pub const AF_E164: c_int = AF_ISDN;
834pub const pseudo_AF_KEY: c_int = 27;
835pub const AF_INET6: c_int = 28;
836pub const AF_NATM: c_int = 29;
837pub const AF_ATM: c_int = 30;
838pub const pseudo_AF_HDRCMPLT: c_int = 31;
839pub const AF_NETGRAPH: c_int = 32;
840
841pub const PF_UNSPEC: c_int = AF_UNSPEC;
842pub const PF_LOCAL: c_int = AF_LOCAL;
843pub const PF_UNIX: c_int = PF_LOCAL;
844pub const PF_INET: c_int = AF_INET;
845pub const PF_IMPLINK: c_int = AF_IMPLINK;
846pub const PF_PUP: c_int = AF_PUP;
847pub const PF_CHAOS: c_int = AF_CHAOS;
848pub const PF_NETBIOS: c_int = AF_NETBIOS;
849pub const PF_ISO: c_int = AF_ISO;
850pub const PF_OSI: c_int = AF_ISO;
851pub const PF_ECMA: c_int = AF_ECMA;
852pub const PF_DATAKIT: c_int = AF_DATAKIT;
853pub const PF_CCITT: c_int = AF_CCITT;
854pub const PF_SNA: c_int = AF_SNA;
855pub const PF_DECnet: c_int = AF_DECnet;
856pub const PF_DLI: c_int = AF_DLI;
857pub const PF_LAT: c_int = AF_LAT;
858pub const PF_HYLINK: c_int = AF_HYLINK;
859pub const PF_APPLETALK: c_int = AF_APPLETALK;
860pub const PF_ROUTE: c_int = AF_ROUTE;
861pub const PF_LINK: c_int = AF_LINK;
862pub const PF_XTP: c_int = pseudo_AF_XTP;
863pub const PF_COIP: c_int = AF_COIP;
864pub const PF_CNT: c_int = AF_CNT;
865pub const PF_SIP: c_int = AF_SIP;
866pub const PF_IPX: c_int = AF_IPX;
867pub const PF_RTIP: c_int = pseudo_AF_RTIP;
868pub const PF_PIP: c_int = pseudo_AF_PIP;
869pub const PF_ISDN: c_int = AF_ISDN;
870pub const PF_KEY: c_int = pseudo_AF_KEY;
871pub const PF_INET6: c_int = AF_INET6;
872pub const PF_NATM: c_int = AF_NATM;
873pub const PF_ATM: c_int = AF_ATM;
874pub const PF_NETGRAPH: c_int = AF_NETGRAPH;
875
876pub const PIOD_READ_D: c_int = 1;
877pub const PIOD_WRITE_D: c_int = 2;
878pub const PIOD_READ_I: c_int = 3;
879pub const PIOD_WRITE_I: c_int = 4;
880
881pub const PT_TRACE_ME: c_int = 0;
882pub const PT_READ_I: c_int = 1;
883pub const PT_READ_D: c_int = 2;
884pub const PT_WRITE_I: c_int = 4;
885pub const PT_WRITE_D: c_int = 5;
886pub const PT_CONTINUE: c_int = 7;
887pub const PT_KILL: c_int = 8;
888pub const PT_STEP: c_int = 9;
889pub const PT_ATTACH: c_int = 10;
890pub const PT_DETACH: c_int = 11;
891pub const PT_IO: c_int = 12;
892
893pub const SOMAXCONN: c_int = 128;
894
895pub const MSG_OOB: c_int = 0x00000001;
896pub const MSG_PEEK: c_int = 0x00000002;
897pub const MSG_DONTROUTE: c_int = 0x00000004;
898pub const MSG_EOR: c_int = 0x00000008;
899pub const MSG_TRUNC: c_int = 0x00000010;
900pub const MSG_CTRUNC: c_int = 0x00000020;
901pub const MSG_WAITALL: c_int = 0x00000040;
902pub const MSG_DONTWAIT: c_int = 0x00000080;
903pub const MSG_EOF: c_int = 0x00000100;
904
905pub const SCM_TIMESTAMP: c_int = 0x02;
906pub const SCM_CREDS: c_int = 0x03;
907
908pub const SOCK_STREAM: c_int = 1;
909pub const SOCK_DGRAM: c_int = 2;
910pub const SOCK_RAW: c_int = 3;
911pub const SOCK_RDM: c_int = 4;
912pub const SOCK_SEQPACKET: c_int = 5;
913pub const SOCK_CLOEXEC: c_int = 0x10000000;
914pub const SOCK_NONBLOCK: c_int = 0x20000000;
915pub const SOCK_MAXADDRLEN: c_int = 255;
916pub const IP_TTL: c_int = 4;
917pub const IP_HDRINCL: c_int = 2;
918pub const IP_RECVDSTADDR: c_int = 7;
919pub const IP_SENDSRCADDR: c_int = IP_RECVDSTADDR;
920pub const IP_ADD_MEMBERSHIP: c_int = 12;
921pub const IP_DROP_MEMBERSHIP: c_int = 13;
922pub const IP_RECVIF: c_int = 20;
923pub const IP_RECVTTL: c_int = 65;
924pub const IPV6_RECVHOPLIMIT: c_int = 37;
925pub const IPV6_JOIN_GROUP: c_int = 12;
926pub const IPV6_LEAVE_GROUP: c_int = 13;
927pub const IPV6_CHECKSUM: c_int = 26;
928pub const IPV6_RECVPKTINFO: c_int = 36;
929pub const IPV6_PKTINFO: c_int = 46;
930pub const IPV6_HOPLIMIT: c_int = 47;
931pub const IPV6_RECVTCLASS: c_int = 57;
932pub const IPV6_TCLASS: c_int = 61;
933pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 70;
934pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 71;
935pub const IP_BLOCK_SOURCE: c_int = 72;
936pub const IP_UNBLOCK_SOURCE: c_int = 73;
937
938pub const TCP_NOPUSH: c_int = 4;
939pub const TCP_NOOPT: c_int = 8;
940pub const TCP_KEEPIDLE: c_int = 256;
941pub const TCP_KEEPINTVL: c_int = 512;
942pub const TCP_KEEPCNT: c_int = 1024;
943
944pub const SOL_SOCKET: c_int = 0xffff;
945pub const SO_DEBUG: c_int = 0x01;
946pub const SO_ACCEPTCONN: c_int = 0x0002;
947pub const SO_REUSEADDR: c_int = 0x0004;
948pub const SO_KEEPALIVE: c_int = 0x0008;
949pub const SO_DONTROUTE: c_int = 0x0010;
950pub const SO_BROADCAST: c_int = 0x0020;
951pub const SO_USELOOPBACK: c_int = 0x0040;
952pub const SO_LINGER: c_int = 0x0080;
953pub const SO_OOBINLINE: c_int = 0x0100;
954pub const SO_REUSEPORT: c_int = 0x0200;
955pub const SO_TIMESTAMP: c_int = 0x0400;
956pub const SO_NOSIGPIPE: c_int = 0x0800;
957pub const SO_ACCEPTFILTER: c_int = 0x1000;
958pub const SO_SNDBUF: c_int = 0x1001;
959pub const SO_RCVBUF: c_int = 0x1002;
960pub const SO_SNDLOWAT: c_int = 0x1003;
961pub const SO_RCVLOWAT: c_int = 0x1004;
962pub const SO_SNDTIMEO: c_int = 0x1005;
963pub const SO_RCVTIMEO: c_int = 0x1006;
964pub const SO_ERROR: c_int = 0x1007;
965pub const SO_TYPE: c_int = 0x1008;
966
967pub const LOCAL_PEERCRED: c_int = 1;
968
969// net/route.h
970pub const RTF_XRESOLVE: c_int = 0x200;
971pub const RTF_LLINFO: c_int = 0x400;
972pub const RTF_PROTO3: c_int = 0x40000;
973pub const RTF_PINNED: c_int = 0x100000;
974pub const RTF_LOCAL: c_int = 0x200000;
975pub const RTF_BROADCAST: c_int = 0x400000;
976pub const RTF_MULTICAST: c_int = 0x800000;
977
978pub const RTM_LOCK: c_int = 0x8;
979pub const RTM_RESOLVE: c_int = 0xb;
980pub const RTM_NEWADDR: c_int = 0xc;
981pub const RTM_DELADDR: c_int = 0xd;
982pub const RTM_IFINFO: c_int = 0xe;
983pub const RTM_NEWMADDR: c_int = 0xf;
984pub const RTM_DELMADDR: c_int = 0x10;
985pub const RTM_IFANNOUNCE: c_int = 0x11;
986pub const RTM_IEEE80211: c_int = 0x12;
987
988pub const SHUT_RD: c_int = 0;
989pub const SHUT_WR: c_int = 1;
990pub const SHUT_RDWR: c_int = 2;
991
992pub const LOCK_SH: c_int = 1;
993pub const LOCK_EX: c_int = 2;
994pub const LOCK_NB: c_int = 4;
995pub const LOCK_UN: c_int = 8;
996
997pub const MAP_COPY: c_int = 0x0002;
998#[doc(hidden)]
999#[deprecated(
1000    since = "0.2.54",
1001    note = "Removed in FreeBSD 11, unused in DragonFlyBSD"
1002)]
1003pub const MAP_RENAME: c_int = 0x0020;
1004#[doc(hidden)]
1005#[deprecated(
1006    since = "0.2.54",
1007    note = "Removed in FreeBSD 11, unused in DragonFlyBSD"
1008)]
1009pub const MAP_NORESERVE: c_int = 0x0040;
1010pub const MAP_HASSEMAPHORE: c_int = 0x0200;
1011pub const MAP_STACK: c_int = 0x0400;
1012pub const MAP_NOSYNC: c_int = 0x0800;
1013pub const MAP_NOCORE: c_int = 0x020000;
1014
1015pub const IPPROTO_RAW: c_int = 255;
1016
1017pub const _PC_LINK_MAX: c_int = 1;
1018pub const _PC_MAX_CANON: c_int = 2;
1019pub const _PC_MAX_INPUT: c_int = 3;
1020pub const _PC_NAME_MAX: c_int = 4;
1021pub const _PC_PATH_MAX: c_int = 5;
1022pub const _PC_PIPE_BUF: c_int = 6;
1023pub const _PC_CHOWN_RESTRICTED: c_int = 7;
1024pub const _PC_NO_TRUNC: c_int = 8;
1025pub const _PC_VDISABLE: c_int = 9;
1026pub const _PC_ALLOC_SIZE_MIN: c_int = 10;
1027pub const _PC_FILESIZEBITS: c_int = 12;
1028pub const _PC_REC_INCR_XFER_SIZE: c_int = 14;
1029pub const _PC_REC_MAX_XFER_SIZE: c_int = 15;
1030pub const _PC_REC_MIN_XFER_SIZE: c_int = 16;
1031pub const _PC_REC_XFER_ALIGN: c_int = 17;
1032pub const _PC_SYMLINK_MAX: c_int = 18;
1033pub const _PC_MIN_HOLE_SIZE: c_int = 21;
1034pub const _PC_ASYNC_IO: c_int = 53;
1035pub const _PC_PRIO_IO: c_int = 54;
1036pub const _PC_SYNC_IO: c_int = 55;
1037pub const _PC_ACL_EXTENDED: c_int = 59;
1038pub const _PC_ACL_PATH_MAX: c_int = 60;
1039pub const _PC_CAP_PRESENT: c_int = 61;
1040pub const _PC_INF_PRESENT: c_int = 62;
1041pub const _PC_MAC_PRESENT: c_int = 63;
1042
1043pub const _SC_ARG_MAX: c_int = 1;
1044pub const _SC_CHILD_MAX: c_int = 2;
1045pub const _SC_CLK_TCK: c_int = 3;
1046pub const _SC_NGROUPS_MAX: c_int = 4;
1047pub const _SC_OPEN_MAX: c_int = 5;
1048pub const _SC_JOB_CONTROL: c_int = 6;
1049pub const _SC_SAVED_IDS: c_int = 7;
1050pub const _SC_VERSION: c_int = 8;
1051pub const _SC_BC_BASE_MAX: c_int = 9;
1052pub const _SC_BC_DIM_MAX: c_int = 10;
1053pub const _SC_BC_SCALE_MAX: c_int = 11;
1054pub const _SC_BC_STRING_MAX: c_int = 12;
1055pub const _SC_COLL_WEIGHTS_MAX: c_int = 13;
1056pub const _SC_EXPR_NEST_MAX: c_int = 14;
1057pub const _SC_LINE_MAX: c_int = 15;
1058pub const _SC_RE_DUP_MAX: c_int = 16;
1059pub const _SC_2_VERSION: c_int = 17;
1060pub const _SC_2_C_BIND: c_int = 18;
1061pub const _SC_2_C_DEV: c_int = 19;
1062pub const _SC_2_CHAR_TERM: c_int = 20;
1063pub const _SC_2_FORT_DEV: c_int = 21;
1064pub const _SC_2_FORT_RUN: c_int = 22;
1065pub const _SC_2_LOCALEDEF: c_int = 23;
1066pub const _SC_2_SW_DEV: c_int = 24;
1067pub const _SC_2_UPE: c_int = 25;
1068pub const _SC_STREAM_MAX: c_int = 26;
1069pub const _SC_TZNAME_MAX: c_int = 27;
1070pub const _SC_ASYNCHRONOUS_IO: c_int = 28;
1071pub const _SC_MAPPED_FILES: c_int = 29;
1072pub const _SC_MEMLOCK: c_int = 30;
1073pub const _SC_MEMLOCK_RANGE: c_int = 31;
1074pub const _SC_MEMORY_PROTECTION: c_int = 32;
1075pub const _SC_MESSAGE_PASSING: c_int = 33;
1076pub const _SC_PRIORITIZED_IO: c_int = 34;
1077pub const _SC_PRIORITY_SCHEDULING: c_int = 35;
1078pub const _SC_REALTIME_SIGNALS: c_int = 36;
1079pub const _SC_SEMAPHORES: c_int = 37;
1080pub const _SC_FSYNC: c_int = 38;
1081pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 39;
1082pub const _SC_SYNCHRONIZED_IO: c_int = 40;
1083pub const _SC_TIMERS: c_int = 41;
1084pub const _SC_AIO_LISTIO_MAX: c_int = 42;
1085pub const _SC_AIO_MAX: c_int = 43;
1086pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 44;
1087pub const _SC_DELAYTIMER_MAX: c_int = 45;
1088pub const _SC_MQ_OPEN_MAX: c_int = 46;
1089pub const _SC_PAGESIZE: c_int = 47;
1090pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE;
1091pub const _SC_RTSIG_MAX: c_int = 48;
1092pub const _SC_SEM_NSEMS_MAX: c_int = 49;
1093pub const _SC_SEM_VALUE_MAX: c_int = 50;
1094pub const _SC_SIGQUEUE_MAX: c_int = 51;
1095pub const _SC_TIMER_MAX: c_int = 52;
1096pub const _SC_IOV_MAX: c_int = 56;
1097pub const _SC_NPROCESSORS_CONF: c_int = 57;
1098pub const _SC_2_PBS: c_int = 59;
1099pub const _SC_2_PBS_ACCOUNTING: c_int = 60;
1100pub const _SC_2_PBS_CHECKPOINT: c_int = 61;
1101pub const _SC_2_PBS_LOCATE: c_int = 62;
1102pub const _SC_2_PBS_MESSAGE: c_int = 63;
1103pub const _SC_2_PBS_TRACK: c_int = 64;
1104pub const _SC_ADVISORY_INFO: c_int = 65;
1105pub const _SC_BARRIERS: c_int = 66;
1106pub const _SC_CLOCK_SELECTION: c_int = 67;
1107pub const _SC_CPUTIME: c_int = 68;
1108pub const _SC_FILE_LOCKING: c_int = 69;
1109pub const _SC_NPROCESSORS_ONLN: c_int = 58;
1110pub const _SC_GETGR_R_SIZE_MAX: c_int = 70;
1111pub const _SC_GETPW_R_SIZE_MAX: c_int = 71;
1112pub const _SC_HOST_NAME_MAX: c_int = 72;
1113pub const _SC_LOGIN_NAME_MAX: c_int = 73;
1114pub const _SC_MONOTONIC_CLOCK: c_int = 74;
1115pub const _SC_MQ_PRIO_MAX: c_int = 75;
1116pub const _SC_READER_WRITER_LOCKS: c_int = 76;
1117pub const _SC_REGEXP: c_int = 77;
1118pub const _SC_SHELL: c_int = 78;
1119pub const _SC_SPAWN: c_int = 79;
1120pub const _SC_SPIN_LOCKS: c_int = 80;
1121pub const _SC_SPORADIC_SERVER: c_int = 81;
1122pub const _SC_THREAD_ATTR_STACKADDR: c_int = 82;
1123pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 83;
1124pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 85;
1125pub const _SC_THREAD_KEYS_MAX: c_int = 86;
1126pub const _SC_THREAD_PRIO_INHERIT: c_int = 87;
1127pub const _SC_THREAD_PRIO_PROTECT: c_int = 88;
1128pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 89;
1129pub const _SC_THREAD_PROCESS_SHARED: c_int = 90;
1130pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 91;
1131pub const _SC_THREAD_SPORADIC_SERVER: c_int = 92;
1132pub const _SC_THREAD_STACK_MIN: c_int = 93;
1133pub const _SC_THREAD_THREADS_MAX: c_int = 94;
1134pub const _SC_TIMEOUTS: c_int = 95;
1135pub const _SC_THREADS: c_int = 96;
1136pub const _SC_TRACE: c_int = 97;
1137pub const _SC_TRACE_EVENT_FILTER: c_int = 98;
1138pub const _SC_TRACE_INHERIT: c_int = 99;
1139pub const _SC_TRACE_LOG: c_int = 100;
1140pub const _SC_TTY_NAME_MAX: c_int = 101;
1141pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 102;
1142pub const _SC_V6_ILP32_OFF32: c_int = 103;
1143pub const _SC_V6_ILP32_OFFBIG: c_int = 104;
1144pub const _SC_V6_LP64_OFF64: c_int = 105;
1145pub const _SC_V6_LPBIG_OFFBIG: c_int = 106;
1146pub const _SC_ATEXIT_MAX: c_int = 107;
1147pub const _SC_XOPEN_CRYPT: c_int = 108;
1148pub const _SC_XOPEN_ENH_I18N: c_int = 109;
1149pub const _SC_XOPEN_LEGACY: c_int = 110;
1150pub const _SC_XOPEN_REALTIME: c_int = 111;
1151pub const _SC_XOPEN_REALTIME_THREADS: c_int = 112;
1152pub const _SC_XOPEN_SHM: c_int = 113;
1153pub const _SC_XOPEN_STREAMS: c_int = 114;
1154pub const _SC_XOPEN_UNIX: c_int = 115;
1155pub const _SC_XOPEN_VERSION: c_int = 116;
1156pub const _SC_XOPEN_XCU_VERSION: c_int = 117;
1157pub const _SC_IPV6: c_int = 118;
1158pub const _SC_RAW_SOCKETS: c_int = 119;
1159pub const _SC_SYMLOOP_MAX: c_int = 120;
1160pub const _SC_PHYS_PAGES: c_int = 121;
1161
1162pub const _CS_PATH: c_int = 1;
1163
1164pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut();
1165pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut();
1166pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut();
1167pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1;
1168pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2;
1169pub const PTHREAD_MUTEX_NORMAL: c_int = 3;
1170pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_ERRORCHECK;
1171
1172pub const SCHED_FIFO: c_int = 1;
1173pub const SCHED_OTHER: c_int = 2;
1174pub const SCHED_RR: c_int = 3;
1175
1176pub const FD_SETSIZE: usize = 1024;
1177
1178pub const ST_NOSUID: c_ulong = 2;
1179
1180pub const NI_MAXHOST: size_t = 1025;
1181
1182pub const XUCRED_VERSION: c_uint = 0;
1183
1184pub const RTLD_LOCAL: c_int = 0;
1185pub const RTLD_NODELETE: c_int = 0x1000;
1186pub const RTLD_NOLOAD: c_int = 0x2000;
1187pub const RTLD_GLOBAL: c_int = 0x100;
1188
1189pub const LOG_NTP: c_int = 12 << 3;
1190pub const LOG_SECURITY: c_int = 13 << 3;
1191pub const LOG_CONSOLE: c_int = 14 << 3;
1192pub const LOG_NFACILITIES: c_int = 24;
1193
1194pub const TIOCEXCL: c_ulong = 0x2000740d;
1195pub const TIOCNXCL: c_ulong = 0x2000740e;
1196pub const TIOCFLUSH: c_ulong = 0x80047410;
1197pub const TIOCGETA: c_ulong = 0x402c7413;
1198pub const TIOCSETA: c_ulong = 0x802c7414;
1199pub const TIOCSETAW: c_ulong = 0x802c7415;
1200pub const TIOCSETAF: c_ulong = 0x802c7416;
1201pub const TIOCGETD: c_ulong = 0x4004741a;
1202pub const TIOCSETD: c_ulong = 0x8004741b;
1203pub const TIOCGDRAINWAIT: c_ulong = 0x40047456;
1204pub const TIOCSDRAINWAIT: c_ulong = 0x80047457;
1205#[cfg_attr(
1206    not(target_os = "dragonfly"),
1207    deprecated = "unused since FreeBSD 8, removed in FreeBSD 15"
1208)]
1209pub const TIOCMGDTRWAIT: c_ulong = 0x4004745a;
1210#[cfg_attr(
1211    not(target_os = "dragonfly"),
1212    deprecated = "unused since FreeBSD 8, removed in FreeBSD 15"
1213)]
1214pub const TIOCMSDTRWAIT: c_ulong = 0x8004745b;
1215pub const TIOCDRAIN: c_ulong = 0x2000745e;
1216pub const TIOCEXT: c_ulong = 0x80047460;
1217pub const TIOCSCTTY: c_ulong = 0x20007461;
1218pub const TIOCCONS: c_ulong = 0x80047462;
1219pub const TIOCGSID: c_ulong = 0x40047463;
1220pub const TIOCSTAT: c_ulong = 0x20007465;
1221pub const TIOCUCNTL: c_ulong = 0x80047466;
1222pub const TIOCSWINSZ: c_ulong = 0x80087467;
1223pub const TIOCGWINSZ: c_ulong = 0x40087468;
1224pub const TIOCMGET: c_ulong = 0x4004746a;
1225pub const TIOCM_LE: c_int = 0x1;
1226pub const TIOCM_DTR: c_int = 0x2;
1227pub const TIOCM_RTS: c_int = 0x4;
1228pub const TIOCM_ST: c_int = 0x8;
1229pub const TIOCM_SR: c_int = 0x10;
1230pub const TIOCM_CTS: c_int = 0x20;
1231pub const TIOCM_RI: c_int = 0x80;
1232pub const TIOCM_DSR: c_int = 0x100;
1233pub const TIOCM_CD: c_int = 0x40;
1234pub const TIOCM_CAR: c_int = 0x40;
1235pub const TIOCM_RNG: c_int = 0x80;
1236pub const TIOCMBIC: c_ulong = 0x8004746b;
1237pub const TIOCMBIS: c_ulong = 0x8004746c;
1238pub const TIOCMSET: c_ulong = 0x8004746d;
1239pub const TIOCSTART: c_ulong = 0x2000746e;
1240pub const TIOCSTOP: c_ulong = 0x2000746f;
1241pub const TIOCPKT: c_ulong = 0x80047470;
1242pub const TIOCPKT_DATA: c_int = 0x0;
1243pub const TIOCPKT_FLUSHREAD: c_int = 0x1;
1244pub const TIOCPKT_FLUSHWRITE: c_int = 0x2;
1245pub const TIOCPKT_STOP: c_int = 0x4;
1246pub const TIOCPKT_START: c_int = 0x8;
1247pub const TIOCPKT_NOSTOP: c_int = 0x10;
1248pub const TIOCPKT_DOSTOP: c_int = 0x20;
1249pub const TIOCPKT_IOCTL: c_int = 0x40;
1250pub const TIOCNOTTY: c_ulong = 0x20007471;
1251pub const TIOCSTI: c_ulong = 0x80017472;
1252pub const TIOCOUTQ: c_ulong = 0x40047473;
1253pub const TIOCSPGRP: c_ulong = 0x80047476;
1254pub const TIOCGPGRP: c_ulong = 0x40047477;
1255pub const TIOCCDTR: c_ulong = 0x20007478;
1256pub const TIOCSDTR: c_ulong = 0x20007479;
1257pub const TTYDISC: c_int = 0x0;
1258pub const SLIPDISC: c_int = 0x4;
1259pub const PPPDISC: c_int = 0x5;
1260pub const NETGRAPHDISC: c_int = 0x6;
1261
1262pub const BIOCGRSIG: c_ulong = 0x40044272;
1263pub const BIOCSRSIG: c_ulong = 0x80044273;
1264pub const BIOCSDLT: c_ulong = 0x80044278;
1265pub const BIOCGSEESENT: c_ulong = 0x40044276;
1266pub const BIOCSSEESENT: c_ulong = 0x80044277;
1267cfg_if! {
1268    if #[cfg(target_pointer_width = "64")] {
1269        pub const BIOCGDLTLIST: c_ulong = 0xc0104279;
1270        pub const BIOCSETF: c_ulong = 0x80104267;
1271    } else if #[cfg(target_pointer_width = "32")] {
1272        pub const BIOCGDLTLIST: c_ulong = 0xc0084279;
1273        pub const BIOCSETF: c_ulong = 0x80084267;
1274    }
1275}
1276
1277pub const FIODTYPE: c_ulong = 0x4004667a;
1278pub const FIOGETLBA: c_ulong = 0x40046679;
1279
1280pub const B0: speed_t = 0;
1281pub const B50: speed_t = 50;
1282pub const B75: speed_t = 75;
1283pub const B110: speed_t = 110;
1284pub const B134: speed_t = 134;
1285pub const B150: speed_t = 150;
1286pub const B200: speed_t = 200;
1287pub const B300: speed_t = 300;
1288pub const B600: speed_t = 600;
1289pub const B1200: speed_t = 1200;
1290pub const B1800: speed_t = 1800;
1291pub const B2400: speed_t = 2400;
1292pub const B4800: speed_t = 4800;
1293pub const B9600: speed_t = 9600;
1294pub const B19200: speed_t = 19200;
1295pub const B38400: speed_t = 38400;
1296pub const B7200: speed_t = 7200;
1297pub const B14400: speed_t = 14400;
1298pub const B28800: speed_t = 28800;
1299pub const B57600: speed_t = 57600;
1300pub const B76800: speed_t = 76800;
1301pub const B115200: speed_t = 115200;
1302pub const B230400: speed_t = 230400;
1303pub const EXTA: speed_t = 19200;
1304pub const EXTB: speed_t = 38400;
1305
1306pub const SEM_FAILED: *mut sem_t = ptr::null_mut();
1307
1308pub const CRTSCTS: crate::tcflag_t = 0x00030000;
1309pub const CCTS_OFLOW: crate::tcflag_t = 0x00010000;
1310pub const CRTS_IFLOW: crate::tcflag_t = 0x00020000;
1311pub const CDTR_IFLOW: crate::tcflag_t = 0x00040000;
1312pub const CDSR_OFLOW: crate::tcflag_t = 0x00080000;
1313pub const CCAR_OFLOW: crate::tcflag_t = 0x00100000;
1314pub const VERASE2: usize = 7;
1315pub const OCRNL: crate::tcflag_t = 0x10;
1316pub const ONOCR: crate::tcflag_t = 0x20;
1317pub const ONLRET: crate::tcflag_t = 0x40;
1318
1319pub const CMGROUP_MAX: usize = 16;
1320
1321pub const EUI64_LEN: usize = 8;
1322
1323// https://github.com/freebsd/freebsd/blob/HEAD/sys/net/bpf.h
1324pub const BPF_ALIGNMENT: usize = SIZEOF_LONG;
1325
1326// Values for rtprio struct (prio field) and syscall (function argument)
1327pub const RTP_PRIO_MIN: c_ushort = 0;
1328pub const RTP_PRIO_MAX: c_ushort = 31;
1329pub const RTP_LOOKUP: c_int = 0;
1330pub const RTP_SET: c_int = 1;
1331
1332// Flags for chflags(2)
1333pub const UF_SETTABLE: c_ulong = 0x0000ffff;
1334pub const UF_NODUMP: c_ulong = 0x00000001;
1335pub const UF_IMMUTABLE: c_ulong = 0x00000002;
1336pub const UF_APPEND: c_ulong = 0x00000004;
1337pub const UF_OPAQUE: c_ulong = 0x00000008;
1338pub const UF_NOUNLINK: c_ulong = 0x00000010;
1339pub const SF_SETTABLE: c_ulong = 0xffff0000;
1340pub const SF_ARCHIVED: c_ulong = 0x00010000;
1341pub const SF_IMMUTABLE: c_ulong = 0x00020000;
1342pub const SF_APPEND: c_ulong = 0x00040000;
1343pub const SF_NOUNLINK: c_ulong = 0x00100000;
1344
1345pub const TIMER_ABSTIME: c_int = 1;
1346
1347//<sys/timex.h>
1348pub const NTP_API: c_int = 4;
1349pub const MAXPHASE: c_long = 500000000;
1350pub const MAXFREQ: c_long = 500000;
1351pub const MINSEC: c_int = 256;
1352pub const MAXSEC: c_int = 2048;
1353pub const NANOSECOND: c_long = 1000000000;
1354pub const SCALE_PPM: c_int = 65;
1355pub const MAXTC: c_int = 10;
1356pub const MOD_OFFSET: c_uint = 0x0001;
1357pub const MOD_FREQUENCY: c_uint = 0x0002;
1358pub const MOD_MAXERROR: c_uint = 0x0004;
1359pub const MOD_ESTERROR: c_uint = 0x0008;
1360pub const MOD_STATUS: c_uint = 0x0010;
1361pub const MOD_TIMECONST: c_uint = 0x0020;
1362pub const MOD_PPSMAX: c_uint = 0x0040;
1363pub const MOD_TAI: c_uint = 0x0080;
1364pub const MOD_MICRO: c_uint = 0x1000;
1365pub const MOD_NANO: c_uint = 0x2000;
1366pub const MOD_CLKB: c_uint = 0x4000;
1367pub const MOD_CLKA: c_uint = 0x8000;
1368pub const STA_PLL: c_int = 0x0001;
1369pub const STA_PPSFREQ: c_int = 0x0002;
1370pub const STA_PPSTIME: c_int = 0x0004;
1371pub const STA_FLL: c_int = 0x0008;
1372pub const STA_INS: c_int = 0x0010;
1373pub const STA_DEL: c_int = 0x0020;
1374pub const STA_UNSYNC: c_int = 0x0040;
1375pub const STA_FREQHOLD: c_int = 0x0080;
1376pub const STA_PPSSIGNAL: c_int = 0x0100;
1377pub const STA_PPSJITTER: c_int = 0x0200;
1378pub const STA_PPSWANDER: c_int = 0x0400;
1379pub const STA_PPSERROR: c_int = 0x0800;
1380pub const STA_CLOCKERR: c_int = 0x1000;
1381pub const STA_NANO: c_int = 0x2000;
1382pub const STA_MODE: c_int = 0x4000;
1383pub const STA_CLK: c_int = 0x8000;
1384pub const STA_RONLY: c_int = STA_PPSSIGNAL
1385    | STA_PPSJITTER
1386    | STA_PPSWANDER
1387    | STA_PPSERROR
1388    | STA_CLOCKERR
1389    | STA_NANO
1390    | STA_MODE
1391    | STA_CLK;
1392pub const TIME_OK: c_int = 0;
1393pub const TIME_INS: c_int = 1;
1394pub const TIME_DEL: c_int = 2;
1395pub const TIME_OOP: c_int = 3;
1396pub const TIME_WAIT: c_int = 4;
1397pub const TIME_ERROR: c_int = 5;
1398
1399pub const REG_ENOSYS: c_int = -1;
1400pub const REG_ILLSEQ: c_int = 17;
1401
1402pub const IPC_PRIVATE: crate::key_t = 0;
1403pub const IPC_CREAT: c_int = 0o1000;
1404pub const IPC_EXCL: c_int = 0o2000;
1405pub const IPC_NOWAIT: c_int = 0o4000;
1406pub const IPC_RMID: c_int = 0;
1407pub const IPC_SET: c_int = 1;
1408pub const IPC_STAT: c_int = 2;
1409pub const IPC_R: c_int = 0o400;
1410pub const IPC_W: c_int = 0o200;
1411pub const IPC_M: c_int = 0o10000;
1412
1413pub const SHM_RDONLY: c_int = 0o10000;
1414pub const SHM_RND: c_int = 0o20000;
1415pub const SHM_R: c_int = 0o400;
1416pub const SHM_W: c_int = 0o200;
1417
1418pub const KENV_GET: c_int = 0;
1419pub const KENV_SET: c_int = 1;
1420pub const KENV_UNSET: c_int = 2;
1421pub const KENV_DUMP: c_int = 3;
1422pub const KENV_MNAMELEN: c_int = 128;
1423pub const KENV_MVALLEN: c_int = 128;
1424
1425pub const RB_ASKNAME: c_int = 0x001;
1426pub const RB_SINGLE: c_int = 0x002;
1427pub const RB_NOSYNC: c_int = 0x004;
1428pub const RB_HALT: c_int = 0x008;
1429pub const RB_INITNAME: c_int = 0x010;
1430pub const RB_DFLTROOT: c_int = 0x020;
1431pub const RB_KDB: c_int = 0x040;
1432pub const RB_RDONLY: c_int = 0x080;
1433pub const RB_DUMP: c_int = 0x100;
1434pub const RB_MINIROOT: c_int = 0x200;
1435pub const RB_VERBOSE: c_int = 0x800;
1436pub const RB_SERIAL: c_int = 0x1000;
1437pub const RB_CDROM: c_int = 0x2000;
1438pub const RB_POWEROFF: c_int = 0x4000;
1439pub const RB_GDB: c_int = 0x8000;
1440pub const RB_MUTE: c_int = 0x10000;
1441pub const RB_SELFTEST: c_int = 0x20000;
1442
1443// For getrandom()
1444pub const GRND_NONBLOCK: c_uint = 0x1;
1445pub const GRND_RANDOM: c_uint = 0x2;
1446pub const GRND_INSECURE: c_uint = 0x4;
1447
1448// DIFF(main): changed to `c_short` in f62eb023ab
1449pub const POSIX_SPAWN_RESETIDS: c_int = 0x01;
1450pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02;
1451pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x04;
1452pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x08;
1453pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10;
1454pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20;
1455
1456safe_f! {
1457    pub const fn WIFCONTINUED(status: c_int) -> bool {
1458        status == 0x13
1459    }
1460
1461    pub const fn WSTOPSIG(status: c_int) -> c_int {
1462        status >> 8
1463    }
1464
1465    pub const fn WIFSTOPPED(status: c_int) -> bool {
1466        (status & 0o177) == 0o177
1467    }
1468}
1469
1470extern "C" {
1471    pub fn sem_destroy(sem: *mut sem_t) -> c_int;
1472    pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;
1473
1474    pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int;
1475    pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int;
1476    pub fn accept4(
1477        s: c_int,
1478        addr: *mut crate::sockaddr,
1479        addrlen: *mut crate::socklen_t,
1480        flags: c_int,
1481    ) -> c_int;
1482    pub fn chflags(path: *const c_char, flags: c_ulong) -> c_int;
1483    pub fn chflagsat(fd: c_int, path: *const c_char, flags: c_ulong, atflag: c_int) -> c_int;
1484
1485    pub fn clock_nanosleep(
1486        clk_id: crate::clockid_t,
1487        flags: c_int,
1488        rqtp: *const crate::timespec,
1489        rmtp: *mut crate::timespec,
1490    ) -> c_int;
1491
1492    pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
1493    pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
1494    pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int;
1495    pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int;
1496
1497    pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int;
1498
1499    pub fn dirfd(dirp: *mut crate::DIR) -> c_int;
1500    pub fn duplocale(base: crate::locale_t) -> crate::locale_t;
1501    pub fn endutxent();
1502    pub fn fchflags(fd: c_int, flags: c_ulong) -> c_int;
1503
1504    // DIFF(main): changed to `*const *mut` in e77f551de9
1505    pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int;
1506
1507    pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int;
1508    pub fn getdomainname(name: *mut c_char, len: c_int) -> c_int;
1509    pub fn getgrent_r(
1510        grp: *mut crate::group,
1511        buf: *mut c_char,
1512        buflen: size_t,
1513        result: *mut *mut crate::group,
1514    ) -> c_int;
1515    pub fn getpwent_r(
1516        pwd: *mut crate::passwd,
1517        buf: *mut c_char,
1518        buflen: size_t,
1519        result: *mut *mut crate::passwd,
1520    ) -> c_int;
1521    pub fn getgrouplist(
1522        name: *const c_char,
1523        basegid: crate::gid_t,
1524        groups: *mut crate::gid_t,
1525        ngroups: *mut c_int,
1526    ) -> c_int;
1527    pub fn getnameinfo(
1528        sa: *const crate::sockaddr,
1529        salen: crate::socklen_t,
1530        host: *mut c_char,
1531        hostlen: size_t,
1532        serv: *mut c_char,
1533        servlen: size_t,
1534        flags: c_int,
1535    ) -> c_int;
1536    pub fn getpriority(which: c_int, who: c_int) -> c_int;
1537    pub fn getresgid(
1538        rgid: *mut crate::gid_t,
1539        egid: *mut crate::gid_t,
1540        sgid: *mut crate::gid_t,
1541    ) -> c_int;
1542    pub fn getresuid(
1543        ruid: *mut crate::uid_t,
1544        euid: *mut crate::uid_t,
1545        suid: *mut crate::uid_t,
1546    ) -> c_int;
1547    pub fn getutxent() -> *mut utmpx;
1548    pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
1549    pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
1550    pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int;
1551    #[cfg_attr(
1552        all(target_os = "freebsd", any(freebsd11, freebsd10)),
1553        link_name = "kevent@FBSD_1.0"
1554    )]
1555    pub fn kevent(
1556        kq: c_int,
1557        changelist: *const crate::kevent,
1558        nchanges: c_int,
1559        eventlist: *mut crate::kevent,
1560        nevents: c_int,
1561        timeout: *const crate::timespec,
1562    ) -> c_int;
1563    pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int;
1564    pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
1565    pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
1566    pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
1567    #[cfg_attr(
1568        all(target_os = "freebsd", any(freebsd11, freebsd10)),
1569        link_name = "mknodat@FBSD_1.1"
1570    )]
1571    pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
1572    pub fn malloc_usable_size(ptr: *const c_void) -> size_t;
1573    pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int;
1574    pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t;
1575    pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char;
1576    pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int;
1577    pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
1578    pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int;
1579    pub fn ppoll(
1580        fds: *mut crate::pollfd,
1581        nfds: crate::nfds_t,
1582        timeout: *const crate::timespec,
1583        sigmask: *const sigset_t,
1584    ) -> c_int;
1585    pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
1586    pub fn pthread_attr_get_np(tid: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int;
1587    pub fn pthread_attr_getguardsize(
1588        attr: *const crate::pthread_attr_t,
1589        guardsize: *mut size_t,
1590    ) -> c_int;
1591    pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int;
1592    pub fn pthread_attr_getstack(
1593        attr: *const crate::pthread_attr_t,
1594        stackaddr: *mut *mut c_void,
1595        stacksize: *mut size_t,
1596    ) -> c_int;
1597    pub fn pthread_condattr_getclock(
1598        attr: *const pthread_condattr_t,
1599        clock_id: *mut clockid_t,
1600    ) -> c_int;
1601    pub fn pthread_condattr_getpshared(
1602        attr: *const pthread_condattr_t,
1603        pshared: *mut c_int,
1604    ) -> c_int;
1605    pub fn pthread_condattr_setclock(
1606        attr: *mut pthread_condattr_t,
1607        clock_id: crate::clockid_t,
1608    ) -> c_int;
1609    pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int;
1610    pub fn pthread_main_np() -> c_int;
1611    pub fn pthread_mutex_timedlock(
1612        lock: *mut pthread_mutex_t,
1613        abstime: *const crate::timespec,
1614    ) -> c_int;
1615    pub fn pthread_mutexattr_getpshared(
1616        attr: *const pthread_mutexattr_t,
1617        pshared: *mut c_int,
1618    ) -> c_int;
1619    pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int;
1620    pub fn pthread_rwlockattr_getpshared(
1621        attr: *const pthread_rwlockattr_t,
1622        val: *mut c_int,
1623    ) -> c_int;
1624    pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int;
1625    pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int;
1626    pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int;
1627    pub fn pthread_barrierattr_getpshared(
1628        attr: *const crate::pthread_barrierattr_t,
1629        shared: *mut c_int,
1630    ) -> c_int;
1631    pub fn pthread_barrierattr_setpshared(
1632        attr: *mut crate::pthread_barrierattr_t,
1633        shared: c_int,
1634    ) -> c_int;
1635    pub fn pthread_barrier_init(
1636        barrier: *mut pthread_barrier_t,
1637        attr: *const crate::pthread_barrierattr_t,
1638        count: c_uint,
1639    ) -> c_int;
1640    pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int;
1641    pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int;
1642    pub fn pthread_get_name_np(tid: crate::pthread_t, name: *mut c_char, len: size_t);
1643    pub fn pthread_set_name_np(tid: crate::pthread_t, name: *const c_char);
1644    pub fn pthread_getname_np(
1645        thread: crate::pthread_t,
1646        buffer: *mut c_char,
1647        length: size_t,
1648    ) -> c_int;
1649    pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int;
1650    pub fn pthread_setschedparam(
1651        native: crate::pthread_t,
1652        policy: c_int,
1653        param: *const sched_param,
1654    ) -> c_int;
1655    pub fn pthread_getschedparam(
1656        native: crate::pthread_t,
1657        policy: *mut c_int,
1658        param: *mut sched_param,
1659    ) -> c_int;
1660    pub fn ptrace(request: c_int, pid: crate::pid_t, addr: *mut c_char, data: c_int) -> c_int;
1661    pub fn utrace(addr: *const c_void, len: size_t) -> c_int;
1662    pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
1663    pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
1664    pub fn querylocale(mask: c_int, loc: crate::locale_t) -> *const c_char;
1665    pub fn rtprio(function: c_int, pid: crate::pid_t, rtp: *mut rtprio) -> c_int;
1666    pub fn sched_rr_get_interval(pid: crate::pid_t, t: *mut crate::timespec) -> c_int;
1667    pub fn sched_getparam(pid: crate::pid_t, param: *mut sched_param) -> c_int;
1668    pub fn sched_setparam(pid: crate::pid_t, param: *const sched_param) -> c_int;
1669    pub fn sched_getscheduler(pid: crate::pid_t) -> c_int;
1670    pub fn sched_setscheduler(
1671        pid: crate::pid_t,
1672        policy: c_int,
1673        param: *const crate::sched_param,
1674    ) -> c_int;
1675    pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int;
1676    pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int;
1677    pub fn sendfile(
1678        fd: c_int,
1679        s: c_int,
1680        offset: off_t,
1681        nbytes: size_t,
1682        hdtr: *mut crate::sf_hdtr,
1683        sbytes: *mut off_t,
1684        flags: c_int,
1685    ) -> c_int;
1686    pub fn setdomainname(name: *const c_char, len: c_int) -> c_int;
1687    pub fn sethostname(name: *const c_char, len: c_int) -> c_int;
1688    pub fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int;
1689    pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int;
1690    pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int;
1691    pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int;
1692    pub fn setutxent();
1693    pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
1694    pub fn sigtimedwait(
1695        set: *const sigset_t,
1696        info: *mut siginfo_t,
1697        timeout: *const crate::timespec,
1698    ) -> c_int;
1699    pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int;
1700    pub fn sysctl(
1701        name: *const c_int,
1702        namelen: c_uint,
1703        oldp: *mut c_void,
1704        oldlenp: *mut size_t,
1705        newp: *const c_void,
1706        newlen: size_t,
1707    ) -> c_int;
1708    pub fn sysctlbyname(
1709        name: *const c_char,
1710        oldp: *mut c_void,
1711        oldlenp: *mut size_t,
1712        newp: *const c_void,
1713        newlen: size_t,
1714    ) -> c_int;
1715    pub fn sysctlnametomib(name: *const c_char, mibp: *mut c_int, sizep: *mut size_t) -> c_int;
1716    pub fn uselocale(loc: crate::locale_t) -> crate::locale_t;
1717    pub fn utimensat(
1718        dirfd: c_int,
1719        path: *const c_char,
1720        times: *const crate::timespec,
1721        flag: c_int,
1722    ) -> c_int;
1723
1724    pub fn ntp_adjtime(buf: *mut timex) -> c_int;
1725    pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int;
1726
1727    // #include <link.h>
1728    pub fn dl_iterate_phdr(
1729        callback: Option<
1730            unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int,
1731        >,
1732        data: *mut c_void,
1733    ) -> c_int;
1734
1735    pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t;
1736    pub fn iconv(
1737        cd: iconv_t,
1738        inbuf: *mut *mut c_char,
1739        inbytesleft: *mut size_t,
1740        outbuf: *mut *mut c_char,
1741        outbytesleft: *mut size_t,
1742    ) -> size_t;
1743    pub fn iconv_close(cd: iconv_t) -> c_int;
1744
1745    // Added in `FreeBSD` 11.0
1746    // Added in `DragonFly BSD` 5.4
1747    pub fn explicit_bzero(s: *mut c_void, len: size_t);
1748    // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1
1749    pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int;
1750    pub fn gethostid() -> c_long;
1751    pub fn sethostid(hostid: c_long);
1752
1753    pub fn eui64_aton(a: *const c_char, e: *mut eui64) -> c_int;
1754    pub fn eui64_ntoa(id: *const eui64, a: *mut c_char, len: size_t) -> c_int;
1755    pub fn eui64_ntohost(hostname: *mut c_char, len: size_t, id: *const eui64) -> c_int;
1756    pub fn eui64_hostton(hostname: *const c_char, id: *mut eui64) -> c_int;
1757
1758    pub fn eaccess(path: *const c_char, mode: c_int) -> c_int;
1759
1760    pub fn kenv(action: c_int, name: *const c_char, value: *mut c_char, len: c_int) -> c_int;
1761    pub fn reboot(howto: c_int) -> c_int;
1762
1763    pub fn exect(path: *const c_char, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int;
1764    pub fn execvP(
1765        file: *const c_char,
1766        search_path: *const c_char,
1767        argv: *const *mut c_char,
1768    ) -> c_int;
1769
1770    pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int;
1771    pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int;
1772
1773    pub fn posix_spawn(
1774        pid: *mut crate::pid_t,
1775        path: *const c_char,
1776        file_actions: *const crate::posix_spawn_file_actions_t,
1777        attrp: *const crate::posix_spawnattr_t,
1778        argv: *const *mut c_char,
1779        envp: *const *mut c_char,
1780    ) -> c_int;
1781    pub fn posix_spawnp(
1782        pid: *mut crate::pid_t,
1783        file: *const c_char,
1784        file_actions: *const crate::posix_spawn_file_actions_t,
1785        attrp: *const crate::posix_spawnattr_t,
1786        argv: *const *mut c_char,
1787        envp: *const *mut c_char,
1788    ) -> c_int;
1789    pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
1790    pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
1791    pub fn posix_spawnattr_getsigdefault(
1792        attr: *const posix_spawnattr_t,
1793        default: *mut crate::sigset_t,
1794    ) -> c_int;
1795    pub fn posix_spawnattr_setsigdefault(
1796        attr: *mut posix_spawnattr_t,
1797        default: *const crate::sigset_t,
1798    ) -> c_int;
1799    pub fn posix_spawnattr_getsigmask(
1800        attr: *const posix_spawnattr_t,
1801        default: *mut crate::sigset_t,
1802    ) -> c_int;
1803    pub fn posix_spawnattr_setsigmask(
1804        attr: *mut posix_spawnattr_t,
1805        default: *const crate::sigset_t,
1806    ) -> c_int;
1807    pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int;
1808    pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
1809    pub fn posix_spawnattr_getpgroup(
1810        attr: *const posix_spawnattr_t,
1811        flags: *mut crate::pid_t,
1812    ) -> c_int;
1813    pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int;
1814    pub fn posix_spawnattr_getschedpolicy(
1815        attr: *const posix_spawnattr_t,
1816        flags: *mut c_int,
1817    ) -> c_int;
1818    pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int;
1819    pub fn posix_spawnattr_getschedparam(
1820        attr: *const posix_spawnattr_t,
1821        param: *mut crate::sched_param,
1822    ) -> c_int;
1823    pub fn posix_spawnattr_setschedparam(
1824        attr: *mut posix_spawnattr_t,
1825        param: *const crate::sched_param,
1826    ) -> c_int;
1827
1828    pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
1829    pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
1830    pub fn posix_spawn_file_actions_addopen(
1831        actions: *mut posix_spawn_file_actions_t,
1832        fd: c_int,
1833        path: *const c_char,
1834        oflag: c_int,
1835        mode: mode_t,
1836    ) -> c_int;
1837    pub fn posix_spawn_file_actions_addclose(
1838        actions: *mut posix_spawn_file_actions_t,
1839        fd: c_int,
1840    ) -> c_int;
1841    pub fn posix_spawn_file_actions_adddup2(
1842        actions: *mut posix_spawn_file_actions_t,
1843        fd: c_int,
1844        newfd: c_int,
1845    ) -> c_int;
1846}
1847
1848#[link(name = "rt")]
1849extern "C" {
1850    pub fn mq_close(mqd: crate::mqd_t) -> c_int;
1851    pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int;
1852    pub fn mq_notify(mqd: crate::mqd_t, notification: *const crate::sigevent) -> c_int;
1853    pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t;
1854    pub fn mq_receive(
1855        mqd: crate::mqd_t,
1856        msg_ptr: *mut c_char,
1857        msg_len: size_t,
1858        msg_prio: *mut c_uint,
1859    ) -> ssize_t;
1860    pub fn mq_send(
1861        mqd: crate::mqd_t,
1862        msg_ptr: *const c_char,
1863        msg_len: size_t,
1864        msg_prio: c_uint,
1865    ) -> c_int;
1866    pub fn mq_setattr(
1867        mqd: crate::mqd_t,
1868        newattr: *const crate::mq_attr,
1869        oldattr: *mut crate::mq_attr,
1870    ) -> c_int;
1871    pub fn mq_timedreceive(
1872        mqd: crate::mqd_t,
1873        msg_ptr: *mut c_char,
1874        msg_len: size_t,
1875        msg_prio: *mut c_uint,
1876        abs_timeout: *const crate::timespec,
1877    ) -> ssize_t;
1878    pub fn mq_timedsend(
1879        mqd: crate::mqd_t,
1880        msg_ptr: *const c_char,
1881        msg_len: size_t,
1882        msg_prio: c_uint,
1883        abs_timeout: *const crate::timespec,
1884    ) -> c_int;
1885    pub fn mq_unlink(name: *const c_char) -> c_int;
1886
1887    pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t;
1888    pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int;
1889}
1890
1891#[link(name = "util")]
1892extern "C" {
1893    pub fn openpty(
1894        amaster: *mut c_int,
1895        aslave: *mut c_int,
1896        name: *mut c_char,
1897        termp: *mut termios,
1898        winp: *mut crate::winsize,
1899    ) -> c_int;
1900    pub fn forkpty(
1901        amaster: *mut c_int,
1902        name: *mut c_char,
1903        termp: *mut termios,
1904        winp: *mut crate::winsize,
1905    ) -> crate::pid_t;
1906    pub fn login_tty(fd: c_int) -> c_int;
1907    pub fn fparseln(
1908        stream: *mut crate::FILE,
1909        len: *mut size_t,
1910        lineno: *mut size_t,
1911        delim: *const c_char,
1912        flags: c_int,
1913    ) -> *mut c_char;
1914}
1915
1916#[link(name = "execinfo")]
1917extern "C" {
1918    pub fn backtrace(addrlist: *mut *mut c_void, len: size_t) -> size_t;
1919    pub fn backtrace_symbols(addrlist: *const *mut c_void, len: size_t) -> *mut *mut c_char;
1920    pub fn backtrace_symbols_fd(addrlist: *const *mut c_void, len: size_t, fd: c_int) -> c_int;
1921}
1922
1923#[link(name = "kvm")]
1924extern "C" {
1925    pub fn kvm_open(
1926        execfile: *const c_char,
1927        corefile: *const c_char,
1928        swapfile: *const c_char,
1929        flags: c_int,
1930        errstr: *const c_char,
1931    ) -> *mut crate::kvm_t;
1932    pub fn kvm_close(kd: *mut crate::kvm_t) -> c_int;
1933    pub fn kvm_getprocs(
1934        kd: *mut crate::kvm_t,
1935        op: c_int,
1936        arg: c_int,
1937        cnt: *mut c_int,
1938    ) -> *mut crate::kinfo_proc;
1939    pub fn kvm_getloadavg(kd: *mut kvm_t, loadavg: *mut c_double, nelem: c_int) -> c_int;
1940    pub fn kvm_openfiles(
1941        execfile: *const c_char,
1942        corefile: *const c_char,
1943        swapfile: *const c_char,
1944        flags: c_int,
1945        errbuf: *mut c_char,
1946    ) -> *mut crate::kvm_t;
1947    pub fn kvm_read(
1948        kd: *mut crate::kvm_t,
1949        addr: c_ulong,
1950        buf: *mut c_void,
1951        nbytes: size_t,
1952    ) -> ssize_t;
1953    pub fn kvm_write(
1954        kd: *mut crate::kvm_t,
1955        addr: c_ulong,
1956        buf: *const c_void,
1957        nbytes: size_t,
1958    ) -> ssize_t;
1959}
1960
1961cfg_if! {
1962    if #[cfg(target_os = "freebsd")] {
1963        mod freebsd;
1964        pub use self::freebsd::*;
1965    } else if #[cfg(target_os = "dragonfly")] {
1966        mod dragonfly;
1967        pub use self::dragonfly::*;
1968    } else {
1969        // ...
1970    }
1971}