• 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 pub type flock64 = flock;
26 
27 cfg_if! {
28     if #[cfg(doc)] {
29         // Used in `linux::arch` to define ioctl constants.
30         pub(crate) type Ioctl = ::c_int;
31     } else {
32         #[doc(hidden)]
33         pub type Ioctl = ::c_int;
34     }
35 }
36 
37 impl siginfo_t {
si_addr(&self) -> *mut ::c_void38     pub unsafe fn si_addr(&self) -> *mut ::c_void {
39         #[repr(C)]
40         struct siginfo_sigfault {
41             _si_signo: ::c_int,
42             _si_errno: ::c_int,
43             _si_code: ::c_int,
44             si_addr: *mut ::c_void,
45         }
46         (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
47     }
48 
si_value(&self) -> ::sigval49     pub unsafe fn si_value(&self) -> ::sigval {
50         #[repr(C)]
51         struct siginfo_si_value {
52             _si_signo: ::c_int,
53             _si_errno: ::c_int,
54             _si_code: ::c_int,
55             _si_timerid: ::c_int,
56             _si_overrun: ::c_int,
57             si_value: ::sigval,
58         }
59         (*(self as *const siginfo_t as *const siginfo_si_value)).si_value
60     }
61 }
62 
63 cfg_if! {
64     if #[cfg(libc_union)] {
65         // Internal, for casts to access union fields
66         #[repr(C)]
67         struct sifields_sigchld {
68             si_pid: ::pid_t,
69             si_uid: ::uid_t,
70             si_status: ::c_int,
71             si_utime: ::c_long,
72             si_stime: ::c_long,
73         }
74         impl ::Copy for sifields_sigchld {}
75         impl ::Clone for sifields_sigchld {
76             fn clone(&self) -> sifields_sigchld {
77                 *self
78             }
79         }
80 
81         // Internal, for casts to access union fields
82         #[repr(C)]
83         union sifields {
84             _align_pointer: *mut ::c_void,
85             sigchld: sifields_sigchld,
86         }
87 
88         // Internal, for casts to access union fields. Note that some variants
89         // of sifields start with a pointer, which makes the alignment of
90         // sifields vary on 32-bit and 64-bit architectures.
91         #[repr(C)]
92         struct siginfo_f {
93             _siginfo_base: [::c_int; 3],
94             sifields: sifields,
95         }
96 
97         impl siginfo_t {
98             unsafe fn sifields(&self) -> &sifields {
99                 &(*(self as *const siginfo_t as *const siginfo_f)).sifields
100             }
101 
102             pub unsafe fn si_pid(&self) -> ::pid_t {
103                 self.sifields().sigchld.si_pid
104             }
105 
106             pub unsafe fn si_uid(&self) -> ::uid_t {
107                 self.sifields().sigchld.si_uid
108             }
109 
110             pub unsafe fn si_status(&self) -> ::c_int {
111                 self.sifields().sigchld.si_status
112             }
113 
114             pub unsafe fn si_utime(&self) -> ::c_long {
115                 self.sifields().sigchld.si_utime
116             }
117 
118             pub unsafe fn si_stime(&self) -> ::c_long {
119                 self.sifields().sigchld.si_stime
120             }
121         }
122     }
123 }
124 
125 s! {
126     pub struct aiocb {
127         pub aio_fildes: ::c_int,
128         pub aio_lio_opcode: ::c_int,
129         pub aio_reqprio: ::c_int,
130         pub aio_buf: *mut ::c_void,
131         pub aio_nbytes: ::size_t,
132         pub aio_sigevent: ::sigevent,
133         __td: *mut ::c_void,
134         __lock: [::c_int; 2],
135         __err: ::c_int,
136         __ret: ::ssize_t,
137         pub aio_offset: off_t,
138         __next: *mut ::c_void,
139         __prev: *mut ::c_void,
140         #[cfg(target_pointer_width = "32")]
141         __dummy4: [::c_char; 24],
142         #[cfg(target_pointer_width = "64")]
143         __dummy4: [::c_char; 16],
144     }
145 
146     pub struct sigaction {
147         pub sa_sigaction: ::sighandler_t,
148         pub sa_mask: ::sigset_t,
149         pub sa_flags: ::c_int,
150         pub sa_restorer: ::Option<extern fn()>,
151     }
152 
153     pub struct statvfs {
154         pub f_bsize: ::c_ulong,
155         pub f_frsize: ::c_ulong,
156         pub f_blocks: ::fsblkcnt_t,
157         pub f_bfree: ::fsblkcnt_t,
158         pub f_bavail: ::fsblkcnt_t,
159         pub f_files: ::fsfilcnt_t,
160         pub f_ffree: ::fsfilcnt_t,
161         pub f_favail: ::fsfilcnt_t,
162         #[cfg(target_endian = "little")]
163         pub f_fsid: ::c_ulong,
164         #[cfg(target_pointer_width = "32")]
165         __f_unused: ::c_int,
166         #[cfg(target_endian = "big")]
167         pub f_fsid: ::c_ulong,
168         pub f_flag: ::c_ulong,
169         pub f_namemax: ::c_ulong,
170         __f_spare: [::c_int; 6],
171     }
172 
173     pub struct termios {
174         pub c_iflag: ::tcflag_t,
175         pub c_oflag: ::tcflag_t,
176         pub c_cflag: ::tcflag_t,
177         pub c_lflag: ::tcflag_t,
178         pub c_line: ::cc_t,
179         pub c_cc: [::cc_t; ::NCCS],
180         pub __c_ispeed: ::speed_t,
181         pub __c_ospeed: ::speed_t,
182     }
183 
184     pub struct flock {
185         pub l_type: ::c_short,
186         pub l_whence: ::c_short,
187         pub l_start: ::off_t,
188         pub l_len: ::off_t,
189         pub l_pid: ::pid_t,
190     }
191 
192     pub struct regex_t {
193         __re_nsub: ::size_t,
194         __opaque: *mut ::c_void,
195         __padding: [*mut ::c_void; 4usize],
196         __nsub2: ::size_t,
197         __padding2: ::c_char,
198     }
199 
200     pub struct rtentry {
201         pub rt_pad1: ::c_ulong,
202         pub rt_dst: ::sockaddr,
203         pub rt_gateway: ::sockaddr,
204         pub rt_genmask: ::sockaddr,
205         pub rt_flags: ::c_ushort,
206         pub rt_pad2: ::c_short,
207         pub rt_pad3: ::c_ulong,
208         pub rt_tos: ::c_uchar,
209         pub rt_class: ::c_uchar,
210         #[cfg(target_pointer_width = "64")]
211         pub rt_pad4: [::c_short; 3usize],
212         #[cfg(not(target_pointer_width = "64"))]
213         pub rt_pad4: [::c_short; 1usize],
214         pub rt_metric: ::c_short,
215         pub rt_dev: *mut ::c_char,
216         pub rt_mtu: ::c_ulong,
217         pub rt_window: ::c_ulong,
218         pub rt_irtt: ::c_ushort,
219     }
220 
221     pub struct __exit_status {
222         pub e_termination: ::c_short,
223         pub e_exit: ::c_short,
224     }
225 
226     pub struct Elf64_Chdr {
227         pub ch_type: ::Elf64_Word,
228         pub ch_reserved: ::Elf64_Word,
229         pub ch_size: ::Elf64_Xword,
230         pub ch_addralign: ::Elf64_Xword,
231     }
232 
233     pub struct Elf32_Chdr {
234         pub ch_type: ::Elf32_Word,
235         pub ch_size: ::Elf32_Word,
236         pub ch_addralign: ::Elf32_Word,
237     }
238 
239     pub struct timex {
240         pub modes: ::c_uint,
241         pub offset: ::c_long,
242         pub freq: ::c_long,
243         pub maxerror: ::c_long,
244         pub esterror: ::c_long,
245         pub status: ::c_int,
246         pub constant: ::c_long,
247         pub precision: ::c_long,
248         pub tolerance: ::c_long,
249         pub time: ::timeval,
250         pub tick: ::c_long,
251         pub ppsfreq: ::c_long,
252         pub jitter: ::c_long,
253         pub shift: ::c_int,
254         pub stabil: ::c_long,
255         pub jitcnt: ::c_long,
256         pub calcnt: ::c_long,
257         pub errcnt: ::c_long,
258         pub stbcnt: ::c_long,
259         pub tai: ::c_int,
260         pub __padding: [::c_int; 11],
261     }
262 
263     pub struct ntptimeval {
264         pub time: ::timeval,
265         pub maxerror: ::c_long,
266         pub esterror: ::c_long,
267     }
268 }
269 
270 s_no_extra_traits! {
271     pub struct sysinfo {
272         pub uptime: ::c_ulong,
273         pub loads: [::c_ulong; 3],
274         pub totalram: ::c_ulong,
275         pub freeram: ::c_ulong,
276         pub sharedram: ::c_ulong,
277         pub bufferram: ::c_ulong,
278         pub totalswap: ::c_ulong,
279         pub freeswap: ::c_ulong,
280         pub procs: ::c_ushort,
281         pub pad: ::c_ushort,
282         pub totalhigh: ::c_ulong,
283         pub freehigh: ::c_ulong,
284         pub mem_unit: ::c_uint,
285         pub __reserved: [::c_char; 256],
286     }
287 
288     // FIXME: musl added paddings and adjusted
289     // layout in 1.2.0 but our CI is still 1.1.24.
290     // So, I'm leaving some fields as comments for now.
291     // ref. https://github.com/bminor/musl/commit/
292     // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392
293     pub struct utmpx {
294         pub ut_type: ::c_short,
295         //__ut_pad1: ::c_short,
296         pub ut_pid: ::pid_t,
297         pub ut_line: [::c_char; 32],
298         pub ut_id: [::c_char; 4],
299         pub ut_user: [::c_char; 32],
300         pub ut_host: [::c_char; 256],
301         pub ut_exit: __exit_status,
302 
303         //#[cfg(target_endian = "little")]
304         pub ut_session: ::c_long,
305         //#[cfg(target_endian = "little")]
306         //__ut_pad2: ::c_long,
307 
308         //#[cfg(not(target_endian = "little"))]
309         //__ut_pad2: ::c_int,
310         //#[cfg(not(target_endian = "little"))]
311         //pub ut_session: ::c_int,
312 
313         pub ut_tv: ::timeval,
314         pub ut_addr_v6: [::c_uint; 4],
315         __unused: [::c_char; 20],
316     }
317 }
318 
319 cfg_if! {
320     if #[cfg(feature = "extra_traits")] {
321         impl PartialEq for sysinfo {
322             fn eq(&self, other: &sysinfo) -> bool {
323                 self.uptime == other.uptime
324                     && self.loads == other.loads
325                     && self.totalram == other.totalram
326                     && self.freeram == other.freeram
327                     && self.sharedram == other.sharedram
328                     && self.bufferram == other.bufferram
329                     && self.totalswap == other.totalswap
330                     && self.freeswap == other.freeswap
331                     && self.procs == other.procs
332                     && self.pad == other.pad
333                     && self.totalhigh == other.totalhigh
334                     && self.freehigh == other.freehigh
335                     && self.mem_unit == other.mem_unit
336                     && self
337                         .__reserved
338                         .iter()
339                         .zip(other.__reserved.iter())
340                         .all(|(a,b)| a == b)
341             }
342         }
343 
344         impl Eq for sysinfo {}
345 
346         impl ::fmt::Debug for sysinfo {
347             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
348                 f.debug_struct("sysinfo")
349                     .field("uptime", &self.uptime)
350                     .field("loads", &self.loads)
351                     .field("totalram", &self.totalram)
352                     .field("freeram", &self.freeram)
353                     .field("sharedram", &self.sharedram)
354                     .field("bufferram", &self.bufferram)
355                     .field("totalswap", &self.totalswap)
356                     .field("freeswap", &self.freeswap)
357                     .field("procs", &self.procs)
358                     .field("pad", &self.pad)
359                     .field("totalhigh", &self.totalhigh)
360                     .field("freehigh", &self.freehigh)
361                     .field("mem_unit", &self.mem_unit)
362                     // FIXME: .field("__reserved", &self.__reserved)
363                     .finish()
364             }
365         }
366 
367         impl ::hash::Hash for sysinfo {
368             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
369                 self.uptime.hash(state);
370                 self.loads.hash(state);
371                 self.totalram.hash(state);
372                 self.freeram.hash(state);
373                 self.sharedram.hash(state);
374                 self.bufferram.hash(state);
375                 self.totalswap.hash(state);
376                 self.freeswap.hash(state);
377                 self.procs.hash(state);
378                 self.pad.hash(state);
379                 self.totalhigh.hash(state);
380                 self.freehigh.hash(state);
381                 self.mem_unit.hash(state);
382                 self.__reserved.hash(state);
383             }
384         }
385 
386         impl PartialEq for utmpx {
387             fn eq(&self, other: &utmpx) -> bool {
388                 self.ut_type == other.ut_type
389                     //&& self.__ut_pad1 == other.__ut_pad1
390                     && self.ut_pid == other.ut_pid
391                     && self.ut_line == other.ut_line
392                     && self.ut_id == other.ut_id
393                     && self.ut_user == other.ut_user
394                     && self
395                         .ut_host
396                         .iter()
397                         .zip(other.ut_host.iter())
398                         .all(|(a,b)| a == b)
399                     && self.ut_exit == other.ut_exit
400                     && self.ut_session == other.ut_session
401                     //&& self.__ut_pad2 == other.__ut_pad2
402                     && self.ut_tv == other.ut_tv
403                     && self.ut_addr_v6 == other.ut_addr_v6
404                     && self.__unused == other.__unused
405             }
406         }
407 
408         impl Eq for utmpx {}
409 
410         impl ::fmt::Debug for utmpx {
411             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
412                 f.debug_struct("utmpx")
413                     .field("ut_type", &self.ut_type)
414                     //.field("__ut_pad1", &self.__ut_pad1)
415                     .field("ut_pid", &self.ut_pid)
416                     .field("ut_line", &self.ut_line)
417                     .field("ut_id", &self.ut_id)
418                     .field("ut_user", &self.ut_user)
419                     //FIXME: .field("ut_host", &self.ut_host)
420                     .field("ut_exit", &self.ut_exit)
421                     .field("ut_session", &self.ut_session)
422                     //.field("__ut_pad2", &self.__ut_pad2)
423                     .field("ut_tv", &self.ut_tv)
424                     .field("ut_addr_v6", &self.ut_addr_v6)
425                     .field("__unused", &self.__unused)
426                     .finish()
427             }
428         }
429 
430         impl ::hash::Hash for utmpx {
431             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
432                 self.ut_type.hash(state);
433                 //self.__ut_pad1.hash(state);
434                 self.ut_pid.hash(state);
435                 self.ut_line.hash(state);
436                 self.ut_id.hash(state);
437                 self.ut_user.hash(state);
438                 self.ut_host.hash(state);
439                 self.ut_exit.hash(state);
440                 self.ut_session.hash(state);
441                 //self.__ut_pad2.hash(state);
442                 self.ut_tv.hash(state);
443                 self.ut_addr_v6.hash(state);
444                 self.__unused.hash(state);
445             }
446         }
447     }
448 }
449 
450 // include/sys/mman.h
451 /*
452  * Huge page size encoding when MAP_HUGETLB is specified, and a huge page
453  * size other than the default is desired.  See hugetlb_encode.h.
454  * All known huge page size encodings are provided here.  It is the
455  * responsibility of the application to know which sizes are supported on
456  * the running system.  See mmap(2) man page for details.
457  */
458 pub const MAP_HUGE_SHIFT: ::c_int = 26;
459 pub const MAP_HUGE_MASK: ::c_int = 0x3f;
460 
461 pub const MAP_HUGE_64KB: ::c_int = 16 << MAP_HUGE_SHIFT;
462 pub const MAP_HUGE_512KB: ::c_int = 19 << MAP_HUGE_SHIFT;
463 pub const MAP_HUGE_1MB: ::c_int = 20 << MAP_HUGE_SHIFT;
464 pub const MAP_HUGE_2MB: ::c_int = 21 << MAP_HUGE_SHIFT;
465 pub const MAP_HUGE_8MB: ::c_int = 23 << MAP_HUGE_SHIFT;
466 pub const MAP_HUGE_16MB: ::c_int = 24 << MAP_HUGE_SHIFT;
467 pub const MAP_HUGE_32MB: ::c_int = 25 << MAP_HUGE_SHIFT;
468 pub const MAP_HUGE_256MB: ::c_int = 28 << MAP_HUGE_SHIFT;
469 pub const MAP_HUGE_512MB: ::c_int = 29 << MAP_HUGE_SHIFT;
470 pub const MAP_HUGE_1GB: ::c_int = 30 << MAP_HUGE_SHIFT;
471 pub const MAP_HUGE_2GB: ::c_int = 31 << MAP_HUGE_SHIFT;
472 pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT;
473 
474 pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
475 
476 pub const SFD_CLOEXEC: ::c_int = 0x080000;
477 
478 pub const NCCS: usize = 32;
479 
480 pub const O_TRUNC: ::c_int = 512;
481 pub const O_NOATIME: ::c_int = 0o1000000;
482 pub const O_CLOEXEC: ::c_int = 0x80000;
483 pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
484 
485 pub const EBFONT: ::c_int = 59;
486 pub const ENOSTR: ::c_int = 60;
487 pub const ENODATA: ::c_int = 61;
488 pub const ETIME: ::c_int = 62;
489 pub const ENOSR: ::c_int = 63;
490 pub const ENONET: ::c_int = 64;
491 pub const ENOPKG: ::c_int = 65;
492 pub const EREMOTE: ::c_int = 66;
493 pub const ENOLINK: ::c_int = 67;
494 pub const EADV: ::c_int = 68;
495 pub const ESRMNT: ::c_int = 69;
496 pub const ECOMM: ::c_int = 70;
497 pub const EPROTO: ::c_int = 71;
498 pub const EDOTDOT: ::c_int = 73;
499 
500 pub const F_RDLCK: ::c_int = 0;
501 pub const F_WRLCK: ::c_int = 1;
502 pub const F_UNLCK: ::c_int = 2;
503 
504 pub const SA_NODEFER: ::c_int = 0x40000000;
505 pub const SA_RESETHAND: ::c_int = 0x80000000;
506 pub const SA_RESTART: ::c_int = 0x10000000;
507 pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
508 
509 pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
510 
511 pub const EFD_CLOEXEC: ::c_int = 0x80000;
512 
513 pub const BUFSIZ: ::c_uint = 1024;
514 pub const TMP_MAX: ::c_uint = 10000;
515 pub const FOPEN_MAX: ::c_uint = 1000;
516 pub const FILENAME_MAX: ::c_uint = 4096;
517 pub const O_PATH: ::c_int = 0o10000000;
518 pub const O_EXEC: ::c_int = 0o10000000;
519 pub const O_SEARCH: ::c_int = 0o10000000;
520 pub const O_ACCMODE: ::c_int = 0o10000003;
521 pub const O_NDELAY: ::c_int = O_NONBLOCK;
522 pub const NI_MAXHOST: ::socklen_t = 255;
523 pub const PTHREAD_STACK_MIN: ::size_t = 2048;
524 
525 pub const POSIX_MADV_DONTNEED: ::c_int = 4;
526 
527 pub const RLIM_INFINITY: ::rlim_t = !0;
528 pub const RLIMIT_RTTIME: ::c_int = 15;
529 
530 pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
531 
532 pub const SOCK_DCCP: ::c_int = 6;
533 pub const SOCK_PACKET: ::c_int = 10;
534 
535 #[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
536 pub const SIGUNUSED: ::c_int = ::SIGSYS;
537 
538 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
539 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
540 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
541 
542 pub const CPU_SETSIZE: ::c_int = 128;
543 
544 pub const PTRACE_TRACEME: ::c_int = 0;
545 pub const PTRACE_PEEKTEXT: ::c_int = 1;
546 pub const PTRACE_PEEKDATA: ::c_int = 2;
547 pub const PTRACE_PEEKUSER: ::c_int = 3;
548 pub const PTRACE_POKETEXT: ::c_int = 4;
549 pub const PTRACE_POKEDATA: ::c_int = 5;
550 pub const PTRACE_POKEUSER: ::c_int = 6;
551 pub const PTRACE_CONT: ::c_int = 7;
552 pub const PTRACE_KILL: ::c_int = 8;
553 pub const PTRACE_SINGLESTEP: ::c_int = 9;
554 pub const PTRACE_GETREGS: ::c_int = 12;
555 pub const PTRACE_SETREGS: ::c_int = 13;
556 pub const PTRACE_GETFPREGS: ::c_int = 14;
557 pub const PTRACE_SETFPREGS: ::c_int = 15;
558 pub const PTRACE_ATTACH: ::c_int = 16;
559 pub const PTRACE_DETACH: ::c_int = 17;
560 pub const PTRACE_GETFPXREGS: ::c_int = 18;
561 pub const PTRACE_SETFPXREGS: ::c_int = 19;
562 pub const PTRACE_SYSCALL: ::c_int = 24;
563 pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
564 pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
565 pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
566 pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
567 pub const PTRACE_GETREGSET: ::c_int = 0x4204;
568 pub const PTRACE_SETREGSET: ::c_int = 0x4205;
569 pub const PTRACE_SEIZE: ::c_int = 0x4206;
570 pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
571 pub const PTRACE_LISTEN: ::c_int = 0x4208;
572 pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
573 
574 pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
575 pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
576 // NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
577 pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;
578 
579 pub const AF_IB: ::c_int = 27;
580 pub const AF_MPLS: ::c_int = 28;
581 pub const AF_NFC: ::c_int = 39;
582 pub const AF_VSOCK: ::c_int = 40;
583 pub const AF_XDP: ::c_int = 44;
584 pub const PF_IB: ::c_int = AF_IB;
585 pub const PF_MPLS: ::c_int = AF_MPLS;
586 pub const PF_NFC: ::c_int = AF_NFC;
587 pub const PF_VSOCK: ::c_int = AF_VSOCK;
588 pub const PF_XDP: ::c_int = AF_XDP;
589 
590 pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
591 
592 pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
593 
594 pub const TCSANOW: ::c_int = 0;
595 pub const TCSADRAIN: ::c_int = 1;
596 pub const TCSAFLUSH: ::c_int = 2;
597 
598 pub const RTLD_GLOBAL: ::c_int = 0x100;
599 pub const RTLD_NOLOAD: ::c_int = 0x4;
600 
601 pub const CLOCK_SGI_CYCLE: ::clockid_t = 10;
602 
603 pub const B0: ::speed_t = 0o000000;
604 pub const B50: ::speed_t = 0o000001;
605 pub const B75: ::speed_t = 0o000002;
606 pub const B110: ::speed_t = 0o000003;
607 pub const B134: ::speed_t = 0o000004;
608 pub const B150: ::speed_t = 0o000005;
609 pub const B200: ::speed_t = 0o000006;
610 pub const B300: ::speed_t = 0o000007;
611 pub const B600: ::speed_t = 0o000010;
612 pub const B1200: ::speed_t = 0o000011;
613 pub const B1800: ::speed_t = 0o000012;
614 pub const B2400: ::speed_t = 0o000013;
615 pub const B4800: ::speed_t = 0o000014;
616 pub const B9600: ::speed_t = 0o000015;
617 pub const B19200: ::speed_t = 0o000016;
618 pub const B38400: ::speed_t = 0o000017;
619 pub const EXTA: ::speed_t = B19200;
620 pub const EXTB: ::speed_t = B38400;
621 
622 pub const RLIMIT_CPU: ::c_int = 0;
623 pub const RLIMIT_FSIZE: ::c_int = 1;
624 pub const RLIMIT_DATA: ::c_int = 2;
625 pub const RLIMIT_STACK: ::c_int = 3;
626 pub const RLIMIT_CORE: ::c_int = 4;
627 pub const RLIMIT_LOCKS: ::c_int = 10;
628 pub const RLIMIT_SIGPENDING: ::c_int = 11;
629 pub const RLIMIT_MSGQUEUE: ::c_int = 12;
630 pub const RLIMIT_NICE: ::c_int = 13;
631 pub const RLIMIT_RTPRIO: ::c_int = 14;
632 
633 pub const REG_OK: ::c_int = 0;
634 
635 pub const PRIO_PROCESS: ::c_int = 0;
636 pub const PRIO_PGRP: ::c_int = 1;
637 pub const PRIO_USER: ::c_int = 2;
638 
639 pub const ADJ_OFFSET: ::c_uint = 0x0001;
640 pub const ADJ_FREQUENCY: ::c_uint = 0x0002;
641 pub const ADJ_MAXERROR: ::c_uint = 0x0004;
642 pub const ADJ_ESTERROR: ::c_uint = 0x0008;
643 pub const ADJ_STATUS: ::c_uint = 0x0010;
644 pub const ADJ_TIMECONST: ::c_uint = 0x0020;
645 pub const ADJ_TAI: ::c_uint = 0x0080;
646 pub const ADJ_SETOFFSET: ::c_uint = 0x0100;
647 pub const ADJ_MICRO: ::c_uint = 0x1000;
648 pub const ADJ_NANO: ::c_uint = 0x2000;
649 pub const ADJ_TICK: ::c_uint = 0x4000;
650 pub const ADJ_OFFSET_SINGLESHOT: ::c_uint = 0x8001;
651 pub const ADJ_OFFSET_SS_READ: ::c_uint = 0xa001;
652 pub const MOD_OFFSET: ::c_uint = ADJ_OFFSET;
653 pub const MOD_FREQUENCY: ::c_uint = ADJ_FREQUENCY;
654 pub const MOD_MAXERROR: ::c_uint = ADJ_MAXERROR;
655 pub const MOD_ESTERROR: ::c_uint = ADJ_ESTERROR;
656 pub const MOD_STATUS: ::c_uint = ADJ_STATUS;
657 pub const MOD_TIMECONST: ::c_uint = ADJ_TIMECONST;
658 pub const MOD_CLKB: ::c_uint = ADJ_TICK;
659 pub const MOD_CLKA: ::c_uint = ADJ_OFFSET_SINGLESHOT;
660 pub const MOD_TAI: ::c_uint = ADJ_TAI;
661 pub const MOD_MICRO: ::c_uint = ADJ_MICRO;
662 pub const MOD_NANO: ::c_uint = ADJ_NANO;
663 pub const STA_PLL: ::c_int = 0x0001;
664 pub const STA_PPSFREQ: ::c_int = 0x0002;
665 pub const STA_PPSTIME: ::c_int = 0x0004;
666 pub const STA_FLL: ::c_int = 0x0008;
667 pub const STA_INS: ::c_int = 0x0010;
668 pub const STA_DEL: ::c_int = 0x0020;
669 pub const STA_UNSYNC: ::c_int = 0x0040;
670 pub const STA_FREQHOLD: ::c_int = 0x0080;
671 pub const STA_PPSSIGNAL: ::c_int = 0x0100;
672 pub const STA_PPSJITTER: ::c_int = 0x0200;
673 pub const STA_PPSWANDER: ::c_int = 0x0400;
674 pub const STA_PPSERROR: ::c_int = 0x0800;
675 pub const STA_CLOCKERR: ::c_int = 0x1000;
676 pub const STA_NANO: ::c_int = 0x2000;
677 pub const STA_MODE: ::c_int = 0x4000;
678 pub const STA_CLK: ::c_int = 0x8000;
679 pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
680     | STA_PPSJITTER
681     | STA_PPSWANDER
682     | STA_PPSERROR
683     | STA_CLOCKERR
684     | STA_NANO
685     | STA_MODE
686     | STA_CLK;
687 
688 pub const TIME_OK: ::c_int = 0;
689 pub const TIME_INS: ::c_int = 1;
690 pub const TIME_DEL: ::c_int = 2;
691 pub const TIME_OOP: ::c_int = 3;
692 pub const TIME_WAIT: ::c_int = 4;
693 pub const TIME_ERROR: ::c_int = 5;
694 pub const TIME_BAD: ::c_int = TIME_ERROR;
695 pub const MAXTC: ::c_long = 6;
696 
697 cfg_if! {
698     if #[cfg(target_arch = "s390x")] {
699         pub const POSIX_FADV_DONTNEED: ::c_int = 6;
700         pub const POSIX_FADV_NOREUSE: ::c_int = 7;
701     } else {
702         pub const POSIX_FADV_DONTNEED: ::c_int = 4;
703         pub const POSIX_FADV_NOREUSE: ::c_int = 5;
704     }
705 }
706 
707 extern "C" {
sendmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_uint, ) -> ::c_int708     pub fn sendmmsg(
709         sockfd: ::c_int,
710         msgvec: *mut ::mmsghdr,
711         vlen: ::c_uint,
712         flags: ::c_uint,
713     ) -> ::c_int;
recvmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_uint, timeout: *mut ::timespec, ) -> ::c_int714     pub fn recvmmsg(
715         sockfd: ::c_int,
716         msgvec: *mut ::mmsghdr,
717         vlen: ::c_uint,
718         flags: ::c_uint,
719         timeout: *mut ::timespec,
720     ) -> ::c_int;
721 
getrlimit64(resource: ::c_int, rlim: *mut ::rlimit64) -> ::c_int722     pub fn getrlimit64(resource: ::c_int, rlim: *mut ::rlimit64) -> ::c_int;
setrlimit64(resource: ::c_int, rlim: *const ::rlimit64) -> ::c_int723     pub fn setrlimit64(resource: ::c_int, rlim: *const ::rlimit64) -> ::c_int;
getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int724     pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int725     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_int726     pub fn prlimit(
727         pid: ::pid_t,
728         resource: ::c_int,
729         new_limit: *const ::rlimit,
730         old_limit: *mut ::rlimit,
731     ) -> ::c_int;
prlimit64( pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit64, old_limit: *mut ::rlimit64, ) -> ::c_int732     pub fn prlimit64(
733         pid: ::pid_t,
734         resource: ::c_int,
735         new_limit: *const ::rlimit64,
736         old_limit: *mut ::rlimit64,
737     ) -> ::c_int;
738 
ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int739     pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int740     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
ptrace(request: ::c_int, ...) -> ::c_long741     pub fn ptrace(request: ::c_int, ...) -> ::c_long;
getpriority(which: ::c_int, who: ::id_t) -> ::c_int742     pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int743     pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
744     // Musl targets need the `mask` argument of `fanotify_mark` be specified
745     // `::c_ulonglong` instead of `u64` or there will be a type mismatch between
746     // `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_int747     pub fn fanotify_mark(
748         fd: ::c_int,
749         flags: ::c_uint,
750         mask: ::c_ulonglong,
751         dirfd: ::c_int,
752         path: *const ::c_char,
753     ) -> ::c_int;
getauxval(type_: ::c_ulong) -> ::c_ulong754     pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
755 
756     // Added in `musl` 1.1.20
explicit_bzero(s: *mut ::c_void, len: ::size_t)757     pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t);
758     // Added in `musl` 1.2.2
reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void759     pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
760 
adjtimex(buf: *mut ::timex) -> ::c_int761     pub fn adjtimex(buf: *mut ::timex) -> ::c_int;
clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int762     pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
763 
ctermid(s: *mut ::c_char) -> *mut ::c_char764     pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
765 
memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int766     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_int767     pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int;
768 }
769 
770 cfg_if! {
771     if #[cfg(any(target_arch = "x86_64",
772                  target_arch = "aarch64",
773                  target_arch = "mips64",
774                  target_arch = "powerpc64",
775                  target_arch = "s390x",
776                  target_arch = "riscv64"))] {
777         mod b64;
778         pub use self::b64::*;
779     } else if #[cfg(any(target_arch = "x86",
780                         target_arch = "mips",
781                         target_arch = "powerpc",
782                         target_arch = "hexagon",
783                         target_arch = "arm"))] {
784         mod b32;
785         pub use self::b32::*;
786     } else { }
787 }
788