Debian Codegraph @

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

raw
1 // FIXME(ulibc): this module has definitions that are redundant with the parent
2 #![allow(dead_code)]
3
4 use crate::off64_t;
5 use crate::prelude::*;
6
7 pub type shmatt_t = c_ulong;
8 pub type msgqnum_t = c_ulong;
9 pub type msglen_t = c_ulong;
10 pub type regoff_t = c_int;
11 pub type rlim_t = c_ulong;
12 pub type __rlimit_resource_t = c_ulong;
13 pub type __priority_which_t = c_uint;
14
15 cfg_if! {
16 if #[cfg(doc)] {
17 // Used in `linux::arch` to define ioctl constants.
18 pub(crate) type Ioctl = c_ulong;
19 } else {
20 #[doc(hidden)]
21 pub type Ioctl = c_ulong;
22 }
23 }
24
25 s! {
26 pub struct statvfs {
27 // Different than GNU!
28 pub f_bsize: c_ulong,
29 pub f_frsize: c_ulong,
30 pub f_blocks: crate::fsblkcnt_t,
31 pub f_bfree: crate::fsblkcnt_t,
32 pub f_bavail: crate::fsblkcnt_t,
33 pub f_files: crate::fsfilcnt_t,
34 pub f_ffree: crate::fsfilcnt_t,
35 pub f_favail: crate::fsfilcnt_t,
36 #[cfg(target_endian = "little")]
37 pub f_fsid: c_ulong,
38 #[cfg(target_pointer_width = "32")]
39 __f_unused: Padding<c_int>,
40 #[cfg(target_endian = "big")]
41 pub f_fsid: c_ulong,
42 pub f_flag: c_ulong,
43 pub f_namemax: c_ulong,
44 __f_spare: [c_int; 6],
45 }
46
47 pub struct regex_t {
48 __buffer: *mut c_void,
49 __allocated: size_t,
50 __used: size_t,
51 __syntax: c_ulong,
52 __fastmap: *mut c_char,
53 __translate: *mut c_char,
54 __re_nsub: size_t,
55 __bitfield: u8,
56 }
57
58 pub struct rtentry {
59 pub rt_pad1: c_ulong,
60 pub rt_dst: crate::sockaddr,
61 pub rt_gateway: crate::sockaddr,
62 pub rt_genmask: crate::sockaddr,
63 pub rt_flags: c_ushort,
64 pub rt_pad2: c_short,
65 pub rt_pad3: c_ulong,
66 pub rt_tos: c_uchar,
67 pub rt_class: c_uchar,
68 #[cfg(target_pointer_width = "64")]
69 pub rt_pad4: [c_short; 3usize],
70 #[cfg(not(target_pointer_width = "64"))]
71 pub rt_pad4: c_short,
72 pub rt_metric: c_short,
73 pub rt_dev: *mut c_char,
74 pub rt_mtu: c_ulong,
75 pub rt_window: c_ulong,
76 pub rt_irtt: c_ushort,
77 }
78
79 pub struct __exit_status {
80 pub e_termination: c_short,
81 pub e_exit: c_short,
82 }
83
84 pub struct ptrace_peeksiginfo_args {
85 pub off: crate::__u64,
86 pub flags: crate::__u32,
87 pub nr: crate::__s32,
88 }
89
90 #[cfg_attr(
91 any(
92 target_pointer_width = "32",
93 target_arch = "x86_64",
94 target_arch = "powerpc64",
95 target_arch = "mips64",
96 target_arch = "s390x",
97 target_arch = "sparc64"
98 ),
99 repr(align(4))
100 )]
101 #[cfg_attr(
102 not(any(
103 target_pointer_width = "32",
104 target_arch = "x86_64",
105 target_arch = "powerpc64",
106 target_arch = "mips64",
107 target_arch = "s390x",
108 target_arch = "sparc64"
109 )),
110 repr(align(8))
111 )]
112 pub struct pthread_mutexattr_t {
113 size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T],
114 }
115
116 #[repr(align(4))]
117 pub struct pthread_condattr_t {
118 size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T],
119 }
120
121 pub struct tcp_info {
122 pub tcpi_state: u8,
123 pub tcpi_ca_state: u8,
124 pub tcpi_retransmits: u8,
125 pub tcpi_probes: u8,
126 pub tcpi_backoff: u8,
127 pub tcpi_options: u8,
128 /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
129 /// Each is 4 bits.
130 pub tcpi_snd_rcv_wscale: u8,
131 pub tcpi_rto: u32,
132 pub tcpi_ato: u32,
133 pub tcpi_snd_mss: u32,
134 pub tcpi_rcv_mss: u32,
135 pub tcpi_unacked: u32,
136 pub tcpi_sacked: u32,
137 pub tcpi_lost: u32,
138 pub tcpi_retrans: u32,
139 pub tcpi_fackets: u32,
140 pub tcpi_last_data_sent: u32,
141 pub tcpi_last_ack_sent: u32,
142 pub tcpi_last_data_recv: u32,
143 pub tcpi_last_ack_recv: u32,
144 pub tcpi_pmtu: u32,
145 pub tcpi_rcv_ssthresh: u32,
146 pub tcpi_rtt: u32,
147 pub tcpi_rttvar: u32,
148 pub tcpi_snd_ssthresh: u32,
149 pub tcpi_snd_cwnd: u32,
150 pub tcpi_advmss: u32,
151 pub tcpi_reordering: u32,
152 pub tcpi_rcv_rtt: u32,
153 pub tcpi_rcv_space: u32,
154 pub tcpi_total_retrans: u32,
155 }
156 }
157
158 impl siginfo_t {
159 pub unsafe fn si_addr(&self) -> *mut c_void {
160 #[repr(C)]
161 struct siginfo_sigfault {
162 _si_signo: c_int,
163 _si_errno: c_int,
164 _si_code: c_int,
165 si_addr: *mut c_void,
166 }
167 (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
168 }
169
170 pub unsafe fn si_value(&self) -> crate::sigval {
171 #[repr(C)]
172 struct siginfo_si_value {
173 _si_signo: c_int,
174 _si_errno: c_int,
175 _si_code: c_int,
176 _si_timerid: c_int,
177 _si_overrun: c_int,
178 si_value: crate::sigval,
179 }
180 (*(self as *const siginfo_t as *const siginfo_si_value)).si_value
181 }
182 }
183
184 s_no_extra_traits! {
185 // Internal, for casts to access union fields
186 struct sifields_sigchld {
187 si_pid: crate::pid_t,
188 si_uid: crate::uid_t,
189 si_status: c_int,
190 si_utime: c_long,
191 si_stime: c_long,
192 }
193
194 // Internal, for casts to access union fields
195 union sifields {
196 _align_pointer: *mut c_void,
197 sigchld: sifields_sigchld,
198 }
199
200 // Internal, for casts to access union fields. Note that some variants
201 // of sifields start with a pointer, which makes the alignment of
202 // sifields vary on 32-bit and 64-bit architectures.
203 struct siginfo_f {
204 _siginfo_base: [c_int; 3],
205 sifields: sifields,
206 }
207 }
208
209 impl siginfo_t {
210 unsafe fn sifields(&self) -> &sifields {
211 &(*(self as *const siginfo_t as *const siginfo_f)).sifields
212 }
213
214 pub unsafe fn si_pid(&self) -> crate::pid_t {
215 self.sifields().sigchld.si_pid
216 }
217
218 pub unsafe fn si_uid(&self) -> crate::uid_t {
219 self.sifields().sigchld.si_uid
220 }
221
222 pub unsafe fn si_status(&self) -> c_int {
223 self.sifields().sigchld.si_status
224 }
225
226 pub unsafe fn si_utime(&self) -> c_long {
227 self.sifields().sigchld.si_utime
228 }
229
230 pub unsafe fn si_stime(&self) -> c_long {
231 self.sifields().sigchld.si_stime
232 }
233 }
234
235 pub const MCL_CURRENT: c_int = 0x0001;
236 pub const MCL_FUTURE: c_int = 0x0002;
237 pub const MCL_ONFAULT: c_int = 0x0004;
238
239 pub const SIGEV_THREAD_ID: c_int = 4;
240
241 pub const AF_VSOCK: c_int = 40;
242
243 // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the
244 // following are only available on newer Linux versions than the versions
245 // currently used in CI in some configurations, so we define them here.
246 pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70;
247 pub const XFS_SUPER_MAGIC: c_long = 0x58465342;
248
249 pub const PTRACE_TRACEME: c_int = 0;
250 pub const PTRACE_PEEKTEXT: c_int = 1;
251 pub const PTRACE_PEEKDATA: c_int = 2;
252 pub const PTRACE_PEEKUSER: c_int = 3;
253 pub const PTRACE_POKETEXT: c_int = 4;
254 pub const PTRACE_POKEDATA: c_int = 5;
255 pub const PTRACE_POKEUSER: c_int = 6;
256 pub const PTRACE_CONT: c_int = 7;
257 pub const PTRACE_KILL: c_int = 8;
258 pub const PTRACE_SINGLESTEP: c_int = 9;
259 pub const PTRACE_GETREGS: c_int = 12;
260 pub const PTRACE_SETREGS: c_int = 13;
261 pub const PTRACE_GETFPREGS: c_int = 14;
262 pub const PTRACE_SETFPREGS: c_int = 15;
263 pub const PTRACE_ATTACH: c_int = 16;
264 pub const PTRACE_DETACH: c_int = 17;
265 pub const PTRACE_GETFPXREGS: c_int = 18;
266 pub const PTRACE_SETFPXREGS: c_int = 19;
267 pub const PTRACE_SYSCALL: c_int = 24;
268 pub const PTRACE_SETOPTIONS: c_int = 0x4200;
269 pub const PTRACE_GETEVENTMSG: c_int = 0x4201;
270 pub const PTRACE_GETSIGINFO: c_int = 0x4202;
271 pub const PTRACE_SETSIGINFO: c_int = 0x4203;
272 pub const PTRACE_GETREGSET: c_int = 0x4204;
273 pub const PTRACE_SETREGSET: c_int = 0x4205;
274 pub const PTRACE_SEIZE: c_int = 0x4206;
275 pub const PTRACE_INTERRUPT: c_int = 0x4207;
276 pub const PTRACE_LISTEN: c_int = 0x4208;
277
278 pub const POSIX_FADV_DONTNEED: c_int = 4;
279 pub const POSIX_FADV_NOREUSE: c_int = 5;
280
281 // These are different than GNU!
282 pub const LC_CTYPE: c_int = 0;
283 pub const LC_NUMERIC: c_int = 1;
284 pub const LC_TIME: c_int = 3;
285 pub const LC_COLLATE: c_int = 4;
286 pub const LC_MONETARY: c_int = 2;
287 pub const LC_MESSAGES: c_int = 5;
288 pub const LC_ALL: c_int = 6;
289 // end different section
290
291 // MS_ flags for mount(2)
292 pub const MS_RMT_MASK: c_ulong =
293 crate::MS_RDONLY | crate::MS_SYNCHRONOUS | crate::MS_MANDLOCK | crate::MS_I_VERSION;
294
295 pub const ENOTSUP: c_int = EOPNOTSUPP;
296
297 pub const IPV6_JOIN_GROUP: c_int = 20;
298 pub const IPV6_LEAVE_GROUP: c_int = 21;
299
300 // These are different from GNU
301 pub const ABDAY_1: crate::nl_item = 0x300;
302 pub const ABDAY_2: crate::nl_item = 0x301;
303 pub const ABDAY_3: crate::nl_item = 0x302;
304 pub const ABDAY_4: crate::nl_item = 0x303;
305 pub const ABDAY_5: crate::nl_item = 0x304;
306 pub const ABDAY_6: crate::nl_item = 0x305;
307 pub const ABDAY_7: crate::nl_item = 0x306;
308 pub const DAY_1: crate::nl_item = 0x307;
309 pub const DAY_2: crate::nl_item = 0x308;
310 pub const DAY_3: crate::nl_item = 0x309;
311 pub const DAY_4: crate::nl_item = 0x30A;
312 pub const DAY_5: crate::nl_item = 0x30B;
313 pub const DAY_6: crate::nl_item = 0x30C;
314 pub const DAY_7: crate::nl_item = 0x30D;
315 pub const ABMON_1: crate::nl_item = 0x30E;
316 pub const ABMON_2: crate::nl_item = 0x30F;
317 pub const ABMON_3: crate::nl_item = 0x310;
318 pub const ABMON_4: crate::nl_item = 0x311;
319 pub const ABMON_5: crate::nl_item = 0x312;
320 pub const ABMON_6: crate::nl_item = 0x313;
321 pub const ABMON_7: crate::nl_item = 0x314;
322 pub const ABMON_8: crate::nl_item = 0x315;
323 pub const ABMON_9: crate::nl_item = 0x316;
324 pub const ABMON_10: crate::nl_item = 0x317;
325 pub const ABMON_11: crate::nl_item = 0x318;
326 pub const ABMON_12: crate::nl_item = 0x319;
327 pub const MON_1: crate::nl_item = 0x31A;
328 pub const MON_2: crate::nl_item = 0x31B;
329 pub const MON_3: crate::nl_item = 0x31C;
330 pub const MON_4: crate::nl_item = 0x31D;
331 pub const MON_5: crate::nl_item = 0x31E;
332 pub const MON_6: crate::nl_item = 0x31F;
333 pub const MON_7: crate::nl_item = 0x320;
334 pub const MON_8: crate::nl_item = 0x321;
335 pub const MON_9: crate::nl_item = 0x322;
336 pub const MON_10: crate::nl_item = 0x323;
337 pub const MON_11: crate::nl_item = 0x324;
338 pub const MON_12: crate::nl_item = 0x325;
339 pub const AM_STR: crate::nl_item = 0x326;
340 pub const PM_STR: crate::nl_item = 0x327;
341 pub const D_T_FMT: crate::nl_item = 0x328;
342 pub const D_FMT: crate::nl_item = 0x329;
343 pub const T_FMT: crate::nl_item = 0x32A;
344 pub const T_FMT_AMPM: crate::nl_item = 0x32B;
345 pub const ERA: crate::nl_item = 0x32C;
346 pub const ERA_D_FMT: crate::nl_item = 0x32E;
347 pub const ALT_DIGITS: crate::nl_item = 0x32F;
348 pub const ERA_D_T_FMT: crate::nl_item = 0x330;
349 pub const ERA_T_FMT: crate::nl_item = 0x331;
350 pub const CODESET: crate::nl_item = 10;
351 pub const CRNCYSTR: crate::nl_item = 0x215;
352 pub const RADIXCHAR: crate::nl_item = 0x100;
353 pub const THOUSEP: crate::nl_item = 0x101;
354 pub const NOEXPR: crate::nl_item = 0x501;
355 pub const YESSTR: crate::nl_item = 0x502;
356 pub const NOSTR: crate::nl_item = 0x503;
357
358 // Different than Gnu.
359 pub const FILENAME_MAX: c_uint = 4095;
360
361 pub const PRIO_PROCESS: c_int = 0;
362 pub const PRIO_PGRP: c_int = 1;
363 pub const PRIO_USER: c_int = 2;
364
365 pub const SOMAXCONN: c_int = 128;
366
367 pub const ST_RELATIME: c_ulong = 4096;
368
369 pub const AF_NFC: c_int = PF_NFC;
370 pub const BUFSIZ: c_int = 4096;
371 pub const EDEADLOCK: c_int = EDEADLK;
372 pub const EXTA: c_uint = B19200;
373 pub const EXTB: c_uint = B38400;
374 pub const EXTPROC: crate::tcflag_t = 0o200000;
375 pub const FOPEN_MAX: c_int = 16;
376 pub const F_GETOWN: c_int = 9;
377 pub const F_OFD_GETLK: c_int = 36;
378 pub const F_OFD_SETLK: c_int = 37;
379 pub const F_OFD_SETLKW: c_int = 38;
380 pub const F_RDLCK: c_int = 0;
381 pub const F_SETOWN: c_int = 8;
382 pub const F_UNLCK: c_int = 2;
383 pub const F_WRLCK: c_int = 1;
384 pub const IPV6_MULTICAST_ALL: c_int = 29;
385 pub const IPV6_ROUTER_ALERT_ISOLATE: c_int = 30;
386 pub const MAP_HUGE_SHIFT: c_int = 26;
387 pub const MAP_HUGE_MASK: c_int = 0x3f;
388 pub const MAP_HUGE_64KB: c_int = 16 << MAP_HUGE_SHIFT;
389 pub const MAP_HUGE_512KB: c_int = 19 << MAP_HUGE_SHIFT;
390 pub const MAP_HUGE_1MB: c_int = 20 << MAP_HUGE_SHIFT;
391 pub const MAP_HUGE_2MB: c_int = 21 << MAP_HUGE_SHIFT;
392 pub const MAP_HUGE_8MB: c_int = 23 << MAP_HUGE_SHIFT;
393 pub const MAP_HUGE_16MB: c_int = 24 << MAP_HUGE_SHIFT;
394 pub const MAP_HUGE_32MB: c_int = 25 << MAP_HUGE_SHIFT;
395 pub const MAP_HUGE_256MB: c_int = 28 << MAP_HUGE_SHIFT;
396 pub const MAP_HUGE_512MB: c_int = 29 << MAP_HUGE_SHIFT;
397 pub const MAP_HUGE_1GB: c_int = 30 << MAP_HUGE_SHIFT;
398 pub const MAP_HUGE_2GB: c_int = 31 << MAP_HUGE_SHIFT;
399 pub const MAP_HUGE_16GB: c_int = 34 << MAP_HUGE_SHIFT;
400 pub const MINSIGSTKSZ: c_int = 2048;
401 pub const MSG_COPY: c_int = 0o40000;
402 pub const NI_MAXHOST: crate::socklen_t = 1025;
403 pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY;
404 pub const PACKET_MR_UNICAST: c_int = 3;
405 pub const PF_NFC: c_int = 39;
406 pub const PF_VSOCK: c_int = 40;
407 pub const PTRACE_EVENT_STOP: c_int = 128;
408 pub const PTRACE_GETSIGMASK: c_uint = 0x420a;
409 pub const PTRACE_PEEKSIGINFO: c_int = 0x4209;
410 pub const PTRACE_SETSIGMASK: c_uint = 0x420b;
411 pub const RTLD_NOLOAD: c_int = 0x00004;
412 pub const RUSAGE_THREAD: c_int = 1;
413 pub const SHM_EXEC: c_int = 0o100000;
414 pub const SIGPOLL: c_int = SIGIO;
415 pub const SOCK_DCCP: c_int = 6;
416 #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")]
417 pub const SOCK_PACKET: c_int = 10;
418 pub const TCP_COOKIE_TRANSACTIONS: c_int = 15;
419 pub const UDP_GRO: c_int = 104;
420 pub const UDP_SEGMENT: c_int = 103;
421 pub const YESEXPR: c_int = ((5) << 8) | (0);
422
423 extern "C" {
424 pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int;
425
426 pub fn pthread_rwlockattr_getkind_np(
427 attr: *const crate::pthread_rwlockattr_t,
428 val: *mut c_int,
429 ) -> c_int;
430 pub fn pthread_rwlockattr_setkind_np(
431 attr: *mut crate::pthread_rwlockattr_t,
432 val: c_int,
433 ) -> c_int;
434
435 pub fn ptrace(request: c_uint, ...) -> c_long;
436
437 pub fn sendmmsg(
438 sockfd: c_int,
439 msgvec: *mut crate::mmsghdr,
440 vlen: c_uint,
441 flags: c_int,
442 ) -> c_int;
443 pub fn recvmmsg(
444 sockfd: c_int,
445 msgvec: *mut crate::mmsghdr,
446 vlen: c_uint,
447 flags: c_int,
448 timeout: *mut crate::timespec,
449 ) -> c_int;
450
451 pub fn openpty(
452 amaster: *mut c_int,
453 aslave: *mut c_int,
454 name: *mut c_char,
455 termp: *mut termios,
456 winp: *mut crate::winsize,
457 ) -> c_int;
458 pub fn forkpty(
459 amaster: *mut c_int,
460 name: *mut c_char,
461 termp: *mut termios,
462 winp: *mut crate::winsize,
463 ) -> crate::pid_t;
464
465 pub fn getnameinfo(
466 sa: *const crate::sockaddr,
467 salen: crate::socklen_t,
468 host: *mut c_char,
469 hostlen: crate::socklen_t,
470 serv: *mut c_char,
471 servlen: crate::socklen_t,
472 flags: c_int,
473 ) -> c_int;
474
475 pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
476 pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
477
478 pub fn sethostid(hostid: c_long) -> c_int;
479 pub fn fanotify_mark(
480 fd: c_int,
481 flags: c_uint,
482 mask: u64,
483 dirfd: c_int,
484 path: *const c_char,
485 ) -> c_int;
486 pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int;
487 pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64)
488 -> c_int;
489 pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int;
490 pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int;
491 pub fn getpriority(which: crate::__priority_which_t, who: crate::id_t) -> c_int;
492 pub fn setpriority(which: crate::__priority_which_t, who: crate::id_t, prio: c_int) -> c_int;
493 pub fn getauxval(type_: c_ulong) -> c_ulong;
494 }
495
496 cfg_if! {
497 if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] {
498 mod mips;
499 pub use self::mips::*;
500 } else if #[cfg(target_arch = "x86_64")] {
501 mod x86_64;
502 pub use self::x86_64::*;
503 } else if #[cfg(target_arch = "arm")] {
504 mod arm;
505 pub use self::arm::*;
506 } else {
507 pub use unsupported_target;
508 }
509 }