1 pub type pthread_t = *mut ::c_void;
2 pub type clock_t = c_long;
3 #[cfg_attr(
4     not(feature = "rustc-dep-of-std"),
5     deprecated(
6         since = "0.2.80",
7         note = "This type is changed to 64-bit in musl 1.2.0, \
8                 we'll follow that change in the future release. \
9                 See #1848 for more info."
10     )
11 )]
12 pub type time_t = c_long;
13 pub type suseconds_t = c_long;
14 pub type ino_t = u64;
15 pub type off_t = i64;
16 pub type blkcnt_t = i64;
17 
18 pub type shmatt_t = ::c_ulong;
19 pub type msgqnum_t = ::c_ulong;
20 pub type msglen_t = ::c_ulong;
21 pub type fsblkcnt_t = ::c_ulonglong;
22 pub type fsfilcnt_t = ::c_ulonglong;
23 pub type rlim_t = ::c_ulonglong;
24 
25 cfg_if! {
26     if #[cfg(doc)] {
27         // Used in `linux::arch` to define ioctl constants.
28         pub(crate) type Ioctl = ::c_int;
29     } else {
30         #[doc(hidden)]
31         pub type Ioctl = ::c_int;
32     }
33 }
34 
35 impl siginfo_t {
36     pub unsafe fn si_addr(&self) -> *mut ::c_void {
37         #[repr(C)]
38         struct siginfo_sigfault {
39             _si_signo: ::c_int,
40             _si_errno: ::c_int,
41             _si_code: ::c_int,
42             si_addr: *mut ::c_void,
43         }
44         (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
45     }
46 
47     pub unsafe fn si_value(&self) -> ::sigval {
48         #[repr(C)]
49         struct siginfo_si_value {
50             _si_signo: ::c_int,
51             _si_errno: ::c_int,
52             _si_code: ::c_int,
53             _si_timerid: ::c_int,
54             _si_overrun: ::c_int,
55             si_value: ::sigval,
56         }
57         (*(self as *const siginfo_t as *const siginfo_si_value)).si_value
58     }
59 }
60 
61 cfg_if! {
62     if #[cfg(libc_union)] {
63         // Internal, for casts to access union fields
64         #[repr(C)]
65         struct sifields_sigchld {
66             si_pid: ::pid_t,
67             si_uid: ::uid_t,
68             si_status: ::c_int,
69             si_utime: ::c_long,
70             si_stime: ::c_long,
71         }
72         impl ::Copy for sifields_sigchld {}
73         impl ::Clone for sifields_sigchld {
74             fn clone(&self) -> sifields_sigchld {
75                 *self
76             }
77         }
78 
79         // Internal, for casts to access union fields
80         #[repr(C)]
81         union sifields {
82             _align_pointer: *mut ::c_void,
83             sigchld: sifields_sigchld,
84         }
85 
86         // Internal, for casts to access union fields. Note that some variants
87         // of sifields start with a pointer, which makes the alignment of
88         // sifields vary on 32-bit and 64-bit architectures.
89         #[repr(C)]
90         struct siginfo_f {
91             _siginfo_base: [::c_int; 3],
92             sifields: sifields,
93         }
94 
95         impl siginfo_t {
96             unsafe fn sifields(&self) -> &sifields {
97                 &(*(self as *const siginfo_t as *const siginfo_f)).sifields
98             }
99 
100             pub unsafe fn si_pid(&self) -> ::pid_t {
101                 self.sifields().sigchld.si_pid
102             }
103 
104             pub unsafe fn si_uid(&self) -> ::uid_t {
105                 self.sifields().sigchld.si_uid
106             }
107 
108             pub unsafe fn si_status(&self) -> ::c_int {
109                 self.sifields().sigchld.si_status
110             }
111 
112             pub unsafe fn si_utime(&self) -> ::c_long {
113                 self.sifields().sigchld.si_utime
114             }
115 
116             pub unsafe fn si_stime(&self) -> ::c_long {
117                 self.sifields().sigchld.si_stime
118             }
119         }
120     }
121 }
122 
123 s! {
124     pub struct aiocb {
125         pub aio_fildes: ::c_int,
126         pub aio_lio_opcode: ::c_int,
127         pub aio_reqprio: ::c_int,
128         pub aio_buf: *mut ::c_void,
129         pub aio_nbytes: ::size_t,
130         pub aio_sigevent: ::sigevent,
131         __td: *mut ::c_void,
132         __lock: [::c_int; 2],
133         __err: ::c_int,
134         __ret: ::ssize_t,
135         pub aio_offset: off_t,
136         __next: *mut ::c_void,
137         __prev: *mut ::c_void,
138         #[cfg(target_pointer_width = "32")]
139         __dummy4: [::c_char; 24],
140         #[cfg(target_pointer_width = "64")]
141         __dummy4: [::c_char; 16],
142     }
143 
144     pub struct sigaction {
145         pub sa_sigaction: ::sighandler_t,
146         pub sa_mask: ::sigset_t,
147         pub sa_flags: ::c_int,
148         pub sa_restorer: ::Option<extern fn()>,
149     }
150 
151     pub struct statvfs {
152         pub f_bsize: ::c_ulong,
153         pub f_frsize: ::c_ulong,
154         pub f_blocks: ::fsblkcnt_t,
155         pub f_bfree: ::fsblkcnt_t,
156         pub f_bavail: ::fsblkcnt_t,
157         pub f_files: ::fsfilcnt_t,
158         pub f_ffree: ::fsfilcnt_t,
159         pub f_favail: ::fsfilcnt_t,
160         #[cfg(target_endian = "little")]
161         pub f_fsid: ::c_ulong,
162         #[cfg(target_pointer_width = "32")]
163         __f_unused: ::c_int,
164         #[cfg(target_endian = "big")]
165         pub f_fsid: ::c_ulong,
166         pub f_flag: ::c_ulong,
167         pub f_namemax: ::c_ulong,
168         __f_spare: [::c_int; 6],
169     }
170 
171     pub struct termios {
172         pub c_iflag: ::tcflag_t,
173         pub c_oflag: ::tcflag_t,
174         pub c_cflag: ::tcflag_t,
175         pub c_lflag: ::tcflag_t,
176         pub c_line: ::cc_t,
177         pub c_cc: [::cc_t; ::NCCS],
178         pub __c_ispeed: ::speed_t,
179         pub __c_ospeed: ::speed_t,
180     }
181 
182     pub struct flock {
183         pub l_type: ::c_short,
184         pub l_whence: ::c_short,
185         pub l_start: ::off_t,
186         pub l_len: ::off_t,
187         pub l_pid: ::pid_t,
188     }
189 
190     pub struct flock64 {
191         pub l_type: ::c_short,
192         pub l_whence: ::c_short,
193         pub l_start: ::off64_t,
194         pub l_len: ::off64_t,
195         pub l_pid: ::pid_t,
196     }
197 
198     pub struct regex_t {
199         __re_nsub: ::size_t,
200         __opaque: *mut ::c_void,
201         __padding: [*mut ::c_void; 4usize],
202         __nsub2: ::size_t,
203         __padding2: ::c_char,
204     }
205 
206     pub struct rtentry {
207         pub rt_pad1: ::c_ulong,
208         pub rt_dst: ::sockaddr,
209         pub rt_gateway: ::sockaddr,
210         pub rt_genmask: ::sockaddr,
211         pub rt_flags: ::c_ushort,
212         pub rt_pad2: ::c_short,
213         pub rt_pad3: ::c_ulong,
214         pub rt_tos: ::c_uchar,
215         pub rt_class: ::c_uchar,
216         #[cfg(target_pointer_width = "64")]
217         pub rt_pad4: [::c_short; 3usize],
218         #[cfg(not(target_pointer_width = "64"))]
219         pub rt_pad4: [::c_short; 1usize],
220         pub rt_metric: ::c_short,
221         pub rt_dev: *mut ::c_char,
222         pub rt_mtu: ::c_ulong,
223         pub rt_window: ::c_ulong,
224         pub rt_irtt: ::c_ushort,
225     }
226 
227     pub struct __exit_status {
228         pub e_termination: ::c_short,
229         pub e_exit: ::c_short,
230     }
231 
232     pub struct Elf64_Chdr {
233         pub ch_type: ::Elf64_Word,
234         pub ch_reserved: ::Elf64_Word,
235         pub ch_size: ::Elf64_Xword,
236         pub ch_addralign: ::Elf64_Xword,
237     }
238 
239     pub struct Elf32_Chdr {
240         pub ch_type: ::Elf32_Word,
241         pub ch_size: ::Elf32_Word,
242         pub ch_addralign: ::Elf32_Word,
243     }
244 
245     pub struct timex {
246         pub modes: ::c_uint,
247         pub offset: ::c_long,
248         pub freq: ::c_long,
249         pub maxerror: ::c_long,
250         pub esterror: ::c_long,
251         pub status: ::c_int,
252         pub constant: ::c_long,
253         pub precision: ::c_long,
254         pub tolerance: ::c_long,
255         pub time: ::timeval,
256         pub tick: ::c_long,
257         pub ppsfreq: ::c_long,
258         pub jitter: ::c_long,
259         pub shift: ::c_int,
260         pub stabil: ::c_long,
261         pub jitcnt: ::c_long,
262         pub calcnt: ::c_long,
263         pub errcnt: ::c_long,
264         pub stbcnt: ::c_long,
265         pub tai: ::c_int,
266         pub __padding: [::c_int; 11],
267     }
268 
269     pub struct ntptimeval {
270         pub time: ::timeval,
271         pub maxerror: ::c_long,
272         pub esterror: ::c_long,
273     }
274 
275     // linux/if_xdp.h
276 
277     pub struct sockaddr_xdp {
278         pub sxdp_family: ::__u16,
279         pub sxdp_flags: ::__u16,
280         pub sxdp_ifindex: ::__u32,
281         pub sxdp_queue_id: ::__u32,
282         pub sxdp_shared_umem_fd: ::__u32,
283     }
284 
285     pub struct xdp_ring_offset {
286         pub producer: ::__u64,
287         pub consumer: ::__u64,
288         pub desc: ::__u64,
289         pub flags: ::__u64,
290     }
291 
292     pub struct xdp_mmap_offsets {
293         pub rx: xdp_ring_offset,
294         pub tx: xdp_ring_offset,
295         pub fr: xdp_ring_offset,
296         pub cr: xdp_ring_offset,
297     }
298 
299     pub struct xdp_ring_offset_v1 {
300         pub producer: ::__u64,
301         pub consumer: ::__u64,
302         pub desc: ::__u64,
303     }
304 
305     pub struct xdp_mmap_offsets_v1 {
306         pub rx: xdp_ring_offset_v1,
307         pub tx: xdp_ring_offset_v1,
308         pub fr: xdp_ring_offset_v1,
309         pub cr: xdp_ring_offset_v1,
310     }
311 
312     pub struct xdp_umem_reg {
313         pub addr: ::__u64,
314         pub len: ::__u64,
315         pub chunk_size: ::__u32,
316         pub headroom: ::__u32,
317         pub flags: ::__u32,
318     }
319 
320     pub struct xdp_umem_reg_v1 {
321         pub addr: ::__u64,
322         pub len: ::__u64,
323         pub chunk_size: ::__u32,
324         pub headroom: ::__u32,
325     }
326 
327     pub struct xdp_statistics {
328         pub rx_dropped: ::__u64,
329         pub rx_invalid_descs: ::__u64,
330         pub tx_invalid_descs: ::__u64,
331         pub rx_ring_full: ::__u64,
332         pub rx_fill_ring_empty_descs: ::__u64,
333         pub tx_ring_empty_descs: ::__u64,
334     }
335 
336     pub struct xdp_statistics_v1 {
337         pub rx_dropped: ::__u64,
338         pub rx_invalid_descs: ::__u64,
339         pub tx_invalid_descs: ::__u64,
340     }
341 
342     pub struct xdp_options {
343         pub flags: ::__u32,
344     }
345 
346     pub struct xdp_desc {
347         pub addr: ::__u64,
348         pub len: ::__u32,
349         pub options: ::__u32,
350     }
351 
352     // netinet/tcp.h
353 
354     pub struct tcp_info {
355         pub tcpi_state: u8,
356         pub tcpi_ca_state: u8,
357         pub tcpi_retransmits: u8,
358         pub tcpi_probes: u8,
359         pub tcpi_backoff: u8,
360         pub tcpi_options: u8,
361         /*
362          * FIXME(musl): when musl headers are more up to date
363         /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
364         /// Each is 4 bits.
365         pub tcpi_snd_rcv_wscale: u8,
366         /// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and
367         /// `tcpi_fastopen_client_fail` (2 bits).
368         pub tcpi_delivery_fastopen_bitfields: u8,
369         */
370         pub tcpi_rto: u32,
371         pub tcpi_ato: u32,
372         pub tcpi_snd_mss: u32,
373         pub tcpi_rcv_mss: u32,
374         pub tcpi_unacked: u32,
375         pub tcpi_sacked: u32,
376         pub tcpi_lost: u32,
377         pub tcpi_retrans: u32,
378         pub tcpi_fackets: u32,
379         pub tcpi_last_data_sent: u32,
380         pub tcpi_last_ack_sent: u32,
381         pub tcpi_last_data_recv: u32,
382         pub tcpi_last_ack_recv: u32,
383         pub tcpi_pmtu: u32,
384         pub tcpi_rcv_ssthresh: u32,
385         pub tcpi_rtt: u32,
386         pub tcpi_rttvar: u32,
387         pub tcpi_snd_ssthresh: u32,
388         pub tcpi_snd_cwnd: u32,
389         pub tcpi_advmss: u32,
390         pub tcpi_reordering: u32,
391         pub tcpi_rcv_rtt: u32,
392         pub tcpi_rcv_space: u32,
393         pub tcpi_total_retrans: u32,
394         pub tcpi_pacing_rate: u64,
395         pub tcpi_max_pacing_rate: u64,
396         pub tcpi_bytes_acked: u64,
397         pub tcpi_bytes_received: u64,
398         pub tcpi_segs_out: u32,
399         pub tcpi_segs_in: u32,
400         pub tcpi_notsent_bytes: u32,
401         pub tcpi_min_rtt: u32,
402         pub tcpi_data_segs_in: u32,
403         pub tcpi_data_segs_out: u32,
404         pub tcpi_delivery_rate: u64,
405         pub tcpi_busy_time: u64,
406         pub tcpi_rwnd_limited: u64,
407         pub tcpi_sndbuf_limited: u64,
408         pub tcpi_delivered: u32,
409         pub tcpi_delivered_ce: u32,
410         pub tcpi_bytes_sent: u64,
411         pub tcpi_bytes_retrans: u64,
412         pub tcpi_dsack_dups: u32,
413         pub tcpi_reord_seen: u32,
414         // FIXME(musl): to uncomment once CI musl is updated
415         //pub tcpi_rcv_ooopack: u32,
416         //pub tcpi_snd_wnd: u32,
417     }
418 }
419 
420 s_no_extra_traits! {
421     pub struct sysinfo {
422         pub uptime: ::c_ulong,
423         pub loads: [::c_ulong; 3],
424         pub totalram: ::c_ulong,
425         pub freeram: ::c_ulong,
426         pub sharedram: ::c_ulong,
427         pub bufferram: ::c_ulong,
428         pub totalswap: ::c_ulong,
429         pub freeswap: ::c_ulong,
430         pub procs: ::c_ushort,
431         pub pad: ::c_ushort,
432         pub totalhigh: ::c_ulong,
433         pub freehigh: ::c_ulong,
434         pub mem_unit: ::c_uint,
435         pub __reserved: [::c_char; 256],
436     }
437 
438     // FIXME: musl added paddings and adjusted
439     // layout in 1.2.0 but our CI is still 1.1.24.
440     // So, I'm leaving some fields as cfg for now.
441     // ref. https://github.com/bminor/musl/commit/
442     // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392
443     //
444     // OpenHarmony uses the musl 1.2 layout.
445     pub struct utmpx {
446         pub ut_type: ::c_short,
447         __ut_pad1: ::c_short,
448         pub ut_pid: ::pid_t,
449         pub ut_line: [::c_char; 32],
450         pub ut_id: [::c_char; 4],
451         pub ut_user: [::c_char; 32],
452         pub ut_host: [::c_char; 256],
453         pub ut_exit: __exit_status,
454 
455         #[cfg(target_env = "musl")]
456         pub ut_session: ::c_long,
457 
458         #[cfg(target_env = "ohos")]
459         #[cfg(target_endian = "little")]
460         pub ut_session: ::c_int,
461         #[cfg(target_env = "ohos")]
462         #[cfg(target_endian = "little")]
463         __ut_pad2: ::c_int,
464 
465         #[cfg(target_env = "ohos")]
466         #[cfg(not(target_endian = "little"))]
467         __ut_pad2: ::c_int,
468         #[cfg(target_env = "ohos")]
469         #[cfg(not(target_endian = "little"))]
470         pub ut_session: ::c_int,
471 
472         pub ut_tv: ::timeval,
473         pub ut_addr_v6: [::c_uint; 4],
474         __unused: [::c_char; 20],
475     }
476 }
477 
478 cfg_if! {
479     if #[cfg(feature = "extra_traits")] {
480         impl PartialEq for sysinfo {
481             fn eq(&self, other: &sysinfo) -> bool {
482                 self.uptime == other.uptime
483                     && self.loads == other.loads
484                     && self.totalram == other.totalram
485                     && self.freeram == other.freeram
486                     && self.sharedram == other.sharedram
487                     && self.bufferram == other.bufferram
488                     && self.totalswap == other.totalswap
489                     && self.freeswap == other.freeswap
490                     && self.procs == other.procs
491                     && self.pad == other.pad
492                     && self.totalhigh == other.totalhigh
493                     && self.freehigh == other.freehigh
494                     && self.mem_unit == other.mem_unit
495                     && self
496                         .__reserved
497                         .iter()
498                         .zip(other.__reserved.iter())
499                         .all(|(a,b)| a == b)
500             }
501         }
502 
503         impl Eq for sysinfo {}
504 
505         impl ::fmt::Debug for sysinfo {
506             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
507                 f.debug_struct("sysinfo")
508                     .field("uptime", &self.uptime)
509                     .field("loads", &self.loads)
510                     .field("totalram", &self.totalram)
511                     .field("freeram", &self.freeram)
512                     .field("sharedram", &self.sharedram)
513                     .field("bufferram", &self.bufferram)
514                     .field("totalswap", &self.totalswap)
515                     .field("freeswap", &self.freeswap)
516                     .field("procs", &self.procs)
517                     .field("pad", &self.pad)
518                     .field("totalhigh", &self.totalhigh)
519                     .field("freehigh", &self.freehigh)
520                     .field("mem_unit", &self.mem_unit)
521                     // FIXME: .field("__reserved", &self.__reserved)
522                     .finish()
523             }
524         }
525 
526         impl ::hash::Hash for sysinfo {
527             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
528                 self.uptime.hash(state);
529                 self.loads.hash(state);
530                 self.totalram.hash(state);
531                 self.freeram.hash(state);
532                 self.sharedram.hash(state);
533                 self.bufferram.hash(state);
534                 self.totalswap.hash(state);
535                 self.freeswap.hash(state);
536                 self.procs.hash(state);
537                 self.pad.hash(state);
538                 self.totalhigh.hash(state);
539                 self.freehigh.hash(state);
540                 self.mem_unit.hash(state);
541                 self.__reserved.hash(state);
542             }
543         }
544 
545         impl PartialEq for utmpx {
546             fn eq(&self, other: &utmpx) -> bool {
547                 self.ut_type == other.ut_type
548                     //&& self.__ut_pad1 == other.__ut_pad1
549                     && self.ut_pid == other.ut_pid
550                     && self.ut_line == other.ut_line
551                     && self.ut_id == other.ut_id
552                     && self.ut_user == other.ut_user
553                     && self
554                         .ut_host
555                         .iter()
556                         .zip(other.ut_host.iter())
557                         .all(|(a,b)| a == b)
558                     && self.ut_exit == other.ut_exit
559                     && self.ut_session == other.ut_session
560                     //&& self.__ut_pad2 == other.__ut_pad2
561                     && self.ut_tv == other.ut_tv
562                     && self.ut_addr_v6 == other.ut_addr_v6
563                     && self.__unused == other.__unused
564             }
565         }
566 
567         impl Eq for utmpx {}
568 
569         impl ::fmt::Debug for utmpx {
570             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
571                 f.debug_struct("utmpx")
572                     .field("ut_type", &self.ut_type)
573                     //.field("__ut_pad1", &self.__ut_pad1)
574                     .field("ut_pid", &self.ut_pid)
575                     .field("ut_line", &self.ut_line)
576                     .field("ut_id", &self.ut_id)
577                     .field("ut_user", &self.ut_user)
578                     //FIXME: .field("ut_host", &self.ut_host)
579                     .field("ut_exit", &self.ut_exit)
580                     .field("ut_session", &self.ut_session)
581                     //.field("__ut_pad2", &self.__ut_pad2)
582                     .field("ut_tv", &self.ut_tv)
583                     .field("ut_addr_v6", &self.ut_addr_v6)
584                     .field("__unused", &self.__unused)
585                     .finish()
586             }
587         }
588 
589         impl ::hash::Hash for utmpx {
590             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
591                 self.ut_type.hash(state);
592                 //self.__ut_pad1.hash(state);
593                 self.ut_pid.hash(state);
594                 self.ut_line.hash(state);
595                 self.ut_id.hash(state);
596                 self.ut_user.hash(state);
597                 self.ut_host.hash(state);
598                 self.ut_exit.hash(state);
599                 self.ut_session.hash(state);
600                 //self.__ut_pad2.hash(state);
601                 self.ut_tv.hash(state);
602                 self.ut_addr_v6.hash(state);
603                 self.__unused.hash(state);
604             }
605         }
606     }
607 }
608 
609 // include/sys/mman.h
610 /*
611  * Huge page size encoding when MAP_HUGETLB is specified, and a huge page
612  * size other than the default is desired.  See hugetlb_encode.h.
613  * All known huge page size encodings are provided here.  It is the
614  * responsibility of the application to know which sizes are supported on
615  * the running system.  See mmap(2) man page for details.
616  */
617 pub const MAP_HUGE_SHIFT: ::c_int = 26;
618 pub const MAP_HUGE_MASK: ::c_int = 0x3f;
619 
620 pub const MAP_HUGE_64KB: ::c_int = 16 << MAP_HUGE_SHIFT;
621 pub const MAP_HUGE_512KB: ::c_int = 19 << MAP_HUGE_SHIFT;
622 pub const MAP_HUGE_1MB: ::c_int = 20 << MAP_HUGE_SHIFT;
623 pub const MAP_HUGE_2MB: ::c_int = 21 << MAP_HUGE_SHIFT;
624 pub const MAP_HUGE_8MB: ::c_int = 23 << MAP_HUGE_SHIFT;
625 pub const MAP_HUGE_16MB: ::c_int = 24 << MAP_HUGE_SHIFT;
626 pub const MAP_HUGE_32MB: ::c_int = 25 << MAP_HUGE_SHIFT;
627 pub const MAP_HUGE_256MB: ::c_int = 28 << MAP_HUGE_SHIFT;
628 pub const MAP_HUGE_512MB: ::c_int = 29 << MAP_HUGE_SHIFT;
629 pub const MAP_HUGE_1GB: ::c_int = 30 << MAP_HUGE_SHIFT;
630 pub const MAP_HUGE_2GB: ::c_int = 31 << MAP_HUGE_SHIFT;
631 pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT;
632 
633 pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
634 
635 // include/utmpx.h
636 pub const EMPTY: ::c_short = 0;
637 pub const RUN_LVL: ::c_short = 1;
638 pub const BOOT_TIME: ::c_short = 2;
639 pub const NEW_TIME: ::c_short = 3;
640 pub const OLD_TIME: ::c_short = 4;
641 pub const INIT_PROCESS: ::c_short = 5;
642 pub const LOGIN_PROCESS: ::c_short = 6;
643 pub const USER_PROCESS: ::c_short = 7;
644 pub const DEAD_PROCESS: ::c_short = 8;
645 // musl does not define ACCOUNTING
646 
647 pub const SFD_CLOEXEC: ::c_int = 0x080000;
648 
649 pub const NCCS: usize = 32;
650 
651 pub const O_TRUNC: ::c_int = 512;
652 pub const O_NOATIME: ::c_int = 0o1000000;
653 pub const O_CLOEXEC: ::c_int = 0x80000;
654 pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
655 
656 pub const EBFONT: ::c_int = 59;
657 pub const ENOSTR: ::c_int = 60;
658 pub const ENODATA: ::c_int = 61;
659 pub const ETIME: ::c_int = 62;
660 pub const ENOSR: ::c_int = 63;
661 pub const ENONET: ::c_int = 64;
662 pub const ENOPKG: ::c_int = 65;
663 pub const EREMOTE: ::c_int = 66;
664 pub const ENOLINK: ::c_int = 67;
665 pub const EADV: ::c_int = 68;
666 pub const ESRMNT: ::c_int = 69;
667 pub const ECOMM: ::c_int = 70;
668 pub const EPROTO: ::c_int = 71;
669 pub const EDOTDOT: ::c_int = 73;
670 
671 pub const F_OFD_GETLK: ::c_int = 36;
672 pub const F_OFD_SETLK: ::c_int = 37;
673 pub const F_OFD_SETLKW: ::c_int = 38;
674 
675 pub const F_RDLCK: ::c_int = 0;
676 pub const F_WRLCK: ::c_int = 1;
677 pub const F_UNLCK: ::c_int = 2;
678 
679 pub const SA_NODEFER: ::c_int = 0x40000000;
680 pub const SA_RESETHAND: ::c_int = 0x80000000;
681 pub const SA_RESTART: ::c_int = 0x10000000;
682 pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
683 
684 pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
685 
686 pub const EFD_CLOEXEC: ::c_int = 0x80000;
687 
688 pub const BUFSIZ: ::c_uint = 1024;
689 pub const TMP_MAX: ::c_uint = 10000;
690 pub const FOPEN_MAX: ::c_uint = 1000;
691 pub const FILENAME_MAX: ::c_uint = 4096;
692 pub const O_PATH: ::c_int = 0o10000000;
693 pub const O_EXEC: ::c_int = 0o10000000;
694 pub const O_SEARCH: ::c_int = 0o10000000;
695 pub const O_ACCMODE: ::c_int = 0o10000003;
696 pub const O_NDELAY: ::c_int = O_NONBLOCK;
697 pub const NI_MAXHOST: ::socklen_t = 255;
698 pub const PTHREAD_STACK_MIN: ::size_t = 2048;
699 
700 pub const POSIX_MADV_DONTNEED: ::c_int = 4;
701 
702 pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
703 
704 pub const SOCK_SEQPACKET: ::c_int = 5;
705 pub const SOCK_DCCP: ::c_int = 6;
706 pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK;
707 pub const SOCK_PACKET: ::c_int = 10;
708 
709 pub const SOMAXCONN: ::c_int = 128;
710 
711 #[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
712 pub const SIGUNUSED: ::c_int = ::SIGSYS;
713 
714 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
715 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
716 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
717 pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
718 
719 pub const CPU_SETSIZE: ::c_int = 128;
720 
721 pub const PTRACE_TRACEME: ::c_int = 0;
722 pub const PTRACE_PEEKTEXT: ::c_int = 1;
723 pub const PTRACE_PEEKDATA: ::c_int = 2;
724 pub const PTRACE_PEEKUSER: ::c_int = 3;
725 pub const PTRACE_POKETEXT: ::c_int = 4;
726 pub const PTRACE_POKEDATA: ::c_int = 5;
727 pub const PTRACE_POKEUSER: ::c_int = 6;
728 pub const PTRACE_CONT: ::c_int = 7;
729 pub const PTRACE_KILL: ::c_int = 8;
730 pub const PTRACE_SINGLESTEP: ::c_int = 9;
731 pub const PTRACE_GETREGS: ::c_int = 12;
732 pub const PTRACE_SETREGS: ::c_int = 13;
733 pub const PTRACE_GETFPREGS: ::c_int = 14;
734 pub const PTRACE_SETFPREGS: ::c_int = 15;
735 pub const PTRACE_ATTACH: ::c_int = 16;
736 pub const PTRACE_DETACH: ::c_int = 17;
737 pub const PTRACE_GETFPXREGS: ::c_int = 18;
738 pub const PTRACE_SETFPXREGS: ::c_int = 19;
739 pub const PTRACE_SYSCALL: ::c_int = 24;
740 pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
741 pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
742 pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
743 pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
744 pub const PTRACE_GETREGSET: ::c_int = 0x4204;
745 pub const PTRACE_SETREGSET: ::c_int = 0x4205;
746 pub const PTRACE_SEIZE: ::c_int = 0x4206;
747 pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
748 pub const PTRACE_LISTEN: ::c_int = 0x4208;
749 pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
750 pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a;
751 pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b;
752 
753 pub const RWF_HIPRI: ::c_int = 0x00000001;
754 pub const RWF_DSYNC: ::c_int = 0x00000002;
755 pub const RWF_SYNC: ::c_int = 0x00000004;
756 pub const RWF_NOWAIT: ::c_int = 0x00000008;
757 pub const RWF_APPEND: ::c_int = 0x00000010;
758 
759 pub const AF_IB: ::c_int = 27;
760 pub const AF_MPLS: ::c_int = 28;
761 pub const AF_NFC: ::c_int = 39;
762 pub const AF_VSOCK: ::c_int = 40;
763 pub const AF_XDP: ::c_int = 44;
764 pub const PF_IB: ::c_int = AF_IB;
765 pub const PF_MPLS: ::c_int = AF_MPLS;
766 pub const PF_NFC: ::c_int = AF_NFC;
767 pub const PF_VSOCK: ::c_int = AF_VSOCK;
768 pub const PF_XDP: ::c_int = AF_XDP;
769 
770 pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
771 
772 pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
773 
774 pub const PIDFD_NONBLOCK: ::c_uint = O_NONBLOCK as ::c_uint;
775 
776 pub const TCSANOW: ::c_int = 0;
777 pub const TCSADRAIN: ::c_int = 1;
778 pub const TCSAFLUSH: ::c_int = 2;
779 
780 pub const RTLD_GLOBAL: ::c_int = 0x100;
781 pub const RTLD_NOLOAD: ::c_int = 0x4;
782 
783 pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
784 
785 pub const B0: ::speed_t = 0o000000;
786 pub const B50: ::speed_t = 0o000001;
787 pub const B75: ::speed_t = 0o000002;
788 pub const B110: ::speed_t = 0o000003;
789 pub const B134: ::speed_t = 0o000004;
790 pub const B150: ::speed_t = 0o000005;
791 pub const B200: ::speed_t = 0o000006;
792 pub const B300: ::speed_t = 0o000007;
793 pub const B600: ::speed_t = 0o000010;
794 pub const B1200: ::speed_t = 0o000011;
795 pub const B1800: ::speed_t = 0o000012;
796 pub const B2400: ::speed_t = 0o000013;
797 pub const B4800: ::speed_t = 0o000014;
798 pub const B9600: ::speed_t = 0o000015;
799 pub const B19200: ::speed_t = 0o000016;
800 pub const B38400: ::speed_t = 0o000017;
801 pub const EXTA: ::speed_t = B19200;
802 pub const EXTB: ::speed_t = B38400;
803 
804 pub const REG_OK: ::c_int = 0;
805 
806 pub const PRIO_PROCESS: ::c_int = 0;
807 pub const PRIO_PGRP: ::c_int = 1;
808 pub const PRIO_USER: ::c_int = 2;
809 
810 pub const ADJ_OFFSET: ::c_uint = 0x0001;
811 pub const ADJ_FREQUENCY: ::c_uint = 0x0002;
812 pub const ADJ_MAXERROR: ::c_uint = 0x0004;
813 pub const ADJ_ESTERROR: ::c_uint = 0x0008;
814 pub const ADJ_STATUS: ::c_uint = 0x0010;
815 pub const ADJ_TIMECONST: ::c_uint = 0x0020;
816 pub const ADJ_TAI: ::c_uint = 0x0080;
817 pub const ADJ_SETOFFSET: ::c_uint = 0x0100;
818 pub const ADJ_MICRO: ::c_uint = 0x1000;
819 pub const ADJ_NANO: ::c_uint = 0x2000;
820 pub const ADJ_TICK: ::c_uint = 0x4000;
821 pub const ADJ_OFFSET_SINGLESHOT: ::c_uint = 0x8001;
822 pub const ADJ_OFFSET_SS_READ: ::c_uint = 0xa001;
823 pub const MOD_OFFSET: ::c_uint = ADJ_OFFSET;
824 pub const MOD_FREQUENCY: ::c_uint = ADJ_FREQUENCY;
825 pub const MOD_MAXERROR: ::c_uint = ADJ_MAXERROR;
826 pub const MOD_ESTERROR: ::c_uint = ADJ_ESTERROR;
827 pub const MOD_STATUS: ::c_uint = ADJ_STATUS;
828 pub const MOD_TIMECONST: ::c_uint = ADJ_TIMECONST;
829 pub const MOD_CLKB: ::c_uint = ADJ_TICK;
830 pub const MOD_CLKA: ::c_uint = ADJ_OFFSET_SINGLESHOT;
831 pub const MOD_TAI: ::c_uint = ADJ_TAI;
832 pub const MOD_MICRO: ::c_uint = ADJ_MICRO;
833 pub const MOD_NANO: ::c_uint = ADJ_NANO;
834 pub const STA_PLL: ::c_int = 0x0001;
835 pub const STA_PPSFREQ: ::c_int = 0x0002;
836 pub const STA_PPSTIME: ::c_int = 0x0004;
837 pub const STA_FLL: ::c_int = 0x0008;
838 pub const STA_INS: ::c_int = 0x0010;
839 pub const STA_DEL: ::c_int = 0x0020;
840 pub const STA_UNSYNC: ::c_int = 0x0040;
841 pub const STA_FREQHOLD: ::c_int = 0x0080;
842 pub const STA_PPSSIGNAL: ::c_int = 0x0100;
843 pub const STA_PPSJITTER: ::c_int = 0x0200;
844 pub const STA_PPSWANDER: ::c_int = 0x0400;
845 pub const STA_PPSERROR: ::c_int = 0x0800;
846 pub const STA_CLOCKERR: ::c_int = 0x1000;
847 pub const STA_NANO: ::c_int = 0x2000;
848 pub const STA_MODE: ::c_int = 0x4000;
849 pub const STA_CLK: ::c_int = 0x8000;
850 pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
851     | STA_PPSJITTER
852     | STA_PPSWANDER
853     | STA_PPSERROR
854     | STA_CLOCKERR
855     | STA_NANO
856     | STA_MODE
857     | STA_CLK;
858 
859 pub const TIME_OK: ::c_int = 0;
860 pub const TIME_INS: ::c_int = 1;
861 pub const TIME_DEL: ::c_int = 2;
862 pub const TIME_OOP: ::c_int = 3;
863 pub const TIME_WAIT: ::c_int = 4;
864 pub const TIME_ERROR: ::c_int = 5;
865 pub const TIME_BAD: ::c_int = TIME_ERROR;
866 pub const MAXTC: ::c_long = 6;
867 
868 pub const SOL_XDP: ::c_int = 283;
869 
870 // linux/if_xdp.h
871 pub const XDP_SHARED_UMEM: ::__u16 = 1 << 0;
872 pub const XDP_COPY: ::__u16 = 1 << 1;
873 pub const XDP_ZEROCOPY: ::__u16 = 1 << 2;
874 pub const XDP_USE_NEED_WAKEUP: ::__u16 = 1 << 3;
875 pub const XDP_USE_SG: ::__u16 = 1 << 4;
876 
877 pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: ::__u32 = 1 << 0;
878 
879 pub const XDP_RING_NEED_WAKEUP: ::__u32 = 1 << 0;
880 
881 pub const XDP_MMAP_OFFSETS: ::c_int = 1;
882 pub const XDP_RX_RING: ::c_int = 2;
883 pub const XDP_TX_RING: ::c_int = 3;
884 pub const XDP_UMEM_REG: ::c_int = 4;
885 pub const XDP_UMEM_FILL_RING: ::c_int = 5;
886 pub const XDP_UMEM_COMPLETION_RING: ::c_int = 6;
887 pub const XDP_STATISTICS: ::c_int = 7;
888 pub const XDP_OPTIONS: ::c_int = 8;
889 
890 pub const XDP_OPTIONS_ZEROCOPY: ::__u32 = 1 << 0;
891 
892 pub const XDP_PGOFF_RX_RING: ::off_t = 0;
893 pub const XDP_PGOFF_TX_RING: ::off_t = 0x80000000;
894 pub const XDP_UMEM_PGOFF_FILL_RING: ::c_ulonglong = 0x100000000;
895 pub const XDP_UMEM_PGOFF_COMPLETION_RING: ::c_ulonglong = 0x180000000;
896 
897 pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: ::c_int = 48;
898 pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
899 
900 pub const XDP_PKT_CONTD: ::__u32 = 1 << 0;
901 
902 cfg_if! {
903     if #[cfg(target_arch = "s390x")] {
904         pub const POSIX_FADV_DONTNEED: ::c_int = 6;
905         pub const POSIX_FADV_NOREUSE: ::c_int = 7;
906     } else {
907         pub const POSIX_FADV_DONTNEED: ::c_int = 4;
908         pub const POSIX_FADV_NOREUSE: ::c_int = 5;
909     }
910 }
911 
912 extern "C" {
913     pub fn sendmmsg(
914         sockfd: ::c_int,
915         msgvec: *mut ::mmsghdr,
916         vlen: ::c_uint,
917         flags: ::c_uint,
918     ) -> ::c_int;
919     pub fn recvmmsg(
920         sockfd: ::c_int,
921         msgvec: *mut ::mmsghdr,
922         vlen: ::c_uint,
923         flags: ::c_uint,
924         timeout: *mut ::timespec,
925     ) -> ::c_int;
926 
927     pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
928     pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
929     pub fn prlimit(
930         pid: ::pid_t,
931         resource: ::c_int,
932         new_limit: *const ::rlimit,
933         old_limit: *mut ::rlimit,
934     ) -> ::c_int;
935     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
936     pub fn ptrace(request: ::c_int, ...) -> ::c_long;
937     pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
938     pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
939     // Musl targets need the `mask` argument of `fanotify_mark` be specified
940     // `::c_ulonglong` instead of `u64` or there will be a type mismatch between
941     // `long long unsigned int` and the expected `uint64_t`.
942     pub fn fanotify_mark(
943         fd: ::c_int,
944         flags: ::c_uint,
945         mask: ::c_ulonglong,
946         dirfd: ::c_int,
947         path: *const ::c_char,
948     ) -> ::c_int;
949     pub fn preadv2(
950         fd: ::c_int,
951         iov: *const ::iovec,
952         iovcnt: ::c_int,
953         offset: ::off_t,
954         flags: ::c_int,
955     ) -> ::ssize_t;
956     pub fn pwritev2(
957         fd: ::c_int,
958         iov: *const ::iovec,
959         iovcnt: ::c_int,
960         offset: ::off_t,
961         flags: ::c_int,
962     ) -> ::ssize_t;
963     pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
964 
965     // Added in `musl` 1.1.20
966     pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t);
967     // Added in `musl` 1.2.2
968     pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
969 
970     pub fn adjtimex(buf: *mut ::timex) -> ::c_int;
971     pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
972 
973     pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
974 
975     pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
976     pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int;
977     pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t;
978 
979     pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
980     pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
981 
982     pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
983 
984     pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
985     pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
986 
987     // Added in `musl` 1.1.24
988     pub fn posix_spawn_file_actions_addchdir_np(
989         actions: *mut ::posix_spawn_file_actions_t,
990         path: *const ::c_char,
991     ) -> ::c_int;
992     // Added in `musl` 1.1.24
993     pub fn posix_spawn_file_actions_addfchdir_np(
994         actions: *mut ::posix_spawn_file_actions_t,
995         fd: ::c_int,
996     ) -> ::c_int;
997 }
998 
999 // Alias <foo> to <foo>64 to mimic glibc's LFS64 support
1000 mod lfs64;
1001 pub use self::lfs64::*;
1002 
1003 cfg_if! {
1004     if #[cfg(any(target_arch = "x86_64",
1005                  target_arch = "aarch64",
1006                  target_arch = "mips64",
1007                  target_arch = "powerpc64",
1008                  target_arch = "s390x",
1009                  target_arch = "riscv64",
1010                  target_arch = "loongarch64"))] {
1011         mod b64;
1012         pub use self::b64::*;
1013     } else if #[cfg(any(target_arch = "x86",
1014                         target_arch = "mips",
1015                         target_arch = "powerpc",
1016                         target_arch = "hexagon",
1017                         target_arch = "riscv32",
1018                         target_arch = "arm"))] {
1019         mod b32;
1020         pub use self::b32::*;
1021     } else { }
1022 }
1023