Skip to main content

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

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