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