Debian Codegraph @

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

raw
1 use crate::off64_t;
2 use crate::prelude::*;
3
4 pub type shmatt_t = c_ulong;
5 pub type regoff_t = c_int;
6 pub type rlim_t = c_ulong;
7 pub type __rlimit_resource_t = c_int;
8 pub type __priority_which_t = c_uint;
9
10 pub type _pthread_descr = *mut c_void;
11 pub type __pthread_cond_align_t = c_long;
12
13 cfg_if! {
14 if #[cfg(doc)] {
15 // Used in `linux::arch` to define ioctl constants.
16 pub(crate) type Ioctl = c_ulong;
17 } else {
18 #[doc(hidden)]
19 pub type Ioctl = c_ulong;
20 }
21 }
22
23 s! {
24 pub struct cmsghdr {
25 pub cmsg_len: crate::size_t,
26 pub cmsg_level: c_int,
27 pub cmsg_type: c_int,
28 }
29
30 pub struct msghdr {
31 pub msg_name: *mut c_void,
32 pub msg_namelen: crate::socklen_t,
33 pub msg_iov: *mut crate::iovec,
34 #[cfg(target_pointer_width = "32")]
35 pub msg_iovlen: c_int,
36 #[cfg(target_pointer_width = "64")]
37 pub msg_iovlen: crate::size_t,
38 pub msg_control: *mut c_void,
39 #[cfg(target_pointer_width = "32")]
40 pub msg_controllen: crate::socklen_t,
41 #[cfg(target_pointer_width = "64")]
42 pub msg_controllen: crate::size_t,
43 pub msg_flags: c_int,
44 }
45
46 pub struct statfs {
47 pub f_type: fsword_t,
48 pub f_bsize: fsword_t,
49 pub f_blocks: crate::fsblkcnt_t,
50 pub f_bfree: crate::fsblkcnt_t,
51 pub f_bavail: crate::fsblkcnt_t,
52 pub f_files: crate::fsfilcnt_t,
53 pub f_ffree: crate::fsfilcnt_t,
54 pub f_fsid: crate::fsid_t,
55 pub f_namelen: fsword_t,
56 pub f_frsize: fsword_t,
57 pub f_flags: fsword_t,
58 pub f_spare: [fsword_t; 4],
59 }
60
61 pub struct statfs64 {
62 pub f_type: fsword_t,
63 pub f_bsize: fsword_t,
64 pub f_blocks: crate::fsblkcnt64_t,
65 pub f_bfree: crate::fsblkcnt64_t,
66 pub f_bavail: crate::fsblkcnt64_t,
67 pub f_files: crate::fsfilcnt64_t,
68 pub f_ffree: crate::fsfilcnt64_t,
69 pub f_fsid: crate::fsid_t,
70 pub f_namelen: fsword_t,
71 pub f_frsize: fsword_t,
72 pub f_flags: fsword_t,
73 pub f_spare: [fsword_t; 4],
74 }
75
76 pub struct statvfs64 {
77 pub f_bsize: c_ulong,
78 pub f_frsize: c_ulong,
79 pub f_blocks: crate::fsfilcnt64_t,
80 pub f_bfree: crate::fsfilcnt64_t,
81 pub f_bavail: crate::fsfilcnt64_t,
82 pub f_files: crate::fsfilcnt64_t,
83 pub f_ffree: crate::fsfilcnt64_t,
84 pub f_favail: crate::fsfilcnt64_t,
85 pub f_fsid: c_ulong,
86 pub f_flag: c_ulong,
87 pub f_namemax: c_ulong,
88 pub __f_spare: [c_int; 6],
89 }
90
91 pub struct ipc_perm {
92 pub __key: crate::key_t,
93 pub uid: crate::uid_t,
94 pub gid: crate::gid_t,
95 pub cuid: crate::uid_t,
96 pub cgid: crate::gid_t,
97 #[cfg(target_pointer_width = "32")]
98 pub mode: c_ushort,
99 #[cfg(target_pointer_width = "64")]
100 pub mode: c_uint,
101 #[cfg(target_pointer_width = "32")]
102 __pad1: c_ushort,
103 pub __seq: c_ushort,
104 __pad2: c_ushort,
105 __unused1: c_ulong,
106 __unused2: c_ulong,
107 }
108
109 pub struct statvfs {
110 // Different than GNU!
111 pub f_bsize: c_ulong,
112 pub f_frsize: c_ulong,
113 pub f_blocks: crate::fsblkcnt_t,
114 pub f_bfree: crate::fsblkcnt_t,
115 pub f_bavail: crate::fsblkcnt_t,
116 pub f_files: crate::fsfilcnt_t,
117 pub f_ffree: crate::fsfilcnt_t,
118 pub f_favail: crate::fsfilcnt_t,
119 #[cfg(target_endian = "little")]
120 pub f_fsid: c_ulong,
121 #[cfg(target_pointer_width = "32")]
122 __f_unused: c_int,
123 #[cfg(target_endian = "big")]
124 pub f_fsid: c_ulong,
125 pub f_flag: c_ulong,
126 pub f_namemax: c_ulong,
127 __f_spare: [c_int; 6],
128 }
129
130 pub struct sysinfo {
131 pub uptime: c_long,
132 pub loads: [c_ulong; 3],
133 pub totalram: c_ulong,
134 pub freeram: c_ulong,
135 pub sharedram: c_ulong,
136 pub bufferram: c_ulong,
137 pub totalswap: c_ulong,
138 pub freeswap: c_ulong,
139 pub procs: c_ushort,
140 pub pad: c_ushort,
141 pub totalhigh: c_ulong,
142 pub freehigh: c_ulong,
143 pub mem_unit: c_uint,
144 #[cfg(target_pointer_width = "32")]
145 pub _f: [c_char; 8],
146 #[cfg(target_pointer_width = "64")]
147 pub _f: [c_char; 0],
148 }
149
150 pub struct regex_t {
151 __buffer: *mut c_void,
152 __allocated: size_t,
153 __used: size_t,
154 __syntax: c_ulong,
155 __fastmap: *mut c_char,
156 __translate: *mut c_char,
157 __re_nsub: size_t,
158 __bitfield: u8,
159 }
160
161 pub struct rtentry {
162 pub rt_pad1: c_ulong,
163 pub rt_dst: crate::sockaddr,
164 pub rt_gateway: crate::sockaddr,
165 pub rt_genmask: crate::sockaddr,
166 pub rt_flags: c_ushort,
167 pub rt_pad2: c_short,
168 pub rt_pad3: c_ulong,
169 pub rt_tos: c_uchar,
170 pub rt_class: c_uchar,
171 #[cfg(target_pointer_width = "64")]
172 pub rt_pad4: [c_short; 3usize],
173 #[cfg(not(target_pointer_width = "64"))]
174 pub rt_pad4: c_short,
175 pub rt_metric: c_short,
176 pub rt_dev: *mut c_char,
177 pub rt_mtu: c_ulong,
178 pub rt_window: c_ulong,
179 pub rt_irtt: c_ushort,
180 }
181
182 pub struct __exit_status {
183 pub e_termination: c_short,
184 pub e_exit: c_short,
185 }
186
187 pub struct tcp_info {
188 pub tcpi_state: u8,
189 pub tcpi_ca_state: u8,
190 pub tcpi_retransmits: u8,
191 pub tcpi_probes: u8,
192 pub tcpi_backoff: u8,
193 pub tcpi_options: u8,
194 /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
195 /// Each is 4 bits.
196 pub tcpi_snd_rcv_wscale: u8,
197 pub tcpi_rto: u32,
198 pub tcpi_ato: u32,
199 pub tcpi_snd_mss: u32,
200 pub tcpi_rcv_mss: u32,
201 pub tcpi_unacked: u32,
202 pub tcpi_sacked: u32,
203 pub tcpi_lost: u32,
204 pub tcpi_retrans: u32,
205 pub tcpi_fackets: u32,
206 pub tcpi_last_data_sent: u32,
207 pub tcpi_last_ack_sent: u32,
208 pub tcpi_last_data_recv: u32,
209 pub tcpi_last_ack_recv: u32,
210 pub tcpi_pmtu: u32,
211 pub tcpi_rcv_ssthresh: u32,
212 pub tcpi_rtt: u32,
213 pub tcpi_rttvar: u32,
214 pub tcpi_snd_ssthresh: u32,
215 pub tcpi_snd_cwnd: u32,
216 pub tcpi_advmss: u32,
217 pub tcpi_reordering: u32,
218 pub tcpi_rcv_rtt: u32,
219 pub tcpi_rcv_space: u32,
220 pub tcpi_total_retrans: u32,
221 }
222
223 pub struct __sched_param {
224 __sched_priority: c_int,
225 }
226
227 pub struct _pthread_fastlock {
228 __status: c_long,
229 __spinlock: c_int,
230 }
231
232 pub struct pthread_cond_t {
233 __c_lock: _pthread_fastlock,
234 __c_waiting: _pthread_descr,
235 __padding: [u8; PTHREAD_COND_PADDING_SIZE],
236 __align: __pthread_cond_align_t,
237 }
238
239 pub struct pthread_condattr_t {
240 __dummy: c_int,
241 }
242
243 pub struct pthread_mutex_t {
244 __m_reserved: c_int,
245 __m_count: c_int,
246 __m_owner: _pthread_descr,
247 __m_kind: c_int,
248 __m_lock: _pthread_fastlock,
249 }
250
251 pub struct pthread_mutexattr_t {
252 __mutexkind: c_int,
253 }
254
255 pub struct pthread_rwlock_t {
256 __rw_lock: _pthread_fastlock,
257 __rw_readers: c_int,
258 __rw_writer: _pthread_descr,
259 __rw_read_waiting: _pthread_descr,
260 __rw_write_waiting: _pthread_descr,
261 __rw_kind: c_int,
262 __rw_pshared: c_int,
263 }
264
265 pub struct pthread_rwlockattr_t {
266 __lockkind: c_int,
267 __pshared: c_int,
268 }
269
270 pub struct pthread_barrier_t {
271 __ba_lock: _pthread_fastlock,
272 __ba_required: c_int,
273 __ba_present: c_int,
274 __ba_waiting: _pthread_descr,
275 }
276
277 pub struct pthread_barrierattr_t {
278 __pshared: c_int,
279 }
280 }
281
282 impl siginfo_t {
283 pub unsafe fn si_addr(&self) -> *mut c_void {
284 #[repr(C)]
285 struct siginfo_sigfault {
286 _si_signo: c_int,
287 _si_errno: c_int,
288 _si_code: c_int,
289 si_addr: *mut c_void,
290 }
291 (*core::ptr::from_ref(self).cast::<siginfo_sigfault>()).si_addr
292 }
293
294 pub unsafe fn si_value(&self) -> crate::sigval {
295 #[repr(C)]
296 struct siginfo_si_value {
297 _si_signo: c_int,
298 _si_errno: c_int,
299 _si_code: c_int,
300 _si_timerid: c_int,
301 _si_overrun: c_int,
302 si_value: crate::sigval,
303 }
304 (*core::ptr::from_ref(self).cast::<siginfo_si_value>()).si_value
305 }
306 }
307
308 s_no_extra_traits! {
309 // Internal, for casts to access union fields
310 struct sifields_sigchld {
311 si_pid: crate::pid_t,
312 si_uid: crate::uid_t,
313 si_status: c_int,
314 si_utime: c_long,
315 si_stime: c_long,
316 }
317
318 // Internal, for casts to access union fields
319 union sifields {
320 _align_pointer: *mut c_void,
321 sigchld: sifields_sigchld,
322 }
323
324 // Internal, for casts to access union fields. Note that some variants
325 // of sifields start with a pointer, which makes the alignment of
326 // sifields vary on 32-bit and 64-bit architectures.
327 struct siginfo_f {
328 _siginfo_base: [c_int; 3],
329 sifields: sifields,
330 }
331 }
332
333 impl siginfo_t {
334 unsafe fn sifields(&self) -> &sifields {
335 &(*core::ptr::from_ref(self).cast::<siginfo_f>()).sifields
336 }
337
338 pub unsafe fn si_pid(&self) -> crate::pid_t {
339 self.sifields().sigchld.si_pid
340 }
341
342 pub unsafe fn si_uid(&self) -> crate::uid_t {
343 self.sifields().sigchld.si_uid
344 }
345
346 pub unsafe fn si_status(&self) -> c_int {
347 self.sifields().sigchld.si_status
348 }
349
350 pub unsafe fn si_utime(&self) -> c_long {
351 self.sifields().sigchld.si_utime
352 }
353
354 pub unsafe fn si_stime(&self) -> c_long {
355 self.sifields().sigchld.si_stime
356 }
357 }
358
359 pub const MCL_CURRENT: c_int = 0x0001;
360 pub const MCL_FUTURE: c_int = 0x0002;
361 pub const MCL_ONFAULT: c_int = 0x0004;
362
363 pub const SIGEV_THREAD_ID: c_int = 4;
364
365 pub const AF_VSOCK: c_int = 40;
366
367 pub const POSIX_FADV_DONTNEED: c_int = 4;
368 pub const POSIX_FADV_NOREUSE: c_int = 5;
369
370 // These are different than GNU!
371 pub const LC_CTYPE: c_int = 0;
372 pub const LC_NUMERIC: c_int = 1;
373 pub const LC_TIME: c_int = 3;
374 pub const LC_COLLATE: c_int = 4;
375 pub const LC_MONETARY: c_int = 2;
376 pub const LC_MESSAGES: c_int = 5;
377 pub const LC_ALL: c_int = 6;
378 // end different section
379
380 // MS_ flags for mount(2)
381 pub const MS_RMT_MASK: c_ulong =
382 crate::MS_RDONLY | crate::MS_SYNCHRONOUS | crate::MS_MANDLOCK | crate::MS_I_VERSION;
383
384 pub const ENOTSUP: c_int = EOPNOTSUPP;
385
386 pub const IPV6_JOIN_GROUP: c_int = 20;
387 pub const IPV6_LEAVE_GROUP: c_int = 21;
388
389 // Different than Gnu.
390 pub const FILENAME_MAX: c_uint = 4095;
391
392 pub const PRIO_PROCESS: c_int = 0;
393 pub const PRIO_PGRP: c_int = 1;
394 pub const PRIO_USER: c_int = 2;
395
396 pub const SOMAXCONN: c_int = 128;
397
398 pub const ST_RELATIME: c_ulong = 4096;
399
400 pub const SO_TIMESTAMP: c_int = 29;
401
402 pub const RLIM_INFINITY: crate::rlim_t = !0;
403
404 pub const AF_NFC: c_int = PF_NFC;
405 pub const BUFSIZ: c_int = 256;
406 pub const EDEADLK: c_int = 0x23;
407 pub const EDEADLOCK: c_int = EDEADLK;
408 pub const EXTA: c_uint = B19200;
409 pub const EXTB: c_uint = B38400;
410 pub const EXTPROC: crate::tcflag_t = 0o200000;
411 pub const FOPEN_MAX: c_int = 16;
412 pub const F_GETOWN: c_int = 9;
413 pub const F_OFD_GETLK: c_int = 36;
414 pub const F_OFD_SETLK: c_int = 37;
415 pub const F_OFD_SETLKW: c_int = 38;
416 pub const F_RDLCK: c_int = 0;
417 pub const F_SETOWN: c_int = 8;
418 pub const F_UNLCK: c_int = 2;
419 pub const F_WRLCK: c_int = 1;
420 pub const IPV6_MULTICAST_ALL: c_int = 29;
421 pub const IPV6_ROUTER_ALERT_ISOLATE: c_int = 30;
422 pub const MAP_HUGE_SHIFT: c_int = 26;
423 pub const MAP_HUGE_MASK: c_int = 0x3f;
424 pub const MSG_COPY: c_int = 0o40000;
425 pub const NI_MAXHOST: crate::socklen_t = 1025;
426 pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY;
427 pub const PACKET_MR_UNICAST: c_int = 3;
428 pub const PF_NFC: c_int = 39;
429 pub const PF_VSOCK: c_int = 40;
430 pub const RTLD_NOLOAD: c_int = 0x00004;
431 pub const RUSAGE_THREAD: c_int = 1;
432 pub const SHM_EXEC: c_int = 0o100000;
433 pub const SOCK_DCCP: c_int = 6;
434 pub const SOCK_PACKET: c_int = 10;
435 pub const TCP_COOKIE_TRANSACTIONS: c_int = 15;
436 pub const UDP_GRO: c_int = 104;
437 pub const UDP_SEGMENT: c_int = 103;
438
439 pub const PTHREAD_RWLOCK_PREFER_READER_NP: c_int = 0;
440 pub const PTHREAD_RWLOCK_PREFER_WRITER_NP: c_int = 1;
441 pub const PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP: c_int = 2;
442 pub const PTHREAD_RWLOCK_DEFAULT_NP: c_int = PTHREAD_RWLOCK_PREFER_WRITER_NP;
443
444 pub const PTHREAD_MUTEX_TIMED_NP: c_int = 0;
445 pub const PTHREAD_MUTEX_RECURSIVE_NP: c_int = 1;
446 pub const PTHREAD_MUTEX_ERRORCHECK_NP: c_int = 2;
447 pub const PTHREAD_MUTEX_ADAPTIVE_NP: c_int = 3;
448
449 pub const __LT_SPINLOCK_INIT: c_int = 0;
450
451 pub const __LOCK_INITIALIZER: _pthread_fastlock = _pthread_fastlock {
452 __status: 0,
453 __spinlock: __LT_SPINLOCK_INIT,
454 };
455
456 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
457 __m_reserved: 0,
458 __m_count: 0,
459 __m_owner: core::ptr::null_mut(),
460 __m_kind: PTHREAD_MUTEX_TIMED_NP,
461 __m_lock: __LOCK_INITIALIZER,
462 };
463
464 const PTHREAD_COND_PADDING_SIZE: usize = 48
465 - size_of::<_pthread_fastlock>()
466 - size_of::<_pthread_descr>()
467 - size_of::<__pthread_cond_align_t>();
468
469 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
470 __c_lock: __LOCK_INITIALIZER,
471 __c_waiting: core::ptr::null_mut(),
472 __padding: [0; PTHREAD_COND_PADDING_SIZE],
473 __align: 0,
474 };
475
476 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
477 __rw_lock: __LOCK_INITIALIZER,
478 __rw_readers: 0,
479 __rw_writer: core::ptr::null_mut(),
480 __rw_read_waiting: core::ptr::null_mut(),
481 __rw_write_waiting: core::ptr::null_mut(),
482 __rw_kind: PTHREAD_RWLOCK_DEFAULT_NP,
483 __rw_pshared: crate::PTHREAD_PROCESS_PRIVATE,
484 };
485
486 extern "C" {
487 pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int;
488
489 pub fn pthread_rwlockattr_getkind_np(
490 attr: *const crate::pthread_rwlockattr_t,
491 val: *mut c_int,
492 ) -> c_int;
493 pub fn pthread_rwlockattr_setkind_np(
494 attr: *mut crate::pthread_rwlockattr_t,
495 val: c_int,
496 ) -> c_int;
497
498 pub fn openpty(
499 amaster: *mut c_int,
500 aslave: *mut c_int,
501 name: *mut c_char,
502 termp: *mut termios,
503 winp: *mut crate::winsize,
504 ) -> c_int;
505
506 pub fn getnameinfo(
507 sa: *const crate::sockaddr,
508 salen: crate::socklen_t,
509 host: *mut c_char,
510 hostlen: crate::socklen_t,
511 serv: *mut c_char,
512 servlen: crate::socklen_t,
513 flags: c_int,
514 ) -> c_int;
515
516 pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
517 pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
518
519 pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int;
520 pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64)
521 -> c_int;
522 pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int;
523 pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int;
524 pub fn getauxval(type_: c_ulong) -> c_ulong;
525
526 }
527
528 cfg_if! {
529 if #[cfg(target_arch = "x86_64")] {
530 mod x86_64;
531 pub use self::x86_64::*;
532 } else if #[cfg(target_arch = "aarch64")] {
533 mod aarch64;
534 pub use self::aarch64::*;
535 } else {
536 // unsupported target
537 }
538 }