diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml index 6a4fbc7f4d332..b36f4f9d2ba57 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/full_ci.yml @@ -118,11 +118,8 @@ jobs: powerpc64le-unknown-linux-gnu, s390x-unknown-linux-gnu, riscv64gc-unknown-linux-gnu, - # FIXME: A recent nightly causes a linker failure: - # https://github.com/rust-lang/rust/issues/76679 - # See this comment for more details: - # https://github.com/rust-lang/libc/pull/2225#issuecomment-880696737 - #wasm32-wasi, + wasm32-wasip1, + wasm32-wasip2, sparc64-unknown-linux-gnu, wasm32-unknown-emscripten, x86_64-linux-android, diff --git a/CHANGELOG.md b/CHANGELOG.md index a5ac00205b010..01c340acaa11f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,37 @@ ## [Unreleased] +## [0.2.159](https://github.com/rust-lang/libc/compare/0.2.158...0.2.159) - 2024-09-24 + +### Added + +- Android: add more `AT_*` constants in +- Apple: add missing `NOTE_*` constants in +- Hermit: add missing error numbers in +- Hurd: add `__timeval` for 64-bit support in +- Linux: add `epoll_pwait2` in +- Linux: add `mq_notify` in +- Linux: add missing `NFT_CT_*` constants in +- Linux: add the `fchmodat2` syscall in +- Linux: add the `mseal` syscall in +- OpenBSD: add `sendmmsg` and `recvmmsg` in +- Unix: add `IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` in +- VxWorks: add `S_ISVTX` in +- VxWorks: add `vxCpuLib` and `taskLib` functions +- WASIp2: add definitions for `std::net` support in + +### Fixed + +- Correctly handle version checks when `clippy-driver` is used + +### Changed + +- EspIdf: change signal constants to c_int in +- HorizonOS: update network definitions in +- Linux: combine `ioctl` APIs in +- WASI: enable CI testing in +- WASIp2: enable CI testing in + ## [0.2.158](https://github.com/rust-lang/libc/compare/0.2.157...0.2.158) - 2024-08-19 ### Other diff --git a/Cargo.toml b/Cargo.toml index 8fe2ad6badabf..3ca0827a37aed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.158" +version = "0.2.159" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/build.rs b/build.rs index 076bbc0114f86..ce4541e62955c 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,5 @@ use std::env; -use std::process::Command; +use std::process::{Command, Output}; use std::str; // List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we @@ -30,6 +30,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "libc_thread_local", "libc_underscore_const_names", "libc_union", + "libc_ctest", ]; // Extra values to allow for check-cfg. @@ -193,31 +194,29 @@ fn main() { } } -fn rustc_minor_nightly() -> (u32, bool) { - macro_rules! otry { - ($e:expr) => { - match $e { - Some(e) => e, - None => panic!("Failed to get rustc version"), - } - }; - } - +/// Run `rustc --version` and capture the output, adjusting arguments as needed if `clippy-driver` +/// is used instead. +fn rustc_version_cmd(is_clippy_driver: bool) -> Output { let rustc = env::var_os("RUSTC").expect("Failed to get rustc version: missing RUSTC env"); - let mut cmd = match env::var_os("RUSTC_WRAPPER").as_ref() { - Some(wrapper) if !wrapper.is_empty() => { + + let mut cmd = match env::var_os("RUSTC_WRAPPER") { + Some(ref wrapper) if wrapper.is_empty() => Command::new(rustc), + Some(wrapper) => { let mut cmd = Command::new(wrapper); cmd.arg(rustc); + if is_clippy_driver { + cmd.arg("--rustc"); + } + cmd } - _ => Command::new(rustc), + None => Command::new(rustc), }; - let output = cmd - .arg("--version") - .output() - .ok() - .expect("Failed to get rustc version"); + cmd.arg("--version"); + + let output = cmd.output().ok().expect("Failed to get rustc version"); + if !output.status.success() { panic!( "failed to run rustc: {}", @@ -225,7 +224,29 @@ fn rustc_minor_nightly() -> (u32, bool) { ); } + output +} + +/// Return the minor version of `rustc`, as well as a bool indicating whether or not the version +/// is a nightly. +fn rustc_minor_nightly() -> (u32, bool) { + macro_rules! otry { + ($e:expr) => { + match $e { + Some(e) => e, + None => panic!("Failed to get rustc version"), + } + }; + } + + let mut output = rustc_version_cmd(false); + + if otry!(str::from_utf8(&output.stdout).ok()).starts_with("clippy") { + output = rustc_version_cmd(true); + } + let version = otry!(str::from_utf8(&output.stdout).ok()); + let mut pieces = version.split('.'); if pieces.next() != Some("rustc 1") { diff --git a/ci/docker/wasm32-wasi/Dockerfile b/ci/docker/wasm32-wasi/Dockerfile deleted file mode 100644 index 80ae09f75038b..0000000000000 --- a/ci/docker/wasm32-wasi/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -FROM ubuntu:23.10 - -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - clang \ - curl \ - git \ - libc6-dev \ - make \ - xz-utils - -# Note that we're using `git reset --hard` to pin to a specific commit for -# verification for now. The sysroot is currently in somewhat of a state of flux -# and is expected to have breaking changes, so this is an attempt to mitigate -# those breaking changes on `libc`'s own CI -RUN git clone https://github.com/WebAssembly/wasi-libc && \ - cd wasi-libc && \ - git reset --hard ad5133410f66b93a2381db5b542aad5e0964db96 -RUN apt-get install -y --no-install-recommends llvm -RUN make -C wasi-libc install -j $(nproc) INSTALL_DIR=/wasi-libc - -RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/dev/wasmtime-dev-x86_64-linux.tar.xz | \ - tar xJf - -ENV PATH=$PATH:/wasmtime-dev-x86_64-linux -COPY docker/wasm32-wasi/clang.sh /wasi-libc/bin/clang - -RUN apt-get install -y --no-install-recommends lld -RUN ln -s /usr/bin/wasm-ld-10 /usr/bin/wasm-ld -ENV PATH=$PATH:/usr/lib/llvm-10/bin - -# Of note here is our clang wrapper which just executes a normal clang -# executable with the right sysroot, and then we're sure to turn off the -# crt-static feature to ensure that the CRT that we're specifying with `clang` -# is used. -ENV CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime \ - CARGO_TARGET_WASM32_WASI_LINKER=/wasi-libc/bin/clang \ - CC_wasm32_wasi=/wasi-libc/bin/clang \ - PATH=$PATH:/rust/bin \ - RUSTFLAGS=-Ctarget-feature=-crt-static diff --git a/ci/docker/wasm32-wasi/clang.sh b/ci/docker/wasm32-wasi/clang.sh deleted file mode 100755 index 83f5da5ad6d81..0000000000000 --- a/ci/docker/wasm32-wasi/clang.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env sh -exec /usr/bin/clang --target=wasm32-wasi --sysroot /wasi-libc/sysroot "$@" diff --git a/ci/docker/wasm32-wasip1/Dockerfile b/ci/docker/wasm32-wasip1/Dockerfile new file mode 100644 index 0000000000000..e1318151d2e62 --- /dev/null +++ b/ci/docker/wasm32-wasip1/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:24.04 + +COPY wasi.sh / +RUN bash /wasi.sh + +# Note that `-D_WASI_EMULATED_PROCESS_CLOCKS` is used to enable access to +# clock-related defines even though they're emulated. Also note that the usage +# of `-Ctarget-feature=-crt-static` here forces usage of the external wasi-libc +# installed via `wasi-sdk` instead of the version that comes with the standard +# library. +ENV CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime \ + CARGO_TARGET_WASM32_WASIP1_LINKER=/opt/wasi-sdk/bin/clang \ + CARGO_TARGET_WASM32_WASIP1_RUSTFLAGS="-lwasi-emulated-process-clocks -Ctarget-feature=-crt-static" \ + CC_wasm32_wasip1=/opt/wasi-sdk/bin/clang \ + CFLAGS_wasm32_wasip1=-D_WASI_EMULATED_PROCESS_CLOCKS \ + PATH=$PATH:/rust/bin:/wasmtime diff --git a/ci/docker/wasm32-wasip2/Dockerfile b/ci/docker/wasm32-wasip2/Dockerfile new file mode 100644 index 0000000000000..c433c491353f9 --- /dev/null +++ b/ci/docker/wasm32-wasip2/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:24.04 + +COPY wasi.sh / +RUN bash /wasi.sh + +# Note that most of these are copied from `wasm32-wasip1/Dockerfile` +# +# FIXME: the `-Clink-arg` to export `cabi_realloc` is a bug in the target +# itself, this should be fixed upstream. +ENV CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtime \ + CARGO_TARGET_WASM32_WASIP2_LINKER=/opt/wasi-sdk/bin/clang \ + CARGO_TARGET_WASM32_WASIP2_RUSTFLAGS="-lwasi-emulated-process-clocks -Ctarget-feature=-crt-static -Clink-arg=-Wl,--export,cabi_realloc" \ + CC_wasm32_wasip2=/opt/wasi-sdk/bin/clang \ + CFLAGS_wasm32_wasip2=-D_WASI_EMULATED_PROCESS_CLOCKS \ + PATH=$PATH:/rust/bin:/wasmtime diff --git a/ci/wasi.sh b/ci/wasi.sh new file mode 100644 index 0000000000000..a06c1f45af11a --- /dev/null +++ b/ci/wasi.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -ex + +apt-get update +apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + clang \ + xz-utils + +# Wasmtime is used to execute tests and wasi-sdk is used to compile tests. +# Download appropriate versions here and configure various flags below. +# +# At the time of this writing wasmtime 24.0.0 is the latest release and +# wasi-sdk-24 is the latest release, that these numbers match is just +# coincidence. +wasmtime=24.0.0 +wasi_sdk=24 + +curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | \ + tar xJf - +mv wasmtime-v$wasmtime-x86_64-linux wasmtime + +# The pre-built `*.deb` files for wasi-sdk install to `/opt/wasi-sdk` +curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$wasi_sdk/wasi-sdk-$wasi_sdk.0-x86_64-linux.deb +dpkg -i ./wasi-sdk-*.deb diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 033458e8bd5de..8f25c7f2ca9d9 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -14,7 +14,7 @@ A test crate for the libc crate. [dependencies.libc] path = ".." -version = "0.2.158" +version = "0.2.159" default-features = false [build-dependencies] diff --git a/libc-test/build.rs b/libc-test/build.rs index 30ab41202e945..75dcd14fc83be 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1521,6 +1521,7 @@ fn test_dragonflybsd(target: &str) { fn test_wasi(target: &str) { assert!(target.contains("wasi")); + let p2 = target.contains("wasip2"); let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); @@ -1530,9 +1531,13 @@ fn test_wasi(target: &str) { "dirent.h", "errno.h", "fcntl.h", + "langinfo.h", "limits.h", "locale.h", "malloc.h", + [p2]: "netdb.h", + [p2]: "netinet/in.h", + [p2]: "netinet/tcp.h", "poll.h", "sched.h", "stdbool.h", @@ -1541,6 +1546,7 @@ fn test_wasi(target: &str) { "stdio.h", "stdlib.h", "string.h", + "sys/ioctl.h", "sys/resource.h", "sys/select.h", "sys/socket.h", @@ -1549,16 +1555,26 @@ fn test_wasi(target: &str) { "sys/types.h", "sys/uio.h", "sys/utsname.h", - "sys/ioctl.h", "time.h", "unistd.h", "wasi/api.h", - "wasi/libc.h", "wasi/libc-find-relpath.h", "wasi/libc-nocwd.h", + "wasi/libc.h", "wchar.h", } + // Currently `ctest2` doesn't support macros-in-static-expressions and will + // panic on them. That affects `CLOCK_*` defines in wasi to set this here + // to omit them. + cfg.cfg("libc_ctest", None); + + // `ctest2` has a hard-coded list of default cfgs which doesn't include + // wasip2, which is why it has to be set here manually. + if p2 { + cfg.cfg("target_env", Some("p2")); + } + cfg.type_name(move |ty, is_struct, is_union| match ty { "FILE" | "fd_set" | "DIR" => ty.to_string(), t if is_union => format!("union {}", t), @@ -1577,20 +1593,35 @@ fn test_wasi(target: &str) { } }); - // Looks like LLD doesn't merge duplicate imports, so if the Rust - // code imports from a module and the C code also imports from a - // module we end up with two imports of function pointers which - // import the same thing but have different function pointers - cfg.skip_fn_ptrcheck(|f| f.starts_with("__wasi")); + // These have a different and internal type in header files and are only + // used here to generate a pointer to them in bindings so skip these tests. + cfg.skip_static(|c| c.starts_with("_CLOCK_")); + + cfg.skip_const(|c| match c { + // These constants aren't yet defined in wasi-libc. + // Exposing them is being tracked by https://github.com/WebAssembly/wasi-libc/issues/531. + "SO_BROADCAST" | "SO_LINGER" => true, + + _ => false, + }); + + cfg.skip_fn(|f| match f { + // This function doesn't actually exist in libc's header files + "__errno_location" => true, + + // The `timeout` argument to this function is `*const` in Rust but + // mutable in C which causes a mismatch. Avoiding breakage by changing + // this in wasi-libc and instead accepting that this is slightly + // different. + "select" => true, + + _ => false, + }); // d_name is declared as a flexible array in WASI libc, so it // doesn't support sizeof. cfg.skip_field(|s, field| s == "dirent" && field == "d_name"); - // Currently Rust/clang disagree on function argument ABI, so skip these - // tests. For more info see WebAssembly/tool-conventions#88 - cfg.skip_roundtrip(|_| true); - cfg.generate("../src/lib.rs", "main.rs"); } @@ -4197,6 +4228,12 @@ fn test_linux(target: &str) { true } + // FIXME: Requires >= 6.6 kernel headers. + "SYS_fchmodat2" => true, + + // FIXME: Requires >= 6.10 kernel headers. + "SYS_mseal" => true, + // FIXME: seems to not be available all the time (from : "PF_VCPU" | "PF_IDLE" diff --git a/libc-test/semver/android-aarch64.txt b/libc-test/semver/android-aarch64.txt index 8a38e32dd5022..d634779743526 100644 --- a/libc-test/semver/android-aarch64.txt +++ b/libc-test/semver/android-aarch64.txt @@ -1,3 +1,5 @@ +AT_SYSINFO_EHDR +AT_VECTOR_SIZE_ARCH HWCAP2_DCPODP HWCAP2_FLAGM2 HWCAP2_FRINT diff --git a/libc-test/semver/android-arm.txt b/libc-test/semver/android-arm.txt index fe1ce5bba1c5d..15578095c5c5f 100644 --- a/libc-test/semver/android-arm.txt +++ b/libc-test/semver/android-arm.txt @@ -1,3 +1,4 @@ +AT_SYSINFO_EHDR NGREG PTRACE_GETFPREGS PTRACE_GETREGS diff --git a/libc-test/semver/android-i686.txt b/libc-test/semver/android-i686.txt index eb6ecadba60b5..5ffb45ebc32c6 100644 --- a/libc-test/semver/android-i686.txt +++ b/libc-test/semver/android-i686.txt @@ -1,3 +1,7 @@ +AT_SYSINFO +AT_SYSINFO_EHDR +AT_VECTOR_SIZE_ARCH +SYS_memfd_secret __c_anonymous_uc_sigmask __c_anonymous_uc_sigmask_with_padding time64_t diff --git a/libc-test/semver/android-riscv64.txt b/libc-test/semver/android-riscv64.txt new file mode 100644 index 0000000000000..723278a289464 --- /dev/null +++ b/libc-test/semver/android-riscv64.txt @@ -0,0 +1,90 @@ +AT_SYSINFO_EHDR +AT_VECTOR_SIZE_ARCH +HWCAP2_AFP +HWCAP2_BF16 +HWCAP2_BTI +HWCAP2_DCPODP +HWCAP2_DGH +HWCAP2_EBF16 +HWCAP2_ECV +HWCAP2_FLAGM2 +HWCAP2_FRINT +HWCAP2_I8MM +HWCAP2_MTE +HWCAP2_MTE3 +HWCAP2_RNG +HWCAP2_RPRES +HWCAP2_SME +HWCAP2_SME_B16F32 +HWCAP2_SME_F16F32 +HWCAP2_SME_F32F32 +HWCAP2_SME_F64F64 +HWCAP2_SME_FA64 +HWCAP2_SME_I16I64 +HWCAP2_SME_I8I32 +HWCAP2_SVE2 +HWCAP2_SVEAES +HWCAP2_SVEBF16 +HWCAP2_SVEBITPERM +HWCAP2_SVEF32MM +HWCAP2_SVEF64MM +HWCAP2_SVEI8MM +HWCAP2_SVEPMULL +HWCAP2_SVESHA3 +HWCAP2_SVESM4 +HWCAP2_SVE_EBF16 +HWCAP2_WFXT +HWCAP_AES +HWCAP_ASIMD +HWCAP_ASIMDDP +HWCAP_ASIMDFHM +HWCAP_ASIMDHP +HWCAP_ASIMDRDM +HWCAP_ATOMICS +HWCAP_CPUID +HWCAP_CRC32 +HWCAP_DCPOP +HWCAP_DIT +HWCAP_EVTSTRM +HWCAP_FCMA +HWCAP_FLAGM +HWCAP_FP +HWCAP_FPHP +HWCAP_ILRCPC +HWCAP_JSCVT +HWCAP_LRCPC +HWCAP_PACA +HWCAP_PACG +HWCAP_PMULL +HWCAP_SB +HWCAP_SHA1 +HWCAP_SHA2 +HWCAP_SHA3 +HWCAP_SHA512 +HWCAP_SM3 +HWCAP_SM4 +HWCAP_SSBS +HWCAP_SVE +HWCAP_USCAT +PROT_BTI +PROT_MTE +SYS_accept +SYS_arch_specific_syscall +SYS_fcntl +SYS_getrlimit +SYS_memfd_secret +SYS_migrate_pages +SYS_msgctl +SYS_msgget +SYS_msgrcv +SYS_msgsnd +SYS_semctl +SYS_semget +SYS_semop +SYS_semtimedop +SYS_shmat +SYS_shmctl +SYS_shmdt +SYS_shmget +SYS_sync_file_range +SYS_syscalls diff --git a/libc-test/semver/android-x86_64.txt b/libc-test/semver/android-x86_64.txt index c4bb87bccb66d..05919bb6f40e5 100644 --- a/libc-test/semver/android-x86_64.txt +++ b/libc-test/semver/android-x86_64.txt @@ -1,3 +1,5 @@ +AT_SYSINFO_EHDR +AT_VECTOR_SIZE_ARCH EFLAGS FS_BASE GS_BASE diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 28b3286bfc339..ddd651da0d6df 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -136,13 +136,39 @@ ATF_NETMASK ATF_PERM ATF_PUBL ATF_USETRAILERS +AT_BASE +AT_BASE_PLATFORM +AT_CLKTCK +AT_EGID AT_EMPTY_PATH +AT_ENTRY +AT_EUID +AT_EXECFD +AT_EXECFN AT_FDCWD +AT_FLAGS +AT_GID +AT_HWCAP +AT_HWCAP2 +AT_IGNORE +AT_MINSIGSTKSZ +AT_NOTELF AT_NO_AUTOMOUNT +AT_NULL +AT_PAGESZ +AT_PHDR +AT_PHENT +AT_PHNUM +AT_PLATFORM +AT_RANDOM AT_RECURSIVE AT_REMOVEDIR +AT_RSEQ_ALIGN +AT_RSEQ_FEATURE_SIZE +AT_SECURE AT_SYMLINK_FOLLOW AT_SYMLINK_NOFOLLOW +AT_UID B0 B1000000 B110 @@ -1477,11 +1503,16 @@ NFT_CMP_LT NFT_CMP_LTE NFT_CMP_NEQ NFT_CONTINUE +NFT_CT_AVGPKT NFT_CT_BYTES NFT_CT_DIRECTION NFT_CT_DST +NFT_CT_DST_IP +NFT_CT_DST_IP6 +NFT_CT_EVENTMASK NFT_CT_EXPIRATION NFT_CT_HELPER +NFT_CT_ID NFT_CT_L3PROTOCOL NFT_CT_LABELS NFT_CT_MARK @@ -1491,8 +1522,11 @@ NFT_CT_PROTO_DST NFT_CT_PROTO_SRC NFT_CT_SECMARK NFT_CT_SRC +NFT_CT_SRC_IP +NFT_CT_SRC_IP6 NFT_CT_STATE NFT_CT_STATUS +NFT_CT_ZONE NFT_DATA_RESERVED_MASK NFT_DATA_VALUE NFT_DATA_VALUE_MAXLEN diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 4d280dc731dfd..89b5cca443395 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1004,6 +1004,8 @@ NOTE_FORK NOTE_LEEWAY NOTE_LINK NOTE_LOWAT +NOTE_MACHTIME +NOTE_MACH_CONTINUOUS_TIME NOTE_NONE NOTE_NSECONDS NOTE_PCTRLMASK diff --git a/libc-test/semver/hermit.txt b/libc-test/semver/hermit.txt new file mode 100644 index 0000000000000..ef3f1894fbb89 --- /dev/null +++ b/libc-test/semver/hermit.txt @@ -0,0 +1,302 @@ +AF_INET +AF_INET6 +CLOCK_REALTIME +CLOCK_MONOTONIC +DT_UNKNOWN +DT_FIFO +DT_CHR +DT_DIR +DT_BLK +DT_REG +DT_LNK +DT_SOCK +DT_WHT +EAI_AGAIN +EAI_BADFLAGS +EAI_FAIL +EAI_FAMILY +EAI_MEMORY +EAI_NODATA +EAI_NONAME +EAI_SERVICE +EAI_SOCKTYPE +EAI_SYSTEM +EAI_OVERFLOW +EFD_SEMAPHORE +EFD_NONBLOCK +EFD_CLOEXEC +F_DUPFD +F_GETFD +F_SETFD +F_GETFL +F_SETFL +FD_CLOEXEC +FIONBIO +FUTEX_RELATIVE_TIMEOUT +IP_TOS +IP_TTL +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MULTICAST_TTL +IP_MULTICAST_LOOP +IPPROTO_IP +IPPROTO_TCP +IPPROTO_UDP +IPPROTO_IPV6 +IPV6_ADD_MEMBERSHIP +IPV6_DROP_MEMBERSHIP +IPV6_MULTICAST_LOOP +IPV6_V6ONLY +MSG_PEEK +O_RDONLY +O_WRONLY +O_RDWR +O_CREAT +O_EXCL +O_TRUNC +O_APPEND +O_NONBLOCK +O_DIRECTORY +POLLIN +POLLPRI +POLLOUT +POLLERR +POLLHUP +POLLNVAL +POLLRDNORM +POLLRDBAND +POLLWRNORM +POLLWRBAND +POLLRDHUP +S_IRWXU +S_IRUSR +S_IWUSR +S_IXUSR +S_IRWXG +S_IRGRP +S_IWGRP +S_IXGRP +S_IRWXO +S_IROTH +S_IWOTH +S_IXOTH +S_IFMT +S_IFSOCK +S_IFLNK +S_IFREG +S_IFBLK +S_IFDIR +S_IFCHR +S_IFIFO +SHUT_RD +SHUT_WR +SHUT_RDWR +SO_REUSEADDR +SO_KEEPALIVE +SO_BROADCAST +SO_LINGER +SO_SNDBUF +SO_RCVBUF +SO_SNDTIMEO +SO_RCVTIMEO +SO_ERROR +SOCK_STREAM +SOCK_DGRAM +SOCK_NONBLOCK +SOCK_CLOEXEC +SOL_SOCKET +STDIN_FILENO +STDOUT_FILENO +STDERR_FILENO +TCP_NODELAY +EPERM +ENOENT +ESRCH +EINTR +EIO +ENXIO +E2BIG +ENOEXEC +EBADF +ECHILD +EAGAIN +ENOMEM +EACCES +EFAULT +ENOTBLK +EBUSY +EEXIST +EXDEV +ENODEV +ENOTDIR +EISDIR +EINVAL +ENFILE +EMFILE +ENOTTY +ETXTBSY +EFBIG +ENOSPC +ESPIPE +EROFS +EMLINK +EPIPE +EDOM +ERANGE +EDEADLK +ENAMETOOLONG +ENOLCK +ENOSYS +ENOTEMPTY +ELOOP +EWOULDBLOCK +ENOMSG +EIDRM +ECHRNG +EL2NSYNC +EL3HLT +EL3RST +ELNRNG +EUNATCH +ENOCSI +EL2HLT +EBADE +EBADR +EXFULL +ENOANO +EBADRQC +EBADSLT +EDEADLOCK +EBFONT +ENOSTR +ENODATA +ETIME +ENOSR +ENONET +ENOPKG +EREMOTE +ENOLINK +EADV +ESRMNT +ECOMM +EPROTO +EMULTIHOP +EDOTDOT +EBADMSG +EOVERFLOW +ENOTUNIQ +EBADFD +EREMCHG +ELIBACC +ELIBBAD +ELIBSCN +ELIBMAX +ELIBEXEC +EILSEQ +ERESTART +ESTRPIPE +EUSERS +ENOTSOCK +EDESTADDRREQ +EMSGSIZE +EPROTOTYPE +ENOPROTOOPT +EPROTONOSUPPORT +ESOCKTNOSUPPORT +EOPNOTSUPP +EPFNOSUPPORT +EAFNOSUPPORT +EADDRINUSE +EADDRNOTAVAIL +ENETDOWN +ENETUNREACH +ENETRESET +ECONNABORTED +ECONNRESET +ENOBUFS +EISCONN +ENOTCONN +ESHUTDOWN +ETOOMANYREFS +ETIMEDOUT +ECONNREFUSED +EHOSTDOWN +EHOSTUNREACH +EALREADY +EINPROGRESS +ESTALE +EUCLEAN +ENOTNAM +ENAVAIL +EISNAM +EREMOTEIO +EDQUOT +ENOMEDIUM +EMEDIUMTYPE +ECANCELED +ENOKEY +EKEYEXPIRED +EKEYREVOKED +EKEYREJECTED +EOWNERDEAD +ENOTRECOVERABLE +ERFKIL +EHWPOISON +addrinfo +dirent64 +in6_addr +in_addr +iovec +pollfd +sockaddr +sockaddr_in +sockaddr_in6 +sockaddr_storage +stat +timespec +sys_abort +sys_accept +sys_alloc +sys_alloc_zeroed +sys_available_parallelism +sys_bind +sys_clock_gettime +sys_close +sys_connect +sys_dealloc +sys_dup +sys_errno +sys_eventfd +sys_exit +sys_fcntl +sys_freeaddrinfo +sys_fstat +sys_futex_wait +sys_futex_wake +sys_getaddrinfo +sys_getdents64 +sys_getpeername +sys_getsockname +sys_getsockopt +sys_ioctl +sys_listen +sys_lstat +sys_mkdir +sys_nanosleep +sys_open +sys_poll +sys_read +sys_readv +sys_realloc +sys_recv +sys_recvfrom +sys_rmdir +sys_send +sys_sendto +sys_setsockopt +sys_shutdown +sys_socket +sys_stat +sys_unlink +sys_write +sys_writev diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 6fa88e6c77927..ce4f85484eee0 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -191,9 +191,13 @@ NFT_CMP_LT NFT_CMP_LTE NFT_CMP_NEQ NFT_CONTINUE +NFT_CT_AVGPKT NFT_CT_BYTES NFT_CT_DIRECTION NFT_CT_DST +NFT_CT_DST_IP +NFT_CT_DST_IP6 +NFT_CT_EVENTMASK NFT_CT_EXPIRATION NFT_CT_HELPER NFT_CT_L3PROTOCOL @@ -205,8 +209,11 @@ NFT_CT_PROTO_DST NFT_CT_PROTO_SRC NFT_CT_SECMARK NFT_CT_SRC +NFT_CT_SRC_IP +NFT_CT_SRC_IP6 NFT_CT_STATE NFT_CT_STATUS +NFT_CT_ZONE NFT_DATA_RESERVED_MASK NFT_DATA_VALUE NFT_DATA_VALUE_MAXLEN @@ -650,6 +657,7 @@ malloc_info malloc_trim malloc_usable_size mallopt +mq_notify nl_mmap_hdr nl_mmap_req nl_pktinfo @@ -703,3 +711,4 @@ putpwent putgrent execveat close_range +epoll_pwait2 diff --git a/libc-test/semver/linux-i686.txt b/libc-test/semver/linux-i686.txt index a14498adc8396..2f40472dcfaeb 100644 --- a/libc-test/semver/linux-i686.txt +++ b/libc-test/semver/linux-i686.txt @@ -132,6 +132,7 @@ SYS_mknod SYS_mmap2 SYS_modify_ldt SYS_mpx +SYS_mseal SYS_nice SYS_oldfstat SYS_oldlstat diff --git a/libc-test/semver/linux-powerpc.txt b/libc-test/semver/linux-powerpc.txt index d9aacc973d972..2826bb98d20e3 100644 --- a/libc-test/semver/linux-powerpc.txt +++ b/libc-test/semver/linux-powerpc.txt @@ -82,6 +82,7 @@ SYS_mknod SYS_mmap2 SYS_modify_ldt SYS_mpx +SYS_mseal SYS_multiplexer SYS_nice SYS_oldfstat diff --git a/libc-test/semver/linux-s390x.txt b/libc-test/semver/linux-s390x.txt index f5d089e3d5e50..96be9c25e4f3c 100644 --- a/libc-test/semver/linux-s390x.txt +++ b/libc-test/semver/linux-s390x.txt @@ -59,6 +59,7 @@ SYS_link SYS_lstat SYS_mkdir SYS_mknod +SYS_mseal SYS_newfstatat SYS_nice SYS_open diff --git a/libc-test/semver/linux-x86_64.txt b/libc-test/semver/linux-x86_64.txt index 6ad111e7308cc..c8a509c215085 100644 --- a/libc-test/semver/linux-x86_64.txt +++ b/libc-test/semver/linux-x86_64.txt @@ -107,6 +107,7 @@ SYS_lstat SYS_mkdir SYS_mknod SYS_modify_ldt +SYS_mseal SYS_open SYS_pause SYS_pipe diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 6f07fec590ff5..197df09e1c2c6 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1137,6 +1137,7 @@ mknodat mkostemp mkostemps mkstemps +mmsghdr mount_info mrand48 msdosfs_args @@ -1216,6 +1217,7 @@ readlinkat reallocarray reboot recvmsg +recvmmsg regcomp regerror regex_t @@ -1237,6 +1239,7 @@ sem_init sem_open sem_timedwait sem_unlink +sendmmsg sendmsg setdomainname setgrent diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 03248dfec58c7..bb8e319def299 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -152,6 +152,8 @@ IF_NAMESIZE IGNBRK IGNCR IGNPAR +IN6ADDR_ANY_INIT +IN6ADDR_LOOPBACK_INIT INADDR_ANY INADDR_BROADCAST INADDR_LOOPBACK @@ -586,6 +588,8 @@ hstrerror if_indextoname if_nametoindex in6_addr +in6addr_any +in6addr_loopback in_addr in_addr_t in_port_t diff --git a/libc-test/semver/wasi-p2.txt b/libc-test/semver/wasi-p2.txt new file mode 100644 index 0000000000000..bb79dfd0dc1e8 --- /dev/null +++ b/libc-test/semver/wasi-p2.txt @@ -0,0 +1,59 @@ +sa_family_t +in_port_t +in_addr_t +socklen_t +sockaddr +in_addr +sockaddr_in +in6_addr +sockaddr_in6 +sockaddr_storage +addrinfo +ip_mreq +ipv6_mreq +SHUT_RD +SHUT_WR +SHUT_RDWR +MSG_NOSIGNAL +MSG_PEEK +SO_REUSEADDR +SO_ERROR +SO_BROADCAST +SO_LINGER +SO_RCVTIMEO +SO_SNDTIMEO +SOCK_DGRAM +SOCK_STREAM +SOL_SOCKET +AF_INET +AF_INET6 +IPPROTO_IP +IPPROTO_TCP +IPPROTO_IPV6 +IP_TTL +IP_MULTICAST_TTL +IP_MULTICAST_LOOP +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IPV6_MULTICAST_LOOP +IPV6_JOIN_GROUP +IPV6_LEAVE_GROUP +IPV6_V6ONLY +IPV6_ADD_MEMBERSHIP +IPV6_DROP_MEMBERSHIP +TCP_NODELAY +EAI_SYSTEM +socket +connect +bind +listen +accept +getsockname +getpeername +sendto +recvfrom +getsockopt +setsockopt +getaddrinfo +freeaddrinfo +gai_strerror diff --git a/src/hermit.rs b/src/hermit.rs index 145d1241b190b..77df54ae12d8d 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -267,6 +267,140 @@ 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; diff --git a/src/unix/align.rs b/src/unix/align.rs index 4fdba9a6aba69..2e7c954ccff7a 100644 --- a/src/unix/align.rs +++ b/src/unix/align.rs @@ -4,3 +4,11 @@ s! { pub s6_addr: [u8; 16], } } + +pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], +}; + +pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], +}; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 06b6c62a63f35..92d724071a3d4 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4522,6 +4522,8 @@ pub const NOTE_ABSOLUTE: u32 = 0x00000008; pub const NOTE_LEEWAY: u32 = 0x00000010; pub const NOTE_CRITICAL: u32 = 0x00000020; pub const NOTE_BACKGROUND: u32 = 0x00000040; +pub const NOTE_MACH_CONTINUOUS_TIME: u32 = 0x00000080; +pub const NOTE_MACHTIME: u32 = 0x00000100; pub const NOTE_TRACK: u32 = 0x00000001; pub const NOTE_TRACKERR: u32 = 0x00000002; pub const NOTE_CHILD: u32 = 0x00000004; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index e92cf65940141..dcd3582fd7bf8 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -92,6 +92,11 @@ s! { pub piod_addr: *mut ::c_void, pub piod_len: ::size_t, } + + pub struct mmsghdr { + pub msg_hdr: ::msghdr, + pub msg_len: ::c_uint, + } } pub const D_T_FMT: ::nl_item = 0; @@ -848,6 +853,20 @@ extern "C" { 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 ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + mmsg: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + timeout: *mut ::timespec, + ) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 0ad2473138080..0517a47b69c30 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -401,11 +401,6 @@ s! { pub sdl_data: [::c_char; 12], } - pub struct mmsghdr { - pub msg_hdr: ::msghdr, - pub msg_len: ::c_uint, - } - pub struct __exit_status { pub e_termination: u16, pub e_exit: u16, @@ -2781,20 +2776,6 @@ extern "C" { pub fn kqueue1(flags: ::c_int) -> ::c_int; - pub fn sendmmsg( - sockfd: ::c_int, - msgvec: *mut ::mmsghdr, - vlen: ::c_uint, - flags: ::c_int, - ) -> ::c_int; - pub fn recvmmsg( - sockfd: ::c_int, - msgvec: *mut ::mmsghdr, - vlen: ::c_uint, - flags: ::c_int, - timeout: *mut ::timespec, - ) -> ::c_int; - pub fn _lwp_self() -> lwpid_t; pub fn memmem( haystack: *const ::c_void, diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 71f1ac8d98c22..ad422fe718349 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -450,6 +450,11 @@ s! { pub tv_nsec: __syscall_slong_t, } + pub struct __timeval { + pub tv_sec: i32, + pub tv_usec: i32, + } + pub struct __locale_data { pub _address: u8, } diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index a062175eef746..c4c78939cba48 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -533,6 +533,9 @@ 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` diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index e549f3b5168e6..64ce93dd22916 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -585,6 +585,11 @@ 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; diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 7b87a1d49dc3e..bd3146deb7f9f 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -417,6 +417,10 @@ pub const SYS_syscalls: ::c_long = 436; 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; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index 9639e1b4fa589..97cf137b7fc79 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -264,32 +264,6 @@ pub const RTLD_GLOBAL: ::c_int = 0x00100; pub const RTLD_NOW: ::c_int = 2; pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; -// From NDK's linux/auxvec.h -pub const AT_NULL: ::c_ulong = 0; -pub const AT_IGNORE: ::c_ulong = 1; -pub const AT_EXECFD: ::c_ulong = 2; -pub const AT_PHDR: ::c_ulong = 3; -pub const AT_PHENT: ::c_ulong = 4; -pub const AT_PHNUM: ::c_ulong = 5; -pub const AT_PAGESZ: ::c_ulong = 6; -pub const AT_BASE: ::c_ulong = 7; -pub const AT_FLAGS: ::c_ulong = 8; -pub const AT_ENTRY: ::c_ulong = 9; -pub const AT_NOTELF: ::c_ulong = 10; -pub const AT_UID: ::c_ulong = 11; -pub const AT_EUID: ::c_ulong = 12; -pub const AT_GID: ::c_ulong = 13; -pub const AT_EGID: ::c_ulong = 14; -pub const AT_PLATFORM: ::c_ulong = 15; -pub const AT_HWCAP: ::c_ulong = 16; -pub const AT_CLKTCK: ::c_ulong = 17; -pub const AT_SECURE: ::c_ulong = 23; -pub const AT_BASE_PLATFORM: ::c_ulong = 24; -pub const AT_RANDOM: ::c_ulong = 25; -pub const AT_HWCAP2: ::c_ulong = 26; -pub const AT_EXECFN: ::c_ulong = 31; -pub const AT_MINSIGSTKSZ: ::c_ulong = 51; - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, __reserved: [0; 36], diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index 9d414dc15fb39..209f050f25ce5 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -345,6 +345,18 @@ pub const SYS_fsmount: ::c_long = 432; pub const SYS_fspick: ::c_long = 433; pub const SYS_syscalls: ::c_long = 436; +// 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; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index be6b5011c21cc..a7363304c65ce 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -794,6 +794,10 @@ 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; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index a9cc5943bb469..a8e935967c132 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -2572,6 +2572,14 @@ pub const NFT_CT_PROTO_DST: ::c_int = 12; pub const NFT_CT_LABELS: ::c_int = 13; pub const NFT_CT_PKTS: ::c_int = 14; pub const NFT_CT_BYTES: ::c_int = 15; +pub const NFT_CT_AVGPKT: ::c_int = 16; +pub const NFT_CT_ZONE: ::c_int = 17; +pub const NFT_CT_EVENTMASK: ::c_int = 18; +pub const NFT_CT_SRC_IP: ::c_int = 19; +pub const NFT_CT_DST_IP: ::c_int = 20; +pub const NFT_CT_SRC_IP6: ::c_int = 21; +pub const NFT_CT_DST_IP6: ::c_int = 22; +pub const NFT_CT_ID: ::c_int = 23; pub const NFT_LIMIT_PKTS: ::c_int = 0; pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1; @@ -3535,6 +3543,34 @@ pub const KLOG_CONSOLE_LEVEL: ::c_int = 8; pub const KLOG_SIZE_UNREAD: ::c_int = 9; pub const KLOG_SIZE_BUFFER: ::c_int = 10; +// From NDK's linux/auxvec.h +pub const AT_NULL: ::c_ulong = 0; +pub const AT_IGNORE: ::c_ulong = 1; +pub const AT_EXECFD: ::c_ulong = 2; +pub const AT_PHDR: ::c_ulong = 3; +pub const AT_PHENT: ::c_ulong = 4; +pub const AT_PHNUM: ::c_ulong = 5; +pub const AT_PAGESZ: ::c_ulong = 6; +pub const AT_BASE: ::c_ulong = 7; +pub const AT_FLAGS: ::c_ulong = 8; +pub const AT_ENTRY: ::c_ulong = 9; +pub const AT_NOTELF: ::c_ulong = 10; +pub const AT_UID: ::c_ulong = 11; +pub const AT_EUID: ::c_ulong = 12; +pub const AT_GID: ::c_ulong = 13; +pub const AT_EGID: ::c_ulong = 14; +pub const AT_PLATFORM: ::c_ulong = 15; +pub const AT_HWCAP: ::c_ulong = 16; +pub const AT_CLKTCK: ::c_ulong = 17; +pub const AT_SECURE: ::c_ulong = 23; +pub const AT_BASE_PLATFORM: ::c_ulong = 24; +pub const AT_RANDOM: ::c_ulong = 25; +pub const AT_HWCAP2: ::c_ulong = 26; +pub const AT_RSEQ_FEATURE_SIZE: ::c_ulong = 27; +pub const AT_RSEQ_ALIGN: ::c_ulong = 28; +pub const AT_EXECFN: ::c_ulong = 31; +pub const AT_MINSIGSTKSZ: ::c_ulong = 51; + // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions // currently used in CI in some configurations, so we define them here. diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 89c93aba8818e..4a14d692c8652 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -855,6 +855,7 @@ 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_mseal: ::c_long = 462; cfg_if! { if #[cfg(libc_align)] { diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index dd5732e0dcc14..cb7fdf7661472 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -823,3 +823,4 @@ 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_mseal: ::c_long = 462; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 27f477bb48f85..4391eb3fa7968 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -1044,6 +1044,8 @@ 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_fchmodat2: ::c_long = 452; +pub const SYS_mseal: ::c_long = 462; // offsets in user_regs_structs, from sys/reg.h pub const EBX: ::c_int = 0; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 284a1788f4409..c8a805cdd36cb 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -892,6 +892,7 @@ 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_mseal: ::c_long = 462; pub const PROT_BTI: ::c_int = 0x10; pub const PROT_MTE: ::c_int = 0x20; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 61ee2dcc9b50a..e85429ef97bf6 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -946,6 +946,7 @@ 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_mseal: ::c_long = 462; extern "C" { diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs index 3831dfad9d414..9b37907bbb28a 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs @@ -438,6 +438,8 @@ 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_fchmodat2: ::c_long = 452; +pub const SYS_mseal: ::c_long = 462; extern "C" { pub fn sysctl( diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs index 06aa0da2d74aa..90745b1762335 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs @@ -366,6 +366,7 @@ pub const SYS_memfd_secret: ::c_long = __X32_SYSCALL_BIT + 447; pub const SYS_process_mrelease: ::c_long = __X32_SYSCALL_BIT + 448; pub const SYS_futex_waitv: ::c_long = __X32_SYSCALL_BIT + 449; pub const SYS_set_mempolicy_home_node: ::c_long = __X32_SYSCALL_BIT + 450; +pub const SYS_fchmodat2: ::c_long = __X32_SYSCALL_BIT + 452; pub const SYS_rt_sigaction: ::c_long = __X32_SYSCALL_BIT + 512; pub const SYS_rt_sigreturn: ::c_long = __X32_SYSCALL_BIT + 513; pub const SYS_ioctl: ::c_long = __X32_SYSCALL_BIT + 514; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index d6e5eb69c7fbb..75d150c90d58a 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1405,7 +1405,6 @@ extern "C" { pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; pub fn glob64( pattern: *const ::c_char, @@ -1541,6 +1540,16 @@ extern "C" { // Added in `glibc` 2.34 pub fn close_range(first: ::c_uint, last: ::c_uint, flags: ::c_int) -> ::c_int; + + pub fn mq_notify(mqdes: ::mqd_t, sevp: *const ::sigevent) -> ::c_int; + + pub fn epoll_pwait2( + epfd: ::c_int, + events: *mut ::epoll_event, + maxevents: ::c_int, + timeout: *const ::timespec, + sigmask: *const ::sigset_t, + ) -> ::c_int; } cfg_if! { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 779faa81ff16e..1973b3f574efa 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3980,6 +3980,13 @@ pub const NFT_CT_PROTO_DST: ::c_int = 12; pub const NFT_CT_LABELS: ::c_int = 13; pub const NFT_CT_PKTS: ::c_int = 14; pub const NFT_CT_BYTES: ::c_int = 15; +pub const NFT_CT_AVGPKT: ::c_int = 16; +pub const NFT_CT_ZONE: ::c_int = 17; +pub const NFT_CT_EVENTMASK: ::c_int = 18; +pub const NFT_CT_SRC_IP: ::c_int = 19; +pub const NFT_CT_DST_IP: ::c_int = 20; +pub const NFT_CT_SRC_IP6: ::c_int = 21; +pub const NFT_CT_DST_IP6: ::c_int = 22; pub const NFT_LIMIT_PKTS: ::c_int = 0; pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1; @@ -5628,6 +5635,8 @@ extern "C" { ) -> ::ssize_t; pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int; + + pub fn ioctl(fd: ::c_int, request: ::Ioctl, ...) -> ::c_int; } // LFS64 extensions diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 8225f26adb474..4ac3e60d43079 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -840,6 +840,7 @@ 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_mseal: ::c_long = 462; extern "C" { pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index bdf25455fd8cc..834a442802b27 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -796,6 +796,7 @@ 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_mseal: ::c_long = 462; extern "C" { pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 12280851e7471..7fad04677f8a4 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -936,6 +936,7 @@ 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_fchmodat2: ::c_long = 452; // offsets in user_regs_structs, from sys/reg.h pub const EBX: ::c_int = 0; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 54e072b314a84..24e6b8419253a 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -561,6 +561,7 @@ 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_mseal: ::c_long = 462; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index aa4cbf87f8a22..567914f7b8cd5 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -722,3 +722,4 @@ 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_mseal: ::c_long = 462; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index 4d17868000ebd..dc617d42fe0cc 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -608,6 +608,8 @@ 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_fchmodat2: ::c_long = 452; +pub const SYS_mseal: ::c_long = 462; // offsets in user_regs_structs, from sys/reg.h pub const R15: ::c_int = 0; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 699c8181f8466..a4c8f79c35cad 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -853,7 +853,6 @@ extern "C" { new_limit: *const ::rlimit, old_limit: *mut ::rlimit, ) -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index b8d10cb94595f..32c65545a8905 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -353,7 +353,6 @@ pub const UDP_SEGMENT: ::c_int = 103; pub const YESEXPR: ::c_int = ((5) << 8) | (0); extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; pub fn pthread_rwlockattr_getkind_np( diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8b3d988ae38ae..6bab825b0449b 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -313,6 +313,11 @@ pub const ATF_PERM: ::c_int = 0x04; pub const ATF_PUBL: ::c_int = 0x08; pub const ATF_USETRAILERS: ::c_int = 0x10; +extern "C" { + pub static in6addr_loopback: in6_addr; + pub static in6addr_any: in6_addr; +} + cfg_if! { if #[cfg(any(target_os = "l4re", target_os = "espidf"))] { // required libraries for L4Re and the ESP-IDF framework are linked externally, ATM diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index e2e98ee9c394a..1a2a907d83191 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -89,14 +89,14 @@ pub const MSG_EOR: ::c_int = 0x08; pub const PTHREAD_STACK_MIN: ::size_t = 768; -pub const SIGABRT: ::size_t = 1; -pub const SIGFPE: ::size_t = 1; -pub const SIGILL: ::size_t = 1; -pub const SIGINT: ::size_t = 1; -pub const SIGSEGV: ::size_t = 1; -pub const SIGTERM: ::size_t = 1; -pub const SIGHUP: ::size_t = 1; -pub const SIGQUIT: ::size_t = 1; +pub const SIGABRT: ::c_int = 1; +pub const SIGFPE: ::c_int = 1; +pub const SIGILL: ::c_int = 1; +pub const SIGINT: ::c_int = 1; +pub const SIGSEGV: ::c_int = 1; +pub const SIGTERM: ::c_int = 1; +pub const SIGHUP: ::c_int = 1; +pub const SIGQUIT: ::c_int = 1; pub const NSIG: ::size_t = 2; extern "C" { diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index 9c70f7b031b63..97e0b18f6fb71 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -21,6 +21,14 @@ pub type sbintime_t = ::c_longlong; pub type sigset_t = ::c_ulong; s! { + pub struct hostent { + pub h_name: *mut ::c_char, + pub h_aliases: *mut *mut ::c_char, + pub h_addrtype: u16, + pub h_length: u16, + pub h_addr_list: *mut *mut ::c_char, + } + pub struct sockaddr { pub sa_family: ::sa_family_t, pub sa_data: [::c_char; 26usize], @@ -35,6 +43,7 @@ s! { 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 { diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index a572cc38bfda9..29693f6ec2402 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -53,6 +53,21 @@ cfg_if! { } } +cfg_if! { + if #[cfg(not(target_os = "horizon"))] { + s!{ + pub struct hostent { + pub h_name: *mut ::c_char, + pub h_aliases: *mut *mut ::c_char, + pub h_addrtype: ::c_int, + pub h_length: ::c_int, + pub h_addr_list: *mut *mut ::c_char, + pub h_addr: *mut ::c_char, + } + } + } +} + s! { // The order of the `ai_addr` field in this struct is crucial // for converting between the Rust and C types. @@ -87,16 +102,7 @@ s! { } pub struct in_addr { - pub s_addr: ::in_addr_t, - } - - pub struct hostent { - pub h_name: *mut ::c_char, - pub h_aliases: *mut *mut ::c_char, - pub h_addrtype: ::c_int, - pub h_length: ::c_int, - pub h_addr_list: *mut *mut ::c_char, - pub h_addr: *mut ::c_char, + pub s_addr: ::in_addr_t, } pub struct pollfd { diff --git a/src/unix/no_align.rs b/src/unix/no_align.rs index f6b9f4c12d4ba..b435d72aa7db0 100644 --- a/src/unix/no_align.rs +++ b/src/unix/no_align.rs @@ -4,3 +4,13 @@ s! { __align: [u32; 0], } } + +pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], + __align: [0u32; 0], +}; + +pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + __align: [0u32; 0], +}; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 4f0274241394e..314283410aed6 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -782,6 +782,7 @@ pub const S_IFSOCK: ::c_int = 0xc000; pub const S_ISUID: ::c_int = 0x0800; pub const S_ISGID: ::c_int = 0x0400; pub const S_ISTXT: ::c_int = 0x0200; +pub const S_ISVTX: ::c_int = 0o1000; pub const S_IRUSR: ::c_int = 0x0100; pub const S_IWUSR: ::c_int = 0x0080; pub const S_IXUSR: ::c_int = 0x0040; @@ -1812,6 +1813,10 @@ extern "C" { pub fn taskIdSelf() -> ::TASK_ID; pub fn taskDelay(ticks: ::_Vx_ticks_t) -> ::c_int; + // taskLib.h + pub fn taskNameSet(task_id: ::TASK_ID, task_name: *mut ::c_char) -> ::c_int; + pub fn taskNameGet(task_id: ::TASK_ID, buf_name: *mut ::c_char, bufsize: ::size_t) -> ::c_int; + // rtpLibCommon.h pub fn rtpInfoGet(rtpId: ::RTP_ID, rtpStruct: *mut ::RTP_DESC) -> ::c_int; pub fn rtpSpawn( @@ -1871,6 +1876,10 @@ extern "C" { ) -> ::c_int; pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int; + + // vxCpuLib.h + fn vxCpuEnabledGet() -> ::cpuset_t; // Get set of running CPU's in the system + fn vxCpuConfiguredGet() -> ::cpuset_t; // Get set of Configured CPU's in the system } //Dummy functions, these don't really exist in VxWorks. diff --git a/src/wasi.rs b/src/wasi/mod.rs similarity index 96% rename from src/wasi.rs rename to src/wasi/mod.rs index 36047cbaed87d..d47d4076cc720 100644 --- a/src/wasi.rs +++ b/src/wasi/mod.rs @@ -245,14 +245,14 @@ pub const AT_SYMLINK_FOLLOW: c_int = 0x2; pub const AT_REMOVEDIR: c_int = 0x4; pub const UTIME_OMIT: c_long = 0xfffffffe; pub const UTIME_NOW: c_long = 0xffffffff; -pub const S_IFIFO: mode_t = 49152; +pub const S_IFIFO: mode_t = 0o1_0000; pub const S_IFCHR: mode_t = 8192; pub const S_IFBLK: mode_t = 24576; pub const S_IFDIR: mode_t = 16384; pub const S_IFREG: mode_t = 32768; pub const S_IFLNK: mode_t = 40960; pub const S_IFSOCK: mode_t = 49152; -pub const S_IFMT: mode_t = 57344; +pub const S_IFMT: mode_t = 0o17_0000; pub const S_IRWXO: mode_t = 0x7; pub const S_IXOTH: mode_t = 0x1; pub const S_IWOTH: mode_t = 0x2; @@ -372,16 +372,26 @@ pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; pub const _SC_IOV_MAX: c_int = 60; pub const _SC_SYMLOOP_MAX: c_int = 173; -#[allow(unused_unsafe)] // `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82 -pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_MONOTONIC)) }; -#[allow(unused_unsafe)] -pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = - unsafe { clockid_t(ptr_addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; -#[allow(unused_unsafe)] -pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_REALTIME)) }; -#[allow(unused_unsafe)] -pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = - unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; +cfg_if! { + if #[cfg(libc_ctest)] { + // skip these constants when this is active because `ctest` currently + // panics on parsing the constants below + } else { + // `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82 + #[allow(unused_unsafe)] + pub static CLOCK_MONOTONIC: clockid_t = + unsafe { clockid_t(ptr_addr_of!(_CLOCK_MONOTONIC)) }; + #[allow(unused_unsafe)] + pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = + unsafe { clockid_t(ptr_addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; + #[allow(unused_unsafe)] + pub static CLOCK_REALTIME: clockid_t = + unsafe { clockid_t(ptr_addr_of!(_CLOCK_REALTIME)) }; + #[allow(unused_unsafe)] + pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = + unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; + } +} pub const ABDAY_1: ::nl_item = 0x20000; pub const ABDAY_2: ::nl_item = 0x20001; @@ -869,3 +879,10 @@ extern "C" { pub fn __errno_location() -> *mut ::c_int; } + +cfg_if! { + if #[cfg(target_env = "p2")] { + mod p2; + pub use self::p2::*; + } +} diff --git a/src/wasi/p2.rs b/src/wasi/p2.rs new file mode 100644 index 0000000000000..3e8eb95fcd1a5 --- /dev/null +++ b/src/wasi/p2.rs @@ -0,0 +1,161 @@ +pub type sa_family_t = ::c_ushort; +pub type in_port_t = ::c_ushort; +pub type in_addr_t = ::c_uint; + +pub type socklen_t = ::c_uint; + +s! { + #[repr(align(16))] + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [::c_char; 0], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + #[repr(align(16))] + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + } + + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [::c_uchar; 16], + } + + #[repr(align(16))] + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: ::c_uint, + pub sin6_addr: in6_addr, + pub sin6_scope_id: ::c_uint, + } + + #[repr(align(16))] + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + pub __ss_data: [::c_char; 32], + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut ::c_char, + pub ai_next: *mut addrinfo, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: ::c_uint, + } +} + +pub const SHUT_RD: ::c_int = 1 << 0; +pub const SHUT_WR: ::c_int = 1 << 1; +pub const SHUT_RDWR: ::c_int = SHUT_RD | SHUT_WR; + +pub const MSG_NOSIGNAL: ::c_int = 0x4000; +pub const MSG_PEEK: ::c_int = 0x0002; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_ERROR: ::c_int = 4; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_LINGER: ::c_int = 13; +pub const SO_RCVTIMEO: ::c_int = 66; +pub const SO_SNDTIMEO: ::c_int = 67; + +pub const SOCK_DGRAM: ::c_int = 5; +pub const SOCK_STREAM: ::c_int = 6; + +pub const SOL_SOCKET: ::c_int = 0x7fffffff; + +pub const AF_INET: ::c_int = 1; +pub const AF_INET6: ::c_int = 2; + +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_TCP: ::c_int = 6; +pub const IPPROTO_IPV6: ::c_int = 41; + +pub const IP_TTL: ::c_int = 2; +pub const IP_MULTICAST_TTL: ::c_int = 33; +pub const IP_MULTICAST_LOOP: ::c_int = 34; +pub const IP_ADD_MEMBERSHIP: ::c_int = 35; +pub const IP_DROP_MEMBERSHIP: ::c_int = 36; + +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; +pub const IPV6_JOIN_GROUP: ::c_int = 20; +pub const IPV6_LEAVE_GROUP: ::c_int = 21; +pub const IPV6_V6ONLY: ::c_int = 26; + +pub const IPV6_ADD_MEMBERSHIP: ::c_int = IPV6_JOIN_GROUP; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = IPV6_LEAVE_GROUP; + +pub const TCP_NODELAY: ::c_int = 1; + +pub const EAI_SYSTEM: ::c_int = -11; + +extern "C" { + pub fn socket(domain: ::c_int, type_: ::c_int, protocol: ::c_int) -> ::c_int; + pub fn connect(fd: ::c_int, name: *const sockaddr, addrlen: socklen_t) -> ::c_int; + pub fn bind(socket: ::c_int, addr: *const sockaddr, addrlen: socklen_t) -> ::c_int; + pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; + pub fn accept(socket: ::c_int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> ::c_int; + + pub fn getsockname(socket: ::c_int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> ::c_int; + pub fn getpeername(socket: ::c_int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> ::c_int; + + pub fn sendto( + socket: ::c_int, + buffer: *const ::c_void, + length: ::size_t, + flags: ::c_int, + addr: *const sockaddr, + addrlen: socklen_t, + ) -> ::ssize_t; + pub fn recvfrom( + socket: ::c_int, + buffer: *mut ::c_void, + length: ::size_t, + flags: ::c_int, + addr: *mut sockaddr, + addrlen: *mut socklen_t, + ) -> ::ssize_t; + + pub fn getsockopt( + sockfd: ::c_int, + level: ::c_int, + optname: ::c_int, + optval: *mut ::c_void, + optlen: *mut socklen_t, + ) -> ::c_int; + pub fn setsockopt( + sockfd: ::c_int, + level: ::c_int, + optname: ::c_int, + optval: *const ::c_void, + optlen: socklen_t, + ) -> ::c_int; + + pub fn getaddrinfo( + host: *const ::c_char, + serv: *const ::c_char, + hint: *const addrinfo, + res: *mut *mut addrinfo, + ) -> ::c_int; + pub fn freeaddrinfo(p: *mut addrinfo); + pub fn gai_strerror(ecode: ::c_int) -> *const ::c_char; +}