aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / libc / src / unix / linux_like / linux / uclibc / mod.rs
| 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 | // Set `--cfg=libc_unstable_uclibc_time64` in RUSTFLAGS if your uClibc has 64-bit `time_t`. |
| 17 | if #[cfg(linux_time_bits64)] { |
| 18 | pub type time_t = i64; |
| 19 | pub type suseconds_t = i64; |
| 20 | } else { |
| 21 | pub type time_t = c_long; |
| 22 | pub type suseconds_t = c_long; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | cfg_if! { |
| 27 | if #[cfg(doc)] { |
| 28 | // Used in `linux::arch` to define ioctl constants. |
| 29 | pub(crate) type Ioctl = c_ulong; |
| 30 | } else { |
| 31 | #[doc(hidden)] |
| 32 | pub type Ioctl = c_ulong; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | s! { |
| 37 | pub struct statvfs { |
| 38 | // Different than GNU! |
| 39 | pub f_bsize: c_ulong, |
| 40 | pub f_frsize: c_ulong, |
| 41 | pub f_blocks: crate::fsblkcnt_t, |
| 42 | pub f_bfree: crate::fsblkcnt_t, |
| 43 | pub f_bavail: crate::fsblkcnt_t, |
| 44 | pub f_files: crate::fsfilcnt_t, |
| 45 | pub f_ffree: crate::fsfilcnt_t, |
| 46 | pub f_favail: crate::fsfilcnt_t, |
| 47 | #[cfg(target_endian = "little")] |
| 48 | pub f_fsid: c_ulong, |
| 49 | #[cfg(target_pointer_width = "32")] |
| 50 | __f_unused: Padding<c_int>, |
| 51 | #[cfg(target_endian = "big")] |
| 52 | pub f_fsid: c_ulong, |
| 53 | pub f_flag: c_ulong, |
| 54 | pub f_namemax: c_ulong, |
| 55 | __f_spare: [c_int; 6], |
| 56 | } |
| 57 | |
| 58 | pub struct regex_t { |
| 59 | __buffer: *mut c_void, |
| 60 | __allocated: size_t, |
| 61 | __used: size_t, |
| 62 | __syntax: c_ulong, |
| 63 | __fastmap: *mut c_char, |
| 64 | __translate: *mut c_char, |
| 65 | __re_nsub: size_t, |
| 66 | __bitfield: u8, |
| 67 | } |
| 68 | |
| 69 | pub struct rtentry { |
| 70 | pub rt_pad1: c_ulong, |
| 71 | pub rt_dst: crate::sockaddr, |
| 72 | pub rt_gateway: crate::sockaddr, |
| 73 | pub rt_genmask: crate::sockaddr, |
| 74 | pub rt_flags: c_ushort, |
| 75 | pub rt_pad2: c_short, |
| 76 | pub rt_pad3: c_ulong, |
| 77 | pub rt_tos: c_uchar, |
| 78 | pub rt_class: c_uchar, |
| 79 | #[cfg(target_pointer_width = "64")] |
| 80 | pub rt_pad4: [c_short; 3usize], |
| 81 | #[cfg(not(target_pointer_width = "64"))] |
| 82 | pub rt_pad4: c_short, |
| 83 | pub rt_metric: c_short, |
| 84 | pub rt_dev: *mut c_char, |
| 85 | pub rt_mtu: c_ulong, |
| 86 | pub rt_window: c_ulong, |
| 87 | pub rt_irtt: c_ushort, |
| 88 | } |
| 89 | |
| 90 | pub struct __exit_status { |
| 91 | pub e_termination: c_short, |
| 92 | pub e_exit: c_short, |
| 93 | } |
| 94 | |
| 95 | pub struct ptrace_peeksiginfo_args { |
| 96 | pub off: crate::__u64, |
| 97 | pub flags: crate::__u32, |
| 98 | pub nr: crate::__s32, |
| 99 | } |
| 100 | |
| 101 | pub struct tcp_info { |
| 102 | pub tcpi_state: u8, |
| 103 | pub tcpi_ca_state: u8, |
| 104 | pub tcpi_retransmits: u8, |
| 105 | pub tcpi_probes: u8, |
| 106 | pub tcpi_backoff: u8, |
| 107 | pub tcpi_options: u8, |
| 108 | /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. |
| 109 | /// Each is 4 bits. |
| 110 | pub tcpi_snd_rcv_wscale: u8, |
| 111 | pub tcpi_rto: u32, |
| 112 | pub tcpi_ato: u32, |
| 113 | pub tcpi_snd_mss: u32, |
| 114 | pub tcpi_rcv_mss: u32, |
| 115 | pub tcpi_unacked: u32, |
| 116 | pub tcpi_sacked: u32, |
| 117 | pub tcpi_lost: u32, |
| 118 | pub tcpi_retrans: u32, |
| 119 | pub tcpi_fackets: u32, |
| 120 | pub tcpi_last_data_sent: u32, |
| 121 | pub tcpi_last_ack_sent: u32, |
| 122 | pub tcpi_last_data_recv: u32, |
| 123 | pub tcpi_last_ack_recv: u32, |
| 124 | pub tcpi_pmtu: u32, |
| 125 | pub tcpi_rcv_ssthresh: u32, |
| 126 | pub tcpi_rtt: u32, |
| 127 | pub tcpi_rttvar: u32, |
| 128 | pub tcpi_snd_ssthresh: u32, |
| 129 | pub tcpi_snd_cwnd: u32, |
| 130 | pub tcpi_advmss: u32, |
| 131 | pub tcpi_reordering: u32, |
| 132 | pub tcpi_rcv_rtt: u32, |
| 133 | pub tcpi_rcv_space: u32, |
| 134 | pub tcpi_total_retrans: u32, |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | impl siginfo_t { |
| 139 | pub unsafe fn si_addr(&self) -> *mut c_void { |
| 140 | #[repr(C)] |
| 141 | struct siginfo_sigfault { |
| 142 | _si_signo: c_int, |
| 143 | _si_errno: c_int, |
| 144 | _si_code: c_int, |
| 145 | si_addr: *mut c_void, |
| 146 | } |
| 147 | (*(self as *const siginfo_t).cast::<siginfo_sigfault>()).si_addr |
| 148 | } |
| 149 | |
| 150 | pub unsafe fn si_value(&self) -> crate::sigval { |
| 151 | #[repr(C)] |
| 152 | struct siginfo_si_value { |
| 153 | _si_signo: c_int, |
| 154 | _si_errno: c_int, |
| 155 | _si_code: c_int, |
| 156 | _si_timerid: c_int, |
| 157 | _si_overrun: c_int, |
| 158 | si_value: crate::sigval, |
| 159 | } |
| 160 | (*(self as *const siginfo_t).cast::<siginfo_si_value>()).si_value |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | s_no_extra_traits! { |
| 165 | // Internal, for casts to access union fields |
| 166 | struct sifields_sigchld { |
| 167 | si_pid: crate::pid_t, |
| 168 | si_uid: crate::uid_t, |
| 169 | si_status: c_int, |
| 170 | si_utime: c_long, |
| 171 | si_stime: c_long, |
| 172 | } |
| 173 | |
| 174 | // Internal, for casts to access union fields |
| 175 | union sifields { |
| 176 | _align_pointer: *mut c_void, |
| 177 | sigchld: sifields_sigchld, |
| 178 | } |
| 179 | |
| 180 | // Internal, for casts to access union fields. Note that some variants |
| 181 | // of sifields start with a pointer, which makes the alignment of |
| 182 | // sifields vary on 32-bit and 64-bit architectures. |
| 183 | struct siginfo_f { |
| 184 | _siginfo_base: [c_int; 3], |
| 185 | sifields: sifields, |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | impl siginfo_t { |
| 190 | unsafe fn sifields(&self) -> &sifields { |
| 191 | &(*(self as *const siginfo_t).cast::<siginfo_f>()).sifields |
| 192 | } |
| 193 | |
| 194 | pub unsafe fn si_pid(&self) -> crate::pid_t { |
| 195 | self.sifields().sigchld.si_pid |
| 196 | } |
| 197 | |
| 198 | pub unsafe fn si_uid(&self) -> crate::uid_t { |
| 199 | self.sifields().sigchld.si_uid |
| 200 | } |
| 201 | |
| 202 | pub unsafe fn si_status(&self) -> c_int { |
| 203 | self.sifields().sigchld.si_status |
| 204 | } |
| 205 | |
| 206 | pub unsafe fn si_utime(&self) -> c_long { |
| 207 | self.sifields().sigchld.si_utime |
| 208 | } |
| 209 | |
| 210 | pub unsafe fn si_stime(&self) -> c_long { |
| 211 | self.sifields().sigchld.si_stime |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | pub const MCL_CURRENT: c_int = 0x0001; |
| 216 | pub const MCL_FUTURE: c_int = 0x0002; |
| 217 | pub const MCL_ONFAULT: c_int = 0x0004; |
| 218 | |
| 219 | pub const SIGEV_THREAD_ID: c_int = 4; |
| 220 | |
| 221 | pub const AF_VSOCK: c_int = 40; |
| 222 | |
| 223 | // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the |
| 224 | // following are only available on newer Linux versions than the versions |
| 225 | // currently used in CI in some configurations, so we define them here. |
| 226 | pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; |
| 227 | pub const XFS_SUPER_MAGIC: c_long = 0x58465342; |
| 228 | |
| 229 | pub const PTRACE_TRACEME: c_int = 0; |
| 230 | pub const PTRACE_PEEKTEXT: c_int = 1; |
| 231 | pub const PTRACE_PEEKDATA: c_int = 2; |
| 232 | pub const PTRACE_PEEKUSER: c_int = 3; |
| 233 | pub const PTRACE_POKETEXT: c_int = 4; |
| 234 | pub const PTRACE_POKEDATA: c_int = 5; |
| 235 | pub const PTRACE_POKEUSER: c_int = 6; |
| 236 | pub const PTRACE_CONT: c_int = 7; |
| 237 | pub const PTRACE_KILL: c_int = 8; |
| 238 | pub const PTRACE_SINGLESTEP: c_int = 9; |
| 239 | pub const PTRACE_GETREGS: c_int = 12; |
| 240 | pub const PTRACE_SETREGS: c_int = 13; |
| 241 | pub const PTRACE_GETFPREGS: c_int = 14; |
| 242 | pub const PTRACE_SETFPREGS: c_int = 15; |
| 243 | pub const PTRACE_ATTACH: c_int = 16; |
| 244 | pub const PTRACE_DETACH: c_int = 17; |
| 245 | pub const PTRACE_GETFPXREGS: c_int = 18; |
| 246 | pub const PTRACE_SETFPXREGS: c_int = 19; |
| 247 | pub const PTRACE_SYSCALL: c_int = 24; |
| 248 | pub const PTRACE_SETOPTIONS: c_int = 0x4200; |
| 249 | pub const PTRACE_GETEVENTMSG: c_int = 0x4201; |
| 250 | pub const PTRACE_GETSIGINFO: c_int = 0x4202; |
| 251 | pub const PTRACE_SETSIGINFO: c_int = 0x4203; |
| 252 | pub const PTRACE_GETREGSET: c_int = 0x4204; |
| 253 | pub const PTRACE_SETREGSET: c_int = 0x4205; |
| 254 | pub const PTRACE_SEIZE: c_int = 0x4206; |
| 255 | pub const PTRACE_INTERRUPT: c_int = 0x4207; |
| 256 | pub const PTRACE_LISTEN: c_int = 0x4208; |
| 257 | |
| 258 | pub const POSIX_FADV_DONTNEED: c_int = 4; |
| 259 | pub const POSIX_FADV_NOREUSE: c_int = 5; |
| 260 | |
| 261 | // These are different than GNU! |
| 262 | pub const LC_CTYPE: c_int = 0; |
| 263 | pub const LC_NUMERIC: c_int = 1; |
| 264 | pub const LC_TIME: c_int = 3; |
| 265 | pub const LC_COLLATE: c_int = 4; |
| 266 | pub const LC_MONETARY: c_int = 2; |
| 267 | pub const LC_MESSAGES: c_int = 5; |
| 268 | pub const LC_ALL: c_int = 6; |
| 269 | // end different section |
| 270 | |
| 271 | pub const ENOTSUP: c_int = EOPNOTSUPP; |
| 272 | |
| 273 | pub const IPV6_JOIN_GROUP: c_int = 20; |
| 274 | pub const IPV6_LEAVE_GROUP: c_int = 21; |
| 275 | |
| 276 | // Different than Gnu. |
| 277 | pub const FILENAME_MAX: c_uint = 4095; |
| 278 | |
| 279 | pub const PRIO_PROCESS: crate::__priority_which_t = 0; |
| 280 | pub const PRIO_PGRP: crate::__priority_which_t = 1; |
| 281 | pub const PRIO_USER: crate::__priority_which_t = 2; |
| 282 | |
| 283 | pub const SOMAXCONN: c_int = 128; |
| 284 | |
| 285 | pub const ST_RELATIME: c_ulong = 4096; |
| 286 | |
| 287 | pub const AF_NFC: c_int = PF_NFC; |
| 288 | pub const BUFSIZ: c_int = 4096; |
| 289 | pub const EDEADLOCK: c_int = EDEADLK; |
| 290 | pub const EXTA: c_uint = B19200; |
| 291 | pub const EXTB: c_uint = B38400; |
| 292 | pub const EXTPROC: crate::tcflag_t = 0o200000; |
| 293 | pub const FOPEN_MAX: c_int = 16; |
| 294 | pub const F_GETOWN: c_int = 9; |
| 295 | pub const F_OFD_GETLK: c_int = 36; |
| 296 | pub const F_OFD_SETLK: c_int = 37; |
| 297 | pub const F_OFD_SETLKW: c_int = 38; |
| 298 | pub const F_RDLCK: c_int = 0; |
| 299 | pub const F_SETOWN: c_int = 8; |
| 300 | pub const F_UNLCK: c_int = 2; |
| 301 | pub const F_WRLCK: c_int = 1; |
| 302 | pub const IPV6_MULTICAST_ALL: c_int = 29; |
| 303 | pub const IPV6_ROUTER_ALERT_ISOLATE: c_int = 30; |
| 304 | pub const MAP_HUGE_SHIFT: c_int = 26; |
| 305 | pub const MAP_HUGE_MASK: c_int = 0x3f; |
| 306 | pub const MAP_HUGE_64KB: c_int = 16 << MAP_HUGE_SHIFT; |
| 307 | pub const MAP_HUGE_512KB: c_int = 19 << MAP_HUGE_SHIFT; |
| 308 | pub const MAP_HUGE_1MB: c_int = 20 << MAP_HUGE_SHIFT; |
| 309 | pub const MAP_HUGE_2MB: c_int = 21 << MAP_HUGE_SHIFT; |
| 310 | pub const MAP_HUGE_8MB: c_int = 23 << MAP_HUGE_SHIFT; |
| 311 | pub const MAP_HUGE_16MB: c_int = 24 << MAP_HUGE_SHIFT; |
| 312 | pub const MAP_HUGE_32MB: c_int = 25 << MAP_HUGE_SHIFT; |
| 313 | pub const MAP_HUGE_256MB: c_int = 28 << MAP_HUGE_SHIFT; |
| 314 | pub const MAP_HUGE_512MB: c_int = 29 << MAP_HUGE_SHIFT; |
| 315 | pub const MAP_HUGE_1GB: c_int = 30 << MAP_HUGE_SHIFT; |
| 316 | pub const MAP_HUGE_2GB: c_int = 31 << MAP_HUGE_SHIFT; |
| 317 | pub const MAP_HUGE_16GB: c_int = 34 << MAP_HUGE_SHIFT; |
| 318 | pub const MINSIGSTKSZ: c_int = 2048; |
| 319 | pub const MSG_COPY: c_int = 0o40000; |
| 320 | pub const NI_MAXHOST: crate::socklen_t = 1025; |
| 321 | pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; |
| 322 | pub const PACKET_MR_UNICAST: c_int = 3; |
| 323 | pub const PF_NFC: c_int = 39; |
| 324 | pub const PF_VSOCK: c_int = 40; |
| 325 | pub const PTRACE_EVENT_STOP: c_int = 128; |
| 326 | pub const PTRACE_GETSIGMASK: c_uint = 0x420a; |
| 327 | pub const PTRACE_PEEKSIGINFO: c_int = 0x4209; |
| 328 | pub const PTRACE_SETSIGMASK: c_uint = 0x420b; |
| 329 | pub const RTLD_NOLOAD: c_int = 0x00004; |
| 330 | pub const RUSAGE_THREAD: c_int = 1; |
| 331 | pub const SHM_EXEC: c_int = 0o100000; |
| 332 | pub const SIGPOLL: c_int = SIGIO; |
| 333 | pub const SOCK_DCCP: c_int = 6; |
| 334 | #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] |
| 335 | pub const SOCK_PACKET: c_int = 10; |
| 336 | pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; |
| 337 | pub const UDP_GRO: c_int = 104; |
| 338 | pub const UDP_SEGMENT: c_int = 103; |
| 339 | |
| 340 | extern "C" { |
| 341 | pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; |
| 342 | |
| 343 | pub fn pthread_rwlockattr_getkind_np( |
| 344 | attr: *const crate::pthread_rwlockattr_t, |
| 345 | val: *mut c_int, |
| 346 | ) -> c_int; |
| 347 | pub fn pthread_rwlockattr_setkind_np( |
| 348 | attr: *mut crate::pthread_rwlockattr_t, |
| 349 | val: c_int, |
| 350 | ) -> c_int; |
| 351 | |
| 352 | pub fn ptrace(request: c_uint, ...) -> c_long; |
| 353 | |
| 354 | pub fn sendmmsg( |
| 355 | sockfd: c_int, |
| 356 | msgvec: *mut crate::mmsghdr, |
| 357 | vlen: c_uint, |
| 358 | flags: c_int, |
| 359 | ) -> c_int; |
| 360 | pub fn recvmmsg( |
| 361 | sockfd: c_int, |
| 362 | msgvec: *mut crate::mmsghdr, |
| 363 | vlen: c_uint, |
| 364 | flags: c_int, |
| 365 | timeout: *mut crate::timespec, |
| 366 | ) -> c_int; |
| 367 | |
| 368 | pub fn openpty( |
| 369 | amaster: *mut c_int, |
| 370 | aslave: *mut c_int, |
| 371 | name: *mut c_char, |
| 372 | termp: *mut termios, |
| 373 | winp: *mut crate::winsize, |
| 374 | ) -> c_int; |
| 375 | pub fn forkpty( |
| 376 | amaster: *mut c_int, |
| 377 | name: *mut c_char, |
| 378 | termp: *mut termios, |
| 379 | winp: *mut crate::winsize, |
| 380 | ) -> crate::pid_t; |
| 381 | |
| 382 | pub fn getnameinfo( |
| 383 | sa: *const crate::sockaddr, |
| 384 | salen: crate::socklen_t, |
| 385 | host: *mut c_char, |
| 386 | hostlen: crate::socklen_t, |
| 387 | serv: *mut c_char, |
| 388 | servlen: crate::socklen_t, |
| 389 | flags: c_int, |
| 390 | ) -> c_int; |
| 391 | |
| 392 | pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; |
| 393 | pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; |
| 394 | |
| 395 | pub fn sethostid(hostid: c_long) -> c_int; |
| 396 | pub fn fanotify_mark( |
| 397 | fd: c_int, |
| 398 | flags: c_uint, |
| 399 | mask: u64, |
| 400 | dirfd: c_int, |
| 401 | path: *const c_char, |
| 402 | ) -> c_int; |
| 403 | pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; |
| 404 | pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) |
| 405 | -> c_int; |
| 406 | pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; |
| 407 | pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; |
| 408 | pub fn getpriority(which: crate::__priority_which_t, who: crate::id_t) -> c_int; |
| 409 | pub fn setpriority(which: crate::__priority_which_t, who: crate::id_t, prio: c_int) -> c_int; |
| 410 | pub fn getauxval(type_: c_ulong) -> c_ulong; |
| 411 | } |
| 412 | |
| 413 | cfg_if! { |
| 414 | if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { |
| 415 | mod mips; |
| 416 | pub use self::mips::*; |
| 417 | } else if #[cfg(target_arch = "x86_64")] { |
| 418 | mod x86_64; |
| 419 | pub use self::x86_64::*; |
| 420 | } else if #[cfg(target_arch = "arm")] { |
| 421 | mod arm; |
| 422 | pub use self::arm::*; |
| 423 | } else { |
| 424 | pub use unsupported_target; |
| 425 | } |
| 426 | } |