Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

69
vendor/libc/src/fuchsia/aarch64.rs vendored Normal file
View File

@@ -0,0 +1,69 @@
use crate::off_t;
use crate::prelude::*;
pub type __u64 = c_ulonglong;
pub type wchar_t = u32;
pub type nlink_t = c_ulong;
pub type blksize_t = c_long;
s! {
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
__pad0: c_ulong,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
__pad1: c_int,
pub st_blocks: crate::blkcnt_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused: [c_uint; 2],
}
pub struct stat64 {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
__pad0: c_ulong,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
__pad1: c_int,
pub st_blocks: crate::blkcnt_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused: [c_uint; 2],
}
pub struct ipc_perm {
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
pub cuid: crate::uid_t,
pub cgid: crate::gid_t,
pub mode: crate::mode_t,
pub __seq: c_ushort,
__unused1: c_ulong,
__unused2: c_ulong,
}
}
// From https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/bits/signal.h;l=20-21;drc=0827b18ab9540c46f8037f407d17ea15a79e9ba7
pub const MINSIGSTKSZ: size_t = 6144;
pub const SIGSTKSZ: size_t = 12288;

4322
vendor/libc/src/fuchsia/mod.rs vendored Normal file

File diff suppressed because it is too large Load Diff

46
vendor/libc/src/fuchsia/riscv64.rs vendored Normal file
View File

@@ -0,0 +1,46 @@
use crate::off_t;
use crate::prelude::*;
// From psABI Calling Convention for RV64
pub type __u64 = c_ulonglong;
pub type wchar_t = i32;
pub type nlink_t = c_ulong;
pub type blksize_t = c_long;
pub type stat64 = stat;
s! {
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: crate::nlink_t,
pub st_mode: crate::mode_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
__pad0: c_int,
pub st_rdev: crate::dev_t,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
pub st_blocks: crate::blkcnt_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused: [c_long; 3],
}
// Not actually used, IPC calls just return ENOSYS
pub struct ipc_perm {
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
pub cuid: crate::uid_t,
pub cgid: crate::gid_t,
pub mode: crate::mode_t,
pub __seq: c_ushort,
__unused1: c_ulong,
__unused2: c_ulong,
}
}

142
vendor/libc/src/fuchsia/x86_64.rs vendored Normal file
View File

@@ -0,0 +1,142 @@
use crate::off_t;
use crate::prelude::*;
pub type wchar_t = i32;
pub type nlink_t = u64;
pub type blksize_t = c_long;
pub type __u64 = c_ulonglong;
s! {
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: crate::nlink_t,
pub st_mode: crate::mode_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
__pad0: c_int,
pub st_rdev: crate::dev_t,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
pub st_blocks: crate::blkcnt_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused: [c_long; 3],
}
pub struct stat64 {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino64_t,
pub st_nlink: crate::nlink_t,
pub st_mode: crate::mode_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
__pad0: c_int,
pub st_rdev: crate::dev_t,
pub st_size: off_t,
pub st_blksize: crate::blksize_t,
pub st_blocks: crate::blkcnt64_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__reserved: [c_long; 3],
}
pub struct mcontext_t {
__private: [u64; 32],
}
pub struct ipc_perm {
pub __ipc_perm_key: crate::key_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
pub cuid: crate::uid_t,
pub cgid: crate::gid_t,
pub mode: crate::mode_t,
pub __seq: c_int,
__unused1: c_long,
__unused2: c_long,
}
}
s_no_extra_traits! {
pub struct ucontext_t {
pub uc_flags: c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: crate::stack_t,
pub uc_mcontext: mcontext_t,
pub uc_sigmask: crate::sigset_t,
__private: [u8; 512],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for ucontext_t {
fn eq(&self, other: &ucontext_t) -> bool {
self.uc_flags == other.uc_flags
&& self.uc_link == other.uc_link
&& self.uc_stack == other.uc_stack
&& self.uc_mcontext == other.uc_mcontext
&& self.uc_sigmask == other.uc_sigmask
&& self
.__private
.iter()
.zip(other.__private.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for ucontext_t {}
impl hash::Hash for ucontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.uc_flags.hash(state);
self.uc_link.hash(state);
self.uc_stack.hash(state);
self.uc_mcontext.hash(state);
self.uc_sigmask.hash(state);
self.__private.hash(state);
}
}
}
}
// offsets in user_regs_structs, from sys/reg.h
pub const R15: c_int = 0;
pub const R14: c_int = 1;
pub const R13: c_int = 2;
pub const R12: c_int = 3;
pub const RBP: c_int = 4;
pub const RBX: c_int = 5;
pub const R11: c_int = 6;
pub const R10: c_int = 7;
pub const R9: c_int = 8;
pub const R8: c_int = 9;
pub const RAX: c_int = 10;
pub const RCX: c_int = 11;
pub const RDX: c_int = 12;
pub const RSI: c_int = 13;
pub const RDI: c_int = 14;
pub const ORIG_RAX: c_int = 15;
pub const RIP: c_int = 16;
pub const CS: c_int = 17;
pub const EFLAGS: c_int = 18;
pub const RSP: c_int = 19;
pub const SS: c_int = 20;
pub const FS_BASE: c_int = 21;
pub const GS_BASE: c_int = 22;
pub const DS: c_int = 23;
pub const ES: c_int = 24;
pub const FS: c_int = 25;
pub const GS: c_int = 26;
pub const MAP_32BIT: c_int = 0x0040;
pub const SIGSTKSZ: size_t = 8192;
pub const MINSIGSTKSZ: size_t = 2048;

561
vendor/libc/src/hermit.rs vendored Normal file
View File

@@ -0,0 +1,561 @@
//! Hermit C type definitions
use crate::prelude::*;
pub type intmax_t = i64;
pub type uintmax_t = u64;
pub type intptr_t = isize;
pub type uintptr_t = usize;
pub type size_t = usize;
pub type ssize_t = isize;
pub type ptrdiff_t = isize;
pub type clockid_t = i32;
pub type in_addr_t = u32;
pub type in_port_t = u16;
pub type mode_t = u32;
pub type nfds_t = usize;
pub type pid_t = i32;
pub type sa_family_t = u8;
pub type socklen_t = u32;
pub type time_t = i64;
s! {
pub struct addrinfo {
pub ai_flags: i32,
pub ai_family: i32,
pub ai_socktype: i32,
pub ai_protocol: i32,
pub ai_addrlen: socklen_t,
pub ai_canonname: *mut c_char,
pub ai_addr: *mut sockaddr,
pub ai_next: *mut addrinfo,
}
pub struct dirent64 {
pub d_ino: u64,
pub d_off: i64,
pub d_reclen: u16,
pub d_type: u8,
pub d_name: [c_char; 256],
}
#[repr(align(4))]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}
pub struct in_addr {
pub s_addr: in_addr_t,
}
pub struct iovec {
iov_base: *mut c_void,
iov_len: usize,
}
pub struct pollfd {
pub fd: i32,
pub events: i16,
pub revents: i16,
}
pub struct sockaddr {
pub sa_len: u8,
pub sa_family: sa_family_t,
pub sa_data: [c_char; 14],
}
pub struct sockaddr_in {
pub sin_len: u8,
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
pub sin_zero: [c_char; 8],
}
pub struct sockaddr_in6 {
pub sin6_len: u8,
pub sin6_family: sa_family_t,
pub sin6_port: in_port_t,
pub sin6_flowinfo: u32,
pub sin6_addr: in6_addr,
pub sin6_scope_id: u32,
}
pub struct sockaddr_storage {
pub ss_len: u8,
pub ss_family: sa_family_t,
__ss_pad1: [u8; 6],
__ss_align: i64,
__ss_pad2: [u8; 112],
}
pub struct stat {
pub st_dev: u64,
pub st_ino: u64,
pub st_nlink: u64,
pub st_mode: mode_t,
pub st_uid: u32,
pub st_gid: u32,
pub st_rdev: u64,
pub st_size: i64,
pub st_blksize: i64,
pub st_blocks: i64,
pub st_atim: timespec,
pub st_mtim: timespec,
pub st_ctim: timespec,
}
pub struct timespec {
pub tv_sec: time_t,
pub tv_nsec: i32,
}
}
pub const AF_UNSPEC: i32 = 0;
pub const AF_INET: i32 = 3;
pub const AF_INET6: i32 = 1;
pub const AF_VSOCK: i32 = 2;
pub const CLOCK_REALTIME: clockid_t = 1;
pub const CLOCK_MONOTONIC: clockid_t = 4;
pub const DT_UNKNOWN: u8 = 0;
pub const DT_FIFO: u8 = 1;
pub const DT_CHR: u8 = 2;
pub const DT_DIR: u8 = 4;
pub const DT_BLK: u8 = 6;
pub const DT_REG: u8 = 8;
pub const DT_LNK: u8 = 10;
pub const DT_SOCK: u8 = 12;
pub const DT_WHT: u8 = 14;
pub const EAI_AGAIN: i32 = 2;
pub const EAI_BADFLAGS: i32 = 3;
pub const EAI_FAIL: i32 = 4;
pub const EAI_FAMILY: i32 = 5;
pub const EAI_MEMORY: i32 = 6;
pub const EAI_NODATA: i32 = 7;
pub const EAI_NONAME: i32 = 8;
pub const EAI_SERVICE: i32 = 9;
pub const EAI_SOCKTYPE: i32 = 10;
pub const EAI_SYSTEM: i32 = 11;
pub const EAI_OVERFLOW: i32 = 14;
pub const EFD_SEMAPHORE: i16 = 0o1;
pub const EFD_NONBLOCK: i16 = 0o4000;
pub const EFD_CLOEXEC: i16 = 0o40000;
pub const F_DUPFD: i32 = 0;
pub const F_GETFD: i32 = 1;
pub const F_SETFD: i32 = 2;
pub const F_GETFL: i32 = 3;
pub const F_SETFL: i32 = 4;
pub const FD_CLOEXEC: i32 = 1;
pub const FIONBIO: i32 = 0x8008667e;
pub const FUTEX_RELATIVE_TIMEOUT: u32 = 1;
pub const IP_TOS: i32 = 1;
pub const IP_TTL: i32 = 2;
pub const IP_ADD_MEMBERSHIP: i32 = 3;
pub const IP_DROP_MEMBERSHIP: i32 = 4;
pub const IP_MULTICAST_TTL: i32 = 5;
pub const IP_MULTICAST_LOOP: i32 = 7;
pub const IPPROTO_IP: i32 = 0;
pub const IPPROTO_TCP: i32 = 6;
pub const IPPROTO_UDP: i32 = 17;
pub const IPPROTO_IPV6: i32 = 41;
pub const IPV6_ADD_MEMBERSHIP: i32 = 12;
pub const IPV6_DROP_MEMBERSHIP: i32 = 13;
pub const IPV6_MULTICAST_LOOP: i32 = 19;
pub const IPV6_V6ONLY: i32 = 27;
pub const MSG_PEEK: i32 = 1;
pub const O_RDONLY: i32 = 0o0;
pub const O_WRONLY: i32 = 0o1;
pub const O_RDWR: i32 = 0o2;
pub const O_CREAT: i32 = 0o100;
pub const O_EXCL: i32 = 0o200;
pub const O_TRUNC: i32 = 0o1000;
pub const O_APPEND: i32 = 0o2000;
pub const O_NONBLOCK: i32 = 0o4000;
pub const O_DIRECTORY: i32 = 0o200000;
pub const POLLIN: i16 = 0x1;
pub const POLLPRI: i16 = 0x2;
pub const POLLOUT: i16 = 0x4;
pub const POLLERR: i16 = 0x8;
pub const POLLHUP: i16 = 0x10;
pub const POLLNVAL: i16 = 0x20;
pub const POLLRDNORM: i16 = 0x040;
pub const POLLRDBAND: i16 = 0x080;
pub const POLLWRNORM: i16 = 0x0100;
pub const POLLWRBAND: i16 = 0x0200;
pub const POLLRDHUP: i16 = 0x2000;
pub const S_IRWXU: mode_t = 0o0700;
pub const S_IRUSR: mode_t = 0o0400;
pub const S_IWUSR: mode_t = 0o0200;
pub const S_IXUSR: mode_t = 0o0100;
pub const S_IRWXG: mode_t = 0o0070;
pub const S_IRGRP: mode_t = 0o0040;
pub const S_IWGRP: mode_t = 0o0020;
pub const S_IXGRP: mode_t = 0o0010;
pub const S_IRWXO: mode_t = 0o0007;
pub const S_IROTH: mode_t = 0o0004;
pub const S_IWOTH: mode_t = 0o0002;
pub const S_IXOTH: mode_t = 0o0001;
pub const S_IFMT: mode_t = 0o17_0000;
pub const S_IFSOCK: mode_t = 0o14_0000;
pub const S_IFLNK: mode_t = 0o12_0000;
pub const S_IFREG: mode_t = 0o10_0000;
pub const S_IFBLK: mode_t = 0o6_0000;
pub const S_IFDIR: mode_t = 0o4_0000;
pub const S_IFCHR: mode_t = 0o2_0000;
pub const S_IFIFO: mode_t = 0o1_0000;
pub const SHUT_RD: i32 = 0;
pub const SHUT_WR: i32 = 1;
pub const SHUT_RDWR: i32 = 2;
pub const SO_REUSEADDR: i32 = 0x0004;
pub const SO_KEEPALIVE: i32 = 0x0008;
pub const SO_BROADCAST: i32 = 0x0020;
pub const SO_LINGER: i32 = 0x0080;
pub const SO_SNDBUF: i32 = 0x1001;
pub const SO_RCVBUF: i32 = 0x1002;
pub const SO_SNDTIMEO: i32 = 0x1005;
pub const SO_RCVTIMEO: i32 = 0x1006;
pub const SO_ERROR: i32 = 0x1007;
pub const SOCK_STREAM: i32 = 1;
pub const SOCK_DGRAM: i32 = 2;
pub const SOCK_NONBLOCK: i32 = 0o4000;
pub const SOCK_CLOEXEC: i32 = 0o40000;
pub const SOL_SOCKET: i32 = 4095;
pub const STDIN_FILENO: c_int = 0;
pub const STDOUT_FILENO: c_int = 1;
pub const STDERR_FILENO: c_int = 2;
pub const TCP_NODELAY: i32 = 1;
pub const EPERM: i32 = 1;
pub const ENOENT: i32 = 2;
pub const ESRCH: i32 = 3;
pub const EINTR: i32 = 4;
pub const EIO: i32 = 5;
pub const ENXIO: i32 = 6;
pub const E2BIG: i32 = 7;
pub const ENOEXEC: i32 = 8;
pub const EBADF: i32 = 9;
pub const ECHILD: i32 = 10;
pub const EAGAIN: i32 = 11;
pub const ENOMEM: i32 = 12;
pub const EACCES: i32 = 13;
pub const EFAULT: i32 = 14;
pub const ENOTBLK: i32 = 15;
pub const EBUSY: i32 = 16;
pub const EEXIST: i32 = 17;
pub const EXDEV: i32 = 18;
pub const ENODEV: i32 = 19;
pub const ENOTDIR: i32 = 20;
pub const EISDIR: i32 = 21;
pub const EINVAL: i32 = 22;
pub const ENFILE: i32 = 23;
pub const EMFILE: i32 = 24;
pub const ENOTTY: i32 = 25;
pub const ETXTBSY: i32 = 26;
pub const EFBIG: i32 = 27;
pub const ENOSPC: i32 = 28;
pub const ESPIPE: i32 = 29;
pub const EROFS: i32 = 30;
pub const EMLINK: i32 = 31;
pub const EPIPE: i32 = 32;
pub const EDOM: i32 = 33;
pub const ERANGE: i32 = 34;
pub const EDEADLK: i32 = 35;
pub const ENAMETOOLONG: i32 = 36;
pub const ENOLCK: i32 = 37;
pub const ENOSYS: i32 = 38;
pub const ENOTEMPTY: i32 = 39;
pub const ELOOP: i32 = 40;
pub const EWOULDBLOCK: i32 = EAGAIN;
pub const ENOMSG: i32 = 42;
pub const EIDRM: i32 = 43;
pub const ECHRNG: i32 = 44;
pub const EL2NSYNC: i32 = 45;
pub const EL3HLT: i32 = 46;
pub const EL3RST: i32 = 47;
pub const ELNRNG: i32 = 48;
pub const EUNATCH: i32 = 49;
pub const ENOCSI: i32 = 50;
pub const EL2HLT: i32 = 51;
pub const EBADE: i32 = 52;
pub const EBADR: i32 = 53;
pub const EXFULL: i32 = 54;
pub const ENOANO: i32 = 55;
pub const EBADRQC: i32 = 56;
pub const EBADSLT: i32 = 57;
pub const EDEADLOCK: i32 = EDEADLK;
pub const EBFONT: i32 = 59;
pub const ENOSTR: i32 = 60;
pub const ENODATA: i32 = 61;
pub const ETIME: i32 = 62;
pub const ENOSR: i32 = 63;
pub const ENONET: i32 = 64;
pub const ENOPKG: i32 = 65;
pub const EREMOTE: i32 = 66;
pub const ENOLINK: i32 = 67;
pub const EADV: i32 = 68;
pub const ESRMNT: i32 = 69;
pub const ECOMM: i32 = 70;
pub const EPROTO: i32 = 71;
pub const EMULTIHOP: i32 = 72;
pub const EDOTDOT: i32 = 73;
pub const EBADMSG: i32 = 74;
pub const EOVERFLOW: i32 = 75;
pub const ENOTUNIQ: i32 = 76;
pub const EBADFD: i32 = 77;
pub const EREMCHG: i32 = 78;
pub const ELIBACC: i32 = 79;
pub const ELIBBAD: i32 = 80;
pub const ELIBSCN: i32 = 81;
pub const ELIBMAX: i32 = 82;
pub const ELIBEXEC: i32 = 83;
pub const EILSEQ: i32 = 84;
pub const ERESTART: i32 = 85;
pub const ESTRPIPE: i32 = 86;
pub const EUSERS: i32 = 87;
pub const ENOTSOCK: i32 = 88;
pub const EDESTADDRREQ: i32 = 89;
pub const EMSGSIZE: i32 = 90;
pub const EPROTOTYPE: i32 = 91;
pub const ENOPROTOOPT: i32 = 92;
pub const EPROTONOSUPPORT: i32 = 93;
pub const ESOCKTNOSUPPORT: i32 = 94;
pub const EOPNOTSUPP: i32 = 95;
pub const EPFNOSUPPORT: i32 = 96;
pub const EAFNOSUPPORT: i32 = 97;
pub const EADDRINUSE: i32 = 98;
pub const EADDRNOTAVAIL: i32 = 99;
pub const ENETDOWN: i32 = 100;
pub const ENETUNREACH: i32 = 101;
pub const ENETRESET: i32 = 102;
pub const ECONNABORTED: i32 = 103;
pub const ECONNRESET: i32 = 104;
pub const ENOBUFS: i32 = 105;
pub const EISCONN: i32 = 106;
pub const ENOTCONN: i32 = 107;
pub const ESHUTDOWN: i32 = 108;
pub const ETOOMANYREFS: i32 = 109;
pub const ETIMEDOUT: i32 = 110;
pub const ECONNREFUSED: i32 = 111;
pub const EHOSTDOWN: i32 = 112;
pub const EHOSTUNREACH: i32 = 113;
pub const EALREADY: i32 = 114;
pub const EINPROGRESS: i32 = 115;
pub const ESTALE: i32 = 116;
pub const EUCLEAN: i32 = 117;
pub const ENOTNAM: i32 = 118;
pub const ENAVAIL: i32 = 119;
pub const EISNAM: i32 = 120;
pub const EREMOTEIO: i32 = 121;
pub const EDQUOT: i32 = 122;
pub const ENOMEDIUM: i32 = 123;
pub const EMEDIUMTYPE: i32 = 124;
pub const ECANCELED: i32 = 125;
pub const ENOKEY: i32 = 126;
pub const EKEYEXPIRED: i32 = 127;
pub const EKEYREVOKED: i32 = 128;
pub const EKEYREJECTED: i32 = 129;
pub const EOWNERDEAD: i32 = 130;
pub const ENOTRECOVERABLE: i32 = 131;
pub const ERFKILL: i32 = 132;
pub const EHWPOISON: i32 = 133;
extern "C" {
#[link_name = "sys_alloc"]
pub fn alloc(size: usize, align: usize) -> *mut u8;
#[link_name = "sys_alloc_zeroed"]
pub fn alloc_zeroed(size: usize, align: usize) -> *mut u8;
#[link_name = "sys_realloc"]
pub fn realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8;
#[link_name = "sys_dealloc"]
pub fn dealloc(ptr: *mut u8, size: usize, align: usize);
#[link_name = "sys_exit"]
pub fn exit(status: i32) -> !;
#[link_name = "sys_abort"]
pub fn abort() -> !;
#[link_name = "sys_errno"]
pub fn errno() -> i32;
#[link_name = "sys_clock_gettime"]
pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32;
#[link_name = "sys_nanosleep"]
pub fn nanosleep(req: *const timespec) -> i32;
#[link_name = "sys_available_parallelism"]
pub fn available_parallelism() -> usize;
#[link_name = "sys_futex_wait"]
pub fn futex_wait(
address: *mut u32,
expected: u32,
timeout: *const timespec,
flags: u32,
) -> i32;
#[link_name = "sys_futex_wake"]
pub fn futex_wake(address: *mut u32, count: i32) -> i32;
#[link_name = "sys_stat"]
pub fn stat(path: *const c_char, stat: *mut stat) -> i32;
#[link_name = "sys_fstat"]
pub fn fstat(fd: i32, stat: *mut stat) -> i32;
#[link_name = "sys_lstat"]
pub fn lstat(path: *const c_char, stat: *mut stat) -> i32;
#[link_name = "sys_open"]
pub fn open(path: *const c_char, flags: i32, mode: mode_t) -> i32;
#[link_name = "sys_unlink"]
pub fn unlink(path: *const c_char) -> i32;
#[link_name = "sys_mkdir"]
pub fn mkdir(path: *const c_char, mode: mode_t) -> i32;
#[link_name = "sys_rmdir"]
pub fn rmdir(path: *const c_char) -> i32;
#[link_name = "sys_read"]
pub fn read(fd: i32, buf: *mut u8, len: usize) -> isize;
#[link_name = "sys_write"]
pub fn write(fd: i32, buf: *const u8, len: usize) -> isize;
#[link_name = "sys_readv"]
pub fn readv(fd: i32, iov: *const iovec, iovcnt: usize) -> isize;
#[link_name = "sys_writev"]
pub fn writev(fd: i32, iov: *const iovec, iovcnt: usize) -> isize;
#[link_name = "sys_close"]
pub fn close(fd: i32) -> i32;
#[link_name = "sys_dup"]
pub fn dup(fd: i32) -> i32;
#[link_name = "sys_fcntl"]
pub fn fcntl(fd: i32, cmd: i32, arg: i32) -> i32;
#[link_name = "sys_getdents64"]
pub fn getdents64(fd: i32, dirp: *mut dirent64, count: usize) -> isize;
#[link_name = "sys_getaddrinfo"]
pub fn getaddrinfo(
nodename: *const c_char,
servname: *const c_char,
hints: *const addrinfo,
res: *mut *mut addrinfo,
) -> i32;
#[link_name = "sys_freeaddrinfo"]
pub fn freeaddrinfo(ai: *mut addrinfo);
#[link_name = "sys_socket"]
pub fn socket(domain: i32, ty: i32, protocol: i32) -> i32;
#[link_name = "sys_bind"]
pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32;
#[link_name = "sys_listen"]
pub fn listen(sockfd: i32, backlog: i32) -> i32;
#[link_name = "sys_accept"]
pub fn accept(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32;
#[link_name = "sys_connect"]
pub fn connect(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32;
#[link_name = "sys_recv"]
pub fn recv(sockfd: i32, buf: *mut u8, len: usize, flags: i32) -> isize;
#[link_name = "sys_recvfrom"]
pub fn recvfrom(
sockfd: i32,
buf: *mut c_void,
len: usize,
flags: i32,
addr: *mut sockaddr,
addrlen: *mut socklen_t,
) -> isize;
#[link_name = "sys_send"]
pub fn send(sockfd: i32, buf: *const c_void, len: usize, flags: i32) -> isize;
#[link_name = "sys_sendto"]
pub fn sendto(
sockfd: i32,
buf: *const c_void,
len: usize,
flags: i32,
to: *const sockaddr,
tolen: socklen_t,
) -> isize;
#[link_name = "sys_getpeername"]
pub fn getpeername(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32;
#[link_name = "sys_getsockname"]
pub fn getsockname(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32;
#[link_name = "sys_getsockopt"]
pub fn getsockopt(
sockfd: i32,
level: i32,
optname: i32,
optval: *mut c_void,
optlen: *mut socklen_t,
) -> i32;
#[link_name = "sys_setsockopt"]
pub fn setsockopt(
sockfd: i32,
level: i32,
optname: i32,
optval: *const c_void,
optlen: socklen_t,
) -> i32;
#[link_name = "sys_ioctl"]
pub fn ioctl(sockfd: i32, cmd: i32, argp: *mut c_void) -> i32;
#[link_name = "sys_shutdown"]
pub fn shutdown(sockfd: i32, how: i32) -> i32;
#[link_name = "sys_eventfd"]
pub fn eventfd(initval: u64, flags: i16) -> i32;
#[link_name = "sys_poll"]
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32;
}

159
vendor/libc/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,159 @@
//! libc - Raw FFI bindings to platforms' system libraries
#![crate_name = "libc"]
#![crate_type = "rlib"]
#![allow(
renamed_and_removed_lints, // Keep this order.
unknown_lints, // Keep this order.
nonstandard_style,
overflowing_literals,
unused_macros,
unused_macro_rules,
)]
#![warn(
missing_copy_implementations,
missing_debug_implementations,
safe_packed_borrows
)]
// Prepare for a future upgrade
#![warn(rust_2024_compatibility)]
// Things missing for 2024 that are blocked on MSRV or breakage
#![allow(
missing_unsafe_on_extern,
edition_2024_expr_fragment_specifier,
// Allowed globally, the warning is enabled in individual modules as we work through them
unsafe_op_in_unsafe_fn
)]
#![cfg_attr(libc_deny_warnings, deny(warnings))]
// Attributes needed when building as part of the standard library
#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
#![cfg_attr(libc_thread_local, feature(thread_local))]
#![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))]
// DIFF(1.0): The thread local references that raise this lint were removed in 1.0
#![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))]
#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
#[macro_use]
mod macros;
mod new;
cfg_if! {
if #[cfg(feature = "rustc-dep-of-std")] {
extern crate rustc_std_workspace_core as core;
}
}
pub use core::ffi::c_void;
#[allow(unused_imports)] // needed while the module is empty on some platforms
pub use new::*;
cfg_if! {
if #[cfg(windows)] {
mod primitives;
pub use crate::primitives::*;
mod windows;
pub use crate::windows::*;
prelude!();
} else if #[cfg(target_os = "fuchsia")] {
mod primitives;
pub use crate::primitives::*;
mod fuchsia;
pub use crate::fuchsia::*;
prelude!();
} else if #[cfg(target_os = "switch")] {
mod primitives;
pub use primitives::*;
mod switch;
pub use switch::*;
prelude!();
} else if #[cfg(target_os = "psp")] {
mod primitives;
pub use primitives::*;
mod psp;
pub use crate::psp::*;
prelude!();
} else if #[cfg(target_os = "vxworks")] {
mod primitives;
pub use crate::primitives::*;
mod vxworks;
pub use crate::vxworks::*;
prelude!();
} else if #[cfg(target_os = "solid_asp3")] {
mod primitives;
pub use crate::primitives::*;
mod solid;
pub use crate::solid::*;
prelude!();
} else if #[cfg(unix)] {
mod primitives;
pub use crate::primitives::*;
mod unix;
pub use crate::unix::*;
prelude!();
} else if #[cfg(target_os = "hermit")] {
mod primitives;
pub use crate::primitives::*;
mod hermit;
pub use crate::hermit::*;
prelude!();
} else if #[cfg(target_os = "teeos")] {
mod primitives;
pub use primitives::*;
mod teeos;
pub use teeos::*;
prelude!();
} else if #[cfg(target_os = "trusty")] {
mod primitives;
pub use crate::primitives::*;
mod trusty;
pub use crate::trusty::*;
prelude!();
} else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
mod primitives;
pub use crate::primitives::*;
mod sgx;
pub use crate::sgx::*;
prelude!();
} else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
mod primitives;
pub use crate::primitives::*;
mod wasi;
pub use crate::wasi::*;
prelude!();
} else if #[cfg(target_os = "xous")] {
mod primitives;
pub use crate::primitives::*;
mod xous;
pub use crate::xous::*;
prelude!();
} else {
// non-supported targets: empty...
}
}

446
vendor/libc/src/macros.rs vendored Normal file
View File

@@ -0,0 +1,446 @@
/// A macro for defining #[cfg] if-else statements.
///
/// This is similar to the `if/elif` C preprocessor macro by allowing definition
/// of a cascade of `#[cfg]` cases, emitting the implementation which matches
/// first.
///
/// This allows you to conveniently provide a long list #[cfg]'d blocks of code
/// without having to rewrite each clause multiple times.
macro_rules! cfg_if {
// match if/else chains with a final `else`
($(
if #[cfg($($meta:meta),*)] { $($it:item)* }
) else * else {
$($it2:item)*
}) => {
cfg_if! {
@__items
() ;
$( ( ($($meta),*) ($($it)*) ), )*
( () ($($it2)*) ),
}
};
// match if/else chains lacking a final `else`
(
if #[cfg($($i_met:meta),*)] { $($i_it:item)* }
$(
else if #[cfg($($e_met:meta),*)] { $($e_it:item)* }
)*
) => {
cfg_if! {
@__items
() ;
( ($($i_met),*) ($($i_it)*) ),
$( ( ($($e_met),*) ($($e_it)*) ), )*
( () () ),
}
};
// Internal and recursive macro to emit all the items
//
// Collects all the negated `cfg`s in a list at the beginning and after the
// semicolon is all the remaining items
(@__items ($($not:meta,)*) ; ) => {};
(@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ),
$($rest:tt)*) => {
// Emit all items within one block, applying an appropriate #[cfg]. The
// #[cfg] will require all `$m` matchers specified and must also negate
// all previous matchers.
cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* }
// Recurse to emit all other items in `$rest`, and when we do so add all
// our `$m` matchers to the list of `$not` matchers as future emissions
// will have to negate everything we just matched as well.
cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* }
};
// Internal macro to Apply a cfg attribute to a list of items
(@__apply $m:meta, $($it:item)*) => {
$(#[$m] $it)*
};
}
/// Create an internal crate prelude with `core` reexports and common types.
macro_rules! prelude {
() => {
mod types;
/// Frequently-used types that are available on all platforms
///
/// We need to reexport the core types so this works with `rust-dep-of-std`.
mod prelude {
// Exports from `core`
#[allow(unused_imports)]
pub(crate) use core::clone::Clone;
#[allow(unused_imports)]
pub(crate) use core::default::Default;
#[allow(unused_imports)]
pub(crate) use core::marker::{Copy, Send, Sync};
#[allow(unused_imports)]
pub(crate) use core::option::Option;
#[allow(unused_imports)]
pub(crate) use core::prelude::v1::derive;
#[allow(unused_imports)]
pub(crate) use core::{fmt, hash, iter, mem, ptr};
#[allow(unused_imports)]
pub(crate) use fmt::Debug;
#[allow(unused_imports)]
pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val};
#[allow(unused_imports)]
pub(crate) use crate::types::{CEnumRepr, Padding};
// Commonly used types defined in this crate
#[allow(unused_imports)]
pub(crate) use crate::{
c_char, c_double, c_float, c_int, c_long, c_longlong, c_short, c_uchar, c_uint,
c_ulong, c_ulonglong, c_ushort, c_void, intptr_t, size_t, ssize_t, uintptr_t,
};
}
};
}
/// Implement `Clone` and `Copy` for a struct, as well as `Debug`, `Eq`, `Hash`, and
/// `PartialEq` if the `extra_traits` feature is enabled.
///
/// Use [`s_no_extra_traits`] for structs where the `extra_traits` feature does not
/// make sense, and for unions.
macro_rules! s {
($(
$(#[$attr:meta])*
pub $t:ident $i:ident { $($field:tt)* }
)*) => ($(
s!(it: $(#[$attr])* pub $t $i { $($field)* });
)*);
(it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead");
);
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
__item! {
#[repr(C)]
#[cfg_attr(
feature = "extra_traits",
::core::prelude::v1::derive(Eq, Hash, PartialEq)
)]
#[::core::prelude::v1::derive(
::core::clone::Clone,
::core::marker::Copy,
::core::fmt::Debug,
)]
#[allow(deprecated)]
$(#[$attr])*
pub struct $i { $($field)* }
}
);
}
/// Implement `Clone` and `Copy` for a tuple struct, as well as `Debug`, `Eq`, `Hash`,
/// and `PartialEq` if the `extra_traits` feature is enabled.
///
/// This is the same as [`s`] but works for tuple structs.
macro_rules! s_paren {
($(
$(#[$attr:meta])*
pub struct $i:ident ( $($field:tt)* );
)*) => ($(
__item! {
#[cfg_attr(
feature = "extra_traits",
::core::prelude::v1::derive(Eq, Hash, PartialEq)
)]
#[::core::prelude::v1::derive(
::core::clone::Clone,
::core::marker::Copy,
::core::fmt::Debug,
)]
$(#[$attr])*
pub struct $i ( $($field)* );
}
)*);
}
/// Implement `Clone`, `Copy`, and `Debug` since those can be derived, but exclude `PartialEq`,
/// `Eq`, and `Hash`.
///
/// Most items will prefer to use [`s`].
macro_rules! s_no_extra_traits {
($(
$(#[$attr:meta])*
pub $t:ident $i:ident { $($field:tt)* }
)*) => ($(
s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* });
)*);
(it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
__item! {
#[repr(C)]
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
$(#[$attr])*
pub union $i { $($field)* }
}
impl ::core::fmt::Debug for $i {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct(::core::stringify!($i)).finish_non_exhaustive()
}
}
);
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
__item! {
#[repr(C)]
#[::core::prelude::v1::derive(
::core::clone::Clone,
::core::marker::Copy,
::core::fmt::Debug,
)]
$(#[$attr])*
pub struct $i { $($field)* }
}
);
}
/// Specify that an enum should have no traits that aren't specified in the macro
/// invocation, i.e. no `Clone` or `Copy`.
macro_rules! missing {
($(
$(#[$attr:meta])*
pub enum $i:ident {}
)*) => ($(
$(#[$attr])*
#[allow(missing_copy_implementations)]
pub enum $i { }
)*);
}
/// Implement `Clone` and `Copy` for an enum, as well as `Debug`, `Eq`, `Hash`, and
/// `PartialEq` if the `extra_traits` feature is enabled.
// FIXME(#4419): Replace all uses of `e!` with `c_enum!`
macro_rules! e {
($(
$(#[$attr:meta])*
pub enum $i:ident { $($field:tt)* }
)*) => ($(
__item! {
#[cfg_attr(
feature = "extra_traits",
::core::prelude::v1::derive(Eq, Hash, PartialEq)
)]
#[::core::prelude::v1::derive(
::core::clone::Clone,
::core::marker::Copy,
::core::fmt::Debug,
)]
$(#[$attr])*
pub enum $i { $($field)* }
}
)*);
}
/// Represent a C enum as Rust constants and a type.
///
/// C enums can't soundly be mapped to Rust enums since C enums are allowed to have duplicates or
/// unlisted values, but this is UB in Rust. This enum doesn't implement any traits, its main
/// purpose is to calculate the correct enum values.
///
/// See <https://github.com/rust-lang/libc/issues/4419> for more.
macro_rules! c_enum {
($(
$(#[repr($repr:ty)])?
pub enum $ty_name:ident {
$($variant:ident $(= $value:expr)?,)+
}
)+) => {
$(c_enum!(@expand;
$(#[repr($repr)])?
pub enum $ty_name {
$($variant $(= $value)?,)+
}
);)+
};
(@expand;
$(#[repr($repr:ty)])?
pub enum $ty_name:ident {
$($variant:ident $(= $value:expr)?,)+
}
) => {
pub type $ty_name = c_enum!(@ty $($repr)?);
c_enum!(@one; $ty_name; 0; $($variant $(= $value)?,)+);
};
// Matcher for a single variant
(@one; $_ty_name:ident; $_idx:expr;) => {};
(
@one; $ty_name:ident; $default_val:expr;
$variant:ident $(= $value:expr)?,
$($tail:tt)*
) => {
pub const $variant: $ty_name = {
#[allow(unused_variables)]
let r = $default_val;
$(let r = $value;)?
r
};
// The next value is always one more than the previous value, unless
// set explicitly.
c_enum!(@one; $ty_name; $variant + 1; $($tail)*);
};
// Use a specific type if provided, otherwise default to `CEnumRepr`
(@ty $repr:ty) => { $repr };
(@ty) => { $crate::prelude::CEnumRepr };
}
/// Define a `unsafe` function.
macro_rules! f {
($(
$(#[$attr:meta])*
// Less than ideal hack to match either `fn` or `const fn`.
pub $(fn $i:ident)? $(const fn $const_i:ident)?
($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
$body:block
)+) => {$(
#[inline]
$(#[$attr])*
pub $(unsafe extern "C" fn $i)? $(const unsafe extern "C" fn $const_i)?
($($arg: $argty),*) -> $ret
$body
)+};
}
/// Define a safe function.
macro_rules! safe_f {
($(
$(#[$attr:meta])*
// Less than ideal hack to match either `fn` or `const fn`.
pub $(fn $i:ident)? $(const fn $const_i:ident)?
($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
$body:block
)+) => {$(
#[inline]
$(#[$attr])*
pub $(extern "C" fn $i)? $(const extern "C" fn $const_i)?
($($arg: $argty),*) -> $ret
$body
)+};
}
macro_rules! __item {
($i:item) => {
$i
};
}
// This macro is used to deprecate items that should be accessed via the mach2 crate
macro_rules! deprecated_mach {
(pub const $id:ident: $ty:ty = $expr:expr;) => {
#[deprecated(
since = "0.2.55",
note = "Use the `mach2` crate instead",
)]
#[allow(deprecated)]
pub const $id: $ty = $expr;
};
($(pub const $id:ident: $ty:ty = $expr:expr;)*) => {
$(
deprecated_mach!(
pub const $id: $ty = $expr;
);
)*
};
(pub type $id:ident = $ty:ty;) => {
#[deprecated(
since = "0.2.55",
note = "Use the `mach2` crate instead",
)]
#[allow(deprecated)]
pub type $id = $ty;
};
($(pub type $id:ident = $ty:ty;)*) => {
$(
deprecated_mach!(
pub type $id = $ty;
);
)*
}
}
#[cfg(test)]
mod tests {
use crate::types::CEnumRepr;
#[test]
fn c_enumbasic() {
// By default, variants get sequential values.
c_enum! {
pub enum e {
VAR0,
VAR1,
VAR2,
}
}
assert_eq!(VAR0, 0 as CEnumRepr);
assert_eq!(VAR1, 1 as CEnumRepr);
assert_eq!(VAR2, 2 as CEnumRepr);
}
#[test]
fn c_enumrepr() {
// By default, variants get sequential values.
c_enum! {
#[repr(u16)]
pub enum e {
VAR0,
}
}
assert_eq!(VAR0, 0_u16);
}
#[test]
fn c_enumset_value() {
// Setting an explicit value resets the count.
c_enum! {
pub enum e {
VAR2 = 2,
VAR3,
VAR4,
}
}
assert_eq!(VAR2, 2 as CEnumRepr);
assert_eq!(VAR3, 3 as CEnumRepr);
assert_eq!(VAR4, 4 as CEnumRepr);
}
#[test]
fn c_enummultiple_set_value() {
// C enums always take one more than the previous value, unless set to a specific
// value. Duplicates are allowed.
c_enum! {
pub enum e {
VAR0,
VAR2_0 = 2,
VAR3_0,
VAR4_0,
VAR2_1 = 2,
VAR3_1,
VAR4_1,
}
}
assert_eq!(VAR0, 0 as CEnumRepr);
assert_eq!(VAR2_0, 2 as CEnumRepr);
assert_eq!(VAR3_0, 3 as CEnumRepr);
assert_eq!(VAR4_0, 4 as CEnumRepr);
assert_eq!(VAR2_1, 2 as CEnumRepr);
assert_eq!(VAR3_1, 3 as CEnumRepr);
assert_eq!(VAR4_1, 4 as CEnumRepr);
}
}

2
vendor/libc/src/new/bionic/mod.rs vendored Normal file
View File

@@ -0,0 +1,2 @@
mod sys;
pub use sys::*;

2
vendor/libc/src/new/bionic/sys/mod.rs vendored Normal file
View File

@@ -0,0 +1,2 @@
mod socket;
pub use socket::*;

View File

@@ -0,0 +1,51 @@
//! Header: `bionic/libc/include/sys/socket.h`
use crate::prelude::*;
s! {
pub struct msghdr {
pub msg_name: *mut c_void,
pub msg_namelen: crate::socklen_t,
pub msg_iov: *mut crate::iovec,
pub msg_iovlen: size_t,
pub msg_control: *mut c_void,
pub msg_controllen: size_t,
pub msg_flags: c_int,
}
pub struct cmsghdr {
pub cmsg_len: size_t,
pub cmsg_level: c_int,
pub cmsg_type: c_int,
}
pub struct ucred {
pub pid: crate::pid_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
}
}
extern "C" {
pub fn recvmmsg(
sockfd: c_int,
msgvec: *mut crate::mmsghdr,
vlen: c_uint,
flags: c_int,
timeout: *const crate::timespec,
) -> c_int;
pub fn sendmmsg(
sockfd: c_int,
msgvec: *const crate::mmsghdr,
vlen: c_uint,
flags: c_int,
) -> c_int;
pub fn recvfrom(
socket: c_int,
buf: *mut c_void,
len: size_t,
flags: c_int,
addr: *mut crate::sockaddr,
addrlen: *mut crate::socklen_t,
) -> ssize_t;
}

View File

@@ -0,0 +1,136 @@
//! Header: `uapi/linux/can.h`
pub(crate) mod j1939;
pub(crate) mod raw;
pub use j1939::*;
pub use raw::*;
use crate::prelude::*;
pub const CAN_EFF_FLAG: canid_t = 0x80000000;
pub const CAN_RTR_FLAG: canid_t = 0x40000000;
pub const CAN_ERR_FLAG: canid_t = 0x20000000;
pub const CAN_SFF_MASK: canid_t = 0x000007FF;
pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF;
pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF;
pub const CANXL_PRIO_MASK: crate::canid_t = CAN_SFF_MASK;
pub type canid_t = u32;
pub const CAN_SFF_ID_BITS: c_int = 11;
pub const CAN_EFF_ID_BITS: c_int = 29;
pub const CANXL_PRIO_BITS: c_int = CAN_SFF_ID_BITS;
pub type can_err_mask_t = u32;
pub const CAN_MAX_DLC: c_int = 8;
pub const CAN_MAX_DLEN: usize = 8;
pub const CANFD_MAX_DLC: c_int = 15;
pub const CANFD_MAX_DLEN: usize = 64;
pub const CANXL_MIN_DLC: c_int = 0;
pub const CANXL_MAX_DLC: c_int = 2047;
pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF;
pub const CANXL_MIN_DLEN: usize = 1;
pub const CANXL_MAX_DLEN: usize = 2048;
s! {
#[repr(align(8))]
pub struct can_frame {
pub can_id: canid_t,
// FIXME(1.0): this field was renamed to `len` in Linux 5.11
pub can_dlc: u8,
__pad: u8,
__res0: u8,
pub len8_dlc: u8,
pub data: [u8; CAN_MAX_DLEN],
}
}
pub const CANFD_BRS: c_int = 0x01;
pub const CANFD_ESI: c_int = 0x02;
pub const CANFD_FDF: c_int = 0x04;
s! {
#[repr(align(8))]
pub struct canfd_frame {
pub can_id: canid_t,
pub len: u8,
pub flags: u8,
__res0: u8,
__res1: u8,
pub data: [u8; CANFD_MAX_DLEN],
}
}
pub const CANXL_XLF: c_int = 0x80;
pub const CANXL_SEC: c_int = 0x01;
s! {
#[repr(align(8))]
pub struct canxl_frame {
pub prio: canid_t,
pub flags: u8,
pub sdt: u8,
pub len: u16,
pub af: u32,
pub data: [u8; CANXL_MAX_DLEN],
}
}
pub const CAN_MTU: usize = size_of::<can_frame>();
pub const CANFD_MTU: usize = size_of::<canfd_frame>();
pub const CANXL_MTU: usize = size_of::<canxl_frame>();
// FIXME(offset_of): use `core::mem::offset_of!` once that is available
// https://github.com/rust-lang/rfcs/pull/3308
// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data);
pub const CANXL_HDR_SIZE: usize = 12;
pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64;
pub const CANXL_MAX_MTU: usize = CANXL_MTU;
pub const CAN_RAW: c_int = 1;
pub const CAN_BCM: c_int = 2;
pub const CAN_TP16: c_int = 3;
pub const CAN_TP20: c_int = 4;
pub const CAN_MCNET: c_int = 5;
pub const CAN_ISOTP: c_int = 6;
pub const CAN_J1939: c_int = 7;
pub const CAN_NPROTO: c_int = 8;
pub const SOL_CAN_BASE: c_int = 100;
s_no_extra_traits! {
pub struct sockaddr_can {
pub can_family: crate::sa_family_t,
pub can_ifindex: c_int,
pub can_addr: __c_anonymous_sockaddr_can_can_addr,
}
pub union __c_anonymous_sockaddr_can_can_addr {
pub tp: __c_anonymous_sockaddr_can_tp,
pub j1939: __c_anonymous_sockaddr_can_j1939,
}
}
s! {
pub struct __c_anonymous_sockaddr_can_tp {
pub rx_id: canid_t,
pub tx_id: canid_t,
}
pub struct __c_anonymous_sockaddr_can_j1939 {
pub name: u64,
pub pgn: u32,
pub addr: u8,
}
pub struct can_filter {
pub can_id: canid_t,
pub can_mask: canid_t,
}
}
pub const CAN_INV_FILTER: canid_t = 0x20000000;

View File

@@ -0,0 +1,60 @@
//! `linux/can/j1939.h`
pub use crate::linux::can::*;
pub const J1939_MAX_UNICAST_ADDR: c_uchar = 0xfd;
pub const J1939_IDLE_ADDR: c_uchar = 0xfe;
pub const J1939_NO_ADDR: c_uchar = 0xff;
pub const J1939_NO_NAME: c_ulong = 0;
pub const J1939_PGN_REQUEST: c_uint = 0x0ea00;
pub const J1939_PGN_ADDRESS_CLAIMED: c_uint = 0x0ee00;
pub const J1939_PGN_ADDRESS_COMMANDED: c_uint = 0x0fed8;
pub const J1939_PGN_PDU1_MAX: c_uint = 0x3ff00;
pub const J1939_PGN_MAX: c_uint = 0x3ffff;
pub const J1939_NO_PGN: c_uint = 0x40000;
pub type pgn_t = u32;
pub type priority_t = u8;
pub type name_t = u64;
pub const SOL_CAN_J1939: c_int = SOL_CAN_BASE + CAN_J1939;
// FIXME(cleanup): these could use c_enum if it can accept anonymous enums.
pub const SO_J1939_FILTER: c_int = 1;
pub const SO_J1939_PROMISC: c_int = 2;
pub const SO_J1939_SEND_PRIO: c_int = 3;
pub const SO_J1939_ERRQUEUE: c_int = 4;
pub const SCM_J1939_DEST_ADDR: c_int = 1;
pub const SCM_J1939_DEST_NAME: c_int = 2;
pub const SCM_J1939_PRIO: c_int = 3;
pub const SCM_J1939_ERRQUEUE: c_int = 4;
pub const J1939_NLA_PAD: c_int = 0;
pub const J1939_NLA_BYTES_ACKED: c_int = 1;
pub const J1939_NLA_TOTAL_SIZE: c_int = 2;
pub const J1939_NLA_PGN: c_int = 3;
pub const J1939_NLA_SRC_NAME: c_int = 4;
pub const J1939_NLA_DEST_NAME: c_int = 5;
pub const J1939_NLA_SRC_ADDR: c_int = 6;
pub const J1939_NLA_DEST_ADDR: c_int = 7;
pub const J1939_EE_INFO_NONE: c_int = 0;
pub const J1939_EE_INFO_TX_ABORT: c_int = 1;
pub const J1939_EE_INFO_RX_RTS: c_int = 2;
pub const J1939_EE_INFO_RX_DPO: c_int = 3;
pub const J1939_EE_INFO_RX_ABORT: c_int = 4;
s! {
pub struct j1939_filter {
pub name: name_t,
pub name_mask: name_t,
pub pgn: pgn_t,
pub pgn_mask: pgn_t,
pub addr: u8,
pub addr_mask: u8,
}
}
pub const J1939_FILTER_MAX: c_int = 512;

View File

@@ -0,0 +1,15 @@
//! `linux/can/raw.h`
pub use crate::linux::can::*;
pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW;
pub const CAN_RAW_FILTER_MAX: c_int = 512;
// FIXME(cleanup): use `c_enum!`, which needs to be adapted to allow omitting a type.
pub const CAN_RAW_FILTER: c_int = 1;
pub const CAN_RAW_ERR_FILTER: c_int = 2;
pub const CAN_RAW_LOOPBACK: c_int = 3;
pub const CAN_RAW_RECV_OWN_MSGS: c_int = 4;
pub const CAN_RAW_FD_FRAMES: c_int = 5;
pub const CAN_RAW_JOIN_FILTERS: c_int = 6;
pub const CAN_RAW_XL_FRAMES: c_int = 7;

View File

@@ -0,0 +1,4 @@
//! The `linux` directory within `include/uapi` in the Linux source tree.
pub(crate) mod can;
pub use can::*;

4
vendor/libc/src/new/linux_uapi/mod.rs vendored Normal file
View File

@@ -0,0 +1,4 @@
//! This directory maps to `include/uapi` in the Linux source tree.
pub(crate) mod linux;
pub use linux::*;

15
vendor/libc/src/new/mod.rs vendored Normal file
View File

@@ -0,0 +1,15 @@
//! This module contains the future directory structure. If possible, new definitions should
//! get added here.
//!
//! Eventually everything should be moved over, and we will move this directory to the top
//! level in `src`.
cfg_if! {
if #[cfg(target_os = "linux")] {
mod linux_uapi;
pub use linux_uapi::*;
} else if #[cfg(target_os = "android")] {
mod bionic;
pub use bionic::*;
}
}

95
vendor/libc/src/primitives.rs vendored Normal file
View File

@@ -0,0 +1,95 @@
//! This module contains type aliases for C's platform-specific types
//! and fixed-width integer types.
//!
//! The platform-specific types definitions were taken from rust-lang/rust in
//! library/core/src/ffi/primitives.rs
//!
//! The fixed-width integer aliases are deprecated: use the Rust types instead.
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type c_float = f32;
pub type c_double = f64;
cfg_if! {
if #[cfg(all(
not(windows),
not(target_vendor = "apple"),
not(target_os = "vita"),
any(
target_arch = "aarch64",
target_arch = "arm",
target_arch = "csky",
target_arch = "hexagon",
target_arch = "msp430",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "riscv32",
target_arch = "riscv64",
target_arch = "s390x",
target_arch = "xtensa",
)
))] {
pub type c_char = u8;
} else {
// On every other target, c_char is signed.
pub type c_char = i8;
}
}
cfg_if! {
if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] {
pub type c_int = i16;
pub type c_uint = u16;
} else {
pub type c_int = i32;
pub type c_uint = u32;
}
}
cfg_if! {
if #[cfg(all(target_pointer_width = "64", not(windows)))] {
pub type c_long = i64;
pub type c_ulong = u64;
} else {
// The minimal size of `long` in the C standard is 32 bits
pub type c_long = i32;
pub type c_ulong = u32;
}
}
#[deprecated(since = "0.2.55", note = "Use i8 instead.")]
pub type int8_t = i8;
#[deprecated(since = "0.2.55", note = "Use i16 instead.")]
pub type int16_t = i16;
#[deprecated(since = "0.2.55", note = "Use i32 instead.")]
pub type int32_t = i32;
#[deprecated(since = "0.2.55", note = "Use i64 instead.")]
pub type int64_t = i64;
#[deprecated(since = "0.2.55", note = "Use u8 instead.")]
pub type uint8_t = u8;
#[deprecated(since = "0.2.55", note = "Use u16 instead.")]
pub type uint16_t = u16;
#[deprecated(since = "0.2.55", note = "Use u32 instead.")]
pub type uint32_t = u32;
#[deprecated(since = "0.2.55", note = "Use u64 instead.")]
pub type uint64_t = u64;
cfg_if! {
if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] {
/// C `__int128` (a GCC extension that's part of many ABIs)
pub type __int128 = i128;
/// C `unsigned __int128` (a GCC extension that's part of many ABIs)
pub type __uint128 = u128;
/// C __int128_t (alternate name for [__int128][])
pub type __int128_t = i128;
/// C __uint128_t (alternate name for [__uint128][])
pub type __uint128_t = u128;
}
}

4131
vendor/libc/src/psp.rs vendored Normal file

File diff suppressed because it is too large Load Diff

15
vendor/libc/src/sgx.rs vendored Normal file
View File

@@ -0,0 +1,15 @@
//! SGX C types definition
use crate::prelude::*;
pub type intmax_t = i64;
pub type uintmax_t = u64;
pub type size_t = usize;
pub type ptrdiff_t = isize;
pub type intptr_t = isize;
pub type uintptr_t = usize;
pub type ssize_t = isize;
pub const INT_MIN: c_int = -2147483648;
pub const INT_MAX: c_int = 2147483647;

1
vendor/libc/src/solid/aarch64.rs vendored Normal file
View File

@@ -0,0 +1 @@
pub type wchar_t = u32;

1
vendor/libc/src/solid/arm.rs vendored Normal file
View File

@@ -0,0 +1 @@
pub type wchar_t = u32;

876
vendor/libc/src/solid/mod.rs vendored Normal file
View File

@@ -0,0 +1,876 @@
//! Interface to the [SOLID] C library
//!
//! [SOLID]: https://solid.kmckk.com/
use crate::prelude::*;
pub type intmax_t = i64;
pub type uintmax_t = u64;
pub type uintptr_t = usize;
pub type intptr_t = isize;
pub type ptrdiff_t = isize;
pub type size_t = crate::uintptr_t;
pub type ssize_t = intptr_t;
pub type clock_t = c_uint;
pub type time_t = i64;
pub type clockid_t = c_int;
pub type timer_t = c_int;
pub type suseconds_t = c_int;
pub type useconds_t = c_uint;
pub type sighandler_t = size_t;
// sys/ansi.h
pub type __caddr_t = *mut c_char;
pub type __gid_t = u32;
pub type __in_addr_t = u32;
pub type __in_port_t = u16;
pub type __mode_t = u32;
pub type __off_t = i64;
pub type __pid_t = i32;
pub type __sa_family_t = u8;
pub type __socklen_t = c_uint;
pub type __uid_t = u32;
pub type __fsblkcnt_t = u64;
pub type __fsfilcnt_t = u64;
// locale.h
pub type locale_t = usize;
// nl_types.h
pub type nl_item = c_long;
// sys/types.h
pub type __va_list = *mut c_char;
pub type u_int8_t = u8;
pub type u_int16_t = u16;
pub type u_int32_t = u32;
pub type u_int64_t = u64;
pub type u_char = c_uchar;
pub type u_short = c_ushort;
pub type u_int = c_uint;
pub type u_long = c_ulong;
pub type unchar = c_uchar;
pub type ushort = c_ushort;
pub type uint = c_uint;
pub type ulong = c_ulong;
pub type u_quad_t = u64;
pub type quad_t = i64;
pub type qaddr_t = *mut quad_t;
pub type longlong_t = i64;
pub type u_longlong_t = u64;
pub type blkcnt_t = i64;
pub type blksize_t = i32;
pub type fsblkcnt_t = __fsblkcnt_t;
pub type fsfilcnt_t = __fsfilcnt_t;
pub type caddr_t = __caddr_t;
pub type daddr_t = i64;
pub type dev_t = u64;
pub type fixpt_t = u32;
pub type gid_t = __gid_t;
pub type idtype_t = c_int;
pub type id_t = u32;
pub type ino_t = u64;
pub type key_t = c_long;
pub type mode_t = __mode_t;
pub type nlink_t = u32;
pub type off_t = __off_t;
pub type pid_t = __pid_t;
pub type lwpid_t = i32;
pub type rlim_t = u64;
pub type segsz_t = i32;
pub type swblk_t = i32;
pub type mqd_t = c_int;
pub type cpuid_t = c_ulong;
pub type psetid_t = c_int;
s! {
// stat.h
pub struct stat {
pub st_dev: dev_t,
pub st_ino: ino_t,
pub st_mode: c_short,
pub st_nlink: c_short,
pub st_uid: c_short,
pub st_gid: c_short,
pub st_rdev: dev_t,
pub st_size: off_t,
pub st_atime: time_t,
pub st_mtime: time_t,
pub st_ctime: time_t,
pub st_blksize: blksize_t,
}
// time.h
pub struct tm {
pub tm_sec: c_int,
pub tm_min: c_int,
pub tm_hour: c_int,
pub tm_mday: c_int,
pub tm_mon: c_int,
pub tm_year: c_int,
pub tm_wday: c_int,
pub tm_yday: c_int,
pub tm_isdst: c_int,
pub tm_gmtoff: c_long,
pub tm_zone: *mut c_char,
}
// stdlib.h
pub struct qdiv_t {
pub quot: quad_t,
pub rem: quad_t,
}
pub struct lldiv_t {
pub quot: c_longlong,
pub rem: c_longlong,
}
pub struct div_t {
pub quot: c_int,
pub rem: c_int,
}
pub struct ldiv_t {
pub quot: c_long,
pub rem: c_long,
}
// locale.h
pub struct lconv {
pub decimal_point: *mut c_char,
pub thousands_sep: *mut c_char,
pub grouping: *mut c_char,
pub int_curr_symbol: *mut c_char,
pub currency_symbol: *mut c_char,
pub mon_decimal_point: *mut c_char,
pub mon_thousands_sep: *mut c_char,
pub mon_grouping: *mut c_char,
pub positive_sign: *mut c_char,
pub negative_sign: *mut c_char,
pub int_frac_digits: c_char,
pub frac_digits: c_char,
pub p_cs_precedes: c_char,
pub p_sep_by_space: c_char,
pub n_cs_precedes: c_char,
pub n_sep_by_space: c_char,
pub p_sign_posn: c_char,
pub n_sign_posn: c_char,
pub int_p_cs_precedes: c_char,
pub int_n_cs_precedes: c_char,
pub int_p_sep_by_space: c_char,
pub int_n_sep_by_space: c_char,
pub int_p_sign_posn: c_char,
pub int_n_sign_posn: c_char,
}
pub struct iovec {
pub iov_base: *mut c_void,
pub iov_len: size_t,
}
pub struct timeval {
pub tv_sec: c_long,
pub tv_usec: c_long,
}
}
pub const INT_MIN: c_int = -2147483648;
pub const INT_MAX: c_int = 2147483647;
pub const EXIT_FAILURE: c_int = 1;
pub const EXIT_SUCCESS: c_int = 0;
pub const RAND_MAX: c_int = 0x7fffffff;
pub const EOF: c_int = -1;
pub const SEEK_SET: c_int = 0;
pub const SEEK_CUR: c_int = 1;
pub const SEEK_END: c_int = 2;
pub const _IOFBF: c_int = 0;
pub const _IONBF: c_int = 2;
pub const _IOLBF: c_int = 1;
pub const BUFSIZ: c_uint = 1024;
pub const FOPEN_MAX: c_uint = 20;
pub const FILENAME_MAX: c_uint = 1024;
pub const O_RDONLY: c_int = 1;
pub const O_WRONLY: c_int = 2;
pub const O_RDWR: c_int = 4;
pub const O_APPEND: c_int = 8;
pub const O_CREAT: c_int = 0x10;
pub const O_EXCL: c_int = 0x400;
pub const O_TEXT: c_int = 0x100;
pub const O_BINARY: c_int = 0x200;
pub const O_TRUNC: c_int = 0x20;
pub const S_IEXEC: c_short = 0o0100;
pub const S_IWRITE: c_short = 0o0200;
pub const S_IREAD: c_short = 0o0400;
pub const S_IFCHR: c_short = 0o2_0000;
pub const S_IFDIR: c_short = 0o4_0000;
pub const S_IFMT: c_short = 0o16_0000;
pub const S_IFIFO: c_short = 0o1_0000;
pub const S_IFBLK: c_short = 0o6_0000;
pub const S_IFREG: c_short = 0o10_0000;
pub const LC_ALL: c_int = 0;
pub const LC_COLLATE: c_int = 1;
pub const LC_CTYPE: c_int = 2;
pub const LC_MONETARY: c_int = 3;
pub const LC_NUMERIC: c_int = 4;
pub const LC_TIME: c_int = 5;
pub const LC_MESSAGES: c_int = 6;
pub const _LC_LAST: c_int = 7;
pub const EPERM: c_int = 1;
pub const ENOENT: c_int = 2;
pub const ESRCH: c_int = 3;
pub const EINTR: c_int = 4;
pub const EIO: c_int = 5;
pub const ENXIO: c_int = 6;
pub const E2BIG: c_int = 7;
pub const ENOEXEC: c_int = 8;
pub const EBADF: c_int = 9;
pub const ECHILD: c_int = 10;
pub const EAGAIN: c_int = 11;
pub const ENOMEM: c_int = 12;
pub const EACCES: c_int = 13;
pub const EFAULT: c_int = 14;
pub const ENOTBLK: c_int = 15;
pub const EBUSY: c_int = 16;
pub const EEXIST: c_int = 17;
pub const EXDEV: c_int = 18;
pub const ENODEV: c_int = 19;
pub const ENOTDIR: c_int = 20;
pub const EISDIR: c_int = 21;
pub const EINVAL: c_int = 22;
pub const ENFILE: c_int = 23;
pub const EMFILE: c_int = 24;
pub const ENOTTY: c_int = 25;
pub const ETXTBSY: c_int = 26;
pub const EFBIG: c_int = 27;
pub const ENOSPC: c_int = 28;
pub const ESPIPE: c_int = 29;
pub const EROFS: c_int = 30;
pub const EMLINK: c_int = 31;
pub const EPIPE: c_int = 32;
pub const EDOM: c_int = 33;
pub const ERANGE: c_int = 34;
pub const EDEADLK: c_int = 35;
pub const ENAMETOOLONG: c_int = 36;
pub const ENOLCK: c_int = 37;
pub const ENOSYS: c_int = 38;
pub const ENOTEMPTY: c_int = 39;
pub const ELOOP: c_int = 40;
pub const EWOULDBLOCK: c_int = EAGAIN;
pub const ENOMSG: c_int = 42;
pub const EIDRM: c_int = 43;
pub const ECHRNG: c_int = 44;
pub const EL2NSYNC: c_int = 45;
pub const EL3HLT: c_int = 46;
pub const EL3RST: c_int = 47;
pub const ELNRNG: c_int = 48;
pub const EUNATCH: c_int = 49;
pub const ENOCSI: c_int = 50;
pub const EL2HLT: c_int = 51;
pub const EBADE: c_int = 52;
pub const EBADR: c_int = 53;
pub const EXFULL: c_int = 54;
pub const ENOANO: c_int = 55;
pub const EBADRQC: c_int = 56;
pub const EBADSLT: c_int = 57;
pub const EDEADLOCK: c_int = EDEADLK;
pub const EBFONT: c_int = 59;
pub const ENOSTR: c_int = 60;
pub const ENODATA: c_int = 61;
pub const ETIME: c_int = 62;
pub const ENOSR: c_int = 63;
pub const ENONET: c_int = 64;
pub const ENOPKG: c_int = 65;
pub const EREMOTE: c_int = 66;
pub const ENOLINK: c_int = 67;
pub const EADV: c_int = 68;
pub const ESRMNT: c_int = 69;
pub const ECOMM: c_int = 70;
pub const EPROTO: c_int = 71;
pub const EMULTIHOP: c_int = 72;
pub const EDOTDOT: c_int = 73;
pub const EBADMSG: c_int = 74;
pub const EOVERFLOW: c_int = 75;
pub const ENOTUNIQ: c_int = 76;
pub const EBADFD: c_int = 77;
pub const EREMCHG: c_int = 78;
pub const ELIBACC: c_int = 79;
pub const ELIBBAD: c_int = 80;
pub const ELIBSCN: c_int = 81;
pub const ELIBMAX: c_int = 82;
pub const ELIBEXEC: c_int = 83;
pub const EILSEQ: c_int = 84;
pub const ERESTART: c_int = 85;
pub const ESTRPIPE: c_int = 86;
pub const EUSERS: c_int = 87;
pub const ENOTSOCK: c_int = 88;
pub const EDESTADDRREQ: c_int = 89;
pub const EMSGSIZE: c_int = 90;
pub const EPROTOTYPE: c_int = 91;
pub const ENOPROTOOPT: c_int = 92;
pub const EPROTONOSUPPORT: c_int = 93;
pub const ESOCKTNOSUPPORT: c_int = 94;
pub const EOPNOTSUPP: c_int = 95;
pub const EPFNOSUPPORT: c_int = 96;
pub const EAFNOSUPPORT: c_int = 97;
pub const EADDRINUSE: c_int = 98;
pub const EADDRNOTAVAIL: c_int = 99;
pub const ENETDOWN: c_int = 100;
pub const ENETUNREACH: c_int = 101;
pub const ENETRESET: c_int = 102;
pub const ECONNABORTED: c_int = 103;
pub const ECONNRESET: c_int = 104;
pub const ENOBUFS: c_int = 105;
pub const EISCONN: c_int = 106;
pub const ENOTCONN: c_int = 107;
pub const ESHUTDOWN: c_int = 108;
pub const ETOOMANYREFS: c_int = 109;
pub const ETIMEDOUT: c_int = 110;
pub const ECONNREFUSED: c_int = 111;
pub const EHOSTDOWN: c_int = 112;
pub const EHOSTUNREACH: c_int = 113;
pub const EALREADY: c_int = 114;
pub const EINPROGRESS: c_int = 115;
pub const ESTALE: c_int = 116;
pub const EUCLEAN: c_int = 117;
pub const ENOTNAM: c_int = 118;
pub const ENAVAIL: c_int = 119;
pub const EISNAM: c_int = 120;
pub const EREMOTEIO: c_int = 121;
pub const EDQUOT: c_int = 122;
pub const ENOMEDIUM: c_int = 123;
pub const EMEDIUMTYPE: c_int = 124;
pub const ECANCELED: c_int = 125;
pub const ENOKEY: c_int = 126;
pub const EKEYEXPIRED: c_int = 127;
pub const EKEYREVOKED: c_int = 128;
pub const EKEYREJECTED: c_int = 129;
pub const EOWNERDEAD: c_int = 130;
pub const ENOTRECOVERABLE: c_int = 131;
pub const ENOTSUP: c_int = 132;
pub const EFTYPE: c_int = 133;
// signal codes
pub const SIGHUP: c_int = 1;
pub const SIGINT: c_int = 2;
pub const SIGQUIT: c_int = 3;
pub const SIGILL: c_int = 4;
pub const SIGTRAP: c_int = 5;
pub const SIGABRT: c_int = 6;
pub const SIGIOT: c_int = SIGABRT;
pub const SIGEMT: c_int = 7;
pub const SIGFPE: c_int = 8;
pub const SIGKILL: c_int = 9;
pub const SIGBUS: c_int = 10;
pub const SIGSEGV: c_int = 11;
pub const SIGSYS: c_int = 12;
pub const SIGPIPE: c_int = 13;
pub const SIGALRM: c_int = 14;
pub const SIGTERM: c_int = 15;
pub const SIGURG: c_int = 16;
pub const SIGSTOP: c_int = 17;
pub const SIGTSTP: c_int = 18;
pub const SIGCONT: c_int = 19;
pub const SIGCHLD: c_int = 20;
pub const SIGTTIN: c_int = 21;
pub const SIGTTOU: c_int = 22;
pub const SIGIO: c_int = 23;
pub const SIGXCPU: c_int = 24;
pub const SIGXFSZ: c_int = 25;
pub const SIGVTALRM: c_int = 26;
pub const SIGPROF: c_int = 27;
pub const SIGWINCH: c_int = 28;
pub const SIGINFO: c_int = 29;
pub const SIGUSR1: c_int = 30;
pub const SIGUSR2: c_int = 31;
pub const SIGPWR: c_int = 32;
#[derive(Debug)]
pub enum FILE {}
impl Copy for FILE {}
impl Clone for FILE {
fn clone(&self) -> FILE {
*self
}
}
#[derive(Debug)]
pub enum fpos_t {}
impl Copy for fpos_t {}
impl Clone for fpos_t {
fn clone(&self) -> fpos_t {
*self
}
}
extern "C" {
// ctype.h
pub fn isalnum(c: c_int) -> c_int;
pub fn isalpha(c: c_int) -> c_int;
pub fn iscntrl(c: c_int) -> c_int;
pub fn isdigit(c: c_int) -> c_int;
pub fn isgraph(c: c_int) -> c_int;
pub fn islower(c: c_int) -> c_int;
pub fn isprint(c: c_int) -> c_int;
pub fn ispunct(c: c_int) -> c_int;
pub fn isspace(c: c_int) -> c_int;
pub fn isupper(c: c_int) -> c_int;
pub fn isxdigit(c: c_int) -> c_int;
pub fn isblank(c: c_int) -> c_int;
pub fn tolower(c: c_int) -> c_int;
pub fn toupper(c: c_int) -> c_int;
// stdio.h
pub fn __get_stdio_file(fileno: c_int) -> *mut FILE;
pub fn clearerr(arg1: *mut FILE);
pub fn fclose(arg1: *mut FILE) -> c_int;
pub fn feof(arg1: *mut FILE) -> c_int;
pub fn ferror(arg1: *mut FILE) -> c_int;
pub fn fflush(arg1: *mut FILE) -> c_int;
pub fn fgetc(arg1: *mut FILE) -> c_int;
pub fn fgets(arg1: *mut c_char, arg2: c_int, arg3: *mut FILE) -> *mut c_char;
pub fn fopen(arg1: *const c_char, arg2: *const c_char) -> *mut FILE;
pub fn fprintf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int;
pub fn fputc(arg1: c_int, arg2: *mut FILE) -> c_int;
pub fn fputs(arg1: *const c_char, arg2: *mut FILE) -> c_int;
pub fn fread(arg1: *mut c_void, arg2: size_t, arg3: size_t, arg4: *mut FILE) -> size_t;
pub fn freopen(arg1: *const c_char, arg2: *const c_char, arg3: *mut FILE) -> *mut FILE;
pub fn fscanf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int;
pub fn fseek(arg1: *mut FILE, arg2: c_long, arg3: c_int) -> c_int;
pub fn ftell(arg1: *mut FILE) -> c_long;
pub fn fwrite(arg1: *const c_void, arg2: size_t, arg3: size_t, arg4: *mut FILE) -> size_t;
pub fn getc(arg1: *mut FILE) -> c_int;
pub fn getchar() -> c_int;
pub fn perror(arg1: *const c_char);
pub fn printf(arg1: *const c_char, ...) -> c_int;
pub fn putc(arg1: c_int, arg2: *mut FILE) -> c_int;
pub fn putchar(arg1: c_int) -> c_int;
pub fn puts(arg1: *const c_char) -> c_int;
pub fn remove(arg1: *const c_char) -> c_int;
pub fn rewind(arg1: *mut FILE);
pub fn scanf(arg1: *const c_char, ...) -> c_int;
pub fn setbuf(arg1: *mut FILE, arg2: *mut c_char);
pub fn setvbuf(arg1: *mut FILE, arg2: *mut c_char, arg3: c_int, arg4: size_t) -> c_int;
pub fn sscanf(arg1: *const c_char, arg2: *const c_char, ...) -> c_int;
pub fn tmpfile() -> *mut FILE;
pub fn ungetc(arg1: c_int, arg2: *mut FILE) -> c_int;
pub fn vfprintf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int;
pub fn vprintf(arg1: *const c_char, arg2: __va_list) -> c_int;
pub fn gets(arg1: *mut c_char) -> *mut c_char;
pub fn sprintf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int;
pub fn tmpnam(arg1: *const c_char) -> *mut c_char;
pub fn vsprintf(arg1: *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int;
pub fn rename(arg1: *const c_char, arg2: *const c_char) -> c_int;
pub fn asiprintf(arg1: *mut *mut c_char, arg2: *const c_char, ...) -> c_int;
pub fn fiprintf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int;
pub fn fiscanf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int;
pub fn iprintf(arg1: *const c_char, ...) -> c_int;
pub fn iscanf(arg1: *const c_char, ...) -> c_int;
pub fn siprintf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int;
pub fn siscanf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int;
pub fn sniprintf(arg1: *mut c_char, arg2: size_t, arg3: *const c_char, ...) -> c_int;
pub fn vasiprintf(arg1: *mut *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int;
pub fn vfiprintf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int;
pub fn vfiscanf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int;
pub fn viprintf(arg1: *const c_char, arg2: __va_list) -> c_int;
pub fn viscanf(arg1: *const c_char, arg2: __va_list) -> c_int;
pub fn vsiprintf(arg1: *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int;
pub fn vsiscanf(arg1: *const c_char, arg2: *const c_char, arg3: __va_list) -> c_int;
pub fn vsniprintf(
arg1: *mut c_char,
arg2: size_t,
arg3: *const c_char,
arg4: __va_list,
) -> c_int;
pub fn vdiprintf(arg1: c_int, arg2: *const c_char, arg3: __va_list) -> c_int;
pub fn diprintf(arg1: c_int, arg2: *const c_char, ...) -> c_int;
pub fn fgetpos(arg1: *mut FILE, arg2: *mut fpos_t) -> c_int;
pub fn fsetpos(arg1: *mut FILE, arg2: *const fpos_t) -> c_int;
pub fn fdopen(arg1: c_int, arg2: *const c_char) -> *mut FILE;
pub fn fileno(arg1: *mut FILE) -> c_int;
pub fn flockfile(arg1: *mut FILE);
pub fn ftrylockfile(arg1: *mut FILE) -> c_int;
pub fn funlockfile(arg1: *mut FILE);
pub fn getc_unlocked(arg1: *mut FILE) -> c_int;
pub fn getchar_unlocked() -> c_int;
pub fn putc_unlocked(arg1: c_int, arg2: *mut FILE) -> c_int;
pub fn putchar_unlocked(arg1: c_int) -> c_int;
pub fn snprintf(arg1: *mut c_char, arg2: size_t, arg3: *const c_char, ...) -> c_int;
pub fn vsnprintf(
arg1: *mut c_char,
arg2: size_t,
arg3: *const c_char,
arg4: __va_list,
) -> c_int;
pub fn getw(arg1: *mut FILE) -> c_int;
pub fn putw(arg1: c_int, arg2: *mut FILE) -> c_int;
pub fn tempnam(arg1: *const c_char, arg2: *const c_char) -> *mut c_char;
pub fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int) -> c_int;
pub fn ftello(stream: *mut FILE) -> off_t;
// stdlib.h
pub fn atof(arg1: *const c_char) -> f64;
pub fn strtod(arg1: *const c_char, arg2: *mut *mut c_char) -> f64;
pub fn drand48() -> f64;
pub fn erand48(arg1: *mut c_ushort) -> f64;
pub fn strtof(arg1: *const c_char, arg2: *mut *mut c_char) -> f32;
pub fn strtold(arg1: *const c_char, arg2: *mut *mut c_char) -> f64;
pub fn strtod_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64;
pub fn strtof_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f32;
pub fn strtold_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64;
pub fn _Exit(arg1: c_int) -> !;
pub fn abort() -> !;
pub fn abs(arg1: c_int) -> c_int;
pub fn atexit(arg1: Option<unsafe extern "C" fn()>) -> c_int;
pub fn atoi(arg1: *const c_char) -> c_int;
pub fn atol(arg1: *const c_char) -> c_long;
pub fn itoa(arg1: c_int, arg2: *mut c_char, arg3: c_int) -> *mut c_char;
pub fn ltoa(arg1: c_long, arg2: *mut c_char, arg3: c_int) -> *mut c_char;
pub fn ultoa(arg1: c_ulong, arg2: *mut c_char, arg3: c_int) -> *mut c_char;
pub fn bsearch(
arg1: *const c_void,
arg2: *const c_void,
arg3: size_t,
arg4: size_t,
arg5: Option<unsafe extern "C" fn(arg1: *const c_void, arg2: *const c_void) -> c_int>,
) -> *mut c_void;
pub fn calloc(arg1: size_t, arg2: size_t) -> *mut c_void;
pub fn div(arg1: c_int, arg2: c_int) -> div_t;
pub fn exit(arg1: c_int) -> !;
pub fn free(arg1: *mut c_void);
pub fn getenv(arg1: *const c_char) -> *mut c_char;
pub fn labs(arg1: c_long) -> c_long;
pub fn ldiv(arg1: c_long, arg2: c_long) -> ldiv_t;
pub fn malloc(arg1: size_t) -> *mut c_void;
pub fn qsort(
arg1: *mut c_void,
arg2: size_t,
arg3: size_t,
arg4: Option<unsafe extern "C" fn(arg1: *const c_void, arg2: *const c_void) -> c_int>,
);
pub fn rand() -> c_int;
pub fn realloc(arg1: *mut c_void, arg2: size_t) -> *mut c_void;
pub fn srand(arg1: c_uint);
pub fn strtol(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_long;
pub fn strtoul(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulong;
pub fn mblen(arg1: *const c_char, arg2: size_t) -> c_int;
pub fn mbstowcs(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t) -> size_t;
pub fn wctomb(arg1: *mut c_char, arg2: wchar_t) -> c_int;
pub fn mbtowc(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t) -> c_int;
pub fn wcstombs(arg1: *mut c_char, arg2: *const wchar_t, arg3: size_t) -> size_t;
pub fn rand_r(arg1: *mut c_uint) -> c_int;
pub fn jrand48(arg1: *mut c_ushort) -> c_long;
pub fn lcong48(arg1: *mut c_ushort);
pub fn lrand48() -> c_long;
pub fn mrand48() -> c_long;
pub fn nrand48(arg1: *mut c_ushort) -> c_long;
pub fn seed48(arg1: *mut c_ushort) -> *mut c_ushort;
pub fn srand48(arg1: c_long);
pub fn putenv(arg1: *mut c_char) -> c_int;
pub fn a64l(arg1: *const c_char) -> c_long;
pub fn l64a(arg1: c_long) -> *mut c_char;
pub fn random() -> c_long;
pub fn setstate(arg1: *mut c_char) -> *mut c_char;
pub fn initstate(arg1: c_uint, arg2: *mut c_char, arg3: size_t) -> *mut c_char;
pub fn srandom(arg1: c_uint);
pub fn mkostemp(arg1: *mut c_char, arg2: c_int) -> c_int;
pub fn mkostemps(arg1: *mut c_char, arg2: c_int, arg3: c_int) -> c_int;
pub fn mkdtemp(arg1: *mut c_char) -> *mut c_char;
pub fn mkstemp(arg1: *mut c_char) -> c_int;
pub fn mktemp(arg1: *mut c_char) -> *mut c_char;
pub fn atoll(arg1: *const c_char) -> c_longlong;
pub fn llabs(arg1: c_longlong) -> c_longlong;
pub fn lldiv(arg1: c_longlong, arg2: c_longlong) -> lldiv_t;
pub fn strtoll(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_longlong;
pub fn strtoull(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulonglong;
pub fn aligned_alloc(arg1: size_t, arg2: size_t) -> *mut c_void;
pub fn at_quick_exit(arg1: Option<unsafe extern "C" fn()>) -> c_int;
pub fn quick_exit(arg1: c_int);
pub fn setenv(arg1: *const c_char, arg2: *const c_char, arg3: c_int) -> c_int;
pub fn unsetenv(arg1: *const c_char) -> c_int;
pub fn humanize_number(
arg1: *mut c_char,
arg2: size_t,
arg3: i64,
arg4: *const c_char,
arg5: c_int,
arg6: c_int,
) -> c_int;
pub fn dehumanize_number(arg1: *const c_char, arg2: *mut i64) -> c_int;
pub fn getenv_r(arg1: *const c_char, arg2: *mut c_char, arg3: size_t) -> c_int;
pub fn heapsort(
arg1: *mut c_void,
arg2: size_t,
arg3: size_t,
arg4: Option<unsafe extern "C" fn(arg1: *const c_void, arg2: *const c_void) -> c_int>,
) -> c_int;
pub fn mergesort(
arg1: *mut c_void,
arg2: size_t,
arg3: size_t,
arg4: Option<unsafe extern "C" fn(arg1: *const c_void, arg2: *const c_void) -> c_int>,
) -> c_int;
pub fn radixsort(
arg1: *mut *const c_uchar,
arg2: c_int,
arg3: *const c_uchar,
arg4: c_uint,
) -> c_int;
pub fn sradixsort(
arg1: *mut *const c_uchar,
arg2: c_int,
arg3: *const c_uchar,
arg4: c_uint,
) -> c_int;
pub fn getprogname() -> *const c_char;
pub fn setprogname(arg1: *const c_char);
pub fn qabs(arg1: quad_t) -> quad_t;
pub fn strtoq(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> quad_t;
pub fn strtouq(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> u_quad_t;
pub fn strsuftoll(
arg1: *const c_char,
arg2: *const c_char,
arg3: c_longlong,
arg4: c_longlong,
) -> c_longlong;
pub fn strsuftollx(
arg1: *const c_char,
arg2: *const c_char,
arg3: c_longlong,
arg4: c_longlong,
arg5: *mut c_char,
arg6: size_t,
) -> c_longlong;
pub fn l64a_r(arg1: c_long, arg2: *mut c_char, arg3: c_int) -> c_int;
pub fn qdiv(arg1: quad_t, arg2: quad_t) -> qdiv_t;
pub fn strtol_l(
arg1: *const c_char,
arg2: *mut *mut c_char,
arg3: c_int,
arg4: locale_t,
) -> c_long;
pub fn strtoul_l(
arg1: *const c_char,
arg2: *mut *mut c_char,
arg3: c_int,
arg4: locale_t,
) -> c_ulong;
pub fn strtoll_l(
arg1: *const c_char,
arg2: *mut *mut c_char,
arg3: c_int,
arg4: locale_t,
) -> c_longlong;
pub fn strtoull_l(
arg1: *const c_char,
arg2: *mut *mut c_char,
arg3: c_int,
arg4: locale_t,
) -> c_ulonglong;
pub fn strtoq_l(
arg1: *const c_char,
arg2: *mut *mut c_char,
arg3: c_int,
arg4: locale_t,
) -> quad_t;
pub fn strtouq_l(
arg1: *const c_char,
arg2: *mut *mut c_char,
arg3: c_int,
arg4: locale_t,
) -> u_quad_t;
pub fn _mb_cur_max_l(arg1: locale_t) -> size_t;
pub fn mblen_l(arg1: *const c_char, arg2: size_t, arg3: locale_t) -> c_int;
pub fn mbstowcs_l(
arg1: *mut wchar_t,
arg2: *const c_char,
arg3: size_t,
arg4: locale_t,
) -> size_t;
pub fn wctomb_l(arg1: *mut c_char, arg2: wchar_t, arg3: locale_t) -> c_int;
pub fn mbtowc_l(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t, arg4: locale_t)
-> c_int;
pub fn wcstombs_l(
arg1: *mut c_char,
arg2: *const wchar_t,
arg3: size_t,
arg4: locale_t,
) -> size_t;
// string.h
pub fn memchr(arg1: *const c_void, arg2: c_int, arg3: size_t) -> *mut c_void;
pub fn memcmp(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int;
pub fn memcpy(arg1: *mut c_void, arg2: *const c_void, arg3: size_t) -> *mut c_void;
pub fn memmove(arg1: *mut c_void, arg2: *const c_void, arg3: size_t) -> *mut c_void;
pub fn memset(arg1: *mut c_void, arg2: c_int, arg3: size_t) -> *mut c_void;
pub fn strcat(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char;
pub fn strchr(arg1: *const c_char, arg2: c_int) -> *mut c_char;
pub fn strcmp(arg1: *const c_char, arg2: *const c_char) -> c_int;
pub fn strcoll(arg1: *const c_char, arg2: *const c_char) -> c_int;
pub fn strcpy(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char;
pub fn strcspn(arg1: *const c_char, arg2: *const c_char) -> size_t;
pub fn strerror(arg1: c_int) -> *mut c_char;
pub fn strlen(arg1: *const c_char) -> size_t;
pub fn strncat(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char;
pub fn strncmp(arg1: *const c_char, arg2: *const c_char, arg3: size_t) -> c_int;
pub fn strncpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char;
pub fn strpbrk(arg1: *const c_char, arg2: *const c_char) -> *mut c_char;
pub fn strrchr(arg1: *const c_char, arg2: c_int) -> *mut c_char;
pub fn strspn(arg1: *const c_char, arg2: *const c_char) -> size_t;
pub fn strstr(arg1: *const c_char, arg2: *const c_char) -> *mut c_char;
pub fn strtok(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char;
pub fn strtok_r(arg1: *mut c_char, arg2: *const c_char, arg3: *mut *mut c_char) -> *mut c_char;
pub fn strerror_r(arg1: c_int, arg2: *mut c_char, arg3: size_t) -> c_int;
pub fn strxfrm(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t;
pub fn memccpy(
arg1: *mut c_void,
arg2: *const c_void,
arg3: c_int,
arg4: size_t,
) -> *mut c_void;
pub fn strdup(arg1: *const c_char) -> *mut c_char;
pub fn stpcpy(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char;
pub fn stpncpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char;
pub fn strnlen(arg1: *const c_char, arg2: size_t) -> size_t;
pub fn memmem(
arg1: *const c_void,
arg2: size_t,
arg3: *const c_void,
arg4: size_t,
) -> *mut c_void;
pub fn strcasestr(arg1: *const c_char, arg2: *const c_char) -> *mut c_char;
pub fn strlcat(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t;
pub fn strlcpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t;
pub fn strsep(arg1: *mut *mut c_char, arg2: *const c_char) -> *mut c_char;
pub fn stresep(arg1: *mut *mut c_char, arg2: *const c_char, arg3: c_int) -> *mut c_char;
pub fn strndup(arg1: *const c_char, arg2: size_t) -> *mut c_char;
pub fn memrchr(arg1: *const c_void, arg2: c_int, arg3: size_t) -> *mut c_void;
pub fn explicit_memset(arg1: *mut c_void, arg2: c_int, arg3: size_t) -> *mut c_void;
pub fn consttime_memequal(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int;
pub fn strcoll_l(arg1: *const c_char, arg2: *const c_char, arg3: locale_t) -> c_int;
pub fn strxfrm_l(
arg1: *mut c_char,
arg2: *const c_char,
arg3: size_t,
arg4: locale_t,
) -> size_t;
pub fn strerror_l(arg1: c_int, arg2: locale_t) -> *mut c_char;
// strings.h
pub fn bcmp(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int;
pub fn bcopy(arg1: *const c_void, arg2: *mut c_void, arg3: size_t);
pub fn bzero(arg1: *mut c_void, arg2: size_t);
pub fn ffs(arg1: c_int) -> c_int;
pub fn popcount(arg1: c_uint) -> c_uint;
pub fn popcountl(arg1: c_ulong) -> c_uint;
pub fn popcountll(arg1: c_ulonglong) -> c_uint;
pub fn popcount32(arg1: u32) -> c_uint;
pub fn popcount64(arg1: u64) -> c_uint;
pub fn rindex(arg1: *const c_char, arg2: c_int) -> *mut c_char;
pub fn strcasecmp(arg1: *const c_char, arg2: *const c_char) -> c_int;
pub fn strncasecmp(arg1: *const c_char, arg2: *const c_char, arg3: size_t) -> c_int;
// signal.h
pub fn signal(arg1: c_int, arg2: sighandler_t) -> sighandler_t;
pub fn raise(arg1: c_int) -> c_int;
// time.h
pub fn asctime(arg1: *const tm) -> *mut c_char;
pub fn clock() -> clock_t;
pub fn ctime(arg1: *const time_t) -> *mut c_char;
pub fn difftime(arg1: time_t, arg2: time_t) -> f64;
pub fn gmtime(arg1: *const time_t) -> *mut tm;
pub fn localtime(arg1: *const time_t) -> *mut tm;
pub fn time(arg1: *mut time_t) -> time_t;
pub fn mktime(arg1: *mut tm) -> time_t;
pub fn strftime(
arg1: *mut c_char,
arg2: size_t,
arg3: *const c_char,
arg4: *const tm,
) -> size_t;
pub fn utime(arg1: *const c_char, arg2: *mut time_t) -> c_int;
pub fn asctime_r(arg1: *const tm, arg2: *mut c_char) -> *mut c_char;
pub fn ctime_r(arg1: *const time_t, arg2: *mut c_char) -> *mut c_char;
pub fn gmtime_r(arg1: *const time_t, arg2: *mut tm) -> *mut tm;
pub fn localtime_r(arg1: *const time_t, arg2: *mut tm) -> *mut tm;
// sys/stat.h
pub fn stat(arg1: *const c_char, arg2: *mut stat) -> c_int;
pub fn lstat(arg1: *const c_char, arg2: *mut stat) -> c_int;
pub fn fstat(arg1: c_int, arg2: *mut stat) -> c_int;
pub fn chmod(arg1: *const c_char, arg2: __mode_t) -> c_int;
pub fn mkdir(arg1: *const c_char, arg2: __mode_t) -> c_int;
// fcntl.h
pub fn open(arg1: *const c_char, arg2: c_int, ...) -> c_int;
pub fn creat(arg1: *const c_char, arg2: c_int) -> c_int;
pub fn close(arg1: c_int) -> c_int;
pub fn read(arg1: c_int, arg2: *mut c_void, arg3: c_int) -> c_int;
pub fn write(arg1: c_int, arg2: *const c_void, arg3: c_int) -> c_int;
pub fn unlink(arg1: *const c_char) -> c_int;
pub fn tell(arg1: c_int) -> c_long;
pub fn dup(arg1: c_int) -> c_int;
pub fn dup2(arg1: c_int, arg2: c_int) -> c_int;
pub fn access(arg1: *const c_char, arg2: c_int) -> c_int;
pub fn rmdir(arg1: *const c_char) -> c_int;
pub fn chdir(arg1: *const c_char) -> c_int;
pub fn _exit(arg1: c_int);
pub fn getwd(arg1: *mut c_char) -> *mut c_char;
pub fn getcwd(arg1: *mut c_char, arg2: size_t) -> *mut c_char;
pub static mut optarg: *mut c_char;
pub static mut opterr: c_int;
pub static mut optind: c_int;
pub static mut optopt: c_int;
pub static mut optreset: c_int;
pub fn getopt(arg1: c_int, arg2: *mut *mut c_char, arg3: *const c_char) -> c_int;
pub static mut suboptarg: *mut c_char;
pub fn getsubopt(
arg1: *mut *mut c_char,
arg2: *const *mut c_char,
arg3: *mut *mut c_char,
) -> c_int;
pub fn fcntl(arg1: c_int, arg2: c_int, ...) -> c_int;
pub fn getpid() -> pid_t;
pub fn sleep(arg1: c_uint) -> c_uint;
pub fn usleep(arg1: useconds_t) -> c_int;
// locale.h
pub fn localeconv() -> *mut lconv;
pub fn setlocale(arg1: c_int, arg2: *const c_char) -> *mut c_char;
pub fn duplocale(arg1: locale_t) -> locale_t;
pub fn freelocale(arg1: locale_t);
pub fn localeconv_l(arg1: locale_t) -> *mut lconv;
pub fn newlocale(arg1: c_int, arg2: *const c_char, arg3: locale_t) -> locale_t;
// langinfo.h
pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char;
pub fn nl_langinfo_l(item: crate::nl_item, locale: locale_t) -> *mut c_char;
// malloc.h
pub fn memalign(align: size_t, size: size_t) -> *mut c_void;
// sys/types.h
pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t;
}
cfg_if! {
if #[cfg(target_arch = "aarch64")] {
mod aarch64;
pub use self::aarch64::*;
} else if #[cfg(any(target_arch = "arm"))] {
mod arm;
pub use self::arm::*;
} else {
// Unknown target_arch
}
}

16
vendor/libc/src/switch.rs vendored Normal file
View File

@@ -0,0 +1,16 @@
//! Switch C type definitions
pub type intmax_t = i64;
pub type uintmax_t = u64;
pub type size_t = usize;
pub type ptrdiff_t = isize;
pub type intptr_t = isize;
pub type uintptr_t = usize;
pub type ssize_t = isize;
pub type off_t = i64;
pub type wchar_t = u32;
pub const INT_MIN: c_int = -2147483648;
pub const INT_MAX: c_int = 2147483647;

1355
vendor/libc/src/teeos/mod.rs vendored Normal file

File diff suppressed because it is too large Load Diff

72
vendor/libc/src/trusty.rs vendored Normal file
View File

@@ -0,0 +1,72 @@
use crate::prelude::*;
pub type size_t = usize;
pub type ssize_t = isize;
pub type off_t = i64;
pub type c_uint8_t = u8;
pub type c_uint16_t = u16;
pub type c_uint32_t = u32;
pub type c_uint64_t = u64;
pub type c_int8_t = i8;
pub type c_int16_t = i16;
pub type c_int32_t = i32;
pub type c_int64_t = i64;
pub type intptr_t = isize;
pub type uintptr_t = usize;
pub type time_t = c_long;
pub type clockid_t = c_int;
s! {
pub struct iovec {
pub iov_base: *mut c_void,
pub iov_len: size_t,
}
pub struct timespec {
pub tv_sec: time_t,
pub tv_nsec: c_long,
}
}
pub const PROT_READ: i32 = 1;
pub const PROT_WRITE: i32 = 2;
// Trusty only supports `CLOCK_BOOTTIME`.
pub const CLOCK_BOOTTIME: clockid_t = 7;
pub const STDOUT_FILENO: c_int = 1;
pub const STDERR_FILENO: c_int = 2;
pub const AT_PAGESZ: c_ulong = 6;
pub const MAP_FAILED: *mut c_void = !0 as *mut c_void;
extern "C" {
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
pub fn malloc(size: size_t) -> *mut c_void;
pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
pub fn free(p: *mut c_void);
pub fn memalign(align: size_t, size: size_t) -> *mut c_void;
pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int;
pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t;
pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t;
pub fn close(fd: c_int) -> c_int;
pub fn strlen(cs: *const c_char) -> size_t;
pub fn getauxval(type_: c_ulong) -> c_ulong;
pub fn mmap(
addr: *mut c_void,
len: size_t,
prot: c_int,
flags: c_int,
fd: c_int,
offset: off_t,
) -> *mut c_void;
pub fn munmap(addr: *mut c_void, len: size_t) -> c_int;
pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
pub fn nanosleep(rqtp: *const crate::timespec, rmtp: *mut crate::timespec) -> c_int;
}

39
vendor/libc/src/types.rs vendored Normal file
View File

@@ -0,0 +1,39 @@
//! Platform-agnostic support types.
use core::mem::MaybeUninit;
use crate::prelude::*;
/// A transparent wrapper over `MaybeUninit<T>` to represent uninitialized padding
/// while providing `Default`.
// This is restricted to `Copy` types since that's a loose indicator that zeros is actually
// a valid bitpattern. There is no technical reason this is required, though, so it could be
// lifted in the future if it becomes a problem.
#[allow(unused)]
#[repr(transparent)]
#[derive(Clone, Copy)]
pub(crate) struct Padding<T: Copy>(MaybeUninit<T>);
impl<T: Copy> Default for Padding<T> {
fn default() -> Self {
Self(MaybeUninit::zeroed())
}
}
impl<T: Copy> fmt::Debug for Padding<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Taken frmo `MaybeUninit`'s debug implementation
// NB: there is no `.pad_fmt` so we can't use a simpler `format_args!("Padding<{..}>").
let full_name = core::any::type_name::<Self>();
let prefix_len = full_name.find("Padding").unwrap();
f.pad(&full_name[prefix_len..])
}
}
/// The default repr type used for C style enums in Rust.
#[cfg(target_env = "msvc")]
#[allow(unused)]
pub(crate) type CEnumRepr = c_int;
#[cfg(not(target_env = "msvc"))]
#[allow(unused)]
pub(crate) type CEnumRepr = c_uint;

3382
vendor/libc/src/unix/aix/mod.rs vendored Normal file

File diff suppressed because it is too large Load Diff

477
vendor/libc/src/unix/aix/powerpc64.rs vendored Normal file
View File

@@ -0,0 +1,477 @@
use crate::off_t;
use crate::prelude::*;
// Define lock_data_instrumented as an empty enum
missing! {
#[derive(Debug)]
pub enum lock_data_instrumented {}
}
s! {
pub struct sigset_t {
pub ss_set: [c_ulong; 4],
}
pub struct fd_set {
pub fds_bits: [c_long; 1024],
}
pub struct flock {
pub l_type: c_short,
pub l_whence: c_short,
pub l_sysid: c_uint,
pub l_pid: crate::pid_t,
pub l_vfs: c_int,
pub l_start: off_t,
pub l_len: off_t,
}
pub struct statvfs {
pub f_bsize: c_ulong,
pub f_frsize: c_ulong,
pub f_blocks: crate::fsblkcnt_t,
pub f_bfree: crate::fsblkcnt_t,
pub f_bavail: crate::fsblkcnt_t,
pub f_files: crate::fsfilcnt_t,
pub f_ffree: crate::fsfilcnt_t,
pub f_favail: crate::fsfilcnt_t,
pub f_fsid: c_ulong,
pub f_basetype: [c_char; 16],
pub f_flag: c_ulong,
pub f_namemax: c_ulong,
pub f_fstr: [c_char; 32],
pub f_filler: [c_ulong; 16],
}
pub struct pthread_rwlock_t {
__rw_word: [c_long; 10],
}
pub struct pthread_cond_t {
__cv_word: [c_long; 6],
}
pub struct pthread_mutex_t {
__mt_word: [c_long; 8],
}
pub struct pthread_once_t {
__on_word: [c_long; 9],
}
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_flag: c_ushort,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
pub st_ssize: c_int,
pub st_atim: crate::timespec,
pub st_mtim: crate::timespec,
pub st_ctim: crate::timespec,
pub st_blksize: crate::blksize_t,
pub st_blocks: crate::blkcnt_t,
pub st_vfstype: c_int,
pub st_vfs: c_uint,
pub st_type: c_uint,
pub st_gen: c_uint,
pub st_reserved: [c_uint; 9],
pub st_padto_ll: c_uint,
pub st_size: off_t,
}
pub struct statfs {
pub f_version: c_int,
pub f_type: c_int,
pub f_bsize: c_ulong,
pub f_blocks: crate::fsblkcnt_t,
pub f_bfree: crate::fsblkcnt_t,
pub f_bavail: crate::fsblkcnt_t,
pub f_files: crate::fsblkcnt_t,
pub f_ffree: crate::fsblkcnt_t,
pub f_fsid: crate::fsid64_t,
pub f_vfstype: c_int,
pub f_fsize: c_ulong,
pub f_vfsnumber: c_int,
pub f_vfsoff: c_int,
pub f_vfslen: c_int,
pub f_vfsvers: c_int,
pub f_fname: [c_char; 32],
pub f_fpack: [c_char; 32],
pub f_name_max: c_int,
}
pub struct aiocb {
pub aio_lio_opcode: c_int,
pub aio_fildes: c_int,
pub aio_word1: c_int,
pub aio_offset: off_t,
pub aio_buf: *mut c_void,
pub aio_return: ssize_t,
pub aio_errno: c_int,
pub aio_nbytes: size_t,
pub aio_reqprio: c_int,
pub aio_sigevent: crate::sigevent,
pub aio_word2: c_int,
pub aio_fp: c_int,
pub aio_handle: *mut aiocb,
pub aio_reserved: [c_uint; 2],
pub aio_sigev_tid: c_long,
}
pub struct __vmxreg_t {
__v: [c_uint; 4],
}
pub struct __vmx_context_t {
pub __vr: [crate::__vmxreg_t; 32],
pub __pad1: [c_uint; 3],
pub __vscr: c_uint,
pub __vrsave: c_uint,
pub __pad2: [c_uint; 3],
}
pub struct __vsx_context_t {
pub __vsr_dw1: [c_ulonglong; 32],
}
pub struct __tm_context_t {
pub vmx: crate::__vmx_context_t,
pub vsx: crate::__vsx_context_t,
pub gpr: [c_ulonglong; 32],
pub lr: c_ulonglong,
pub ctr: c_ulonglong,
pub cr: c_uint,
pub xer: c_uint,
pub amr: c_ulonglong,
pub texasr: c_ulonglong,
pub tfiar: c_ulonglong,
pub tfhar: c_ulonglong,
pub ppr: c_ulonglong,
pub dscr: c_ulonglong,
pub tar: c_ulonglong,
pub fpscr: c_uint,
pub fpscrx: c_uint,
pub fpr: [fpreg_t; 32],
pub tmcontext: c_char,
pub tmstate: c_char,
pub prevowner: c_char,
pub pad: [c_char; 5],
}
pub struct __context64 {
pub gpr: [c_ulonglong; 32],
pub msr: c_ulonglong,
pub iar: c_ulonglong,
pub lr: c_ulonglong,
pub ctr: c_ulonglong,
pub cr: c_uint,
pub xer: c_uint,
pub fpscr: c_uint,
pub fpscrx: c_uint,
pub except: [c_ulonglong; 1],
pub fpr: [fpreg_t; 32],
pub fpeu: c_char,
pub fpinfo: c_char,
pub fpscr24_31: c_char,
pub pad: [c_char; 1],
pub excp_type: c_int,
}
pub struct mcontext_t {
pub jmp_context: __context64,
}
pub struct __extctx_t {
pub __flags: c_uint,
pub __rsvd1: [c_uint; 3],
pub __vmx: crate::__vmx_context_t,
pub __ukeys: [c_uint; 2],
pub __vsx: crate::__vsx_context_t,
pub __tm: crate::__tm_context_t,
pub __reserved: [c_char; 1860],
pub __extctx_magic: c_int,
}
pub struct ucontext_t {
pub __sc_onstack: c_int,
pub uc_sigmask: crate::sigset_t,
pub __sc_uerror: c_int,
pub uc_mcontext: crate::mcontext_t,
pub uc_link: *mut ucontext_t,
pub uc_stack: crate::stack_t,
pub __extctx: *mut crate::__extctx_t,
pub __extctx_magic: c_int,
pub __pad: [c_int; 1],
}
pub struct utmpx {
pub ut_user: [c_char; 256],
pub ut_id: [c_char; 14],
pub ut_line: [c_char; 64],
pub ut_pid: crate::pid_t,
pub ut_type: c_short,
pub ut_tv: crate::timeval,
pub ut_host: [c_char; 256],
pub __dbl_word_pad: c_int,
pub __reservedA: [c_int; 2],
pub __reservedV: [c_int; 6],
}
pub struct pthread_spinlock_t {
pub __sp_word: [c_long; 3],
}
pub struct pthread_barrier_t {
pub __br_word: [c_long; 5],
}
pub struct msqid_ds {
pub msg_perm: crate::ipc_perm,
pub msg_first: c_uint,
pub msg_last: c_uint,
pub msg_cbytes: c_uint,
pub msg_qnum: c_uint,
pub msg_qbytes: c_ulong,
pub msg_lspid: crate::pid_t,
pub msg_lrpid: crate::pid_t,
pub msg_stime: crate::time_t,
pub msg_rtime: crate::time_t,
pub msg_ctime: crate::time_t,
pub msg_rwait: c_int,
pub msg_wwait: c_int,
pub msg_reqevents: c_ushort,
}
}
s_no_extra_traits! {
pub struct siginfo_t {
pub si_signo: c_int,
pub si_errno: c_int,
pub si_code: c_int,
pub si_pid: crate::pid_t,
pub si_uid: crate::uid_t,
pub si_status: c_int,
pub si_addr: *mut c_void,
pub si_band: c_long,
pub si_value: crate::sigval,
pub __si_flags: c_int,
pub __pad: [c_int; 3],
}
pub union _kernel_simple_lock {
pub _slock: c_long,
pub _slockp: *mut lock_data_instrumented,
}
pub struct fileops_t {
pub fo_rw: Option<
extern "C" fn(
file: *mut file,
rw: crate::uio_rw,
io: *mut c_void,
ext: c_long,
secattr: *mut c_void,
) -> c_int,
>,
pub fo_ioctl: Option<
extern "C" fn(
file: *mut file,
a: c_long,
b: crate::caddr_t,
c: c_long,
d: c_long,
) -> c_int,
>,
pub fo_select: Option<
extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int,
>,
pub fo_close: Option<extern "C" fn(file: *mut file) -> c_int>,
pub fo_fstat: Option<extern "C" fn(file: *mut file, sstat: *mut crate::stat) -> c_int>,
}
pub struct file {
pub f_flag: c_long,
pub f_count: c_int,
pub f_options: c_short,
pub f_type: c_short,
// Should be pointer to 'vnode'
pub f_data: *mut c_void,
pub f_offset: c_longlong,
pub f_dir_off: c_long,
// Should be pointer to 'cred'
pub f_cred: *mut c_void,
pub f_lock: _kernel_simple_lock,
pub f_offset_lock: _kernel_simple_lock,
pub f_vinfo: crate::caddr_t,
pub f_ops: *mut fileops_t,
pub f_parentp: crate::caddr_t,
pub f_fnamep: crate::caddr_t,
pub f_fdata: [c_char; 160],
}
pub union __ld_info_file {
pub _ldinfo_fd: c_int,
pub _ldinfo_fp: *mut file,
pub _core_offset: c_long,
}
pub struct ld_info {
pub ldinfo_next: c_uint,
pub ldinfo_flags: c_uint,
pub _file: __ld_info_file,
pub ldinfo_textorg: *mut c_void,
pub ldinfo_textsize: c_ulong,
pub ldinfo_dataorg: *mut c_void,
pub ldinfo_datasize: c_ulong,
pub ldinfo_filename: [c_char; 2],
}
pub union __pollfd_ext_u {
pub addr: *mut c_void,
pub data32: u32,
pub data: u64,
}
pub struct pollfd_ext {
pub fd: c_int,
pub events: c_short,
pub revents: c_short,
pub data: __pollfd_ext_u,
}
pub struct fpreg_t {
pub d: c_double,
}
}
impl siginfo_t {
pub unsafe fn si_addr(&self) -> *mut c_void {
self.si_addr
}
pub unsafe fn si_value(&self) -> crate::sigval {
self.si_value
}
pub unsafe fn si_pid(&self) -> crate::pid_t {
self.si_pid
}
pub unsafe fn si_uid(&self) -> crate::uid_t {
self.si_uid
}
pub unsafe fn si_status(&self) -> c_int {
self.si_status
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for siginfo_t {
fn eq(&self, other: &siginfo_t) -> bool {
self.si_signo == other.si_signo
&& self.si_errno == other.si_errno
&& self.si_code == other.si_code
&& self.si_pid == other.si_pid
&& self.si_uid == other.si_uid
&& self.si_status == other.si_status
&& self.si_addr == other.si_addr
&& self.si_band == other.si_band
&& self.__si_flags == other.__si_flags
&& self.si_value == other.si_value
}
}
impl Eq for siginfo_t {}
impl hash::Hash for siginfo_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.si_signo.hash(state);
self.si_errno.hash(state);
self.si_code.hash(state);
self.si_pid.hash(state);
self.si_uid.hash(state);
self.si_status.hash(state);
self.si_addr.hash(state);
self.si_band.hash(state);
self.si_value.hash(state);
self.__si_flags.hash(state);
}
}
impl PartialEq for __pollfd_ext_u {
fn eq(&self, other: &__pollfd_ext_u) -> bool {
unsafe {
self.addr == other.addr
&& self.data32 == other.data32
&& self.data == other.data
}
}
}
impl Eq for __pollfd_ext_u {}
impl hash::Hash for __pollfd_ext_u {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
unsafe {
self.addr.hash(state);
self.data.hash(state);
self.data32.hash(state);
}
}
}
impl PartialEq for pollfd_ext {
fn eq(&self, other: &pollfd_ext) -> bool {
self.fd == other.fd
&& self.events == other.events
&& self.revents == other.revents
&& self.data == other.data
}
}
impl Eq for pollfd_ext {}
impl hash::Hash for pollfd_ext {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.fd.hash(state);
self.events.hash(state);
self.revents.hash(state);
self.data.hash(state);
}
}
impl PartialEq for fpreg_t {
fn eq(&self, other: &fpreg_t) -> bool {
self.d == other.d
}
}
impl Eq for fpreg_t {}
impl hash::Hash for fpreg_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
let d: u64 = unsafe { mem::transmute(self.d) };
d.hash(state);
}
}
}
}
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
__mt_word: [0, 2, 0, 0, 0, 0, 0, 0],
};
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
__cv_word: [0, 0, 0, 0, 2, 0],
};
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
__rw_word: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0],
};
pub const PTHREAD_ONCE_INIT: pthread_once_t = pthread_once_t {
__on_word: [0, 0, 0, 0, 0, 2, 0, 0, 0],
};
pub const RLIM_INFINITY: c_ulong = 0x7fffffffffffffff;
extern "C" {
pub fn getsystemcfg(label: c_int) -> c_ulong;
}

View File

@@ -0,0 +1,135 @@
//! 32-bit specific Apple (ios/darwin) definitions
use crate::prelude::*;
pub type boolean_t = c_int;
s! {
pub struct if_data {
pub ifi_type: c_uchar,
pub ifi_typelen: c_uchar,
pub ifi_physical: c_uchar,
pub ifi_addrlen: c_uchar,
pub ifi_hdrlen: c_uchar,
pub ifi_recvquota: c_uchar,
pub ifi_xmitquota: c_uchar,
pub ifi_unused1: c_uchar,
pub ifi_mtu: u32,
pub ifi_metric: u32,
pub ifi_baudrate: u32,
pub ifi_ipackets: u32,
pub ifi_ierrors: u32,
pub ifi_opackets: u32,
pub ifi_oerrors: u32,
pub ifi_collisions: u32,
pub ifi_ibytes: u32,
pub ifi_obytes: u32,
pub ifi_imcasts: u32,
pub ifi_omcasts: u32,
pub ifi_iqdrops: u32,
pub ifi_noproto: u32,
pub ifi_recvtiming: u32,
pub ifi_xmittiming: u32,
pub ifi_lastchange: crate::timeval,
pub ifi_unused2: u32,
pub ifi_hwassist: u32,
pub ifi_reserved1: u32,
pub ifi_reserved2: u32,
}
pub struct bpf_hdr {
pub bh_tstamp: crate::timeval,
pub bh_caplen: u32,
pub bh_datalen: u32,
pub bh_hdrlen: c_ushort,
}
pub struct malloc_zone_t {
__private: [crate::uintptr_t; 18], // FIXME(macos): keeping private for now
}
}
s_no_extra_traits! {
pub struct pthread_attr_t {
__sig: c_long,
__opaque: [c_char; 36],
}
pub struct pthread_once_t {
__sig: c_long,
__opaque: [c_char; crate::__PTHREAD_ONCE_SIZE__],
}
#[repr(align(16))]
pub struct max_align_t {
priv_: [f64; 2],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for pthread_attr_t {
fn eq(&self, other: &pthread_attr_t) -> bool {
self.__sig == other.__sig
&& self
.__opaque
.iter()
.zip(other.__opaque.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for pthread_attr_t {}
impl hash::Hash for pthread_attr_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.__sig.hash(state);
self.__opaque.hash(state);
}
}
impl PartialEq for pthread_once_t {
fn eq(&self, other: &pthread_once_t) -> bool {
self.__sig == other.__sig
&& self
.__opaque
.iter()
.zip(other.__opaque.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for pthread_once_t {}
impl hash::Hash for pthread_once_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.__sig.hash(state);
self.__opaque.hash(state);
}
}
}
}
#[doc(hidden)]
#[deprecated(since = "0.2.55")]
pub const NET_RT_MAXID: c_int = 10;
pub const __PTHREAD_MUTEX_SIZE__: usize = 40;
pub const __PTHREAD_COND_SIZE__: usize = 24;
pub const __PTHREAD_CONDATTR_SIZE__: usize = 4;
pub const __PTHREAD_ONCE_SIZE__: usize = 4;
pub const __PTHREAD_RWLOCK_SIZE__: usize = 124;
pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12;
pub const TIOCTIMESTAMP: c_ulong = 0x40087459;
pub const TIOCDCDTIMESTAMP: c_ulong = 0x40087458;
pub const BIOCSETF: c_ulong = 0x80084267;
pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e;
pub const BIOCSETFNR: c_ulong = 0x8008427e;
const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA;
pub const PTHREAD_ONCE_INIT: crate::pthread_once_t = crate::pthread_once_t {
__sig: _PTHREAD_ONCE_SIG_INIT,
__opaque: [0; 4],
};
extern "C" {
pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_ulong) -> c_int;
}

View File

@@ -0,0 +1,53 @@
use crate::prelude::*;
pub type boolean_t = c_int;
pub type mcontext_t = *mut __darwin_mcontext64;
s! {
pub struct malloc_zone_t {
__private: [crate::uintptr_t; 18], // FIXME(macos): needs arm64 auth pointers support
}
pub struct ucontext_t {
pub uc_onstack: c_int,
pub uc_sigmask: crate::sigset_t,
pub uc_stack: crate::stack_t,
pub uc_link: *mut crate::ucontext_t,
pub uc_mcsize: usize,
pub uc_mcontext: mcontext_t,
}
pub struct __darwin_mcontext64 {
pub __es: __darwin_arm_exception_state64,
pub __ss: __darwin_arm_thread_state64,
pub __ns: __darwin_arm_neon_state64,
}
pub struct __darwin_arm_exception_state64 {
pub __far: u64,
pub __esr: u32,
pub __exception: u32,
}
pub struct __darwin_arm_thread_state64 {
pub __x: [u64; 29],
pub __fp: u64,
pub __lr: u64,
pub __sp: u64,
pub __pc: u64,
pub __cpsr: u32,
pub __pad: u32,
}
pub struct __darwin_arm_neon_state64 {
pub __v: [crate::__uint128_t; 32],
pub __fpsr: u32,
pub __fpcr: u32,
}
}
s_no_extra_traits! {
pub struct max_align_t {
priv_: f64,
}
}

View File

@@ -0,0 +1,141 @@
//! 64-bit specific Apple (ios/darwin) definitions
use crate::prelude::*;
s! {
pub struct timeval32 {
pub tv_sec: i32,
pub tv_usec: i32,
}
pub struct if_data {
pub ifi_type: c_uchar,
pub ifi_typelen: c_uchar,
pub ifi_physical: c_uchar,
pub ifi_addrlen: c_uchar,
pub ifi_hdrlen: c_uchar,
pub ifi_recvquota: c_uchar,
pub ifi_xmitquota: c_uchar,
pub ifi_unused1: c_uchar,
pub ifi_mtu: u32,
pub ifi_metric: u32,
pub ifi_baudrate: u32,
pub ifi_ipackets: u32,
pub ifi_ierrors: u32,
pub ifi_opackets: u32,
pub ifi_oerrors: u32,
pub ifi_collisions: u32,
pub ifi_ibytes: u32,
pub ifi_obytes: u32,
pub ifi_imcasts: u32,
pub ifi_omcasts: u32,
pub ifi_iqdrops: u32,
pub ifi_noproto: u32,
pub ifi_recvtiming: u32,
pub ifi_xmittiming: u32,
pub ifi_lastchange: timeval32,
pub ifi_unused2: u32,
pub ifi_hwassist: u32,
pub ifi_reserved1: u32,
pub ifi_reserved2: u32,
}
pub struct bpf_hdr {
pub bh_tstamp: crate::timeval32,
pub bh_caplen: u32,
pub bh_datalen: u32,
pub bh_hdrlen: c_ushort,
}
}
s_no_extra_traits! {
pub struct pthread_attr_t {
__sig: c_long,
__opaque: [c_char; 56],
}
pub struct pthread_once_t {
__sig: c_long,
__opaque: [c_char; __PTHREAD_ONCE_SIZE__],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for pthread_attr_t {
fn eq(&self, other: &pthread_attr_t) -> bool {
self.__sig == other.__sig
&& self
.__opaque
.iter()
.zip(other.__opaque.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for pthread_attr_t {}
impl hash::Hash for pthread_attr_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.__sig.hash(state);
self.__opaque.hash(state);
}
}
impl PartialEq for pthread_once_t {
fn eq(&self, other: &pthread_once_t) -> bool {
self.__sig == other.__sig
&& self
.__opaque
.iter()
.zip(other.__opaque.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for pthread_once_t {}
impl hash::Hash for pthread_once_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.__sig.hash(state);
self.__opaque.hash(state);
}
}
}
}
#[doc(hidden)]
#[deprecated(since = "0.2.55")]
pub const NET_RT_MAXID: c_int = 11;
pub const __PTHREAD_MUTEX_SIZE__: usize = 56;
pub const __PTHREAD_COND_SIZE__: usize = 40;
pub const __PTHREAD_CONDATTR_SIZE__: usize = 8;
pub const __PTHREAD_ONCE_SIZE__: usize = 8;
pub const __PTHREAD_RWLOCK_SIZE__: usize = 192;
pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16;
pub const TIOCTIMESTAMP: c_ulong = 0x40107459;
pub const TIOCDCDTIMESTAMP: c_ulong = 0x40107458;
pub const BIOCSETF: c_ulong = 0x80104267;
pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e;
pub const BIOCSETFNR: c_ulong = 0x8010427e;
const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA;
pub const PTHREAD_ONCE_INIT: crate::pthread_once_t = crate::pthread_once_t {
__sig: _PTHREAD_ONCE_SIG_INIT,
__opaque: [0; 8],
};
extern "C" {
pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_uint) -> c_int;
}
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
} else if #[cfg(target_arch = "aarch64")] {
mod aarch64;
pub use self::aarch64::*;
} else {
// Unknown target_arch
}
}

View File

@@ -0,0 +1,179 @@
use crate::prelude::*;
pub type boolean_t = c_uint;
pub type mcontext_t = *mut __darwin_mcontext64;
s! {
pub struct ucontext_t {
pub uc_onstack: c_int,
pub uc_sigmask: crate::sigset_t,
pub uc_stack: crate::stack_t,
pub uc_link: *mut crate::ucontext_t,
pub uc_mcsize: usize,
pub uc_mcontext: mcontext_t,
}
pub struct __darwin_mcontext64 {
pub __es: __darwin_x86_exception_state64,
pub __ss: __darwin_x86_thread_state64,
pub __fs: __darwin_x86_float_state64,
}
pub struct __darwin_x86_exception_state64 {
pub __trapno: u16,
pub __cpu: u16,
pub __err: u32,
pub __faultvaddr: u64,
}
pub struct __darwin_x86_thread_state64 {
pub __rax: u64,
pub __rbx: u64,
pub __rcx: u64,
pub __rdx: u64,
pub __rdi: u64,
pub __rsi: u64,
pub __rbp: u64,
pub __rsp: u64,
pub __r8: u64,
pub __r9: u64,
pub __r10: u64,
pub __r11: u64,
pub __r12: u64,
pub __r13: u64,
pub __r14: u64,
pub __r15: u64,
pub __rip: u64,
pub __rflags: u64,
pub __cs: u64,
pub __fs: u64,
pub __gs: u64,
}
pub struct __darwin_x86_float_state64 {
pub __fpu_reserved: [c_int; 2],
__fpu_fcw: c_short,
__fpu_fsw: c_short,
pub __fpu_ftw: u8,
pub __fpu_rsrv1: u8,
pub __fpu_fop: u16,
pub __fpu_ip: u32,
pub __fpu_cs: u16,
pub __fpu_rsrv2: u16,
pub __fpu_dp: u32,
pub __fpu_ds: u16,
pub __fpu_rsrv3: u16,
pub __fpu_mxcsr: u32,
pub __fpu_mxcsrmask: u32,
pub __fpu_stmm0: __darwin_mmst_reg,
pub __fpu_stmm1: __darwin_mmst_reg,
pub __fpu_stmm2: __darwin_mmst_reg,
pub __fpu_stmm3: __darwin_mmst_reg,
pub __fpu_stmm4: __darwin_mmst_reg,
pub __fpu_stmm5: __darwin_mmst_reg,
pub __fpu_stmm6: __darwin_mmst_reg,
pub __fpu_stmm7: __darwin_mmst_reg,
pub __fpu_xmm0: __darwin_xmm_reg,
pub __fpu_xmm1: __darwin_xmm_reg,
pub __fpu_xmm2: __darwin_xmm_reg,
pub __fpu_xmm3: __darwin_xmm_reg,
pub __fpu_xmm4: __darwin_xmm_reg,
pub __fpu_xmm5: __darwin_xmm_reg,
pub __fpu_xmm6: __darwin_xmm_reg,
pub __fpu_xmm7: __darwin_xmm_reg,
pub __fpu_xmm8: __darwin_xmm_reg,
pub __fpu_xmm9: __darwin_xmm_reg,
pub __fpu_xmm10: __darwin_xmm_reg,
pub __fpu_xmm11: __darwin_xmm_reg,
pub __fpu_xmm12: __darwin_xmm_reg,
pub __fpu_xmm13: __darwin_xmm_reg,
pub __fpu_xmm14: __darwin_xmm_reg,
pub __fpu_xmm15: __darwin_xmm_reg,
// this field is actually [u8; 96], but defining it with a bigger type
// allows us to auto-implement traits for it since the length of the
// array is less than 32
__fpu_rsrv4: [u32; 24],
pub __fpu_reserved1: c_int,
}
pub struct __darwin_mmst_reg {
pub __mmst_reg: [c_char; 10],
pub __mmst_rsrv: [c_char; 6],
}
pub struct __darwin_xmm_reg {
pub __xmm_reg: [c_char; 16],
}
pub struct malloc_introspection_t {
_private: [crate::uintptr_t; 16], // FIXME(macos): keeping private for now
}
// FIXME(1.0): This should not implement `PartialEq`
#[allow(unpredictable_function_pointer_comparisons)]
pub struct malloc_zone_t {
_reserved1: *mut c_void,
_reserved2: *mut c_void,
pub size:
Option<unsafe extern "C" fn(zone: *mut malloc_zone_t, ptr: *const c_void) -> size_t>,
pub malloc:
Option<unsafe extern "C" fn(zone: *mut malloc_zone_t, size: size_t) -> *mut c_void>,
pub calloc: Option<
unsafe extern "C" fn(
zone: *mut malloc_zone_t,
num_items: size_t,
size: size_t,
) -> *mut c_void,
>,
pub valloc:
Option<unsafe extern "C" fn(zone: *mut malloc_zone_t, size: size_t) -> *mut c_void>,
pub free: Option<unsafe extern "C" fn(zone: *mut malloc_zone_t, ptr: *mut c_void)>,
pub realloc: Option<
unsafe extern "C" fn(
zone: *mut malloc_zone_t,
ptr: *mut c_void,
size: size_t,
) -> *mut c_void,
>,
pub destroy: Option<unsafe extern "C" fn(zone: *mut malloc_zone_t)>,
pub zone_name: *const c_char,
pub batch_malloc: Option<
unsafe extern "C" fn(
zone: *mut malloc_zone_t,
size: size_t,
results: *mut *mut c_void,
num_requested: c_uint,
) -> c_uint,
>,
pub batch_free: Option<
unsafe extern "C" fn(
zone: *mut malloc_zone_t,
to_be_freed: *mut *mut c_void,
num_to_be_freed: c_uint,
),
>,
pub introspect: *mut malloc_introspection_t,
pub version: c_uint,
pub memalign: Option<
unsafe extern "C" fn(
zone: *mut malloc_zone_t,
alignment: size_t,
size: size_t,
) -> *mut c_void,
>,
pub free_definite_size:
Option<unsafe extern "C" fn(zone: *mut malloc_zone_t, ptr: *mut c_void, size: size_t)>,
pub pressure_relief:
Option<unsafe extern "C" fn(zone: *mut malloc_zone_t, goal: size_t) -> size_t>,
pub claimed_address: Option<
unsafe extern "C" fn(zone: *mut malloc_zone_t, ptr: *mut c_void) -> crate::boolean_t,
>,
}
}
s_no_extra_traits! {
#[repr(align(16))]
pub struct max_align_t {
priv_: [f64; 2],
}
}

6236
vendor/libc/src/unix/bsd/apple/mod.rs vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
use crate::prelude::*;
/* DIFF(main): module removed in de76fee6 */
// DragonFlyBSD's __error function is declared with "static inline", so it must
// be implemented in the libc crate, as a pointer to a static thread_local.
f! {
#[deprecated(since = "0.2.77", note = "Use `__errno_location()` instead")]
pub fn __error() -> *mut c_int {
&mut errno
}
}
extern "C" {
#[thread_local]
pub static mut errno: c_int;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
use crate::prelude::*;
pub type clock_t = i32;
pub type wchar_t = u32;
pub type time_t = i64;
pub type suseconds_t = i64;
pub type register_t = i64;
s_no_extra_traits! {
pub struct gpregs {
pub gp_x: [crate::register_t; 30],
pub gp_lr: crate::register_t,
pub gp_sp: crate::register_t,
pub gp_elr: crate::register_t,
pub gp_spsr: u32,
pub gp_pad: c_int,
}
pub struct fpregs {
pub fp_q: u128,
pub fp_sr: u32,
pub fp_cr: u32,
pub fp_flags: c_int,
pub fp_pad: c_int,
}
pub struct mcontext_t {
pub mc_gpregs: gpregs,
pub mc_fpregs: fpregs,
pub mc_flags: c_int,
pub mc_pad: c_int,
pub mc_spare: [u64; 8],
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_longlong>() - 1;
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for gpregs {
fn eq(&self, other: &gpregs) -> bool {
self.gp_x.iter().zip(other.gp_x.iter()).all(|(a, b)| a == b)
&& self.gp_lr == other.gp_lr
&& self.gp_sp == other.gp_sp
&& self.gp_elr == other.gp_elr
&& self.gp_spsr == other.gp_spsr
&& self.gp_pad == other.gp_pad
}
}
impl Eq for gpregs {}
impl hash::Hash for gpregs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.gp_x.hash(state);
self.gp_lr.hash(state);
self.gp_sp.hash(state);
self.gp_elr.hash(state);
self.gp_spsr.hash(state);
self.gp_pad.hash(state);
}
}
impl PartialEq for fpregs {
fn eq(&self, other: &fpregs) -> bool {
self.fp_q == other.fp_q
&& self.fp_sr == other.fp_sr
&& self.fp_cr == other.fp_cr
&& self.fp_flags == other.fp_flags
&& self.fp_pad == other.fp_pad
}
}
impl Eq for fpregs {}
impl hash::Hash for fpregs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.fp_q.hash(state);
self.fp_sr.hash(state);
self.fp_cr.hash(state);
self.fp_flags.hash(state);
self.fp_pad.hash(state);
}
}
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.mc_gpregs == other.mc_gpregs
&& self.mc_fpregs == other.mc_fpregs
&& self.mc_flags == other.mc_flags
&& self.mc_pad == other.mc_pad
&& self
.mc_spare
.iter()
.zip(other.mc_spare.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.mc_gpregs.hash(state);
self.mc_fpregs.hash(state);
self.mc_flags.hash(state);
self.mc_pad.hash(state);
self.mc_spare.hash(state);
}
}
}
}
pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e;
pub const MAP_32BIT: c_int = 0x00080000;
pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4
pub const TIOCTIMESTAMP: c_ulong = 0x40107459;

View File

@@ -0,0 +1,53 @@
use crate::prelude::*;
pub type clock_t = u32;
pub type wchar_t = u32;
pub type time_t = i64;
pub type suseconds_t = i32;
pub type register_t = i32;
pub type __greg_t = c_uint;
pub type __gregset_t = [crate::__greg_t; 17];
s_no_extra_traits! {
pub struct mcontext_t {
pub __gregs: crate::__gregset_t,
pub mc_vfp_size: usize,
pub mc_vfp_ptr: *mut c_void,
pub mc_spare: [c_uint; 33],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.__gregs == other.__gregs
&& self.mc_vfp_size == other.mc_vfp_size
&& self.mc_vfp_ptr == other.mc_vfp_ptr
&& self
.mc_spare
.iter()
.zip(other.mc_spare.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.__gregs.hash(state);
self.mc_vfp_size.hash(state);
self.mc_vfp_ptr.hash(state);
self.mc_spare.hash(state);
}
}
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1;
pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e;
pub const MAP_32BIT: c_int = 0x00080000;
pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4
pub const TIOCTIMESTAMP: c_ulong = 0x40107459;

View File

@@ -0,0 +1,37 @@
use crate::off_t;
use crate::prelude::*;
#[repr(C)]
#[derive(Debug)]
#[cfg_attr(feature = "extra_traits", derive(Eq, Hash, PartialEq))]
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: crate::blkcnt_t,
pub st_blksize: crate::blksize_t,
pub st_flags: crate::fflags_t,
pub st_gen: u32,
pub st_lspare: i32,
pub st_birthtime: crate::time_t,
pub st_birthtime_nsec: c_long,
__unused: [u8; 8],
}
impl Copy for crate::stat {}
impl Clone for crate::stat {
fn clone(&self) -> crate::stat {
*self
}
}

View File

@@ -0,0 +1,36 @@
use crate::off_t;
use crate::prelude::*;
#[repr(C)]
#[derive(Debug)]
#[cfg_attr(feature = "extra_traits", derive(Eq, Hash, PartialEq))]
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: crate::blkcnt_t,
pub st_blksize: crate::blksize_t,
pub st_flags: crate::fflags_t,
pub st_gen: u32,
pub st_lspare: i32,
pub st_birthtime: crate::time_t,
pub st_birthtime_nsec: c_long,
}
impl Copy for crate::stat {}
impl Clone for crate::stat {
fn clone(&self) -> crate::stat {
*self
}
}

View File

@@ -0,0 +1,449 @@
use crate::prelude::*;
// APIs that were changed after FreeBSD 11
// The type of `nlink_t` changed from `u16` to `u64` in FreeBSD 12:
pub type nlink_t = u16;
// Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12:
pub type dev_t = u32;
// Type of `ino_t` changed from `__uint32_t` to `__uint64_t` in FreeBSD 12:
pub type ino_t = u32;
s! {
pub struct kevent {
pub ident: crate::uintptr_t,
pub filter: c_short,
pub flags: c_ushort,
pub fflags: c_uint,
pub data: intptr_t,
pub udata: *mut c_void,
}
pub struct shmid_ds {
pub shm_perm: crate::ipc_perm,
pub shm_segsz: size_t,
pub shm_lpid: crate::pid_t,
pub shm_cpid: crate::pid_t,
// Type of shm_nattc changed from `int` to `shmatt_t` (aka `unsigned
// int`) in FreeBSD 12:
pub shm_nattch: c_int,
pub shm_atime: crate::time_t,
pub shm_dtime: crate::time_t,
pub shm_ctime: crate::time_t,
}
pub struct kinfo_proc {
/// Size of this structure.
pub ki_structsize: c_int,
/// Reserved: layout identifier.
pub ki_layout: c_int,
/// Address of command arguments.
pub ki_args: *mut crate::pargs,
// This is normally "struct proc".
/// Address of proc.
pub ki_paddr: *mut c_void,
// This is normally "struct user".
/// Kernel virtual address of u-area.
pub ki_addr: *mut c_void,
// This is normally "struct vnode".
/// Pointer to trace file.
pub ki_tracep: *mut c_void,
// This is normally "struct vnode".
/// Pointer to executable file.
pub ki_textvp: *mut c_void,
/// Pointer to open file info.
pub ki_fd: *mut crate::filedesc,
// This is normally "struct vmspace".
/// Pointer to kernel vmspace struct.
pub ki_vmspace: *mut c_void,
/// Sleep address.
pub ki_wchan: *mut c_void,
/// Process identifier.
pub ki_pid: crate::pid_t,
/// Parent process ID.
pub ki_ppid: crate::pid_t,
/// Process group ID.
pub ki_pgid: crate::pid_t,
/// tty process group ID.
pub ki_tpgid: crate::pid_t,
/// Process session ID.
pub ki_sid: crate::pid_t,
/// Terminal session ID.
pub ki_tsid: crate::pid_t,
/// Job control counter.
pub ki_jobc: c_short,
/// Unused (just here for alignment).
pub ki_spare_short1: c_short,
/// Controlling tty dev.
pub ki_tdev: crate::dev_t,
/// Signals arrived but not delivered.
pub ki_siglist: crate::sigset_t,
/// Current signal mask.
pub ki_sigmask: crate::sigset_t,
/// Signals being ignored.
pub ki_sigignore: crate::sigset_t,
/// Signals being caught by user.
pub ki_sigcatch: crate::sigset_t,
/// Effective user ID.
pub ki_uid: crate::uid_t,
/// Real user ID.
pub ki_ruid: crate::uid_t,
/// Saved effective user ID.
pub ki_svuid: crate::uid_t,
/// Real group ID.
pub ki_rgid: crate::gid_t,
/// Saved effective group ID.
pub ki_svgid: crate::gid_t,
/// Number of groups.
pub ki_ngroups: c_short,
/// Unused (just here for alignment).
pub ki_spare_short2: c_short,
/// Groups.
pub ki_groups: [crate::gid_t; crate::KI_NGROUPS],
/// Virtual size.
pub ki_size: crate::vm_size_t,
/// Current resident set size in pages.
pub ki_rssize: crate::segsz_t,
/// Resident set size before last swap.
pub ki_swrss: crate::segsz_t,
/// Text size (pages) XXX.
pub ki_tsize: crate::segsz_t,
/// Data size (pages) XXX.
pub ki_dsize: crate::segsz_t,
/// Stack size (pages).
pub ki_ssize: crate::segsz_t,
/// Exit status for wait & stop signal.
pub ki_xstat: crate::u_short,
/// Accounting flags.
pub ki_acflag: crate::u_short,
/// %cpu for process during `ki_swtime`.
pub ki_pctcpu: crate::fixpt_t,
/// Time averaged value of `ki_cpticks`.
pub ki_estcpu: crate::u_int,
/// Time since last blocked.
pub ki_slptime: crate::u_int,
/// Time swapped in or out.
pub ki_swtime: crate::u_int,
/// Number of copy-on-write faults.
pub ki_cow: crate::u_int,
/// Real time in microsec.
pub ki_runtime: u64,
/// Starting time.
pub ki_start: crate::timeval,
/// Time used by process children.
pub ki_childtime: crate::timeval,
/// P_* flags.
pub ki_flag: c_long,
/// KI_* flags (below).
pub ki_kiflag: c_long,
/// Kernel trace points.
pub ki_traceflag: c_int,
/// S* process status.
pub ki_stat: c_char,
/// Process "nice" value.
pub ki_nice: i8, // signed char
/// Process lock (prevent swap) count.
pub ki_lock: c_char,
/// Run queue index.
pub ki_rqindex: c_char,
/// Which cpu we are on.
pub ki_oncpu_old: c_uchar,
/// Last cpu we were on.
pub ki_lastcpu_old: c_uchar,
/// Thread name.
pub ki_tdname: [c_char; crate::TDNAMLEN + 1],
/// Wchan message.
pub ki_wmesg: [c_char; crate::WMESGLEN + 1],
/// Setlogin name.
pub ki_login: [c_char; crate::LOGNAMELEN + 1],
/// Lock name.
pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1],
/// Command name.
pub ki_comm: [c_char; crate::COMMLEN + 1],
/// Emulation name.
pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1],
/// Login class.
pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1],
/// More thread name.
pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1],
/// Spare string space.
pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq
/// Spare room for growth.
pub ki_spareints: [c_int; crate::KI_NSPARE_INT],
/// Which cpu we are on.
pub ki_oncpu: c_int,
/// Last cpu we were on.
pub ki_lastcpu: c_int,
/// PID of tracing process.
pub ki_tracer: c_int,
/// P2_* flags.
pub ki_flag2: c_int,
/// Default FIB number.
pub ki_fibnum: c_int,
/// Credential flags.
pub ki_cr_flags: crate::u_int,
/// Process jail ID.
pub ki_jid: c_int,
/// Number of threads in total.
pub ki_numthreads: c_int,
/// Thread ID.
pub ki_tid: crate::lwpid_t,
/// Process priority.
pub ki_pri: crate::priority,
/// Process rusage statistics.
pub ki_rusage: crate::rusage,
/// rusage of children processes.
pub ki_rusage_ch: crate::rusage,
// This is normally "struct pcb".
/// Kernel virtual addr of pcb.
pub ki_pcb: *mut c_void,
/// Kernel virtual addr of stack.
pub ki_kstack: *mut c_void,
/// User convenience pointer.
pub ki_udata: *mut c_void,
// This is normally "struct thread".
pub ki_tdaddr: *mut c_void,
pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR],
pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG],
/// PS_* flags.
pub ki_sflag: c_long,
/// kthread flag.
pub ki_tdflags: c_long,
}
}
s_no_extra_traits! {
pub struct dirent {
pub d_fileno: crate::ino_t,
pub d_reclen: u16,
pub d_type: u8,
// Type of `d_namlen` changed from `char` to `u16` in FreeBSD 12:
pub d_namlen: u8,
pub d_name: [c_char; 256],
}
pub struct statfs {
pub f_version: u32,
pub f_type: u32,
pub f_flags: u64,
pub f_bsize: u64,
pub f_iosize: u64,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: i64,
pub f_files: u64,
pub f_ffree: i64,
pub f_syncwrites: u64,
pub f_asyncwrites: u64,
pub f_syncreads: u64,
pub f_asyncreads: u64,
f_spare: [u64; 10],
pub f_namemax: u32,
pub f_owner: crate::uid_t,
pub f_fsid: crate::fsid_t,
f_charspare: [c_char; 80],
pub f_fstypename: [c_char; 16],
// Array length changed from 88 to 1024 in FreeBSD 12:
pub f_mntfromname: [c_char; 88],
// Array length changed from 88 to 1024 in FreeBSD 12:
pub f_mntonname: [c_char; 88],
}
pub struct vnstat {
pub vn_fileid: u64,
pub vn_size: u64,
pub vn_mntdir: *mut c_char,
pub vn_dev: u32,
pub vn_fsid: u32,
pub vn_type: c_int,
pub vn_mode: u16,
pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for statfs {
fn eq(&self, other: &statfs) -> bool {
self.f_version == other.f_version
&& self.f_type == other.f_type
&& self.f_flags == other.f_flags
&& self.f_bsize == other.f_bsize
&& self.f_iosize == other.f_iosize
&& self.f_blocks == other.f_blocks
&& self.f_bfree == other.f_bfree
&& self.f_bavail == other.f_bavail
&& self.f_files == other.f_files
&& self.f_ffree == other.f_ffree
&& self.f_syncwrites == other.f_syncwrites
&& self.f_asyncwrites == other.f_asyncwrites
&& self.f_syncreads == other.f_syncreads
&& self.f_asyncreads == other.f_asyncreads
&& self.f_namemax == other.f_namemax
&& self.f_owner == other.f_owner
&& self.f_fsid == other.f_fsid
&& self.f_fstypename == other.f_fstypename
&& self
.f_mntfromname
.iter()
.zip(other.f_mntfromname.iter())
.all(|(a, b)| a == b)
&& self
.f_mntonname
.iter()
.zip(other.f_mntonname.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for statfs {}
impl hash::Hash for statfs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.f_version.hash(state);
self.f_type.hash(state);
self.f_flags.hash(state);
self.f_bsize.hash(state);
self.f_iosize.hash(state);
self.f_blocks.hash(state);
self.f_bfree.hash(state);
self.f_bavail.hash(state);
self.f_files.hash(state);
self.f_ffree.hash(state);
self.f_syncwrites.hash(state);
self.f_asyncwrites.hash(state);
self.f_syncreads.hash(state);
self.f_asyncreads.hash(state);
self.f_namemax.hash(state);
self.f_owner.hash(state);
self.f_fsid.hash(state);
self.f_fstypename.hash(state);
self.f_mntfromname.hash(state);
self.f_mntonname.hash(state);
}
}
impl PartialEq for dirent {
fn eq(&self, other: &dirent) -> bool {
self.d_fileno == other.d_fileno
&& self.d_reclen == other.d_reclen
&& self.d_type == other.d_type
&& self.d_namlen == other.d_namlen
&& self.d_name[..self.d_namlen as _]
.iter()
.zip(other.d_name.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for dirent {}
impl hash::Hash for dirent {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.d_fileno.hash(state);
self.d_reclen.hash(state);
self.d_type.hash(state);
self.d_namlen.hash(state);
self.d_name[..self.d_namlen as _].hash(state);
}
}
impl PartialEq for vnstat {
fn eq(&self, other: &vnstat) -> bool {
let self_vn_devname: &[c_char] = &self.vn_devname;
let other_vn_devname: &[c_char] = &other.vn_devname;
self.vn_fileid == other.vn_fileid
&& self.vn_size == other.vn_size
&& self.vn_mntdir == other.vn_mntdir
&& self.vn_dev == other.vn_dev
&& self.vn_fsid == other.vn_fsid
&& self.vn_type == other.vn_type
&& self.vn_mode == other.vn_mode
&& self_vn_devname == other_vn_devname
}
}
impl Eq for vnstat {}
impl hash::Hash for vnstat {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
let self_vn_devname: &[c_char] = &self.vn_devname;
self.vn_fileid.hash(state);
self.vn_size.hash(state);
self.vn_mntdir.hash(state);
self.vn_dev.hash(state);
self.vn_fsid.hash(state);
self.vn_type.hash(state);
self.vn_mode.hash(state);
self_vn_devname.hash(state);
}
}
}
}
pub const ELAST: c_int = 96;
pub const RAND_MAX: c_int = 0x7fff_fffd;
pub const KI_NSPARE_PTR: usize = 6;
pub const MINCORE_SUPER: c_int = 0x20;
/// max length of devicename
pub const SPECNAMELEN: c_int = 63;
safe_f! {
pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
let major = major as crate::dev_t;
let minor = minor as crate::dev_t;
(major << 8) | minor
}
pub const fn major(dev: crate::dev_t) -> c_int {
((dev >> 8) & 0xff) as c_int
}
pub const fn minor(dev: crate::dev_t) -> c_int {
(dev & 0xffff00ff) as c_int
}
}
extern "C" {
// Return type c_int was removed in FreeBSD 12
pub fn setgrent() -> c_int;
// Type of `addr` argument changed from `const void*` to `void*`
// in FreeBSD 12
pub fn mprotect(addr: *const c_void, len: size_t, prot: c_int) -> c_int;
// Return type c_int was removed in FreeBSD 12
pub fn freelocale(loc: crate::locale_t) -> c_int;
// Return type c_int changed to ssize_t in FreeBSD 12:
pub fn msgrcv(
msqid: c_int,
msgp: *mut c_void,
msgsz: size_t,
msgtyp: c_long,
msgflg: c_int,
) -> c_int;
// Type of `path` argument changed from `const void*` to `void*`
// in FreeBSD 12
pub fn dirname(path: *const c_char) -> *mut c_char;
pub fn basename(path: *const c_char) -> *mut c_char;
// Argument order of the function pointer changed in FreeBSD 14. From 14 onwards the signature
// matches the POSIX specification by having the third argument be a mutable pointer, on
// earlier versions the first argument is the mutable pointer.
#[link_name = "qsort_r@FBSD_1.0"]
pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
arg: *mut c_void,
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
);
}
cfg_if! {
if #[cfg(target_pointer_width = "64")] {
mod b64;
pub use self::b64::*;
} else {
mod b32;
pub use self::b32::*;
}
}

View File

@@ -0,0 +1,487 @@
use crate::off_t;
use crate::prelude::*;
// APIs in FreeBSD 12 that have changed since 11.
pub type nlink_t = u64;
pub type dev_t = u64;
pub type ino_t = u64;
pub type shmatt_t = c_uint;
s! {
pub struct shmid_ds {
pub shm_perm: crate::ipc_perm,
pub shm_segsz: size_t,
pub shm_lpid: crate::pid_t,
pub shm_cpid: crate::pid_t,
pub shm_nattch: crate::shmatt_t,
pub shm_atime: crate::time_t,
pub shm_dtime: crate::time_t,
pub shm_ctime: crate::time_t,
}
pub struct kevent {
pub ident: crate::uintptr_t,
pub filter: c_short,
pub flags: c_ushort,
pub fflags: c_uint,
pub data: i64,
pub udata: *mut c_void,
pub ext: [u64; 4],
}
pub struct kvm_page {
pub version: c_uint,
pub paddr: c_ulong,
pub kmap_vaddr: c_ulong,
pub dmap_vaddr: c_ulong,
pub prot: crate::vm_prot_t,
pub offset: crate::u_long,
pub len: size_t,
}
pub struct kinfo_proc {
/// Size of this structure.
pub ki_structsize: c_int,
/// Reserved: layout identifier.
pub ki_layout: c_int,
/// Address of command arguments.
pub ki_args: *mut crate::pargs,
// This is normally "struct proc".
/// Address of proc.
pub ki_paddr: *mut c_void,
// This is normally "struct user".
/// Kernel virtual address of u-area.
pub ki_addr: *mut c_void,
// This is normally "struct vnode".
/// Pointer to trace file.
pub ki_tracep: *mut c_void,
// This is normally "struct vnode".
/// Pointer to executable file.
pub ki_textvp: *mut c_void,
/// Pointer to open file info.
pub ki_fd: *mut crate::filedesc,
// This is normally "struct vmspace".
/// Pointer to kernel vmspace struct.
pub ki_vmspace: *mut c_void,
/// Sleep address.
pub ki_wchan: *mut c_void,
/// Process identifier.
pub ki_pid: crate::pid_t,
/// Parent process ID.
pub ki_ppid: crate::pid_t,
/// Process group ID.
pub ki_pgid: crate::pid_t,
/// tty process group ID.
pub ki_tpgid: crate::pid_t,
/// Process session ID.
pub ki_sid: crate::pid_t,
/// Terminal session ID.
pub ki_tsid: crate::pid_t,
/// Job control counter.
pub ki_jobc: c_short,
/// Unused (just here for alignment).
pub ki_spare_short1: c_short,
/// Controlling tty dev.
pub ki_tdev_freebsd11: u32,
/// Signals arrived but not delivered.
pub ki_siglist: crate::sigset_t,
/// Current signal mask.
pub ki_sigmask: crate::sigset_t,
/// Signals being ignored.
pub ki_sigignore: crate::sigset_t,
/// Signals being caught by user.
pub ki_sigcatch: crate::sigset_t,
/// Effective user ID.
pub ki_uid: crate::uid_t,
/// Real user ID.
pub ki_ruid: crate::uid_t,
/// Saved effective user ID.
pub ki_svuid: crate::uid_t,
/// Real group ID.
pub ki_rgid: crate::gid_t,
/// Saved effective group ID.
pub ki_svgid: crate::gid_t,
/// Number of groups.
pub ki_ngroups: c_short,
/// Unused (just here for alignment).
pub ki_spare_short2: c_short,
/// Groups.
pub ki_groups: [crate::gid_t; crate::KI_NGROUPS],
/// Virtual size.
pub ki_size: crate::vm_size_t,
/// Current resident set size in pages.
pub ki_rssize: crate::segsz_t,
/// Resident set size before last swap.
pub ki_swrss: crate::segsz_t,
/// Text size (pages) XXX.
pub ki_tsize: crate::segsz_t,
/// Data size (pages) XXX.
pub ki_dsize: crate::segsz_t,
/// Stack size (pages).
pub ki_ssize: crate::segsz_t,
/// Exit status for wait & stop signal.
pub ki_xstat: crate::u_short,
/// Accounting flags.
pub ki_acflag: crate::u_short,
/// %cpu for process during `ki_swtime`.
pub ki_pctcpu: crate::fixpt_t,
/// Time averaged value of `ki_cpticks`.
pub ki_estcpu: crate::u_int,
/// Time since last blocked.
pub ki_slptime: crate::u_int,
/// Time swapped in or out.
pub ki_swtime: crate::u_int,
/// Number of copy-on-write faults.
pub ki_cow: crate::u_int,
/// Real time in microsec.
pub ki_runtime: u64,
/// Starting time.
pub ki_start: crate::timeval,
/// Time used by process children.
pub ki_childtime: crate::timeval,
/// P_* flags.
pub ki_flag: c_long,
/// KI_* flags (below).
pub ki_kiflag: c_long,
/// Kernel trace points.
pub ki_traceflag: c_int,
/// S* process status.
pub ki_stat: c_char,
/// Process "nice" value.
pub ki_nice: i8, // signed char
/// Process lock (prevent swap) count.
pub ki_lock: c_char,
/// Run queue index.
pub ki_rqindex: c_char,
/// Which cpu we are on.
pub ki_oncpu_old: c_uchar,
/// Last cpu we were on.
pub ki_lastcpu_old: c_uchar,
/// Thread name.
pub ki_tdname: [c_char; crate::TDNAMLEN + 1],
/// Wchan message.
pub ki_wmesg: [c_char; crate::WMESGLEN + 1],
/// Setlogin name.
pub ki_login: [c_char; crate::LOGNAMELEN + 1],
/// Lock name.
pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1],
/// Command name.
pub ki_comm: [c_char; crate::COMMLEN + 1],
/// Emulation name.
pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1],
/// Login class.
pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1],
/// More thread name.
pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1],
/// Spare string space.
pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq
/// Spare room for growth.
pub ki_spareints: [c_int; crate::KI_NSPARE_INT],
/// Controlling tty dev.
pub ki_tdev: crate::dev_t,
/// Which cpu we are on.
pub ki_oncpu: c_int,
/// Last cpu we were on.
pub ki_lastcpu: c_int,
/// PID of tracing process.
pub ki_tracer: c_int,
/// P2_* flags.
pub ki_flag2: c_int,
/// Default FIB number.
pub ki_fibnum: c_int,
/// Credential flags.
pub ki_cr_flags: crate::u_int,
/// Process jail ID.
pub ki_jid: c_int,
/// Number of threads in total.
pub ki_numthreads: c_int,
/// Thread ID.
pub ki_tid: crate::lwpid_t,
/// Process priority.
pub ki_pri: crate::priority,
/// Process rusage statistics.
pub ki_rusage: crate::rusage,
/// rusage of children processes.
pub ki_rusage_ch: crate::rusage,
// This is normally "struct pcb".
/// Kernel virtual addr of pcb.
pub ki_pcb: *mut c_void,
/// Kernel virtual addr of stack.
pub ki_kstack: *mut c_void,
/// User convenience pointer.
pub ki_udata: *mut c_void,
// This is normally "struct thread".
pub ki_tdaddr: *mut c_void,
pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR],
pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG],
/// PS_* flags.
pub ki_sflag: c_long,
/// kthread flag.
pub ki_tdflags: c_long,
}
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: crate::nlink_t,
pub st_mode: crate::mode_t,
st_padding0: i16,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
st_padding1: i32,
pub st_rdev: crate::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: crate::time_t,
pub st_birthtime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: crate::blkcnt_t,
pub st_blksize: crate::blksize_t,
pub st_flags: crate::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}
s_no_extra_traits! {
pub struct dirent {
pub d_fileno: crate::ino_t,
pub d_off: off_t,
pub d_reclen: u16,
pub d_type: u8,
d_pad0: u8,
pub d_namlen: u16,
d_pad1: u16,
pub d_name: [c_char; 256],
}
pub struct statfs {
pub f_version: u32,
pub f_type: u32,
pub f_flags: u64,
pub f_bsize: u64,
pub f_iosize: u64,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: i64,
pub f_files: u64,
pub f_ffree: i64,
pub f_syncwrites: u64,
pub f_asyncwrites: u64,
pub f_syncreads: u64,
pub f_asyncreads: u64,
f_spare: [u64; 10],
pub f_namemax: u32,
pub f_owner: crate::uid_t,
pub f_fsid: crate::fsid_t,
f_charspare: [c_char; 80],
pub f_fstypename: [c_char; 16],
pub f_mntfromname: [c_char; 1024],
pub f_mntonname: [c_char; 1024],
}
pub struct vnstat {
pub vn_fileid: u64,
pub vn_size: u64,
pub vn_dev: u64,
pub vn_fsid: u64,
pub vn_mntdir: *mut c_char,
pub vn_type: c_int,
pub vn_mode: u16,
pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for statfs {
fn eq(&self, other: &statfs) -> bool {
self.f_version == other.f_version
&& self.f_type == other.f_type
&& self.f_flags == other.f_flags
&& self.f_bsize == other.f_bsize
&& self.f_iosize == other.f_iosize
&& self.f_blocks == other.f_blocks
&& self.f_bfree == other.f_bfree
&& self.f_bavail == other.f_bavail
&& self.f_files == other.f_files
&& self.f_ffree == other.f_ffree
&& self.f_syncwrites == other.f_syncwrites
&& self.f_asyncwrites == other.f_asyncwrites
&& self.f_syncreads == other.f_syncreads
&& self.f_asyncreads == other.f_asyncreads
&& self.f_namemax == other.f_namemax
&& self.f_owner == other.f_owner
&& self.f_fsid == other.f_fsid
&& self.f_fstypename == other.f_fstypename
&& self
.f_mntfromname
.iter()
.zip(other.f_mntfromname.iter())
.all(|(a, b)| a == b)
&& self
.f_mntonname
.iter()
.zip(other.f_mntonname.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for statfs {}
impl hash::Hash for statfs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.f_version.hash(state);
self.f_type.hash(state);
self.f_flags.hash(state);
self.f_bsize.hash(state);
self.f_iosize.hash(state);
self.f_blocks.hash(state);
self.f_bfree.hash(state);
self.f_bavail.hash(state);
self.f_files.hash(state);
self.f_ffree.hash(state);
self.f_syncwrites.hash(state);
self.f_asyncwrites.hash(state);
self.f_syncreads.hash(state);
self.f_asyncreads.hash(state);
self.f_namemax.hash(state);
self.f_owner.hash(state);
self.f_fsid.hash(state);
self.f_charspare.hash(state);
self.f_fstypename.hash(state);
self.f_mntfromname.hash(state);
self.f_mntonname.hash(state);
}
}
impl PartialEq for dirent {
fn eq(&self, other: &dirent) -> bool {
self.d_fileno == other.d_fileno
&& self.d_off == other.d_off
&& self.d_reclen == other.d_reclen
&& self.d_type == other.d_type
&& self.d_namlen == other.d_namlen
&& self.d_name[..self.d_namlen as _]
.iter()
.zip(other.d_name.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for dirent {}
impl hash::Hash for dirent {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.d_fileno.hash(state);
self.d_off.hash(state);
self.d_reclen.hash(state);
self.d_type.hash(state);
self.d_namlen.hash(state);
self.d_name[..self.d_namlen as _].hash(state);
}
}
impl PartialEq for vnstat {
fn eq(&self, other: &vnstat) -> bool {
let self_vn_devname: &[c_char] = &self.vn_devname;
let other_vn_devname: &[c_char] = &other.vn_devname;
self.vn_fileid == other.vn_fileid
&& self.vn_size == other.vn_size
&& self.vn_dev == other.vn_dev
&& self.vn_fsid == other.vn_fsid
&& self.vn_mntdir == other.vn_mntdir
&& self.vn_type == other.vn_type
&& self.vn_mode == other.vn_mode
&& self_vn_devname == other_vn_devname
}
}
impl Eq for vnstat {}
impl hash::Hash for vnstat {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
let self_vn_devname: &[c_char] = &self.vn_devname;
self.vn_fileid.hash(state);
self.vn_size.hash(state);
self.vn_dev.hash(state);
self.vn_fsid.hash(state);
self.vn_mntdir.hash(state);
self.vn_type.hash(state);
self.vn_mode.hash(state);
self_vn_devname.hash(state);
}
}
}
}
pub const RAND_MAX: c_int = 0x7fff_fffd;
pub const ELAST: c_int = 97;
/// max length of devicename
pub const SPECNAMELEN: c_int = 63;
pub const KI_NSPARE_PTR: usize = 6;
pub const MINCORE_SUPER: c_int = 0x20;
safe_f! {
pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
let major = major as crate::dev_t;
let minor = minor as crate::dev_t;
let mut dev = 0;
dev |= ((major & 0xffffff00) as dev_t) << 32;
dev |= ((major & 0x000000ff) as dev_t) << 8;
dev |= ((minor & 0x0000ff00) as dev_t) << 24;
dev |= ((minor & 0xffff00ff) as dev_t) << 0;
dev
}
pub const fn major(dev: crate::dev_t) -> c_int {
(((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int
}
pub const fn minor(dev: crate::dev_t) -> c_int {
(((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int
}
}
extern "C" {
pub fn setgrent();
pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
pub fn freelocale(loc: crate::locale_t);
pub fn msgrcv(
msqid: c_int,
msgp: *mut c_void,
msgsz: size_t,
msgtyp: c_long,
msgflg: c_int,
) -> ssize_t;
pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;
#[link_name = "qsort_r@FBSD_1.0"]
pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
arg: *mut c_void,
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
);
}
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
}
}

View File

@@ -0,0 +1,7 @@
use crate::prelude::*;
pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN;
pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1;
pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2;
pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1;
pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000;

View File

@@ -0,0 +1,531 @@
use crate::off_t;
use crate::prelude::*;
// APIs in FreeBSD 13 that have changed since 11.
pub type nlink_t = u64;
pub type dev_t = u64;
pub type ino_t = u64;
pub type shmatt_t = c_uint;
pub type kpaddr_t = u64;
pub type kssize_t = i64;
pub type domainset_t = __c_anonymous_domainset;
s! {
pub struct shmid_ds {
pub shm_perm: crate::ipc_perm,
pub shm_segsz: size_t,
pub shm_lpid: crate::pid_t,
pub shm_cpid: crate::pid_t,
pub shm_nattch: crate::shmatt_t,
pub shm_atime: crate::time_t,
pub shm_dtime: crate::time_t,
pub shm_ctime: crate::time_t,
}
pub struct kevent {
pub ident: crate::uintptr_t,
pub filter: c_short,
pub flags: c_ushort,
pub fflags: c_uint,
pub data: i64,
pub udata: *mut c_void,
pub ext: [u64; 4],
}
pub struct kvm_page {
pub kp_version: crate::u_int,
pub kp_paddr: crate::kpaddr_t,
pub kp_kmap_vaddr: crate::kvaddr_t,
pub kp_dmap_vaddr: crate::kvaddr_t,
pub kp_prot: crate::vm_prot_t,
pub kp_offset: off_t,
pub kp_len: size_t,
}
pub struct __c_anonymous_domainset {
#[cfg(target_pointer_width = "64")]
_priv: [c_ulong; 4],
#[cfg(target_pointer_width = "32")]
_priv: [c_ulong; 8],
}
pub struct kinfo_proc {
/// Size of this structure.
pub ki_structsize: c_int,
/// Reserved: layout identifier.
pub ki_layout: c_int,
/// Address of command arguments.
pub ki_args: *mut crate::pargs,
// This is normally "struct proc".
/// Address of proc.
pub ki_paddr: *mut c_void,
// This is normally "struct user".
/// Kernel virtual address of u-area.
pub ki_addr: *mut c_void,
// This is normally "struct vnode".
/// Pointer to trace file.
pub ki_tracep: *mut c_void,
// This is normally "struct vnode".
/// Pointer to executable file.
pub ki_textvp: *mut c_void,
/// Pointer to open file info.
pub ki_fd: *mut crate::filedesc,
// This is normally "struct vmspace".
/// Pointer to kernel vmspace struct.
pub ki_vmspace: *mut c_void,
/// Sleep address.
pub ki_wchan: *const c_void,
/// Process identifier.
pub ki_pid: crate::pid_t,
/// Parent process ID.
pub ki_ppid: crate::pid_t,
/// Process group ID.
pub ki_pgid: crate::pid_t,
/// tty process group ID.
pub ki_tpgid: crate::pid_t,
/// Process session ID.
pub ki_sid: crate::pid_t,
/// Terminal session ID.
pub ki_tsid: crate::pid_t,
/// Job control counter.
pub ki_jobc: c_short,
/// Unused (just here for alignment).
pub ki_spare_short1: c_short,
/// Controlling tty dev.
pub ki_tdev_freebsd11: u32,
/// Signals arrived but not delivered.
pub ki_siglist: crate::sigset_t,
/// Current signal mask.
pub ki_sigmask: crate::sigset_t,
/// Signals being ignored.
pub ki_sigignore: crate::sigset_t,
/// Signals being caught by user.
pub ki_sigcatch: crate::sigset_t,
/// Effective user ID.
pub ki_uid: crate::uid_t,
/// Real user ID.
pub ki_ruid: crate::uid_t,
/// Saved effective user ID.
pub ki_svuid: crate::uid_t,
/// Real group ID.
pub ki_rgid: crate::gid_t,
/// Saved effective group ID.
pub ki_svgid: crate::gid_t,
/// Number of groups.
pub ki_ngroups: c_short,
/// Unused (just here for alignment).
pub ki_spare_short2: c_short,
/// Groups.
pub ki_groups: [crate::gid_t; crate::KI_NGROUPS],
/// Virtual size.
pub ki_size: crate::vm_size_t,
/// Current resident set size in pages.
pub ki_rssize: crate::segsz_t,
/// Resident set size before last swap.
pub ki_swrss: crate::segsz_t,
/// Text size (pages) XXX.
pub ki_tsize: crate::segsz_t,
/// Data size (pages) XXX.
pub ki_dsize: crate::segsz_t,
/// Stack size (pages).
pub ki_ssize: crate::segsz_t,
/// Exit status for wait & stop signal.
pub ki_xstat: crate::u_short,
/// Accounting flags.
pub ki_acflag: crate::u_short,
/// %cpu for process during `ki_swtime`.
pub ki_pctcpu: crate::fixpt_t,
/// Time averaged value of `ki_cpticks`.
pub ki_estcpu: crate::u_int,
/// Time since last blocked.
pub ki_slptime: crate::u_int,
/// Time swapped in or out.
pub ki_swtime: crate::u_int,
/// Number of copy-on-write faults.
pub ki_cow: crate::u_int,
/// Real time in microsec.
pub ki_runtime: u64,
/// Starting time.
pub ki_start: crate::timeval,
/// Time used by process children.
pub ki_childtime: crate::timeval,
/// P_* flags.
pub ki_flag: c_long,
/// KI_* flags (below).
pub ki_kiflag: c_long,
/// Kernel trace points.
pub ki_traceflag: c_int,
/// S* process status.
pub ki_stat: c_char,
/// Process "nice" value.
pub ki_nice: i8, // signed char
/// Process lock (prevent swap) count.
pub ki_lock: c_char,
/// Run queue index.
pub ki_rqindex: c_char,
/// Which cpu we are on.
pub ki_oncpu_old: c_uchar,
/// Last cpu we were on.
pub ki_lastcpu_old: c_uchar,
/// Thread name.
pub ki_tdname: [c_char; crate::TDNAMLEN + 1],
/// Wchan message.
pub ki_wmesg: [c_char; crate::WMESGLEN + 1],
/// Setlogin name.
pub ki_login: [c_char; crate::LOGNAMELEN + 1],
/// Lock name.
pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1],
/// Command name.
pub ki_comm: [c_char; crate::COMMLEN + 1],
/// Emulation name.
pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1],
/// Login class.
pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1],
/// More thread name.
pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1],
/// Spare string space.
pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq
/// Spare room for growth.
pub ki_spareints: [c_int; crate::KI_NSPARE_INT],
/// Controlling tty dev.
pub ki_tdev: u64,
/// Which cpu we are on.
pub ki_oncpu: c_int,
/// Last cpu we were on.
pub ki_lastcpu: c_int,
/// PID of tracing process.
pub ki_tracer: c_int,
/// P2_* flags.
pub ki_flag2: c_int,
/// Default FIB number.
pub ki_fibnum: c_int,
/// Credential flags.
pub ki_cr_flags: crate::u_int,
/// Process jail ID.
pub ki_jid: c_int,
/// Number of threads in total.
pub ki_numthreads: c_int,
/// Thread ID.
pub ki_tid: crate::lwpid_t,
/// Process priority.
pub ki_pri: crate::priority,
/// Process rusage statistics.
pub ki_rusage: crate::rusage,
/// rusage of children processes.
pub ki_rusage_ch: crate::rusage,
// This is normally "struct pcb".
/// Kernel virtual addr of pcb.
pub ki_pcb: *mut c_void,
/// Kernel virtual addr of stack.
pub ki_kstack: *mut c_void,
/// User convenience pointer.
pub ki_udata: *mut c_void,
// This is normally "struct thread".
pub ki_tdaddr: *mut c_void,
// This is normally "struct pwddesc".
/// Pointer to process paths info.
pub ki_pd: *mut c_void,
pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR],
pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG],
/// PS_* flags.
pub ki_sflag: c_long,
/// kthread flag.
pub ki_tdflags: c_long,
}
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: crate::nlink_t,
pub st_mode: crate::mode_t,
st_padding0: i16,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
st_padding1: i32,
pub st_rdev: crate::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: crate::time_t,
pub st_birthtime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: crate::blkcnt_t,
pub st_blksize: crate::blksize_t,
pub st_flags: crate::fflags_t,
pub st_gen: u64,
pub st_spare: [u64; 10],
}
}
s_no_extra_traits! {
pub struct dirent {
pub d_fileno: crate::ino_t,
pub d_off: off_t,
pub d_reclen: u16,
pub d_type: u8,
d_pad0: u8,
pub d_namlen: u16,
d_pad1: u16,
pub d_name: [c_char; 256],
}
pub struct statfs {
pub f_version: u32,
pub f_type: u32,
pub f_flags: u64,
pub f_bsize: u64,
pub f_iosize: u64,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: i64,
pub f_files: u64,
pub f_ffree: i64,
pub f_syncwrites: u64,
pub f_asyncwrites: u64,
pub f_syncreads: u64,
pub f_asyncreads: u64,
f_spare: [u64; 10],
pub f_namemax: u32,
pub f_owner: crate::uid_t,
pub f_fsid: crate::fsid_t,
f_charspare: [c_char; 80],
pub f_fstypename: [c_char; 16],
pub f_mntfromname: [c_char; 1024],
pub f_mntonname: [c_char; 1024],
}
pub struct vnstat {
pub vn_fileid: u64,
pub vn_size: u64,
pub vn_dev: u64,
pub vn_fsid: u64,
pub vn_mntdir: *mut c_char,
pub vn_type: c_int,
pub vn_mode: u16,
pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for statfs {
fn eq(&self, other: &statfs) -> bool {
self.f_version == other.f_version
&& self.f_type == other.f_type
&& self.f_flags == other.f_flags
&& self.f_bsize == other.f_bsize
&& self.f_iosize == other.f_iosize
&& self.f_blocks == other.f_blocks
&& self.f_bfree == other.f_bfree
&& self.f_bavail == other.f_bavail
&& self.f_files == other.f_files
&& self.f_ffree == other.f_ffree
&& self.f_syncwrites == other.f_syncwrites
&& self.f_asyncwrites == other.f_asyncwrites
&& self.f_syncreads == other.f_syncreads
&& self.f_asyncreads == other.f_asyncreads
&& self.f_namemax == other.f_namemax
&& self.f_owner == other.f_owner
&& self.f_fsid == other.f_fsid
&& self.f_fstypename == other.f_fstypename
&& self
.f_mntfromname
.iter()
.zip(other.f_mntfromname.iter())
.all(|(a, b)| a == b)
&& self
.f_mntonname
.iter()
.zip(other.f_mntonname.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for statfs {}
impl hash::Hash for statfs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.f_version.hash(state);
self.f_type.hash(state);
self.f_flags.hash(state);
self.f_bsize.hash(state);
self.f_iosize.hash(state);
self.f_blocks.hash(state);
self.f_bfree.hash(state);
self.f_bavail.hash(state);
self.f_files.hash(state);
self.f_ffree.hash(state);
self.f_syncwrites.hash(state);
self.f_asyncwrites.hash(state);
self.f_syncreads.hash(state);
self.f_asyncreads.hash(state);
self.f_namemax.hash(state);
self.f_owner.hash(state);
self.f_fsid.hash(state);
self.f_charspare.hash(state);
self.f_fstypename.hash(state);
self.f_mntfromname.hash(state);
self.f_mntonname.hash(state);
}
}
impl PartialEq for dirent {
fn eq(&self, other: &dirent) -> bool {
self.d_fileno == other.d_fileno
&& self.d_off == other.d_off
&& self.d_reclen == other.d_reclen
&& self.d_type == other.d_type
&& self.d_namlen == other.d_namlen
&& self.d_name[..self.d_namlen as _]
.iter()
.zip(other.d_name.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for dirent {}
impl hash::Hash for dirent {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.d_fileno.hash(state);
self.d_off.hash(state);
self.d_reclen.hash(state);
self.d_type.hash(state);
self.d_namlen.hash(state);
self.d_name[..self.d_namlen as _].hash(state);
}
}
impl PartialEq for vnstat {
fn eq(&self, other: &vnstat) -> bool {
let self_vn_devname: &[c_char] = &self.vn_devname;
let other_vn_devname: &[c_char] = &other.vn_devname;
self.vn_fileid == other.vn_fileid
&& self.vn_size == other.vn_size
&& self.vn_dev == other.vn_dev
&& self.vn_fsid == other.vn_fsid
&& self.vn_mntdir == other.vn_mntdir
&& self.vn_type == other.vn_type
&& self.vn_mode == other.vn_mode
&& self_vn_devname == other_vn_devname
}
}
impl Eq for vnstat {}
impl hash::Hash for vnstat {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
let self_vn_devname: &[c_char] = &self.vn_devname;
self.vn_fileid.hash(state);
self.vn_size.hash(state);
self.vn_dev.hash(state);
self.vn_fsid.hash(state);
self.vn_mntdir.hash(state);
self.vn_type.hash(state);
self.vn_mode.hash(state);
self_vn_devname.hash(state);
}
}
}
}
pub const RAND_MAX: c_int = 0x7fff_ffff;
pub const ELAST: c_int = 97;
pub const KF_TYPE_EVENTFD: c_int = 13;
/// max length of devicename
pub const SPECNAMELEN: c_int = 255;
pub const KI_NSPARE_PTR: usize = 5;
/// domainset policies
pub const DOMAINSET_POLICY_INVALID: c_int = 0;
pub const DOMAINSET_POLICY_ROUNDROBIN: c_int = 1;
pub const DOMAINSET_POLICY_FIRSTTOUCH: c_int = 2;
pub const DOMAINSET_POLICY_PREFER: c_int = 3;
pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4;
pub const MINCORE_SUPER: c_int = 0x20;
safe_f! {
pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
let major = major as crate::dev_t;
let minor = minor as crate::dev_t;
let mut dev = 0;
dev |= ((major & 0xffffff00) as dev_t) << 32;
dev |= ((major & 0x000000ff) as dev_t) << 8;
dev |= ((minor & 0x0000ff00) as dev_t) << 24;
dev |= ((minor & 0xffff00ff) as dev_t) << 0;
dev
}
pub const fn major(dev: crate::dev_t) -> c_int {
(((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int
}
pub const fn minor(dev: crate::dev_t) -> c_int {
(((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int
}
}
extern "C" {
pub fn setgrent();
pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
pub fn freelocale(loc: crate::locale_t);
pub fn msgrcv(
msqid: c_int,
msgp: *mut c_void,
msgsz: size_t,
msgtyp: c_long,
msgflg: c_int,
) -> ssize_t;
pub fn cpuset_getdomain(
level: crate::cpulevel_t,
which: crate::cpuwhich_t,
id: crate::id_t,
setsize: size_t,
mask: *mut crate::domainset_t,
policy: *mut c_int,
) -> c_int;
pub fn cpuset_setdomain(
level: crate::cpulevel_t,
which: crate::cpuwhich_t,
id: crate::id_t,
setsize: size_t,
mask: *const crate::domainset_t,
policy: c_int,
) -> c_int;
pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;
#[link_name = "qsort_r@FBSD_1.0"]
pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
arg: *mut c_void,
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
);
}
#[link(name = "kvm")]
extern "C" {
pub fn kvm_kerndisp(kd: *mut crate::kvm_t) -> crate::kssize_t;
}
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
}
}

View File

@@ -0,0 +1,7 @@
use crate::prelude::*;
pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN;
pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1;
pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2;
pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1;
pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000;

View File

@@ -0,0 +1,532 @@
use crate::off_t;
use crate::prelude::*;
// APIs in FreeBSD 14 that have changed since 11.
pub type nlink_t = u64;
pub type dev_t = u64;
pub type ino_t = u64;
pub type shmatt_t = c_uint;
pub type kpaddr_t = u64;
pub type kssize_t = i64;
pub type domainset_t = __c_anonymous_domainset;
s! {
pub struct shmid_ds {
pub shm_perm: crate::ipc_perm,
pub shm_segsz: size_t,
pub shm_lpid: crate::pid_t,
pub shm_cpid: crate::pid_t,
pub shm_nattch: crate::shmatt_t,
pub shm_atime: crate::time_t,
pub shm_dtime: crate::time_t,
pub shm_ctime: crate::time_t,
}
pub struct kevent {
pub ident: crate::uintptr_t,
pub filter: c_short,
pub flags: c_ushort,
pub fflags: c_uint,
pub data: i64,
pub udata: *mut c_void,
pub ext: [u64; 4],
}
pub struct kvm_page {
pub kp_version: crate::u_int,
pub kp_paddr: crate::kpaddr_t,
pub kp_kmap_vaddr: crate::kvaddr_t,
pub kp_dmap_vaddr: crate::kvaddr_t,
pub kp_prot: crate::vm_prot_t,
pub kp_offset: off_t,
pub kp_len: size_t,
}
pub struct __c_anonymous_domainset {
#[cfg(target_pointer_width = "64")]
_priv: [c_ulong; 4],
#[cfg(target_pointer_width = "32")]
_priv: [c_ulong; 8],
}
pub struct kinfo_proc {
/// Size of this structure.
pub ki_structsize: c_int,
/// Reserved: layout identifier.
pub ki_layout: c_int,
/// Address of command arguments.
pub ki_args: *mut crate::pargs,
// This is normally "struct proc".
/// Address of proc.
pub ki_paddr: *mut c_void,
// This is normally "struct user".
/// Kernel virtual address of u-area.
pub ki_addr: *mut c_void,
// This is normally "struct vnode".
/// Pointer to trace file.
pub ki_tracep: *mut c_void,
// This is normally "struct vnode".
/// Pointer to executable file.
pub ki_textvp: *mut c_void,
/// Pointer to open file info.
pub ki_fd: *mut crate::filedesc,
// This is normally "struct vmspace".
/// Pointer to kernel vmspace struct.
pub ki_vmspace: *mut c_void,
/// Sleep address.
pub ki_wchan: *const c_void,
/// Process identifier.
pub ki_pid: crate::pid_t,
/// Parent process ID.
pub ki_ppid: crate::pid_t,
/// Process group ID.
pub ki_pgid: crate::pid_t,
/// tty process group ID.
pub ki_tpgid: crate::pid_t,
/// Process session ID.
pub ki_sid: crate::pid_t,
/// Terminal session ID.
pub ki_tsid: crate::pid_t,
/// Job control counter.
pub ki_jobc: c_short,
/// Unused (just here for alignment).
pub ki_spare_short1: c_short,
/// Controlling tty dev.
pub ki_tdev_freebsd11: u32,
/// Signals arrived but not delivered.
pub ki_siglist: crate::sigset_t,
/// Current signal mask.
pub ki_sigmask: crate::sigset_t,
/// Signals being ignored.
pub ki_sigignore: crate::sigset_t,
/// Signals being caught by user.
pub ki_sigcatch: crate::sigset_t,
/// Effective user ID.
pub ki_uid: crate::uid_t,
/// Real user ID.
pub ki_ruid: crate::uid_t,
/// Saved effective user ID.
pub ki_svuid: crate::uid_t,
/// Real group ID.
pub ki_rgid: crate::gid_t,
/// Saved effective group ID.
pub ki_svgid: crate::gid_t,
/// Number of groups.
pub ki_ngroups: c_short,
/// Unused (just here for alignment).
pub ki_spare_short2: c_short,
/// Groups.
pub ki_groups: [crate::gid_t; crate::KI_NGROUPS],
/// Virtual size.
pub ki_size: crate::vm_size_t,
/// Current resident set size in pages.
pub ki_rssize: crate::segsz_t,
/// Resident set size before last swap.
pub ki_swrss: crate::segsz_t,
/// Text size (pages) XXX.
pub ki_tsize: crate::segsz_t,
/// Data size (pages) XXX.
pub ki_dsize: crate::segsz_t,
/// Stack size (pages).
pub ki_ssize: crate::segsz_t,
/// Exit status for wait & stop signal.
pub ki_xstat: crate::u_short,
/// Accounting flags.
pub ki_acflag: crate::u_short,
/// %cpu for process during `ki_swtime`.
pub ki_pctcpu: crate::fixpt_t,
/// Time averaged value of `ki_cpticks`.
pub ki_estcpu: crate::u_int,
/// Time since last blocked.
pub ki_slptime: crate::u_int,
/// Time swapped in or out.
pub ki_swtime: crate::u_int,
/// Number of copy-on-write faults.
pub ki_cow: crate::u_int,
/// Real time in microsec.
pub ki_runtime: u64,
/// Starting time.
pub ki_start: crate::timeval,
/// Time used by process children.
pub ki_childtime: crate::timeval,
/// P_* flags.
pub ki_flag: c_long,
/// KI_* flags (below).
pub ki_kiflag: c_long,
/// Kernel trace points.
pub ki_traceflag: c_int,
/// S* process status.
pub ki_stat: c_char,
/// Process "nice" value.
pub ki_nice: i8, // signed char
/// Process lock (prevent swap) count.
pub ki_lock: c_char,
/// Run queue index.
pub ki_rqindex: c_char,
/// Which cpu we are on.
pub ki_oncpu_old: c_uchar,
/// Last cpu we were on.
pub ki_lastcpu_old: c_uchar,
/// Thread name.
pub ki_tdname: [c_char; crate::TDNAMLEN + 1],
/// Wchan message.
pub ki_wmesg: [c_char; crate::WMESGLEN + 1],
/// Setlogin name.
pub ki_login: [c_char; crate::LOGNAMELEN + 1],
/// Lock name.
pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1],
/// Command name.
pub ki_comm: [c_char; crate::COMMLEN + 1],
/// Emulation name.
pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1],
/// Login class.
pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1],
/// More thread name.
pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1],
/// Spare string space.
pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq
/// Spare room for growth.
pub ki_spareints: [c_int; crate::KI_NSPARE_INT],
/// Controlling tty dev.
pub ki_tdev: u64,
/// Which cpu we are on.
pub ki_oncpu: c_int,
/// Last cpu we were on.
pub ki_lastcpu: c_int,
/// PID of tracing process.
pub ki_tracer: c_int,
/// P2_* flags.
pub ki_flag2: c_int,
/// Default FIB number.
pub ki_fibnum: c_int,
/// Credential flags.
pub ki_cr_flags: crate::u_int,
/// Process jail ID.
pub ki_jid: c_int,
/// Number of threads in total.
pub ki_numthreads: c_int,
/// Thread ID.
pub ki_tid: crate::lwpid_t,
/// Process priority.
pub ki_pri: crate::priority,
/// Process rusage statistics.
pub ki_rusage: crate::rusage,
/// rusage of children processes.
pub ki_rusage_ch: crate::rusage,
// This is normally "struct pcb".
/// Kernel virtual addr of pcb.
pub ki_pcb: *mut c_void,
/// Kernel virtual addr of stack.
pub ki_kstack: *mut c_void,
/// User convenience pointer.
pub ki_udata: *mut c_void,
// This is normally "struct thread".
pub ki_tdaddr: *mut c_void,
// This is normally "struct pwddesc".
/// Pointer to process paths info.
pub ki_pd: *mut c_void,
pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR],
pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG],
/// PS_* flags.
pub ki_sflag: c_long,
/// kthread flag.
pub ki_tdflags: c_long,
}
#[non_exhaustive]
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: crate::nlink_t,
pub st_mode: crate::mode_t,
st_padding0: i16,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
st_padding1: i32,
pub st_rdev: crate::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: crate::time_t,
pub st_birthtime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: crate::blkcnt_t,
pub st_blksize: crate::blksize_t,
pub st_flags: crate::fflags_t,
pub st_gen: u64,
pub st_filerev: u64,
pub st_spare: [u64; 9],
}
}
s_no_extra_traits! {
pub struct dirent {
pub d_fileno: crate::ino_t,
pub d_off: off_t,
pub d_reclen: u16,
pub d_type: u8,
d_pad0: u8,
pub d_namlen: u16,
d_pad1: u16,
pub d_name: [c_char; 256],
}
pub struct statfs {
pub f_version: u32,
pub f_type: u32,
pub f_flags: u64,
pub f_bsize: u64,
pub f_iosize: u64,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: i64,
pub f_files: u64,
pub f_ffree: i64,
pub f_syncwrites: u64,
pub f_asyncwrites: u64,
pub f_syncreads: u64,
pub f_asyncreads: u64,
f_spare: [u64; 10],
pub f_namemax: u32,
pub f_owner: crate::uid_t,
pub f_fsid: crate::fsid_t,
f_charspare: [c_char; 80],
pub f_fstypename: [c_char; 16],
pub f_mntfromname: [c_char; 1024],
pub f_mntonname: [c_char; 1024],
}
pub struct vnstat {
pub vn_fileid: u64,
pub vn_size: u64,
pub vn_dev: u64,
pub vn_fsid: u64,
pub vn_mntdir: *mut c_char,
pub vn_type: c_int,
pub vn_mode: u16,
pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for statfs {
fn eq(&self, other: &statfs) -> bool {
self.f_version == other.f_version
&& self.f_type == other.f_type
&& self.f_flags == other.f_flags
&& self.f_bsize == other.f_bsize
&& self.f_iosize == other.f_iosize
&& self.f_blocks == other.f_blocks
&& self.f_bfree == other.f_bfree
&& self.f_bavail == other.f_bavail
&& self.f_files == other.f_files
&& self.f_ffree == other.f_ffree
&& self.f_syncwrites == other.f_syncwrites
&& self.f_asyncwrites == other.f_asyncwrites
&& self.f_syncreads == other.f_syncreads
&& self.f_asyncreads == other.f_asyncreads
&& self.f_namemax == other.f_namemax
&& self.f_owner == other.f_owner
&& self.f_fsid == other.f_fsid
&& self.f_fstypename == other.f_fstypename
&& self
.f_mntfromname
.iter()
.zip(other.f_mntfromname.iter())
.all(|(a, b)| a == b)
&& self
.f_mntonname
.iter()
.zip(other.f_mntonname.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for statfs {}
impl hash::Hash for statfs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.f_version.hash(state);
self.f_type.hash(state);
self.f_flags.hash(state);
self.f_bsize.hash(state);
self.f_iosize.hash(state);
self.f_blocks.hash(state);
self.f_bfree.hash(state);
self.f_bavail.hash(state);
self.f_files.hash(state);
self.f_ffree.hash(state);
self.f_syncwrites.hash(state);
self.f_asyncwrites.hash(state);
self.f_syncreads.hash(state);
self.f_asyncreads.hash(state);
self.f_namemax.hash(state);
self.f_owner.hash(state);
self.f_fsid.hash(state);
self.f_charspare.hash(state);
self.f_fstypename.hash(state);
self.f_mntfromname.hash(state);
self.f_mntonname.hash(state);
}
}
impl PartialEq for dirent {
fn eq(&self, other: &dirent) -> bool {
self.d_fileno == other.d_fileno
&& self.d_off == other.d_off
&& self.d_reclen == other.d_reclen
&& self.d_type == other.d_type
&& self.d_namlen == other.d_namlen
&& self.d_name[..self.d_namlen as _]
.iter()
.zip(other.d_name.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for dirent {}
impl hash::Hash for dirent {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.d_fileno.hash(state);
self.d_off.hash(state);
self.d_reclen.hash(state);
self.d_type.hash(state);
self.d_namlen.hash(state);
self.d_name[..self.d_namlen as _].hash(state);
}
}
impl PartialEq for vnstat {
fn eq(&self, other: &vnstat) -> bool {
let self_vn_devname: &[c_char] = &self.vn_devname;
let other_vn_devname: &[c_char] = &other.vn_devname;
self.vn_fileid == other.vn_fileid
&& self.vn_size == other.vn_size
&& self.vn_dev == other.vn_dev
&& self.vn_fsid == other.vn_fsid
&& self.vn_mntdir == other.vn_mntdir
&& self.vn_type == other.vn_type
&& self.vn_mode == other.vn_mode
&& self_vn_devname == other_vn_devname
}
}
impl Eq for vnstat {}
impl hash::Hash for vnstat {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
let self_vn_devname: &[c_char] = &self.vn_devname;
self.vn_fileid.hash(state);
self.vn_size.hash(state);
self.vn_dev.hash(state);
self.vn_fsid.hash(state);
self.vn_mntdir.hash(state);
self.vn_type.hash(state);
self.vn_mode.hash(state);
self_vn_devname.hash(state);
}
}
}
}
pub const RAND_MAX: c_int = 0x7fff_ffff;
pub const ELAST: c_int = 97;
pub const KF_TYPE_EVENTFD: c_int = 13;
/// max length of devicename
pub const SPECNAMELEN: c_int = 255;
pub const KI_NSPARE_PTR: usize = 5;
/// domainset policies
pub const DOMAINSET_POLICY_INVALID: c_int = 0;
pub const DOMAINSET_POLICY_ROUNDROBIN: c_int = 1;
pub const DOMAINSET_POLICY_FIRSTTOUCH: c_int = 2;
pub const DOMAINSET_POLICY_PREFER: c_int = 3;
pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4;
pub const MINCORE_SUPER: c_int = 0x60;
safe_f! {
pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
let major = major as crate::dev_t;
let minor = minor as crate::dev_t;
let mut dev = 0;
dev |= ((major & 0xffffff00) as dev_t) << 32;
dev |= ((major & 0x000000ff) as dev_t) << 8;
dev |= ((minor & 0x0000ff00) as dev_t) << 24;
dev |= ((minor & 0xffff00ff) as dev_t) << 0;
dev
}
pub const fn major(dev: crate::dev_t) -> c_int {
(((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int
}
pub const fn minor(dev: crate::dev_t) -> c_int {
(((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int
}
}
extern "C" {
pub fn setgrent();
pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
pub fn freelocale(loc: crate::locale_t);
pub fn msgrcv(
msqid: c_int,
msgp: *mut c_void,
msgsz: size_t,
msgtyp: c_long,
msgflg: c_int,
) -> ssize_t;
pub fn cpuset_getdomain(
level: crate::cpulevel_t,
which: crate::cpuwhich_t,
id: crate::id_t,
setsize: size_t,
mask: *mut crate::domainset_t,
policy: *mut c_int,
) -> c_int;
pub fn cpuset_setdomain(
level: crate::cpulevel_t,
which: crate::cpuwhich_t,
id: crate::id_t,
setsize: size_t,
mask: *const crate::domainset_t,
policy: c_int,
) -> c_int;
pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;
pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
arg: *mut c_void,
);
}
#[link(name = "kvm")]
extern "C" {
pub fn kvm_kerndisp(kd: *mut crate::kvm_t) -> crate::kssize_t;
}
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
}
}

View File

@@ -0,0 +1,14 @@
use crate::prelude::*;
pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN;
pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1;
pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2;
pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1;
pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000;
pub const PROC_LA_CTL: c_int = crate::PROC_PROCCTL_MD_MIN + 2;
pub const PROC_LA_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 3;
pub const PROC_LA_CTL_LA48_ON_EXEC: c_int = 1;
pub const PROC_LA_CTL_LA57_ON_EXEC: c_int = 2;
pub const PROC_LA_CTL_DEFAULT_ON_EXEC: c_int = 3;
pub const PROC_LA_STATUS_LA48: c_int = 0x01000000;
pub const PROC_LA_STATUS_LA57: c_int = 0x02000000;

View File

@@ -0,0 +1,534 @@
use crate::off_t;
use crate::prelude::*;
// APIs in FreeBSD 15 that have changed since 11.
pub type nlink_t = u64;
pub type dev_t = u64;
pub type ino_t = u64;
pub type shmatt_t = c_uint;
pub type kpaddr_t = u64;
pub type kssize_t = i64;
pub type domainset_t = __c_anonymous_domainset;
s! {
pub struct shmid_ds {
pub shm_perm: crate::ipc_perm,
pub shm_segsz: size_t,
pub shm_lpid: crate::pid_t,
pub shm_cpid: crate::pid_t,
pub shm_nattch: crate::shmatt_t,
pub shm_atime: crate::time_t,
pub shm_dtime: crate::time_t,
pub shm_ctime: crate::time_t,
}
pub struct kevent {
pub ident: crate::uintptr_t,
pub filter: c_short,
pub flags: c_ushort,
pub fflags: c_uint,
pub data: i64,
pub udata: *mut c_void,
pub ext: [u64; 4],
}
pub struct kvm_page {
pub kp_version: crate::u_int,
pub kp_paddr: crate::kpaddr_t,
pub kp_kmap_vaddr: crate::kvaddr_t,
pub kp_dmap_vaddr: crate::kvaddr_t,
pub kp_prot: crate::vm_prot_t,
pub kp_offset: off_t,
pub kp_len: size_t,
}
pub struct __c_anonymous_domainset {
#[cfg(target_pointer_width = "64")]
_priv: [c_ulong; 4],
#[cfg(target_pointer_width = "32")]
_priv: [c_ulong; 8],
}
#[non_exhaustive]
pub struct kinfo_proc {
/// Size of this structure.
pub ki_structsize: c_int,
/// Reserved: layout identifier.
pub ki_layout: c_int,
/// Address of command arguments.
pub ki_args: *mut crate::pargs,
// This is normally "struct proc".
/// Address of proc.
pub ki_paddr: *mut c_void,
// This is normally "struct user".
/// Kernel virtual address of u-area.
pub ki_addr: *mut c_void,
// This is normally "struct vnode".
/// Pointer to trace file.
pub ki_tracep: *mut c_void,
// This is normally "struct vnode".
/// Pointer to executable file.
pub ki_textvp: *mut c_void,
/// Pointer to open file info.
pub ki_fd: *mut crate::filedesc,
// This is normally "struct vmspace".
/// Pointer to kernel vmspace struct.
pub ki_vmspace: *mut c_void,
/// Sleep address.
pub ki_wchan: *const c_void,
/// Process identifier.
pub ki_pid: crate::pid_t,
/// Parent process ID.
pub ki_ppid: crate::pid_t,
/// Process group ID.
pub ki_pgid: crate::pid_t,
/// tty process group ID.
pub ki_tpgid: crate::pid_t,
/// Process session ID.
pub ki_sid: crate::pid_t,
/// Terminal session ID.
pub ki_tsid: crate::pid_t,
/// Job control counter.
pub ki_jobc: c_short,
/// Unused (just here for alignment).
pub ki_spare_short1: c_short,
/// Controlling tty dev.
pub ki_tdev_freebsd11: u32,
/// Signals arrived but not delivered.
pub ki_siglist: crate::sigset_t,
/// Current signal mask.
pub ki_sigmask: crate::sigset_t,
/// Signals being ignored.
pub ki_sigignore: crate::sigset_t,
/// Signals being caught by user.
pub ki_sigcatch: crate::sigset_t,
/// Effective user ID.
pub ki_uid: crate::uid_t,
/// Real user ID.
pub ki_ruid: crate::uid_t,
/// Saved effective user ID.
pub ki_svuid: crate::uid_t,
/// Real group ID.
pub ki_rgid: crate::gid_t,
/// Saved effective group ID.
pub ki_svgid: crate::gid_t,
/// Number of groups.
pub ki_ngroups: c_short,
/// Unused (just here for alignment).
pub ki_spare_short2: c_short,
/// Groups.
pub ki_groups: [crate::gid_t; crate::KI_NGROUPS],
/// Virtual size.
pub ki_size: crate::vm_size_t,
/// Current resident set size in pages.
pub ki_rssize: crate::segsz_t,
/// Resident set size before last swap.
pub ki_swrss: crate::segsz_t,
/// Text size (pages) XXX.
pub ki_tsize: crate::segsz_t,
/// Data size (pages) XXX.
pub ki_dsize: crate::segsz_t,
/// Stack size (pages).
pub ki_ssize: crate::segsz_t,
/// Exit status for wait & stop signal.
pub ki_xstat: crate::u_short,
/// Accounting flags.
pub ki_acflag: crate::u_short,
/// %cpu for process during `ki_swtime`.
pub ki_pctcpu: crate::fixpt_t,
/// Time averaged value of `ki_cpticks`.
pub ki_estcpu: crate::u_int,
/// Time since last blocked.
pub ki_slptime: crate::u_int,
/// Time swapped in or out.
pub ki_swtime: crate::u_int,
/// Number of copy-on-write faults.
pub ki_cow: crate::u_int,
/// Real time in microsec.
pub ki_runtime: u64,
/// Starting time.
pub ki_start: crate::timeval,
/// Time used by process children.
pub ki_childtime: crate::timeval,
/// P_* flags.
pub ki_flag: c_long,
/// KI_* flags (below).
pub ki_kiflag: c_long,
/// Kernel trace points.
pub ki_traceflag: c_int,
/// S* process status.
pub ki_stat: c_char,
/// Process "nice" value.
pub ki_nice: i8, // signed char
/// Process lock (prevent swap) count.
pub ki_lock: c_char,
/// Run queue index.
pub ki_rqindex: c_char,
/// Which cpu we are on.
pub ki_oncpu_old: c_uchar,
/// Last cpu we were on.
pub ki_lastcpu_old: c_uchar,
/// Thread name.
pub ki_tdname: [c_char; crate::TDNAMLEN + 1],
/// Wchan message.
pub ki_wmesg: [c_char; crate::WMESGLEN + 1],
/// Setlogin name.
pub ki_login: [c_char; crate::LOGNAMELEN + 1],
/// Lock name.
pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1],
/// Command name.
pub ki_comm: [c_char; crate::COMMLEN + 1],
/// Emulation name.
pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1],
/// Login class.
pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1],
/// More thread name.
pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1],
/// Spare string space.
pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq
/// Spare room for growth.
pub ki_spareints: [c_int; crate::KI_NSPARE_INT],
/// Controlling tty dev.
pub ki_tdev: u64,
/// Which cpu we are on.
pub ki_oncpu: c_int,
/// Last cpu we were on.
pub ki_lastcpu: c_int,
/// PID of tracing process.
pub ki_tracer: c_int,
/// P2_* flags.
pub ki_flag2: c_int,
/// Default FIB number.
pub ki_fibnum: c_int,
/// Credential flags.
pub ki_cr_flags: crate::u_int,
/// Process jail ID.
pub ki_jid: c_int,
/// Number of threads in total.
pub ki_numthreads: c_int,
/// Thread ID.
pub ki_tid: crate::lwpid_t,
/// Process priority.
pub ki_pri: crate::priority,
/// Process rusage statistics.
pub ki_rusage: crate::rusage,
/// rusage of children processes.
pub ki_rusage_ch: crate::rusage,
// This is normally "struct pcb".
/// Kernel virtual addr of pcb.
pub ki_pcb: *mut c_void,
/// Kernel virtual addr of stack.
pub ki_kstack: *mut c_void,
/// User convenience pointer.
pub ki_udata: *mut c_void,
// This is normally "struct thread".
pub ki_tdaddr: *mut c_void,
// This is normally "struct pwddesc".
/// Pointer to process paths info.
pub ki_pd: *mut c_void,
/// Address of the ext err msg place
pub ki_uerrmsg: *mut c_void,
pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR],
pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG],
/// PS_* flags.
pub ki_sflag: c_long,
/// kthread flag.
pub ki_tdflags: c_long,
}
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: crate::nlink_t,
pub st_mode: crate::mode_t,
st_padding0: i16,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
st_padding1: i32,
pub st_rdev: crate::dev_t,
#[cfg(target_arch = "x86")]
st_atim_ext: i32,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_mtim_ext: i32,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_ctim_ext: i32,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
#[cfg(target_arch = "x86")]
st_btim_ext: i32,
pub st_birthtime: crate::time_t,
pub st_birthtime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: crate::blkcnt_t,
pub st_blksize: crate::blksize_t,
pub st_flags: crate::fflags_t,
pub st_gen: u64,
pub st_filerev: u64,
pub st_spare: [u64; 9],
}
}
s_no_extra_traits! {
pub struct dirent {
pub d_fileno: crate::ino_t,
pub d_off: off_t,
pub d_reclen: u16,
pub d_type: u8,
d_pad0: u8,
pub d_namlen: u16,
d_pad1: u16,
pub d_name: [c_char; 256],
}
pub struct statfs {
pub f_version: u32,
pub f_type: u32,
pub f_flags: u64,
pub f_bsize: u64,
pub f_iosize: u64,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: i64,
pub f_files: u64,
pub f_ffree: i64,
pub f_syncwrites: u64,
pub f_asyncwrites: u64,
pub f_syncreads: u64,
pub f_asyncreads: u64,
f_spare: [u64; 10],
pub f_namemax: u32,
pub f_owner: crate::uid_t,
pub f_fsid: crate::fsid_t,
f_charspare: [c_char; 80],
pub f_fstypename: [c_char; 16],
pub f_mntfromname: [c_char; 1024],
pub f_mntonname: [c_char; 1024],
}
pub struct vnstat {
pub vn_fileid: u64,
pub vn_size: u64,
pub vn_dev: u64,
pub vn_fsid: u64,
pub vn_mntdir: *mut c_char,
pub vn_type: c_int,
pub vn_mode: u16,
pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for statfs {
fn eq(&self, other: &statfs) -> bool {
self.f_version == other.f_version
&& self.f_type == other.f_type
&& self.f_flags == other.f_flags
&& self.f_bsize == other.f_bsize
&& self.f_iosize == other.f_iosize
&& self.f_blocks == other.f_blocks
&& self.f_bfree == other.f_bfree
&& self.f_bavail == other.f_bavail
&& self.f_files == other.f_files
&& self.f_ffree == other.f_ffree
&& self.f_syncwrites == other.f_syncwrites
&& self.f_asyncwrites == other.f_asyncwrites
&& self.f_syncreads == other.f_syncreads
&& self.f_asyncreads == other.f_asyncreads
&& self.f_namemax == other.f_namemax
&& self.f_owner == other.f_owner
&& self.f_fsid == other.f_fsid
&& self.f_fstypename == other.f_fstypename
&& self
.f_mntfromname
.iter()
.zip(other.f_mntfromname.iter())
.all(|(a, b)| a == b)
&& self
.f_mntonname
.iter()
.zip(other.f_mntonname.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for statfs {}
impl hash::Hash for statfs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.f_version.hash(state);
self.f_type.hash(state);
self.f_flags.hash(state);
self.f_bsize.hash(state);
self.f_iosize.hash(state);
self.f_blocks.hash(state);
self.f_bfree.hash(state);
self.f_bavail.hash(state);
self.f_files.hash(state);
self.f_ffree.hash(state);
self.f_syncwrites.hash(state);
self.f_asyncwrites.hash(state);
self.f_syncreads.hash(state);
self.f_asyncreads.hash(state);
self.f_namemax.hash(state);
self.f_owner.hash(state);
self.f_fsid.hash(state);
self.f_charspare.hash(state);
self.f_fstypename.hash(state);
self.f_mntfromname.hash(state);
self.f_mntonname.hash(state);
}
}
impl PartialEq for dirent {
fn eq(&self, other: &dirent) -> bool {
self.d_fileno == other.d_fileno
&& self.d_off == other.d_off
&& self.d_reclen == other.d_reclen
&& self.d_type == other.d_type
&& self.d_namlen == other.d_namlen
&& self.d_name[..self.d_namlen as _]
.iter()
.zip(other.d_name.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for dirent {}
impl hash::Hash for dirent {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.d_fileno.hash(state);
self.d_off.hash(state);
self.d_reclen.hash(state);
self.d_type.hash(state);
self.d_namlen.hash(state);
self.d_name[..self.d_namlen as _].hash(state);
}
}
impl PartialEq for vnstat {
fn eq(&self, other: &vnstat) -> bool {
let self_vn_devname: &[c_char] = &self.vn_devname;
let other_vn_devname: &[c_char] = &other.vn_devname;
self.vn_fileid == other.vn_fileid
&& self.vn_size == other.vn_size
&& self.vn_dev == other.vn_dev
&& self.vn_fsid == other.vn_fsid
&& self.vn_mntdir == other.vn_mntdir
&& self.vn_type == other.vn_type
&& self.vn_mode == other.vn_mode
&& self_vn_devname == other_vn_devname
}
}
impl Eq for vnstat {}
impl hash::Hash for vnstat {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
let self_vn_devname: &[c_char] = &self.vn_devname;
self.vn_fileid.hash(state);
self.vn_size.hash(state);
self.vn_dev.hash(state);
self.vn_fsid.hash(state);
self.vn_mntdir.hash(state);
self.vn_type.hash(state);
self.vn_mode.hash(state);
self_vn_devname.hash(state);
}
}
}
}
pub const RAND_MAX: c_int = 0x7fff_ffff;
pub const ELAST: c_int = 97;
pub const KF_TYPE_EVENTFD: c_int = 13;
/// max length of devicename
pub const SPECNAMELEN: c_int = 255;
pub const KI_NSPARE_PTR: usize = 4;
/// domainset policies
pub const DOMAINSET_POLICY_INVALID: c_int = 0;
pub const DOMAINSET_POLICY_ROUNDROBIN: c_int = 1;
pub const DOMAINSET_POLICY_FIRSTTOUCH: c_int = 2;
pub const DOMAINSET_POLICY_PREFER: c_int = 3;
pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4;
pub const MINCORE_SUPER: c_int = 0x60;
safe_f! {
pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
let major = major as crate::dev_t;
let minor = minor as crate::dev_t;
let mut dev = 0;
dev |= ((major & 0xffffff00) as dev_t) << 32;
dev |= ((major & 0x000000ff) as dev_t) << 8;
dev |= ((minor & 0x0000ff00) as dev_t) << 24;
dev |= ((minor & 0xffff00ff) as dev_t) << 0;
dev
}
pub const fn major(dev: crate::dev_t) -> c_int {
(((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int
}
pub const fn minor(dev: crate::dev_t) -> c_int {
(((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int
}
}
extern "C" {
pub fn setgrent();
pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
pub fn freelocale(loc: crate::locale_t);
pub fn msgrcv(
msqid: c_int,
msgp: *mut c_void,
msgsz: size_t,
msgtyp: c_long,
msgflg: c_int,
) -> ssize_t;
pub fn cpuset_getdomain(
level: crate::cpulevel_t,
which: crate::cpuwhich_t,
id: crate::id_t,
setsize: size_t,
mask: *mut crate::domainset_t,
policy: *mut c_int,
) -> c_int;
pub fn cpuset_setdomain(
level: crate::cpulevel_t,
which: crate::cpuwhich_t,
id: crate::id_t,
setsize: size_t,
mask: *const crate::domainset_t,
policy: c_int,
) -> c_int;
pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;
pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
arg: *mut c_void,
);
}
#[link(name = "kvm")]
extern "C" {
pub fn kvm_kerndisp(kd: *mut crate::kvm_t) -> crate::kssize_t;
}
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
}
}

View File

@@ -0,0 +1,14 @@
use crate::prelude::*;
pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN;
pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1;
pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2;
pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1;
pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000;
pub const PROC_LA_CTL: c_int = crate::PROC_PROCCTL_MD_MIN + 2;
pub const PROC_LA_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 3;
pub const PROC_LA_CTL_LA48_ON_EXEC: c_int = 1;
pub const PROC_LA_CTL_LA57_ON_EXEC: c_int = 2;
pub const PROC_LA_CTL_DEFAULT_ON_EXEC: c_int = 3;
pub const PROC_LA_STATUS_LA48: c_int = 0x01000000;
pub const PROC_LA_STATUS_LA57: c_int = 0x02000000;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
use crate::prelude::*;
pub type clock_t = u32;
pub type wchar_t = i32;
pub type time_t = i64;
pub type suseconds_t = i32;
pub type register_t = i32;
s_no_extra_traits! {
#[repr(align(16))]
pub struct mcontext_t {
pub mc_vers: c_int,
pub mc_flags: c_int,
pub mc_onstack: c_int,
pub mc_len: c_int,
pub mc_avec: [u64; 64],
pub mc_av: [u32; 2],
pub mc_frame: [crate::register_t; 42],
pub mc_fpreg: [u64; 33],
pub mc_vsxfpreg: [u64; 32],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.mc_vers == other.mc_vers
&& self.mc_flags == other.mc_flags
&& self.mc_onstack == other.mc_onstack
&& self.mc_len == other.mc_len
&& self.mc_avec == other.mc_avec
&& self.mc_av == other.mc_av
&& self.mc_frame == other.mc_frame
&& self.mc_fpreg == other.mc_fpreg
&& self.mc_vsxfpreg == other.mc_vsxfpreg
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.mc_vers.hash(state);
self.mc_flags.hash(state);
self.mc_onstack.hash(state);
self.mc_len.hash(state);
self.mc_avec.hash(state);
self.mc_av.hash(state);
self.mc_frame.hash(state);
self.mc_fpreg.hash(state);
self.mc_vsxfpreg.hash(state);
}
}
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1;
pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e;
pub const MAP_32BIT: c_int = 0x00080000;
pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4
pub const TIOCTIMESTAMP: c_ulong = 0x40107459;

View File

@@ -0,0 +1,63 @@
use crate::prelude::*;
pub type clock_t = u32;
pub type wchar_t = i32;
pub type time_t = i64;
pub type suseconds_t = i64;
pub type register_t = i64;
s_no_extra_traits! {
#[repr(align(16))]
pub struct mcontext_t {
pub mc_vers: c_int,
pub mc_flags: c_int,
pub mc_onstack: c_int,
pub mc_len: c_int,
pub mc_avec: [u64; 64],
pub mc_av: [u32; 2],
pub mc_frame: [crate::register_t; 42],
pub mc_fpreg: [u64; 33],
pub mc_vsxfpreg: [u64; 32],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.mc_vers == other.mc_vers
&& self.mc_flags == other.mc_flags
&& self.mc_onstack == other.mc_onstack
&& self.mc_len == other.mc_len
&& self.mc_avec == other.mc_avec
&& self.mc_av == other.mc_av
&& self.mc_frame == other.mc_frame
&& self.mc_fpreg == other.mc_fpreg
&& self.mc_vsxfpreg == other.mc_vsxfpreg
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.mc_vers.hash(state);
self.mc_flags.hash(state);
self.mc_onstack.hash(state);
self.mc_len.hash(state);
self.mc_avec.hash(state);
self.mc_av.hash(state);
self.mc_frame.hash(state);
self.mc_fpreg.hash(state);
self.mc_vsxfpreg.hash(state);
}
}
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e;
pub const MAP_32BIT: c_int = 0x00080000;
pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4
pub const TIOCTIMESTAMP: c_ulong = 0x40107459;

View File

@@ -0,0 +1,116 @@
use crate::prelude::*;
pub type clock_t = i32;
pub type wchar_t = c_int;
pub type time_t = i64;
pub type suseconds_t = c_long;
pub type register_t = i64;
s_no_extra_traits! {
pub struct gpregs {
pub gp_ra: crate::register_t,
pub gp_sp: crate::register_t,
pub gp_gp: crate::register_t,
pub gp_tp: crate::register_t,
pub gp_t: [crate::register_t; 7],
pub gp_s: [crate::register_t; 12],
pub gp_a: [crate::register_t; 8],
pub gp_sepc: crate::register_t,
pub gp_sstatus: crate::register_t,
}
pub struct fpregs {
pub fp_x: [[u64; 2]; 32],
pub fp_fcsr: u64,
pub fp_flags: c_int,
pub pad: c_int,
}
pub struct mcontext_t {
pub mc_gpregs: gpregs,
pub mc_fpregs: fpregs,
pub mc_flags: c_int,
pub mc_pad: c_int,
pub mc_spare: [u64; 8],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for gpregs {
fn eq(&self, other: &gpregs) -> bool {
self.gp_ra == other.gp_ra
&& self.gp_sp == other.gp_sp
&& self.gp_gp == other.gp_gp
&& self.gp_tp == other.gp_tp
&& self.gp_t.iter().zip(other.gp_t.iter()).all(|(a, b)| a == b)
&& self.gp_s.iter().zip(other.gp_s.iter()).all(|(a, b)| a == b)
&& self.gp_a.iter().zip(other.gp_a.iter()).all(|(a, b)| a == b)
&& self.gp_sepc == other.gp_sepc
&& self.gp_sstatus == other.gp_sstatus
}
}
impl Eq for gpregs {}
impl hash::Hash for gpregs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.gp_ra.hash(state);
self.gp_sp.hash(state);
self.gp_gp.hash(state);
self.gp_tp.hash(state);
self.gp_t.hash(state);
self.gp_s.hash(state);
self.gp_a.hash(state);
self.gp_sepc.hash(state);
self.gp_sstatus.hash(state);
}
}
impl PartialEq for fpregs {
fn eq(&self, other: &fpregs) -> bool {
self.fp_x == other.fp_x
&& self.fp_fcsr == other.fp_fcsr
&& self.fp_flags == other.fp_flags
&& self.pad == other.pad
}
}
impl Eq for fpregs {}
impl hash::Hash for fpregs {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.fp_x.hash(state);
self.fp_fcsr.hash(state);
self.fp_flags.hash(state);
self.pad.hash(state);
}
}
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.mc_gpregs == other.mc_gpregs
&& self.mc_fpregs == other.mc_fpregs
&& self.mc_flags == other.mc_flags
&& self.mc_pad == other.mc_pad
&& self
.mc_spare
.iter()
.zip(other.mc_spare.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.mc_gpregs.hash(state);
self.mc_fpregs.hash(state);
self.mc_flags.hash(state);
self.mc_pad.hash(state);
self.mc_spare.hash(state);
}
}
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_longlong>() - 1;
pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e;
pub const MAP_32BIT: c_int = 0x00080000;
pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4
pub const TIOCTIMESTAMP: c_ulong = 0x40107459;

View File

@@ -0,0 +1,134 @@
use crate::prelude::*;
pub type clock_t = c_ulong;
pub type wchar_t = i32;
pub type time_t = i32;
pub type suseconds_t = i32;
pub type register_t = i32;
s_no_extra_traits! {
#[repr(align(16))]
pub struct mcontext_t {
pub mc_onstack: register_t,
pub mc_gs: register_t,
pub mc_fs: register_t,
pub mc_es: register_t,
pub mc_ds: register_t,
pub mc_edi: register_t,
pub mc_esi: register_t,
pub mc_ebp: register_t,
pub mc_isp: register_t,
pub mc_ebx: register_t,
pub mc_edx: register_t,
pub mc_ecx: register_t,
pub mc_eax: register_t,
pub mc_trapno: register_t,
pub mc_err: register_t,
pub mc_eip: register_t,
pub mc_cs: register_t,
pub mc_eflags: register_t,
pub mc_esp: register_t,
pub mc_ss: register_t,
pub mc_len: c_int,
pub mc_fpformat: c_int,
pub mc_ownedfp: c_int,
pub mc_flags: register_t,
pub mc_fpstate: [c_int; 128],
pub mc_fsbase: register_t,
pub mc_gsbase: register_t,
pub mc_xfpustate: register_t,
pub mc_xfpustate_len: register_t,
pub mc_spare2: [c_int; 4],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.mc_onstack == other.mc_onstack
&& self.mc_gs == other.mc_gs
&& self.mc_fs == other.mc_fs
&& self.mc_es == other.mc_es
&& self.mc_ds == other.mc_ds
&& self.mc_edi == other.mc_edi
&& self.mc_esi == other.mc_esi
&& self.mc_ebp == other.mc_ebp
&& self.mc_isp == other.mc_isp
&& self.mc_ebx == other.mc_ebx
&& self.mc_edx == other.mc_edx
&& self.mc_ecx == other.mc_ecx
&& self.mc_eax == other.mc_eax
&& self.mc_trapno == other.mc_trapno
&& self.mc_err == other.mc_err
&& self.mc_eip == other.mc_eip
&& self.mc_cs == other.mc_cs
&& self.mc_eflags == other.mc_eflags
&& self.mc_esp == other.mc_esp
&& self.mc_ss == other.mc_ss
&& self.mc_len == other.mc_len
&& self.mc_fpformat == other.mc_fpformat
&& self.mc_ownedfp == other.mc_ownedfp
&& self.mc_flags == other.mc_flags
&& self
.mc_fpstate
.iter()
.zip(other.mc_fpstate.iter())
.all(|(a, b)| a == b)
&& self.mc_fsbase == other.mc_fsbase
&& self.mc_gsbase == other.mc_gsbase
&& self.mc_xfpustate == other.mc_xfpustate
&& self.mc_xfpustate_len == other.mc_xfpustate_len
&& self
.mc_spare2
.iter()
.zip(other.mc_spare2.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.mc_onstack.hash(state);
self.mc_gs.hash(state);
self.mc_fs.hash(state);
self.mc_es.hash(state);
self.mc_ds.hash(state);
self.mc_edi.hash(state);
self.mc_esi.hash(state);
self.mc_ebp.hash(state);
self.mc_isp.hash(state);
self.mc_ebx.hash(state);
self.mc_edx.hash(state);
self.mc_ecx.hash(state);
self.mc_eax.hash(state);
self.mc_trapno.hash(state);
self.mc_err.hash(state);
self.mc_eip.hash(state);
self.mc_cs.hash(state);
self.mc_eflags.hash(state);
self.mc_esp.hash(state);
self.mc_ss.hash(state);
self.mc_len.hash(state);
self.mc_fpformat.hash(state);
self.mc_ownedfp.hash(state);
self.mc_flags.hash(state);
self.mc_fpstate.hash(state);
self.mc_fsbase.hash(state);
self.mc_gsbase.hash(state);
self.mc_xfpustate.hash(state);
self.mc_xfpustate_len.hash(state);
self.mc_spare2.hash(state);
}
}
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4
pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e;
pub const KINFO_FILE_SIZE: c_int = 1392;
pub const TIOCTIMESTAMP: c_ulong = 0x40087459;

View File

@@ -0,0 +1,346 @@
use crate::prelude::*;
pub type clock_t = i32;
pub type wchar_t = i32;
pub type time_t = i64;
pub type suseconds_t = i64;
pub type register_t = i64;
s! {
pub struct reg32 {
pub r_fs: u32,
pub r_es: u32,
pub r_ds: u32,
pub r_edi: u32,
pub r_esi: u32,
pub r_ebp: u32,
pub r_isp: u32,
pub r_ebx: u32,
pub r_edx: u32,
pub r_ecx: u32,
pub r_eax: u32,
pub r_trapno: u32,
pub r_err: u32,
pub r_eip: u32,
pub r_cs: u32,
pub r_eflags: u32,
pub r_esp: u32,
pub r_ss: u32,
pub r_gs: u32,
}
pub struct reg {
pub r_r15: i64,
pub r_r14: i64,
pub r_r13: i64,
pub r_r12: i64,
pub r_r11: i64,
pub r_r10: i64,
pub r_r9: i64,
pub r_r8: i64,
pub r_rdi: i64,
pub r_rsi: i64,
pub r_rbp: i64,
pub r_rbx: i64,
pub r_rdx: i64,
pub r_rcx: i64,
pub r_rax: i64,
pub r_trapno: u32,
pub r_fs: u16,
pub r_gs: u16,
pub r_err: u32,
pub r_es: u16,
pub r_ds: u16,
pub r_rip: i64,
pub r_cs: i64,
pub r_rflags: i64,
pub r_rsp: i64,
pub r_ss: i64,
}
}
s_no_extra_traits! {
pub struct fpreg32 {
pub fpr_env: [u32; 7],
pub fpr_acc: [[u8; 10]; 8],
pub fpr_ex_sw: u32,
pub fpr_pad: [u8; 64],
}
pub struct fpreg {
pub fpr_env: [u64; 4],
pub fpr_acc: [[u8; 16]; 8],
pub fpr_xacc: [[u8; 16]; 16],
pub fpr_spare: [u64; 12],
}
pub struct xmmreg {
pub xmm_env: [u32; 8],
pub xmm_acc: [[u8; 16]; 8],
pub xmm_reg: [[u8; 16]; 8],
pub xmm_pad: [u8; 224],
}
pub union __c_anonymous_elf64_auxv_union {
pub a_val: c_long,
pub a_ptr: *mut c_void,
pub a_fcn: extern "C" fn(),
}
pub struct Elf64_Auxinfo {
pub a_type: c_long,
pub a_un: __c_anonymous_elf64_auxv_union,
}
#[repr(align(16))]
pub struct max_align_t {
priv_: [f64; 4],
}
#[repr(align(16))]
#[cfg_attr(not(any(freebsd11, freebsd12, freebsd13, freebsd14)), non_exhaustive)]
pub struct mcontext_t {
pub mc_onstack: register_t,
pub mc_rdi: register_t,
pub mc_rsi: register_t,
pub mc_rdx: register_t,
pub mc_rcx: register_t,
pub mc_r8: register_t,
pub mc_r9: register_t,
pub mc_rax: register_t,
pub mc_rbx: register_t,
pub mc_rbp: register_t,
pub mc_r10: register_t,
pub mc_r11: register_t,
pub mc_r12: register_t,
pub mc_r13: register_t,
pub mc_r14: register_t,
pub mc_r15: register_t,
pub mc_trapno: u32,
pub mc_fs: u16,
pub mc_gs: u16,
pub mc_addr: register_t,
pub mc_flags: u32,
pub mc_es: u16,
pub mc_ds: u16,
pub mc_err: register_t,
pub mc_rip: register_t,
pub mc_cs: register_t,
pub mc_rflags: register_t,
pub mc_rsp: register_t,
pub mc_ss: register_t,
pub mc_len: c_long,
pub mc_fpformat: c_long,
pub mc_ownedfp: c_long,
pub mc_fpstate: [c_long; 64],
pub mc_fsbase: register_t,
pub mc_gsbase: register_t,
pub mc_xfpustate: register_t,
pub mc_xfpustate_len: register_t,
// freebsd < 15
#[cfg(any(freebsd11, freebsd12, freebsd13, freebsd14))]
pub mc_spare: [c_long; 4],
// freebsd >= 15
#[cfg(not(any(freebsd11, freebsd12, freebsd13, freebsd14)))]
pub mc_tlsbase: register_t,
#[cfg(not(any(freebsd11, freebsd12, freebsd13, freebsd14)))]
pub mc_spare: [c_long; 3],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for fpreg32 {
fn eq(&self, other: &fpreg32) -> bool {
self.fpr_env == other.fpr_env
&& self.fpr_acc == other.fpr_acc
&& self.fpr_ex_sw == other.fpr_ex_sw
&& self
.fpr_pad
.iter()
.zip(other.fpr_pad.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for fpreg32 {}
impl hash::Hash for fpreg32 {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.fpr_env.hash(state);
self.fpr_acc.hash(state);
self.fpr_ex_sw.hash(state);
self.fpr_pad.hash(state);
}
}
impl PartialEq for fpreg {
fn eq(&self, other: &fpreg) -> bool {
self.fpr_env == other.fpr_env
&& self.fpr_acc == other.fpr_acc
&& self.fpr_xacc == other.fpr_xacc
&& self.fpr_spare == other.fpr_spare
}
}
impl Eq for fpreg {}
impl hash::Hash for fpreg {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.fpr_env.hash(state);
self.fpr_acc.hash(state);
self.fpr_xacc.hash(state);
self.fpr_spare.hash(state);
}
}
impl PartialEq for xmmreg {
fn eq(&self, other: &xmmreg) -> bool {
self.xmm_env == other.xmm_env
&& self.xmm_acc == other.xmm_acc
&& self.xmm_reg == other.xmm_reg
&& self
.xmm_pad
.iter()
.zip(other.xmm_pad.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for xmmreg {}
impl hash::Hash for xmmreg {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.xmm_env.hash(state);
self.xmm_acc.hash(state);
self.xmm_reg.hash(state);
self.xmm_pad.hash(state);
}
}
// FIXME(msrv): suggested method was added in 1.85
#[allow(unpredictable_function_pointer_comparisons)]
impl PartialEq for __c_anonymous_elf64_auxv_union {
fn eq(&self, other: &__c_anonymous_elf64_auxv_union) -> bool {
unsafe {
self.a_val == other.a_val
|| self.a_ptr == other.a_ptr
|| self.a_fcn == other.a_fcn
}
}
}
impl Eq for __c_anonymous_elf64_auxv_union {}
impl PartialEq for Elf64_Auxinfo {
fn eq(&self, other: &Elf64_Auxinfo) -> bool {
self.a_type == other.a_type && self.a_un == other.a_un
}
}
impl Eq for Elf64_Auxinfo {}
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.mc_onstack == other.mc_onstack
&& self.mc_rdi == other.mc_rdi
&& self.mc_rsi == other.mc_rsi
&& self.mc_rdx == other.mc_rdx
&& self.mc_rcx == other.mc_rcx
&& self.mc_r8 == other.mc_r8
&& self.mc_r9 == other.mc_r9
&& self.mc_rax == other.mc_rax
&& self.mc_rbx == other.mc_rbx
&& self.mc_rbp == other.mc_rbp
&& self.mc_r10 == other.mc_r10
&& self.mc_r11 == other.mc_r11
&& self.mc_r12 == other.mc_r12
&& self.mc_r13 == other.mc_r13
&& self.mc_r14 == other.mc_r14
&& self.mc_r15 == other.mc_r15
&& self.mc_trapno == other.mc_trapno
&& self.mc_fs == other.mc_fs
&& self.mc_gs == other.mc_gs
&& self.mc_addr == other.mc_addr
&& self.mc_flags == other.mc_flags
&& self.mc_es == other.mc_es
&& self.mc_ds == other.mc_ds
&& self.mc_err == other.mc_err
&& self.mc_rip == other.mc_rip
&& self.mc_cs == other.mc_cs
&& self.mc_rflags == other.mc_rflags
&& self.mc_rsp == other.mc_rsp
&& self.mc_ss == other.mc_ss
&& self.mc_len == other.mc_len
&& self.mc_fpformat == other.mc_fpformat
&& self.mc_ownedfp == other.mc_ownedfp
&& self
.mc_fpstate
.iter()
.zip(other.mc_fpstate.iter())
.all(|(a, b)| a == b)
&& self.mc_fsbase == other.mc_fsbase
&& self.mc_gsbase == other.mc_gsbase
&& self.mc_xfpustate == other.mc_xfpustate
&& self.mc_xfpustate_len == other.mc_xfpustate_len
&& self.mc_spare == other.mc_spare
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.mc_onstack.hash(state);
self.mc_rdi.hash(state);
self.mc_rsi.hash(state);
self.mc_rdx.hash(state);
self.mc_rcx.hash(state);
self.mc_r8.hash(state);
self.mc_r9.hash(state);
self.mc_rax.hash(state);
self.mc_rbx.hash(state);
self.mc_rbp.hash(state);
self.mc_r10.hash(state);
self.mc_r11.hash(state);
self.mc_r12.hash(state);
self.mc_r13.hash(state);
self.mc_r14.hash(state);
self.mc_r15.hash(state);
self.mc_trapno.hash(state);
self.mc_fs.hash(state);
self.mc_gs.hash(state);
self.mc_addr.hash(state);
self.mc_flags.hash(state);
self.mc_es.hash(state);
self.mc_ds.hash(state);
self.mc_err.hash(state);
self.mc_rip.hash(state);
self.mc_cs.hash(state);
self.mc_rflags.hash(state);
self.mc_rsp.hash(state);
self.mc_ss.hash(state);
self.mc_len.hash(state);
self.mc_fpformat.hash(state);
self.mc_ownedfp.hash(state);
self.mc_fpstate.hash(state);
self.mc_fsbase.hash(state);
self.mc_gsbase.hash(state);
self.mc_xfpustate.hash(state);
self.mc_xfpustate_len.hash(state);
self.mc_spare.hash(state);
}
}
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e;
pub const MAP_32BIT: c_int = 0x00080000;
pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4
pub const _MC_HASSEGS: u32 = 0x1;
pub const _MC_HASBASES: u32 = 0x2;
pub const _MC_HASFPXSTATE: u32 = 0x4;
pub const _MC_FPFMT_NODEV: c_long = 0x10000;
pub const _MC_FPFMT_XMM: c_long = 0x10002;
pub const _MC_FPOWNED_NONE: c_long = 0x20000;
pub const _MC_FPOWNED_FPU: c_long = 0x20001;
pub const _MC_FPOWNED_PCB: c_long = 0x20002;
pub const KINFO_FILE_SIZE: c_int = 1392;
pub const TIOCTIMESTAMP: c_ulong = 0x40107459;

File diff suppressed because it is too large Load Diff

969
vendor/libc/src/unix/bsd/mod.rs vendored Normal file
View File

@@ -0,0 +1,969 @@
use crate::prelude::*;
pub type off_t = i64;
pub type useconds_t = u32;
pub type blkcnt_t = i64;
pub type socklen_t = u32;
pub type sa_family_t = u8;
pub type pthread_t = crate::uintptr_t;
pub type nfds_t = c_uint;
pub type regoff_t = off_t;
s! {
pub struct sockaddr {
pub sa_len: u8,
pub sa_family: sa_family_t,
pub sa_data: [c_char; 14],
}
pub struct sockaddr_in6 {
pub sin6_len: u8,
pub sin6_family: sa_family_t,
pub sin6_port: crate::in_port_t,
pub sin6_flowinfo: u32,
pub sin6_addr: crate::in6_addr,
pub sin6_scope_id: u32,
}
pub struct passwd {
pub pw_name: *mut c_char,
pub pw_passwd: *mut c_char,
pub pw_uid: crate::uid_t,
pub pw_gid: crate::gid_t,
pub pw_change: crate::time_t,
pub pw_class: *mut c_char,
pub pw_gecos: *mut c_char,
pub pw_dir: *mut c_char,
pub pw_shell: *mut c_char,
pub pw_expire: crate::time_t,
#[cfg(not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos",
target_os = "netbsd",
target_os = "openbsd"
)))]
pub pw_fields: c_int,
}
pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut c_char,
pub ifa_flags: c_uint,
pub ifa_addr: *mut crate::sockaddr,
pub ifa_netmask: *mut crate::sockaddr,
pub ifa_dstaddr: *mut crate::sockaddr,
pub ifa_data: *mut c_void,
#[cfg(target_os = "netbsd")]
pub ifa_addrflags: c_uint,
}
pub struct fd_set {
#[cfg(all(
target_pointer_width = "64",
any(target_os = "freebsd", target_os = "dragonfly")
))]
fds_bits: [i64; FD_SETSIZE as usize / 64],
#[cfg(not(all(
target_pointer_width = "64",
any(target_os = "freebsd", target_os = "dragonfly")
)))]
fds_bits: [i32; FD_SETSIZE as usize / 32],
}
pub struct tm {
pub tm_sec: c_int,
pub tm_min: c_int,
pub tm_hour: c_int,
pub tm_mday: c_int,
pub tm_mon: c_int,
pub tm_year: c_int,
pub tm_wday: c_int,
pub tm_yday: c_int,
pub tm_isdst: c_int,
pub tm_gmtoff: c_long,
pub tm_zone: *mut c_char,
}
pub struct msghdr {
pub msg_name: *mut c_void,
pub msg_namelen: crate::socklen_t,
pub msg_iov: *mut crate::iovec,
pub msg_iovlen: c_int,
pub msg_control: *mut c_void,
pub msg_controllen: crate::socklen_t,
pub msg_flags: c_int,
}
pub struct cmsghdr {
pub cmsg_len: crate::socklen_t,
pub cmsg_level: c_int,
pub cmsg_type: c_int,
}
pub struct fsid_t {
__fsid_val: [i32; 2],
}
pub struct if_nameindex {
pub if_index: c_uint,
pub if_name: *mut c_char,
}
pub struct regex_t {
__re_magic: c_int,
__re_nsub: size_t,
__re_endp: *const c_char,
__re_g: *mut c_void,
}
pub struct regmatch_t {
pub rm_so: regoff_t,
pub rm_eo: regoff_t,
}
pub struct option {
pub name: *const c_char,
pub has_arg: c_int,
pub flag: *mut c_int,
pub val: c_int,
}
}
s_no_extra_traits! {
pub struct sockaddr_un {
pub sun_len: u8,
pub sun_family: sa_family_t,
pub sun_path: [c_char; 104],
}
pub struct utsname {
#[cfg(not(target_os = "dragonfly"))]
pub sysname: [c_char; 256],
#[cfg(target_os = "dragonfly")]
pub sysname: [c_char; 32],
#[cfg(not(target_os = "dragonfly"))]
pub nodename: [c_char; 256],
#[cfg(target_os = "dragonfly")]
pub nodename: [c_char; 32],
#[cfg(not(target_os = "dragonfly"))]
pub release: [c_char; 256],
#[cfg(target_os = "dragonfly")]
pub release: [c_char; 32],
#[cfg(not(target_os = "dragonfly"))]
pub version: [c_char; 256],
#[cfg(target_os = "dragonfly")]
pub version: [c_char; 32],
#[cfg(not(target_os = "dragonfly"))]
pub machine: [c_char; 256],
#[cfg(target_os = "dragonfly")]
pub machine: [c_char; 32],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for sockaddr_un {
fn eq(&self, other: &sockaddr_un) -> bool {
self.sun_len == other.sun_len
&& self.sun_family == other.sun_family
&& self
.sun_path
.iter()
.zip(other.sun_path.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for sockaddr_un {}
impl hash::Hash for sockaddr_un {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.sun_len.hash(state);
self.sun_family.hash(state);
self.sun_path.hash(state);
}
}
impl PartialEq for utsname {
fn eq(&self, other: &utsname) -> bool {
self.sysname
.iter()
.zip(other.sysname.iter())
.all(|(a, b)| a == b)
&& self
.nodename
.iter()
.zip(other.nodename.iter())
.all(|(a, b)| a == b)
&& self
.release
.iter()
.zip(other.release.iter())
.all(|(a, b)| a == b)
&& self
.version
.iter()
.zip(other.version.iter())
.all(|(a, b)| a == b)
&& self
.machine
.iter()
.zip(other.machine.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for utsname {}
impl hash::Hash for utsname {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.sysname.hash(state);
self.nodename.hash(state);
self.release.hash(state);
self.version.hash(state);
self.machine.hash(state);
}
}
}
}
pub const LC_ALL: c_int = 0;
pub const LC_COLLATE: c_int = 1;
pub const LC_CTYPE: c_int = 2;
pub const LC_MONETARY: c_int = 3;
pub const LC_NUMERIC: c_int = 4;
pub const LC_TIME: c_int = 5;
pub const LC_MESSAGES: c_int = 6;
pub const FIOCLEX: c_ulong = 0x20006601;
pub const FIONCLEX: c_ulong = 0x20006602;
pub const FIONREAD: c_ulong = 0x4004667f;
pub const FIONBIO: c_ulong = 0x8004667e;
pub const FIOASYNC: c_ulong = 0x8004667d;
pub const FIOSETOWN: c_ulong = 0x8004667c;
pub const FIOGETOWN: c_ulong = 0x4004667b;
pub const PATH_MAX: c_int = 1024;
pub const MAXPATHLEN: c_int = PATH_MAX;
pub const IOV_MAX: c_int = 1024;
pub const SA_ONSTACK: c_int = 0x0001;
pub const SA_SIGINFO: c_int = 0x0040;
pub const SA_RESTART: c_int = 0x0002;
pub const SA_RESETHAND: c_int = 0x0004;
pub const SA_NOCLDSTOP: c_int = 0x0008;
pub const SA_NODEFER: c_int = 0x0010;
pub const SA_NOCLDWAIT: c_int = 0x0020;
pub const SS_ONSTACK: c_int = 1;
pub const SS_DISABLE: c_int = 4;
pub const SIGCHLD: c_int = 20;
pub const SIGBUS: c_int = 10;
pub const SIGUSR1: c_int = 30;
pub const SIGUSR2: c_int = 31;
pub const SIGCONT: c_int = 19;
pub const SIGSTOP: c_int = 17;
pub const SIGTSTP: c_int = 18;
pub const SIGURG: c_int = 16;
pub const SIGIO: c_int = 23;
pub const SIGSYS: c_int = 12;
pub const SIGTTIN: c_int = 21;
pub const SIGTTOU: c_int = 22;
pub const SIGXCPU: c_int = 24;
pub const SIGXFSZ: c_int = 25;
pub const SIGVTALRM: c_int = 26;
pub const SIGPROF: c_int = 27;
pub const SIGWINCH: c_int = 28;
pub const SIGINFO: c_int = 29;
pub const SIG_SETMASK: c_int = 3;
pub const SIG_BLOCK: c_int = 0x1;
pub const SIG_UNBLOCK: c_int = 0x2;
pub const IP_TOS: c_int = 3;
pub const IP_MULTICAST_IF: c_int = 9;
pub const IP_MULTICAST_TTL: c_int = 10;
pub const IP_MULTICAST_LOOP: c_int = 11;
pub const IPV6_UNICAST_HOPS: c_int = 4;
pub const IPV6_MULTICAST_IF: c_int = 9;
pub const IPV6_MULTICAST_HOPS: c_int = 10;
pub const IPV6_MULTICAST_LOOP: c_int = 11;
pub const IPV6_V6ONLY: c_int = 27;
pub const IPV6_DONTFRAG: c_int = 62;
pub const IPTOS_ECN_NOTECT: u8 = 0x00;
pub const IPTOS_ECN_MASK: u8 = 0x03;
pub const IPTOS_ECN_ECT1: u8 = 0x01;
pub const IPTOS_ECN_ECT0: u8 = 0x02;
pub const IPTOS_ECN_CE: u8 = 0x03;
pub const ST_RDONLY: c_ulong = 1;
pub const SCM_RIGHTS: c_int = 0x01;
pub const NCCS: usize = 20;
pub const O_ACCMODE: c_int = 0x3;
pub const O_RDONLY: c_int = 0;
pub const O_WRONLY: c_int = 1;
pub const O_RDWR: c_int = 2;
pub const O_APPEND: c_int = 8;
pub const O_CREAT: c_int = 512;
pub const O_TRUNC: c_int = 1024;
pub const O_EXCL: c_int = 2048;
pub const O_ASYNC: c_int = 0x40;
pub const O_SYNC: c_int = 0x80;
pub const O_NONBLOCK: c_int = 0x4;
pub const O_NOFOLLOW: c_int = 0x100;
pub const O_SHLOCK: c_int = 0x10;
pub const O_EXLOCK: c_int = 0x20;
pub const O_FSYNC: c_int = O_SYNC;
pub const O_NDELAY: c_int = O_NONBLOCK;
pub const F_GETOWN: c_int = 5;
pub const F_SETOWN: c_int = 6;
pub const F_RDLCK: c_short = 1;
pub const F_UNLCK: c_short = 2;
pub const F_WRLCK: c_short = 3;
pub const MNT_RDONLY: c_int = 0x00000001;
pub const MNT_SYNCHRONOUS: c_int = 0x00000002;
pub const MNT_NOEXEC: c_int = 0x00000004;
pub const MNT_NOSUID: c_int = 0x00000008;
pub const MNT_ASYNC: c_int = 0x00000040;
pub const MNT_EXPORTED: c_int = 0x00000100;
pub const MNT_UPDATE: c_int = 0x00010000;
pub const MNT_RELOAD: c_int = 0x00040000;
pub const MNT_FORCE: c_int = 0x00080000;
pub const Q_SYNC: c_int = 0x600;
pub const Q_QUOTAON: c_int = 0x100;
pub const Q_QUOTAOFF: c_int = 0x200;
pub const TCIOFF: c_int = 3;
pub const TCION: c_int = 4;
pub const TCOOFF: c_int = 1;
pub const TCOON: c_int = 2;
pub const TCIFLUSH: c_int = 1;
pub const TCOFLUSH: c_int = 2;
pub const TCIOFLUSH: c_int = 3;
pub const TCSANOW: c_int = 0;
pub const TCSADRAIN: c_int = 1;
pub const TCSAFLUSH: c_int = 2;
pub const VEOF: usize = 0;
pub const VEOL: usize = 1;
pub const VEOL2: usize = 2;
pub const VERASE: usize = 3;
pub const VWERASE: usize = 4;
pub const VKILL: usize = 5;
pub const VREPRINT: usize = 6;
pub const VINTR: usize = 8;
pub const VQUIT: usize = 9;
pub const VSUSP: usize = 10;
pub const VDSUSP: usize = 11;
pub const VSTART: usize = 12;
pub const VSTOP: usize = 13;
pub const VLNEXT: usize = 14;
pub const VDISCARD: usize = 15;
pub const VMIN: usize = 16;
pub const VTIME: usize = 17;
pub const VSTATUS: usize = 18;
pub const _POSIX_VDISABLE: crate::cc_t = 0xff;
pub const IGNBRK: crate::tcflag_t = 0x00000001;
pub const BRKINT: crate::tcflag_t = 0x00000002;
pub const IGNPAR: crate::tcflag_t = 0x00000004;
pub const PARMRK: crate::tcflag_t = 0x00000008;
pub const INPCK: crate::tcflag_t = 0x00000010;
pub const ISTRIP: crate::tcflag_t = 0x00000020;
pub const INLCR: crate::tcflag_t = 0x00000040;
pub const IGNCR: crate::tcflag_t = 0x00000080;
pub const ICRNL: crate::tcflag_t = 0x00000100;
pub const IXON: crate::tcflag_t = 0x00000200;
pub const IXOFF: crate::tcflag_t = 0x00000400;
pub const IXANY: crate::tcflag_t = 0x00000800;
pub const IMAXBEL: crate::tcflag_t = 0x00002000;
pub const OPOST: crate::tcflag_t = 0x1;
pub const ONLCR: crate::tcflag_t = 0x2;
pub const OXTABS: crate::tcflag_t = 0x4;
pub const ONOEOT: crate::tcflag_t = 0x8;
pub const CIGNORE: crate::tcflag_t = 0x00000001;
pub const CSIZE: crate::tcflag_t = 0x00000300;
pub const CS5: crate::tcflag_t = 0x00000000;
pub const CS6: crate::tcflag_t = 0x00000100;
pub const CS7: crate::tcflag_t = 0x00000200;
pub const CS8: crate::tcflag_t = 0x00000300;
pub const CSTOPB: crate::tcflag_t = 0x00000400;
pub const CREAD: crate::tcflag_t = 0x00000800;
pub const PARENB: crate::tcflag_t = 0x00001000;
pub const PARODD: crate::tcflag_t = 0x00002000;
pub const HUPCL: crate::tcflag_t = 0x00004000;
pub const CLOCAL: crate::tcflag_t = 0x00008000;
pub const ECHOKE: crate::tcflag_t = 0x00000001;
pub const ECHOE: crate::tcflag_t = 0x00000002;
pub const ECHOK: crate::tcflag_t = 0x00000004;
pub const ECHO: crate::tcflag_t = 0x00000008;
pub const ECHONL: crate::tcflag_t = 0x00000010;
pub const ECHOPRT: crate::tcflag_t = 0x00000020;
pub const ECHOCTL: crate::tcflag_t = 0x00000040;
pub const ISIG: crate::tcflag_t = 0x00000080;
pub const ICANON: crate::tcflag_t = 0x00000100;
pub const ALTWERASE: crate::tcflag_t = 0x00000200;
pub const IEXTEN: crate::tcflag_t = 0x00000400;
pub const EXTPROC: crate::tcflag_t = 0x00000800;
pub const TOSTOP: crate::tcflag_t = 0x00400000;
pub const FLUSHO: crate::tcflag_t = 0x00800000;
pub const NOKERNINFO: crate::tcflag_t = 0x02000000;
pub const PENDIN: crate::tcflag_t = 0x20000000;
pub const NOFLSH: crate::tcflag_t = 0x80000000;
pub const MDMBUF: crate::tcflag_t = 0x00100000;
pub const WNOHANG: c_int = 0x00000001;
pub const WUNTRACED: c_int = 0x00000002;
pub const RTLD_LAZY: c_int = 0x1;
pub const RTLD_NOW: c_int = 0x2;
pub const RTLD_NEXT: *mut c_void = -1isize as *mut c_void;
pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void;
pub const RTLD_SELF: *mut c_void = -3isize as *mut c_void;
pub const LOG_CRON: c_int = 9 << 3;
pub const LOG_AUTHPRIV: c_int = 10 << 3;
pub const LOG_FTP: c_int = 11 << 3;
pub const LOG_PERROR: c_int = 0x20;
pub const TCP_NODELAY: c_int = 1;
pub const TCP_MAXSEG: c_int = 2;
pub const PIPE_BUF: usize = 512;
// si_code values for SIGBUS signal
pub const BUS_ADRALN: c_int = 1;
pub const BUS_ADRERR: c_int = 2;
pub const BUS_OBJERR: c_int = 3;
// si_code values for SIGCHLD signal
pub const CLD_EXITED: c_int = 1;
pub const CLD_KILLED: c_int = 2;
pub const CLD_DUMPED: c_int = 3;
pub const CLD_TRAPPED: c_int = 4;
pub const CLD_STOPPED: c_int = 5;
pub const CLD_CONTINUED: c_int = 6;
pub const POLLIN: c_short = 0x1;
pub const POLLPRI: c_short = 0x2;
pub const POLLOUT: c_short = 0x4;
pub const POLLERR: c_short = 0x8;
pub const POLLHUP: c_short = 0x10;
pub const POLLNVAL: c_short = 0x20;
pub const POLLRDNORM: c_short = 0x040;
pub const POLLWRNORM: c_short = 0x004;
pub const POLLRDBAND: c_short = 0x080;
pub const POLLWRBAND: c_short = 0x100;
pub const BIOCGBLEN: c_ulong = 0x40044266;
pub const BIOCSBLEN: c_ulong = 0xc0044266;
pub const BIOCFLUSH: c_uint = 0x20004268;
pub const BIOCPROMISC: c_uint = 0x20004269;
pub const BIOCGDLT: c_ulong = 0x4004426a;
pub const BIOCGETIF: c_ulong = 0x4020426b;
pub const BIOCSETIF: c_ulong = 0x8020426c;
pub const BIOCGSTATS: c_ulong = 0x4008426f;
pub const BIOCIMMEDIATE: c_ulong = 0x80044270;
pub const BIOCVERSION: c_ulong = 0x40044271;
pub const BIOCGHDRCMPLT: c_ulong = 0x40044274;
pub const BIOCSHDRCMPLT: c_ulong = 0x80044275;
pub const SIOCGIFADDR: c_ulong = 0xc0206921;
pub const REG_BASIC: c_int = 0o0000;
pub const REG_EXTENDED: c_int = 0o0001;
pub const REG_ICASE: c_int = 0o0002;
pub const REG_NOSUB: c_int = 0o0004;
pub const REG_NEWLINE: c_int = 0o0010;
pub const REG_NOSPEC: c_int = 0o0020;
pub const REG_PEND: c_int = 0o0040;
pub const REG_DUMP: c_int = 0o0200;
pub const REG_NOMATCH: c_int = 1;
pub const REG_BADPAT: c_int = 2;
pub const REG_ECOLLATE: c_int = 3;
pub const REG_ECTYPE: c_int = 4;
pub const REG_EESCAPE: c_int = 5;
pub const REG_ESUBREG: c_int = 6;
pub const REG_EBRACK: c_int = 7;
pub const REG_EPAREN: c_int = 8;
pub const REG_EBRACE: c_int = 9;
pub const REG_BADBR: c_int = 10;
pub const REG_ERANGE: c_int = 11;
pub const REG_ESPACE: c_int = 12;
pub const REG_BADRPT: c_int = 13;
pub const REG_EMPTY: c_int = 14;
pub const REG_ASSERT: c_int = 15;
pub const REG_INVARG: c_int = 16;
pub const REG_ATOI: c_int = 255;
pub const REG_ITOA: c_int = 0o0400;
pub const REG_NOTBOL: c_int = 0o00001;
pub const REG_NOTEOL: c_int = 0o00002;
pub const REG_STARTEND: c_int = 0o00004;
pub const REG_TRACE: c_int = 0o00400;
pub const REG_LARGE: c_int = 0o01000;
pub const REG_BACKR: c_int = 0o02000;
pub const TIOCCBRK: c_uint = 0x2000747a;
pub const TIOCSBRK: c_uint = 0x2000747b;
pub const PRIO_PROCESS: c_int = 0;
pub const PRIO_PGRP: c_int = 1;
pub const PRIO_USER: c_int = 2;
pub const ITIMER_REAL: c_int = 0;
pub const ITIMER_VIRTUAL: c_int = 1;
pub const ITIMER_PROF: c_int = 2;
// net/route.h
pub const RTF_UP: c_int = 0x1;
pub const RTF_GATEWAY: c_int = 0x2;
pub const RTF_HOST: c_int = 0x4;
pub const RTF_REJECT: c_int = 0x8;
pub const RTF_DYNAMIC: c_int = 0x10;
pub const RTF_MODIFIED: c_int = 0x20;
pub const RTF_DONE: c_int = 0x40;
pub const RTF_STATIC: c_int = 0x800;
pub const RTF_BLACKHOLE: c_int = 0x1000;
pub const RTF_PROTO2: c_int = 0x4000;
pub const RTF_PROTO1: c_int = 0x8000;
// Message types
pub const RTM_ADD: c_int = 0x1;
pub const RTM_DELETE: c_int = 0x2;
pub const RTM_CHANGE: c_int = 0x3;
pub const RTM_GET: c_int = 0x4;
pub const RTM_LOSING: c_int = 0x5;
pub const RTM_REDIRECT: c_int = 0x6;
pub const RTM_MISS: c_int = 0x7;
// Bitmask values for rtm_addrs.
pub const RTA_DST: c_int = 0x1;
pub const RTA_GATEWAY: c_int = 0x2;
pub const RTA_NETMASK: c_int = 0x4;
pub const RTA_GENMASK: c_int = 0x8;
pub const RTA_IFP: c_int = 0x10;
pub const RTA_IFA: c_int = 0x20;
pub const RTA_AUTHOR: c_int = 0x40;
pub const RTA_BRD: c_int = 0x80;
// Index offsets for sockaddr array for alternate internal encoding.
pub const RTAX_DST: c_int = 0;
pub const RTAX_GATEWAY: c_int = 1;
pub const RTAX_NETMASK: c_int = 2;
pub const RTAX_GENMASK: c_int = 3;
pub const RTAX_IFP: c_int = 4;
pub const RTAX_IFA: c_int = 5;
pub const RTAX_AUTHOR: c_int = 6;
pub const RTAX_BRD: c_int = 7;
f! {
pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr {
if (*mhdr).msg_controllen as usize >= size_of::<cmsghdr>() {
(*mhdr).msg_control.cast::<cmsghdr>()
} else {
core::ptr::null_mut()
}
}
pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () {
let bits = size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
(*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
return;
}
pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool {
let bits = size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0;
}
pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () {
let bits = size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
(*set).fds_bits[fd / bits] |= 1 << (fd % bits);
return;
}
pub fn FD_ZERO(set: *mut fd_set) -> () {
for slot in &mut (*set).fds_bits {
*slot = 0;
}
}
}
safe_f! {
pub const fn WTERMSIG(status: c_int) -> c_int {
status & 0o177
}
pub const fn WIFEXITED(status: c_int) -> bool {
(status & 0o177) == 0
}
pub const fn WEXITSTATUS(status: c_int) -> c_int {
(status >> 8) & 0x00ff
}
pub const fn WCOREDUMP(status: c_int) -> bool {
(status & 0o200) != 0
}
pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int {
(cmd << 8) | (type_ & 0x00ff)
}
}
extern "C" {
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "getrlimit$UNIX2003"
)]
pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "setrlimit$UNIX2003"
)]
pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int;
pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
pub fn abs(i: c_int) -> c_int;
pub fn labs(i: c_long) -> c_long;
#[cfg_attr(
all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
link_name = "rand@FBSD_1.0"
)]
pub fn rand() -> c_int;
#[cfg_attr(
all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
link_name = "srand@FBSD_1.0"
)]
pub fn srand(seed: c_uint);
pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int;
pub fn freeifaddrs(ifa: *mut crate::ifaddrs);
pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int;
pub fn setlogin(name: *const c_char) -> c_int;
pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int;
pub fn kqueue() -> c_int;
pub fn unmount(target: *const c_char, arg: c_int) -> c_int;
pub fn syscall(num: c_int, ...) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")]
pub fn getpwent() -> *mut passwd;
pub fn setpwent();
pub fn endpwent();
pub fn endgrent();
pub fn getgrent() -> *mut crate::group;
pub fn getprogname() -> *const c_char;
pub fn setprogname(name: *const c_char);
pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int;
pub fn if_nameindex() -> *mut if_nameindex;
pub fn if_freenameindex(ptr: *mut if_nameindex);
pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int;
#[cfg_attr(
all(target_os = "macos", not(target_arch = "aarch64")),
link_name = "glob$INODE64"
)]
#[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
#[cfg_attr(
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "glob@FBSD_1.0"
)]
pub fn glob(
pattern: *const c_char,
flags: c_int,
errfunc: Option<extern "C" fn(epath: *const c_char, errno: c_int) -> c_int>,
pglob: *mut crate::glob_t,
) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
#[cfg_attr(
all(target_os = "freebsd", any(freebsd11, freebsd10)),
link_name = "globfree@FBSD_1.0"
)]
pub fn globfree(pglob: *mut crate::glob_t);
pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
pub fn shm_unlink(name: *const c_char) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86_64"),
link_name = "seekdir$INODE64"
)]
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "seekdir$INODE64$UNIX2003"
)]
pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
#[cfg_attr(
all(target_os = "macos", target_arch = "x86_64"),
link_name = "telldir$INODE64"
)]
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "telldir$INODE64$UNIX2003"
)]
pub fn telldir(dirp: *mut crate::DIR) -> c_long;
pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "msync$UNIX2003"
)]
#[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "recvfrom$UNIX2003"
)]
pub fn recvfrom(
socket: c_int,
buf: *mut c_void,
len: size_t,
flags: c_int,
addr: *mut crate::sockaddr,
addrlen: *mut crate::socklen_t,
) -> ssize_t;
pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__futimes50")]
pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int;
pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "bind$UNIX2003"
)]
pub fn bind(
socket: c_int,
address: *const crate::sockaddr,
address_len: crate::socklen_t,
) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "writev$UNIX2003"
)]
pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "readv$UNIX2003"
)]
pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "sendmsg$UNIX2003"
)]
pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "recvmsg$UNIX2003"
)]
pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t;
pub fn sync();
pub fn getgrgid_r(
gid: crate::gid_t,
grp: *mut crate::group,
buf: *mut c_char,
buflen: size_t,
result: *mut *mut crate::group,
) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "sigaltstack$UNIX2003"
)]
#[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int;
pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int;
pub fn sem_close(sem: *mut sem_t) -> c_int;
pub fn getdtablesize() -> c_int;
pub fn getgrnam_r(
name: *const c_char,
grp: *mut crate::group,
buf: *mut c_char,
buflen: size_t,
result: *mut *mut crate::group,
) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "pthread_sigmask$UNIX2003"
)]
pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int;
pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t;
pub fn getgrnam(name: *const c_char) -> *mut crate::group;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "pthread_cancel$UNIX2003"
)]
pub fn pthread_cancel(thread: crate::pthread_t) -> c_int;
pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int;
pub fn sched_get_priority_min(policy: c_int) -> c_int;
pub fn sched_get_priority_max(policy: c_int) -> c_int;
pub fn sem_unlink(name: *const c_char) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
pub fn getpwnam_r(
name: *const c_char,
pwd: *mut passwd,
buf: *mut c_char,
buflen: size_t,
result: *mut *mut passwd,
) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
pub fn getpwuid_r(
uid: crate::uid_t,
pwd: *mut passwd,
buf: *mut c_char,
buflen: size_t,
result: *mut *mut passwd,
) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "sigwait$UNIX2003"
)]
pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int;
pub fn pthread_atfork(
prepare: Option<unsafe extern "C" fn()>,
parent: Option<unsafe extern "C" fn()>,
child: Option<unsafe extern "C" fn()>,
) -> c_int;
pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "popen$UNIX2003"
)]
pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE;
pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int;
pub fn pthread_create(
native: *mut crate::pthread_t,
attr: *const crate::pthread_attr_t,
f: extern "C" fn(*mut c_void) -> *mut c_void,
value: *mut c_void,
) -> c_int;
pub fn acct(filename: *const c_char) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "wait4$UNIX2003"
)]
#[cfg_attr(
all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
link_name = "wait4@FBSD_1.0"
)]
pub fn wait4(
pid: crate::pid_t,
status: *mut c_int,
options: c_int,
rusage: *mut crate::rusage,
) -> crate::pid_t;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "getitimer$UNIX2003"
)]
pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int;
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
link_name = "setitimer$UNIX2003"
)]
pub fn setitimer(
which: c_int,
new_value: *const crate::itimerval,
old_value: *mut crate::itimerval,
) -> c_int;
pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int;
pub fn regexec(
preg: *const regex_t,
input: *const c_char,
nmatch: size_t,
pmatch: *mut regmatch_t,
eflags: c_int,
) -> c_int;
pub fn regerror(
errcode: c_int,
preg: *const regex_t,
errbuf: *mut c_char,
errbuf_size: size_t,
) -> size_t;
pub fn regfree(preg: *mut regex_t);
pub fn arc4random() -> u32;
pub fn arc4random_buf(buf: *mut c_void, size: size_t);
pub fn arc4random_uniform(l: u32) -> u32;
pub fn drand48() -> c_double;
pub fn erand48(xseed: *mut c_ushort) -> c_double;
pub fn lrand48() -> c_long;
pub fn nrand48(xseed: *mut c_ushort) -> c_long;
pub fn mrand48() -> c_long;
pub fn jrand48(xseed: *mut c_ushort) -> c_long;
pub fn srand48(seed: c_long);
pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort;
pub fn lcong48(p: *mut c_ushort);
pub fn getopt_long(
argc: c_int,
argv: *const *mut c_char,
optstring: *const c_char,
longopts: *const option,
longindex: *mut c_int,
) -> c_int;
pub fn strftime(
buf: *mut c_char,
maxsize: size_t,
format: *const c_char,
timeptr: *const crate::tm,
) -> size_t;
pub fn strftime_l(
buf: *mut c_char,
maxsize: size_t,
format: *const c_char,
timeptr: *const crate::tm,
locale: crate::locale_t,
) -> size_t;
pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char;
}
cfg_if! {
if #[cfg(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
))] {
mod apple;
pub use self::apple::*;
} else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] {
mod netbsdlike;
pub use self::netbsdlike::*;
} else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] {
mod freebsdlike;
pub use self::freebsdlike::*;
} else {
// Unknown target_os
}
}

View File

@@ -0,0 +1,905 @@
use crate::off_t;
use crate::prelude::*;
pub type wchar_t = i32;
pub type time_t = i64;
pub type mode_t = u32;
pub type nlink_t = u32;
pub type ino_t = u64;
pub type pthread_key_t = c_int;
pub type rlim_t = u64;
pub type speed_t = c_uint;
pub type tcflag_t = c_uint;
pub type nl_item = c_long;
pub type clockid_t = c_int;
pub type id_t = u32;
pub type sem_t = *mut sem;
pub type key_t = c_long;
#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
}
#[derive(Debug)]
pub enum sem {}
impl Copy for sem {}
impl Clone for sem {
fn clone(&self) -> sem {
*self
}
}
s! {
pub struct sched_param {
pub sched_priority: c_int,
}
pub struct sigaction {
pub sa_sigaction: crate::sighandler_t,
pub sa_mask: crate::sigset_t,
pub sa_flags: c_int,
}
pub struct stack_t {
pub ss_sp: *mut c_void,
pub ss_size: size_t,
pub ss_flags: c_int,
}
pub struct in6_pktinfo {
pub ipi6_addr: crate::in6_addr,
pub ipi6_ifindex: c_uint,
}
pub struct termios {
pub c_iflag: crate::tcflag_t,
pub c_oflag: crate::tcflag_t,
pub c_cflag: crate::tcflag_t,
pub c_lflag: crate::tcflag_t,
pub c_cc: [crate::cc_t; crate::NCCS],
pub c_ispeed: c_int,
pub c_ospeed: c_int,
}
pub struct flock {
pub l_start: off_t,
pub l_len: off_t,
pub l_pid: crate::pid_t,
pub l_type: c_short,
pub l_whence: c_short,
}
pub struct ipc_perm {
pub cuid: crate::uid_t,
pub cgid: crate::gid_t,
pub uid: crate::uid_t,
pub gid: crate::gid_t,
pub mode: mode_t,
#[cfg(target_os = "openbsd")]
pub seq: c_ushort,
#[cfg(target_os = "netbsd")]
pub _seq: c_ushort,
#[cfg(target_os = "openbsd")]
pub key: crate::key_t,
#[cfg(target_os = "netbsd")]
pub _key: crate::key_t,
}
pub struct ptrace_io_desc {
pub piod_op: c_int,
pub piod_offs: *mut c_void,
pub piod_addr: *mut c_void,
pub piod_len: size_t,
}
pub struct mmsghdr {
pub msg_hdr: crate::msghdr,
pub msg_len: c_uint,
}
}
pub const D_T_FMT: crate::nl_item = 0;
pub const D_FMT: crate::nl_item = 1;
pub const T_FMT: crate::nl_item = 2;
pub const T_FMT_AMPM: crate::nl_item = 3;
pub const AM_STR: crate::nl_item = 4;
pub const PM_STR: crate::nl_item = 5;
pub const DAY_1: crate::nl_item = 6;
pub const DAY_2: crate::nl_item = 7;
pub const DAY_3: crate::nl_item = 8;
pub const DAY_4: crate::nl_item = 9;
pub const DAY_5: crate::nl_item = 10;
pub const DAY_6: crate::nl_item = 11;
pub const DAY_7: crate::nl_item = 12;
pub const ABDAY_1: crate::nl_item = 13;
pub const ABDAY_2: crate::nl_item = 14;
pub const ABDAY_3: crate::nl_item = 15;
pub const ABDAY_4: crate::nl_item = 16;
pub const ABDAY_5: crate::nl_item = 17;
pub const ABDAY_6: crate::nl_item = 18;
pub const ABDAY_7: crate::nl_item = 19;
pub const MON_1: crate::nl_item = 20;
pub const MON_2: crate::nl_item = 21;
pub const MON_3: crate::nl_item = 22;
pub const MON_4: crate::nl_item = 23;
pub const MON_5: crate::nl_item = 24;
pub const MON_6: crate::nl_item = 25;
pub const MON_7: crate::nl_item = 26;
pub const MON_8: crate::nl_item = 27;
pub const MON_9: crate::nl_item = 28;
pub const MON_10: crate::nl_item = 29;
pub const MON_11: crate::nl_item = 30;
pub const MON_12: crate::nl_item = 31;
pub const ABMON_1: crate::nl_item = 32;
pub const ABMON_2: crate::nl_item = 33;
pub const ABMON_3: crate::nl_item = 34;
pub const ABMON_4: crate::nl_item = 35;
pub const ABMON_5: crate::nl_item = 36;
pub const ABMON_6: crate::nl_item = 37;
pub const ABMON_7: crate::nl_item = 38;
pub const ABMON_8: crate::nl_item = 39;
pub const ABMON_9: crate::nl_item = 40;
pub const ABMON_10: crate::nl_item = 41;
pub const ABMON_11: crate::nl_item = 42;
pub const ABMON_12: crate::nl_item = 43;
pub const RADIXCHAR: crate::nl_item = 44;
pub const THOUSEP: crate::nl_item = 45;
pub const YESSTR: crate::nl_item = 46;
pub const YESEXPR: crate::nl_item = 47;
pub const NOSTR: crate::nl_item = 48;
pub const NOEXPR: crate::nl_item = 49;
pub const CRNCYSTR: crate::nl_item = 50;
pub const CODESET: crate::nl_item = 51;
pub const EXIT_FAILURE: c_int = 1;
pub const EXIT_SUCCESS: c_int = 0;
pub const RAND_MAX: c_int = 2147483647;
pub const EOF: c_int = -1;
pub const SEEK_SET: c_int = 0;
pub const SEEK_CUR: c_int = 1;
pub const SEEK_END: c_int = 2;
pub const _IOFBF: c_int = 0;
pub const _IONBF: c_int = 2;
pub const _IOLBF: c_int = 1;
pub const BUFSIZ: c_uint = 1024;
pub const FOPEN_MAX: c_uint = 20;
pub const FILENAME_MAX: c_uint = 1024;
pub const L_tmpnam: c_uint = 1024;
pub const O_NOCTTY: c_int = 32768;
pub const S_IFIFO: mode_t = 0o1_0000;
pub const S_IFCHR: mode_t = 0o2_0000;
pub const S_IFBLK: mode_t = 0o6_0000;
pub const S_IFDIR: mode_t = 0o4_0000;
pub const S_IFREG: mode_t = 0o10_0000;
pub const S_IFLNK: mode_t = 0o12_0000;
pub const S_IFSOCK: mode_t = 0o14_0000;
pub const S_IFMT: mode_t = 0o17_0000;
pub const S_IEXEC: mode_t = 0o0100;
pub const S_IWRITE: mode_t = 0o0200;
pub const S_IREAD: mode_t = 0o0400;
pub const S_IRWXU: mode_t = 0o0700;
pub const S_IXUSR: mode_t = 0o0100;
pub const S_IWUSR: mode_t = 0o0200;
pub const S_IRUSR: mode_t = 0o0400;
pub const S_IRWXG: mode_t = 0o0070;
pub const S_IXGRP: mode_t = 0o0010;
pub const S_IWGRP: mode_t = 0o0020;
pub const S_IRGRP: mode_t = 0o0040;
pub const S_IRWXO: mode_t = 0o0007;
pub const S_IXOTH: mode_t = 0o0001;
pub const S_IWOTH: mode_t = 0o0002;
pub const S_IROTH: mode_t = 0o0004;
pub const F_OK: c_int = 0;
pub const R_OK: c_int = 4;
pub const W_OK: c_int = 2;
pub const X_OK: c_int = 1;
pub const STDIN_FILENO: c_int = 0;
pub const STDOUT_FILENO: c_int = 1;
pub const STDERR_FILENO: c_int = 2;
pub const F_LOCK: c_int = 1;
pub const F_TEST: c_int = 3;
pub const F_TLOCK: c_int = 2;
pub const F_ULOCK: c_int = 0;
pub const F_GETLK: c_int = 7;
pub const F_SETLK: c_int = 8;
pub const F_SETLKW: c_int = 9;
pub const SIGHUP: c_int = 1;
pub const SIGINT: c_int = 2;
pub const SIGQUIT: c_int = 3;
pub const SIGILL: c_int = 4;
pub const SIGABRT: c_int = 6;
pub const SIGEMT: c_int = 7;
pub const SIGFPE: c_int = 8;
pub const SIGKILL: c_int = 9;
pub const SIGSEGV: c_int = 11;
pub const SIGPIPE: c_int = 13;
pub const SIGALRM: c_int = 14;
pub const SIGTERM: c_int = 15;
pub const PROT_NONE: c_int = 0;
pub const PROT_READ: c_int = 1;
pub const PROT_WRITE: c_int = 2;
pub const PROT_EXEC: c_int = 4;
pub const MAP_FILE: c_int = 0x0000;
pub const MAP_SHARED: c_int = 0x0001;
pub const MAP_PRIVATE: c_int = 0x0002;
pub const MAP_FIXED: c_int = 0x0010;
pub const MAP_ANON: c_int = 0x1000;
pub const MAP_ANONYMOUS: c_int = MAP_ANON;
pub const MAP_FAILED: *mut c_void = !0 as *mut c_void;
pub const IPC_CREAT: c_int = 0o001000;
pub const IPC_EXCL: c_int = 0o002000;
pub const IPC_NOWAIT: c_int = 0o004000;
pub const IPC_PRIVATE: crate::key_t = 0;
pub const IPC_RMID: c_int = 0;
pub const IPC_SET: c_int = 1;
pub const IPC_STAT: c_int = 2;
pub const IPC_R: c_int = 0o000400;
pub const IPC_W: c_int = 0o000200;
pub const IPC_M: c_int = 0o010000;
pub const SHM_R: c_int = IPC_R;
pub const SHM_W: c_int = IPC_W;
pub const MCL_CURRENT: c_int = 0x0001;
pub const MCL_FUTURE: c_int = 0x0002;
pub const MS_ASYNC: c_int = 0x0001;
pub const EPERM: c_int = 1;
pub const ENOENT: c_int = 2;
pub const ESRCH: c_int = 3;
pub const EINTR: c_int = 4;
pub const EIO: c_int = 5;
pub const ENXIO: c_int = 6;
pub const E2BIG: c_int = 7;
pub const ENOEXEC: c_int = 8;
pub const EBADF: c_int = 9;
pub const ECHILD: c_int = 10;
pub const EDEADLK: c_int = 11;
pub const ENOMEM: c_int = 12;
pub const EACCES: c_int = 13;
pub const EFAULT: c_int = 14;
pub const ENOTBLK: c_int = 15;
pub const EBUSY: c_int = 16;
pub const EEXIST: c_int = 17;
pub const EXDEV: c_int = 18;
pub const ENODEV: c_int = 19;
pub const ENOTDIR: c_int = 20;
pub const EISDIR: c_int = 21;
pub const EINVAL: c_int = 22;
pub const ENFILE: c_int = 23;
pub const EMFILE: c_int = 24;
pub const ENOTTY: c_int = 25;
pub const ETXTBSY: c_int = 26;
pub const EFBIG: c_int = 27;
pub const ENOSPC: c_int = 28;
pub const ESPIPE: c_int = 29;
pub const EROFS: c_int = 30;
pub const EMLINK: c_int = 31;
pub const EPIPE: c_int = 32;
pub const EDOM: c_int = 33;
pub const ERANGE: c_int = 34;
pub const EAGAIN: c_int = 35;
pub const EWOULDBLOCK: c_int = 35;
pub const EINPROGRESS: c_int = 36;
pub const EALREADY: c_int = 37;
pub const ENOTSOCK: c_int = 38;
pub const EDESTADDRREQ: c_int = 39;
pub const EMSGSIZE: c_int = 40;
pub const EPROTOTYPE: c_int = 41;
pub const ENOPROTOOPT: c_int = 42;
pub const EPROTONOSUPPORT: c_int = 43;
pub const ESOCKTNOSUPPORT: c_int = 44;
pub const EOPNOTSUPP: c_int = 45;
pub const EPFNOSUPPORT: c_int = 46;
pub const EAFNOSUPPORT: c_int = 47;
pub const EADDRINUSE: c_int = 48;
pub const EADDRNOTAVAIL: c_int = 49;
pub const ENETDOWN: c_int = 50;
pub const ENETUNREACH: c_int = 51;
pub const ENETRESET: c_int = 52;
pub const ECONNABORTED: c_int = 53;
pub const ECONNRESET: c_int = 54;
pub const ENOBUFS: c_int = 55;
pub const EISCONN: c_int = 56;
pub const ENOTCONN: c_int = 57;
pub const ESHUTDOWN: c_int = 58;
pub const ETOOMANYREFS: c_int = 59;
pub const ETIMEDOUT: c_int = 60;
pub const ECONNREFUSED: c_int = 61;
pub const ELOOP: c_int = 62;
pub const ENAMETOOLONG: c_int = 63;
pub const EHOSTDOWN: c_int = 64;
pub const EHOSTUNREACH: c_int = 65;
pub const ENOTEMPTY: c_int = 66;
pub const EPROCLIM: c_int = 67;
pub const EUSERS: c_int = 68;
pub const EDQUOT: c_int = 69;
pub const ESTALE: c_int = 70;
pub const EREMOTE: c_int = 71;
pub const EBADRPC: c_int = 72;
pub const ERPCMISMATCH: c_int = 73;
pub const EPROGUNAVAIL: c_int = 74;
pub const EPROGMISMATCH: c_int = 75;
pub const EPROCUNAVAIL: c_int = 76;
pub const ENOLCK: c_int = 77;
pub const ENOSYS: c_int = 78;
pub const EFTYPE: c_int = 79;
pub const EAUTH: c_int = 80;
pub const ENEEDAUTH: c_int = 81;
pub const F_DUPFD: c_int = 0;
pub const F_GETFD: c_int = 1;
pub const F_SETFD: c_int = 2;
pub const F_GETFL: c_int = 3;
pub const F_SETFL: c_int = 4;
pub const SIGTRAP: c_int = 5;
pub const GLOB_APPEND: c_int = 0x0001;
pub const GLOB_DOOFFS: c_int = 0x0002;
pub const GLOB_ERR: c_int = 0x0004;
pub const GLOB_MARK: c_int = 0x0008;
pub const GLOB_NOCHECK: c_int = 0x0010;
pub const GLOB_NOSORT: c_int = 0x0020;
pub const GLOB_NOESCAPE: c_int = 0x1000;
pub const GLOB_NOSPACE: c_int = -1;
pub const GLOB_ABORTED: c_int = -2;
pub const GLOB_NOMATCH: c_int = -3;
pub const GLOB_NOSYS: c_int = -4;
pub const POSIX_MADV_NORMAL: c_int = 0;
pub const POSIX_MADV_RANDOM: c_int = 1;
pub const POSIX_MADV_SEQUENTIAL: c_int = 2;
pub const POSIX_MADV_WILLNEED: c_int = 3;
pub const POSIX_MADV_DONTNEED: c_int = 4;
// DIFF(main): changed to `c_short` in f62eb023ab
pub const POSIX_SPAWN_RESETIDS: c_int = 0x01;
pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02;
pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x04;
pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x08;
pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10;
pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20;
pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
pub const PTHREAD_CREATE_DETACHED: c_int = 1;
pub const PIOD_READ_D: c_int = 1;
pub const PIOD_WRITE_D: c_int = 2;
pub const PIOD_READ_I: c_int = 3;
pub const PIOD_WRITE_I: c_int = 4;
pub const PIOD_READ_AUXV: c_int = 5;
pub const PT_TRACE_ME: c_int = 0;
pub const PT_READ_I: c_int = 1;
pub const PT_READ_D: c_int = 2;
pub const PT_WRITE_I: c_int = 4;
pub const PT_WRITE_D: c_int = 5;
pub const PT_CONTINUE: c_int = 7;
pub const PT_KILL: c_int = 8;
pub const PT_ATTACH: c_int = 9;
pub const PT_DETACH: c_int = 10;
pub const PT_IO: c_int = 11;
// http://man.openbsd.org/OpenBSD-current/man2/clock_getres.2
// The man page says clock_gettime(3) can accept various values as clockid_t but
// http://fxr.watson.org/fxr/source/kern/kern_time.c?v=OPENBSD;im=excerpts#L161
// the implementation rejects anything other than the below two
//
// http://netbsd.gw.com/cgi-bin/man-cgi?clock_gettime
// https://github.com/jsonn/src/blob/HEAD/sys/kern/subr_time.c#L222
// Basically the same goes for NetBSD
pub const CLOCK_REALTIME: crate::clockid_t = 0;
pub const CLOCK_MONOTONIC: crate::clockid_t = 3;
pub const RLIMIT_CPU: c_int = 0;
pub const RLIMIT_FSIZE: c_int = 1;
pub const RLIMIT_DATA: c_int = 2;
pub const RLIMIT_STACK: c_int = 3;
pub const RLIMIT_CORE: c_int = 4;
pub const RLIMIT_RSS: c_int = 5;
pub const RLIMIT_MEMLOCK: c_int = 6;
pub const RLIMIT_NPROC: c_int = 7;
pub const RLIMIT_NOFILE: c_int = 8;
pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY;
pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY;
pub const RUSAGE_SELF: c_int = 0;
pub const RUSAGE_CHILDREN: c_int = -1;
pub const MADV_NORMAL: c_int = 0;
pub const MADV_RANDOM: c_int = 1;
pub const MADV_SEQUENTIAL: c_int = 2;
pub const MADV_WILLNEED: c_int = 3;
pub const MADV_DONTNEED: c_int = 4;
pub const MADV_FREE: c_int = 6;
// sys/fstypes.h in NetBSD, or sys/mount.h in OpenBSD
pub const MNT_NODEV: c_int = 0x00000010;
pub const MNT_LOCAL: c_int = 0x00001000;
pub const MNT_QUOTA: c_int = 0x00002000;
// sys/ioccom.h in NetBSD and OpenBSD
pub const IOCPARM_MASK: u32 = 0x1fff;
pub const IOC_VOID: c_ulong = 0x20000000;
pub const IOC_OUT: c_ulong = 0x40000000;
pub const IOC_IN: c_ulong = 0x80000000;
pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT;
pub const IOC_DIRMASK: c_ulong = 0xe0000000;
pub const fn _IO(g: c_ulong, n: c_ulong) -> c_ulong {
_IOC(IOC_VOID, g, n, 0)
}
/// Build an ioctl number for an read-only ioctl.
pub const fn _IOR<T>(g: c_ulong, n: c_ulong) -> c_ulong {
_IOC(IOC_OUT, g, n, mem::size_of::<T>() as c_ulong)
}
/// Build an ioctl number for an write-only ioctl.
pub const fn _IOW<T>(g: c_ulong, n: c_ulong) -> c_ulong {
_IOC(IOC_IN, g, n, mem::size_of::<T>() as c_ulong)
}
/// Build an ioctl number for a read-write ioctl.
pub const fn _IOWR<T>(g: c_ulong, n: c_ulong) -> c_ulong {
_IOC(IOC_INOUT, g, n, mem::size_of::<T>() as c_ulong)
}
pub const AF_UNSPEC: c_int = 0;
pub const AF_LOCAL: c_int = 1;
pub const AF_UNIX: c_int = AF_LOCAL;
pub const AF_INET: c_int = 2;
pub const AF_IMPLINK: c_int = 3;
pub const AF_PUP: c_int = 4;
pub const AF_CHAOS: c_int = 5;
pub const AF_NS: c_int = 6;
pub const AF_ISO: c_int = 7;
pub const AF_OSI: c_int = AF_ISO;
pub const AF_DATAKIT: c_int = 9;
pub const AF_CCITT: c_int = 10;
pub const AF_SNA: c_int = 11;
pub const AF_DECnet: c_int = 12;
pub const AF_DLI: c_int = 13;
pub const AF_LAT: c_int = 14;
pub const AF_HYLINK: c_int = 15;
pub const AF_APPLETALK: c_int = 16;
pub const AF_LINK: c_int = 18;
pub const pseudo_AF_XTP: c_int = 19;
pub const AF_COIP: c_int = 20;
pub const AF_CNT: c_int = 21;
pub const pseudo_AF_RTIP: c_int = 22;
pub const AF_IPX: c_int = 23;
pub const AF_INET6: c_int = 24;
pub const pseudo_AF_PIP: c_int = 25;
pub const AF_ISDN: c_int = 26;
pub const AF_E164: c_int = AF_ISDN;
pub const AF_NATM: c_int = 27;
pub const PF_UNSPEC: c_int = AF_UNSPEC;
pub const PF_LOCAL: c_int = AF_LOCAL;
pub const PF_UNIX: c_int = PF_LOCAL;
pub const PF_INET: c_int = AF_INET;
pub const PF_IMPLINK: c_int = AF_IMPLINK;
pub const PF_PUP: c_int = AF_PUP;
pub const PF_CHAOS: c_int = AF_CHAOS;
pub const PF_NS: c_int = AF_NS;
pub const PF_ISO: c_int = AF_ISO;
pub const PF_OSI: c_int = AF_ISO;
pub const PF_DATAKIT: c_int = AF_DATAKIT;
pub const PF_CCITT: c_int = AF_CCITT;
pub const PF_SNA: c_int = AF_SNA;
pub const PF_DECnet: c_int = AF_DECnet;
pub const PF_DLI: c_int = AF_DLI;
pub const PF_LAT: c_int = AF_LAT;
pub const PF_HYLINK: c_int = AF_HYLINK;
pub const PF_APPLETALK: c_int = AF_APPLETALK;
pub const PF_LINK: c_int = AF_LINK;
pub const PF_XTP: c_int = pseudo_AF_XTP;
pub const PF_COIP: c_int = AF_COIP;
pub const PF_CNT: c_int = AF_CNT;
pub const PF_IPX: c_int = AF_IPX;
pub const PF_INET6: c_int = AF_INET6;
pub const PF_RTIP: c_int = pseudo_AF_RTIP;
pub const PF_PIP: c_int = pseudo_AF_PIP;
pub const PF_ISDN: c_int = AF_ISDN;
pub const PF_NATM: c_int = AF_NATM;
pub const SOCK_STREAM: c_int = 1;
pub const SOCK_DGRAM: c_int = 2;
pub const SOCK_RAW: c_int = 3;
pub const SOCK_RDM: c_int = 4;
pub const SOCK_SEQPACKET: c_int = 5;
pub const IP_TTL: c_int = 4;
pub const IP_HDRINCL: c_int = 2;
pub const IP_ADD_MEMBERSHIP: c_int = 12;
pub const IP_DROP_MEMBERSHIP: c_int = 13;
pub const IPV6_RECVPKTINFO: c_int = 36;
pub const IPV6_PKTINFO: c_int = 46;
pub const IPV6_RECVTCLASS: c_int = 57;
pub const IPV6_TCLASS: c_int = 61;
pub const SOL_SOCKET: c_int = 0xffff;
pub const SO_DEBUG: c_int = 0x01;
pub const SO_ACCEPTCONN: c_int = 0x0002;
pub const SO_REUSEADDR: c_int = 0x0004;
pub const SO_KEEPALIVE: c_int = 0x0008;
pub const SO_DONTROUTE: c_int = 0x0010;
pub const SO_BROADCAST: c_int = 0x0020;
pub const SO_USELOOPBACK: c_int = 0x0040;
pub const SO_LINGER: c_int = 0x0080;
pub const SO_OOBINLINE: c_int = 0x0100;
pub const SO_REUSEPORT: c_int = 0x0200;
pub const SO_SNDBUF: c_int = 0x1001;
pub const SO_RCVBUF: c_int = 0x1002;
pub const SO_SNDLOWAT: c_int = 0x1003;
pub const SO_RCVLOWAT: c_int = 0x1004;
pub const SO_ERROR: c_int = 0x1007;
pub const SO_TYPE: c_int = 0x1008;
pub const SOMAXCONN: c_int = 128;
pub const MSG_OOB: c_int = 0x1;
pub const MSG_PEEK: c_int = 0x2;
pub const MSG_DONTROUTE: c_int = 0x4;
pub const MSG_EOR: c_int = 0x8;
pub const MSG_TRUNC: c_int = 0x10;
pub const MSG_CTRUNC: c_int = 0x20;
pub const MSG_WAITALL: c_int = 0x40;
pub const MSG_DONTWAIT: c_int = 0x80;
pub const MSG_BCAST: c_int = 0x100;
pub const MSG_MCAST: c_int = 0x200;
pub const MSG_NOSIGNAL: c_int = 0x400;
pub const MSG_CMSG_CLOEXEC: c_int = 0x800;
pub const SHUT_RD: c_int = 0;
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;
pub const LOCK_SH: c_int = 1;
pub const LOCK_EX: c_int = 2;
pub const LOCK_NB: c_int = 4;
pub const LOCK_UN: c_int = 8;
pub const IPPROTO_RAW: c_int = 255;
pub const _SC_ARG_MAX: c_int = 1;
pub const _SC_CHILD_MAX: c_int = 2;
pub const _SC_NGROUPS_MAX: c_int = 4;
pub const _SC_OPEN_MAX: c_int = 5;
pub const _SC_JOB_CONTROL: c_int = 6;
pub const _SC_SAVED_IDS: c_int = 7;
pub const _SC_VERSION: c_int = 8;
pub const _SC_BC_BASE_MAX: c_int = 9;
pub const _SC_BC_DIM_MAX: c_int = 10;
pub const _SC_BC_SCALE_MAX: c_int = 11;
pub const _SC_BC_STRING_MAX: c_int = 12;
pub const _SC_COLL_WEIGHTS_MAX: c_int = 13;
pub const _SC_EXPR_NEST_MAX: c_int = 14;
pub const _SC_LINE_MAX: c_int = 15;
pub const _SC_RE_DUP_MAX: c_int = 16;
pub const _SC_2_VERSION: c_int = 17;
pub const _SC_2_C_BIND: c_int = 18;
pub const _SC_2_C_DEV: c_int = 19;
pub const _SC_2_CHAR_TERM: c_int = 20;
pub const _SC_2_FORT_DEV: c_int = 21;
pub const _SC_2_FORT_RUN: c_int = 22;
pub const _SC_2_LOCALEDEF: c_int = 23;
pub const _SC_2_SW_DEV: c_int = 24;
pub const _SC_2_UPE: c_int = 25;
pub const _SC_STREAM_MAX: c_int = 26;
pub const _SC_TZNAME_MAX: c_int = 27;
pub const _SC_PAGESIZE: c_int = 28;
pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE;
pub const _SC_FSYNC: c_int = 29;
pub const _SC_XOPEN_SHM: c_int = 30;
pub const Q_GETQUOTA: c_int = 0x300;
pub const Q_SETQUOTA: c_int = 0x400;
pub const RTLD_GLOBAL: c_int = 0x100;
pub const LOG_NFACILITIES: c_int = 24;
pub const HW_NCPU: c_int = 3;
pub const B0: speed_t = 0;
pub const B50: speed_t = 50;
pub const B75: speed_t = 75;
pub const B110: speed_t = 110;
pub const B134: speed_t = 134;
pub const B150: speed_t = 150;
pub const B200: speed_t = 200;
pub const B300: speed_t = 300;
pub const B600: speed_t = 600;
pub const B1200: speed_t = 1200;
pub const B1800: speed_t = 1800;
pub const B2400: speed_t = 2400;
pub const B4800: speed_t = 4800;
pub const B9600: speed_t = 9600;
pub const B19200: speed_t = 19200;
pub const B38400: speed_t = 38400;
pub const B7200: speed_t = 7200;
pub const B14400: speed_t = 14400;
pub const B28800: speed_t = 28800;
pub const B57600: speed_t = 57600;
pub const B76800: speed_t = 76800;
pub const B115200: speed_t = 115200;
pub const B230400: speed_t = 230400;
pub const EXTA: speed_t = 19200;
pub const EXTB: speed_t = 38400;
pub const SEM_FAILED: *mut sem_t = ptr::null_mut();
pub const CRTSCTS: crate::tcflag_t = 0x00010000;
pub const CRTS_IFLOW: crate::tcflag_t = CRTSCTS;
pub const CCTS_OFLOW: crate::tcflag_t = CRTSCTS;
pub const OCRNL: crate::tcflag_t = 0x10;
pub const TIOCEXCL: c_ulong = 0x2000740d;
pub const TIOCNXCL: c_ulong = 0x2000740e;
pub const TIOCFLUSH: c_ulong = 0x80047410;
pub const TIOCGETA: c_ulong = 0x402c7413;
pub const TIOCSETA: c_ulong = 0x802c7414;
pub const TIOCSETAW: c_ulong = 0x802c7415;
pub const TIOCSETAF: c_ulong = 0x802c7416;
pub const TIOCGETD: c_ulong = 0x4004741a;
pub const TIOCSETD: c_ulong = 0x8004741b;
pub const TIOCMGET: c_ulong = 0x4004746a;
pub const TIOCMBIC: c_ulong = 0x8004746b;
pub const TIOCMBIS: c_ulong = 0x8004746c;
pub const TIOCMSET: c_ulong = 0x8004746d;
pub const TIOCSTART: c_ulong = 0x2000746e;
pub const TIOCSTOP: c_ulong = 0x2000746f;
pub const TIOCSCTTY: c_ulong = 0x20007461;
pub const TIOCGWINSZ: c_ulong = 0x40087468;
pub const TIOCSWINSZ: c_ulong = 0x80087467;
pub const TIOCM_LE: c_int = 0o0001;
pub const TIOCM_DTR: c_int = 0o0002;
pub const TIOCM_RTS: c_int = 0o0004;
pub const TIOCM_ST: c_int = 0o0010;
pub const TIOCM_SR: c_int = 0o0020;
pub const TIOCM_CTS: c_int = 0o0040;
pub const TIOCM_CAR: c_int = 0o0100;
pub const TIOCM_RNG: c_int = 0o0200;
pub const TIOCM_DSR: c_int = 0o0400;
pub const TIOCM_CD: c_int = TIOCM_CAR;
pub const TIOCM_RI: c_int = TIOCM_RNG;
pub const TIMER_ABSTIME: c_int = 1;
// sys/reboot.h
pub const RB_AUTOBOOT: c_int = 0;
pub const TCP_INFO: c_int = 9;
#[link(name = "util")]
extern "C" {
pub fn setgrent();
pub fn sem_destroy(sem: *mut sem_t) -> c_int;
pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;
pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int;
pub fn accept4(
s: c_int,
addr: *mut crate::sockaddr,
addrlen: *mut crate::socklen_t,
flags: c_int,
) -> c_int;
pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_char) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__clock_getres50")]
pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")]
pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")]
pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int;
pub fn __errno() -> *mut c_int;
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int;
pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int;
pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int;
pub fn utimensat(
dirfd: c_int,
path: *const c_char,
times: *const crate::timespec,
flag: c_int,
) -> c_int;
pub fn fdatasync(fd: c_int) -> c_int;
pub fn login_tty(fd: c_int) -> c_int;
pub fn getpriority(which: c_int, who: crate::id_t) -> c_int;
pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int;
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int;
pub fn pthread_condattr_setclock(
attr: *mut pthread_condattr_t,
clock_id: crate::clockid_t,
) -> c_int;
pub fn sethostname(name: *const c_char, len: size_t) -> c_int;
pub fn pthread_mutex_timedlock(
lock: *mut pthread_mutex_t,
abstime: *const crate::timespec,
) -> c_int;
pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int;
pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int;
pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int;
pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int;
pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int;
pub fn pthread_setschedparam(
native: crate::pthread_t,
policy: c_int,
param: *const sched_param,
) -> c_int;
pub fn pthread_getschedparam(
native: crate::pthread_t,
policy: *mut c_int,
param: *mut sched_param,
) -> c_int;
pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int;
pub fn getgrouplist(
name: *const c_char,
basegid: crate::gid_t,
groups: *mut crate::gid_t,
ngroups: *mut c_int,
) -> c_int;
pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int;
pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int;
pub fn setdomainname(name: *const c_char, len: size_t) -> c_int;
pub fn uname(buf: *mut crate::utsname) -> c_int;
pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int;
pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void;
pub fn shmdt(shmaddr: *const c_void) -> c_int;
pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
// DIFF(main): changed to `*const *mut` in e77f551de9
pub fn execvpe(
file: *const c_char,
argv: *const *const c_char,
envp: *const *const c_char,
) -> c_int;
pub fn waitid(
idtype: idtype_t,
id: crate::id_t,
infop: *mut crate::siginfo_t,
options: c_int,
) -> c_int;
pub fn posix_spawn(
pid: *mut crate::pid_t,
path: *const c_char,
file_actions: *const crate::posix_spawn_file_actions_t,
attrp: *const crate::posix_spawnattr_t,
argv: *const *mut c_char,
envp: *const *mut c_char,
) -> c_int;
pub fn posix_spawnp(
pid: *mut crate::pid_t,
file: *const c_char,
file_actions: *const crate::posix_spawn_file_actions_t,
attrp: *const crate::posix_spawnattr_t,
argv: *const *mut c_char,
envp: *const *mut c_char,
) -> c_int;
pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
pub fn posix_spawnattr_getsigdefault(
attr: *const posix_spawnattr_t,
default: *mut crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_setsigdefault(
attr: *mut posix_spawnattr_t,
default: *const crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_getsigmask(
attr: *const posix_spawnattr_t,
default: *mut crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_setsigmask(
attr: *mut posix_spawnattr_t,
default: *const crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int;
pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
pub fn posix_spawnattr_getpgroup(
attr: *const posix_spawnattr_t,
flags: *mut crate::pid_t,
) -> c_int;
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int;
pub fn posix_spawnattr_getschedpolicy(
attr: *const posix_spawnattr_t,
flags: *mut c_int,
) -> c_int;
pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int;
pub fn posix_spawnattr_getschedparam(
attr: *const posix_spawnattr_t,
param: *mut crate::sched_param,
) -> c_int;
pub fn posix_spawnattr_setschedparam(
attr: *mut posix_spawnattr_t,
param: *const crate::sched_param,
) -> c_int;
pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
pub fn posix_spawn_file_actions_addopen(
actions: *mut posix_spawn_file_actions_t,
fd: c_int,
path: *const c_char,
oflag: c_int,
mode: mode_t,
) -> c_int;
pub fn posix_spawn_file_actions_addclose(
actions: *mut posix_spawn_file_actions_t,
fd: c_int,
) -> c_int;
pub fn posix_spawn_file_actions_adddup2(
actions: *mut posix_spawn_file_actions_t,
fd: c_int,
newfd: c_int,
) -> c_int;
}
extern "C" {
pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void;
pub fn gethostid() -> c_long;
pub fn sethostid(hostid: c_long) -> c_int;
pub fn ftok(path: *const c_char, id: c_int) -> crate::key_t;
pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;
pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int;
pub fn sendmmsg(sockfd: c_int, mmsg: *mut crate::mmsghdr, vlen: c_uint, flags: c_int) -> c_int;
pub fn recvmmsg(
sockfd: c_int,
mmsg: *mut crate::mmsghdr,
vlen: c_uint,
flags: c_int,
timeout: *mut crate::timespec,
) -> c_int;
pub fn closefrom(lowfd: c_int) -> c_int;
}
cfg_if! {
if #[cfg(target_os = "netbsd")] {
mod netbsd;
pub use self::netbsd::*;
} else if #[cfg(target_os = "openbsd")] {
mod openbsd;
pub use self::openbsd::*;
} else {
// Unknown target_os
}
}

View File

@@ -0,0 +1,132 @@
use crate::prelude::*;
use crate::PT_FIRSTMACH;
pub type greg_t = u64;
pub type __cpu_simple_lock_nv_t = c_uchar;
s! {
pub struct __fregset {
pub __qregs: [__c_anonymous__freg; 32],
pub __fpcr: u32,
pub __fpsr: u32,
}
pub struct mcontext_t {
pub __gregs: [crate::greg_t; 32],
pub __fregs: __fregset,
__spare: [crate::greg_t; 8],
}
pub struct ucontext_t {
pub uc_flags: c_uint,
pub uc_link: *mut ucontext_t,
pub uc_sigmask: crate::sigset_t,
pub uc_stack: crate::stack_t,
pub uc_mcontext: mcontext_t,
}
}
s_no_extra_traits! {
#[repr(align(16))]
pub union __c_anonymous__freg {
pub __b8: [u8; 16],
pub __h16: [u16; 8],
pub __s32: [u32; 4],
pub __d64: [u64; 2],
pub __q128: [u128; 1],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for __c_anonymous__freg {
fn eq(&self, other: &__c_anonymous__freg) -> bool {
unsafe {
self.__b8 == other.__b8
|| self.__h16 == other.__h16
|| self.__s32 == other.__s32
|| self.__d64 == other.__d64
|| self.__q128 == other.__q128
}
}
}
impl Eq for __c_anonymous__freg {}
impl hash::Hash for __c_anonymous__freg {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
unsafe {
self.__b8.hash(state);
self.__h16.hash(state);
self.__s32.hash(state);
self.__d64.hash(state);
self.__q128.hash(state);
}
}
}
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1;
pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0;
pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1;
pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 2;
pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 3;
pub const _REG_R0: c_int = 0;
pub const _REG_R1: c_int = 1;
pub const _REG_R2: c_int = 2;
pub const _REG_R3: c_int = 3;
pub const _REG_R4: c_int = 4;
pub const _REG_R5: c_int = 5;
pub const _REG_R6: c_int = 6;
pub const _REG_R7: c_int = 7;
pub const _REG_R8: c_int = 8;
pub const _REG_R9: c_int = 9;
pub const _REG_R10: c_int = 10;
pub const _REG_R11: c_int = 11;
pub const _REG_R12: c_int = 12;
pub const _REG_R13: c_int = 13;
pub const _REG_R14: c_int = 14;
pub const _REG_R15: c_int = 15;
pub const _REG_CPSR: c_int = 16;
pub const _REG_X0: c_int = 0;
pub const _REG_X1: c_int = 1;
pub const _REG_X2: c_int = 2;
pub const _REG_X3: c_int = 3;
pub const _REG_X4: c_int = 4;
pub const _REG_X5: c_int = 5;
pub const _REG_X6: c_int = 6;
pub const _REG_X7: c_int = 7;
pub const _REG_X8: c_int = 8;
pub const _REG_X9: c_int = 9;
pub const _REG_X10: c_int = 10;
pub const _REG_X11: c_int = 11;
pub const _REG_X12: c_int = 12;
pub const _REG_X13: c_int = 13;
pub const _REG_X14: c_int = 14;
pub const _REG_X15: c_int = 15;
pub const _REG_X16: c_int = 16;
pub const _REG_X17: c_int = 17;
pub const _REG_X18: c_int = 18;
pub const _REG_X19: c_int = 19;
pub const _REG_X20: c_int = 20;
pub const _REG_X21: c_int = 21;
pub const _REG_X22: c_int = 22;
pub const _REG_X23: c_int = 23;
pub const _REG_X24: c_int = 24;
pub const _REG_X25: c_int = 25;
pub const _REG_X26: c_int = 26;
pub const _REG_X27: c_int = 27;
pub const _REG_X28: c_int = 28;
pub const _REG_X29: c_int = 29;
pub const _REG_X30: c_int = 30;
pub const _REG_X31: c_int = 31;
pub const _REG_ELR: c_int = 32;
pub const _REG_SPSR: c_int = 33;
pub const _REG_TIPDR: c_int = 34;
pub const _REG_RV: c_int = _REG_X0;
pub const _REG_FP: c_int = _REG_X29;
pub const _REG_LR: c_int = _REG_X30;
pub const _REG_SP: c_int = _REG_X31;
pub const _REG_PC: c_int = _REG_ELR;

View File

@@ -0,0 +1,70 @@
use crate::prelude::*;
use crate::PT_FIRSTMACH;
pub type __cpu_simple_lock_nv_t = c_int;
pub(crate) const _ALIGNBYTES: usize = size_of::<c_longlong>() - 1;
pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1;
pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2;
pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3;
pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4;
pub const _REG_R0: c_int = 0;
pub const _REG_R1: c_int = 1;
pub const _REG_R2: c_int = 2;
pub const _REG_R3: c_int = 3;
pub const _REG_R4: c_int = 4;
pub const _REG_R5: c_int = 5;
pub const _REG_R6: c_int = 6;
pub const _REG_R7: c_int = 7;
pub const _REG_R8: c_int = 8;
pub const _REG_R9: c_int = 9;
pub const _REG_R10: c_int = 10;
pub const _REG_R11: c_int = 11;
pub const _REG_R12: c_int = 12;
pub const _REG_R13: c_int = 13;
pub const _REG_R14: c_int = 14;
pub const _REG_R15: c_int = 15;
pub const _REG_CPSR: c_int = 16;
pub const _REG_X0: c_int = 0;
pub const _REG_X1: c_int = 1;
pub const _REG_X2: c_int = 2;
pub const _REG_X3: c_int = 3;
pub const _REG_X4: c_int = 4;
pub const _REG_X5: c_int = 5;
pub const _REG_X6: c_int = 6;
pub const _REG_X7: c_int = 7;
pub const _REG_X8: c_int = 8;
pub const _REG_X9: c_int = 9;
pub const _REG_X10: c_int = 10;
pub const _REG_X11: c_int = 11;
pub const _REG_X12: c_int = 12;
pub const _REG_X13: c_int = 13;
pub const _REG_X14: c_int = 14;
pub const _REG_X15: c_int = 15;
pub const _REG_X16: c_int = 16;
pub const _REG_X17: c_int = 17;
pub const _REG_X18: c_int = 18;
pub const _REG_X19: c_int = 19;
pub const _REG_X20: c_int = 20;
pub const _REG_X21: c_int = 21;
pub const _REG_X22: c_int = 22;
pub const _REG_X23: c_int = 23;
pub const _REG_X24: c_int = 24;
pub const _REG_X25: c_int = 25;
pub const _REG_X26: c_int = 26;
pub const _REG_X27: c_int = 27;
pub const _REG_X28: c_int = 28;
pub const _REG_X29: c_int = 29;
pub const _REG_X30: c_int = 30;
pub const _REG_X31: c_int = 31;
pub const _REG_ELR: c_int = 32;
pub const _REG_SPSR: c_int = 33;
pub const _REG_TIPDR: c_int = 34;
pub const _REG_RV: c_int = _REG_R0;
pub const _REG_FP: c_int = _REG_R11;
pub const _REG_LR: c_int = _REG_R13;
pub const _REG_SP: c_int = _REG_R14;
pub const _REG_PC: c_int = _REG_R15;

View File

@@ -0,0 +1,11 @@
use crate::prelude::*;
use crate::PT_FIRSTMACH;
pub type __cpu_simple_lock_nv_t = c_int;
pub(crate) const _ALIGNBYTES: usize = size_of::<c_longlong>() - 1;
pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1;
pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2;
pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3;
pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
use crate::prelude::*;
use crate::PT_FIRSTMACH;
pub type __cpu_simple_lock_nv_t = c_int;
pub(crate) const _ALIGNBYTES: usize = size_of::<c_double>() - 1;
pub const PT_STEP: c_int = PT_FIRSTMACH + 0;
pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1;
pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2;

View File

@@ -0,0 +1,77 @@
use PT_FIRSTMACH;
use crate::prelude::*;
pub type __greg_t = u64;
pub type __cpu_simple_lock_nv_t = c_int;
pub type __gregset = [__greg_t; _NGREG];
pub type __fregset = [__freg; _NFREG];
s! {
pub struct mcontext_t {
pub __gregs: __gregset,
pub __fregs: __fpregset,
__spare: [crate::__greg_t; 7],
}
}
s_no_extra_traits! {
pub union __fpreg {
pub u_u64: u64,
pub u_d: c_double,
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0;
pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1;
pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 2;
pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 3;
pub const _NGREG: usize = 32;
pub const _NFREG: usize = 33;
pub const _REG_X1: c_int = 0;
pub const _REG_X2: c_int = 1;
pub const _REG_X3: c_int = 2;
pub const _REG_X4: c_int = 3;
pub const _REG_X5: c_int = 4;
pub const _REG_X6: c_int = 5;
pub const _REG_X7: c_int = 6;
pub const _REG_X8: c_int = 7;
pub const _REG_X9: c_int = 8;
pub const _REG_X10: c_int = 9;
pub const _REG_X11: c_int = 10;
pub const _REG_X12: c_int = 11;
pub const _REG_X13: c_int = 12;
pub const _REG_X14: c_int = 13;
pub const _REG_X15: c_int = 14;
pub const _REG_X16: c_int = 15;
pub const _REG_X17: c_int = 16;
pub const _REG_X18: c_int = 17;
pub const _REG_X19: c_int = 18;
pub const _REG_X20: c_int = 19;
pub const _REG_X21: c_int = 20;
pub const _REG_X22: c_int = 21;
pub const _REG_X23: c_int = 22;
pub const _REG_X24: c_int = 23;
pub const _REG_X25: c_int = 24;
pub const _REG_X26: c_int = 25;
pub const _REG_X27: c_int = 26;
pub const _REG_X28: c_int = 27;
pub const _REG_X29: c_int = 28;
pub const _REG_X30: c_int = 29;
pub const _REG_X31: c_int = 30;
pub const _REG_PC: c_int = 31;
pub const _REG_RA: c_int = _REG_X1;
pub const _REG_SP: c_int = _REG_X2;
pub const _REG_GP: c_int = _REG_X3;
pub const _REG_TP: c_int = _REG_X4;
pub const _REG_S0: c_int = _REG_X8;
pub const _REG_RV: c_int = _REG_X10;
pub const _REG_A0: c_int = _REG_X10;
pub const _REG_F0: c_int = 0;
pub const _REG_FPCSR: c_int = 32;

View File

@@ -0,0 +1,7 @@
use crate::prelude::*;
pub type __cpu_simple_lock_nv_t = c_uchar;
// should be pub(crate), but that requires Rust 1.18.0
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 0xf;

View File

@@ -0,0 +1,5 @@
use crate::prelude::*;
pub type __cpu_simple_lock_nv_t = c_uchar;
pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1;

View File

@@ -0,0 +1,56 @@
use crate::prelude::*;
use crate::PT_FIRSTMACH;
pub type c___greg_t = u64;
pub type __cpu_simple_lock_nv_t = c_uchar;
s! {
pub struct mcontext_t {
pub __gregs: [c___greg_t; 26],
pub _mc_tlsbase: c___greg_t,
pub __fpregs: [[c_char; 32]; 16],
}
pub struct ucontext_t {
pub uc_flags: c_uint,
pub uc_link: *mut crate::ucontext_t,
pub uc_sigmask: crate::sigset_t,
pub uc_stack: crate::stack_t,
pub uc_mcontext: crate::mcontext_t,
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const PT_STEP: c_int = PT_FIRSTMACH + 0;
pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1;
pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2;
pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3;
pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4;
pub const _REG_RDI: c_int = 0;
pub const _REG_RSI: c_int = 1;
pub const _REG_RDX: c_int = 2;
pub const _REG_RCX: c_int = 3;
pub const _REG_R8: c_int = 4;
pub const _REG_R9: c_int = 5;
pub const _REG_R10: c_int = 6;
pub const _REG_R11: c_int = 7;
pub const _REG_R12: c_int = 8;
pub const _REG_R13: c_int = 9;
pub const _REG_R14: c_int = 10;
pub const _REG_R15: c_int = 11;
pub const _REG_RBP: c_int = 12;
pub const _REG_RBX: c_int = 13;
pub const _REG_RAX: c_int = 14;
pub const _REG_GS: c_int = 15;
pub const _REG_FS: c_int = 16;
pub const _REG_ES: c_int = 17;
pub const _REG_DS: c_int = 18;
pub const _REG_TRAPNO: c_int = 19;
pub const _REG_ERR: c_int = 20;
pub const _REG_RIP: c_int = 21;
pub const _REG_CS: c_int = 22;
pub const _REG_RFLAGS: c_int = 23;
pub const _REG_RSP: c_int = 24;
pub const _REG_SS: c_int = 25;

View File

@@ -0,0 +1,20 @@
use crate::prelude::*;
pub type ucontext_t = sigcontext;
s! {
pub struct sigcontext {
__sc_unused: c_int,
pub sc_mask: c_int,
pub sc_sp: c_ulong,
pub sc_lr: c_ulong,
pub sc_elr: c_ulong,
pub sc_spsr: c_ulong,
pub sc_x: [c_ulong; 30],
pub sc_cookie: c_long,
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const _MAX_PAGE_SHIFT: u32 = 12;

View File

@@ -0,0 +1,5 @@
use crate::prelude::*;
pub(crate) const _ALIGNBYTES: usize = size_of::<c_double>() - 1;
pub const _MAX_PAGE_SHIFT: u32 = 12;

View File

@@ -0,0 +1,4 @@
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 7;
pub const _MAX_PAGE_SHIFT: u32 = 14;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
use crate::prelude::*;
pub(crate) const _ALIGNBYTES: usize = size_of::<c_double>() - 1;
pub const _MAX_PAGE_SHIFT: u32 = 12;

View File

@@ -0,0 +1,5 @@
use crate::prelude::*;
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const _MAX_PAGE_SHIFT: u32 = 12;

View File

@@ -0,0 +1,25 @@
use crate::prelude::*;
pub type ucontext_t = sigcontext;
s! {
pub struct sigcontext {
__sc_unused: c_int,
pub sc_mask: c_int,
pub sc_ra: c_long,
pub sc_sp: c_long,
pub sc_gp: c_long,
pub sc_tp: c_long,
pub sc_t: [c_long; 7],
pub sc_s: [c_long; 12],
pub sc_a: [c_long; 8],
pub sc_sepc: c_long,
pub sc_f: [c_long; 32],
pub sc_fcsr: c_long,
pub sc_cookie: c_long,
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const _MAX_PAGE_SHIFT: u32 = 12;

View File

@@ -0,0 +1,4 @@
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 0xf;
pub const _MAX_PAGE_SHIFT: u32 = 13;

View File

@@ -0,0 +1,5 @@
use crate::prelude::*;
pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1;
pub const _MAX_PAGE_SHIFT: u32 = 12;

View File

@@ -0,0 +1,109 @@
use crate::prelude::*;
use crate::PT_FIRSTMACH;
pub type ucontext_t = sigcontext;
s! {
pub struct sigcontext {
pub sc_rdi: c_long,
pub sc_rsi: c_long,
pub sc_rdx: c_long,
pub sc_rcx: c_long,
pub sc_r8: c_long,
pub sc_r9: c_long,
pub sc_r10: c_long,
pub sc_r11: c_long,
pub sc_r12: c_long,
pub sc_r13: c_long,
pub sc_r14: c_long,
pub sc_r15: c_long,
pub sc_rbp: c_long,
pub sc_rbx: c_long,
pub sc_rax: c_long,
pub sc_gs: c_long,
pub sc_fs: c_long,
pub sc_es: c_long,
pub sc_ds: c_long,
pub sc_trapno: c_long,
pub sc_err: c_long,
pub sc_rip: c_long,
pub sc_cs: c_long,
pub sc_rflags: c_long,
pub sc_rsp: c_long,
pub sc_ss: c_long,
pub sc_fpstate: *mut fxsave64,
__sc_unused: c_int,
pub sc_mask: c_int,
pub sc_cookie: c_long,
}
}
s_no_extra_traits! {
#[repr(packed)]
pub struct fxsave64 {
pub fx_fcw: u16,
pub fx_fsw: u16,
pub fx_ftw: u8,
__fx_unused1: u8,
pub fx_fop: u16,
pub fx_rip: u64,
pub fx_rdp: u64,
pub fx_mxcsr: u32,
pub fx_mxcsr_mask: u32,
pub fx_st: [[u64; 2]; 8],
pub fx_xmm: [[u64; 2]; 16],
__fx_unused3: [u8; 96],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
// `fxsave64` is packed, so field access is unaligned.
// use {x} to create temporary storage, copy field to it, and do aligned access.
impl PartialEq for fxsave64 {
fn eq(&self, other: &fxsave64) -> bool {
return { self.fx_fcw } == { other.fx_fcw }
&& { self.fx_fsw } == { other.fx_fsw }
&& { self.fx_ftw } == { other.fx_ftw }
&& { self.fx_fop } == { other.fx_fop }
&& { self.fx_rip } == { other.fx_rip }
&& { self.fx_rdp } == { other.fx_rdp }
&& { self.fx_mxcsr } == { other.fx_mxcsr }
&& { self.fx_mxcsr_mask } == { other.fx_mxcsr_mask }
&& { self.fx_st }
.iter()
.zip({ other.fx_st }.iter())
.all(|(a, b)| a == b)
&& { self.fx_xmm }
.iter()
.zip({ other.fx_xmm }.iter())
.all(|(a, b)| a == b);
}
}
impl Eq for fxsave64 {}
impl hash::Hash for fxsave64 {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
{ self.fx_fcw }.hash(state);
{ self.fx_fsw }.hash(state);
{ self.fx_ftw }.hash(state);
{ self.fx_fop }.hash(state);
{ self.fx_rip }.hash(state);
{ self.fx_rdp }.hash(state);
{ self.fx_mxcsr }.hash(state);
{ self.fx_mxcsr_mask }.hash(state);
{ self.fx_st }.hash(state);
{ self.fx_xmm }.hash(state);
}
}
}
}
pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1;
pub const _MAX_PAGE_SHIFT: u32 = 12;
pub const PT_STEP: c_int = PT_FIRSTMACH + 0;
pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1;
pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2;
pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3;
pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4;

2477
vendor/libc/src/unix/cygwin/mod.rs vendored Normal file

File diff suppressed because it is too large Load Diff

18
vendor/libc/src/unix/haiku/b32.rs vendored Normal file
View File

@@ -0,0 +1,18 @@
pub type time_t = i32;
pub type Elf_Addr = crate::Elf32_Addr;
pub type Elf_Half = crate::Elf32_Half;
pub type Elf_Phdr = crate::Elf32_Phdr;
s! {
pub struct Elf32_Phdr {
pub p_type: crate::Elf32_Word,
pub p_offset: crate::Elf32_Off,
pub p_vaddr: crate::Elf32_Addr,
pub p_paddr: crate::Elf32_Addr,
pub p_filesz: crate::Elf32_Word,
pub p_memsz: crate::Elf32_Word,
pub p_flags: crate::Elf32_Word,
pub p_align: crate::Elf32_Word,
}
}

18
vendor/libc/src/unix/haiku/b64.rs vendored Normal file
View File

@@ -0,0 +1,18 @@
pub type time_t = i64;
pub type Elf_Addr = crate::Elf64_Addr;
pub type Elf_Half = crate::Elf64_Half;
pub type Elf_Phdr = crate::Elf64_Phdr;
s! {
pub struct Elf64_Phdr {
pub p_type: crate::Elf64_Word,
pub p_flags: crate::Elf64_Word,
pub p_offset: crate::Elf64_Off,
pub p_vaddr: crate::Elf64_Addr,
pub p_paddr: crate::Elf64_Addr,
pub p_filesz: crate::Elf64_Xword,
pub p_memsz: crate::Elf64_Xword,
pub p_align: crate::Elf64_Xword,
}
}

151
vendor/libc/src/unix/haiku/bsd.rs vendored Normal file
View File

@@ -0,0 +1,151 @@
//! This file contains the BSD APIs available in Haiku. It corresponds to the
//! header files in `headers/compatibility/bsd`.
//!
//! Note that Haiku's BSD compatibility is a combination of system APIs and
//! utility libraries. There should only be system APIs in `libc`. When you are
//! trying to determine whether something should be included in this file, the
//! best indicator is whether it also exists in the BSD-specific definitions in
//! this libc crate.
use crate::prelude::*;
// stringlist.h (utility library)
// Note: this is kept because it was previously introduced
pub type StringList = _stringlist;
s! {
// stringlist.h (utility library)
// Note: this is kept because it was previously introduced
pub struct _stringlist {
pub sl_str: *mut *mut c_char,
pub sl_max: size_t,
pub sl_cur: size_t,
}
// sys/event.h
pub struct kevent {
pub ident: crate::uintptr_t,
pub filter: c_short,
pub flags: c_ushort,
pub fflags: c_uint,
pub data: i64,
pub udata: *mut c_void,
pub ext: [u64; 4],
}
// sys/link_elf.h
pub struct dl_phdr_info {
pub dlpi_addr: crate::Elf_Addr,
pub dlpi_name: *const c_char,
pub dlpi_phdr: *const crate::Elf_Phdr,
pub dlpi_phnum: crate::Elf_Half,
}
}
// sys/event.h
pub const EVFILT_READ: i16 = -1;
pub const EVFILT_WRITE: i16 = -2;
pub const EVFILT_PROC: i16 = -5;
pub const EV_ADD: u16 = 0x0001;
pub const EV_DELETE: u16 = 0x0002;
pub const EV_ONESHOT: u16 = 0x0010;
pub const EV_CLEAR: u16 = 0x0020;
pub const EV_EOF: u16 = 0x8000;
pub const EV_ERROR: u16 = 0x4000;
pub const NOTE_EXIT: u32 = 0x80000000;
// sys/ioccom.h
pub const IOC_VOID: c_ulong = 0x20000000;
pub const IOC_OUT: c_ulong = 0x40000000;
pub const IOC_IN: c_ulong = 0x80000000;
pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT;
pub const IOC_DIRMASK: c_ulong = 0xe0000000;
#[link(name = "bsd")]
extern "C" {
// stdlib.h
pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int;
pub fn getprogname() -> *const c_char;
pub fn setprogname(progname: *const c_char);
pub fn arc4random() -> u32;
pub fn arc4random_uniform(upper_bound: u32) -> u32;
pub fn arc4random_buf(buf: *mut c_void, n: size_t);
pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int;
pub fn strtonum(
nptr: *const c_char,
minval: c_longlong,
maxval: c_longlong,
errstr: *mut *const c_char,
) -> c_longlong;
// pty.h
pub fn openpty(
amaster: *mut c_int,
aslave: *mut c_int,
name: *mut c_char,
termp: *mut crate::termios,
winp: *mut crate::winsize,
) -> c_int;
pub fn login_tty(_fd: c_int) -> c_int;
pub fn forkpty(
amaster: *mut c_int,
name: *mut c_char,
termp: *mut crate::termios,
winp: *mut crate::winsize,
) -> crate::pid_t;
// string.h
pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char;
pub fn explicit_bzero(buf: *mut c_void, len: size_t);
// stringlist.h (utility library)
// Note: this is kept because it was previously introduced
pub fn sl_init() -> *mut StringList;
pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int;
pub fn sl_free(sl: *mut StringList, i: c_int);
pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char;
// sys/event.h
pub fn kqueue() -> c_int;
pub fn kevent(
kq: c_int,
changelist: *const kevent,
nchanges: c_int,
eventlist: *mut kevent,
nevents: c_int,
timeout: *const crate::timespec,
) -> c_int;
// sys/link_elf.h
pub fn dl_iterate_phdr(
callback: Option<
unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int,
>,
data: *mut c_void,
) -> c_int;
// sys/time.h
pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
// sys/uov.h
pub fn preadv(
fd: c_int,
iov: *const crate::iovec,
iovcnt: c_int,
offset: crate::off_t,
) -> ssize_t;
pub fn pwritev(
fd: c_int,
iov: *const crate::iovec,
iovcnt: c_int,
offset: crate::off_t,
) -> ssize_t;
// sys/wait.h
pub fn wait4(
pid: crate::pid_t,
status: *mut c_int,
options: c_int,
rusage: *mut crate::rusage,
) -> crate::pid_t;
}

2097
vendor/libc/src/unix/haiku/mod.rs vendored Normal file

File diff suppressed because it is too large Load Diff

1388
vendor/libc/src/unix/haiku/native.rs vendored Normal file

File diff suppressed because it is too large Load Diff

208
vendor/libc/src/unix/haiku/x86_64.rs vendored Normal file
View File

@@ -0,0 +1,208 @@
use crate::prelude::*;
s_no_extra_traits! {
pub struct fpu_state {
pub control: c_ushort,
pub status: c_ushort,
pub tag: c_ushort,
pub opcode: c_ushort,
pub rip: c_ulong,
pub rdp: c_ulong,
pub mxcsr: c_uint,
pub mscsr_mask: c_uint,
pub _fpreg: [[c_uchar; 8]; 16],
pub _xmm: [[c_uchar; 16]; 16],
pub _reserved_416_511: [c_uchar; 96],
}
pub struct xstate_hdr {
pub bv: c_ulong,
pub xcomp_bv: c_ulong,
pub _reserved: [c_uchar; 48],
}
pub struct savefpu {
pub fp_fxsave: fpu_state,
pub fp_xstate: xstate_hdr,
pub _fp_ymm: [[c_uchar; 16]; 16],
}
pub struct mcontext_t {
pub rax: c_ulong,
pub rbx: c_ulong,
pub rcx: c_ulong,
pub rdx: c_ulong,
pub rdi: c_ulong,
pub rsi: c_ulong,
pub rbp: c_ulong,
pub r8: c_ulong,
pub r9: c_ulong,
pub r10: c_ulong,
pub r11: c_ulong,
pub r12: c_ulong,
pub r13: c_ulong,
pub r14: c_ulong,
pub r15: c_ulong,
pub rsp: c_ulong,
pub rip: c_ulong,
pub rflags: c_ulong,
pub fpu: savefpu,
}
pub struct ucontext_t {
pub uc_link: *mut ucontext_t,
pub uc_sigmask: crate::sigset_t,
pub uc_stack: crate::stack_t,
pub uc_mcontext: mcontext_t,
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for fpu_state {
fn eq(&self, other: &fpu_state) -> bool {
self.control == other.control
&& self.status == other.status
&& self.tag == other.tag
&& self.opcode == other.opcode
&& self.rip == other.rip
&& self.rdp == other.rdp
&& self.mxcsr == other.mxcsr
&& self.mscsr_mask == other.mscsr_mask
&& self
._fpreg
.iter()
.zip(other._fpreg.iter())
.all(|(a, b)| a == b)
&& self._xmm.iter().zip(other._xmm.iter()).all(|(a, b)| a == b)
&& self
._reserved_416_511
.iter()
.zip(other._reserved_416_511.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for fpu_state {}
impl hash::Hash for fpu_state {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.control.hash(state);
self.status.hash(state);
self.tag.hash(state);
self.opcode.hash(state);
self.rip.hash(state);
self.rdp.hash(state);
self.mxcsr.hash(state);
self.mscsr_mask.hash(state);
self._fpreg.hash(state);
self._xmm.hash(state);
self._reserved_416_511.hash(state);
}
}
impl PartialEq for xstate_hdr {
fn eq(&self, other: &xstate_hdr) -> bool {
self.bv == other.bv
&& self.xcomp_bv == other.xcomp_bv
&& self
._reserved
.iter()
.zip(other._reserved.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for xstate_hdr {}
impl hash::Hash for xstate_hdr {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.bv.hash(state);
self.xcomp_bv.hash(state);
self._reserved.hash(state);
}
}
impl PartialEq for savefpu {
fn eq(&self, other: &savefpu) -> bool {
self.fp_fxsave == other.fp_fxsave
&& self.fp_xstate == other.fp_xstate
&& self
._fp_ymm
.iter()
.zip(other._fp_ymm.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for savefpu {}
impl hash::Hash for savefpu {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.fp_fxsave.hash(state);
self.fp_xstate.hash(state);
self._fp_ymm.hash(state);
}
}
impl PartialEq for mcontext_t {
fn eq(&self, other: &mcontext_t) -> bool {
self.rax == other.rax
&& self.rbx == other.rbx
&& self.rbx == other.rbx
&& self.rcx == other.rcx
&& self.rdx == other.rdx
&& self.rdi == other.rdi
&& self.rsi == other.rsi
&& self.r8 == other.r8
&& self.r9 == other.r9
&& self.r10 == other.r10
&& self.r11 == other.r11
&& self.r12 == other.r12
&& self.r13 == other.r13
&& self.r14 == other.r14
&& self.r15 == other.r15
&& self.rsp == other.rsp
&& self.rip == other.rip
&& self.rflags == other.rflags
&& self.fpu == other.fpu
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.rax.hash(state);
self.rbx.hash(state);
self.rcx.hash(state);
self.rdx.hash(state);
self.rdi.hash(state);
self.rsi.hash(state);
self.rbp.hash(state);
self.r8.hash(state);
self.r9.hash(state);
self.r10.hash(state);
self.r11.hash(state);
self.r12.hash(state);
self.r13.hash(state);
self.r14.hash(state);
self.r15.hash(state);
self.rsp.hash(state);
self.rip.hash(state);
self.rflags.hash(state);
self.fpu.hash(state);
}
}
impl PartialEq for ucontext_t {
fn eq(&self, other: &ucontext_t) -> bool {
self.uc_link == other.uc_link
&& self.uc_sigmask == other.uc_sigmask
&& self.uc_stack == other.uc_stack
&& self.uc_mcontext == other.uc_mcontext
}
}
impl Eq for ucontext_t {}
impl hash::Hash for ucontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.uc_link.hash(state);
self.uc_sigmask.hash(state);
self.uc_stack.hash(state);
self.uc_mcontext.hash(state);
}
}
}
}

92
vendor/libc/src/unix/hurd/b32.rs vendored Normal file
View File

@@ -0,0 +1,92 @@
use crate::prelude::*;
pub type __int64_t = c_longlong;
pub type __uint64_t = c_ulonglong;
pub type int_fast16_t = c_int;
pub type int_fast32_t = c_int;
pub type int_fast64_t = c_longlong;
pub type uint_fast16_t = c_uint;
pub type uint_fast32_t = c_uint;
pub type uint_fast64_t = c_ulonglong;
pub type __quad_t = c_longlong;
pub type __u_quad_t = c_ulonglong;
pub type __intmax_t = c_longlong;
pub type __uintmax_t = c_ulonglong;
pub type __squad_type = crate::__int64_t;
pub type __uquad_type = crate::__uint64_t;
pub type __sword_type = c_int;
pub type __uword_type = c_uint;
pub type __slong32_type = c_long;
pub type __ulong32_type = c_ulong;
pub type __s64_type = crate::__int64_t;
pub type __u64_type = crate::__uint64_t;
pub type __ipc_pid_t = c_ushort;
pub type Elf32_Half = u16;
pub type Elf32_Word = u32;
pub type Elf32_Off = u32;
pub type Elf32_Addr = u32;
pub type Elf32_Section = u16;
pub type Elf_Addr = crate::Elf32_Addr;
pub type Elf_Half = crate::Elf32_Half;
pub type Elf_Ehdr = crate::Elf32_Ehdr;
pub type Elf_Phdr = crate::Elf32_Phdr;
pub type Elf_Shdr = crate::Elf32_Shdr;
pub type Elf_Sym = crate::Elf32_Sym;
s! {
pub struct Elf32_Ehdr {
pub e_ident: [c_uchar; 16],
pub e_type: Elf32_Half,
pub e_machine: Elf32_Half,
pub e_version: Elf32_Word,
pub e_entry: Elf32_Addr,
pub e_phoff: Elf32_Off,
pub e_shoff: Elf32_Off,
pub e_flags: Elf32_Word,
pub e_ehsize: Elf32_Half,
pub e_phentsize: Elf32_Half,
pub e_phnum: Elf32_Half,
pub e_shentsize: Elf32_Half,
pub e_shnum: Elf32_Half,
pub e_shstrndx: Elf32_Half,
}
pub struct Elf32_Shdr {
pub sh_name: Elf32_Word,
pub sh_type: Elf32_Word,
pub sh_flags: Elf32_Word,
pub sh_addr: Elf32_Addr,
pub sh_offset: Elf32_Off,
pub sh_size: Elf32_Word,
pub sh_link: Elf32_Word,
pub sh_info: Elf32_Word,
pub sh_addralign: Elf32_Word,
pub sh_entsize: Elf32_Word,
}
pub struct Elf32_Sym {
pub st_name: Elf32_Word,
pub st_value: Elf32_Addr,
pub st_size: Elf32_Word,
pub st_info: c_uchar,
pub st_other: c_uchar,
pub st_shndx: Elf32_Section,
}
pub struct Elf32_Phdr {
pub p_type: crate::Elf32_Word,
pub p_offset: crate::Elf32_Off,
pub p_vaddr: crate::Elf32_Addr,
pub p_paddr: crate::Elf32_Addr,
pub p_filesz: crate::Elf32_Word,
pub p_memsz: crate::Elf32_Word,
pub p_flags: crate::Elf32_Word,
pub p_align: crate::Elf32_Word,
}
}

94
vendor/libc/src/unix/hurd/b64.rs vendored Normal file
View File

@@ -0,0 +1,94 @@
use crate::prelude::*;
pub type __int64_t = c_long;
pub type __uint64_t = c_ulong;
pub type int_fast16_t = c_long;
pub type int_fast32_t = c_long;
pub type int_fast64_t = c_long;
pub type uint_fast16_t = c_ulong;
pub type uint_fast32_t = c_ulong;
pub type uint_fast64_t = c_ulong;
pub type __quad_t = c_long;
pub type __u_quad_t = c_ulong;
pub type __intmax_t = c_long;
pub type __uintmax_t = c_ulong;
pub type __squad_type = c_long;
pub type __uquad_type = c_ulong;
pub type __sword_type = c_long;
pub type __uword_type = c_ulong;
pub type __slong32_type = c_int;
pub type __ulong32_type = c_uint;
pub type __s64_type = c_long;
pub type __u64_type = c_ulong;
pub type __ipc_pid_t = c_int;
pub type Elf64_Half = u16;
pub type Elf64_Word = u32;
pub type Elf64_Off = u64;
pub type Elf64_Addr = u64;
pub type Elf64_Xword = u64;
pub type Elf64_Sxword = i64;
pub type Elf64_Section = u16;
pub type Elf_Addr = crate::Elf64_Addr;
pub type Elf_Half = crate::Elf64_Half;
pub type Elf_Ehdr = crate::Elf64_Ehdr;
pub type Elf_Phdr = crate::Elf64_Phdr;
pub type Elf_Shdr = crate::Elf64_Shdr;
pub type Elf_Sym = crate::Elf64_Sym;
s! {
pub struct Elf64_Ehdr {
pub e_ident: [c_uchar; 16],
pub e_type: Elf64_Half,
pub e_machine: Elf64_Half,
pub e_version: Elf64_Word,
pub e_entry: Elf64_Addr,
pub e_phoff: Elf64_Off,
pub e_shoff: Elf64_Off,
pub e_flags: Elf64_Word,
pub e_ehsize: Elf64_Half,
pub e_phentsize: Elf64_Half,
pub e_phnum: Elf64_Half,
pub e_shentsize: Elf64_Half,
pub e_shnum: Elf64_Half,
pub e_shstrndx: Elf64_Half,
}
pub struct Elf64_Shdr {
pub sh_name: Elf64_Word,
pub sh_type: Elf64_Word,
pub sh_flags: Elf64_Xword,
pub sh_addr: Elf64_Addr,
pub sh_offset: Elf64_Off,
pub sh_size: Elf64_Xword,
pub sh_link: Elf64_Word,
pub sh_info: Elf64_Word,
pub sh_addralign: Elf64_Xword,
pub sh_entsize: Elf64_Xword,
}
pub struct Elf64_Sym {
pub st_name: Elf64_Word,
pub st_info: c_uchar,
pub st_other: c_uchar,
pub st_shndx: Elf64_Section,
pub st_value: Elf64_Addr,
pub st_size: Elf64_Xword,
}
pub struct Elf64_Phdr {
pub p_type: crate::Elf64_Word,
pub p_flags: crate::Elf64_Word,
pub p_offset: crate::Elf64_Off,
pub p_vaddr: crate::Elf64_Addr,
pub p_paddr: crate::Elf64_Addr,
pub p_filesz: crate::Elf64_Xword,
pub p_memsz: crate::Elf64_Xword,
pub p_align: crate::Elf64_Xword,
}
}

4623
vendor/libc/src/unix/hurd/mod.rs vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,532 @@
use crate::prelude::*;
pub type wchar_t = u32;
pub type greg_t = i32;
pub type mcontext_t = sigcontext;
s! {
pub struct sigcontext {
pub trap_no: c_ulong,
pub error_code: c_ulong,
pub oldmask: c_ulong,
pub arm_r0: c_ulong,
pub arm_r1: c_ulong,
pub arm_r2: c_ulong,
pub arm_r3: c_ulong,
pub arm_r4: c_ulong,
pub arm_r5: c_ulong,
pub arm_r6: c_ulong,
pub arm_r7: c_ulong,
pub arm_r8: c_ulong,
pub arm_r9: c_ulong,
pub arm_r10: c_ulong,
pub arm_fp: c_ulong,
pub arm_ip: c_ulong,
pub arm_sp: c_ulong,
pub arm_lr: c_ulong,
pub arm_pc: c_ulong,
pub arm_cpsr: c_ulong,
pub fault_address: c_ulong,
}
}
s_no_extra_traits! {
pub struct __c_anonymous_uc_sigmask_with_padding {
pub uc_sigmask: crate::sigset_t,
/* Android has a wrong (smaller) sigset_t on x86. */
__padding_rt_sigset: u32,
}
pub union __c_anonymous_uc_sigmask {
uc_sigmask: __c_anonymous_uc_sigmask_with_padding,
uc_sigmask64: crate::sigset64_t,
}
pub struct ucontext_t {
pub uc_flags: c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: crate::stack_t,
pub uc_mcontext: mcontext_t,
pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask,
/* The kernel adds extra padding after uc_sigmask to match
* glibc sigset_t on ARM. */
__padding: [c_char; 120],
__align: [c_longlong; 0],
uc_regspace: [c_ulong; 128],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for __c_anonymous_uc_sigmask_with_padding {
fn eq(&self, other: &__c_anonymous_uc_sigmask_with_padding) -> bool {
self.uc_sigmask == other.uc_sigmask
// Ignore padding
}
}
impl Eq for __c_anonymous_uc_sigmask_with_padding {}
impl hash::Hash for __c_anonymous_uc_sigmask_with_padding {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.uc_sigmask.hash(state)
// Ignore padding
}
}
impl PartialEq for __c_anonymous_uc_sigmask {
fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool {
unsafe { self.uc_sigmask == other.uc_sigmask }
}
}
impl Eq for __c_anonymous_uc_sigmask {}
impl hash::Hash for __c_anonymous_uc_sigmask {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
unsafe { self.uc_sigmask.hash(state) }
}
}
impl PartialEq for ucontext_t {
fn eq(&self, other: &Self) -> bool {
self.uc_flags == other.uc_flags
&& self.uc_link == other.uc_link
&& self.uc_stack == other.uc_stack
&& self.uc_mcontext == other.uc_mcontext
&& self.uc_sigmask__c_anonymous_union == other.uc_sigmask__c_anonymous_union
&& &self.uc_regspace[..] == &other.uc_regspace[..]
// Ignore padding field
}
}
impl Eq for ucontext_t {}
impl hash::Hash for ucontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.uc_flags.hash(state);
self.uc_link.hash(state);
self.uc_stack.hash(state);
self.uc_mcontext.hash(state);
self.uc_sigmask__c_anonymous_union.hash(state);
self.uc_regspace[..].hash(state);
// Ignore padding field
}
}
}
}
pub const O_DIRECT: c_int = 0x10000;
pub const O_DIRECTORY: c_int = 0x4000;
pub const O_NOFOLLOW: c_int = 0x8000;
pub const O_LARGEFILE: c_int = 0o400000;
pub const SYS_restart_syscall: c_long = 0;
pub const SYS_exit: c_long = 1;
pub const SYS_fork: c_long = 2;
pub const SYS_read: c_long = 3;
pub const SYS_write: c_long = 4;
pub const SYS_open: c_long = 5;
pub const SYS_close: c_long = 6;
pub const SYS_creat: c_long = 8;
pub const SYS_link: c_long = 9;
pub const SYS_unlink: c_long = 10;
pub const SYS_execve: c_long = 11;
pub const SYS_chdir: c_long = 12;
pub const SYS_mknod: c_long = 14;
pub const SYS_chmod: c_long = 15;
pub const SYS_lchown: c_long = 16;
pub const SYS_lseek: c_long = 19;
pub const SYS_getpid: c_long = 20;
pub const SYS_mount: c_long = 21;
pub const SYS_setuid: c_long = 23;
pub const SYS_getuid: c_long = 24;
pub const SYS_ptrace: c_long = 26;
pub const SYS_pause: c_long = 29;
pub const SYS_access: c_long = 33;
pub const SYS_nice: c_long = 34;
pub const SYS_sync: c_long = 36;
pub const SYS_kill: c_long = 37;
pub const SYS_rename: c_long = 38;
pub const SYS_mkdir: c_long = 39;
pub const SYS_rmdir: c_long = 40;
pub const SYS_dup: c_long = 41;
pub const SYS_pipe: c_long = 42;
pub const SYS_times: c_long = 43;
pub const SYS_brk: c_long = 45;
pub const SYS_setgid: c_long = 46;
pub const SYS_getgid: c_long = 47;
pub const SYS_geteuid: c_long = 49;
pub const SYS_getegid: c_long = 50;
pub const SYS_acct: c_long = 51;
pub const SYS_umount2: c_long = 52;
pub const SYS_ioctl: c_long = 54;
pub const SYS_fcntl: c_long = 55;
pub const SYS_setpgid: c_long = 57;
pub const SYS_umask: c_long = 60;
pub const SYS_chroot: c_long = 61;
pub const SYS_ustat: c_long = 62;
pub const SYS_dup2: c_long = 63;
pub const SYS_getppid: c_long = 64;
pub const SYS_getpgrp: c_long = 65;
pub const SYS_setsid: c_long = 66;
pub const SYS_sigaction: c_long = 67;
pub const SYS_setreuid: c_long = 70;
pub const SYS_setregid: c_long = 71;
pub const SYS_sigsuspend: c_long = 72;
pub const SYS_sigpending: c_long = 73;
pub const SYS_sethostname: c_long = 74;
pub const SYS_setrlimit: c_long = 75;
pub const SYS_getrusage: c_long = 77;
pub const SYS_gettimeofday: c_long = 78;
pub const SYS_settimeofday: c_long = 79;
pub const SYS_getgroups: c_long = 80;
pub const SYS_setgroups: c_long = 81;
pub const SYS_symlink: c_long = 83;
pub const SYS_readlink: c_long = 85;
pub const SYS_uselib: c_long = 86;
pub const SYS_swapon: c_long = 87;
pub const SYS_reboot: c_long = 88;
pub const SYS_munmap: c_long = 91;
pub const SYS_truncate: c_long = 92;
pub const SYS_ftruncate: c_long = 93;
pub const SYS_fchmod: c_long = 94;
pub const SYS_fchown: c_long = 95;
pub const SYS_getpriority: c_long = 96;
pub const SYS_setpriority: c_long = 97;
pub const SYS_statfs: c_long = 99;
pub const SYS_fstatfs: c_long = 100;
pub const SYS_syslog: c_long = 103;
pub const SYS_setitimer: c_long = 104;
pub const SYS_getitimer: c_long = 105;
pub const SYS_stat: c_long = 106;
pub const SYS_lstat: c_long = 107;
pub const SYS_fstat: c_long = 108;
pub const SYS_vhangup: c_long = 111;
pub const SYS_wait4: c_long = 114;
pub const SYS_swapoff: c_long = 115;
pub const SYS_sysinfo: c_long = 116;
pub const SYS_fsync: c_long = 118;
pub const SYS_sigreturn: c_long = 119;
pub const SYS_clone: c_long = 120;
pub const SYS_setdomainname: c_long = 121;
pub const SYS_uname: c_long = 122;
pub const SYS_adjtimex: c_long = 124;
pub const SYS_mprotect: c_long = 125;
pub const SYS_sigprocmask: c_long = 126;
pub const SYS_init_module: c_long = 128;
pub const SYS_delete_module: c_long = 129;
pub const SYS_quotactl: c_long = 131;
pub const SYS_getpgid: c_long = 132;
pub const SYS_fchdir: c_long = 133;
pub const SYS_bdflush: c_long = 134;
pub const SYS_sysfs: c_long = 135;
pub const SYS_personality: c_long = 136;
pub const SYS_setfsuid: c_long = 138;
pub const SYS_setfsgid: c_long = 139;
pub const SYS_getdents: c_long = 141;
pub const SYS_flock: c_long = 143;
pub const SYS_msync: c_long = 144;
pub const SYS_readv: c_long = 145;
pub const SYS_writev: c_long = 146;
pub const SYS_getsid: c_long = 147;
pub const SYS_fdatasync: c_long = 148;
pub const SYS_mlock: c_long = 150;
pub const SYS_munlock: c_long = 151;
pub const SYS_mlockall: c_long = 152;
pub const SYS_munlockall: c_long = 153;
pub const SYS_sched_setparam: c_long = 154;
pub const SYS_sched_getparam: c_long = 155;
pub const SYS_sched_setscheduler: c_long = 156;
pub const SYS_sched_getscheduler: c_long = 157;
pub const SYS_sched_yield: c_long = 158;
pub const SYS_sched_get_priority_max: c_long = 159;
pub const SYS_sched_get_priority_min: c_long = 160;
pub const SYS_sched_rr_get_interval: c_long = 161;
pub const SYS_nanosleep: c_long = 162;
pub const SYS_mremap: c_long = 163;
pub const SYS_setresuid: c_long = 164;
pub const SYS_getresuid: c_long = 165;
pub const SYS_poll: c_long = 168;
pub const SYS_nfsservctl: c_long = 169;
pub const SYS_setresgid: c_long = 170;
pub const SYS_getresgid: c_long = 171;
pub const SYS_prctl: c_long = 172;
pub const SYS_rt_sigreturn: c_long = 173;
pub const SYS_rt_sigaction: c_long = 174;
pub const SYS_rt_sigprocmask: c_long = 175;
pub const SYS_rt_sigpending: c_long = 176;
pub const SYS_rt_sigtimedwait: c_long = 177;
pub const SYS_rt_sigqueueinfo: c_long = 178;
pub const SYS_rt_sigsuspend: c_long = 179;
pub const SYS_pread64: c_long = 180;
pub const SYS_pwrite64: c_long = 181;
pub const SYS_chown: c_long = 182;
pub const SYS_getcwd: c_long = 183;
pub const SYS_capget: c_long = 184;
pub const SYS_capset: c_long = 185;
pub const SYS_sigaltstack: c_long = 186;
pub const SYS_sendfile: c_long = 187;
pub const SYS_vfork: c_long = 190;
pub const SYS_ugetrlimit: c_long = 191;
pub const SYS_mmap2: c_long = 192;
pub const SYS_truncate64: c_long = 193;
pub const SYS_ftruncate64: c_long = 194;
pub const SYS_stat64: c_long = 195;
pub const SYS_lstat64: c_long = 196;
pub const SYS_fstat64: c_long = 197;
pub const SYS_lchown32: c_long = 198;
pub const SYS_getuid32: c_long = 199;
pub const SYS_getgid32: c_long = 200;
pub const SYS_geteuid32: c_long = 201;
pub const SYS_getegid32: c_long = 202;
pub const SYS_setreuid32: c_long = 203;
pub const SYS_setregid32: c_long = 204;
pub const SYS_getgroups32: c_long = 205;
pub const SYS_setgroups32: c_long = 206;
pub const SYS_fchown32: c_long = 207;
pub const SYS_setresuid32: c_long = 208;
pub const SYS_getresuid32: c_long = 209;
pub const SYS_setresgid32: c_long = 210;
pub const SYS_getresgid32: c_long = 211;
pub const SYS_chown32: c_long = 212;
pub const SYS_setuid32: c_long = 213;
pub const SYS_setgid32: c_long = 214;
pub const SYS_setfsuid32: c_long = 215;
pub const SYS_setfsgid32: c_long = 216;
pub const SYS_getdents64: c_long = 217;
pub const SYS_pivot_root: c_long = 218;
pub const SYS_mincore: c_long = 219;
pub const SYS_madvise: c_long = 220;
pub const SYS_fcntl64: c_long = 221;
pub const SYS_gettid: c_long = 224;
pub const SYS_readahead: c_long = 225;
pub const SYS_setxattr: c_long = 226;
pub const SYS_lsetxattr: c_long = 227;
pub const SYS_fsetxattr: c_long = 228;
pub const SYS_getxattr: c_long = 229;
pub const SYS_lgetxattr: c_long = 230;
pub const SYS_fgetxattr: c_long = 231;
pub const SYS_listxattr: c_long = 232;
pub const SYS_llistxattr: c_long = 233;
pub const SYS_flistxattr: c_long = 234;
pub const SYS_removexattr: c_long = 235;
pub const SYS_lremovexattr: c_long = 236;
pub const SYS_fremovexattr: c_long = 237;
pub const SYS_tkill: c_long = 238;
pub const SYS_sendfile64: c_long = 239;
pub const SYS_futex: c_long = 240;
pub const SYS_sched_setaffinity: c_long = 241;
pub const SYS_sched_getaffinity: c_long = 242;
pub const SYS_io_setup: c_long = 243;
pub const SYS_io_destroy: c_long = 244;
pub const SYS_io_getevents: c_long = 245;
pub const SYS_io_submit: c_long = 246;
pub const SYS_io_cancel: c_long = 247;
pub const SYS_exit_group: c_long = 248;
pub const SYS_lookup_dcookie: c_long = 249;
pub const SYS_epoll_create: c_long = 250;
pub const SYS_epoll_ctl: c_long = 251;
pub const SYS_epoll_wait: c_long = 252;
pub const SYS_remap_file_pages: c_long = 253;
pub const SYS_set_tid_address: c_long = 256;
pub const SYS_timer_create: c_long = 257;
pub const SYS_timer_settime: c_long = 258;
pub const SYS_timer_gettime: c_long = 259;
pub const SYS_timer_getoverrun: c_long = 260;
pub const SYS_timer_delete: c_long = 261;
pub const SYS_clock_settime: c_long = 262;
pub const SYS_clock_gettime: c_long = 263;
pub const SYS_clock_getres: c_long = 264;
pub const SYS_clock_nanosleep: c_long = 265;
pub const SYS_statfs64: c_long = 266;
pub const SYS_fstatfs64: c_long = 267;
pub const SYS_tgkill: c_long = 268;
pub const SYS_utimes: c_long = 269;
pub const SYS_arm_fadvise64_64: c_long = 270;
pub const SYS_pciconfig_iobase: c_long = 271;
pub const SYS_pciconfig_read: c_long = 272;
pub const SYS_pciconfig_write: c_long = 273;
pub const SYS_mq_open: c_long = 274;
pub const SYS_mq_unlink: c_long = 275;
pub const SYS_mq_timedsend: c_long = 276;
pub const SYS_mq_timedreceive: c_long = 277;
pub const SYS_mq_notify: c_long = 278;
pub const SYS_mq_getsetattr: c_long = 279;
pub const SYS_waitid: c_long = 280;
pub const SYS_socket: c_long = 281;
pub const SYS_bind: c_long = 282;
pub const SYS_connect: c_long = 283;
pub const SYS_listen: c_long = 284;
pub const SYS_accept: c_long = 285;
pub const SYS_getsockname: c_long = 286;
pub const SYS_getpeername: c_long = 287;
pub const SYS_socketpair: c_long = 288;
pub const SYS_send: c_long = 289;
pub const SYS_sendto: c_long = 290;
pub const SYS_recv: c_long = 291;
pub const SYS_recvfrom: c_long = 292;
pub const SYS_shutdown: c_long = 293;
pub const SYS_setsockopt: c_long = 294;
pub const SYS_getsockopt: c_long = 295;
pub const SYS_sendmsg: c_long = 296;
pub const SYS_recvmsg: c_long = 297;
pub const SYS_semop: c_long = 298;
pub const SYS_semget: c_long = 299;
pub const SYS_semctl: c_long = 300;
pub const SYS_msgsnd: c_long = 301;
pub const SYS_msgrcv: c_long = 302;
pub const SYS_msgget: c_long = 303;
pub const SYS_msgctl: c_long = 304;
pub const SYS_shmat: c_long = 305;
pub const SYS_shmdt: c_long = 306;
pub const SYS_shmget: c_long = 307;
pub const SYS_shmctl: c_long = 308;
pub const SYS_add_key: c_long = 309;
pub const SYS_request_key: c_long = 310;
pub const SYS_keyctl: c_long = 311;
pub const SYS_semtimedop: c_long = 312;
pub const SYS_vserver: c_long = 313;
pub const SYS_ioprio_set: c_long = 314;
pub const SYS_ioprio_get: c_long = 315;
pub const SYS_inotify_init: c_long = 316;
pub const SYS_inotify_add_watch: c_long = 317;
pub const SYS_inotify_rm_watch: c_long = 318;
pub const SYS_mbind: c_long = 319;
pub const SYS_get_mempolicy: c_long = 320;
pub const SYS_set_mempolicy: c_long = 321;
pub const SYS_openat: c_long = 322;
pub const SYS_mkdirat: c_long = 323;
pub const SYS_mknodat: c_long = 324;
pub const SYS_fchownat: c_long = 325;
pub const SYS_futimesat: c_long = 326;
pub const SYS_fstatat64: c_long = 327;
pub const SYS_unlinkat: c_long = 328;
pub const SYS_renameat: c_long = 329;
pub const SYS_linkat: c_long = 330;
pub const SYS_symlinkat: c_long = 331;
pub const SYS_readlinkat: c_long = 332;
pub const SYS_fchmodat: c_long = 333;
pub const SYS_faccessat: c_long = 334;
pub const SYS_pselect6: c_long = 335;
pub const SYS_ppoll: c_long = 336;
pub const SYS_unshare: c_long = 337;
pub const SYS_set_robust_list: c_long = 338;
pub const SYS_get_robust_list: c_long = 339;
pub const SYS_splice: c_long = 340;
pub const SYS_arm_sync_file_range: c_long = 341;
pub const SYS_tee: c_long = 342;
pub const SYS_vmsplice: c_long = 343;
pub const SYS_move_pages: c_long = 344;
pub const SYS_getcpu: c_long = 345;
pub const SYS_epoll_pwait: c_long = 346;
pub const SYS_kexec_load: c_long = 347;
pub const SYS_utimensat: c_long = 348;
pub const SYS_signalfd: c_long = 349;
pub const SYS_timerfd_create: c_long = 350;
pub const SYS_eventfd: c_long = 351;
pub const SYS_fallocate: c_long = 352;
pub const SYS_timerfd_settime: c_long = 353;
pub const SYS_timerfd_gettime: c_long = 354;
pub const SYS_signalfd4: c_long = 355;
pub const SYS_eventfd2: c_long = 356;
pub const SYS_epoll_create1: c_long = 357;
pub const SYS_dup3: c_long = 358;
pub const SYS_pipe2: c_long = 359;
pub const SYS_inotify_init1: c_long = 360;
pub const SYS_preadv: c_long = 361;
pub const SYS_pwritev: c_long = 362;
pub const SYS_rt_tgsigqueueinfo: c_long = 363;
pub const SYS_perf_event_open: c_long = 364;
pub const SYS_recvmmsg: c_long = 365;
pub const SYS_accept4: c_long = 366;
pub const SYS_fanotify_init: c_long = 367;
pub const SYS_fanotify_mark: c_long = 368;
pub const SYS_prlimit64: c_long = 369;
pub const SYS_name_to_handle_at: c_long = 370;
pub const SYS_open_by_handle_at: c_long = 371;
pub const SYS_clock_adjtime: c_long = 372;
pub const SYS_syncfs: c_long = 373;
pub const SYS_sendmmsg: c_long = 374;
pub const SYS_setns: c_long = 375;
pub const SYS_process_vm_readv: c_long = 376;
pub const SYS_process_vm_writev: c_long = 377;
pub const SYS_kcmp: c_long = 378;
pub const SYS_finit_module: c_long = 379;
pub const SYS_sched_setattr: c_long = 380;
pub const SYS_sched_getattr: c_long = 381;
pub const SYS_renameat2: c_long = 382;
pub const SYS_seccomp: c_long = 383;
pub const SYS_getrandom: c_long = 384;
pub const SYS_memfd_create: c_long = 385;
pub const SYS_bpf: c_long = 386;
pub const SYS_execveat: c_long = 387;
pub const SYS_userfaultfd: c_long = 388;
pub const SYS_membarrier: c_long = 389;
pub const SYS_mlock2: c_long = 390;
pub const SYS_copy_file_range: c_long = 391;
pub const SYS_preadv2: c_long = 392;
pub const SYS_pwritev2: c_long = 393;
pub const SYS_pkey_mprotect: c_long = 394;
pub const SYS_pkey_alloc: c_long = 395;
pub const SYS_pkey_free: c_long = 396;
pub const SYS_statx: c_long = 397;
pub const SYS_pidfd_send_signal: c_long = 424;
pub const SYS_io_uring_setup: c_long = 425;
pub const SYS_io_uring_enter: c_long = 426;
pub const SYS_io_uring_register: c_long = 427;
pub const SYS_open_tree: c_long = 428;
pub const SYS_move_mount: c_long = 429;
pub const SYS_fsopen: c_long = 430;
pub const SYS_fsconfig: c_long = 431;
pub const SYS_fsmount: c_long = 432;
pub const SYS_fspick: c_long = 433;
pub const SYS_pidfd_open: c_long = 434;
pub const SYS_clone3: c_long = 435;
pub const SYS_close_range: c_long = 436;
pub const SYS_openat2: c_long = 437;
pub const SYS_pidfd_getfd: c_long = 438;
pub const SYS_faccessat2: c_long = 439;
pub const SYS_process_madvise: c_long = 440;
pub const SYS_epoll_pwait2: c_long = 441;
pub const SYS_mount_setattr: c_long = 442;
pub const SYS_quotactl_fd: c_long = 443;
pub const SYS_landlock_create_ruleset: c_long = 444;
pub const SYS_landlock_add_rule: c_long = 445;
pub const SYS_landlock_restrict_self: c_long = 446;
pub const SYS_process_mrelease: c_long = 448;
pub const SYS_futex_waitv: c_long = 449;
pub const SYS_set_mempolicy_home_node: c_long = 450;
// offsets in mcontext_t.gregs from sys/ucontext.h
pub const REG_R0: c_int = 0;
pub const REG_R1: c_int = 1;
pub const REG_R2: c_int = 2;
pub const REG_R3: c_int = 3;
pub const REG_R4: c_int = 4;
pub const REG_R5: c_int = 5;
pub const REG_R6: c_int = 6;
pub const REG_R7: c_int = 7;
pub const REG_R8: c_int = 8;
pub const REG_R9: c_int = 9;
pub const REG_R10: c_int = 10;
pub const REG_R11: c_int = 11;
pub const REG_R12: c_int = 12;
pub const REG_R13: c_int = 13;
pub const REG_R14: c_int = 14;
pub const REG_R15: c_int = 15;
pub const NGREG: c_int = 18;
// From NDK's asm/auxvec.h
pub const AT_SYSINFO_EHDR: c_ulong = 33;
f! {
// Sadly, Android before 5.0 (API level 21), the accept4 syscall is not
// exposed by the libc. As work-around, we implement it through `syscall`
// directly. This workaround can be removed if the minimum version of
// Android is bumped. When the workaround is removed, `accept4` can be
// moved back to `linux_like/mod.rs`
pub fn accept4(
fd: c_int,
addr: *mut crate::sockaddr,
len: *mut crate::socklen_t,
flg: c_int,
) -> c_int {
crate::syscall(SYS_accept4, fd, addr, len, flg) as c_int
}
}

View File

@@ -0,0 +1,239 @@
use crate::prelude::*;
// The following definitions are correct for arm and i686,
// but may be wrong for mips
pub type mode_t = u16;
pub type off64_t = c_longlong;
pub type sigset_t = c_ulong;
pub type socklen_t = i32;
pub type time64_t = i64;
pub type __u64 = c_ulonglong;
pub type __s64 = c_longlong;
s! {
// FIXME(1.0): This should not implement `PartialEq`
#[allow(unpredictable_function_pointer_comparisons)]
pub struct sigaction {
pub sa_sigaction: crate::sighandler_t,
pub sa_mask: crate::sigset_t,
pub sa_flags: c_int,
pub sa_restorer: Option<extern "C" fn()>,
}
pub struct rlimit64 {
pub rlim_cur: u64,
pub rlim_max: u64,
}
pub struct stat {
pub st_dev: c_ulonglong,
__pad0: [c_uchar; 4],
__st_ino: crate::ino_t,
pub st_mode: c_uint,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: c_ulonglong,
__pad3: [c_uchar; 4],
pub st_size: c_longlong,
pub st_blksize: crate::blksize_t,
pub st_blocks: c_ulonglong,
pub st_atime: c_long,
pub st_atime_nsec: c_long,
pub st_mtime: c_long,
pub st_mtime_nsec: c_long,
pub st_ctime: c_long,
pub st_ctime_nsec: c_long,
pub st_ino: c_ulonglong,
}
pub struct stat64 {
pub st_dev: c_ulonglong,
__pad0: [c_uchar; 4],
__st_ino: crate::ino_t,
pub st_mode: c_uint,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: c_ulonglong,
__pad3: [c_uchar; 4],
pub st_size: c_longlong,
pub st_blksize: crate::blksize_t,
pub st_blocks: c_ulonglong,
pub st_atime: c_long,
pub st_atime_nsec: c_long,
pub st_mtime: c_long,
pub st_mtime_nsec: c_long,
pub st_ctime: c_long,
pub st_ctime_nsec: c_long,
pub st_ino: c_ulonglong,
}
pub struct statfs64 {
pub f_type: u32,
pub f_bsize: u32,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: u64,
pub f_files: u64,
pub f_ffree: u64,
pub f_fsid: crate::__fsid_t,
pub f_namelen: u32,
pub f_frsize: u32,
pub f_flags: u32,
pub f_spare: [u32; 4],
}
pub struct statvfs64 {
pub f_bsize: c_ulong,
pub f_frsize: c_ulong,
pub f_blocks: c_ulong,
pub f_bfree: c_ulong,
pub f_bavail: c_ulong,
pub f_files: c_ulong,
pub f_ffree: c_ulong,
pub f_favail: c_ulong,
pub f_fsid: c_ulong,
pub f_flag: c_ulong,
pub f_namemax: c_ulong,
}
pub struct pthread_attr_t {
pub flags: u32,
pub stack_base: *mut c_void,
pub stack_size: size_t,
pub guard_size: size_t,
pub sched_policy: i32,
pub sched_priority: i32,
}
pub struct pthread_mutex_t {
value: c_int,
}
pub struct pthread_cond_t {
value: c_int,
}
pub struct pthread_rwlock_t {
lock: pthread_mutex_t,
cond: pthread_cond_t,
numLocks: c_int,
writerThreadId: c_int,
pendingReaders: c_int,
pendingWriters: c_int,
attr: i32,
__reserved: [c_char; 12],
}
pub struct pthread_barrier_t {
__private: [i32; 8],
}
pub struct pthread_spinlock_t {
__private: [i32; 2],
}
pub struct passwd {
pub pw_name: *mut c_char,
pub pw_passwd: *mut c_char,
pub pw_uid: crate::uid_t,
pub pw_gid: crate::gid_t,
pub pw_dir: *mut c_char,
pub pw_shell: *mut c_char,
}
pub struct statfs {
pub f_type: u32,
pub f_bsize: u32,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: u64,
pub f_files: u64,
pub f_ffree: u64,
pub f_fsid: crate::__fsid_t,
pub f_namelen: u32,
pub f_frsize: u32,
pub f_flags: u32,
pub f_spare: [u32; 4],
}
pub struct sysinfo {
pub uptime: c_long,
pub loads: [c_ulong; 3],
pub totalram: c_ulong,
pub freeram: c_ulong,
pub sharedram: c_ulong,
pub bufferram: c_ulong,
pub totalswap: c_ulong,
pub freeswap: c_ulong,
pub procs: c_ushort,
pub pad: c_ushort,
pub totalhigh: c_ulong,
pub freehigh: c_ulong,
pub mem_unit: c_uint,
pub _f: [c_char; 8],
}
}
s_no_extra_traits! {
pub struct sigset64_t {
__bits: [c_ulong; 2],
}
}
// These constants must be of the same type of sigaction.sa_flags
pub const SA_NOCLDSTOP: c_int = 0x00000001;
pub const SA_NOCLDWAIT: c_int = 0x00000002;
pub const SA_NODEFER: c_int = 0x40000000;
pub const SA_ONSTACK: c_int = 0x08000000;
pub const SA_RESETHAND: c_int = 0x80000000;
pub const SA_RESTART: c_int = 0x10000000;
pub const SA_SIGINFO: c_int = 0x00000004;
pub const RTLD_GLOBAL: c_int = 2;
pub const RTLD_NOW: c_int = 0;
pub const RTLD_DEFAULT: *mut c_void = -1isize as *mut c_void;
pub const PTRACE_GETFPREGS: c_int = 14;
pub const PTRACE_SETFPREGS: c_int = 15;
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0 };
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { value: 0 };
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
lock: PTHREAD_MUTEX_INITIALIZER,
cond: PTHREAD_COND_INITIALIZER,
numLocks: 0,
writerThreadId: 0,
pendingReaders: 0,
pendingWriters: 0,
attr: 0,
__reserved: [0; 12],
};
pub const PTHREAD_STACK_MIN: size_t = 4096 * 2;
pub const CPU_SETSIZE: size_t = 32;
pub const __CPU_BITS: size_t = 32;
pub const UT_LINESIZE: usize = 8;
pub const UT_NAMESIZE: usize = 8;
pub const UT_HOSTSIZE: usize = 16;
pub const SIGSTKSZ: size_t = 8192;
pub const MINSIGSTKSZ: size_t = 2048;
extern "C" {
pub fn timegm64(tm: *const crate::tm) -> crate::time64_t;
}
cfg_if! {
if #[cfg(target_arch = "x86")] {
mod x86;
pub use self::x86::*;
} else if #[cfg(target_arch = "arm")] {
mod arm;
pub use self::arm::*;
} else {
// Unknown target_arch
}
}

View File

@@ -0,0 +1,604 @@
use crate::prelude::*;
pub type wchar_t = i32;
pub type greg_t = i32;
s! {
pub struct _libc_fpreg {
pub significand: [u16; 4],
pub exponent: u16,
}
pub struct _libc_fpstate {
pub cw: c_ulong,
pub sw: c_ulong,
pub tag: c_ulong,
pub ipoff: c_ulong,
pub cssel: c_ulong,
pub dataoff: c_ulong,
pub datasel: c_ulong,
pub _st: [_libc_fpreg; 8],
pub status: c_ulong,
}
pub struct mcontext_t {
pub gregs: [greg_t; 19],
pub fpregs: *mut _libc_fpstate,
pub oldmask: c_ulong,
pub cr2: c_ulong,
}
}
s_no_extra_traits! {
pub struct __c_anonymous_uc_sigmask_with_padding {
pub uc_sigmask: crate::sigset_t,
/* Android has a wrong (smaller) sigset_t on x86. */
__padding_rt_sigset: u32,
}
pub union __c_anonymous_uc_sigmask {
uc_sigmask: __c_anonymous_uc_sigmask_with_padding,
uc_sigmask64: crate::sigset64_t,
}
pub struct ucontext_t {
pub uc_flags: c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: crate::stack_t,
pub uc_mcontext: mcontext_t,
pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask,
__padding_rt_sigset: u32,
__fpregs_mem: _libc_fpstate,
}
#[repr(align(8))]
pub struct max_align_t {
priv_: [f64; 2],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for __c_anonymous_uc_sigmask_with_padding {
fn eq(&self, other: &__c_anonymous_uc_sigmask_with_padding) -> bool {
self.uc_sigmask == other.uc_sigmask
// Ignore padding
}
}
impl Eq for __c_anonymous_uc_sigmask_with_padding {}
impl hash::Hash for __c_anonymous_uc_sigmask_with_padding {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.uc_sigmask.hash(state)
// Ignore padding
}
}
impl PartialEq for __c_anonymous_uc_sigmask {
fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool {
unsafe { self.uc_sigmask == other.uc_sigmask }
}
}
impl Eq for __c_anonymous_uc_sigmask {}
impl hash::Hash for __c_anonymous_uc_sigmask {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
unsafe { self.uc_sigmask.hash(state) }
}
}
impl PartialEq for ucontext_t {
fn eq(&self, other: &Self) -> bool {
self.uc_flags == other.uc_flags
&& self.uc_link == other.uc_link
&& self.uc_stack == other.uc_stack
&& self.uc_mcontext == other.uc_mcontext
&& self.uc_sigmask__c_anonymous_union == other.uc_sigmask__c_anonymous_union
// Ignore padding field
}
}
impl Eq for ucontext_t {}
impl hash::Hash for ucontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.uc_flags.hash(state);
self.uc_link.hash(state);
self.uc_stack.hash(state);
self.uc_mcontext.hash(state);
self.uc_sigmask__c_anonymous_union.hash(state);
// Ignore padding field
}
}
}
}
pub const O_DIRECT: c_int = 0x4000;
pub const O_DIRECTORY: c_int = 0x10000;
pub const O_NOFOLLOW: c_int = 0x20000;
pub const O_LARGEFILE: c_int = 0o0100000;
pub const MAP_32BIT: c_int = 0x40;
// Syscall table
pub const SYS_restart_syscall: c_long = 0;
pub const SYS_exit: c_long = 1;
pub const SYS_fork: c_long = 2;
pub const SYS_read: c_long = 3;
pub const SYS_write: c_long = 4;
pub const SYS_open: c_long = 5;
pub const SYS_close: c_long = 6;
pub const SYS_waitpid: c_long = 7;
pub const SYS_creat: c_long = 8;
pub const SYS_link: c_long = 9;
pub const SYS_unlink: c_long = 10;
pub const SYS_execve: c_long = 11;
pub const SYS_chdir: c_long = 12;
pub const SYS_time: c_long = 13;
pub const SYS_mknod: c_long = 14;
pub const SYS_chmod: c_long = 15;
pub const SYS_lchown: c_long = 16;
pub const SYS_break: c_long = 17;
pub const SYS_oldstat: c_long = 18;
pub const SYS_lseek: c_long = 19;
pub const SYS_getpid: c_long = 20;
pub const SYS_mount: c_long = 21;
pub const SYS_umount: c_long = 22;
pub const SYS_setuid: c_long = 23;
pub const SYS_getuid: c_long = 24;
pub const SYS_stime: c_long = 25;
pub const SYS_ptrace: c_long = 26;
pub const SYS_alarm: c_long = 27;
pub const SYS_oldfstat: c_long = 28;
pub const SYS_pause: c_long = 29;
pub const SYS_utime: c_long = 30;
pub const SYS_stty: c_long = 31;
pub const SYS_gtty: c_long = 32;
pub const SYS_access: c_long = 33;
pub const SYS_nice: c_long = 34;
pub const SYS_ftime: c_long = 35;
pub const SYS_sync: c_long = 36;
pub const SYS_kill: c_long = 37;
pub const SYS_rename: c_long = 38;
pub const SYS_mkdir: c_long = 39;
pub const SYS_rmdir: c_long = 40;
pub const SYS_dup: c_long = 41;
pub const SYS_pipe: c_long = 42;
pub const SYS_times: c_long = 43;
pub const SYS_prof: c_long = 44;
pub const SYS_brk: c_long = 45;
pub const SYS_setgid: c_long = 46;
pub const SYS_getgid: c_long = 47;
pub const SYS_signal: c_long = 48;
pub const SYS_geteuid: c_long = 49;
pub const SYS_getegid: c_long = 50;
pub const SYS_acct: c_long = 51;
pub const SYS_umount2: c_long = 52;
pub const SYS_lock: c_long = 53;
pub const SYS_ioctl: c_long = 54;
pub const SYS_fcntl: c_long = 55;
pub const SYS_mpx: c_long = 56;
pub const SYS_setpgid: c_long = 57;
pub const SYS_ulimit: c_long = 58;
pub const SYS_oldolduname: c_long = 59;
pub const SYS_umask: c_long = 60;
pub const SYS_chroot: c_long = 61;
pub const SYS_ustat: c_long = 62;
pub const SYS_dup2: c_long = 63;
pub const SYS_getppid: c_long = 64;
pub const SYS_getpgrp: c_long = 65;
pub const SYS_setsid: c_long = 66;
pub const SYS_sigaction: c_long = 67;
pub const SYS_sgetmask: c_long = 68;
pub const SYS_ssetmask: c_long = 69;
pub const SYS_setreuid: c_long = 70;
pub const SYS_setregid: c_long = 71;
pub const SYS_sigsuspend: c_long = 72;
pub const SYS_sigpending: c_long = 73;
pub const SYS_sethostname: c_long = 74;
pub const SYS_setrlimit: c_long = 75;
pub const SYS_getrlimit: c_long = 76;
pub const SYS_getrusage: c_long = 77;
pub const SYS_gettimeofday: c_long = 78;
pub const SYS_settimeofday: c_long = 79;
pub const SYS_getgroups: c_long = 80;
pub const SYS_setgroups: c_long = 81;
pub const SYS_select: c_long = 82;
pub const SYS_symlink: c_long = 83;
pub const SYS_oldlstat: c_long = 84;
pub const SYS_readlink: c_long = 85;
pub const SYS_uselib: c_long = 86;
pub const SYS_swapon: c_long = 87;
pub const SYS_reboot: c_long = 88;
pub const SYS_readdir: c_long = 89;
pub const SYS_mmap: c_long = 90;
pub const SYS_munmap: c_long = 91;
pub const SYS_truncate: c_long = 92;
pub const SYS_ftruncate: c_long = 93;
pub const SYS_fchmod: c_long = 94;
pub const SYS_fchown: c_long = 95;
pub const SYS_getpriority: c_long = 96;
pub const SYS_setpriority: c_long = 97;
pub const SYS_profil: c_long = 98;
pub const SYS_statfs: c_long = 99;
pub const SYS_fstatfs: c_long = 100;
pub const SYS_ioperm: c_long = 101;
pub const SYS_socketcall: c_long = 102;
pub const SYS_syslog: c_long = 103;
pub const SYS_setitimer: c_long = 104;
pub const SYS_getitimer: c_long = 105;
pub const SYS_stat: c_long = 106;
pub const SYS_lstat: c_long = 107;
pub const SYS_fstat: c_long = 108;
pub const SYS_olduname: c_long = 109;
pub const SYS_iopl: c_long = 110;
pub const SYS_vhangup: c_long = 111;
pub const SYS_idle: c_long = 112;
pub const SYS_vm86old: c_long = 113;
pub const SYS_wait4: c_long = 114;
pub const SYS_swapoff: c_long = 115;
pub const SYS_sysinfo: c_long = 116;
pub const SYS_ipc: c_long = 117;
pub const SYS_fsync: c_long = 118;
pub const SYS_sigreturn: c_long = 119;
pub const SYS_clone: c_long = 120;
pub const SYS_setdomainname: c_long = 121;
pub const SYS_uname: c_long = 122;
pub const SYS_modify_ldt: c_long = 123;
pub const SYS_adjtimex: c_long = 124;
pub const SYS_mprotect: c_long = 125;
pub const SYS_sigprocmask: c_long = 126;
#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")]
pub const SYS_create_module: c_long = 127;
pub const SYS_init_module: c_long = 128;
pub const SYS_delete_module: c_long = 129;
#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")]
pub const SYS_get_kernel_syms: c_long = 130;
pub const SYS_quotactl: c_long = 131;
pub const SYS_getpgid: c_long = 132;
pub const SYS_fchdir: c_long = 133;
pub const SYS_bdflush: c_long = 134;
pub const SYS_sysfs: c_long = 135;
pub const SYS_personality: c_long = 136;
pub const SYS_afs_syscall: c_long = 137;
pub const SYS_setfsuid: c_long = 138;
pub const SYS_setfsgid: c_long = 139;
// FIXME(android): SYS__llseek is in the NDK sources but for some reason is
// not available in the tests
// pub const SYS__llseek: c_long = 140;
pub const SYS_getdents: c_long = 141;
// FIXME(android): SYS__newselect is in the NDK sources but for some reason is
// not available in the tests
// pub const SYS__newselect: c_long = 142;
pub const SYS_flock: c_long = 143;
pub const SYS_msync: c_long = 144;
pub const SYS_readv: c_long = 145;
pub const SYS_writev: c_long = 146;
pub const SYS_getsid: c_long = 147;
pub const SYS_fdatasync: c_long = 148;
// FIXME(android): SYS__llseek is in the NDK sources but for some reason is
// not available in the tests
// pub const SYS__sysctl: c_long = 149;
pub const SYS_mlock: c_long = 150;
pub const SYS_munlock: c_long = 151;
pub const SYS_mlockall: c_long = 152;
pub const SYS_munlockall: c_long = 153;
pub const SYS_sched_setparam: c_long = 154;
pub const SYS_sched_getparam: c_long = 155;
pub const SYS_sched_setscheduler: c_long = 156;
pub const SYS_sched_getscheduler: c_long = 157;
pub const SYS_sched_yield: c_long = 158;
pub const SYS_sched_get_priority_max: c_long = 159;
pub const SYS_sched_get_priority_min: c_long = 160;
pub const SYS_sched_rr_get_interval: c_long = 161;
pub const SYS_nanosleep: c_long = 162;
pub const SYS_mremap: c_long = 163;
pub const SYS_setresuid: c_long = 164;
pub const SYS_getresuid: c_long = 165;
pub const SYS_vm86: c_long = 166;
#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")]
pub const SYS_query_module: c_long = 167;
pub const SYS_poll: c_long = 168;
pub const SYS_nfsservctl: c_long = 169;
pub const SYS_setresgid: c_long = 170;
pub const SYS_getresgid: c_long = 171;
pub const SYS_prctl: c_long = 172;
pub const SYS_rt_sigreturn: c_long = 173;
pub const SYS_rt_sigaction: c_long = 174;
pub const SYS_rt_sigprocmask: c_long = 175;
pub const SYS_rt_sigpending: c_long = 176;
pub const SYS_rt_sigtimedwait: c_long = 177;
pub const SYS_rt_sigqueueinfo: c_long = 178;
pub const SYS_rt_sigsuspend: c_long = 179;
pub const SYS_pread64: c_long = 180;
pub const SYS_pwrite64: c_long = 181;
pub const SYS_chown: c_long = 182;
pub const SYS_getcwd: c_long = 183;
pub const SYS_capget: c_long = 184;
pub const SYS_capset: c_long = 185;
pub const SYS_sigaltstack: c_long = 186;
pub const SYS_sendfile: c_long = 187;
pub const SYS_getpmsg: c_long = 188;
pub const SYS_putpmsg: c_long = 189;
pub const SYS_vfork: c_long = 190;
pub const SYS_ugetrlimit: c_long = 191;
pub const SYS_mmap2: c_long = 192;
pub const SYS_truncate64: c_long = 193;
pub const SYS_ftruncate64: c_long = 194;
pub const SYS_stat64: c_long = 195;
pub const SYS_lstat64: c_long = 196;
pub const SYS_fstat64: c_long = 197;
pub const SYS_lchown32: c_long = 198;
pub const SYS_getuid32: c_long = 199;
pub const SYS_getgid32: c_long = 200;
pub const SYS_geteuid32: c_long = 201;
pub const SYS_getegid32: c_long = 202;
pub const SYS_setreuid32: c_long = 203;
pub const SYS_setregid32: c_long = 204;
pub const SYS_getgroups32: c_long = 205;
pub const SYS_setgroups32: c_long = 206;
pub const SYS_fchown32: c_long = 207;
pub const SYS_setresuid32: c_long = 208;
pub const SYS_getresuid32: c_long = 209;
pub const SYS_setresgid32: c_long = 210;
pub const SYS_getresgid32: c_long = 211;
pub const SYS_chown32: c_long = 212;
pub const SYS_setuid32: c_long = 213;
pub const SYS_setgid32: c_long = 214;
pub const SYS_setfsuid32: c_long = 215;
pub const SYS_setfsgid32: c_long = 216;
pub const SYS_pivot_root: c_long = 217;
pub const SYS_mincore: c_long = 218;
pub const SYS_madvise: c_long = 219;
pub const SYS_getdents64: c_long = 220;
pub const SYS_fcntl64: c_long = 221;
pub const SYS_gettid: c_long = 224;
pub const SYS_readahead: c_long = 225;
pub const SYS_setxattr: c_long = 226;
pub const SYS_lsetxattr: c_long = 227;
pub const SYS_fsetxattr: c_long = 228;
pub const SYS_getxattr: c_long = 229;
pub const SYS_lgetxattr: c_long = 230;
pub const SYS_fgetxattr: c_long = 231;
pub const SYS_listxattr: c_long = 232;
pub const SYS_llistxattr: c_long = 233;
pub const SYS_flistxattr: c_long = 234;
pub const SYS_removexattr: c_long = 235;
pub const SYS_lremovexattr: c_long = 236;
pub const SYS_fremovexattr: c_long = 237;
pub const SYS_tkill: c_long = 238;
pub const SYS_sendfile64: c_long = 239;
pub const SYS_futex: c_long = 240;
pub const SYS_sched_setaffinity: c_long = 241;
pub const SYS_sched_getaffinity: c_long = 242;
pub const SYS_set_thread_area: c_long = 243;
pub const SYS_get_thread_area: c_long = 244;
pub const SYS_io_setup: c_long = 245;
pub const SYS_io_destroy: c_long = 246;
pub const SYS_io_getevents: c_long = 247;
pub const SYS_io_submit: c_long = 248;
pub const SYS_io_cancel: c_long = 249;
pub const SYS_fadvise64: c_long = 250;
pub const SYS_exit_group: c_long = 252;
pub const SYS_lookup_dcookie: c_long = 253;
pub const SYS_epoll_create: c_long = 254;
pub const SYS_epoll_ctl: c_long = 255;
pub const SYS_epoll_wait: c_long = 256;
pub const SYS_remap_file_pages: c_long = 257;
pub const SYS_set_tid_address: c_long = 258;
pub const SYS_timer_create: c_long = 259;
pub const SYS_timer_settime: c_long = 260;
pub const SYS_timer_gettime: c_long = 261;
pub const SYS_timer_getoverrun: c_long = 262;
pub const SYS_timer_delete: c_long = 263;
pub const SYS_clock_settime: c_long = 264;
pub const SYS_clock_gettime: c_long = 265;
pub const SYS_clock_getres: c_long = 266;
pub const SYS_clock_nanosleep: c_long = 267;
pub const SYS_statfs64: c_long = 268;
pub const SYS_fstatfs64: c_long = 269;
pub const SYS_tgkill: c_long = 270;
pub const SYS_utimes: c_long = 271;
pub const SYS_fadvise64_64: c_long = 272;
pub const SYS_vserver: c_long = 273;
pub const SYS_mbind: c_long = 274;
pub const SYS_get_mempolicy: c_long = 275;
pub const SYS_set_mempolicy: c_long = 276;
pub const SYS_mq_open: c_long = 277;
pub const SYS_mq_unlink: c_long = 278;
pub const SYS_mq_timedsend: c_long = 279;
pub const SYS_mq_timedreceive: c_long = 280;
pub const SYS_mq_notify: c_long = 281;
pub const SYS_mq_getsetattr: c_long = 282;
pub const SYS_kexec_load: c_long = 283;
pub const SYS_waitid: c_long = 284;
pub const SYS_add_key: c_long = 286;
pub const SYS_request_key: c_long = 287;
pub const SYS_keyctl: c_long = 288;
pub const SYS_ioprio_set: c_long = 289;
pub const SYS_ioprio_get: c_long = 290;
pub const SYS_inotify_init: c_long = 291;
pub const SYS_inotify_add_watch: c_long = 292;
pub const SYS_inotify_rm_watch: c_long = 293;
pub const SYS_migrate_pages: c_long = 294;
pub const SYS_openat: c_long = 295;
pub const SYS_mkdirat: c_long = 296;
pub const SYS_mknodat: c_long = 297;
pub const SYS_fchownat: c_long = 298;
pub const SYS_futimesat: c_long = 299;
pub const SYS_fstatat64: c_long = 300;
pub const SYS_unlinkat: c_long = 301;
pub const SYS_renameat: c_long = 302;
pub const SYS_linkat: c_long = 303;
pub const SYS_symlinkat: c_long = 304;
pub const SYS_readlinkat: c_long = 305;
pub const SYS_fchmodat: c_long = 306;
pub const SYS_faccessat: c_long = 307;
pub const SYS_pselect6: c_long = 308;
pub const SYS_ppoll: c_long = 309;
pub const SYS_unshare: c_long = 310;
pub const SYS_set_robust_list: c_long = 311;
pub const SYS_get_robust_list: c_long = 312;
pub const SYS_splice: c_long = 313;
pub const SYS_sync_file_range: c_long = 314;
pub const SYS_tee: c_long = 315;
pub const SYS_vmsplice: c_long = 316;
pub const SYS_move_pages: c_long = 317;
pub const SYS_getcpu: c_long = 318;
pub const SYS_epoll_pwait: c_long = 319;
pub const SYS_utimensat: c_long = 320;
pub const SYS_signalfd: c_long = 321;
pub const SYS_timerfd_create: c_long = 322;
pub const SYS_eventfd: c_long = 323;
pub const SYS_fallocate: c_long = 324;
pub const SYS_timerfd_settime: c_long = 325;
pub const SYS_timerfd_gettime: c_long = 326;
pub const SYS_signalfd4: c_long = 327;
pub const SYS_eventfd2: c_long = 328;
pub const SYS_epoll_create1: c_long = 329;
pub const SYS_dup3: c_long = 330;
pub const SYS_pipe2: c_long = 331;
pub const SYS_inotify_init1: c_long = 332;
pub const SYS_preadv: c_long = 333;
pub const SYS_pwritev: c_long = 334;
pub const SYS_rt_tgsigqueueinfo: c_long = 335;
pub const SYS_perf_event_open: c_long = 336;
pub const SYS_recvmmsg: c_long = 337;
pub const SYS_fanotify_init: c_long = 338;
pub const SYS_fanotify_mark: c_long = 339;
pub const SYS_prlimit64: c_long = 340;
pub const SYS_name_to_handle_at: c_long = 341;
pub const SYS_open_by_handle_at: c_long = 342;
pub const SYS_clock_adjtime: c_long = 343;
pub const SYS_syncfs: c_long = 344;
pub const SYS_sendmmsg: c_long = 345;
pub const SYS_setns: c_long = 346;
pub const SYS_process_vm_readv: c_long = 347;
pub const SYS_process_vm_writev: c_long = 348;
pub const SYS_kcmp: c_long = 349;
pub const SYS_finit_module: c_long = 350;
pub const SYS_sched_setattr: c_long = 351;
pub const SYS_sched_getattr: c_long = 352;
pub const SYS_renameat2: c_long = 353;
pub const SYS_seccomp: c_long = 354;
pub const SYS_getrandom: c_long = 355;
pub const SYS_memfd_create: c_long = 356;
pub const SYS_bpf: c_long = 357;
pub const SYS_execveat: c_long = 358;
pub const SYS_socket: c_long = 359;
pub const SYS_socketpair: c_long = 360;
pub const SYS_bind: c_long = 361;
pub const SYS_connect: c_long = 362;
pub const SYS_listen: c_long = 363;
pub const SYS_accept4: c_long = 364;
pub const SYS_getsockopt: c_long = 365;
pub const SYS_setsockopt: c_long = 366;
pub const SYS_getsockname: c_long = 367;
pub const SYS_getpeername: c_long = 368;
pub const SYS_sendto: c_long = 369;
pub const SYS_sendmsg: c_long = 370;
pub const SYS_recvfrom: c_long = 371;
pub const SYS_recvmsg: c_long = 372;
pub const SYS_shutdown: c_long = 373;
pub const SYS_userfaultfd: c_long = 374;
pub const SYS_membarrier: c_long = 375;
pub const SYS_mlock2: c_long = 376;
pub const SYS_copy_file_range: c_long = 377;
pub const SYS_preadv2: c_long = 378;
pub const SYS_pwritev2: c_long = 379;
pub const SYS_pkey_mprotect: c_long = 380;
pub const SYS_pkey_alloc: c_long = 381;
pub const SYS_pkey_free: c_long = 382;
pub const SYS_statx: c_long = 383;
pub const SYS_pidfd_send_signal: c_long = 424;
pub const SYS_io_uring_setup: c_long = 425;
pub const SYS_io_uring_enter: c_long = 426;
pub const SYS_io_uring_register: c_long = 427;
pub const SYS_open_tree: c_long = 428;
pub const SYS_move_mount: c_long = 429;
pub const SYS_fsopen: c_long = 430;
pub const SYS_fsconfig: c_long = 431;
pub const SYS_fsmount: c_long = 432;
pub const SYS_fspick: c_long = 433;
pub const SYS_pidfd_open: c_long = 434;
pub const SYS_clone3: c_long = 435;
pub const SYS_close_range: c_long = 436;
pub const SYS_openat2: c_long = 437;
pub const SYS_pidfd_getfd: c_long = 438;
pub const SYS_faccessat2: c_long = 439;
pub const SYS_process_madvise: c_long = 440;
pub const SYS_epoll_pwait2: c_long = 441;
pub const SYS_mount_setattr: c_long = 442;
pub const SYS_quotactl_fd: c_long = 443;
pub const SYS_landlock_create_ruleset: c_long = 444;
pub const SYS_landlock_add_rule: c_long = 445;
pub const SYS_landlock_restrict_self: c_long = 446;
pub const SYS_memfd_secret: c_long = 447;
pub const SYS_process_mrelease: c_long = 448;
pub const SYS_futex_waitv: c_long = 449;
pub const SYS_set_mempolicy_home_node: c_long = 450;
// offsets in user_regs_structs, from sys/reg.h
pub const EBX: c_int = 0;
pub const ECX: c_int = 1;
pub const EDX: c_int = 2;
pub const ESI: c_int = 3;
pub const EDI: c_int = 4;
pub const EBP: c_int = 5;
pub const EAX: c_int = 6;
pub const DS: c_int = 7;
pub const ES: c_int = 8;
pub const FS: c_int = 9;
pub const GS: c_int = 10;
pub const ORIG_EAX: c_int = 11;
pub const EIP: c_int = 12;
pub const CS: c_int = 13;
pub const EFL: c_int = 14;
pub const UESP: c_int = 15;
pub const SS: c_int = 16;
// offsets in mcontext_t.gregs from sys/ucontext.h
pub const REG_GS: c_int = 0;
pub const REG_FS: c_int = 1;
pub const REG_ES: c_int = 2;
pub const REG_DS: c_int = 3;
pub const REG_EDI: c_int = 4;
pub const REG_ESI: c_int = 5;
pub const REG_EBP: c_int = 6;
pub const REG_ESP: c_int = 7;
pub const REG_EBX: c_int = 8;
pub const REG_EDX: c_int = 9;
pub const REG_ECX: c_int = 10;
pub const REG_EAX: c_int = 11;
pub const REG_TRAPNO: c_int = 12;
pub const REG_ERR: c_int = 13;
pub const REG_EIP: c_int = 14;
pub const REG_CS: c_int = 15;
pub const REG_EFL: c_int = 16;
pub const REG_UESP: c_int = 17;
pub const REG_SS: c_int = 18;
// From NDK's asm/auxvec.h
pub const AT_SYSINFO: c_ulong = 32;
pub const AT_SYSINFO_EHDR: c_ulong = 33;
pub const AT_VECTOR_SIZE_ARCH: c_ulong = 3;
// socketcall values from linux/net.h (only the needed ones, and not public)
const SYS_ACCEPT4: c_int = 18;
f! {
// Sadly, Android before 5.0 (API level 21), the accept4 syscall is not
// exposed by the libc. As work-around, we implement it as raw syscall.
// Note that for x86, the `accept4` syscall is not available either,
// and we must use the `socketcall` syscall instead.
// This workaround can be removed if the minimum Android version is bumped.
// When the workaround is removed, `accept4` can be moved back
// to `linux_like/mod.rs`
pub fn accept4(
fd: c_int,
addr: *mut crate::sockaddr,
len: *mut crate::socklen_t,
flg: c_int,
) -> c_int {
// Arguments are passed as array of `long int`
// (which is big enough on x86 for a pointer).
let mut args = [fd as c_long, addr as c_long, len as c_long, flg as c_long];
crate::syscall(SYS_socketcall, SYS_ACCEPT4, args[..].as_mut_ptr())
}
}

View File

@@ -0,0 +1,473 @@
use crate::off64_t;
use crate::prelude::*;
pub type wchar_t = u32;
pub type __u64 = c_ulonglong;
pub type __s64 = c_longlong;
s! {
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: c_uint,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
__pad1: c_ulong,
pub st_size: off64_t,
pub st_blksize: c_int,
__pad2: c_int,
pub st_blocks: c_long,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused4: c_uint,
__unused5: c_uint,
}
pub struct stat64 {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: c_uint,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
__pad1: c_ulong,
pub st_size: off64_t,
pub st_blksize: c_int,
__pad2: c_int,
pub st_blocks: c_long,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused4: c_uint,
__unused5: c_uint,
}
pub struct user_regs_struct {
pub regs: [u64; 31],
pub sp: u64,
pub pc: u64,
pub pstate: u64,
}
pub struct ucontext_t {
pub uc_flags: c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: crate::stack_t,
pub uc_sigmask: crate::sigset_t,
pub uc_mcontext: mcontext_t,
}
#[repr(align(16))]
pub struct mcontext_t {
pub fault_address: c_ulonglong,
pub regs: [c_ulonglong; 31],
pub sp: c_ulonglong,
pub pc: c_ulonglong,
pub pstate: c_ulonglong,
__reserved: [u64; 512],
}
pub struct user_fpsimd_struct {
pub vregs: [crate::__uint128_t; 32],
pub fpsr: u32,
pub fpcr: u32,
}
}
s_no_extra_traits! {
#[repr(align(16))]
pub struct max_align_t {
priv_: [f32; 8],
}
}
pub const O_DIRECT: c_int = 0x10000;
pub const O_DIRECTORY: c_int = 0x4000;
pub const O_NOFOLLOW: c_int = 0x8000;
pub const O_LARGEFILE: c_int = 0o400000;
pub const SIGSTKSZ: size_t = 16384;
pub const MINSIGSTKSZ: size_t = 5120;
// From NDK's asm/hwcap.h
pub const HWCAP_FP: c_ulong = 1 << 0;
pub const HWCAP_ASIMD: c_ulong = 1 << 1;
pub const HWCAP_EVTSTRM: c_ulong = 1 << 2;
pub const HWCAP_AES: c_ulong = 1 << 3;
pub const HWCAP_PMULL: c_ulong = 1 << 4;
pub const HWCAP_SHA1: c_ulong = 1 << 5;
pub const HWCAP_SHA2: c_ulong = 1 << 6;
pub const HWCAP_CRC32: c_ulong = 1 << 7;
pub const HWCAP_ATOMICS: c_ulong = 1 << 8;
pub const HWCAP_FPHP: c_ulong = 1 << 9;
pub const HWCAP_ASIMDHP: c_ulong = 1 << 10;
pub const HWCAP_CPUID: c_ulong = 1 << 11;
pub const HWCAP_ASIMDRDM: c_ulong = 1 << 12;
pub const HWCAP_JSCVT: c_ulong = 1 << 13;
pub const HWCAP_FCMA: c_ulong = 1 << 14;
pub const HWCAP_LRCPC: c_ulong = 1 << 15;
pub const HWCAP_DCPOP: c_ulong = 1 << 16;
pub const HWCAP_SHA3: c_ulong = 1 << 17;
pub const HWCAP_SM3: c_ulong = 1 << 18;
pub const HWCAP_SM4: c_ulong = 1 << 19;
pub const HWCAP_ASIMDDP: c_ulong = 1 << 20;
pub const HWCAP_SHA512: c_ulong = 1 << 21;
pub const HWCAP_SVE: c_ulong = 1 << 22;
pub const HWCAP_ASIMDFHM: c_ulong = 1 << 23;
pub const HWCAP_DIT: c_ulong = 1 << 24;
pub const HWCAP_USCAT: c_ulong = 1 << 25;
pub const HWCAP_ILRCPC: c_ulong = 1 << 26;
pub const HWCAP_FLAGM: c_ulong = 1 << 27;
pub const HWCAP_SSBS: c_ulong = 1 << 28;
pub const HWCAP_SB: c_ulong = 1 << 29;
pub const HWCAP_PACA: c_ulong = 1 << 30;
pub const HWCAP_PACG: c_ulong = 1 << 31;
pub const HWCAP2_DCPODP: c_ulong = 1 << 0;
pub const HWCAP2_SVE2: c_ulong = 1 << 1;
pub const HWCAP2_SVEAES: c_ulong = 1 << 2;
pub const HWCAP2_SVEPMULL: c_ulong = 1 << 3;
pub const HWCAP2_SVEBITPERM: c_ulong = 1 << 4;
pub const HWCAP2_SVESHA3: c_ulong = 1 << 5;
pub const HWCAP2_SVESM4: c_ulong = 1 << 6;
pub const HWCAP2_FLAGM2: c_ulong = 1 << 7;
pub const HWCAP2_FRINT: c_ulong = 1 << 8;
pub const HWCAP2_SVEI8MM: c_ulong = 1 << 9;
pub const HWCAP2_SVEF32MM: c_ulong = 1 << 10;
pub const HWCAP2_SVEF64MM: c_ulong = 1 << 11;
pub const HWCAP2_SVEBF16: c_ulong = 1 << 12;
pub const HWCAP2_I8MM: c_ulong = 1 << 13;
pub const HWCAP2_BF16: c_ulong = 1 << 14;
pub const HWCAP2_DGH: c_ulong = 1 << 15;
pub const HWCAP2_RNG: c_ulong = 1 << 16;
pub const HWCAP2_BTI: c_ulong = 1 << 17;
pub const HWCAP2_MTE: c_ulong = 1 << 18;
pub const HWCAP2_ECV: c_ulong = 1 << 19;
pub const HWCAP2_AFP: c_ulong = 1 << 20;
pub const HWCAP2_RPRES: c_ulong = 1 << 21;
pub const HWCAP2_MTE3: c_ulong = 1 << 22;
pub const HWCAP2_SME: c_ulong = 1 << 23;
pub const HWCAP2_SME_I16I64: c_ulong = 1 << 24;
pub const HWCAP2_SME_F64F64: c_ulong = 1 << 25;
pub const HWCAP2_SME_I8I32: c_ulong = 1 << 26;
pub const HWCAP2_SME_F16F32: c_ulong = 1 << 27;
pub const HWCAP2_SME_B16F32: c_ulong = 1 << 28;
pub const HWCAP2_SME_F32F32: c_ulong = 1 << 29;
pub const HWCAP2_SME_FA64: c_ulong = 1 << 30;
pub const HWCAP2_WFXT: c_ulong = 1 << 31;
pub const HWCAP2_EBF16: c_ulong = 1 << 32;
pub const HWCAP2_SVE_EBF16: c_ulong = 1 << 33;
pub const SYS_io_setup: c_long = 0;
pub const SYS_io_destroy: c_long = 1;
pub const SYS_io_submit: c_long = 2;
pub const SYS_io_cancel: c_long = 3;
pub const SYS_io_getevents: c_long = 4;
pub const SYS_setxattr: c_long = 5;
pub const SYS_lsetxattr: c_long = 6;
pub const SYS_fsetxattr: c_long = 7;
pub const SYS_getxattr: c_long = 8;
pub const SYS_lgetxattr: c_long = 9;
pub const SYS_fgetxattr: c_long = 10;
pub const SYS_listxattr: c_long = 11;
pub const SYS_llistxattr: c_long = 12;
pub const SYS_flistxattr: c_long = 13;
pub const SYS_removexattr: c_long = 14;
pub const SYS_lremovexattr: c_long = 15;
pub const SYS_fremovexattr: c_long = 16;
pub const SYS_getcwd: c_long = 17;
pub const SYS_lookup_dcookie: c_long = 18;
pub const SYS_eventfd2: c_long = 19;
pub const SYS_epoll_create1: c_long = 20;
pub const SYS_epoll_ctl: c_long = 21;
pub const SYS_epoll_pwait: c_long = 22;
pub const SYS_dup: c_long = 23;
pub const SYS_dup3: c_long = 24;
pub const SYS_fcntl: c_long = 25;
pub const SYS_inotify_init1: c_long = 26;
pub const SYS_inotify_add_watch: c_long = 27;
pub const SYS_inotify_rm_watch: c_long = 28;
pub const SYS_ioctl: c_long = 29;
pub const SYS_ioprio_set: c_long = 30;
pub const SYS_ioprio_get: c_long = 31;
pub const SYS_flock: c_long = 32;
pub const SYS_mknodat: c_long = 33;
pub const SYS_mkdirat: c_long = 34;
pub const SYS_unlinkat: c_long = 35;
pub const SYS_symlinkat: c_long = 36;
pub const SYS_linkat: c_long = 37;
pub const SYS_renameat: c_long = 38;
pub const SYS_umount2: c_long = 39;
pub const SYS_mount: c_long = 40;
pub const SYS_pivot_root: c_long = 41;
pub const SYS_nfsservctl: c_long = 42;
pub const SYS_fallocate: c_long = 47;
pub const SYS_faccessat: c_long = 48;
pub const SYS_chdir: c_long = 49;
pub const SYS_fchdir: c_long = 50;
pub const SYS_chroot: c_long = 51;
pub const SYS_fchmod: c_long = 52;
pub const SYS_fchmodat: c_long = 53;
pub const SYS_fchownat: c_long = 54;
pub const SYS_fchown: c_long = 55;
pub const SYS_openat: c_long = 56;
pub const SYS_close: c_long = 57;
pub const SYS_vhangup: c_long = 58;
pub const SYS_pipe2: c_long = 59;
pub const SYS_quotactl: c_long = 60;
pub const SYS_getdents64: c_long = 61;
pub const SYS_lseek: c_long = 62;
pub const SYS_read: c_long = 63;
pub const SYS_write: c_long = 64;
pub const SYS_readv: c_long = 65;
pub const SYS_writev: c_long = 66;
pub const SYS_pread64: c_long = 67;
pub const SYS_pwrite64: c_long = 68;
pub const SYS_preadv: c_long = 69;
pub const SYS_pwritev: c_long = 70;
pub const SYS_pselect6: c_long = 72;
pub const SYS_ppoll: c_long = 73;
pub const SYS_signalfd4: c_long = 74;
pub const SYS_vmsplice: c_long = 75;
pub const SYS_splice: c_long = 76;
pub const SYS_tee: c_long = 77;
pub const SYS_readlinkat: c_long = 78;
pub const SYS_sync: c_long = 81;
pub const SYS_fsync: c_long = 82;
pub const SYS_fdatasync: c_long = 83;
pub const SYS_sync_file_range: c_long = 84;
pub const SYS_timerfd_create: c_long = 85;
pub const SYS_timerfd_settime: c_long = 86;
pub const SYS_timerfd_gettime: c_long = 87;
pub const SYS_utimensat: c_long = 88;
pub const SYS_acct: c_long = 89;
pub const SYS_capget: c_long = 90;
pub const SYS_capset: c_long = 91;
pub const SYS_personality: c_long = 92;
pub const SYS_exit: c_long = 93;
pub const SYS_exit_group: c_long = 94;
pub const SYS_waitid: c_long = 95;
pub const SYS_set_tid_address: c_long = 96;
pub const SYS_unshare: c_long = 97;
pub const SYS_futex: c_long = 98;
pub const SYS_set_robust_list: c_long = 99;
pub const SYS_get_robust_list: c_long = 100;
pub const SYS_nanosleep: c_long = 101;
pub const SYS_getitimer: c_long = 102;
pub const SYS_setitimer: c_long = 103;
pub const SYS_kexec_load: c_long = 104;
pub const SYS_init_module: c_long = 105;
pub const SYS_delete_module: c_long = 106;
pub const SYS_timer_create: c_long = 107;
pub const SYS_timer_gettime: c_long = 108;
pub const SYS_timer_getoverrun: c_long = 109;
pub const SYS_timer_settime: c_long = 110;
pub const SYS_timer_delete: c_long = 111;
pub const SYS_clock_settime: c_long = 112;
pub const SYS_clock_gettime: c_long = 113;
pub const SYS_clock_getres: c_long = 114;
pub const SYS_clock_nanosleep: c_long = 115;
pub const SYS_syslog: c_long = 116;
pub const SYS_ptrace: c_long = 117;
pub const SYS_sched_setparam: c_long = 118;
pub const SYS_sched_setscheduler: c_long = 119;
pub const SYS_sched_getscheduler: c_long = 120;
pub const SYS_sched_getparam: c_long = 121;
pub const SYS_sched_setaffinity: c_long = 122;
pub const SYS_sched_getaffinity: c_long = 123;
pub const SYS_sched_yield: c_long = 124;
pub const SYS_sched_get_priority_max: c_long = 125;
pub const SYS_sched_get_priority_min: c_long = 126;
pub const SYS_sched_rr_get_interval: c_long = 127;
pub const SYS_restart_syscall: c_long = 128;
pub const SYS_kill: c_long = 129;
pub const SYS_tkill: c_long = 130;
pub const SYS_tgkill: c_long = 131;
pub const SYS_sigaltstack: c_long = 132;
pub const SYS_rt_sigsuspend: c_long = 133;
pub const SYS_rt_sigaction: c_long = 134;
pub const SYS_rt_sigprocmask: c_long = 135;
pub const SYS_rt_sigpending: c_long = 136;
pub const SYS_rt_sigtimedwait: c_long = 137;
pub const SYS_rt_sigqueueinfo: c_long = 138;
pub const SYS_rt_sigreturn: c_long = 139;
pub const SYS_setpriority: c_long = 140;
pub const SYS_getpriority: c_long = 141;
pub const SYS_reboot: c_long = 142;
pub const SYS_setregid: c_long = 143;
pub const SYS_setgid: c_long = 144;
pub const SYS_setreuid: c_long = 145;
pub const SYS_setuid: c_long = 146;
pub const SYS_setresuid: c_long = 147;
pub const SYS_getresuid: c_long = 148;
pub const SYS_setresgid: c_long = 149;
pub const SYS_getresgid: c_long = 150;
pub const SYS_setfsuid: c_long = 151;
pub const SYS_setfsgid: c_long = 152;
pub const SYS_times: c_long = 153;
pub const SYS_setpgid: c_long = 154;
pub const SYS_getpgid: c_long = 155;
pub const SYS_getsid: c_long = 156;
pub const SYS_setsid: c_long = 157;
pub const SYS_getgroups: c_long = 158;
pub const SYS_setgroups: c_long = 159;
pub const SYS_uname: c_long = 160;
pub const SYS_sethostname: c_long = 161;
pub const SYS_setdomainname: c_long = 162;
pub const SYS_getrlimit: c_long = 163;
pub const SYS_setrlimit: c_long = 164;
pub const SYS_getrusage: c_long = 165;
pub const SYS_umask: c_long = 166;
pub const SYS_prctl: c_long = 167;
pub const SYS_getcpu: c_long = 168;
pub const SYS_gettimeofday: c_long = 169;
pub const SYS_settimeofday: c_long = 170;
pub const SYS_adjtimex: c_long = 171;
pub const SYS_getpid: c_long = 172;
pub const SYS_getppid: c_long = 173;
pub const SYS_getuid: c_long = 174;
pub const SYS_geteuid: c_long = 175;
pub const SYS_getgid: c_long = 176;
pub const SYS_getegid: c_long = 177;
pub const SYS_gettid: c_long = 178;
pub const SYS_sysinfo: c_long = 179;
pub const SYS_mq_open: c_long = 180;
pub const SYS_mq_unlink: c_long = 181;
pub const SYS_mq_timedsend: c_long = 182;
pub const SYS_mq_timedreceive: c_long = 183;
pub const SYS_mq_notify: c_long = 184;
pub const SYS_mq_getsetattr: c_long = 185;
pub const SYS_msgget: c_long = 186;
pub const SYS_msgctl: c_long = 187;
pub const SYS_msgrcv: c_long = 188;
pub const SYS_msgsnd: c_long = 189;
pub const SYS_semget: c_long = 190;
pub const SYS_semctl: c_long = 191;
pub const SYS_semtimedop: c_long = 192;
pub const SYS_semop: c_long = 193;
pub const SYS_shmget: c_long = 194;
pub const SYS_shmctl: c_long = 195;
pub const SYS_shmat: c_long = 196;
pub const SYS_shmdt: c_long = 197;
pub const SYS_socket: c_long = 198;
pub const SYS_socketpair: c_long = 199;
pub const SYS_bind: c_long = 200;
pub const SYS_listen: c_long = 201;
pub const SYS_accept: c_long = 202;
pub const SYS_connect: c_long = 203;
pub const SYS_getsockname: c_long = 204;
pub const SYS_getpeername: c_long = 205;
pub const SYS_sendto: c_long = 206;
pub const SYS_recvfrom: c_long = 207;
pub const SYS_setsockopt: c_long = 208;
pub const SYS_getsockopt: c_long = 209;
pub const SYS_shutdown: c_long = 210;
pub const SYS_sendmsg: c_long = 211;
pub const SYS_recvmsg: c_long = 212;
pub const SYS_readahead: c_long = 213;
pub const SYS_brk: c_long = 214;
pub const SYS_munmap: c_long = 215;
pub const SYS_mremap: c_long = 216;
pub const SYS_add_key: c_long = 217;
pub const SYS_request_key: c_long = 218;
pub const SYS_keyctl: c_long = 219;
pub const SYS_clone: c_long = 220;
pub const SYS_execve: c_long = 221;
pub const SYS_mmap: c_long = 222;
pub const SYS_swapon: c_long = 224;
pub const SYS_swapoff: c_long = 225;
pub const SYS_mprotect: c_long = 226;
pub const SYS_msync: c_long = 227;
pub const SYS_mlock: c_long = 228;
pub const SYS_munlock: c_long = 229;
pub const SYS_mlockall: c_long = 230;
pub const SYS_munlockall: c_long = 231;
pub const SYS_mincore: c_long = 232;
pub const SYS_madvise: c_long = 233;
pub const SYS_remap_file_pages: c_long = 234;
pub const SYS_mbind: c_long = 235;
pub const SYS_get_mempolicy: c_long = 236;
pub const SYS_set_mempolicy: c_long = 237;
pub const SYS_migrate_pages: c_long = 238;
pub const SYS_move_pages: c_long = 239;
pub const SYS_rt_tgsigqueueinfo: c_long = 240;
pub const SYS_perf_event_open: c_long = 241;
pub const SYS_accept4: c_long = 242;
pub const SYS_recvmmsg: c_long = 243;
pub const SYS_arch_specific_syscall: c_long = 244;
pub const SYS_wait4: c_long = 260;
pub const SYS_prlimit64: c_long = 261;
pub const SYS_fanotify_init: c_long = 262;
pub const SYS_fanotify_mark: c_long = 263;
pub const SYS_name_to_handle_at: c_long = 264;
pub const SYS_open_by_handle_at: c_long = 265;
pub const SYS_clock_adjtime: c_long = 266;
pub const SYS_syncfs: c_long = 267;
pub const SYS_setns: c_long = 268;
pub const SYS_sendmmsg: c_long = 269;
pub const SYS_process_vm_readv: c_long = 270;
pub const SYS_process_vm_writev: c_long = 271;
pub const SYS_kcmp: c_long = 272;
pub const SYS_finit_module: c_long = 273;
pub const SYS_sched_setattr: c_long = 274;
pub const SYS_sched_getattr: c_long = 275;
pub const SYS_renameat2: c_long = 276;
pub const SYS_seccomp: c_long = 277;
pub const SYS_getrandom: c_long = 278;
pub const SYS_memfd_create: c_long = 279;
pub const SYS_bpf: c_long = 280;
pub const SYS_execveat: c_long = 281;
pub const SYS_userfaultfd: c_long = 282;
pub const SYS_membarrier: c_long = 283;
pub const SYS_mlock2: c_long = 284;
pub const SYS_copy_file_range: c_long = 285;
pub const SYS_preadv2: c_long = 286;
pub const SYS_pwritev2: c_long = 287;
pub const SYS_pkey_mprotect: c_long = 288;
pub const SYS_pkey_alloc: c_long = 289;
pub const SYS_pkey_free: c_long = 290;
pub const SYS_statx: c_long = 291;
pub const SYS_pidfd_send_signal: c_long = 424;
pub const SYS_io_uring_setup: c_long = 425;
pub const SYS_io_uring_enter: c_long = 426;
pub const SYS_io_uring_register: c_long = 427;
pub const SYS_open_tree: c_long = 428;
pub const SYS_move_mount: c_long = 429;
pub const SYS_fsopen: c_long = 430;
pub const SYS_fsconfig: c_long = 431;
pub const SYS_fsmount: c_long = 432;
pub const SYS_fspick: c_long = 433;
pub const SYS_pidfd_open: c_long = 434;
pub const SYS_clone3: c_long = 435;
pub const SYS_close_range: c_long = 436;
pub const SYS_openat2: c_long = 437;
pub const SYS_pidfd_getfd: c_long = 438;
pub const SYS_faccessat2: c_long = 439;
pub const SYS_process_madvise: c_long = 440;
pub const SYS_epoll_pwait2: c_long = 441;
pub const SYS_mount_setattr: c_long = 442;
pub const SYS_quotactl_fd: c_long = 443;
pub const SYS_landlock_create_ruleset: c_long = 444;
pub const SYS_landlock_add_rule: c_long = 445;
pub const SYS_landlock_restrict_self: c_long = 446;
pub const SYS_memfd_secret: c_long = 447;
pub const SYS_process_mrelease: c_long = 448;
pub const SYS_futex_waitv: c_long = 449;
pub const SYS_set_mempolicy_home_node: c_long = 450;
pub const SYS_syscalls: c_long = 451;
pub const PROT_BTI: c_int = 0x10;
pub const PROT_MTE: c_int = 0x20;
// From NDK's asm/auxvec.h
pub const AT_SYSINFO_EHDR: c_ulong = 33;
pub const AT_VECTOR_SIZE_ARCH: c_ulong = 2;

View File

@@ -0,0 +1,292 @@
use crate::prelude::*;
// The following definitions are correct for aarch64 and x86_64,
// but may be wrong for mips64
pub type mode_t = u32;
pub type off64_t = i64;
pub type socklen_t = u32;
s! {
pub struct sigset_t {
__val: [c_ulong; 1],
}
// FIXME(1.0): This should not implement `PartialEq`
#[allow(unpredictable_function_pointer_comparisons)]
pub struct sigaction {
pub sa_flags: c_int,
pub sa_sigaction: crate::sighandler_t,
pub sa_mask: crate::sigset_t,
pub sa_restorer: Option<extern "C" fn()>,
}
pub struct rlimit64 {
pub rlim_cur: c_ulonglong,
pub rlim_max: c_ulonglong,
}
pub struct pthread_attr_t {
pub flags: u32,
pub stack_base: *mut c_void,
pub stack_size: size_t,
pub guard_size: size_t,
pub sched_policy: i32,
pub sched_priority: i32,
__reserved: [c_char; 16],
}
pub struct passwd {
pub pw_name: *mut c_char,
pub pw_passwd: *mut c_char,
pub pw_uid: crate::uid_t,
pub pw_gid: crate::gid_t,
pub pw_gecos: *mut c_char,
pub pw_dir: *mut c_char,
pub pw_shell: *mut c_char,
}
pub struct statfs {
pub f_type: u64,
pub f_bsize: u64,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: u64,
pub f_files: u64,
pub f_ffree: u64,
pub f_fsid: crate::__fsid_t,
pub f_namelen: u64,
pub f_frsize: u64,
pub f_flags: u64,
pub f_spare: [u64; 4],
}
pub struct sysinfo {
pub uptime: c_long,
pub loads: [c_ulong; 3],
pub totalram: c_ulong,
pub freeram: c_ulong,
pub sharedram: c_ulong,
pub bufferram: c_ulong,
pub totalswap: c_ulong,
pub freeswap: c_ulong,
pub procs: c_ushort,
pub pad: c_ushort,
pub totalhigh: c_ulong,
pub freehigh: c_ulong,
pub mem_unit: c_uint,
pub _f: [c_char; 0],
}
pub struct statfs64 {
pub f_type: u64,
pub f_bsize: u64,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: u64,
pub f_files: u64,
pub f_ffree: u64,
pub f_fsid: crate::__fsid_t,
pub f_namelen: u64,
pub f_frsize: u64,
pub f_flags: u64,
pub f_spare: [u64; 4],
}
pub struct statvfs64 {
pub f_bsize: c_ulong,
pub f_frsize: c_ulong,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: u64,
pub f_files: u64,
pub f_ffree: u64,
pub f_favail: u64,
pub f_fsid: c_ulong,
pub f_flag: c_ulong,
pub f_namemax: c_ulong,
__f_spare: [c_int; 6],
}
pub struct pthread_barrier_t {
__private: [i64; 4],
}
pub struct pthread_spinlock_t {
__private: i64,
}
}
s_no_extra_traits! {
pub struct pthread_mutex_t {
value: c_int,
__reserved: [c_char; 36],
}
pub struct pthread_cond_t {
value: c_int,
__reserved: [c_char; 44],
}
pub struct pthread_rwlock_t {
numLocks: c_int,
writerThreadId: c_int,
pendingReaders: c_int,
pendingWriters: c_int,
attr: i32,
__reserved: [c_char; 36],
}
pub struct sigset64_t {
__bits: [c_ulong; 1],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for pthread_mutex_t {
fn eq(&self, other: &pthread_mutex_t) -> bool {
self.value == other.value
&& self
.__reserved
.iter()
.zip(other.__reserved.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for pthread_mutex_t {}
impl hash::Hash for pthread_mutex_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.value.hash(state);
self.__reserved.hash(state);
}
}
impl PartialEq for pthread_cond_t {
fn eq(&self, other: &pthread_cond_t) -> bool {
self.value == other.value
&& self
.__reserved
.iter()
.zip(other.__reserved.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for pthread_cond_t {}
impl hash::Hash for pthread_cond_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.value.hash(state);
self.__reserved.hash(state);
}
}
impl PartialEq for pthread_rwlock_t {
fn eq(&self, other: &pthread_rwlock_t) -> bool {
self.numLocks == other.numLocks
&& self.writerThreadId == other.writerThreadId
&& self.pendingReaders == other.pendingReaders
&& self.pendingWriters == other.pendingWriters
&& self.attr == other.attr
&& self
.__reserved
.iter()
.zip(other.__reserved.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for pthread_rwlock_t {}
impl hash::Hash for pthread_rwlock_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.numLocks.hash(state);
self.writerThreadId.hash(state);
self.pendingReaders.hash(state);
self.pendingWriters.hash(state);
self.attr.hash(state);
self.__reserved.hash(state);
}
}
}
}
// These constants must be of the same type of sigaction.sa_flags
pub const SA_NOCLDSTOP: c_int = 0x00000001;
pub const SA_NOCLDWAIT: c_int = 0x00000002;
pub const SA_NODEFER: c_int = 0x40000000;
pub const SA_ONSTACK: c_int = 0x08000000;
pub const SA_RESETHAND: c_int = 0x80000000;
pub const SA_RESTART: c_int = 0x10000000;
pub const SA_SIGINFO: c_int = 0x00000004;
pub const RTLD_GLOBAL: c_int = 0x00100;
pub const RTLD_NOW: c_int = 2;
pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut();
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
value: 0,
__reserved: [0; 36],
};
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
value: 0,
__reserved: [0; 44],
};
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
numLocks: 0,
writerThreadId: 0,
pendingReaders: 0,
pendingWriters: 0,
attr: 0,
__reserved: [0; 36],
};
pub const PTHREAD_STACK_MIN: size_t = 4096 * 4;
pub const CPU_SETSIZE: size_t = 1024;
pub const __CPU_BITS: size_t = 64;
pub const UT_LINESIZE: usize = 32;
pub const UT_NAMESIZE: usize = 32;
pub const UT_HOSTSIZE: usize = 256;
f! {
// Sadly, Android before 5.0 (API level 21), the accept4 syscall is not
// exposed by the libc. As work-around, we implement it through `syscall`
// directly. This workaround can be removed if the minimum version of
// Android is bumped. When the workaround is removed, `accept4` can be
// moved back to `linux_like/mod.rs`
pub fn accept4(
fd: c_int,
addr: *mut crate::sockaddr,
len: *mut crate::socklen_t,
flg: c_int,
) -> c_int {
crate::syscall(SYS_accept4, fd, addr, len, flg) as c_int
}
}
extern "C" {
pub fn __system_property_wait(
pi: *const crate::prop_info,
__old_serial: u32,
__new_serial_ptr: *mut u32,
__relative_timeout: *const crate::timespec,
) -> bool;
}
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
} else if #[cfg(target_arch = "aarch64")] {
mod aarch64;
pub use self::aarch64::*;
} else if #[cfg(target_arch = "riscv64")] {
mod riscv64;
pub use self::riscv64::*;
} else {
// Unknown target_arch
}
}

View File

@@ -0,0 +1,384 @@
use crate::off64_t;
use crate::prelude::*;
pub type wchar_t = u32;
pub type greg_t = i64;
pub type __u64 = c_ulonglong;
pub type __s64 = c_longlong;
s! {
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: c_uint,
pub st_nlink: c_uint,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
__pad1: c_ulong,
pub st_size: off64_t,
pub st_blksize: c_int,
__pad2: c_int,
pub st_blocks: c_long,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused4: c_uint,
__unused5: c_uint,
}
pub struct stat64 {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: c_uint,
pub st_nlink: c_uint,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
__pad1: c_ulong,
pub st_size: off64_t,
pub st_blksize: c_int,
__pad2: c_int,
pub st_blocks: c_long,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
__unused4: c_uint,
__unused5: c_uint,
}
}
s_no_extra_traits! {
#[repr(align(16))]
pub struct max_align_t {
priv_: [f32; 8],
}
}
pub const O_DIRECT: c_int = 0x40000;
pub const O_DIRECTORY: c_int = 0x200000;
pub const O_NOFOLLOW: c_int = 0x400000;
pub const O_LARGEFILE: c_int = 0x100000;
pub const SIGSTKSZ: size_t = 8192;
pub const MINSIGSTKSZ: size_t = 2048;
// From NDK's asm/hwcap.h
pub const COMPAT_HWCAP_ISA_I: c_ulong = 1 << (b'I' - b'A');
pub const COMPAT_HWCAP_ISA_M: c_ulong = 1 << (b'M' - b'A');
pub const COMPAT_HWCAP_ISA_A: c_ulong = 1 << (b'A' - b'A');
pub const COMPAT_HWCAP_ISA_F: c_ulong = 1 << (b'F' - b'A');
pub const COMPAT_HWCAP_ISA_D: c_ulong = 1 << (b'D' - b'A');
pub const COMPAT_HWCAP_ISA_C: c_ulong = 1 << (b'C' - b'A');
pub const SYS_io_setup: c_long = 0;
pub const SYS_io_destroy: c_long = 1;
pub const SYS_io_submit: c_long = 2;
pub const SYS_io_cancel: c_long = 3;
pub const SYS_io_getevents: c_long = 4;
pub const SYS_setxattr: c_long = 5;
pub const SYS_lsetxattr: c_long = 6;
pub const SYS_fsetxattr: c_long = 7;
pub const SYS_getxattr: c_long = 8;
pub const SYS_lgetxattr: c_long = 9;
pub const SYS_fgetxattr: c_long = 10;
pub const SYS_listxattr: c_long = 11;
pub const SYS_llistxattr: c_long = 12;
pub const SYS_flistxattr: c_long = 13;
pub const SYS_removexattr: c_long = 14;
pub const SYS_lremovexattr: c_long = 15;
pub const SYS_fremovexattr: c_long = 16;
pub const SYS_getcwd: c_long = 17;
pub const SYS_lookup_dcookie: c_long = 18;
pub const SYS_eventfd2: c_long = 19;
pub const SYS_epoll_create1: c_long = 20;
pub const SYS_epoll_ctl: c_long = 21;
pub const SYS_epoll_pwait: c_long = 22;
pub const SYS_dup: c_long = 23;
pub const SYS_dup3: c_long = 24;
pub const SYS_inotify_init1: c_long = 26;
pub const SYS_inotify_add_watch: c_long = 27;
pub const SYS_inotify_rm_watch: c_long = 28;
pub const SYS_ioctl: c_long = 29;
pub const SYS_ioprio_set: c_long = 30;
pub const SYS_ioprio_get: c_long = 31;
pub const SYS_flock: c_long = 32;
pub const SYS_mknodat: c_long = 33;
pub const SYS_mkdirat: c_long = 34;
pub const SYS_unlinkat: c_long = 35;
pub const SYS_symlinkat: c_long = 36;
pub const SYS_linkat: c_long = 37;
pub const SYS_renameat: c_long = 38;
pub const SYS_umount2: c_long = 39;
pub const SYS_mount: c_long = 40;
pub const SYS_pivot_root: c_long = 41;
pub const SYS_nfsservctl: c_long = 42;
pub const SYS_fallocate: c_long = 47;
pub const SYS_faccessat: c_long = 48;
pub const SYS_chdir: c_long = 49;
pub const SYS_fchdir: c_long = 50;
pub const SYS_chroot: c_long = 51;
pub const SYS_fchmod: c_long = 52;
pub const SYS_fchmodat: c_long = 53;
pub const SYS_fchownat: c_long = 54;
pub const SYS_fchown: c_long = 55;
pub const SYS_openat: c_long = 56;
pub const SYS_close: c_long = 57;
pub const SYS_vhangup: c_long = 58;
pub const SYS_pipe2: c_long = 59;
pub const SYS_quotactl: c_long = 60;
pub const SYS_getdents64: c_long = 61;
pub const SYS_read: c_long = 63;
pub const SYS_write: c_long = 64;
pub const SYS_readv: c_long = 65;
pub const SYS_writev: c_long = 66;
pub const SYS_pread64: c_long = 67;
pub const SYS_pwrite64: c_long = 68;
pub const SYS_preadv: c_long = 69;
pub const SYS_pwritev: c_long = 70;
pub const SYS_pselect6: c_long = 72;
pub const SYS_ppoll: c_long = 73;
pub const SYS_signalfd4: c_long = 74;
pub const SYS_vmsplice: c_long = 75;
pub const SYS_splice: c_long = 76;
pub const SYS_tee: c_long = 77;
pub const SYS_readlinkat: c_long = 78;
pub const SYS_sync: c_long = 81;
pub const SYS_fsync: c_long = 82;
pub const SYS_fdatasync: c_long = 83;
pub const SYS_sync_file_range: c_long = 84;
pub const SYS_timerfd_create: c_long = 85;
pub const SYS_timerfd_settime: c_long = 86;
pub const SYS_timerfd_gettime: c_long = 87;
pub const SYS_utimensat: c_long = 88;
pub const SYS_acct: c_long = 89;
pub const SYS_capget: c_long = 90;
pub const SYS_capset: c_long = 91;
pub const SYS_personality: c_long = 92;
pub const SYS_exit: c_long = 93;
pub const SYS_exit_group: c_long = 94;
pub const SYS_waitid: c_long = 95;
pub const SYS_set_tid_address: c_long = 96;
pub const SYS_unshare: c_long = 97;
pub const SYS_futex: c_long = 98;
pub const SYS_set_robust_list: c_long = 99;
pub const SYS_get_robust_list: c_long = 100;
pub const SYS_nanosleep: c_long = 101;
pub const SYS_getitimer: c_long = 102;
pub const SYS_setitimer: c_long = 103;
pub const SYS_kexec_load: c_long = 104;
pub const SYS_init_module: c_long = 105;
pub const SYS_delete_module: c_long = 106;
pub const SYS_timer_create: c_long = 107;
pub const SYS_timer_gettime: c_long = 108;
pub const SYS_timer_getoverrun: c_long = 109;
pub const SYS_timer_settime: c_long = 110;
pub const SYS_timer_delete: c_long = 111;
pub const SYS_clock_settime: c_long = 112;
pub const SYS_clock_gettime: c_long = 113;
pub const SYS_clock_getres: c_long = 114;
pub const SYS_clock_nanosleep: c_long = 115;
pub const SYS_syslog: c_long = 116;
pub const SYS_ptrace: c_long = 117;
pub const SYS_sched_setparam: c_long = 118;
pub const SYS_sched_setscheduler: c_long = 119;
pub const SYS_sched_getscheduler: c_long = 120;
pub const SYS_sched_getparam: c_long = 121;
pub const SYS_sched_setaffinity: c_long = 122;
pub const SYS_sched_getaffinity: c_long = 123;
pub const SYS_sched_yield: c_long = 124;
pub const SYS_sched_get_priority_max: c_long = 125;
pub const SYS_sched_get_priority_min: c_long = 126;
pub const SYS_sched_rr_get_interval: c_long = 127;
pub const SYS_restart_syscall: c_long = 128;
pub const SYS_kill: c_long = 129;
pub const SYS_tkill: c_long = 130;
pub const SYS_tgkill: c_long = 131;
pub const SYS_sigaltstack: c_long = 132;
pub const SYS_rt_sigsuspend: c_long = 133;
pub const SYS_rt_sigaction: c_long = 134;
pub const SYS_rt_sigprocmask: c_long = 135;
pub const SYS_rt_sigpending: c_long = 136;
pub const SYS_rt_sigtimedwait: c_long = 137;
pub const SYS_rt_sigqueueinfo: c_long = 138;
pub const SYS_rt_sigreturn: c_long = 139;
pub const SYS_setpriority: c_long = 140;
pub const SYS_getpriority: c_long = 141;
pub const SYS_reboot: c_long = 142;
pub const SYS_setregid: c_long = 143;
pub const SYS_setgid: c_long = 144;
pub const SYS_setreuid: c_long = 145;
pub const SYS_setuid: c_long = 146;
pub const SYS_setresuid: c_long = 147;
pub const SYS_getresuid: c_long = 148;
pub const SYS_setresgid: c_long = 149;
pub const SYS_getresgid: c_long = 150;
pub const SYS_setfsuid: c_long = 151;
pub const SYS_setfsgid: c_long = 152;
pub const SYS_times: c_long = 153;
pub const SYS_setpgid: c_long = 154;
pub const SYS_getpgid: c_long = 155;
pub const SYS_getsid: c_long = 156;
pub const SYS_setsid: c_long = 157;
pub const SYS_getgroups: c_long = 158;
pub const SYS_setgroups: c_long = 159;
pub const SYS_uname: c_long = 160;
pub const SYS_sethostname: c_long = 161;
pub const SYS_setdomainname: c_long = 162;
pub const SYS_getrlimit: c_long = 163;
pub const SYS_setrlimit: c_long = 164;
pub const SYS_getrusage: c_long = 165;
pub const SYS_umask: c_long = 166;
pub const SYS_prctl: c_long = 167;
pub const SYS_getcpu: c_long = 168;
pub const SYS_gettimeofday: c_long = 169;
pub const SYS_settimeofday: c_long = 170;
pub const SYS_adjtimex: c_long = 171;
pub const SYS_getpid: c_long = 172;
pub const SYS_getppid: c_long = 173;
pub const SYS_getuid: c_long = 174;
pub const SYS_geteuid: c_long = 175;
pub const SYS_getgid: c_long = 176;
pub const SYS_getegid: c_long = 177;
pub const SYS_gettid: c_long = 178;
pub const SYS_sysinfo: c_long = 179;
pub const SYS_mq_open: c_long = 180;
pub const SYS_mq_unlink: c_long = 181;
pub const SYS_mq_timedsend: c_long = 182;
pub const SYS_mq_timedreceive: c_long = 183;
pub const SYS_mq_notify: c_long = 184;
pub const SYS_mq_getsetattr: c_long = 185;
pub const SYS_msgget: c_long = 186;
pub const SYS_msgctl: c_long = 187;
pub const SYS_msgrcv: c_long = 188;
pub const SYS_msgsnd: c_long = 189;
pub const SYS_semget: c_long = 190;
pub const SYS_semctl: c_long = 191;
pub const SYS_semtimedop: c_long = 192;
pub const SYS_semop: c_long = 193;
pub const SYS_shmget: c_long = 194;
pub const SYS_shmctl: c_long = 195;
pub const SYS_shmat: c_long = 196;
pub const SYS_shmdt: c_long = 197;
pub const SYS_socket: c_long = 198;
pub const SYS_socketpair: c_long = 199;
pub const SYS_bind: c_long = 200;
pub const SYS_listen: c_long = 201;
pub const SYS_accept: c_long = 202;
pub const SYS_connect: c_long = 203;
pub const SYS_getsockname: c_long = 204;
pub const SYS_getpeername: c_long = 205;
pub const SYS_sendto: c_long = 206;
pub const SYS_recvfrom: c_long = 207;
pub const SYS_setsockopt: c_long = 208;
pub const SYS_getsockopt: c_long = 209;
pub const SYS_shutdown: c_long = 210;
pub const SYS_sendmsg: c_long = 211;
pub const SYS_recvmsg: c_long = 212;
pub const SYS_readahead: c_long = 213;
pub const SYS_brk: c_long = 214;
pub const SYS_munmap: c_long = 215;
pub const SYS_mremap: c_long = 216;
pub const SYS_add_key: c_long = 217;
pub const SYS_request_key: c_long = 218;
pub const SYS_keyctl: c_long = 219;
pub const SYS_clone: c_long = 220;
pub const SYS_execve: c_long = 221;
pub const SYS_swapon: c_long = 224;
pub const SYS_swapoff: c_long = 225;
pub const SYS_mprotect: c_long = 226;
pub const SYS_msync: c_long = 227;
pub const SYS_mlock: c_long = 228;
pub const SYS_munlock: c_long = 229;
pub const SYS_mlockall: c_long = 230;
pub const SYS_munlockall: c_long = 231;
pub const SYS_mincore: c_long = 232;
pub const SYS_madvise: c_long = 233;
pub const SYS_remap_file_pages: c_long = 234;
pub const SYS_mbind: c_long = 235;
pub const SYS_get_mempolicy: c_long = 236;
pub const SYS_set_mempolicy: c_long = 237;
pub const SYS_migrate_pages: c_long = 238;
pub const SYS_move_pages: c_long = 239;
pub const SYS_rt_tgsigqueueinfo: c_long = 240;
pub const SYS_perf_event_open: c_long = 241;
pub const SYS_accept4: c_long = 242;
pub const SYS_recvmmsg: c_long = 243;
pub const SYS_arch_specific_syscall: c_long = 244;
pub const SYS_wait4: c_long = 260;
pub const SYS_prlimit64: c_long = 261;
pub const SYS_fanotify_init: c_long = 262;
pub const SYS_fanotify_mark: c_long = 263;
pub const SYS_name_to_handle_at: c_long = 264;
pub const SYS_open_by_handle_at: c_long = 265;
pub const SYS_clock_adjtime: c_long = 266;
pub const SYS_syncfs: c_long = 267;
pub const SYS_setns: c_long = 268;
pub const SYS_sendmmsg: c_long = 269;
pub const SYS_process_vm_readv: c_long = 270;
pub const SYS_process_vm_writev: c_long = 271;
pub const SYS_kcmp: c_long = 272;
pub const SYS_finit_module: c_long = 273;
pub const SYS_sched_setattr: c_long = 274;
pub const SYS_sched_getattr: c_long = 275;
pub const SYS_renameat2: c_long = 276;
pub const SYS_seccomp: c_long = 277;
pub const SYS_getrandom: c_long = 278;
pub const SYS_memfd_create: c_long = 279;
pub const SYS_bpf: c_long = 280;
pub const SYS_execveat: c_long = 281;
pub const SYS_userfaultfd: c_long = 282;
pub const SYS_membarrier: c_long = 283;
pub const SYS_mlock2: c_long = 284;
pub const SYS_copy_file_range: c_long = 285;
pub const SYS_preadv2: c_long = 286;
pub const SYS_pwritev2: c_long = 287;
pub const SYS_pkey_mprotect: c_long = 288;
pub const SYS_pkey_alloc: c_long = 289;
pub const SYS_pkey_free: c_long = 290;
pub const SYS_statx: c_long = 291;
pub const SYS_pidfd_send_signal: c_long = 424;
pub const SYS_io_uring_setup: c_long = 425;
pub const SYS_io_uring_enter: c_long = 426;
pub const SYS_io_uring_register: c_long = 427;
pub const SYS_open_tree: c_long = 428;
pub const SYS_move_mount: c_long = 429;
pub const SYS_fsopen: c_long = 430;
pub const SYS_fsconfig: c_long = 431;
pub const SYS_fsmount: c_long = 432;
pub const SYS_fspick: c_long = 433;
pub const SYS_pidfd_open: c_long = 434;
pub const SYS_clone3: c_long = 435;
pub const SYS_close_range: c_long = 436;
pub const SYS_openat2: c_long = 437;
pub const SYS_pidfd_getfd: c_long = 438;
pub const SYS_faccessat2: c_long = 439;
pub const SYS_process_madvise: c_long = 440;
pub const SYS_epoll_pwait2: c_long = 441;
pub const SYS_mount_setattr: c_long = 442;
pub const SYS_quotactl_fd: c_long = 443;
pub const SYS_landlock_create_ruleset: c_long = 444;
pub const SYS_landlock_add_rule: c_long = 445;
pub const SYS_landlock_restrict_self: c_long = 446;
pub const SYS_memfd_secret: c_long = 447;
pub const SYS_process_mrelease: c_long = 448;
pub const SYS_futex_waitv: c_long = 449;
pub const SYS_set_mempolicy_home_node: c_long = 450;
// From NDK's asm/auxvec.h
pub const AT_SYSINFO_EHDR: c_ulong = 33;
pub const AT_L1I_CACHESIZE: c_ulong = 40;
pub const AT_L1I_CACHEGEOMETRY: c_ulong = 41;
pub const AT_L1D_CACHESIZE: c_ulong = 42;
pub const AT_L1D_CACHEGEOMETRY: c_ulong = 43;
pub const AT_L2_CACHESIZE: c_ulong = 44;
pub const AT_L2_CACHEGEOMETRY: c_ulong = 45;
pub const AT_L3_CACHESIZE: c_ulong = 46;
pub const AT_L3_CACHEGEOMETRY: c_ulong = 47;
pub const AT_VECTOR_SIZE_ARCH: c_ulong = 9;

View File

@@ -0,0 +1,748 @@
use crate::off64_t;
use crate::prelude::*;
pub type wchar_t = i32;
pub type greg_t = i64;
pub type __u64 = c_ulonglong;
pub type __s64 = c_longlong;
s! {
pub struct stat {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: c_ulong,
pub st_mode: c_uint,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
pub st_size: off64_t,
pub st_blksize: c_long,
pub st_blocks: c_long,
pub st_atime: c_long,
pub st_atime_nsec: c_long,
pub st_mtime: c_long,
pub st_mtime_nsec: c_long,
pub st_ctime: c_long,
pub st_ctime_nsec: c_long,
__unused: [c_long; 3],
}
pub struct stat64 {
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: c_ulong,
pub st_mode: c_uint,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
pub st_size: off64_t,
pub st_blksize: c_long,
pub st_blocks: c_long,
pub st_atime: c_long,
pub st_atime_nsec: c_long,
pub st_mtime: c_long,
pub st_mtime_nsec: c_long,
pub st_ctime: c_long,
pub st_ctime_nsec: c_long,
__unused: [c_long; 3],
}
pub struct _libc_xmmreg {
pub element: [u32; 4],
}
pub struct user_regs_struct {
pub r15: c_ulong,
pub r14: c_ulong,
pub r13: c_ulong,
pub r12: c_ulong,
pub rbp: c_ulong,
pub rbx: c_ulong,
pub r11: c_ulong,
pub r10: c_ulong,
pub r9: c_ulong,
pub r8: c_ulong,
pub rax: c_ulong,
pub rcx: c_ulong,
pub rdx: c_ulong,
pub rsi: c_ulong,
pub rdi: c_ulong,
pub orig_rax: c_ulong,
pub rip: c_ulong,
pub cs: c_ulong,
pub eflags: c_ulong,
pub rsp: c_ulong,
pub ss: c_ulong,
pub fs_base: c_ulong,
pub gs_base: c_ulong,
pub ds: c_ulong,
pub es: c_ulong,
pub fs: c_ulong,
pub gs: c_ulong,
}
pub struct user {
pub regs: user_regs_struct,
pub u_fpvalid: c_int,
pub i387: user_fpregs_struct,
pub u_tsize: c_ulong,
pub u_dsize: c_ulong,
pub u_ssize: c_ulong,
pub start_code: c_ulong,
pub start_stack: c_ulong,
pub signal: c_long,
__reserved: c_int,
#[cfg(target_pointer_width = "32")]
__pad1: u32,
pub u_ar0: *mut user_regs_struct,
#[cfg(target_pointer_width = "32")]
__pad2: u32,
pub u_fpstate: *mut user_fpregs_struct,
pub magic: c_ulong,
pub u_comm: [c_char; 32],
pub u_debugreg: [c_ulong; 8],
pub error_code: c_ulong,
pub fault_address: c_ulong,
}
}
s_no_extra_traits! {
pub union __c_anonymous_uc_sigmask {
uc_sigmask: crate::sigset_t,
uc_sigmask64: crate::sigset64_t,
}
#[repr(align(16))]
pub struct max_align_t {
priv_: [f64; 4],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for __c_anonymous_uc_sigmask {
fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool {
unsafe { self.uc_sigmask == other.uc_sigmask }
}
}
impl Eq for __c_anonymous_uc_sigmask {}
impl hash::Hash for __c_anonymous_uc_sigmask {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
unsafe { self.uc_sigmask.hash(state) }
}
}
}
}
s_no_extra_traits! {
pub struct _libc_fpxreg {
pub significand: [u16; 4],
pub exponent: u16,
__padding: [u16; 3],
}
pub struct _libc_fpstate {
pub cwd: u16,
pub swd: u16,
pub ftw: u16,
pub fop: u16,
pub rip: u64,
pub rdp: u64,
pub mxcsr: u32,
pub mxcr_mask: u32,
pub _st: [_libc_fpxreg; 8],
pub _xmm: [_libc_xmmreg; 16],
__private: [u32; 24],
}
pub struct mcontext_t {
pub gregs: [greg_t; 23],
pub fpregs: *mut _libc_fpstate,
__private: [u64; 8],
}
pub struct ucontext_t {
pub uc_flags: c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: crate::stack_t,
pub uc_mcontext: mcontext_t,
pub uc_sigmask64: __c_anonymous_uc_sigmask,
__fpregs_mem: _libc_fpstate,
}
pub struct user_fpregs_struct {
pub cwd: c_ushort,
pub swd: c_ushort,
pub ftw: c_ushort,
pub fop: c_ushort,
pub rip: c_ulong,
pub rdp: c_ulong,
pub mxcsr: c_uint,
pub mxcr_mask: c_uint,
pub st_space: [c_uint; 32],
pub xmm_space: [c_uint; 64],
padding: [c_uint; 24],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for _libc_fpxreg {
fn eq(&self, other: &Self) -> bool {
self.significand == other.significand && self.exponent == other.exponent
// Ignore padding field
}
}
impl Eq for _libc_fpxreg {}
impl hash::Hash for _libc_fpxreg {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.significand.hash(state);
self.exponent.hash(state);
// Ignore padding field
}
}
impl PartialEq for _libc_fpstate {
fn eq(&self, other: &Self) -> bool {
self.cwd == other.cwd
&& self.swd == other.swd
&& self.ftw == other.ftw
&& self.fop == other.fop
&& self.rip == other.rip
&& self.rdp == other.rdp
&& self.mxcsr == other.mxcsr
&& self.mxcr_mask == other.mxcr_mask
&& self._st == other._st
&& self._xmm == other._xmm
// Ignore padding field
}
}
impl Eq for _libc_fpstate {}
impl hash::Hash for _libc_fpstate {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.cwd.hash(state);
self.swd.hash(state);
self.ftw.hash(state);
self.fop.hash(state);
self.rip.hash(state);
self.rdp.hash(state);
self.mxcsr.hash(state);
self.mxcr_mask.hash(state);
self._st.hash(state);
self._xmm.hash(state);
// Ignore padding field
}
}
impl PartialEq for mcontext_t {
fn eq(&self, other: &Self) -> bool {
self.gregs == other.gregs && self.fpregs == other.fpregs
// Ignore padding field
}
}
impl Eq for mcontext_t {}
impl hash::Hash for mcontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.gregs.hash(state);
self.fpregs.hash(state);
// Ignore padding field
}
}
impl PartialEq for ucontext_t {
fn eq(&self, other: &Self) -> bool {
self.uc_flags == other.uc_flags
&& self.uc_link == other.uc_link
&& self.uc_stack == other.uc_stack
&& self.uc_mcontext == other.uc_mcontext
&& self.uc_sigmask64 == other.uc_sigmask64
// Ignore padding field
}
}
impl Eq for ucontext_t {}
impl hash::Hash for ucontext_t {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.uc_flags.hash(state);
self.uc_link.hash(state);
self.uc_stack.hash(state);
self.uc_mcontext.hash(state);
self.uc_sigmask64.hash(state);
// Ignore padding field
}
}
impl PartialEq for user_fpregs_struct {
fn eq(&self, other: &user_fpregs_struct) -> bool {
self.cwd == other.cwd
&& self.swd == other.swd
&& self.ftw == other.ftw
&& self.fop == other.fop
&& self.rip == other.rip
&& self.rdp == other.rdp
&& self.mxcsr == other.mxcsr
&& self.mxcr_mask == other.mxcr_mask
&& self.st_space == other.st_space
&& self
.xmm_space
.iter()
.zip(other.xmm_space.iter())
.all(|(a, b)| a == b)
// Ignore padding field
}
}
impl Eq for user_fpregs_struct {}
impl hash::Hash for user_fpregs_struct {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.cwd.hash(state);
self.swd.hash(state);
self.ftw.hash(state);
self.fop.hash(state);
self.rip.hash(state);
self.rdp.hash(state);
self.mxcsr.hash(state);
self.mxcr_mask.hash(state);
self.st_space.hash(state);
self.xmm_space.hash(state);
// Ignore padding field
}
}
}
}
pub const O_DIRECT: c_int = 0x4000;
pub const O_DIRECTORY: c_int = 0x10000;
pub const O_NOFOLLOW: c_int = 0x20000;
pub const O_LARGEFILE: c_int = 0o0100000;
pub const SIGSTKSZ: size_t = 8192;
pub const MINSIGSTKSZ: size_t = 2048;
pub const MAP_32BIT: c_int = 0x40;
// Syscall table
pub const SYS_read: c_long = 0;
pub const SYS_write: c_long = 1;
pub const SYS_open: c_long = 2;
pub const SYS_close: c_long = 3;
pub const SYS_stat: c_long = 4;
pub const SYS_fstat: c_long = 5;
pub const SYS_lstat: c_long = 6;
pub const SYS_poll: c_long = 7;
pub const SYS_lseek: c_long = 8;
pub const SYS_mmap: c_long = 9;
pub const SYS_mprotect: c_long = 10;
pub const SYS_munmap: c_long = 11;
pub const SYS_brk: c_long = 12;
pub const SYS_rt_sigaction: c_long = 13;
pub const SYS_rt_sigprocmask: c_long = 14;
pub const SYS_rt_sigreturn: c_long = 15;
pub const SYS_ioctl: c_long = 16;
pub const SYS_pread64: c_long = 17;
pub const SYS_pwrite64: c_long = 18;
pub const SYS_readv: c_long = 19;
pub const SYS_writev: c_long = 20;
pub const SYS_access: c_long = 21;
pub const SYS_pipe: c_long = 22;
pub const SYS_select: c_long = 23;
pub const SYS_sched_yield: c_long = 24;
pub const SYS_mremap: c_long = 25;
pub const SYS_msync: c_long = 26;
pub const SYS_mincore: c_long = 27;
pub const SYS_madvise: c_long = 28;
pub const SYS_shmget: c_long = 29;
pub const SYS_shmat: c_long = 30;
pub const SYS_shmctl: c_long = 31;
pub const SYS_dup: c_long = 32;
pub const SYS_dup2: c_long = 33;
pub const SYS_pause: c_long = 34;
pub const SYS_nanosleep: c_long = 35;
pub const SYS_getitimer: c_long = 36;
pub const SYS_alarm: c_long = 37;
pub const SYS_setitimer: c_long = 38;
pub const SYS_getpid: c_long = 39;
pub const SYS_sendfile: c_long = 40;
pub const SYS_socket: c_long = 41;
pub const SYS_connect: c_long = 42;
pub const SYS_accept: c_long = 43;
pub const SYS_sendto: c_long = 44;
pub const SYS_recvfrom: c_long = 45;
pub const SYS_sendmsg: c_long = 46;
pub const SYS_recvmsg: c_long = 47;
pub const SYS_shutdown: c_long = 48;
pub const SYS_bind: c_long = 49;
pub const SYS_listen: c_long = 50;
pub const SYS_getsockname: c_long = 51;
pub const SYS_getpeername: c_long = 52;
pub const SYS_socketpair: c_long = 53;
pub const SYS_setsockopt: c_long = 54;
pub const SYS_getsockopt: c_long = 55;
pub const SYS_clone: c_long = 56;
pub const SYS_fork: c_long = 57;
pub const SYS_vfork: c_long = 58;
pub const SYS_execve: c_long = 59;
pub const SYS_exit: c_long = 60;
pub const SYS_wait4: c_long = 61;
pub const SYS_kill: c_long = 62;
pub const SYS_uname: c_long = 63;
pub const SYS_semget: c_long = 64;
pub const SYS_semop: c_long = 65;
pub const SYS_semctl: c_long = 66;
pub const SYS_shmdt: c_long = 67;
pub const SYS_msgget: c_long = 68;
pub const SYS_msgsnd: c_long = 69;
pub const SYS_msgrcv: c_long = 70;
pub const SYS_msgctl: c_long = 71;
pub const SYS_fcntl: c_long = 72;
pub const SYS_flock: c_long = 73;
pub const SYS_fsync: c_long = 74;
pub const SYS_fdatasync: c_long = 75;
pub const SYS_truncate: c_long = 76;
pub const SYS_ftruncate: c_long = 77;
pub const SYS_getdents: c_long = 78;
pub const SYS_getcwd: c_long = 79;
pub const SYS_chdir: c_long = 80;
pub const SYS_fchdir: c_long = 81;
pub const SYS_rename: c_long = 82;
pub const SYS_mkdir: c_long = 83;
pub const SYS_rmdir: c_long = 84;
pub const SYS_creat: c_long = 85;
pub const SYS_link: c_long = 86;
pub const SYS_unlink: c_long = 87;
pub const SYS_symlink: c_long = 88;
pub const SYS_readlink: c_long = 89;
pub const SYS_chmod: c_long = 90;
pub const SYS_fchmod: c_long = 91;
pub const SYS_chown: c_long = 92;
pub const SYS_fchown: c_long = 93;
pub const SYS_lchown: c_long = 94;
pub const SYS_umask: c_long = 95;
pub const SYS_gettimeofday: c_long = 96;
pub const SYS_getrlimit: c_long = 97;
pub const SYS_getrusage: c_long = 98;
pub const SYS_sysinfo: c_long = 99;
pub const SYS_times: c_long = 100;
pub const SYS_ptrace: c_long = 101;
pub const SYS_getuid: c_long = 102;
pub const SYS_syslog: c_long = 103;
pub const SYS_getgid: c_long = 104;
pub const SYS_setuid: c_long = 105;
pub const SYS_setgid: c_long = 106;
pub const SYS_geteuid: c_long = 107;
pub const SYS_getegid: c_long = 108;
pub const SYS_setpgid: c_long = 109;
pub const SYS_getppid: c_long = 110;
pub const SYS_getpgrp: c_long = 111;
pub const SYS_setsid: c_long = 112;
pub const SYS_setreuid: c_long = 113;
pub const SYS_setregid: c_long = 114;
pub const SYS_getgroups: c_long = 115;
pub const SYS_setgroups: c_long = 116;
pub const SYS_setresuid: c_long = 117;
pub const SYS_getresuid: c_long = 118;
pub const SYS_setresgid: c_long = 119;
pub const SYS_getresgid: c_long = 120;
pub const SYS_getpgid: c_long = 121;
pub const SYS_setfsuid: c_long = 122;
pub const SYS_setfsgid: c_long = 123;
pub const SYS_getsid: c_long = 124;
pub const SYS_capget: c_long = 125;
pub const SYS_capset: c_long = 126;
pub const SYS_rt_sigpending: c_long = 127;
pub const SYS_rt_sigtimedwait: c_long = 128;
pub const SYS_rt_sigqueueinfo: c_long = 129;
pub const SYS_rt_sigsuspend: c_long = 130;
pub const SYS_sigaltstack: c_long = 131;
pub const SYS_utime: c_long = 132;
pub const SYS_mknod: c_long = 133;
pub const SYS_uselib: c_long = 134;
pub const SYS_personality: c_long = 135;
pub const SYS_ustat: c_long = 136;
pub const SYS_statfs: c_long = 137;
pub const SYS_fstatfs: c_long = 138;
pub const SYS_sysfs: c_long = 139;
pub const SYS_getpriority: c_long = 140;
pub const SYS_setpriority: c_long = 141;
pub const SYS_sched_setparam: c_long = 142;
pub const SYS_sched_getparam: c_long = 143;
pub const SYS_sched_setscheduler: c_long = 144;
pub const SYS_sched_getscheduler: c_long = 145;
pub const SYS_sched_get_priority_max: c_long = 146;
pub const SYS_sched_get_priority_min: c_long = 147;
pub const SYS_sched_rr_get_interval: c_long = 148;
pub const SYS_mlock: c_long = 149;
pub const SYS_munlock: c_long = 150;
pub const SYS_mlockall: c_long = 151;
pub const SYS_munlockall: c_long = 152;
pub const SYS_vhangup: c_long = 153;
pub const SYS_modify_ldt: c_long = 154;
pub const SYS_pivot_root: c_long = 155;
// FIXME(android): SYS__sysctl is in the NDK sources but for some reason is
// not available in the tests
// pub const SYS__sysctl: c_long = 156;
pub const SYS_prctl: c_long = 157;
pub const SYS_arch_prctl: c_long = 158;
pub const SYS_adjtimex: c_long = 159;
pub const SYS_setrlimit: c_long = 160;
pub const SYS_chroot: c_long = 161;
pub const SYS_sync: c_long = 162;
pub const SYS_acct: c_long = 163;
pub const SYS_settimeofday: c_long = 164;
pub const SYS_mount: c_long = 165;
pub const SYS_umount2: c_long = 166;
pub const SYS_swapon: c_long = 167;
pub const SYS_swapoff: c_long = 168;
pub const SYS_reboot: c_long = 169;
pub const SYS_sethostname: c_long = 170;
pub const SYS_setdomainname: c_long = 171;
pub const SYS_iopl: c_long = 172;
pub const SYS_ioperm: c_long = 173;
#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")]
pub const SYS_create_module: c_long = 174;
pub const SYS_init_module: c_long = 175;
pub const SYS_delete_module: c_long = 176;
#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")]
pub const SYS_get_kernel_syms: c_long = 177;
#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")]
pub const SYS_query_module: c_long = 178;
pub const SYS_quotactl: c_long = 179;
pub const SYS_nfsservctl: c_long = 180;
pub const SYS_getpmsg: c_long = 181;
pub const SYS_putpmsg: c_long = 182;
pub const SYS_afs_syscall: c_long = 183;
pub const SYS_tuxcall: c_long = 184;
pub const SYS_security: c_long = 185;
pub const SYS_gettid: c_long = 186;
pub const SYS_readahead: c_long = 187;
pub const SYS_setxattr: c_long = 188;
pub const SYS_lsetxattr: c_long = 189;
pub const SYS_fsetxattr: c_long = 190;
pub const SYS_getxattr: c_long = 191;
pub const SYS_lgetxattr: c_long = 192;
pub const SYS_fgetxattr: c_long = 193;
pub const SYS_listxattr: c_long = 194;
pub const SYS_llistxattr: c_long = 195;
pub const SYS_flistxattr: c_long = 196;
pub const SYS_removexattr: c_long = 197;
pub const SYS_lremovexattr: c_long = 198;
pub const SYS_fremovexattr: c_long = 199;
pub const SYS_tkill: c_long = 200;
pub const SYS_time: c_long = 201;
pub const SYS_futex: c_long = 202;
pub const SYS_sched_setaffinity: c_long = 203;
pub const SYS_sched_getaffinity: c_long = 204;
pub const SYS_set_thread_area: c_long = 205;
pub const SYS_io_setup: c_long = 206;
pub const SYS_io_destroy: c_long = 207;
pub const SYS_io_getevents: c_long = 208;
pub const SYS_io_submit: c_long = 209;
pub const SYS_io_cancel: c_long = 210;
pub const SYS_get_thread_area: c_long = 211;
pub const SYS_lookup_dcookie: c_long = 212;
pub const SYS_epoll_create: c_long = 213;
pub const SYS_epoll_ctl_old: c_long = 214;
pub const SYS_epoll_wait_old: c_long = 215;
pub const SYS_remap_file_pages: c_long = 216;
pub const SYS_getdents64: c_long = 217;
pub const SYS_set_tid_address: c_long = 218;
pub const SYS_restart_syscall: c_long = 219;
pub const SYS_semtimedop: c_long = 220;
pub const SYS_fadvise64: c_long = 221;
pub const SYS_timer_create: c_long = 222;
pub const SYS_timer_settime: c_long = 223;
pub const SYS_timer_gettime: c_long = 224;
pub const SYS_timer_getoverrun: c_long = 225;
pub const SYS_timer_delete: c_long = 226;
pub const SYS_clock_settime: c_long = 227;
pub const SYS_clock_gettime: c_long = 228;
pub const SYS_clock_getres: c_long = 229;
pub const SYS_clock_nanosleep: c_long = 230;
pub const SYS_exit_group: c_long = 231;
pub const SYS_epoll_wait: c_long = 232;
pub const SYS_epoll_ctl: c_long = 233;
pub const SYS_tgkill: c_long = 234;
pub const SYS_utimes: c_long = 235;
pub const SYS_vserver: c_long = 236;
pub const SYS_mbind: c_long = 237;
pub const SYS_set_mempolicy: c_long = 238;
pub const SYS_get_mempolicy: c_long = 239;
pub const SYS_mq_open: c_long = 240;
pub const SYS_mq_unlink: c_long = 241;
pub const SYS_mq_timedsend: c_long = 242;
pub const SYS_mq_timedreceive: c_long = 243;
pub const SYS_mq_notify: c_long = 244;
pub const SYS_mq_getsetattr: c_long = 245;
pub const SYS_kexec_load: c_long = 246;
pub const SYS_waitid: c_long = 247;
pub const SYS_add_key: c_long = 248;
pub const SYS_request_key: c_long = 249;
pub const SYS_keyctl: c_long = 250;
pub const SYS_ioprio_set: c_long = 251;
pub const SYS_ioprio_get: c_long = 252;
pub const SYS_inotify_init: c_long = 253;
pub const SYS_inotify_add_watch: c_long = 254;
pub const SYS_inotify_rm_watch: c_long = 255;
pub const SYS_migrate_pages: c_long = 256;
pub const SYS_openat: c_long = 257;
pub const SYS_mkdirat: c_long = 258;
pub const SYS_mknodat: c_long = 259;
pub const SYS_fchownat: c_long = 260;
pub const SYS_futimesat: c_long = 261;
pub const SYS_newfstatat: c_long = 262;
pub const SYS_unlinkat: c_long = 263;
pub const SYS_renameat: c_long = 264;
pub const SYS_linkat: c_long = 265;
pub const SYS_symlinkat: c_long = 266;
pub const SYS_readlinkat: c_long = 267;
pub const SYS_fchmodat: c_long = 268;
pub const SYS_faccessat: c_long = 269;
pub const SYS_pselect6: c_long = 270;
pub const SYS_ppoll: c_long = 271;
pub const SYS_unshare: c_long = 272;
pub const SYS_set_robust_list: c_long = 273;
pub const SYS_get_robust_list: c_long = 274;
pub const SYS_splice: c_long = 275;
pub const SYS_tee: c_long = 276;
pub const SYS_sync_file_range: c_long = 277;
pub const SYS_vmsplice: c_long = 278;
pub const SYS_move_pages: c_long = 279;
pub const SYS_utimensat: c_long = 280;
pub const SYS_epoll_pwait: c_long = 281;
pub const SYS_signalfd: c_long = 282;
pub const SYS_timerfd_create: c_long = 283;
pub const SYS_eventfd: c_long = 284;
pub const SYS_fallocate: c_long = 285;
pub const SYS_timerfd_settime: c_long = 286;
pub const SYS_timerfd_gettime: c_long = 287;
pub const SYS_accept4: c_long = 288;
pub const SYS_signalfd4: c_long = 289;
pub const SYS_eventfd2: c_long = 290;
pub const SYS_epoll_create1: c_long = 291;
pub const SYS_dup3: c_long = 292;
pub const SYS_pipe2: c_long = 293;
pub const SYS_inotify_init1: c_long = 294;
pub const SYS_preadv: c_long = 295;
pub const SYS_pwritev: c_long = 296;
pub const SYS_rt_tgsigqueueinfo: c_long = 297;
pub const SYS_perf_event_open: c_long = 298;
pub const SYS_recvmmsg: c_long = 299;
pub const SYS_fanotify_init: c_long = 300;
pub const SYS_fanotify_mark: c_long = 301;
pub const SYS_prlimit64: c_long = 302;
pub const SYS_name_to_handle_at: c_long = 303;
pub const SYS_open_by_handle_at: c_long = 304;
pub const SYS_clock_adjtime: c_long = 305;
pub const SYS_syncfs: c_long = 306;
pub const SYS_sendmmsg: c_long = 307;
pub const SYS_setns: c_long = 308;
pub const SYS_getcpu: c_long = 309;
pub const SYS_process_vm_readv: c_long = 310;
pub const SYS_process_vm_writev: c_long = 311;
pub const SYS_kcmp: c_long = 312;
pub const SYS_finit_module: c_long = 313;
pub const SYS_sched_setattr: c_long = 314;
pub const SYS_sched_getattr: c_long = 315;
pub const SYS_renameat2: c_long = 316;
pub const SYS_seccomp: c_long = 317;
pub const SYS_getrandom: c_long = 318;
pub const SYS_memfd_create: c_long = 319;
pub const SYS_kexec_file_load: c_long = 320;
pub const SYS_bpf: c_long = 321;
pub const SYS_execveat: c_long = 322;
pub const SYS_userfaultfd: c_long = 323;
pub const SYS_membarrier: c_long = 324;
pub const SYS_mlock2: c_long = 325;
pub const SYS_copy_file_range: c_long = 326;
pub const SYS_preadv2: c_long = 327;
pub const SYS_pwritev2: c_long = 328;
pub const SYS_pkey_mprotect: c_long = 329;
pub const SYS_pkey_alloc: c_long = 330;
pub const SYS_pkey_free: c_long = 331;
pub const SYS_statx: c_long = 332;
pub const SYS_pidfd_send_signal: c_long = 424;
pub const SYS_io_uring_setup: c_long = 425;
pub const SYS_io_uring_enter: c_long = 426;
pub const SYS_io_uring_register: c_long = 427;
pub const SYS_open_tree: c_long = 428;
pub const SYS_move_mount: c_long = 429;
pub const SYS_fsopen: c_long = 430;
pub const SYS_fsconfig: c_long = 431;
pub const SYS_fsmount: c_long = 432;
pub const SYS_fspick: c_long = 433;
pub const SYS_pidfd_open: c_long = 434;
pub const SYS_clone3: c_long = 435;
pub const SYS_close_range: c_long = 436;
pub const SYS_openat2: c_long = 437;
pub const SYS_pidfd_getfd: c_long = 438;
pub const SYS_faccessat2: c_long = 439;
pub const SYS_process_madvise: c_long = 440;
pub const SYS_epoll_pwait2: c_long = 441;
pub const SYS_mount_setattr: c_long = 442;
pub const SYS_quotactl_fd: c_long = 443;
pub const SYS_landlock_create_ruleset: c_long = 444;
pub const SYS_landlock_add_rule: c_long = 445;
pub const SYS_landlock_restrict_self: c_long = 446;
pub const SYS_memfd_secret: c_long = 447;
pub const SYS_process_mrelease: c_long = 448;
pub const SYS_futex_waitv: c_long = 449;
pub const SYS_set_mempolicy_home_node: c_long = 450;
// offsets in user_regs_structs, from sys/reg.h
pub const R15: c_int = 0;
pub const R14: c_int = 1;
pub const R13: c_int = 2;
pub const R12: c_int = 3;
pub const RBP: c_int = 4;
pub const RBX: c_int = 5;
pub const R11: c_int = 6;
pub const R10: c_int = 7;
pub const R9: c_int = 8;
pub const R8: c_int = 9;
pub const RAX: c_int = 10;
pub const RCX: c_int = 11;
pub const RDX: c_int = 12;
pub const RSI: c_int = 13;
pub const RDI: c_int = 14;
pub const ORIG_RAX: c_int = 15;
pub const RIP: c_int = 16;
pub const CS: c_int = 17;
pub const EFLAGS: c_int = 18;
pub const RSP: c_int = 19;
pub const SS: c_int = 20;
pub const FS_BASE: c_int = 21;
pub const GS_BASE: c_int = 22;
pub const DS: c_int = 23;
pub const ES: c_int = 24;
pub const FS: c_int = 25;
pub const GS: c_int = 26;
// offsets in mcontext_t.gregs from sys/ucontext.h
pub const REG_R8: c_int = 0;
pub const REG_R9: c_int = 1;
pub const REG_R10: c_int = 2;
pub const REG_R11: c_int = 3;
pub const REG_R12: c_int = 4;
pub const REG_R13: c_int = 5;
pub const REG_R14: c_int = 6;
pub const REG_R15: c_int = 7;
pub const REG_RDI: c_int = 8;
pub const REG_RSI: c_int = 9;
pub const REG_RBP: c_int = 10;
pub const REG_RBX: c_int = 11;
pub const REG_RDX: c_int = 12;
pub const REG_RAX: c_int = 13;
pub const REG_RCX: c_int = 14;
pub const REG_RSP: c_int = 15;
pub const REG_RIP: c_int = 16;
pub const REG_EFL: c_int = 17;
pub const REG_CSGSFS: c_int = 18;
pub const REG_ERR: c_int = 19;
pub const REG_TRAPNO: c_int = 20;
pub const REG_OLDMASK: c_int = 21;
pub const REG_CR2: c_int = 22;
// From NDK's asm/auxvec.h
pub const AT_SYSINFO_EHDR: c_ulong = 33;
pub const AT_VECTOR_SIZE_ARCH: c_ulong = 3;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,211 @@
use crate::off64_t;
use crate::prelude::*;
// In-sync with ../linux/musl/lfs64.rs except for fallocate64, prlimit64 and sendfile64
#[inline]
pub unsafe extern "C" fn creat64(path: *const c_char, mode: crate::mode_t) -> c_int {
crate::creat(path, mode)
}
#[inline]
pub unsafe extern "C" fn fgetpos64(stream: *mut crate::FILE, pos: *mut crate::fpos64_t) -> c_int {
crate::fgetpos(stream, pos as *mut _)
}
#[inline]
pub unsafe extern "C" fn fopen64(pathname: *const c_char, mode: *const c_char) -> *mut crate::FILE {
crate::fopen(pathname, mode)
}
#[inline]
pub unsafe extern "C" fn freopen64(
pathname: *const c_char,
mode: *const c_char,
stream: *mut crate::FILE,
) -> *mut crate::FILE {
crate::freopen(pathname, mode, stream)
}
#[inline]
pub unsafe extern "C" fn fseeko64(
stream: *mut crate::FILE,
offset: off64_t,
whence: c_int,
) -> c_int {
crate::fseeko(stream, offset, whence)
}
#[inline]
pub unsafe extern "C" fn fsetpos64(stream: *mut crate::FILE, pos: *const crate::fpos64_t) -> c_int {
crate::fsetpos(stream, pos as *mut _)
}
#[inline]
pub unsafe extern "C" fn fstat64(fildes: c_int, buf: *mut crate::stat64) -> c_int {
crate::fstat(fildes, buf as *mut _)
}
#[inline]
pub unsafe extern "C" fn fstatat64(
fd: c_int,
path: *const c_char,
buf: *mut crate::stat64,
flag: c_int,
) -> c_int {
crate::fstatat(fd, path, buf as *mut _, flag)
}
#[inline]
pub unsafe extern "C" fn fstatfs64(fd: c_int, buf: *mut crate::statfs64) -> c_int {
crate::fstatfs(fd, buf as *mut _)
}
#[inline]
pub unsafe extern "C" fn fstatvfs64(fd: c_int, buf: *mut crate::statvfs64) -> c_int {
crate::fstatvfs(fd, buf as *mut _)
}
#[inline]
pub unsafe extern "C" fn ftello64(stream: *mut crate::FILE) -> off64_t {
crate::ftello(stream)
}
#[inline]
pub unsafe extern "C" fn ftruncate64(fd: c_int, length: off64_t) -> c_int {
crate::ftruncate(fd, length)
}
#[inline]
pub unsafe extern "C" fn getrlimit64(resource: c_int, rlim: *mut crate::rlimit64) -> c_int {
crate::getrlimit(resource, rlim as *mut _)
}
#[inline]
pub unsafe extern "C" fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t {
crate::lseek(fd, offset, whence)
}
#[inline]
pub unsafe extern "C" fn lstat64(path: *const c_char, buf: *mut crate::stat64) -> c_int {
crate::lstat(path, buf as *mut _)
}
#[inline]
pub unsafe extern "C" fn mmap64(
addr: *mut c_void,
length: size_t,
prot: c_int,
flags: c_int,
fd: c_int,
offset: off64_t,
) -> *mut c_void {
crate::mmap(addr, length, prot, flags, fd, offset)
}
// These functions are variadic in the C ABI since the `mode` argument is "optional". Variadic
// `extern "C"` functions are unstable in Rust so we cannot write a shim function for these
// entrypoints. See https://github.com/rust-lang/rust/issues/44930.
//
// These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an
// argument, nor do their names clash with any declared types.
pub use crate::{open as open64, openat as openat64};
#[inline]
pub unsafe extern "C" fn posix_fadvise64(
fd: c_int,
offset: off64_t,
len: off64_t,
advice: c_int,
) -> c_int {
crate::posix_fadvise(fd, offset, len, advice)
}
#[inline]
pub unsafe extern "C" fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int {
crate::posix_fallocate(fd, offset, len)
}
#[inline]
pub unsafe extern "C" fn pread64(
fd: c_int,
buf: *mut c_void,
count: size_t,
offset: off64_t,
) -> ssize_t {
crate::pread(fd, buf, count, offset)
}
#[inline]
pub unsafe extern "C" fn preadv64(
fd: c_int,
iov: *const crate::iovec,
iovcnt: c_int,
offset: off64_t,
) -> ssize_t {
crate::preadv(fd, iov, iovcnt, offset)
}
#[inline]
pub unsafe extern "C" fn pwrite64(
fd: c_int,
buf: *const c_void,
count: size_t,
offset: off64_t,
) -> ssize_t {
crate::pwrite(fd, buf, count, offset)
}
#[inline]
pub unsafe extern "C" fn pwritev64(
fd: c_int,
iov: *const crate::iovec,
iovcnt: c_int,
offset: off64_t,
) -> ssize_t {
crate::pwritev(fd, iov, iovcnt, offset)
}
#[inline]
pub unsafe extern "C" fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64 {
crate::readdir(dirp) as *mut _
}
#[inline]
pub unsafe extern "C" fn readdir64_r(
dirp: *mut crate::DIR,
entry: *mut crate::dirent64,
result: *mut *mut crate::dirent64,
) -> c_int {
crate::readdir_r(dirp, entry as *mut _, result as *mut _)
}
#[inline]
pub unsafe extern "C" fn setrlimit64(resource: c_int, rlim: *const crate::rlimit64) -> c_int {
crate::setrlimit(resource, rlim as *mut _)
}
#[inline]
pub unsafe extern "C" fn stat64(pathname: *const c_char, statbuf: *mut crate::stat64) -> c_int {
crate::stat(pathname, statbuf as *mut _)
}
#[inline]
pub unsafe extern "C" fn statfs64(pathname: *const c_char, buf: *mut crate::statfs64) -> c_int {
crate::statfs(pathname, buf as *mut _)
}
#[inline]
pub unsafe extern "C" fn statvfs64(path: *const c_char, buf: *mut crate::statvfs64) -> c_int {
crate::statvfs(path, buf as *mut _)
}
#[inline]
pub unsafe extern "C" fn tmpfile64() -> *mut crate::FILE {
crate::tmpfile()
}
#[inline]
pub unsafe extern "C" fn truncate64(path: *const c_char, length: off64_t) -> c_int {
crate::truncate(path, length)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,334 @@
use crate::prelude::*;
use crate::Ioctl;
s! {
pub struct termios2 {
pub c_iflag: crate::tcflag_t,
pub c_oflag: crate::tcflag_t,
pub c_cflag: crate::tcflag_t,
pub c_lflag: crate::tcflag_t,
pub c_line: crate::cc_t,
pub c_cc: [crate::cc_t; 19],
pub c_ispeed: crate::speed_t,
pub c_ospeed: crate::speed_t,
}
}
// include/uapi/asm-generic/socket.h
// arch/alpha/include/uapi/asm/socket.h
// tools/include/uapi/asm-generic/socket.h
// arch/mips/include/uapi/asm/socket.h
pub const SOL_SOCKET: c_int = 1;
// Defined in unix/linux_like/mod.rs
// pub const SO_DEBUG: c_int = 1;
pub const SO_REUSEADDR: c_int = 2;
pub const SO_TYPE: c_int = 3;
pub const SO_ERROR: c_int = 4;
pub const SO_DONTROUTE: c_int = 5;
pub const SO_BROADCAST: c_int = 6;
pub const SO_SNDBUF: c_int = 7;
pub const SO_RCVBUF: c_int = 8;
pub const SO_KEEPALIVE: c_int = 9;
pub const SO_OOBINLINE: c_int = 10;
pub const SO_NO_CHECK: c_int = 11;
pub const SO_PRIORITY: c_int = 12;
pub const SO_LINGER: c_int = 13;
pub const SO_BSDCOMPAT: c_int = 14;
pub const SO_REUSEPORT: c_int = 15;
pub const SO_PASSCRED: c_int = 16;
pub const SO_PEERCRED: c_int = 17;
pub const SO_RCVLOWAT: c_int = 18;
pub const SO_SNDLOWAT: c_int = 19;
pub const SO_SECURITY_AUTHENTICATION: c_int = 22;
pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
pub const SO_BINDTODEVICE: c_int = 25;
pub const SO_ATTACH_FILTER: c_int = 26;
pub const SO_DETACH_FILTER: c_int = 27;
pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
pub const SO_PEERNAME: c_int = 28;
cfg_if! {
if #[cfg(all(
linux_time_bits64,
any(target_arch = "arm", target_arch = "x86"),
not(any(target_env = "musl", target_env = "ohos"))
))] {
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
} else if #[cfg(all(
linux_time_bits64,
any(target_arch = "arm", target_arch = "x86"),
any(target_env = "musl", target_env = "ohos")
))] {
pub const SO_TIMESTAMP: c_int = 63;
pub const SO_TIMESTAMPNS: c_int = 64;
pub const SO_TIMESTAMPING: c_int = 65;
pub const SO_RCVTIMEO: c_int = 66;
pub const SO_SNDTIMEO: c_int = 67;
} else {
const SO_TIMESTAMP_OLD: c_int = 29;
const SO_TIMESTAMPNS_OLD: c_int = 35;
const SO_TIMESTAMPING_OLD: c_int = 37;
const SO_RCVTIMEO_OLD: c_int = 20;
const SO_SNDTIMEO_OLD: c_int = 21;
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
}
}
pub const SO_ACCEPTCONN: c_int = 30;
pub const SO_PEERSEC: c_int = 31;
pub const SO_SNDBUFFORCE: c_int = 32;
pub const SO_RCVBUFFORCE: c_int = 33;
pub const SO_PASSSEC: c_int = 34;
pub const SO_MARK: c_int = 36;
pub const SO_PROTOCOL: c_int = 38;
pub const SO_DOMAIN: c_int = 39;
pub const SO_RXQ_OVFL: c_int = 40;
pub const SO_WIFI_STATUS: c_int = 41;
pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS;
pub const SO_PEEK_OFF: c_int = 42;
pub const SO_NOFCS: c_int = 43;
pub const SO_LOCK_FILTER: c_int = 44;
pub const SO_SELECT_ERR_QUEUE: c_int = 45;
pub const SO_BUSY_POLL: c_int = 46;
pub const SO_MAX_PACING_RATE: c_int = 47;
pub const SO_BPF_EXTENSIONS: c_int = 48;
pub const SO_INCOMING_CPU: c_int = 49;
pub const SO_ATTACH_BPF: c_int = 50;
pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER;
pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51;
pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52;
pub const SO_CNX_ADVICE: c_int = 53;
pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54;
pub const SO_MEMINFO: c_int = 55;
pub const SO_INCOMING_NAPI_ID: c_int = 56;
pub const SO_COOKIE: c_int = 57;
pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58;
pub const SO_PEERGROUPS: c_int = 59;
pub const SO_ZEROCOPY: c_int = 60;
pub const SO_TXTIME: c_int = 61;
pub const SCM_TXTIME: c_int = SO_TXTIME;
pub const SO_BINDTOIFINDEX: c_int = 62;
cfg_if! {
// Some of these platforms in CI already have these constants.
// But they may still not have those _OLD ones.
if #[cfg(all(
any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64",
target_arch = "csky",
target_arch = "loongarch64"
),
// FIXME(musl):
// Musl hardcodes the SO_* constants instead
// of inheriting them from the kernel headers.
// For new constants you might need consider updating
// musl in the CI as well.
not(any(target_env = "musl", target_env = "ohos"))
))] {
pub const SO_TIMESTAMP_NEW: c_int = 63;
pub const SO_TIMESTAMPNS_NEW: c_int = 64;
pub const SO_TIMESTAMPING_NEW: c_int = 65;
pub const SO_RCVTIMEO_NEW: c_int = 66;
pub const SO_SNDTIMEO_NEW: c_int = 67;
pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
}
}
pub const SO_PREFER_BUSY_POLL: c_int = 69;
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
pub const SO_NETNS_COOKIE: c_int = 71;
pub const SO_BUF_LOCK: c_int = 72;
pub const SO_RESERVE_MEM: c_int = 73;
pub const SO_TXREHASH: c_int = 74;
pub const SO_RCVMARK: c_int = 75;
pub const SO_PASSPIDFD: c_int = 76;
pub const SO_PEERPIDFD: c_int = 77;
pub const SO_DEVMEM_LINEAR: c_int = 78;
pub const SO_DEVMEM_DMABUF: c_int = 79;
pub const SO_DEVMEM_DONTNEED: c_int = 80;
// Defined in unix/linux_like/mod.rs
// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
// Ioctl Constants
pub const TCGETS: Ioctl = 0x5401;
pub const TCSETS: Ioctl = 0x5402;
pub const TCSETSW: Ioctl = 0x5403;
pub const TCSETSF: Ioctl = 0x5404;
pub const TCGETA: Ioctl = 0x5405;
pub const TCSETA: Ioctl = 0x5406;
pub const TCSETAW: Ioctl = 0x5407;
pub const TCSETAF: Ioctl = 0x5408;
pub const TCSBRK: Ioctl = 0x5409;
pub const TCXONC: Ioctl = 0x540A;
pub const TCFLSH: Ioctl = 0x540B;
pub const TIOCEXCL: Ioctl = 0x540C;
pub const TIOCNXCL: Ioctl = 0x540D;
pub const TIOCSCTTY: Ioctl = 0x540E;
pub const TIOCGPGRP: Ioctl = 0x540F;
pub const TIOCSPGRP: Ioctl = 0x5410;
pub const TIOCOUTQ: Ioctl = 0x5411;
pub const TIOCSTI: Ioctl = 0x5412;
pub const TIOCGWINSZ: Ioctl = 0x5413;
pub const TIOCSWINSZ: Ioctl = 0x5414;
pub const TIOCMGET: Ioctl = 0x5415;
pub const TIOCMBIS: Ioctl = 0x5416;
pub const TIOCMBIC: Ioctl = 0x5417;
pub const TIOCMSET: Ioctl = 0x5418;
pub const TIOCGSOFTCAR: Ioctl = 0x5419;
pub const TIOCSSOFTCAR: Ioctl = 0x541A;
pub const FIONREAD: Ioctl = 0x541B;
pub const TIOCINQ: Ioctl = FIONREAD;
pub const TIOCLINUX: Ioctl = 0x541C;
pub const TIOCCONS: Ioctl = 0x541D;
pub const TIOCGSERIAL: Ioctl = 0x541E;
pub const TIOCSSERIAL: Ioctl = 0x541F;
pub const TIOCPKT: Ioctl = 0x5420;
pub const FIONBIO: Ioctl = 0x5421;
pub const TIOCNOTTY: Ioctl = 0x5422;
pub const TIOCSETD: Ioctl = 0x5423;
pub const TIOCGETD: Ioctl = 0x5424;
pub const TCSBRKP: Ioctl = 0x5425;
pub const TIOCSBRK: Ioctl = 0x5427;
pub const TIOCCBRK: Ioctl = 0x5428;
pub const TIOCGSID: Ioctl = 0x5429;
pub const TCGETS2: Ioctl = 0x802c542a;
pub const TCSETS2: Ioctl = 0x402c542b;
pub const TCSETSW2: Ioctl = 0x402c542c;
pub const TCSETSF2: Ioctl = 0x402c542d;
pub const TIOCGRS485: Ioctl = 0x542E;
pub const TIOCSRS485: Ioctl = 0x542F;
pub const TIOCGPTN: Ioctl = 0x80045430;
pub const TIOCSPTLCK: Ioctl = 0x40045431;
pub const TIOCGDEV: Ioctl = 0x80045432;
pub const TCGETX: Ioctl = 0x5432;
pub const TCSETX: Ioctl = 0x5433;
pub const TCSETXF: Ioctl = 0x5434;
pub const TCSETXW: Ioctl = 0x5435;
pub const TIOCSIG: Ioctl = 0x40045436;
pub const TIOCVHANGUP: Ioctl = 0x5437;
pub const TIOCGPKT: Ioctl = 0x80045438;
pub const TIOCGPTLCK: Ioctl = 0x80045439;
pub const TIOCGEXCL: Ioctl = 0x80045440;
pub const TIOCGPTPEER: Ioctl = 0x5441;
// pub const TIOCGISO7816: Ioctl = 0x80285442;
// pub const TIOCSISO7816: Ioctl = 0xc0285443;
pub const FIONCLEX: Ioctl = 0x5450;
pub const FIOCLEX: Ioctl = 0x5451;
pub const FIOASYNC: Ioctl = 0x5452;
pub const TIOCSERCONFIG: Ioctl = 0x5453;
pub const TIOCSERGWILD: Ioctl = 0x5454;
pub const TIOCSERSWILD: Ioctl = 0x5455;
pub const TIOCGLCKTRMIOS: Ioctl = 0x5456;
pub const TIOCSLCKTRMIOS: Ioctl = 0x5457;
pub const TIOCSERGSTRUCT: Ioctl = 0x5458;
pub const TIOCSERGETLSR: Ioctl = 0x5459;
pub const TIOCSERGETMULTI: Ioctl = 0x545A;
pub const TIOCSERSETMULTI: Ioctl = 0x545B;
pub const TIOCMIWAIT: Ioctl = 0x545C;
pub const TIOCGICOUNT: Ioctl = 0x545D;
pub const BLKIOMIN: Ioctl = 0x1278;
pub const BLKIOOPT: Ioctl = 0x1279;
pub const BLKSSZGET: Ioctl = 0x1268;
pub const BLKPBSZGET: Ioctl = 0x127B;
cfg_if! {
if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] {
pub const FIOQSIZE: Ioctl = 0x545E;
} else {
pub const FIOQSIZE: Ioctl = 0x5460;
}
}
pub const TIOCM_LE: c_int = 0x001;
pub const TIOCM_DTR: c_int = 0x002;
pub const TIOCM_RTS: c_int = 0x004;
pub const TIOCM_ST: c_int = 0x008;
pub const TIOCM_SR: c_int = 0x010;
pub const TIOCM_CTS: c_int = 0x020;
pub const TIOCM_CAR: c_int = 0x040;
pub const TIOCM_CD: c_int = TIOCM_CAR;
pub const TIOCM_RNG: c_int = 0x080;
pub const TIOCM_RI: c_int = TIOCM_RNG;
pub const TIOCM_DSR: c_int = 0x100;
pub const BOTHER: crate::speed_t = 0o010000;
pub const IBSHIFT: crate::tcflag_t = 16;
// RLIMIT Constants
cfg_if! {
if #[cfg(any(target_env = "gnu", target_env = "uclibc"))] {
pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0;
pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1;
pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2;
pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3;
pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4;
pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5;
pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6;
pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7;
pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8;
pub const RLIMIT_AS: crate::__rlimit_resource_t = 9;
pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10;
pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11;
pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12;
pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13;
pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14;
pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15;
#[allow(deprecated)]
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS;
} else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
pub const RLIMIT_CPU: c_int = 0;
pub const RLIMIT_FSIZE: c_int = 1;
pub const RLIMIT_DATA: c_int = 2;
pub const RLIMIT_STACK: c_int = 3;
pub const RLIMIT_CORE: c_int = 4;
pub const RLIMIT_RSS: c_int = 5;
pub const RLIMIT_NPROC: c_int = 6;
pub const RLIMIT_NOFILE: c_int = 7;
pub const RLIMIT_MEMLOCK: c_int = 8;
pub const RLIMIT_AS: c_int = 9;
pub const RLIMIT_LOCKS: c_int = 10;
pub const RLIMIT_SIGPENDING: c_int = 11;
pub const RLIMIT_MSGQUEUE: c_int = 12;
pub const RLIMIT_NICE: c_int = 13;
pub const RLIMIT_RTPRIO: c_int = 14;
pub const RLIMIT_RTTIME: c_int = 15;
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIM_NLIMITS: c_int = 16;
#[allow(deprecated)]
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS;
}
}
cfg_if! {
if #[cfg(target_env = "gnu")] {
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16;
} else if #[cfg(target_env = "uclibc")] {
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 15;
}
}
pub const RLIM_INFINITY: crate::rlim_t = !0;

View File

@@ -0,0 +1,333 @@
use crate::prelude::*;
use crate::Ioctl;
s! {
pub struct termios2 {
pub c_iflag: crate::tcflag_t,
pub c_oflag: crate::tcflag_t,
pub c_cflag: crate::tcflag_t,
pub c_lflag: crate::tcflag_t,
pub c_line: crate::cc_t,
pub c_cc: [crate::cc_t; 23],
pub c_ispeed: crate::speed_t,
pub c_ospeed: crate::speed_t,
}
}
// arch/mips/include/uapi/asm/socket.h
pub const SOL_SOCKET: c_int = 0xffff;
// Defined in unix/linux_like/mod.rs
// pub const SO_DEBUG: c_int = 0x0001;
pub const SO_REUSEADDR: c_int = 0x0004;
pub const SO_KEEPALIVE: c_int = 0x0008;
pub const SO_DONTROUTE: c_int = 0x0010;
pub const SO_BROADCAST: c_int = 0x0020;
pub const SO_LINGER: c_int = 0x0080;
pub const SO_OOBINLINE: c_int = 0x0100;
pub const SO_REUSEPORT: c_int = 0x0200;
pub const SO_TYPE: c_int = 0x1008;
// pub const SO_STYLE: c_int = SO_TYPE;
pub const SO_ERROR: c_int = 0x1007;
pub const SO_SNDBUF: c_int = 0x1001;
pub const SO_RCVBUF: c_int = 0x1002;
pub const SO_SNDLOWAT: c_int = 0x1003;
pub const SO_RCVLOWAT: c_int = 0x1004;
cfg_if! {
if #[cfg(linux_time_bits64)] {
const SO_RCVTIMEO_NEW: c_int = 66;
const SO_SNDTIMEO_NEW: c_int = 67;
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
} else {
const SO_SNDTIMEO_OLD: c_int = 0x1005;
const SO_RCVTIMEO_OLD: c_int = 0x1006;
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
}
}
pub const SO_ACCEPTCONN: c_int = 0x1009;
pub const SO_PROTOCOL: c_int = 0x1028;
pub const SO_DOMAIN: c_int = 0x1029;
pub const SO_NO_CHECK: c_int = 11;
pub const SO_PRIORITY: c_int = 12;
pub const SO_BSDCOMPAT: c_int = 14;
pub const SO_PASSCRED: c_int = 17;
pub const SO_PEERCRED: c_int = 18;
pub const SO_SECURITY_AUTHENTICATION: c_int = 22;
pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
pub const SO_BINDTODEVICE: c_int = 25;
pub const SO_ATTACH_FILTER: c_int = 26;
pub const SO_DETACH_FILTER: c_int = 27;
pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
pub const SO_PEERNAME: c_int = 28;
pub const SO_PEERSEC: c_int = 30;
pub const SO_SNDBUFFORCE: c_int = 31;
pub const SO_RCVBUFFORCE: c_int = 33;
pub const SO_PASSSEC: c_int = 34;
pub const SO_MARK: c_int = 36;
pub const SO_RXQ_OVFL: c_int = 40;
pub const SO_WIFI_STATUS: c_int = 41;
pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS;
pub const SO_PEEK_OFF: c_int = 42;
pub const SO_NOFCS: c_int = 43;
pub const SO_LOCK_FILTER: c_int = 44;
pub const SO_SELECT_ERR_QUEUE: c_int = 45;
pub const SO_BUSY_POLL: c_int = 46;
pub const SO_MAX_PACING_RATE: c_int = 47;
pub const SO_BPF_EXTENSIONS: c_int = 48;
pub const SO_INCOMING_CPU: c_int = 49;
pub const SO_ATTACH_BPF: c_int = 50;
pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER;
pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51;
pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52;
pub const SO_CNX_ADVICE: c_int = 53;
pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54;
pub const SO_MEMINFO: c_int = 55;
pub const SO_INCOMING_NAPI_ID: c_int = 56;
pub const SO_COOKIE: c_int = 57;
pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58;
pub const SO_PEERGROUPS: c_int = 59;
pub const SO_ZEROCOPY: c_int = 60;
pub const SO_TXTIME: c_int = 61;
pub const SCM_TXTIME: c_int = SO_TXTIME;
pub const SO_BINDTOIFINDEX: c_int = 62;
cfg_if! {
if #[cfg(linux_time_bits64)] {
const SO_TIMESTAMP_NEW: c_int = 63;
const SO_TIMESTAMPNS_NEW: c_int = 64;
const SO_TIMESTAMPING_NEW: c_int = 65;
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
} else {
const SO_TIMESTAMP_OLD: c_int = 29;
const SO_TIMESTAMPNS_OLD: c_int = 35;
const SO_TIMESTAMPING_OLD: c_int = 37;
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
}
}
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
pub const SO_PREFER_BUSY_POLL: c_int = 69;
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
pub const SO_NETNS_COOKIE: c_int = 71;
pub const SO_BUF_LOCK: c_int = 72;
pub const SO_RESERVE_MEM: c_int = 73;
pub const SO_TXREHASH: c_int = 74;
pub const SO_RCVMARK: c_int = 75;
pub const SO_PASSPIDFD: c_int = 76;
pub const SO_PEERPIDFD: c_int = 77;
pub const SO_DEVMEM_LINEAR: c_int = 78;
pub const SO_DEVMEM_DMABUF: c_int = 79;
pub const SO_DEVMEM_DONTNEED: c_int = 80;
// Defined in unix/linux_like/mod.rs
// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
// Ioctl Constants
pub const TCGETS: Ioctl = 0x540d;
pub const TCSETS: Ioctl = 0x540e;
pub const TCSETSW: Ioctl = 0x540f;
pub const TCSETSF: Ioctl = 0x5410;
pub const TCGETA: Ioctl = 0x5401;
pub const TCSETA: Ioctl = 0x5402;
pub const TCSETAW: Ioctl = 0x5403;
pub const TCSETAF: Ioctl = 0x5404;
pub const TCSBRK: Ioctl = 0x5405;
pub const TCXONC: Ioctl = 0x5406;
pub const TCFLSH: Ioctl = 0x5407;
pub const TIOCEXCL: Ioctl = 0x740d;
pub const TIOCNXCL: Ioctl = 0x740e;
pub const TIOCSCTTY: Ioctl = 0x5480;
pub const TIOCGPGRP: Ioctl = 0x40047477;
pub const TIOCSPGRP: Ioctl = 0x80047476;
pub const TIOCOUTQ: Ioctl = 0x7472;
pub const TIOCSTI: Ioctl = 0x5472;
pub const TIOCGWINSZ: Ioctl = 0x40087468;
pub const TIOCSWINSZ: Ioctl = 0x80087467;
pub const TIOCMGET: Ioctl = 0x741d;
pub const TIOCMBIS: Ioctl = 0x741b;
pub const TIOCMBIC: Ioctl = 0x741c;
pub const TIOCMSET: Ioctl = 0x741a;
pub const TIOCGSOFTCAR: Ioctl = 0x5481;
pub const TIOCSSOFTCAR: Ioctl = 0x5482;
pub const FIONREAD: Ioctl = 0x467f;
pub const TIOCINQ: Ioctl = FIONREAD;
pub const TIOCLINUX: Ioctl = 0x5483;
pub const TIOCCONS: Ioctl = 0x80047478;
pub const TIOCGSERIAL: Ioctl = 0x5484;
pub const TIOCSSERIAL: Ioctl = 0x5485;
pub const TIOCPKT: Ioctl = 0x5470;
pub const FIONBIO: Ioctl = 0x667e;
pub const TIOCNOTTY: Ioctl = 0x5471;
pub const TIOCSETD: Ioctl = 0x7401;
pub const TIOCGETD: Ioctl = 0x7400;
pub const TCSBRKP: Ioctl = 0x5486;
pub const TIOCSBRK: Ioctl = 0x5427;
pub const TIOCCBRK: Ioctl = 0x5428;
pub const TIOCGSID: Ioctl = 0x7416;
pub const TCGETS2: Ioctl = 0x4030542a;
pub const TCSETS2: Ioctl = 0x8030542b;
pub const TCSETSW2: Ioctl = 0x8030542c;
pub const TCSETSF2: Ioctl = 0x8030542d;
pub const TIOCGPTN: Ioctl = 0x40045430;
pub const TIOCSPTLCK: Ioctl = 0x80045431;
pub const TIOCGDEV: Ioctl = 0x40045432;
pub const TIOCSIG: Ioctl = 0x80045436;
pub const TIOCVHANGUP: Ioctl = 0x5437;
pub const TIOCGPKT: Ioctl = 0x40045438;
pub const TIOCGPTLCK: Ioctl = 0x40045439;
pub const TIOCGEXCL: Ioctl = 0x40045440;
pub const TIOCGPTPEER: Ioctl = 0x20005441;
//pub const TIOCGISO7816: Ioctl = 0x40285442;
//pub const TIOCSISO7816: Ioctl = 0xc0285443;
pub const FIONCLEX: Ioctl = 0x6602;
pub const FIOCLEX: Ioctl = 0x6601;
pub const FIOASYNC: Ioctl = 0x667d;
pub const TIOCSERCONFIG: Ioctl = 0x5488;
pub const TIOCSERGWILD: Ioctl = 0x5489;
pub const TIOCSERSWILD: Ioctl = 0x548a;
pub const TIOCGLCKTRMIOS: Ioctl = 0x548b;
pub const TIOCSLCKTRMIOS: Ioctl = 0x548c;
pub const TIOCSERGSTRUCT: Ioctl = 0x548d;
pub const TIOCSERGETLSR: Ioctl = 0x548e;
pub const TIOCSERGETMULTI: Ioctl = 0x548f;
pub const TIOCSERSETMULTI: Ioctl = 0x5490;
pub const TIOCMIWAIT: Ioctl = 0x5491;
pub const TIOCGICOUNT: Ioctl = 0x5492;
pub const FIOQSIZE: Ioctl = 0x667f;
pub const TIOCSLTC: Ioctl = 0x7475;
pub const TIOCGETP: Ioctl = 0x7408;
pub const TIOCSETP: Ioctl = 0x7409;
pub const TIOCSETN: Ioctl = 0x740a;
pub const BLKIOMIN: Ioctl = 0x20001278;
pub const BLKIOOPT: Ioctl = 0x20001279;
pub const BLKSSZGET: Ioctl = 0x20001268;
pub const BLKPBSZGET: Ioctl = 0x2000127B;
cfg_if! {
if #[cfg(target_env = "musl")] {
pub const TIOCGRS485: Ioctl = 0x4020542e;
pub const TIOCSRS485: Ioctl = 0xc020542f;
}
}
pub const TIOCM_LE: c_int = 0x001;
pub const TIOCM_DTR: c_int = 0x002;
pub const TIOCM_RTS: c_int = 0x004;
pub const TIOCM_ST: c_int = 0x010;
pub const TIOCM_SR: c_int = 0x020;
pub const TIOCM_CTS: c_int = 0x040;
pub const TIOCM_CAR: c_int = 0x100;
pub const TIOCM_CD: c_int = TIOCM_CAR;
pub const TIOCM_RNG: c_int = 0x200;
pub const TIOCM_RI: c_int = TIOCM_RNG;
pub const TIOCM_DSR: c_int = 0x400;
pub const BOTHER: crate::speed_t = 0o010000;
pub const IBSHIFT: crate::tcflag_t = 16;
// RLIMIT Constants
cfg_if! {
if #[cfg(any(target_env = "gnu", target_env = "uclibc"))] {
pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0;
pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1;
pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2;
pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3;
pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4;
pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 5;
pub const RLIMIT_AS: crate::__rlimit_resource_t = 6;
pub const RLIMIT_RSS: crate::__rlimit_resource_t = 7;
pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 8;
pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 9;
pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10;
pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11;
pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12;
pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13;
pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14;
pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15;
#[allow(deprecated)]
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS;
} else if #[cfg(target_env = "musl")] {
pub const RLIMIT_CPU: c_int = 0;
pub const RLIMIT_FSIZE: c_int = 1;
pub const RLIMIT_DATA: c_int = 2;
pub const RLIMIT_STACK: c_int = 3;
pub const RLIMIT_CORE: c_int = 4;
pub const RLIMIT_NOFILE: c_int = 5;
pub const RLIMIT_AS: c_int = 6;
pub const RLIMIT_RSS: c_int = 7;
pub const RLIMIT_NPROC: c_int = 8;
pub const RLIMIT_MEMLOCK: c_int = 9;
pub const RLIMIT_LOCKS: c_int = 10;
pub const RLIMIT_SIGPENDING: c_int = 11;
pub const RLIMIT_MSGQUEUE: c_int = 12;
pub const RLIMIT_NICE: c_int = 13;
pub const RLIMIT_RTPRIO: c_int = 14;
pub const RLIMIT_RTTIME: c_int = 15;
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIM_NLIMITS: c_int = 16;
#[allow(deprecated)]
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS;
pub const RLIM_INFINITY: crate::rlim_t = !0;
}
}
cfg_if! {
if #[cfg(target_env = "gnu")] {
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16;
} else if #[cfg(target_env = "uclibc")] {
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 15;
}
}
cfg_if! {
if #[cfg(
any(target_arch = "mips64", target_arch = "mips64r6"),
any(target_env = "gnu", target_env = "uclibc")
)] {
pub const RLIM_INFINITY: crate::rlim_t = !0;
}
}
cfg_if! {
if #[cfg(all(
any(target_arch = "mips", target_arch = "mips32r6"),
any(
all(target_env = "uclibc", linux_time_bits64),
all(
target_env = "gnu",
any(linux_time_bits64, gnu_file_offset_bits64)
)
)
))] {
pub const RLIM_INFINITY: crate::rlim_t = !0;
} else if #[cfg(all(
any(target_arch = "mips", target_arch = "mips32r6"),
any(target_env = "uclibc", target_env = "gnu"),
not(linux_time_bits64)
))] {
pub const RLIM_INFINITY: crate::rlim_t = 0x7fffffff;
}
}

View File

@@ -0,0 +1,20 @@
cfg_if! {
if #[cfg(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"
))] {
mod mips;
pub use self::mips::*;
} else if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] {
mod powerpc;
pub use self::powerpc::*;
} else if #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] {
mod sparc;
pub use self::sparc::*;
} else {
mod generic;
pub use self::generic::*;
}
}

View File

@@ -0,0 +1,280 @@
use crate::prelude::*;
use crate::Ioctl;
// arch/powerpc/include/uapi/asm/socket.h
pub const SOL_SOCKET: c_int = 1;
// Defined in unix/linux_like/mod.rs
// pub const SO_DEBUG: c_int = 1;
pub const SO_REUSEADDR: c_int = 2;
pub const SO_TYPE: c_int = 3;
pub const SO_ERROR: c_int = 4;
pub const SO_DONTROUTE: c_int = 5;
pub const SO_BROADCAST: c_int = 6;
pub const SO_SNDBUF: c_int = 7;
pub const SO_RCVBUF: c_int = 8;
pub const SO_KEEPALIVE: c_int = 9;
pub const SO_OOBINLINE: c_int = 10;
pub const SO_NO_CHECK: c_int = 11;
pub const SO_PRIORITY: c_int = 12;
pub const SO_LINGER: c_int = 13;
pub const SO_BSDCOMPAT: c_int = 14;
pub const SO_REUSEPORT: c_int = 15;
// powerpc only differs in these
pub const SO_RCVLOWAT: c_int = 16;
pub const SO_SNDLOWAT: c_int = 17;
cfg_if! {
if #[cfg(linux_time_bits64)] {
const SO_RCVTIMEO_NEW: c_int = 66;
const SO_SNDTIMEO_NEW: c_int = 67;
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
} else {
const SO_RCVTIMEO_OLD: c_int = 18;
const SO_SNDTIMEO_OLD: c_int = 19;
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
}
}
pub const SO_PASSCRED: c_int = 20;
pub const SO_PEERCRED: c_int = 21;
// end
pub const SO_SECURITY_AUTHENTICATION: c_int = 22;
pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
pub const SO_BINDTODEVICE: c_int = 25;
pub const SO_ATTACH_FILTER: c_int = 26;
pub const SO_DETACH_FILTER: c_int = 27;
pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
pub const SO_PEERNAME: c_int = 28;
cfg_if! {
if #[cfg(linux_time_bits64)] {
const SO_TIMESTAMP_NEW: c_int = 63;
const SO_TIMESTAMPNS_NEW: c_int = 64;
const SO_TIMESTAMPING_NEW: c_int = 65;
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
} else {
const SO_TIMESTAMP_OLD: c_int = 29;
const SO_TIMESTAMPNS_OLD: c_int = 35;
const SO_TIMESTAMPING_OLD: c_int = 37;
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
}
}
pub const SO_ACCEPTCONN: c_int = 30;
pub const SO_PEERSEC: c_int = 31;
pub const SO_SNDBUFFORCE: c_int = 32;
pub const SO_RCVBUFFORCE: c_int = 33;
pub const SO_PASSSEC: c_int = 34;
pub const SO_MARK: c_int = 36;
pub const SO_PROTOCOL: c_int = 38;
pub const SO_DOMAIN: c_int = 39;
pub const SO_RXQ_OVFL: c_int = 40;
pub const SO_WIFI_STATUS: c_int = 41;
pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS;
pub const SO_PEEK_OFF: c_int = 42;
pub const SO_NOFCS: c_int = 43;
pub const SO_LOCK_FILTER: c_int = 44;
pub const SO_SELECT_ERR_QUEUE: c_int = 45;
pub const SO_BUSY_POLL: c_int = 46;
pub const SO_MAX_PACING_RATE: c_int = 47;
pub const SO_BPF_EXTENSIONS: c_int = 48;
pub const SO_INCOMING_CPU: c_int = 49;
pub const SO_ATTACH_BPF: c_int = 50;
pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER;
pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51;
pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52;
pub const SO_CNX_ADVICE: c_int = 53;
pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54;
pub const SO_MEMINFO: c_int = 55;
pub const SO_INCOMING_NAPI_ID: c_int = 56;
pub const SO_COOKIE: c_int = 57;
pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58;
pub const SO_PEERGROUPS: c_int = 59;
pub const SO_ZEROCOPY: c_int = 60;
pub const SO_TXTIME: c_int = 61;
pub const SCM_TXTIME: c_int = SO_TXTIME;
pub const SO_BINDTOIFINDEX: c_int = 62;
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
pub const SO_PREFER_BUSY_POLL: c_int = 69;
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
pub const SO_NETNS_COOKIE: c_int = 71;
pub const SO_BUF_LOCK: c_int = 72;
pub const SO_RESERVE_MEM: c_int = 73;
pub const SO_TXREHASH: c_int = 74;
pub const SO_RCVMARK: c_int = 75;
pub const SO_PASSPIDFD: c_int = 76;
pub const SO_PEERPIDFD: c_int = 77;
pub const SO_DEVMEM_LINEAR: c_int = 78;
pub const SO_DEVMEM_DMABUF: c_int = 79;
pub const SO_DEVMEM_DONTNEED: c_int = 80;
// Defined in unix/linux_like/mod.rs
// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
// Ioctl Constants
cfg_if! {
if #[cfg(target_env = "gnu")] {
pub const TCGETS: Ioctl = 0x403c7413;
pub const TCSETS: Ioctl = 0x803c7414;
pub const TCSETSW: Ioctl = 0x803c7415;
pub const TCSETSF: Ioctl = 0x803c7416;
} else if #[cfg(target_env = "musl")] {
pub const TCGETS: Ioctl = 0x402c7413;
pub const TCSETS: Ioctl = 0x802c7414;
pub const TCSETSW: Ioctl = 0x802c7415;
pub const TCSETSF: Ioctl = 0x802c7416;
}
}
pub const TCGETA: Ioctl = 0x40147417;
pub const TCSETA: Ioctl = 0x80147418;
pub const TCSETAW: Ioctl = 0x80147419;
pub const TCSETAF: Ioctl = 0x8014741C;
pub const TCSBRK: Ioctl = 0x2000741D;
pub const TCXONC: Ioctl = 0x2000741E;
pub const TCFLSH: Ioctl = 0x2000741F;
pub const TIOCEXCL: Ioctl = 0x540C;
pub const TIOCNXCL: Ioctl = 0x540D;
pub const TIOCSCTTY: Ioctl = 0x540E;
pub const TIOCGPGRP: Ioctl = 0x40047477;
pub const TIOCSPGRP: Ioctl = 0x80047476;
pub const TIOCOUTQ: Ioctl = 0x40047473;
pub const TIOCSTI: Ioctl = 0x5412;
pub const TIOCGWINSZ: Ioctl = 0x40087468;
pub const TIOCSWINSZ: Ioctl = 0x80087467;
pub const TIOCMGET: Ioctl = 0x5415;
pub const TIOCMBIS: Ioctl = 0x5416;
pub const TIOCMBIC: Ioctl = 0x5417;
pub const TIOCMSET: Ioctl = 0x5418;
pub const TIOCGSOFTCAR: Ioctl = 0x5419;
pub const TIOCSSOFTCAR: Ioctl = 0x541A;
pub const FIONREAD: Ioctl = 0x4004667F;
pub const TIOCINQ: Ioctl = FIONREAD;
pub const TIOCLINUX: Ioctl = 0x541C;
pub const TIOCCONS: Ioctl = 0x541D;
pub const TIOCGSERIAL: Ioctl = 0x541E;
pub const TIOCSSERIAL: Ioctl = 0x541F;
pub const TIOCPKT: Ioctl = 0x5420;
pub const FIONBIO: Ioctl = 0x8004667e;
pub const TIOCNOTTY: Ioctl = 0x5422;
pub const TIOCSETD: Ioctl = 0x5423;
pub const TIOCGETD: Ioctl = 0x5424;
pub const TCSBRKP: Ioctl = 0x5425;
pub const TIOCSBRK: Ioctl = 0x5427;
pub const TIOCCBRK: Ioctl = 0x5428;
pub const TIOCGSID: Ioctl = 0x5429;
pub const TIOCGRS485: Ioctl = 0x542e;
pub const TIOCSRS485: Ioctl = 0x542f;
pub const TIOCGPTN: Ioctl = 0x40045430;
pub const TIOCSPTLCK: Ioctl = 0x80045431;
pub const TIOCGDEV: Ioctl = 0x40045432;
pub const TIOCSIG: Ioctl = 0x80045436;
pub const TIOCVHANGUP: Ioctl = 0x5437;
pub const TIOCGPKT: Ioctl = 0x40045438;
pub const TIOCGPTLCK: Ioctl = 0x40045439;
pub const TIOCGEXCL: Ioctl = 0x40045440;
pub const TIOCGPTPEER: Ioctl = 0x20005441;
//pub const TIOCGISO7816: Ioctl = 0x40285442;
//pub const TIOCSISO7816: Ioctl = 0xc0285443;
pub const FIONCLEX: Ioctl = 0x20006602;
pub const FIOCLEX: Ioctl = 0x20006601;
pub const FIOASYNC: Ioctl = 0x8004667d;
pub const TIOCSERCONFIG: Ioctl = 0x5453;
pub const TIOCSERGWILD: Ioctl = 0x5454;
pub const TIOCSERSWILD: Ioctl = 0x5455;
pub const TIOCGLCKTRMIOS: Ioctl = 0x5456;
pub const TIOCSLCKTRMIOS: Ioctl = 0x5457;
pub const TIOCSERGSTRUCT: Ioctl = 0x5458;
pub const TIOCSERGETLSR: Ioctl = 0x5459;
pub const TIOCSERGETMULTI: Ioctl = 0x545A;
pub const TIOCSERSETMULTI: Ioctl = 0x545B;
pub const TIOCMIWAIT: Ioctl = 0x545C;
pub const TIOCGICOUNT: Ioctl = 0x545D;
pub const BLKIOMIN: Ioctl = 0x20001278;
pub const BLKIOOPT: Ioctl = 0x20001279;
pub const BLKSSZGET: Ioctl = 0x20001268;
pub const BLKPBSZGET: Ioctl = 0x2000127B;
//pub const FIOQSIZE: Ioctl = 0x40086680;
pub const TIOCM_LE: c_int = 0x001;
pub const TIOCM_DTR: c_int = 0x002;
pub const TIOCM_RTS: c_int = 0x004;
pub const TIOCM_ST: c_int = 0x008;
pub const TIOCM_SR: c_int = 0x010;
pub const TIOCM_CTS: c_int = 0x020;
pub const TIOCM_CAR: c_int = 0x040;
pub const TIOCM_CD: c_int = TIOCM_CAR;
pub const TIOCM_RNG: c_int = 0x080;
pub const TIOCM_RI: c_int = TIOCM_RNG;
pub const TIOCM_DSR: c_int = 0x100;
pub const BOTHER: crate::speed_t = 0o0037;
pub const IBSHIFT: crate::tcflag_t = 16;
// RLIMIT Constants
cfg_if! {
if #[cfg(target_env = "gnu")] {
pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0;
pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1;
pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2;
pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3;
pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4;
pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5;
pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6;
pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7;
pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8;
pub const RLIMIT_AS: crate::__rlimit_resource_t = 9;
pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10;
pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11;
pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12;
pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13;
pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14;
pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15;
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16;
#[allow(deprecated)]
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS;
} else if #[cfg(target_env = "musl")] {
pub const RLIMIT_CPU: c_int = 0;
pub const RLIMIT_FSIZE: c_int = 1;
pub const RLIMIT_DATA: c_int = 2;
pub const RLIMIT_STACK: c_int = 3;
pub const RLIMIT_CORE: c_int = 4;
pub const RLIMIT_RSS: c_int = 5;
pub const RLIMIT_NPROC: c_int = 6;
pub const RLIMIT_NOFILE: c_int = 7;
pub const RLIMIT_MEMLOCK: c_int = 8;
pub const RLIMIT_AS: c_int = 9;
pub const RLIMIT_LOCKS: c_int = 10;
pub const RLIMIT_SIGPENDING: c_int = 11;
pub const RLIMIT_MSGQUEUE: c_int = 12;
pub const RLIMIT_NICE: c_int = 13;
pub const RLIMIT_RTPRIO: c_int = 14;
pub const RLIMIT_RTTIME: c_int = 15;
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIM_NLIMITS: c_int = 16;
#[allow(deprecated)]
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS;
}
}
pub const RLIM_INFINITY: crate::rlim_t = !0;

Some files were not shown because too many files have changed in this diff Show More