• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
si_addr(&self) -> *mut ::c_void36     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 
si_value(&self) -> ::sigval47     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 
353 s_no_extra_traits! {
354     pub struct sysinfo {
355         pub uptime: ::c_ulong,
356         pub loads: [::c_ulong; 3],
357         pub totalram: ::c_ulong,
358         pub freeram: ::c_ulong,
359         pub sharedram: ::c_ulong,
360         pub bufferram: ::c_ulong,
361         pub totalswap: ::c_ulong,
362         pub freeswap: ::c_ulong,
363         pub procs: ::c_ushort,
364         pub pad: ::c_ushort,
365         pub totalhigh: ::c_ulong,
366         pub freehigh: ::c_ulong,
367         pub mem_unit: ::c_uint,
368         pub __reserved: [::c_char; 256],
369     }
370 
371     // FIXME: musl added paddings and adjusted
372     // layout in 1.2.0 but our CI is still 1.1.24.
373     // So, I'm leaving some fields as cfg for now.
374     // ref. https://github.com/bminor/musl/commit/
375     // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392
376     //
377     // OpenHarmony uses the musl 1.2 layout.
378     pub struct utmpx {
379         pub ut_type: ::c_short,
380         __ut_pad1: ::c_short,
381         pub ut_pid: ::pid_t,
382         pub ut_line: [::c_char; 32],
383         pub ut_id: [::c_char; 4],
384         pub ut_user: [::c_char; 32],
385         pub ut_host: [::c_char; 256],
386         pub ut_exit: __exit_status,
387 
388         #[cfg(target_env = "musl")]
389         pub ut_session: ::c_long,
390 
391         #[cfg(target_env = "ohos")]
392         #[cfg(target_endian = "little")]
393         pub ut_session: ::c_int,
394         #[cfg(target_env = "ohos")]
395         #[cfg(target_endian = "little")]
396         __ut_pad2: ::c_int,
397 
398         #[cfg(target_env = "ohos")]
399         #[cfg(not(target_endian = "little"))]
400         __ut_pad2: ::c_int,
401         #[cfg(target_env = "ohos")]
402         #[cfg(not(target_endian = "little"))]
403         pub ut_session: ::c_int,
404 
405         pub ut_tv: ::timeval,
406         pub ut_addr_v6: [::c_uint; 4],
407         __unused: [::c_char; 20],
408     }
409 }
410 
411 cfg_if! {
412     if #[cfg(feature = "extra_traits")] {
413         impl PartialEq for sysinfo {
414             fn eq(&self, other: &sysinfo) -> bool {
415                 self.uptime == other.uptime
416                     && self.loads == other.loads
417                     && self.totalram == other.totalram
418                     && self.freeram == other.freeram
419                     && self.sharedram == other.sharedram
420                     && self.bufferram == other.bufferram
421                     && self.totalswap == other.totalswap
422                     && self.freeswap == other.freeswap
423                     && self.procs == other.procs
424                     && self.pad == other.pad
425                     && self.totalhigh == other.totalhigh
426                     && self.freehigh == other.freehigh
427                     && self.mem_unit == other.mem_unit
428                     && self
429                         .__reserved
430                         .iter()
431                         .zip(other.__reserved.iter())
432                         .all(|(a,b)| a == b)
433             }
434         }
435 
436         impl Eq for sysinfo {}
437 
438         impl ::fmt::Debug for sysinfo {
439             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
440                 f.debug_struct("sysinfo")
441                     .field("uptime", &self.uptime)
442                     .field("loads", &self.loads)
443                     .field("totalram", &self.totalram)
444                     .field("freeram", &self.freeram)
445                     .field("sharedram", &self.sharedram)
446                     .field("bufferram", &self.bufferram)
447                     .field("totalswap", &self.totalswap)
448                     .field("freeswap", &self.freeswap)
449                     .field("procs", &self.procs)
450                     .field("pad", &self.pad)
451                     .field("totalhigh", &self.totalhigh)
452                     .field("freehigh", &self.freehigh)
453                     .field("mem_unit", &self.mem_unit)
454                     // FIXME: .field("__reserved", &self.__reserved)
455                     .finish()
456             }
457         }
458 
459         impl ::hash::Hash for sysinfo {
460             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
461                 self.uptime.hash(state);
462                 self.loads.hash(state);
463                 self.totalram.hash(state);
464                 self.freeram.hash(state);
465                 self.sharedram.hash(state);
466                 self.bufferram.hash(state);
467                 self.totalswap.hash(state);
468                 self.freeswap.hash(state);
469                 self.procs.hash(state);
470                 self.pad.hash(state);
471                 self.totalhigh.hash(state);
472                 self.freehigh.hash(state);
473                 self.mem_unit.hash(state);
474                 self.__reserved.hash(state);
475             }
476         }
477 
478         impl PartialEq for utmpx {
479             fn eq(&self, other: &utmpx) -> bool {
480                 self.ut_type == other.ut_type
481                     //&& self.__ut_pad1 == other.__ut_pad1
482                     && self.ut_pid == other.ut_pid
483                     && self.ut_line == other.ut_line
484                     && self.ut_id == other.ut_id
485                     && self.ut_user == other.ut_user
486                     && self
487                         .ut_host
488                         .iter()
489                         .zip(other.ut_host.iter())
490                         .all(|(a,b)| a == b)
491                     && self.ut_exit == other.ut_exit
492                     && self.ut_session == other.ut_session
493                     //&& self.__ut_pad2 == other.__ut_pad2
494                     && self.ut_tv == other.ut_tv
495                     && self.ut_addr_v6 == other.ut_addr_v6
496                     && self.__unused == other.__unused
497             }
498         }
499 
500         impl Eq for utmpx {}
501 
502         impl ::fmt::Debug for utmpx {
503             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
504                 f.debug_struct("utmpx")
505                     .field("ut_type", &self.ut_type)
506                     //.field("__ut_pad1", &self.__ut_pad1)
507                     .field("ut_pid", &self.ut_pid)
508                     .field("ut_line", &self.ut_line)
509                     .field("ut_id", &self.ut_id)
510                     .field("ut_user", &self.ut_user)
511                     //FIXME: .field("ut_host", &self.ut_host)
512                     .field("ut_exit", &self.ut_exit)
513                     .field("ut_session", &self.ut_session)
514                     //.field("__ut_pad2", &self.__ut_pad2)
515                     .field("ut_tv", &self.ut_tv)
516                     .field("ut_addr_v6", &self.ut_addr_v6)
517                     .field("__unused", &self.__unused)
518                     .finish()
519             }
520         }
521 
522         impl ::hash::Hash for utmpx {
523             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
524                 self.ut_type.hash(state);
525                 //self.__ut_pad1.hash(state);
526                 self.ut_pid.hash(state);
527                 self.ut_line.hash(state);
528                 self.ut_id.hash(state);
529                 self.ut_user.hash(state);
530                 self.ut_host.hash(state);
531                 self.ut_exit.hash(state);
532                 self.ut_session.hash(state);
533                 //self.__ut_pad2.hash(state);
534                 self.ut_tv.hash(state);
535                 self.ut_addr_v6.hash(state);
536                 self.__unused.hash(state);
537             }
538         }
539     }
540 }
541 
542 // include/sys/mman.h
543 /*
544  * Huge page size encoding when MAP_HUGETLB is specified, and a huge page
545  * size other than the default is desired.  See hugetlb_encode.h.
546  * All known huge page size encodings are provided here.  It is the
547  * responsibility of the application to know which sizes are supported on
548  * the running system.  See mmap(2) man page for details.
549  */
550 pub const MAP_HUGE_SHIFT: ::c_int = 26;
551 pub const MAP_HUGE_MASK: ::c_int = 0x3f;
552 
553 pub const MAP_HUGE_64KB: ::c_int = 16 << MAP_HUGE_SHIFT;
554 pub const MAP_HUGE_512KB: ::c_int = 19 << MAP_HUGE_SHIFT;
555 pub const MAP_HUGE_1MB: ::c_int = 20 << MAP_HUGE_SHIFT;
556 pub const MAP_HUGE_2MB: ::c_int = 21 << MAP_HUGE_SHIFT;
557 pub const MAP_HUGE_8MB: ::c_int = 23 << MAP_HUGE_SHIFT;
558 pub const MAP_HUGE_16MB: ::c_int = 24 << MAP_HUGE_SHIFT;
559 pub const MAP_HUGE_32MB: ::c_int = 25 << MAP_HUGE_SHIFT;
560 pub const MAP_HUGE_256MB: ::c_int = 28 << MAP_HUGE_SHIFT;
561 pub const MAP_HUGE_512MB: ::c_int = 29 << MAP_HUGE_SHIFT;
562 pub const MAP_HUGE_1GB: ::c_int = 30 << MAP_HUGE_SHIFT;
563 pub const MAP_HUGE_2GB: ::c_int = 31 << MAP_HUGE_SHIFT;
564 pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT;
565 
566 pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
567 
568 pub const SFD_CLOEXEC: ::c_int = 0x080000;
569 
570 pub const NCCS: usize = 32;
571 
572 pub const O_TRUNC: ::c_int = 512;
573 pub const O_NOATIME: ::c_int = 0o1000000;
574 pub const O_CLOEXEC: ::c_int = 0x80000;
575 pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
576 
577 pub const EBFONT: ::c_int = 59;
578 pub const ENOSTR: ::c_int = 60;
579 pub const ENODATA: ::c_int = 61;
580 pub const ETIME: ::c_int = 62;
581 pub const ENOSR: ::c_int = 63;
582 pub const ENONET: ::c_int = 64;
583 pub const ENOPKG: ::c_int = 65;
584 pub const EREMOTE: ::c_int = 66;
585 pub const ENOLINK: ::c_int = 67;
586 pub const EADV: ::c_int = 68;
587 pub const ESRMNT: ::c_int = 69;
588 pub const ECOMM: ::c_int = 70;
589 pub const EPROTO: ::c_int = 71;
590 pub const EDOTDOT: ::c_int = 73;
591 
592 pub const F_OFD_GETLK: ::c_int = 36;
593 pub const F_OFD_SETLK: ::c_int = 37;
594 pub const F_OFD_SETLKW: ::c_int = 38;
595 
596 pub const F_RDLCK: ::c_int = 0;
597 pub const F_WRLCK: ::c_int = 1;
598 pub const F_UNLCK: ::c_int = 2;
599 
600 pub const SA_NODEFER: ::c_int = 0x40000000;
601 pub const SA_RESETHAND: ::c_int = 0x80000000;
602 pub const SA_RESTART: ::c_int = 0x10000000;
603 pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
604 
605 pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
606 
607 pub const EFD_CLOEXEC: ::c_int = 0x80000;
608 
609 pub const BUFSIZ: ::c_uint = 1024;
610 pub const TMP_MAX: ::c_uint = 10000;
611 pub const FOPEN_MAX: ::c_uint = 1000;
612 pub const FILENAME_MAX: ::c_uint = 4096;
613 pub const O_PATH: ::c_int = 0o10000000;
614 pub const O_EXEC: ::c_int = 0o10000000;
615 pub const O_SEARCH: ::c_int = 0o10000000;
616 pub const O_ACCMODE: ::c_int = 0o10000003;
617 pub const O_NDELAY: ::c_int = O_NONBLOCK;
618 pub const NI_MAXHOST: ::socklen_t = 255;
619 pub const PTHREAD_STACK_MIN: ::size_t = 2048;
620 
621 pub const POSIX_MADV_DONTNEED: ::c_int = 4;
622 
623 pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
624 
625 pub const SOCK_SEQPACKET: ::c_int = 5;
626 pub const SOCK_DCCP: ::c_int = 6;
627 pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK;
628 pub const SOCK_PACKET: ::c_int = 10;
629 
630 pub const SOMAXCONN: ::c_int = 128;
631 
632 #[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
633 pub const SIGUNUSED: ::c_int = ::SIGSYS;
634 
635 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
636 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
637 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
638 pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
639 
640 pub const CPU_SETSIZE: ::c_int = 128;
641 
642 pub const PTRACE_TRACEME: ::c_int = 0;
643 pub const PTRACE_PEEKTEXT: ::c_int = 1;
644 pub const PTRACE_PEEKDATA: ::c_int = 2;
645 pub const PTRACE_PEEKUSER: ::c_int = 3;
646 pub const PTRACE_POKETEXT: ::c_int = 4;
647 pub const PTRACE_POKEDATA: ::c_int = 5;
648 pub const PTRACE_POKEUSER: ::c_int = 6;
649 pub const PTRACE_CONT: ::c_int = 7;
650 pub const PTRACE_KILL: ::c_int = 8;
651 pub const PTRACE_SINGLESTEP: ::c_int = 9;
652 pub const PTRACE_GETREGS: ::c_int = 12;
653 pub const PTRACE_SETREGS: ::c_int = 13;
654 pub const PTRACE_GETFPREGS: ::c_int = 14;
655 pub const PTRACE_SETFPREGS: ::c_int = 15;
656 pub const PTRACE_ATTACH: ::c_int = 16;
657 pub const PTRACE_DETACH: ::c_int = 17;
658 pub const PTRACE_GETFPXREGS: ::c_int = 18;
659 pub const PTRACE_SETFPXREGS: ::c_int = 19;
660 pub const PTRACE_SYSCALL: ::c_int = 24;
661 pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
662 pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
663 pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
664 pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
665 pub const PTRACE_GETREGSET: ::c_int = 0x4204;
666 pub const PTRACE_SETREGSET: ::c_int = 0x4205;
667 pub const PTRACE_SEIZE: ::c_int = 0x4206;
668 pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
669 pub const PTRACE_LISTEN: ::c_int = 0x4208;
670 pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
671 pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a;
672 pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b;
673 
674 pub const AF_IB: ::c_int = 27;
675 pub const AF_MPLS: ::c_int = 28;
676 pub const AF_NFC: ::c_int = 39;
677 pub const AF_VSOCK: ::c_int = 40;
678 pub const AF_XDP: ::c_int = 44;
679 pub const PF_IB: ::c_int = AF_IB;
680 pub const PF_MPLS: ::c_int = AF_MPLS;
681 pub const PF_NFC: ::c_int = AF_NFC;
682 pub const PF_VSOCK: ::c_int = AF_VSOCK;
683 pub const PF_XDP: ::c_int = AF_XDP;
684 
685 pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
686 
687 pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
688 
689 pub const PIDFD_NONBLOCK: ::c_uint = O_NONBLOCK as ::c_uint;
690 
691 pub const TCSANOW: ::c_int = 0;
692 pub const TCSADRAIN: ::c_int = 1;
693 pub const TCSAFLUSH: ::c_int = 2;
694 
695 pub const RTLD_GLOBAL: ::c_int = 0x100;
696 pub const RTLD_NOLOAD: ::c_int = 0x4;
697 
698 pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
699 
700 pub const B0: ::speed_t = 0o000000;
701 pub const B50: ::speed_t = 0o000001;
702 pub const B75: ::speed_t = 0o000002;
703 pub const B110: ::speed_t = 0o000003;
704 pub const B134: ::speed_t = 0o000004;
705 pub const B150: ::speed_t = 0o000005;
706 pub const B200: ::speed_t = 0o000006;
707 pub const B300: ::speed_t = 0o000007;
708 pub const B600: ::speed_t = 0o000010;
709 pub const B1200: ::speed_t = 0o000011;
710 pub const B1800: ::speed_t = 0o000012;
711 pub const B2400: ::speed_t = 0o000013;
712 pub const B4800: ::speed_t = 0o000014;
713 pub const B9600: ::speed_t = 0o000015;
714 pub const B19200: ::speed_t = 0o000016;
715 pub const B38400: ::speed_t = 0o000017;
716 pub const EXTA: ::speed_t = B19200;
717 pub const EXTB: ::speed_t = B38400;
718 
719 pub const REG_OK: ::c_int = 0;
720 
721 pub const PRIO_PROCESS: ::c_int = 0;
722 pub const PRIO_PGRP: ::c_int = 1;
723 pub const PRIO_USER: ::c_int = 2;
724 
725 pub const ADJ_OFFSET: ::c_uint = 0x0001;
726 pub const ADJ_FREQUENCY: ::c_uint = 0x0002;
727 pub const ADJ_MAXERROR: ::c_uint = 0x0004;
728 pub const ADJ_ESTERROR: ::c_uint = 0x0008;
729 pub const ADJ_STATUS: ::c_uint = 0x0010;
730 pub const ADJ_TIMECONST: ::c_uint = 0x0020;
731 pub const ADJ_TAI: ::c_uint = 0x0080;
732 pub const ADJ_SETOFFSET: ::c_uint = 0x0100;
733 pub const ADJ_MICRO: ::c_uint = 0x1000;
734 pub const ADJ_NANO: ::c_uint = 0x2000;
735 pub const ADJ_TICK: ::c_uint = 0x4000;
736 pub const ADJ_OFFSET_SINGLESHOT: ::c_uint = 0x8001;
737 pub const ADJ_OFFSET_SS_READ: ::c_uint = 0xa001;
738 pub const MOD_OFFSET: ::c_uint = ADJ_OFFSET;
739 pub const MOD_FREQUENCY: ::c_uint = ADJ_FREQUENCY;
740 pub const MOD_MAXERROR: ::c_uint = ADJ_MAXERROR;
741 pub const MOD_ESTERROR: ::c_uint = ADJ_ESTERROR;
742 pub const MOD_STATUS: ::c_uint = ADJ_STATUS;
743 pub const MOD_TIMECONST: ::c_uint = ADJ_TIMECONST;
744 pub const MOD_CLKB: ::c_uint = ADJ_TICK;
745 pub const MOD_CLKA: ::c_uint = ADJ_OFFSET_SINGLESHOT;
746 pub const MOD_TAI: ::c_uint = ADJ_TAI;
747 pub const MOD_MICRO: ::c_uint = ADJ_MICRO;
748 pub const MOD_NANO: ::c_uint = ADJ_NANO;
749 pub const STA_PLL: ::c_int = 0x0001;
750 pub const STA_PPSFREQ: ::c_int = 0x0002;
751 pub const STA_PPSTIME: ::c_int = 0x0004;
752 pub const STA_FLL: ::c_int = 0x0008;
753 pub const STA_INS: ::c_int = 0x0010;
754 pub const STA_DEL: ::c_int = 0x0020;
755 pub const STA_UNSYNC: ::c_int = 0x0040;
756 pub const STA_FREQHOLD: ::c_int = 0x0080;
757 pub const STA_PPSSIGNAL: ::c_int = 0x0100;
758 pub const STA_PPSJITTER: ::c_int = 0x0200;
759 pub const STA_PPSWANDER: ::c_int = 0x0400;
760 pub const STA_PPSERROR: ::c_int = 0x0800;
761 pub const STA_CLOCKERR: ::c_int = 0x1000;
762 pub const STA_NANO: ::c_int = 0x2000;
763 pub const STA_MODE: ::c_int = 0x4000;
764 pub const STA_CLK: ::c_int = 0x8000;
765 pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
766     | STA_PPSJITTER
767     | STA_PPSWANDER
768     | STA_PPSERROR
769     | STA_CLOCKERR
770     | STA_NANO
771     | STA_MODE
772     | STA_CLK;
773 
774 pub const TIME_OK: ::c_int = 0;
775 pub const TIME_INS: ::c_int = 1;
776 pub const TIME_DEL: ::c_int = 2;
777 pub const TIME_OOP: ::c_int = 3;
778 pub const TIME_WAIT: ::c_int = 4;
779 pub const TIME_ERROR: ::c_int = 5;
780 pub const TIME_BAD: ::c_int = TIME_ERROR;
781 pub const MAXTC: ::c_long = 6;
782 
783 pub const SOL_XDP: ::c_int = 283;
784 
785 // linux/if_xdp.h
786 pub const XDP_SHARED_UMEM: ::__u16 = 1 << 0;
787 pub const XDP_COPY: ::__u16 = 1 << 1;
788 pub const XDP_ZEROCOPY: ::__u16 = 1 << 2;
789 pub const XDP_USE_NEED_WAKEUP: ::__u16 = 1 << 3;
790 pub const XDP_USE_SG: ::__u16 = 1 << 4;
791 
792 pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: ::__u32 = 1 << 0;
793 
794 pub const XDP_RING_NEED_WAKEUP: ::__u32 = 1 << 0;
795 
796 pub const XDP_MMAP_OFFSETS: ::c_int = 1;
797 pub const XDP_RX_RING: ::c_int = 2;
798 pub const XDP_TX_RING: ::c_int = 3;
799 pub const XDP_UMEM_REG: ::c_int = 4;
800 pub const XDP_UMEM_FILL_RING: ::c_int = 5;
801 pub const XDP_UMEM_COMPLETION_RING: ::c_int = 6;
802 pub const XDP_STATISTICS: ::c_int = 7;
803 pub const XDP_OPTIONS: ::c_int = 8;
804 
805 pub const XDP_OPTIONS_ZEROCOPY: ::__u32 = 1 << 0;
806 
807 pub const XDP_PGOFF_RX_RING: ::off_t = 0;
808 pub const XDP_PGOFF_TX_RING: ::off_t = 0x80000000;
809 pub const XDP_UMEM_PGOFF_FILL_RING: ::c_ulonglong = 0x100000000;
810 pub const XDP_UMEM_PGOFF_COMPLETION_RING: ::c_ulonglong = 0x180000000;
811 
812 pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: ::c_int = 48;
813 pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
814 
815 pub const XDP_PKT_CONTD: ::__u32 = 1 << 0;
816 
817 cfg_if! {
818     if #[cfg(target_arch = "s390x")] {
819         pub const POSIX_FADV_DONTNEED: ::c_int = 6;
820         pub const POSIX_FADV_NOREUSE: ::c_int = 7;
821     } else {
822         pub const POSIX_FADV_DONTNEED: ::c_int = 4;
823         pub const POSIX_FADV_NOREUSE: ::c_int = 5;
824     }
825 }
826 
827 extern "C" {
sendmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_uint, ) -> ::c_int828     pub fn sendmmsg(
829         sockfd: ::c_int,
830         msgvec: *mut ::mmsghdr,
831         vlen: ::c_uint,
832         flags: ::c_uint,
833     ) -> ::c_int;
recvmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_uint, timeout: *mut ::timespec, ) -> ::c_int834     pub fn recvmmsg(
835         sockfd: ::c_int,
836         msgvec: *mut ::mmsghdr,
837         vlen: ::c_uint,
838         flags: ::c_uint,
839         timeout: *mut ::timespec,
840     ) -> ::c_int;
841 
getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int842     pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int843     pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
prlimit( pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit, old_limit: *mut ::rlimit, ) -> ::c_int844     pub fn prlimit(
845         pid: ::pid_t,
846         resource: ::c_int,
847         new_limit: *const ::rlimit,
848         old_limit: *mut ::rlimit,
849     ) -> ::c_int;
ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int850     pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int851     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
ptrace(request: ::c_int, ...) -> ::c_long852     pub fn ptrace(request: ::c_int, ...) -> ::c_long;
getpriority(which: ::c_int, who: ::id_t) -> ::c_int853     pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int854     pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
855     // Musl targets need the `mask` argument of `fanotify_mark` be specified
856     // `::c_ulonglong` instead of `u64` or there will be a type mismatch between
857     // `long long unsigned int` and the expected `uint64_t`.
fanotify_mark( fd: ::c_int, flags: ::c_uint, mask: ::c_ulonglong, dirfd: ::c_int, path: *const ::c_char, ) -> ::c_int858     pub fn fanotify_mark(
859         fd: ::c_int,
860         flags: ::c_uint,
861         mask: ::c_ulonglong,
862         dirfd: ::c_int,
863         path: *const ::c_char,
864     ) -> ::c_int;
getauxval(type_: ::c_ulong) -> ::c_ulong865     pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
866 
867     // Added in `musl` 1.1.20
explicit_bzero(s: *mut ::c_void, len: ::size_t)868     pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t);
869     // Added in `musl` 1.2.2
reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void870     pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
871 
adjtimex(buf: *mut ::timex) -> ::c_int872     pub fn adjtimex(buf: *mut ::timex) -> ::c_int;
clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int873     pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
874 
ctermid(s: *mut ::c_char) -> *mut ::c_char875     pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
876 
memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int877     pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int878     pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int;
malloc_usable_size(ptr: *mut ::c_void) -> ::size_t879     pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t;
880 
euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int881     pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int882     pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
883 
asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char884     pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
885 
strftime( s: *mut ::c_char, max: ::size_t, format: *const ::c_char, tm: *const ::tm, ) -> ::size_t886     pub fn strftime(
887         s: *mut ::c_char,
888         max: ::size_t,
889         format: *const ::c_char,
890         tm: *const ::tm,
891     ) -> ::size_t;
strftime_l( s: *mut ::c_char, max: ::size_t, format: *const ::c_char, tm: *const ::tm, locale: ::locale_t, ) -> ::size_t892     pub fn strftime_l(
893         s: *mut ::c_char,
894         max: ::size_t,
895         format: *const ::c_char,
896         tm: *const ::tm,
897         locale: ::locale_t,
898     ) -> ::size_t;
strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char899     pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;
900 
dirname(path: *mut ::c_char) -> *mut ::c_char901     pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
basename(path: *mut ::c_char) -> *mut ::c_char902     pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
903 }
904 
905 // Alias <foo> to <foo>64 to mimic glibc's LFS64 support
906 mod lfs64;
907 pub use self::lfs64::*;
908 
909 cfg_if! {
910     if #[cfg(any(target_arch = "x86_64",
911                  target_arch = "aarch64",
912                  target_arch = "mips64",
913                  target_arch = "powerpc64",
914                  target_arch = "s390x",
915                  target_arch = "riscv64"))] {
916         mod b64;
917         pub use self::b64::*;
918     } else if #[cfg(any(target_arch = "x86",
919                         target_arch = "mips",
920                         target_arch = "powerpc",
921                         target_arch = "hexagon",
922                         target_arch = "riscv32",
923                         target_arch = "arm"))] {
924         mod b32;
925         pub use self::b32::*;
926     } else { }
927 }
928