libc/unix/linux_like/linux/gnu/
mod.rs

1use crate::off64_t;
2use crate::prelude::*;
3
4pub type pthread_t = c_ulong;
5pub type __priority_which_t = c_uint;
6pub type __rlimit_resource_t = c_uint;
7pub type Lmid_t = c_long;
8pub type regoff_t = c_int;
9pub type __kernel_rwf_t = c_int;
10pub type __be16 = crate::__u16;
11
12cfg_if! {
13    if #[cfg(doc)] {
14        // Used in `linux::arch` to define ioctl constants.
15        pub(crate) type Ioctl = c_ulong;
16    } else {
17        #[doc(hidden)]
18        pub type Ioctl = c_ulong;
19    }
20}
21
22s! {
23    pub struct aiocb {
24        pub aio_fildes: c_int,
25        pub aio_lio_opcode: c_int,
26        pub aio_reqprio: c_int,
27        pub aio_buf: *mut c_void,
28        pub aio_nbytes: size_t,
29        pub aio_sigevent: crate::sigevent,
30        __next_prio: *mut aiocb,
31        __abs_prio: c_int,
32        __policy: c_int,
33        __error_code: c_int,
34        __return_value: ssize_t,
35        pub aio_offset: off_t,
36        #[cfg(all(
37            not(gnu_file_offset_bits64),
38            not(target_arch = "x86_64"),
39            target_pointer_width = "32"
40        ))]
41        __unused1: Padding<[c_char; 4]>,
42        __glibc_reserved: Padding<[c_char; 32]>,
43    }
44
45    pub struct __exit_status {
46        pub e_termination: c_short,
47        pub e_exit: c_short,
48    }
49
50    pub struct __timeval {
51        pub tv_sec: i32,
52        pub tv_usec: i32,
53    }
54
55    pub struct glob64_t {
56        pub gl_pathc: size_t,
57        pub gl_pathv: *mut *mut c_char,
58        pub gl_offs: size_t,
59        pub gl_flags: c_int,
60
61        __unused1: Padding<*mut c_void>,
62        __unused2: Padding<*mut c_void>,
63        __unused3: Padding<*mut c_void>,
64        __unused4: Padding<*mut c_void>,
65        __unused5: Padding<*mut c_void>,
66    }
67
68    pub struct msghdr {
69        pub msg_name: *mut c_void,
70        pub msg_namelen: crate::socklen_t,
71        pub msg_iov: *mut crate::iovec,
72        pub msg_iovlen: size_t,
73        pub msg_control: *mut c_void,
74        pub msg_controllen: size_t,
75        pub msg_flags: c_int,
76    }
77
78    pub struct cmsghdr {
79        pub cmsg_len: size_t,
80        pub cmsg_level: c_int,
81        pub cmsg_type: c_int,
82    }
83
84    pub struct termios {
85        pub c_iflag: crate::tcflag_t,
86        pub c_oflag: crate::tcflag_t,
87        pub c_cflag: crate::tcflag_t,
88        pub c_lflag: crate::tcflag_t,
89        pub c_line: crate::cc_t,
90        pub c_cc: [crate::cc_t; crate::NCCS],
91        #[cfg(not(any(
92            target_arch = "sparc",
93            target_arch = "sparc64",
94            target_arch = "mips",
95            target_arch = "mips32r6",
96            target_arch = "mips64",
97            target_arch = "mips64r6"
98        )))]
99        pub c_ispeed: crate::speed_t,
100        #[cfg(not(any(
101            target_arch = "sparc",
102            target_arch = "sparc64",
103            target_arch = "mips",
104            target_arch = "mips32r6",
105            target_arch = "mips64",
106            target_arch = "mips64r6"
107        )))]
108        pub c_ospeed: crate::speed_t,
109    }
110
111    pub struct mallinfo {
112        pub arena: c_int,
113        pub ordblks: c_int,
114        pub smblks: c_int,
115        pub hblks: c_int,
116        pub hblkhd: c_int,
117        pub usmblks: c_int,
118        pub fsmblks: c_int,
119        pub uordblks: c_int,
120        pub fordblks: c_int,
121        pub keepcost: c_int,
122    }
123
124    pub struct mallinfo2 {
125        pub arena: size_t,
126        pub ordblks: size_t,
127        pub smblks: size_t,
128        pub hblks: size_t,
129        pub hblkhd: size_t,
130        pub usmblks: size_t,
131        pub fsmblks: size_t,
132        pub uordblks: size_t,
133        pub fordblks: size_t,
134        pub keepcost: size_t,
135    }
136
137    pub struct ntptimeval {
138        pub time: crate::timeval,
139        pub maxerror: c_long,
140        pub esterror: c_long,
141        pub tai: c_long,
142        pub __glibc_reserved1: c_long,
143        pub __glibc_reserved2: c_long,
144        pub __glibc_reserved3: c_long,
145        pub __glibc_reserved4: c_long,
146    }
147
148    pub struct regex_t {
149        __buffer: *mut c_void,
150        __allocated: size_t,
151        __used: size_t,
152        __syntax: c_ulong,
153        __fastmap: *mut c_char,
154        __translate: *mut c_char,
155        __re_nsub: size_t,
156        __bitfield: u8,
157    }
158
159    pub struct Elf64_Chdr {
160        pub ch_type: crate::Elf64_Word,
161        pub ch_reserved: crate::Elf64_Word,
162        pub ch_size: crate::Elf64_Xword,
163        pub ch_addralign: crate::Elf64_Xword,
164    }
165
166    pub struct Elf32_Chdr {
167        pub ch_type: crate::Elf32_Word,
168        pub ch_size: crate::Elf32_Word,
169        pub ch_addralign: crate::Elf32_Word,
170    }
171
172    pub struct seminfo {
173        pub semmap: c_int,
174        pub semmni: c_int,
175        pub semmns: c_int,
176        pub semmnu: c_int,
177        pub semmsl: c_int,
178        pub semopm: c_int,
179        pub semume: c_int,
180        pub semusz: c_int,
181        pub semvmx: c_int,
182        pub semaem: c_int,
183    }
184
185    pub struct ptrace_peeksiginfo_args {
186        pub off: crate::__u64,
187        pub flags: crate::__u32,
188        pub nr: crate::__s32,
189    }
190
191    pub struct __c_anonymous_ptrace_syscall_info_entry {
192        pub nr: crate::__u64,
193        pub args: [crate::__u64; 6],
194    }
195
196    pub struct __c_anonymous_ptrace_syscall_info_exit {
197        pub sval: crate::__s64,
198        pub is_error: crate::__u8,
199    }
200
201    pub struct __c_anonymous_ptrace_syscall_info_seccomp {
202        pub nr: crate::__u64,
203        pub args: [crate::__u64; 6],
204        pub ret_data: crate::__u32,
205        reserved2: Padding<crate::__u32>,
206    }
207
208    pub struct ptrace_syscall_info {
209        pub op: crate::__u8,
210        reserved: Padding<crate::__u8>,
211        pub flags: crate::__u16,
212        pub arch: crate::__u32,
213        pub instruction_pointer: crate::__u64,
214        pub stack_pointer: crate::__u64,
215        pub u: __c_anonymous_ptrace_syscall_info_data,
216    }
217
218    pub struct ptrace_sud_config {
219        pub mode: crate::__u64,
220        pub selector: crate::__u64,
221        pub offset: crate::__u64,
222        pub len: crate::__u64,
223    }
224
225    pub struct iocb {
226        pub aio_data: crate::__u64,
227        #[cfg(target_endian = "little")]
228        pub aio_key: crate::__u32,
229        #[cfg(target_endian = "little")]
230        pub aio_rw_flags: crate::__kernel_rwf_t,
231        #[cfg(target_endian = "big")]
232        pub aio_rw_flags: crate::__kernel_rwf_t,
233        #[cfg(target_endian = "big")]
234        pub aio_key: crate::__u32,
235        pub aio_lio_opcode: crate::__u16,
236        pub aio_reqprio: crate::__s16,
237        pub aio_fildes: crate::__u32,
238        pub aio_buf: crate::__u64,
239        pub aio_nbytes: crate::__u64,
240        pub aio_offset: crate::__s64,
241        aio_reserved2: Padding<crate::__u64>,
242        pub aio_flags: crate::__u32,
243        pub aio_resfd: crate::__u32,
244    }
245
246    // netinet/tcp.h
247
248    pub struct tcp_info {
249        pub tcpi_state: u8,
250        pub tcpi_ca_state: u8,
251        pub tcpi_retransmits: u8,
252        pub tcpi_probes: u8,
253        pub tcpi_backoff: u8,
254        pub tcpi_options: u8,
255        /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
256        /// Each is 4 bits.
257        pub tcpi_snd_rcv_wscale: u8,
258        pub tcpi_rto: u32,
259        pub tcpi_ato: u32,
260        pub tcpi_snd_mss: u32,
261        pub tcpi_rcv_mss: u32,
262        pub tcpi_unacked: u32,
263        pub tcpi_sacked: u32,
264        pub tcpi_lost: u32,
265        pub tcpi_retrans: u32,
266        pub tcpi_fackets: u32,
267        pub tcpi_last_data_sent: u32,
268        pub tcpi_last_ack_sent: u32,
269        pub tcpi_last_data_recv: u32,
270        pub tcpi_last_ack_recv: u32,
271        pub tcpi_pmtu: u32,
272        pub tcpi_rcv_ssthresh: u32,
273        pub tcpi_rtt: u32,
274        pub tcpi_rttvar: u32,
275        pub tcpi_snd_ssthresh: u32,
276        pub tcpi_snd_cwnd: u32,
277        pub tcpi_advmss: u32,
278        pub tcpi_reordering: u32,
279        pub tcpi_rcv_rtt: u32,
280        pub tcpi_rcv_space: u32,
281        pub tcpi_total_retrans: u32,
282    }
283
284    pub struct fanotify_event_info_pidfd {
285        pub hdr: crate::fanotify_event_info_header,
286        pub pidfd: crate::__s32,
287    }
288
289    pub struct fanotify_event_info_error {
290        pub hdr: crate::fanotify_event_info_header,
291        pub error: crate::__s32,
292        pub error_count: crate::__u32,
293    }
294
295    // FIXME(1.0) this is actually a union
296    #[cfg_attr(target_pointer_width = "32", repr(align(4)))]
297    #[cfg_attr(target_pointer_width = "64", repr(align(8)))]
298    pub struct sem_t {
299        #[cfg(target_pointer_width = "32")]
300        __size: [c_char; 16],
301        #[cfg(target_pointer_width = "64")]
302        __size: [c_char; 32],
303    }
304
305    pub struct mbstate_t {
306        __count: c_int,
307        __wchb: [c_char; 4],
308    }
309
310    pub struct fpos64_t {
311        __pos: off64_t,
312        __state: crate::mbstate_t,
313    }
314
315    pub struct fpos_t {
316        #[cfg(not(gnu_file_offset_bits64))]
317        __pos: off_t,
318        #[cfg(gnu_file_offset_bits64)]
319        __pos: off64_t,
320        __state: crate::mbstate_t,
321    }
322
323    // linux x32 compatibility
324    // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437
325    #[derive(Default)]
326    pub struct timespec {
327        pub tv_sec: time_t,
328        #[cfg(all(gnu_time_bits64, target_endian = "big"))]
329        __pad: Padding<i32>,
330        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
331        pub tv_nsec: c_long,
332        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
333        pub tv_nsec: i64,
334        #[cfg(all(gnu_time_bits64, target_endian = "little"))]
335        __pad: Padding<i32>,
336    }
337
338    pub struct utmpx {
339        pub ut_type: c_short,
340        pub ut_pid: crate::pid_t,
341        pub ut_line: [c_char; __UT_LINESIZE],
342        pub ut_id: [c_char; 4],
343
344        pub ut_user: [c_char; __UT_NAMESIZE],
345        pub ut_host: [c_char; __UT_HOSTSIZE],
346        pub ut_exit: __exit_status,
347
348        #[cfg(any(
349            target_arch = "aarch64",
350            target_arch = "s390x",
351            target_arch = "loongarch64",
352            all(target_pointer_width = "32", not(target_arch = "x86_64"))
353        ))]
354        pub ut_session: c_long,
355        #[cfg(any(
356            target_arch = "aarch64",
357            target_arch = "s390x",
358            target_arch = "loongarch64",
359            all(target_pointer_width = "32", not(target_arch = "x86_64"))
360        ))]
361        pub ut_tv: crate::timeval,
362
363        #[cfg(not(any(
364            target_arch = "aarch64",
365            target_arch = "s390x",
366            target_arch = "loongarch64",
367            all(target_pointer_width = "32", not(target_arch = "x86_64"))
368        )))]
369        pub ut_session: i32,
370        #[cfg(not(any(
371            target_arch = "aarch64",
372            target_arch = "s390x",
373            target_arch = "loongarch64",
374            all(target_pointer_width = "32", not(target_arch = "x86_64"))
375        )))]
376        pub ut_tv: __timeval,
377
378        pub ut_addr_v6: [i32; 4],
379        __glibc_reserved: Padding<[c_char; 20]>,
380    }
381}
382
383impl siginfo_t {
384    pub unsafe fn si_addr(&self) -> *mut c_void {
385        #[repr(C)]
386        struct siginfo_sigfault {
387            _si_signo: c_int,
388            _si_errno: c_int,
389            _si_code: c_int,
390            si_addr: *mut c_void,
391        }
392        (*(self as *const siginfo_t).cast::<siginfo_sigfault>()).si_addr
393    }
394
395    pub unsafe fn si_value(&self) -> crate::sigval {
396        #[repr(C)]
397        struct siginfo_timer {
398            _si_signo: c_int,
399            _si_errno: c_int,
400            _si_code: c_int,
401            _si_tid: c_int,
402            _si_overrun: c_int,
403            si_sigval: crate::sigval,
404        }
405        (*(self as *const siginfo_t).cast::<siginfo_timer>()).si_sigval
406    }
407}
408
409s_no_extra_traits! {
410    // linux/if_ether.h
411
412    #[repr(C, packed)]
413    pub struct ethhdr {
414        pub h_dest: [c_uchar; crate::ETH_ALEN as usize],
415        pub h_source: [c_uchar; crate::ETH_ALEN as usize],
416        pub h_proto: crate::__be16,
417    }
418
419    // Internal, for casts to access union fields
420    struct sifields_sigchld {
421        si_pid: crate::pid_t,
422        si_uid: crate::uid_t,
423        si_status: c_int,
424        si_utime: c_long,
425        si_stime: c_long,
426    }
427
428    // Internal, for casts to access union fields
429    union sifields {
430        _align_pointer: *mut c_void,
431        sigchld: sifields_sigchld,
432    }
433
434    // Internal, for casts to access union fields. Note that some variants
435    // of sifields start with a pointer, which makes the alignment of
436    // sifields vary on 32-bit and 64-bit architectures.
437    struct siginfo_f {
438        _siginfo_base: [c_int; 3],
439        sifields: sifields,
440    }
441}
442
443impl siginfo_t {
444    unsafe fn sifields(&self) -> &sifields {
445        &(*(self as *const siginfo_t).cast::<siginfo_f>()).sifields
446    }
447
448    pub unsafe fn si_pid(&self) -> crate::pid_t {
449        self.sifields().sigchld.si_pid
450    }
451
452    pub unsafe fn si_uid(&self) -> crate::uid_t {
453        self.sifields().sigchld.si_uid
454    }
455
456    pub unsafe fn si_status(&self) -> c_int {
457        self.sifields().sigchld.si_status
458    }
459
460    pub unsafe fn si_utime(&self) -> c_long {
461        self.sifields().sigchld.si_utime
462    }
463
464    pub unsafe fn si_stime(&self) -> c_long {
465        self.sifields().sigchld.si_stime
466    }
467}
468
469s_no_extra_traits! {
470    pub union __c_anonymous_ptrace_syscall_info_data {
471        pub entry: __c_anonymous_ptrace_syscall_info_entry,
472        pub exit: __c_anonymous_ptrace_syscall_info_exit,
473        pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp,
474    }
475}
476
477cfg_if! {
478    if #[cfg(feature = "extra_traits")] {
479        impl PartialEq for __c_anonymous_ptrace_syscall_info_data {
480            fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool {
481                unsafe {
482                    self.entry == other.entry
483                        || self.exit == other.exit
484                        || self.seccomp == other.seccomp
485                }
486            }
487        }
488
489        impl Eq for __c_anonymous_ptrace_syscall_info_data {}
490
491        impl hash::Hash for __c_anonymous_ptrace_syscall_info_data {
492            fn hash<H: hash::Hasher>(&self, state: &mut H) {
493                unsafe {
494                    self.entry.hash(state);
495                    self.exit.hash(state);
496                    self.seccomp.hash(state);
497                }
498            }
499        }
500    }
501}
502
503// include/uapi/asm-generic/hugetlb_encode.h
504pub const HUGETLB_FLAG_ENCODE_SHIFT: c_int = 26;
505pub const HUGETLB_FLAG_ENCODE_MASK: c_int = 0x3f;
506
507pub const HUGETLB_FLAG_ENCODE_64KB: c_int = 16 << HUGETLB_FLAG_ENCODE_SHIFT;
508pub const HUGETLB_FLAG_ENCODE_512KB: c_int = 19 << HUGETLB_FLAG_ENCODE_SHIFT;
509pub const HUGETLB_FLAG_ENCODE_1MB: c_int = 20 << HUGETLB_FLAG_ENCODE_SHIFT;
510pub const HUGETLB_FLAG_ENCODE_2MB: c_int = 21 << HUGETLB_FLAG_ENCODE_SHIFT;
511pub const HUGETLB_FLAG_ENCODE_8MB: c_int = 23 << HUGETLB_FLAG_ENCODE_SHIFT;
512pub const HUGETLB_FLAG_ENCODE_16MB: c_int = 24 << HUGETLB_FLAG_ENCODE_SHIFT;
513pub const HUGETLB_FLAG_ENCODE_32MB: c_int = 25 << HUGETLB_FLAG_ENCODE_SHIFT;
514pub const HUGETLB_FLAG_ENCODE_256MB: c_int = 28 << HUGETLB_FLAG_ENCODE_SHIFT;
515pub const HUGETLB_FLAG_ENCODE_512MB: c_int = 29 << HUGETLB_FLAG_ENCODE_SHIFT;
516pub const HUGETLB_FLAG_ENCODE_1GB: c_int = 30 << HUGETLB_FLAG_ENCODE_SHIFT;
517pub const HUGETLB_FLAG_ENCODE_2GB: c_int = 31 << HUGETLB_FLAG_ENCODE_SHIFT;
518pub const HUGETLB_FLAG_ENCODE_16GB: c_int = 34 << HUGETLB_FLAG_ENCODE_SHIFT;
519
520// include/uapi/linux/mman.h
521/*
522 * Huge page size encoding when MAP_HUGETLB is specified, and a huge page
523 * size other than the default is desired.  See hugetlb_encode.h.
524 * All known huge page size encodings are provided here.  It is the
525 * responsibility of the application to know which sizes are supported on
526 * the running system.  See mmap(2) man page for details.
527 */
528pub const MAP_HUGE_SHIFT: c_int = HUGETLB_FLAG_ENCODE_SHIFT;
529pub const MAP_HUGE_MASK: c_int = HUGETLB_FLAG_ENCODE_MASK;
530
531pub const MAP_HUGE_64KB: c_int = HUGETLB_FLAG_ENCODE_64KB;
532pub const MAP_HUGE_512KB: c_int = HUGETLB_FLAG_ENCODE_512KB;
533pub const MAP_HUGE_1MB: c_int = HUGETLB_FLAG_ENCODE_1MB;
534pub const MAP_HUGE_2MB: c_int = HUGETLB_FLAG_ENCODE_2MB;
535pub const MAP_HUGE_8MB: c_int = HUGETLB_FLAG_ENCODE_8MB;
536pub const MAP_HUGE_16MB: c_int = HUGETLB_FLAG_ENCODE_16MB;
537pub const MAP_HUGE_32MB: c_int = HUGETLB_FLAG_ENCODE_32MB;
538pub const MAP_HUGE_256MB: c_int = HUGETLB_FLAG_ENCODE_256MB;
539pub const MAP_HUGE_512MB: c_int = HUGETLB_FLAG_ENCODE_512MB;
540pub const MAP_HUGE_1GB: c_int = HUGETLB_FLAG_ENCODE_1GB;
541pub const MAP_HUGE_2GB: c_int = HUGETLB_FLAG_ENCODE_2GB;
542pub const MAP_HUGE_16GB: c_int = HUGETLB_FLAG_ENCODE_16GB;
543
544pub const PRIO_PROCESS: crate::__priority_which_t = 0;
545pub const PRIO_PGRP: crate::__priority_which_t = 1;
546pub const PRIO_USER: crate::__priority_which_t = 2;
547
548pub const MS_RMT_MASK: c_ulong = 0x02800051;
549
550pub const __UT_LINESIZE: usize = 32;
551pub const __UT_NAMESIZE: usize = 32;
552pub const __UT_HOSTSIZE: usize = 256;
553pub const EMPTY: c_short = 0;
554pub const RUN_LVL: c_short = 1;
555pub const BOOT_TIME: c_short = 2;
556pub const NEW_TIME: c_short = 3;
557pub const OLD_TIME: c_short = 4;
558pub const INIT_PROCESS: c_short = 5;
559pub const LOGIN_PROCESS: c_short = 6;
560pub const USER_PROCESS: c_short = 7;
561pub const DEAD_PROCESS: c_short = 8;
562pub const ACCOUNTING: c_short = 9;
563
564// dlfcn.h
565pub const LM_ID_BASE: c_long = 0;
566pub const LM_ID_NEWLM: c_long = -1;
567
568pub const RTLD_DI_LMID: c_int = 1;
569pub const RTLD_DI_LINKMAP: c_int = 2;
570pub const RTLD_DI_CONFIGADDR: c_int = 3;
571pub const RTLD_DI_SERINFO: c_int = 4;
572pub const RTLD_DI_SERINFOSIZE: c_int = 5;
573pub const RTLD_DI_ORIGIN: c_int = 6;
574pub const RTLD_DI_PROFILENAME: c_int = 7;
575pub const RTLD_DI_PROFILEOUT: c_int = 8;
576pub const RTLD_DI_TLS_MODID: c_int = 9;
577pub const RTLD_DI_TLS_DATA: c_int = 10;
578
579pub const SOCK_NONBLOCK: c_int = O_NONBLOCK;
580
581pub const SOL_RXRPC: c_int = 272;
582pub const SOL_PPPOL2TP: c_int = 273;
583pub const SOL_PNPIPE: c_int = 275;
584pub const SOL_RDS: c_int = 276;
585pub const SOL_IUCV: c_int = 277;
586pub const SOL_CAIF: c_int = 278;
587pub const SOL_NFC: c_int = 280;
588
589pub const MSG_TRYHARD: c_int = 4;
590
591pub const LC_PAPER: c_int = 7;
592pub const LC_NAME: c_int = 8;
593pub const LC_ADDRESS: c_int = 9;
594pub const LC_TELEPHONE: c_int = 10;
595pub const LC_MEASUREMENT: c_int = 11;
596pub const LC_IDENTIFICATION: c_int = 12;
597pub const LC_PAPER_MASK: c_int = 1 << LC_PAPER;
598pub const LC_NAME_MASK: c_int = 1 << LC_NAME;
599pub const LC_ADDRESS_MASK: c_int = 1 << LC_ADDRESS;
600pub const LC_TELEPHONE_MASK: c_int = 1 << LC_TELEPHONE;
601pub const LC_MEASUREMENT_MASK: c_int = 1 << LC_MEASUREMENT;
602pub const LC_IDENTIFICATION_MASK: c_int = 1 << LC_IDENTIFICATION;
603pub const LC_ALL_MASK: c_int = crate::LC_CTYPE_MASK
604    | crate::LC_NUMERIC_MASK
605    | crate::LC_TIME_MASK
606    | crate::LC_COLLATE_MASK
607    | crate::LC_MONETARY_MASK
608    | crate::LC_MESSAGES_MASK
609    | LC_PAPER_MASK
610    | LC_NAME_MASK
611    | LC_ADDRESS_MASK
612    | LC_TELEPHONE_MASK
613    | LC_MEASUREMENT_MASK
614    | LC_IDENTIFICATION_MASK;
615
616pub const ENOTSUP: c_int = EOPNOTSUPP;
617
618pub const SOCK_SEQPACKET: c_int = 5;
619pub const SOCK_DCCP: c_int = 6;
620#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")]
621pub const SOCK_PACKET: c_int = 10;
622
623pub const AF_IB: c_int = 27;
624pub const AF_MPLS: c_int = 28;
625pub const AF_NFC: c_int = 39;
626pub const AF_VSOCK: c_int = 40;
627pub const AF_XDP: c_int = 44;
628pub const PF_IB: c_int = AF_IB;
629pub const PF_MPLS: c_int = AF_MPLS;
630pub const PF_NFC: c_int = AF_NFC;
631pub const PF_VSOCK: c_int = AF_VSOCK;
632pub const PF_XDP: c_int = AF_XDP;
633
634pub const SIGEV_THREAD_ID: c_int = 4;
635
636pub const BUFSIZ: c_uint = 8192;
637pub const TMP_MAX: c_uint = 238328;
638pub const FOPEN_MAX: c_uint = 16;
639pub const FILENAME_MAX: c_uint = 4096;
640pub const _CS_GNU_LIBC_VERSION: c_int = 2;
641pub const _CS_GNU_LIBPTHREAD_VERSION: c_int = 3;
642pub const _CS_V6_ENV: c_int = 1148;
643pub const _CS_V7_ENV: c_int = 1149;
644pub const _SC_EQUIV_CLASS_MAX: c_int = 41;
645pub const _SC_CHARCLASS_NAME_MAX: c_int = 45;
646pub const _SC_PII: c_int = 53;
647pub const _SC_PII_XTI: c_int = 54;
648pub const _SC_PII_SOCKET: c_int = 55;
649pub const _SC_PII_INTERNET: c_int = 56;
650pub const _SC_PII_OSI: c_int = 57;
651pub const _SC_POLL: c_int = 58;
652pub const _SC_SELECT: c_int = 59;
653pub const _SC_PII_INTERNET_STREAM: c_int = 61;
654pub const _SC_PII_INTERNET_DGRAM: c_int = 62;
655pub const _SC_PII_OSI_COTS: c_int = 63;
656pub const _SC_PII_OSI_CLTS: c_int = 64;
657pub const _SC_PII_OSI_M: c_int = 65;
658pub const _SC_T_IOV_MAX: c_int = 66;
659pub const _SC_2_C_VERSION: c_int = 96;
660pub const _SC_CHAR_BIT: c_int = 101;
661pub const _SC_CHAR_MAX: c_int = 102;
662pub const _SC_CHAR_MIN: c_int = 103;
663pub const _SC_INT_MAX: c_int = 104;
664pub const _SC_INT_MIN: c_int = 105;
665pub const _SC_LONG_BIT: c_int = 106;
666pub const _SC_WORD_BIT: c_int = 107;
667pub const _SC_MB_LEN_MAX: c_int = 108;
668pub const _SC_SSIZE_MAX: c_int = 110;
669pub const _SC_SCHAR_MAX: c_int = 111;
670pub const _SC_SCHAR_MIN: c_int = 112;
671pub const _SC_SHRT_MAX: c_int = 113;
672pub const _SC_SHRT_MIN: c_int = 114;
673pub const _SC_UCHAR_MAX: c_int = 115;
674pub const _SC_UINT_MAX: c_int = 116;
675pub const _SC_ULONG_MAX: c_int = 117;
676pub const _SC_USHRT_MAX: c_int = 118;
677pub const _SC_NL_ARGMAX: c_int = 119;
678pub const _SC_NL_LANGMAX: c_int = 120;
679pub const _SC_NL_MSGMAX: c_int = 121;
680pub const _SC_NL_NMAX: c_int = 122;
681pub const _SC_NL_SETMAX: c_int = 123;
682pub const _SC_NL_TEXTMAX: c_int = 124;
683pub const _SC_BASE: c_int = 134;
684pub const _SC_C_LANG_SUPPORT: c_int = 135;
685pub const _SC_C_LANG_SUPPORT_R: c_int = 136;
686pub const _SC_DEVICE_IO: c_int = 140;
687pub const _SC_DEVICE_SPECIFIC: c_int = 141;
688pub const _SC_DEVICE_SPECIFIC_R: c_int = 142;
689pub const _SC_FD_MGMT: c_int = 143;
690pub const _SC_FIFO: c_int = 144;
691pub const _SC_PIPE: c_int = 145;
692pub const _SC_FILE_ATTRIBUTES: c_int = 146;
693pub const _SC_FILE_LOCKING: c_int = 147;
694pub const _SC_FILE_SYSTEM: c_int = 148;
695pub const _SC_MULTI_PROCESS: c_int = 150;
696pub const _SC_SINGLE_PROCESS: c_int = 151;
697pub const _SC_NETWORKING: c_int = 152;
698pub const _SC_REGEX_VERSION: c_int = 156;
699pub const _SC_SIGNALS: c_int = 158;
700pub const _SC_SYSTEM_DATABASE: c_int = 162;
701pub const _SC_SYSTEM_DATABASE_R: c_int = 163;
702pub const _SC_USER_GROUPS: c_int = 166;
703pub const _SC_USER_GROUPS_R: c_int = 167;
704pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 185;
705pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 186;
706pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 187;
707pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 188;
708pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 189;
709pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 190;
710pub const _SC_LEVEL2_CACHE_SIZE: c_int = 191;
711pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 192;
712pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 193;
713pub const _SC_LEVEL3_CACHE_SIZE: c_int = 194;
714pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 195;
715pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 196;
716pub const _SC_LEVEL4_CACHE_SIZE: c_int = 197;
717pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 198;
718pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 199;
719pub const O_ACCMODE: c_int = 3;
720pub const ST_RELATIME: c_ulong = 4096;
721pub const NI_MAXHOST: crate::socklen_t = 1025;
722
723// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the
724// following are only available on newer Linux versions than the versions
725// currently used in CI in some configurations, so we define them here.
726cfg_if! {
727    if #[cfg(not(target_arch = "s390x"))] {
728        pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70;
729        pub const XFS_SUPER_MAGIC: c_long = 0x58465342;
730    } else if #[cfg(target_arch = "s390x")] {
731        pub const BINDERFS_SUPER_MAGIC: c_uint = 0x6c6f6f70;
732        pub const XFS_SUPER_MAGIC: c_uint = 0x58465342;
733    }
734}
735
736pub const CPU_SETSIZE: c_int = 0x400;
737
738pub const PTRACE_TRACEME: c_uint = 0;
739pub const PTRACE_PEEKTEXT: c_uint = 1;
740pub const PTRACE_PEEKDATA: c_uint = 2;
741pub const PTRACE_PEEKUSER: c_uint = 3;
742pub const PTRACE_POKETEXT: c_uint = 4;
743pub const PTRACE_POKEDATA: c_uint = 5;
744pub const PTRACE_POKEUSER: c_uint = 6;
745pub const PTRACE_CONT: c_uint = 7;
746pub const PTRACE_KILL: c_uint = 8;
747pub const PTRACE_SINGLESTEP: c_uint = 9;
748pub const PTRACE_ATTACH: c_uint = 16;
749pub const PTRACE_SYSCALL: c_uint = 24;
750pub const PTRACE_SETOPTIONS: c_uint = 0x4200;
751pub const PTRACE_GETEVENTMSG: c_uint = 0x4201;
752pub const PTRACE_GETSIGINFO: c_uint = 0x4202;
753pub const PTRACE_SETSIGINFO: c_uint = 0x4203;
754pub const PTRACE_GETREGSET: c_uint = 0x4204;
755pub const PTRACE_SETREGSET: c_uint = 0x4205;
756pub const PTRACE_SEIZE: c_uint = 0x4206;
757pub const PTRACE_INTERRUPT: c_uint = 0x4207;
758pub const PTRACE_LISTEN: c_uint = 0x4208;
759pub const PTRACE_PEEKSIGINFO: c_uint = 0x4209;
760pub const PTRACE_GETSIGMASK: c_uint = 0x420a;
761pub const PTRACE_SETSIGMASK: c_uint = 0x420b;
762pub const PTRACE_GET_SYSCALL_INFO: c_uint = 0x420e;
763pub const PTRACE_SET_SYSCALL_INFO: c_uint = 0x4212;
764pub const PTRACE_SYSCALL_INFO_NONE: crate::__u8 = 0;
765pub const PTRACE_SYSCALL_INFO_ENTRY: crate::__u8 = 1;
766pub const PTRACE_SYSCALL_INFO_EXIT: crate::__u8 = 2;
767pub const PTRACE_SYSCALL_INFO_SECCOMP: crate::__u8 = 3;
768pub const PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4210;
769pub const PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4211;
770
771// linux/rtnetlink.h
772pub const TCA_PAD: c_ushort = 9;
773pub const TCA_DUMP_INVISIBLE: c_ushort = 10;
774pub const TCA_CHAIN: c_ushort = 11;
775pub const TCA_HW_OFFLOAD: c_ushort = 12;
776
777pub const RTM_DELNETCONF: u16 = 81;
778pub const RTM_NEWSTATS: u16 = 92;
779pub const RTM_GETSTATS: u16 = 94;
780pub const RTM_NEWCACHEREPORT: u16 = 96;
781
782pub const RTM_F_LOOKUP_TABLE: c_uint = 0x1000;
783pub const RTM_F_FIB_MATCH: c_uint = 0x2000;
784
785pub const RTA_VIA: c_ushort = 18;
786pub const RTA_NEWDST: c_ushort = 19;
787pub const RTA_PREF: c_ushort = 20;
788pub const RTA_ENCAP_TYPE: c_ushort = 21;
789pub const RTA_ENCAP: c_ushort = 22;
790pub const RTA_EXPIRES: c_ushort = 23;
791pub const RTA_PAD: c_ushort = 24;
792pub const RTA_UID: c_ushort = 25;
793pub const RTA_TTL_PROPAGATE: c_ushort = 26;
794
795// linux/neighbor.h
796pub const NTF_EXT_LEARNED: u8 = 0x10;
797pub const NTF_OFFLOADED: u8 = 0x20;
798
799pub const NDA_MASTER: c_ushort = 9;
800pub const NDA_LINK_NETNSID: c_ushort = 10;
801pub const NDA_SRC_VNI: c_ushort = 11;
802
803// linux/personality.h
804pub const UNAME26: c_int = 0x0020000;
805pub const FDPIC_FUNCPTRS: c_int = 0x0080000;
806
807pub const GENL_UNS_ADMIN_PERM: c_int = 0x10;
808
809pub const GENL_ID_VFS_DQUOT: c_int = crate::NLMSG_MIN_TYPE + 1;
810pub const GENL_ID_PMCRAID: c_int = crate::NLMSG_MIN_TYPE + 2;
811
812pub const ELFOSABI_ARM_AEABI: u8 = 64;
813
814// linux/sched.h
815pub const CLONE_NEWTIME: c_int = 0x80;
816// DIFF(main): changed to `c_ulonglong` in e9abac9ac2
817pub const CLONE_CLEAR_SIGHAND: c_int = 0x100000000;
818pub const CLONE_INTO_CGROUP: c_int = 0x200000000;
819
820pub const M_MXFAST: c_int = 1;
821pub const M_NLBLKS: c_int = 2;
822pub const M_GRAIN: c_int = 3;
823pub const M_KEEP: c_int = 4;
824pub const M_TRIM_THRESHOLD: c_int = -1;
825pub const M_TOP_PAD: c_int = -2;
826pub const M_MMAP_THRESHOLD: c_int = -3;
827pub const M_MMAP_MAX: c_int = -4;
828pub const M_CHECK_ACTION: c_int = -5;
829pub const M_PERTURB: c_int = -6;
830pub const M_ARENA_TEST: c_int = -7;
831pub const M_ARENA_MAX: c_int = -8;
832
833pub const SOMAXCONN: c_int = 4096;
834
835// linux/mount.h
836pub const MOVE_MOUNT_F_SYMLINKS: c_uint = 0x00000001;
837pub const MOVE_MOUNT_F_AUTOMOUNTS: c_uint = 0x00000002;
838pub const MOVE_MOUNT_F_EMPTY_PATH: c_uint = 0x00000004;
839pub const MOVE_MOUNT_T_SYMLINKS: c_uint = 0x00000010;
840pub const MOVE_MOUNT_T_AUTOMOUNTS: c_uint = 0x00000020;
841pub const MOVE_MOUNT_T_EMPTY_PATH: c_uint = 0x00000040;
842pub const MOVE_MOUNT_SET_GROUP: c_uint = 0x00000100;
843pub const MOVE_MOUNT_BENEATH: c_uint = 0x00000200;
844
845// sys/timex.h
846pub const ADJ_OFFSET: c_uint = 0x0001;
847pub const ADJ_FREQUENCY: c_uint = 0x0002;
848pub const ADJ_MAXERROR: c_uint = 0x0004;
849pub const ADJ_ESTERROR: c_uint = 0x0008;
850pub const ADJ_STATUS: c_uint = 0x0010;
851pub const ADJ_TIMECONST: c_uint = 0x0020;
852pub const ADJ_TAI: c_uint = 0x0080;
853pub const ADJ_SETOFFSET: c_uint = 0x0100;
854pub const ADJ_MICRO: c_uint = 0x1000;
855pub const ADJ_NANO: c_uint = 0x2000;
856pub const ADJ_TICK: c_uint = 0x4000;
857pub const ADJ_OFFSET_SINGLESHOT: c_uint = 0x8001;
858pub const ADJ_OFFSET_SS_READ: c_uint = 0xa001;
859pub const MOD_OFFSET: c_uint = ADJ_OFFSET;
860pub const MOD_FREQUENCY: c_uint = ADJ_FREQUENCY;
861pub const MOD_MAXERROR: c_uint = ADJ_MAXERROR;
862pub const MOD_ESTERROR: c_uint = ADJ_ESTERROR;
863pub const MOD_STATUS: c_uint = ADJ_STATUS;
864pub const MOD_TIMECONST: c_uint = ADJ_TIMECONST;
865pub const MOD_CLKB: c_uint = ADJ_TICK;
866pub const MOD_CLKA: c_uint = ADJ_OFFSET_SINGLESHOT;
867pub const MOD_TAI: c_uint = ADJ_TAI;
868pub const MOD_MICRO: c_uint = ADJ_MICRO;
869pub const MOD_NANO: c_uint = ADJ_NANO;
870pub const STA_PLL: c_int = 0x0001;
871pub const STA_PPSFREQ: c_int = 0x0002;
872pub const STA_PPSTIME: c_int = 0x0004;
873pub const STA_FLL: c_int = 0x0008;
874pub const STA_INS: c_int = 0x0010;
875pub const STA_DEL: c_int = 0x0020;
876pub const STA_UNSYNC: c_int = 0x0040;
877pub const STA_FREQHOLD: c_int = 0x0080;
878pub const STA_PPSSIGNAL: c_int = 0x0100;
879pub const STA_PPSJITTER: c_int = 0x0200;
880pub const STA_PPSWANDER: c_int = 0x0400;
881pub const STA_PPSERROR: c_int = 0x0800;
882pub const STA_CLOCKERR: c_int = 0x1000;
883pub const STA_NANO: c_int = 0x2000;
884pub const STA_MODE: c_int = 0x4000;
885pub const STA_CLK: c_int = 0x8000;
886pub const STA_RONLY: c_int = STA_PPSSIGNAL
887    | STA_PPSJITTER
888    | STA_PPSWANDER
889    | STA_PPSERROR
890    | STA_CLOCKERR
891    | STA_NANO
892    | STA_MODE
893    | STA_CLK;
894pub const NTP_API: c_int = 4;
895pub const TIME_OK: c_int = 0;
896pub const TIME_INS: c_int = 1;
897pub const TIME_DEL: c_int = 2;
898pub const TIME_OOP: c_int = 3;
899pub const TIME_WAIT: c_int = 4;
900pub const TIME_ERROR: c_int = 5;
901pub const TIME_BAD: c_int = TIME_ERROR;
902pub const MAXTC: c_long = 6;
903
904// Portable GLOB_* flags are defined at the `linux_like` level.
905// The following are GNU extensions.
906pub const GLOB_PERIOD: c_int = 1 << 7;
907pub const GLOB_ALTDIRFUNC: c_int = 1 << 9;
908pub const GLOB_BRACE: c_int = 1 << 10;
909pub const GLOB_NOMAGIC: c_int = 1 << 11;
910pub const GLOB_TILDE: c_int = 1 << 12;
911pub const GLOB_ONLYDIR: c_int = 1 << 13;
912pub const GLOB_TILDE_CHECK: c_int = 1 << 14;
913
914pub const MADV_COLLAPSE: c_int = 25;
915
916cfg_if! {
917    if #[cfg(any(
918        target_arch = "arm",
919        target_arch = "x86",
920        target_arch = "x86_64",
921        target_arch = "s390x",
922        target_arch = "riscv64",
923        target_arch = "riscv32"
924    ))] {
925        pub const PTHREAD_STACK_MIN: size_t = 16384;
926    } else if #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] {
927        pub const PTHREAD_STACK_MIN: size_t = 0x6000;
928    } else {
929        pub const PTHREAD_STACK_MIN: size_t = 131072;
930    }
931}
932pub const PTHREAD_MUTEX_ADAPTIVE_NP: c_int = 3;
933
934pub const REG_STARTEND: c_int = 4;
935
936pub const REG_EEND: c_int = 14;
937pub const REG_ESIZE: c_int = 15;
938pub const REG_ERPAREN: c_int = 16;
939
940extern "C" {
941    pub fn fgetspent_r(
942        fp: *mut crate::FILE,
943        spbuf: *mut crate::spwd,
944        buf: *mut c_char,
945        buflen: size_t,
946        spbufp: *mut *mut crate::spwd,
947    ) -> c_int;
948    pub fn sgetspent_r(
949        s: *const c_char,
950        spbuf: *mut crate::spwd,
951        buf: *mut c_char,
952        buflen: size_t,
953        spbufp: *mut *mut crate::spwd,
954    ) -> c_int;
955    pub fn getspent_r(
956        spbuf: *mut crate::spwd,
957        buf: *mut c_char,
958        buflen: size_t,
959        spbufp: *mut *mut crate::spwd,
960    ) -> c_int;
961    pub fn qsort_r(
962        base: *mut c_void,
963        num: size_t,
964        size: size_t,
965        compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
966        arg: *mut c_void,
967    );
968    #[cfg_attr(gnu_time_bits64, link_name = "__sendmmsg64")]
969    pub fn sendmmsg(
970        sockfd: c_int,
971        msgvec: *mut crate::mmsghdr,
972        vlen: c_uint,
973        flags: c_int,
974    ) -> c_int;
975    #[cfg_attr(gnu_time_bits64, link_name = "__recvmmsg64")]
976    pub fn recvmmsg(
977        sockfd: c_int,
978        msgvec: *mut crate::mmsghdr,
979        vlen: c_uint,
980        flags: c_int,
981        timeout: *mut crate::timespec,
982    ) -> c_int;
983
984    pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int;
985    pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64)
986        -> c_int;
987    #[cfg_attr(gnu_file_offset_bits64, link_name = "getrlimit64")]
988    pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int;
989    #[cfg_attr(gnu_file_offset_bits64, link_name = "setrlimit64")]
990    pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int;
991    #[cfg_attr(gnu_file_offset_bits64, link_name = "prlimit64")]
992    pub fn prlimit(
993        pid: crate::pid_t,
994        resource: crate::__rlimit_resource_t,
995        new_limit: *const crate::rlimit,
996        old_limit: *mut crate::rlimit,
997    ) -> c_int;
998    pub fn prlimit64(
999        pid: crate::pid_t,
1000        resource: crate::__rlimit_resource_t,
1001        new_limit: *const crate::rlimit64,
1002        old_limit: *mut crate::rlimit64,
1003    ) -> c_int;
1004    pub fn utmpname(file: *const c_char) -> c_int;
1005    pub fn utmpxname(file: *const c_char) -> c_int;
1006    pub fn getutxent() -> *mut utmpx;
1007    pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
1008    pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
1009    pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
1010    pub fn setutxent();
1011    pub fn endutxent();
1012    pub fn getpt() -> c_int;
1013    pub fn mallopt(param: c_int, value: c_int) -> c_int;
1014    #[cfg_attr(gnu_time_bits64, link_name = "__gettimeofday64")]
1015    pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int;
1016    pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int;
1017    pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t;
1018    pub fn getauxval(type_: c_ulong) -> c_ulong;
1019
1020    #[cfg_attr(gnu_time_bits64, link_name = "___adjtimex64")]
1021    pub fn adjtimex(buf: *mut timex) -> c_int;
1022    #[cfg_attr(gnu_time_bits64, link_name = "___adjtimex64")]
1023    pub fn ntp_adjtime(buf: *mut timex) -> c_int;
1024    #[cfg_attr(not(gnu_time_bits64), link_name = "ntp_gettimex")]
1025    #[cfg_attr(gnu_time_bits64, link_name = "__ntp_gettime64")]
1026    pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int;
1027    #[cfg_attr(gnu_time_bits64, link_name = "__clock_adjtime64")]
1028    pub fn clock_adjtime(clk_id: crate::clockid_t, buf: *mut crate::timex) -> c_int;
1029
1030    pub fn fanotify_mark(
1031        fd: c_int,
1032        flags: c_uint,
1033        mask: u64,
1034        dirfd: c_int,
1035        path: *const c_char,
1036    ) -> c_int;
1037    #[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64v2")]
1038    pub fn preadv2(
1039        fd: c_int,
1040        iov: *const crate::iovec,
1041        iovcnt: c_int,
1042        offset: off_t,
1043        flags: c_int,
1044    ) -> ssize_t;
1045    #[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64v2")]
1046    pub fn pwritev2(
1047        fd: c_int,
1048        iov: *const crate::iovec,
1049        iovcnt: c_int,
1050        offset: off_t,
1051        flags: c_int,
1052    ) -> ssize_t;
1053    pub fn preadv64v2(
1054        fd: c_int,
1055        iov: *const crate::iovec,
1056        iovcnt: c_int,
1057        offset: off64_t,
1058        flags: c_int,
1059    ) -> ssize_t;
1060    pub fn pwritev64v2(
1061        fd: c_int,
1062        iov: *const crate::iovec,
1063        iovcnt: c_int,
1064        offset: off64_t,
1065        flags: c_int,
1066    ) -> ssize_t;
1067    pub fn renameat2(
1068        olddirfd: c_int,
1069        oldpath: *const c_char,
1070        newdirfd: c_int,
1071        newpath: *const c_char,
1072        flags: c_uint,
1073    ) -> c_int;
1074
1075    // Added in `glibc` 2.25
1076    pub fn explicit_bzero(s: *mut c_void, len: size_t);
1077    // Added in `glibc` 2.29
1078    pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void;
1079
1080    pub fn ctermid(s: *mut c_char) -> *mut c_char;
1081    pub fn backtrace(buf: *mut *mut c_void, sz: c_int) -> c_int;
1082    pub fn backtrace_symbols(buffer: *const *mut c_void, len: c_int) -> *mut *mut c_char;
1083    pub fn backtrace_symbols_fd(buffer: *const *mut c_void, len: c_int, fd: c_int);
1084    #[cfg_attr(gnu_time_bits64, link_name = "__glob64_time64")]
1085    pub fn glob64(
1086        pattern: *const c_char,
1087        flags: c_int,
1088        errfunc: Option<extern "C" fn(epath: *const c_char, errno: c_int) -> c_int>,
1089        pglob: *mut glob64_t,
1090    ) -> c_int;
1091    #[cfg_attr(gnu_time_bits64, link_name = "__globfree64_time64")]
1092    pub fn globfree64(pglob: *mut glob64_t);
1093    pub fn ptrace(request: c_uint, ...) -> c_long;
1094    pub fn pthread_attr_getaffinity_np(
1095        attr: *const crate::pthread_attr_t,
1096        cpusetsize: size_t,
1097        cpuset: *mut crate::cpu_set_t,
1098    ) -> c_int;
1099    pub fn pthread_attr_setaffinity_np(
1100        attr: *mut crate::pthread_attr_t,
1101        cpusetsize: size_t,
1102        cpuset: *const crate::cpu_set_t,
1103    ) -> c_int;
1104    pub fn getpriority(which: crate::__priority_which_t, who: crate::id_t) -> c_int;
1105    pub fn setpriority(which: crate::__priority_which_t, who: crate::id_t, prio: c_int) -> c_int;
1106    pub fn pthread_rwlockattr_getkind_np(
1107        attr: *const crate::pthread_rwlockattr_t,
1108        val: *mut c_int,
1109    ) -> c_int;
1110    pub fn pthread_rwlockattr_setkind_np(
1111        attr: *mut crate::pthread_rwlockattr_t,
1112        val: c_int,
1113    ) -> c_int;
1114    pub fn pthread_sigqueue(thread: crate::pthread_t, sig: c_int, value: crate::sigval) -> c_int;
1115    pub fn pthread_tryjoin_np(thread: crate::pthread_t, retval: *mut *mut c_void) -> c_int;
1116    #[cfg_attr(
1117        all(target_pointer_width = "32", gnu_time_bits64),
1118        link_name = "__pthread_timedjoin_np64"
1119    )]
1120    pub fn pthread_timedjoin_np(
1121        thread: crate::pthread_t,
1122        retval: *mut *mut c_void,
1123        abstime: *const crate::timespec,
1124    ) -> c_int;
1125    pub fn mallinfo() -> crate::mallinfo;
1126    pub fn mallinfo2() -> crate::mallinfo2;
1127    pub fn malloc_stats();
1128    pub fn malloc_info(options: c_int, stream: *mut crate::FILE) -> c_int;
1129    pub fn malloc_usable_size(ptr: *mut c_void) -> size_t;
1130    pub fn getpwent_r(
1131        pwd: *mut crate::passwd,
1132        buf: *mut c_char,
1133        buflen: size_t,
1134        result: *mut *mut crate::passwd,
1135    ) -> c_int;
1136    pub fn getgrent_r(
1137        grp: *mut crate::group,
1138        buf: *mut c_char,
1139        buflen: size_t,
1140        result: *mut *mut crate::group,
1141    ) -> c_int;
1142    pub fn fgetpwent_r(
1143        stream: *mut crate::FILE,
1144        pwd: *mut crate::passwd,
1145        buf: *mut c_char,
1146        buflen: size_t,
1147        result: *mut *mut crate::passwd,
1148    ) -> c_int;
1149    pub fn fgetgrent_r(
1150        stream: *mut crate::FILE,
1151        grp: *mut crate::group,
1152        buf: *mut c_char,
1153        buflen: size_t,
1154        result: *mut *mut crate::group,
1155    ) -> c_int;
1156
1157    pub fn putpwent(p: *const crate::passwd, stream: *mut crate::FILE) -> c_int;
1158    pub fn putgrent(grp: *const crate::group, stream: *mut crate::FILE) -> c_int;
1159
1160    pub fn sethostid(hostid: c_long) -> c_int;
1161
1162    pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int;
1163    pub fn mlock2(addr: *const c_void, len: size_t, flags: c_uint) -> c_int;
1164
1165    pub fn euidaccess(pathname: *const c_char, mode: c_int) -> c_int;
1166    pub fn eaccess(pathname: *const c_char, mode: c_int) -> c_int;
1167
1168    pub fn asctime_r(tm: *const crate::tm, buf: *mut c_char) -> *mut c_char;
1169    #[cfg_attr(gnu_time_bits64, link_name = "__ctime64_r")]
1170    pub fn ctime_r(timep: *const time_t, buf: *mut c_char) -> *mut c_char;
1171
1172    pub fn dirname(path: *mut c_char) -> *mut c_char;
1173    /// POSIX version of `basename(3)`, defined in `libgen.h`.
1174    #[link_name = "__xpg_basename"]
1175    pub fn posix_basename(path: *mut c_char) -> *mut c_char;
1176    /// GNU version of `basename(3)`, defined in `string.h`.
1177    #[link_name = "basename"]
1178    pub fn gnu_basename(path: *const c_char) -> *mut c_char;
1179    pub fn dlmopen(lmid: Lmid_t, filename: *const c_char, flag: c_int) -> *mut c_void;
1180    pub fn dlinfo(handle: *mut c_void, request: c_int, info: *mut c_void) -> c_int;
1181    pub fn dladdr1(
1182        addr: *const c_void,
1183        info: *mut crate::Dl_info,
1184        extra_info: *mut *mut c_void,
1185        flags: c_int,
1186    ) -> c_int;
1187    pub fn dlvsym(
1188        handle: *mut c_void,
1189        symbol: *const c_char,
1190        version: *const c_char,
1191    ) -> *mut c_void;
1192    pub fn malloc_trim(__pad: size_t) -> c_int;
1193    pub fn gnu_get_libc_release() -> *const c_char;
1194    pub fn gnu_get_libc_version() -> *const c_char;
1195
1196    // posix/spawn.h
1197    // Added in `glibc` 2.29
1198    pub fn posix_spawn_file_actions_addchdir_np(
1199        actions: *mut crate::posix_spawn_file_actions_t,
1200        path: *const c_char,
1201    ) -> c_int;
1202    // Added in `glibc` 2.29
1203    pub fn posix_spawn_file_actions_addfchdir_np(
1204        actions: *mut crate::posix_spawn_file_actions_t,
1205        fd: c_int,
1206    ) -> c_int;
1207    // Added in `glibc` 2.34
1208    pub fn posix_spawn_file_actions_addclosefrom_np(
1209        actions: *mut crate::posix_spawn_file_actions_t,
1210        from: c_int,
1211    ) -> c_int;
1212    // Added in `glibc` 2.35
1213    pub fn posix_spawn_file_actions_addtcsetpgrp_np(
1214        actions: *mut crate::posix_spawn_file_actions_t,
1215        tcfd: c_int,
1216    ) -> c_int;
1217
1218    // mntent.h
1219    pub fn getmntent_r(
1220        stream: *mut crate::FILE,
1221        mntbuf: *mut crate::mntent,
1222        buf: *mut c_char,
1223        buflen: c_int,
1224    ) -> *mut crate::mntent;
1225
1226    pub fn execveat(
1227        dirfd: c_int,
1228        pathname: *const c_char,
1229        argv: *const *mut c_char,
1230        envp: *const *mut c_char,
1231        flags: c_int,
1232    ) -> c_int;
1233
1234    // Added in `glibc` 2.34
1235    pub fn close_range(first: c_uint, last: c_uint, flags: c_int) -> c_int;
1236
1237    pub fn mq_notify(mqdes: crate::mqd_t, sevp: *const crate::sigevent) -> c_int;
1238
1239    #[cfg_attr(gnu_time_bits64, link_name = "__epoll_pwait2_time64")]
1240    pub fn epoll_pwait2(
1241        epfd: c_int,
1242        events: *mut crate::epoll_event,
1243        maxevents: c_int,
1244        timeout: *const crate::timespec,
1245        sigmask: *const crate::sigset_t,
1246    ) -> c_int;
1247
1248    pub fn mempcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
1249
1250    pub fn tgkill(tgid: crate::pid_t, tid: crate::pid_t, sig: c_int) -> c_int;
1251}
1252
1253cfg_if! {
1254    if #[cfg(any(
1255        target_arch = "x86",
1256        target_arch = "arm",
1257        target_arch = "m68k",
1258        target_arch = "csky",
1259        target_arch = "mips",
1260        target_arch = "mips32r6",
1261        target_arch = "powerpc",
1262        target_arch = "sparc",
1263        target_arch = "riscv32"
1264    ))] {
1265        mod b32;
1266        pub use self::b32::*;
1267    } else if #[cfg(any(
1268        target_arch = "x86_64",
1269        target_arch = "aarch64",
1270        target_arch = "powerpc64",
1271        target_arch = "mips64",
1272        target_arch = "mips64r6",
1273        target_arch = "s390x",
1274        target_arch = "sparc64",
1275        target_arch = "riscv64",
1276        target_arch = "loongarch64"
1277    ))] {
1278        mod b64;
1279        pub use self::b64::*;
1280    } else {
1281        // Unknown target_arch
1282    }
1283}