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