Debian Codegraph @

debian/missing-sources/libc/src/unix/linux_like/linux/musl/mod.rs

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