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