interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / unix / linux_like / linux / musl / mod.rs

919 lines · 29490 bytes Raw Blame History
1use crate::off64_t;
2use crate::prelude::*;
3
4pub type pthread_t = *mut c_void;
5pub type clock_t = c_long;
6#[cfg(musl32_time64)]
7pub 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)]
18pub type time_t = c_long;
19#[cfg(musl32_time64)]
20pub 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)]
31pub type suseconds_t = c_long;
32pub type ino_t = u64;
33pub type off_t = i64;
34pub type blkcnt_t = i64;
35
36pub type shmatt_t = c_ulong;
37pub type msgqnum_t = c_ulong;
38pub type msglen_t = c_ulong;
39pub type fsblkcnt_t = c_ulonglong;
40pub type fsblkcnt64_t = c_ulonglong;
41pub type fsfilcnt_t = c_ulonglong;
42pub type fsfilcnt64_t = c_ulonglong;
43pub type rlim_t = c_ulonglong;
44
45cfg_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
55impl 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).cast::<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).cast::<siginfo_si_value>()).si_value
78 }
79}
80
81s_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
106impl siginfo_t {
107 unsafe fn sifields(&self) -> &sifields {
108 &(*(self as *const siginfo_t).cast::<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
132s! {
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 */
494pub const MAP_HUGE_SHIFT: c_int = 26;
495pub const MAP_HUGE_MASK: c_int = 0x3f;
496
497pub const MAP_HUGE_64KB: c_int = 16 << MAP_HUGE_SHIFT;
498pub const MAP_HUGE_512KB: c_int = 19 << MAP_HUGE_SHIFT;
499pub const MAP_HUGE_1MB: c_int = 20 << MAP_HUGE_SHIFT;
500pub const MAP_HUGE_2MB: c_int = 21 << MAP_HUGE_SHIFT;
501pub const MAP_HUGE_8MB: c_int = 23 << MAP_HUGE_SHIFT;
502pub const MAP_HUGE_16MB: c_int = 24 << MAP_HUGE_SHIFT;
503pub const MAP_HUGE_32MB: c_int = 25 << MAP_HUGE_SHIFT;
504pub const MAP_HUGE_256MB: c_int = 28 << MAP_HUGE_SHIFT;
505pub const MAP_HUGE_512MB: c_int = 29 << MAP_HUGE_SHIFT;
506pub const MAP_HUGE_1GB: c_int = 30 << MAP_HUGE_SHIFT;
507pub const MAP_HUGE_2GB: c_int = 31 << MAP_HUGE_SHIFT;
508pub const MAP_HUGE_16GB: c_int = 34 << MAP_HUGE_SHIFT;
509
510// include/utmpx.h
511pub const EMPTY: c_short = 0;
512pub const RUN_LVL: c_short = 1;
513pub const BOOT_TIME: c_short = 2;
514pub const NEW_TIME: c_short = 3;
515pub const OLD_TIME: c_short = 4;
516pub const INIT_PROCESS: c_short = 5;
517pub const LOGIN_PROCESS: c_short = 6;
518pub const USER_PROCESS: c_short = 7;
519pub const DEAD_PROCESS: c_short = 8;
520pub const ACCOUNTING: c_short = 9;
521
522pub const SFD_CLOEXEC: c_int = 0x080000;
523
524#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
525pub const NCCS: usize = 32;
526#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
527pub const NCCS: usize = 19;
528
529pub const O_TRUNC: c_int = 512;
530pub const O_NOATIME: c_int = 0o1000000;
531pub const O_CLOEXEC: c_int = 0x80000;
532pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY;
533
534pub const EBFONT: c_int = 59;
535pub const ENOSTR: c_int = 60;
536pub const ENODATA: c_int = 61;
537pub const ETIME: c_int = 62;
538pub const ENOSR: c_int = 63;
539pub const ENONET: c_int = 64;
540pub const ENOPKG: c_int = 65;
541pub const EREMOTE: c_int = 66;
542pub const ENOLINK: c_int = 67;
543pub const EADV: c_int = 68;
544pub const ESRMNT: c_int = 69;
545pub const ECOMM: c_int = 70;
546pub const EPROTO: c_int = 71;
547pub const EDOTDOT: c_int = 73;
548
549pub const F_OFD_GETLK: c_int = 36;
550pub const F_OFD_SETLK: c_int = 37;
551pub const F_OFD_SETLKW: c_int = 38;
552
553pub const F_RDLCK: c_int = 0;
554pub const F_WRLCK: c_int = 1;
555pub const F_UNLCK: c_int = 2;
556
557pub const SA_NODEFER: c_int = 0x40000000;
558pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000);
559pub const SA_RESTART: c_int = 0x10000000;
560pub const SA_NOCLDSTOP: c_int = 0x00000001;
561
562pub const EPOLL_CLOEXEC: c_int = 0x80000;
563
564pub const EFD_CLOEXEC: c_int = 0x80000;
565
566pub const BUFSIZ: c_uint = 1024;
567pub const TMP_MAX: c_uint = 10000;
568pub const FOPEN_MAX: c_uint = 1000;
569pub const FILENAME_MAX: c_uint = 4096;
570pub const O_PATH: c_int = 0o10000000;
571pub const O_EXEC: c_int = 0o10000000;
572pub const O_SEARCH: c_int = 0o10000000;
573pub const O_ACCMODE: c_int = 0o10000003;
574pub const O_NDELAY: c_int = O_NONBLOCK;
575pub const NI_MAXHOST: crate::socklen_t = 255;
576pub const PTHREAD_STACK_MIN: size_t = 2048;
577
578pub const MAP_ANONYMOUS: c_int = MAP_ANON;
579
580pub const SOCK_SEQPACKET: c_int = 5;
581pub const SOCK_DCCP: c_int = 6;
582pub const SOCK_NONBLOCK: c_int = O_NONBLOCK;
583#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")]
584pub const SOCK_PACKET: c_int = 10;
585
586pub const SOMAXCONN: c_int = 128;
587
588#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
589pub const SIGUNUSED: c_int = crate::SIGSYS;
590
591pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
592pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
593pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
594pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
595
596// Value was changed in 1.2.4
597pub const CPU_SETSIZE: c_int = if cfg!(musl_v1_2_3) { 1024 } else { 128 };
598
599pub const PTRACE_TRACEME: c_int = 0;
600pub const PTRACE_PEEKTEXT: c_int = 1;
601pub const PTRACE_PEEKDATA: c_int = 2;
602pub const PTRACE_PEEKUSER: c_int = 3;
603pub const PTRACE_POKETEXT: c_int = 4;
604pub const PTRACE_POKEDATA: c_int = 5;
605pub const PTRACE_POKEUSER: c_int = 6;
606pub const PTRACE_CONT: c_int = 7;
607pub const PTRACE_KILL: c_int = 8;
608pub const PTRACE_SINGLESTEP: c_int = 9;
609pub const PTRACE_GETREGS: c_int = 12;
610pub const PTRACE_SETREGS: c_int = 13;
611pub const PTRACE_GETFPREGS: c_int = 14;
612pub const PTRACE_SETFPREGS: c_int = 15;
613pub const PTRACE_ATTACH: c_int = 16;
614pub const PTRACE_DETACH: c_int = 17;
615pub const PTRACE_GETFPXREGS: c_int = 18;
616pub const PTRACE_SETFPXREGS: c_int = 19;
617pub const PTRACE_SYSCALL: c_int = 24;
618pub const PTRACE_SETOPTIONS: c_int = 0x4200;
619pub const PTRACE_GETEVENTMSG: c_int = 0x4201;
620pub const PTRACE_GETSIGINFO: c_int = 0x4202;
621pub const PTRACE_SETSIGINFO: c_int = 0x4203;
622pub const PTRACE_GETREGSET: c_int = 0x4204;
623pub const PTRACE_SETREGSET: c_int = 0x4205;
624pub const PTRACE_SEIZE: c_int = 0x4206;
625pub const PTRACE_INTERRUPT: c_int = 0x4207;
626pub const PTRACE_LISTEN: c_int = 0x4208;
627pub const PTRACE_PEEKSIGINFO: c_int = 0x4209;
628pub const PTRACE_GETSIGMASK: c_uint = 0x420a;
629pub const PTRACE_SETSIGMASK: c_uint = 0x420b;
630
631pub const AF_IB: c_int = 27;
632pub const AF_MPLS: c_int = 28;
633pub const AF_NFC: c_int = 39;
634pub const AF_VSOCK: c_int = 40;
635pub const AF_XDP: c_int = 44;
636pub const PF_IB: c_int = AF_IB;
637pub const PF_MPLS: c_int = AF_MPLS;
638pub const PF_NFC: c_int = AF_NFC;
639pub const PF_VSOCK: c_int = AF_VSOCK;
640pub const PF_XDP: c_int = AF_XDP;
641
642pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK;
643
644pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK;
645
646pub const TCSANOW: c_int = 0;
647pub const TCSADRAIN: c_int = 1;
648pub const TCSAFLUSH: c_int = 2;
649
650pub const RTLD_GLOBAL: c_int = 0x100;
651pub const RTLD_NOLOAD: c_int = 0x4;
652
653pub const CLOCK_SGI_CYCLE: crate::clockid_t = 10;
654
655pub const B0: crate::speed_t = 0o000000;
656pub const B50: crate::speed_t = 0o000001;
657pub const B75: crate::speed_t = 0o000002;
658pub const B110: crate::speed_t = 0o000003;
659pub const B134: crate::speed_t = 0o000004;
660pub const B150: crate::speed_t = 0o000005;
661pub const B200: crate::speed_t = 0o000006;
662pub const B300: crate::speed_t = 0o000007;
663pub const B600: crate::speed_t = 0o000010;
664pub const B1200: crate::speed_t = 0o000011;
665pub const B1800: crate::speed_t = 0o000012;
666pub const B2400: crate::speed_t = 0o000013;
667pub const B4800: crate::speed_t = 0o000014;
668pub const B9600: crate::speed_t = 0o000015;
669pub const B19200: crate::speed_t = 0o000016;
670pub const B38400: crate::speed_t = 0o000017;
671pub const EXTA: crate::speed_t = B19200;
672pub const EXTB: crate::speed_t = B38400;
673
674pub const REG_OK: c_int = 0;
675
676pub const PRIO_PROCESS: c_int = 0;
677pub const PRIO_PGRP: c_int = 1;
678pub const PRIO_USER: c_int = 2;
679
680pub const ADJ_OFFSET: c_uint = 0x0001;
681pub const ADJ_FREQUENCY: c_uint = 0x0002;
682pub const ADJ_MAXERROR: c_uint = 0x0004;
683pub const ADJ_ESTERROR: c_uint = 0x0008;
684pub const ADJ_STATUS: c_uint = 0x0010;
685pub const ADJ_TIMECONST: c_uint = 0x0020;
686pub const ADJ_TAI: c_uint = 0x0080;
687pub const ADJ_SETOFFSET: c_uint = 0x0100;
688pub const ADJ_MICRO: c_uint = 0x1000;
689pub const ADJ_NANO: c_uint = 0x2000;
690pub const ADJ_TICK: c_uint = 0x4000;
691pub const ADJ_OFFSET_SINGLESHOT: c_uint = 0x8001;
692pub const ADJ_OFFSET_SS_READ: c_uint = 0xa001;
693pub const MOD_OFFSET: c_uint = ADJ_OFFSET;
694pub const MOD_FREQUENCY: c_uint = ADJ_FREQUENCY;
695pub const MOD_MAXERROR: c_uint = ADJ_MAXERROR;
696pub const MOD_ESTERROR: c_uint = ADJ_ESTERROR;
697pub const MOD_STATUS: c_uint = ADJ_STATUS;
698pub const MOD_TIMECONST: c_uint = ADJ_TIMECONST;
699pub const MOD_CLKB: c_uint = ADJ_TICK;
700pub const MOD_CLKA: c_uint = ADJ_OFFSET_SINGLESHOT;
701pub const MOD_TAI: c_uint = ADJ_TAI;
702pub const MOD_MICRO: c_uint = ADJ_MICRO;
703pub const MOD_NANO: c_uint = ADJ_NANO;
704pub const STA_PLL: c_int = 0x0001;
705pub const STA_PPSFREQ: c_int = 0x0002;
706pub const STA_PPSTIME: c_int = 0x0004;
707pub const STA_FLL: c_int = 0x0008;
708pub const STA_INS: c_int = 0x0010;
709pub const STA_DEL: c_int = 0x0020;
710pub const STA_UNSYNC: c_int = 0x0040;
711pub const STA_FREQHOLD: c_int = 0x0080;
712pub const STA_PPSSIGNAL: c_int = 0x0100;
713pub const STA_PPSJITTER: c_int = 0x0200;
714pub const STA_PPSWANDER: c_int = 0x0400;
715pub const STA_PPSERROR: c_int = 0x0800;
716pub const STA_CLOCKERR: c_int = 0x1000;
717pub const STA_NANO: c_int = 0x2000;
718pub const STA_MODE: c_int = 0x4000;
719pub const STA_CLK: c_int = 0x8000;
720pub const STA_RONLY: c_int = STA_PPSSIGNAL
721 | STA_PPSJITTER
722 | STA_PPSWANDER
723 | STA_PPSERROR
724 | STA_CLOCKERR
725 | STA_NANO
726 | STA_MODE
727 | STA_CLK;
728
729pub const TIME_OK: c_int = 0;
730pub const TIME_INS: c_int = 1;
731pub const TIME_DEL: c_int = 2;
732pub const TIME_OOP: c_int = 3;
733pub const TIME_WAIT: c_int = 4;
734pub const TIME_ERROR: c_int = 5;
735pub const TIME_BAD: c_int = TIME_ERROR;
736pub const MAXTC: c_long = 6;
737
738pub const _CS_V6_ENV: c_int = 1148;
739pub const _CS_V7_ENV: c_int = 1149;
740
741pub const CLONE_NEWTIME: c_int = 0x80;
742
743pub const UT_HOSTSIZE: usize = 256;
744pub const UT_LINESIZE: usize = 32;
745pub const UT_NAMESIZE: usize = 32;
746
747cfg_if! {
748 if #[cfg(target_arch = "s390x")] {
749 pub const POSIX_FADV_DONTNEED: c_int = 6;
750 pub const POSIX_FADV_NOREUSE: c_int = 7;
751 } else {
752 pub const POSIX_FADV_DONTNEED: c_int = 4;
753 pub const POSIX_FADV_NOREUSE: c_int = 5;
754 }
755}
756
757extern "C" {
758 pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int;
759 pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int;
760 pub fn prlimit(
761 pid: crate::pid_t,
762 resource: c_int,
763 new_limit: *const crate::rlimit,
764 old_limit: *mut crate::rlimit,
765 ) -> c_int;
766 #[cfg_attr(musl_redir_time64, link_name = "__gettimeofday_time64")]
767 pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int;
768 pub fn ptrace(request: c_int, ...) -> c_long;
769 pub fn getpriority(which: c_int, who: crate::id_t) -> c_int;
770 pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;
771 // Musl targets need the `mask` argument of `fanotify_mark` be specified
772 // `c_ulonglong` instead of `u64` or there will be a type mismatch between
773 // `long long unsigned int` and the expected `uint64_t`.
774 pub fn fanotify_mark(
775 fd: c_int,
776 flags: c_uint,
777 mask: c_ulonglong,
778 dirfd: c_int,
779 path: *const c_char,
780 ) -> c_int;
781 pub fn preadv2(
782 fd: c_int,
783 iov: *const crate::iovec,
784 iovcnt: c_int,
785 offset: off_t,
786 flags: c_int,
787 ) -> ssize_t;
788 pub fn pwritev2(
789 fd: c_int,
790 iov: *const crate::iovec,
791 iovcnt: c_int,
792 offset: off_t,
793 flags: c_int,
794 ) -> ssize_t;
795 pub fn getauxval(type_: c_ulong) -> c_ulong;
796 pub fn renameat2(
797 olddirfd: c_int,
798 oldpath: *const c_char,
799 newdirfd: c_int,
800 newpath: *const c_char,
801 flags: c_uint,
802 ) -> c_int;
803
804 // Added in `musl` 1.1.20
805 pub fn explicit_bzero(s: *mut c_void, len: size_t);
806 // Added in `musl` 1.2.2
807 pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void;
808
809 #[cfg_attr(musl_redir_time64, link_name = "__adjtimex_time64")]
810 pub fn adjtimex(buf: *mut crate::timex) -> c_int;
811 #[cfg_attr(musl_redir_time64, link_name = "__clock_adjtime64")]
812 pub fn clock_adjtime(clk_id: crate::clockid_t, buf: *mut crate::timex) -> c_int;
813
814 pub fn ctermid(s: *mut c_char) -> *mut c_char;
815
816 pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int;
817 pub fn mlock2(addr: *const c_void, len: size_t, flags: c_uint) -> c_int;
818 pub fn malloc_usable_size(ptr: *mut c_void) -> size_t;
819
820 pub fn euidaccess(pathname: *const c_char, mode: c_int) -> c_int;
821 pub fn eaccess(pathname: *const c_char, mode: c_int) -> c_int;
822
823 pub fn asctime_r(tm: *const crate::tm, buf: *mut c_char) -> *mut c_char;
824
825 pub fn dirname(path: *mut c_char) -> *mut c_char;
826 pub fn basename(path: *mut c_char) -> *mut c_char;
827
828 // Added in `musl` 1.1.20
829 pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t;
830
831 // Added in `musl` 1.1.24
832 pub fn posix_spawn_file_actions_addchdir_np(
833 actions: *mut crate::posix_spawn_file_actions_t,
834 path: *const c_char,
835 ) -> c_int;
836 // Added in `musl` 1.1.24
837 pub fn posix_spawn_file_actions_addfchdir_np(
838 actions: *mut crate::posix_spawn_file_actions_t,
839 fd: c_int,
840 ) -> c_int;
841
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 getutxent() -> *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 getutxid(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 getutxline(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 pututxline(ut: *const utmpx) -> *mut utmpx;
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 setutxent();
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 endutxent();
872 #[deprecated(
873 since = "0.2.172",
874 note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
875 )]
876 pub fn utmpxname(file: *const c_char) -> c_int;
877 pub fn pthread_tryjoin_np(thread: crate::pthread_t, retval: *mut *mut c_void) -> c_int;
878 #[cfg_attr(
879 all(musl_redir_time64, target_pointer_width = "32"),
880 link_name = "__pthread_timedjoin_np_time64"
881 )]
882 pub fn pthread_timedjoin_np(
883 thread: crate::pthread_t,
884 retval: *mut *mut c_void,
885 abstime: *const crate::timespec,
886 ) -> c_int;
887}
888
889// Alias <foo> to <foo>64 to mimic glibc's LFS64 support
890mod lfs64;
891pub use self::lfs64::*;
892
893cfg_if! {
894 if #[cfg(any(
895 target_arch = "x86_64",
896 target_arch = "aarch64",
897 target_arch = "mips64",
898 target_arch = "powerpc64",
899 target_arch = "s390x",
900 target_arch = "riscv64",
901 target_arch = "loongarch64",
902 // musl-linux ABI for wasm32 follows b64 convention
903 target_arch = "wasm32",
904 ))] {
905 mod b64;
906 pub use self::b64::*;
907 } else if #[cfg(any(
908 target_arch = "x86",
909 target_arch = "mips",
910 target_arch = "powerpc",
911 target_arch = "hexagon",
912 target_arch = "riscv32",
913 target_arch = "arm"
914 ))] {
915 mod b32;
916 pub use self::b32::*;
917 } else {
918 }
919}