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