diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml deleted file mode 100644 index 5ace4600a1f26..0000000000000 --- a/.github/dependabot.yaml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 0000000000000..6ce8de556d5b4 --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,42 @@ +{ + $schema: "https://docs.renovatebot.com/renovate-schema.json", + extends: [ + "config:recommended", + ":maintainLockFilesMonthly", + "helpers:pinGitHubActionDigestsToSemver" + ], + packageRules: [ + { + matchCategories: [ + "rust" + ], + matchJsonata: [ + "isBreaking != true" + ], + // Disable non-breaking change updates because they + // are updated periodically with lockfile maintainance. + enabled: false, + }, + { + matchManagers: [ + "github-actions" + ], + // Every month + schedule: "* 0 1 * *", + groupName: "Github Actions", + }, + { + // Don't updates such as 23.10 -> mantic-20240530 + "matchDatasources": ["docker"], + "pinDigests": false + } + ], + // Receive any update that fixes security vulnerabilities. + // We need this because we disabled "patch" updates for Rust. + // Note: You need to enable "Dependabot alerts" in "Code security" GitHub + // Settings to receive security updates. + // See https://docs.renovatebot.com/configuration-options/#vulnerabilityalerts + vulnerabilityAlerts: { + enabled: true, + }, +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bf6aa9bc50f18..9faeffbbd0d70 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,7 +48,7 @@ jobs: with: persist-credentials: false - run: rustup update stable --no-self-update - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 # Here we use the latest stable Rust toolchain already installed by GitHub # Ideally we should run it for every target, but we cannot rely on unstable toolchains # due to Clippy not being consistent between them. @@ -82,7 +82,7 @@ jobs: run: ./ci/install-rust.sh - name: Install semver-checks - uses: taiki-e/install-action@6a1bd70eaac3c8bdf093356838d7ee09fda951cf # v2.85.5 + uses: taiki-e/install-action@5b4d68e2e660441203ab128a23676f1e4faf1532 # v2.86.3 if: matrix.toolchain == 'stable' with: tool: cargo-semver-checks @@ -94,7 +94,7 @@ jobs: # FIXME(ci): These `du` statements are temporary for debugging cache - name: Target size before restoring cache run: du -sh target | sort -k 2 || true - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: ${{ matrix.os }}-${{ matrix.toolchain }} - name: Target size after restoring cache @@ -151,7 +151,7 @@ jobs: persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: ${{ matrix.target }} @@ -191,34 +191,34 @@ jobs: - target: aarch64-linux-android - target: aarch64-unknown-linux-musl - target: aarch64-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - target: arm-linux-androideabi - target: arm-unknown-linux-gnueabihf - target: arm-unknown-linux-musleabihf - target: arm-unknown-linux-musleabihf - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl # FIXME(#4297): Disabled due to spurious failue # - target: i686-linux-android - target: i686-unknown-linux-musl - target: i686-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - target: loongarch64-unknown-linux-gnu - target: loongarch64-unknown-linux-musl - target: loongarch64-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - target: powerpc64-unknown-linux-gnu - target: powerpc64-unknown-linux-musl - target: powerpc64-unknown-linux-musl - env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2: 1 } artifact-tag: new-musl - target: powerpc64le-unknown-linux-gnu - target: powerpc64le-unknown-linux-musl - target: powerpc64le-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - target: riscv64gc-unknown-linux-gnu - target: s390x-unknown-linux-gnu @@ -235,7 +235,7 @@ jobs: # - target: x86_64-unknown-linux-gnux32 - target: x86_64-unknown-linux-musl - target: x86_64-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl # FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually. # - target: x86_64-unknown-redox @@ -243,6 +243,15 @@ jobs: # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu + + # Testing iOS and tvOS should give us reasonably good coverage for Apple platforms. + # (watchOS is similar to tvOS, and visionOS is similar to iOS). + - target: aarch64-apple-ios-sim + os: macos-26 + cargo-apple-runner: true + - target: aarch64-apple-tvos-sim + os: macos-26 + cargo-apple-runner: true runs-on: ${{ matrix.os && matrix.os || 'ubuntu-26.04' }} timeout-minutes: 25 env: @@ -253,7 +262,7 @@ jobs: persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: ${{ matrix.target }} @@ -264,12 +273,21 @@ jobs: jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV shell: bash + - name: Install `cargo-apple-runner` + if: matrix.cargo-apple-runner + uses: taiki-e/install-action@6c6fd71fe4fb72c3697d269963d0e15df8adedad # v2.85.10 + with: + tool: cargo-apple-runner + - name: Run natively - if: runner.os != 'Linux' + if: runner.os != 'Linux' && !matrix.cargo-apple-runner run: ./ci/run.sh ${{ matrix.target }} - name: Run in Docker - if: runner.os == 'Linux' + if: runner.os == 'Linux' && !matrix.cargo-apple-runner run: ./ci/run-docker.sh ${{ matrix.target }} + - name: Run on Apple's simulator + if: matrix.cargo-apple-runner + run: ./ci/run-apple-simulator.sh ${{ matrix.target }} - name: Create CI artifacts id: create_artifacts @@ -304,7 +322,7 @@ jobs: with: persist-credentials: false - name: Test on FreeBSD - uses: vmactions/freebsd-vm@77ed28d336d03fe19a3f4f7266c1d2c4714dd79d # v1.5.2 + uses: vmactions/freebsd-vm@83b151f58c6047089f4c80eb5ba2039d158ce093 # v1.5.3 if: contains(matrix.target, 'freebsd') with: release: ${{ matrix.release }} @@ -331,7 +349,7 @@ jobs: run: ./ci/bsd-run.sh ${{ matrix.target }} - name: Test on NetBSD - uses: vmactions/netbsd-vm@e7ac71b97abbe8437cec8859a5acf72dfa6a8be0 # v1.4.5 + uses: vmactions/netbsd-vm@00081e82b14bc40114eb97f32b4455306828516b # v1.4.6 if: contains(matrix.target, 'netbsd') with: release: "10.1" @@ -366,7 +384,7 @@ jobs: - name: Install Rust # FIXME(rust-lang/rust#160439): unpin once the issue is fixed run: rustup update nightly-2026-08-02 --no-self-update && rustup default nightly-2026-08-02 - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 - run: cargo doc --workspace --no-deps zizmor: @@ -382,7 +400,7 @@ jobs: persist-credentials: false - name: Run zizmor - uses: zizmorcore/zizmor-action@6fc4b006235f201fdab3722e17240ab420d580e5 # v0.6.1 + uses: zizmorcore/zizmor-action@3dc1ecc9bcb9e94e9b2c709687979e1298497054 # v0.6.2 # One job that "summarizes" the success state of this pipeline. This can then be added to branch # protection, rather than having to add each job separately. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35fcba6404ba7..a4f3b18e729fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -112,28 +112,79 @@ chance of being accepted: ### Source links -Please include permalinks to headers in commit messages for all API changes. +Please include permalinks to headers in commit messages for all API changes; +the maintainers need to compare changes against these sources, and we also want +to keep a record of exactly what the API looked like when bindings were written. Common sources include: -* Linux uapi: https://github.com/torvalds/linux/tree/master/include/uapi -* Glibc: https://github.com/sailfishos-mirror/glibc (original is https://sourceware.org/git/?p=glibc.git;a=tree) -* Musl: https://github.com/kraj/musl (original is https://git.musl-libc.org/cgit/musl/tree/) -* Apple XNU: https://github.com/apple-oss-distributions/xnu, libc https://github.com/apple-oss-distributions/Libc/tree/main/include -* Android: https://cs.android.com/android/platform/superproject/main -* FreeBSD: https://github.com/freebsd/freebsd-src/tree/main/lib/libc -* Illumos: https://github.com/illumos/illumos-gate/tree/master/usr/src/lib/libc -* Fuchsia: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/ +* Apple XNU: , + libc +* Android: +* Cygwin: (official mirror), + (original) +* DragonFlyBSD: (official mirror), + (original) +* Emscripten: +* FreeBSD: (official mirror), + (original) +* Fuchsia: +* Glibc: (unofficial mirror), + (original) +* Illumos: (official mirror), + (original) +* Linux uapi: (official mirror), + (original) +* Musl: (unofficial mirror), + (original) +* NetBSD: (official mirror), + (original) +* OpenBSD: (official mirror), + (original) +* RedoxOS: +* Windows GNU: (unofficial mirror), + (original) +* Windows MSVC: After navigating to the relevant file and selecting relevant lines, get a -permalink. On GitHub this is available by clicking the triple dots and -selecting "copy permalink", and on the Android and Fuchsia source viewers -this is available via l-r (links->commit). - -If sources are closed, link to documentation or paste relevant C declarations. +permalink: + +* On GitHub, click the triple dots and selecting "copy permalink". +* On the Android and Fuchsia source viewers, type l-r (links->commit). +* Cgit is trickier. Locate the latest commit by clicking "summary", clicking + the commit message tagged with "master" (or other name as applicable), and + copying the sha from that commit. Next, insert `?id=abcd1234...` in the URL, + (before line number indicators like `#123`) and copy the result. This should + look something like + . +* For CVSweb, navigate to the file of interest and click on the "annotate" link + for the desired revision. Example: + . + +If sources are not public, link to documentation or paste relevant C +declarations. (Including this information in the PR description is fine too, commit messages are preferred because they become part of history.) +### Manual pages + +Including links to manpages is not required but can also be very helpful to +include. Some platforms also publish manpages but not sources. + +Common web manuals: + +* AIX: +* Apple: + is the only known official site but it is severly outdated. + or are better options. +* DragonFlyBSD: +* FreeBSD: +* Illumos: +* NetBSD: +* OpenBSD: +* Solaris: +* Windows MSVC: + ## Breaking change policy See `src/lib.rs` for details. diff --git a/Cargo.lock b/Cargo.lock index 70bfea50a5c57..513e31dab0828 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,7 +149,7 @@ dependencies = [ "libc", "proc-macro2", "regex", - "syn 2.0.119", + "syn 3.0.4", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5ac3f724f41fc..afc199db5a633 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,6 +100,7 @@ targets = [ # Tier 3 targets that are distinct enough to be useful, or have historically # been documented. "aarch64-unknown-freebsd", + "aarch64-unknown-helenos", "aarch64-unknown-hermit", "aarch64-unknown-illumos", "aarch64-unknown-netbsd", @@ -117,6 +118,7 @@ targets = [ "armv7r-none-eabihf", "hexagon-unknown-linux-musl", "i686-unknown-haiku", + "i686-unknown-helenos", "i686-unknown-netbsd", "i686-unknown-openbsd", "i686-wrs-vxworks", @@ -129,6 +131,7 @@ targets = [ "mipsel-sony-psp", "mipsel-unknown-linux-gnu", "mipsel-unknown-linux-musl", + "powerpc-unknown-helenos", "powerpc-unknown-linux-gnuspe", "powerpc-unknown-netbsd", "powerpc-wrs-vxworks", @@ -150,6 +153,7 @@ targets = [ "riscv64imac-unknown-none-elf", "s390x-unknown-linux-musl", "sparc-unknown-linux-gnu", + "sparc64-unknown-helenos", "sparc64-unknown-netbsd", "thumbv6m-none-eabi", "thumbv7em-none-eabi", @@ -160,6 +164,7 @@ targets = [ "x86_64-pc-cygwin", "x86_64-unknown-dragonfly", "x86_64-unknown-haiku", + "x86_64-unknown-helenos", "x86_64-unknown-hermit", "x86_64-unknown-hurd-gnu", "x86_64-unknown-l4re-uclibc", diff --git a/build.rs b/build.rs index 4a5e154f85a27..28467e7da033f 100644 --- a/build.rs +++ b/build.rs @@ -33,8 +33,8 @@ const ALLOWED_CFGS: &[&str] = &[ "libc_elfv2", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", - "musl_v1_2_3", - // musl v1.2.3+ && 32-bit: time_t is i64, struct layouts change + "musl_v1_2", + // musl v1.2.0+ && 32-bit: time_t is i64, struct layouts change "musl32_time64", // Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64 "musl_redir_time64", @@ -48,6 +48,7 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ "target_os", &[ "switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", "qurt", "qnx", + "helenos", ], ), ( @@ -150,13 +151,20 @@ fn main() { _ => (), } - let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3"); + let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); + if let Ok(old_musl_v1_2_3) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") { + println!( + "cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \ + set `--cfg=libc_unstable_musl_v1_2`instead" + ); + musl_v1_2 |= old_musl_v1_2_3 != "0"; + } if let Ok(old_musl_v1_2_3) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") { println!( "cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \ - set `--cfg=libc_unstable_musl_v1_2_3` via RUSTFLAGS instead" + set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead" ); - musl_v1_2_3 |= old_musl_v1_2_3 != "0"; + musl_v1_2 |= old_musl_v1_2_3 != "0"; } // OpenHarmony uses a fork of the musl libc @@ -168,11 +176,11 @@ fn main() { || target_env == "ohos" || target_abi == "pauthtest" { - musl_v1_2_3 = true; + musl_v1_2 = true; } - if musl && musl_v1_2_3 { - set_cfg("musl_v1_2_3"); + if musl && musl_v1_2 { + set_cfg("musl_v1_2"); if target_ptr_width == "32" { set_cfg("musl32_time64"); set_cfg("linux_time_bits64"); diff --git a/ci/README.md b/ci/README.md index 54017ccc0d6eb..9b1388bb9b3a0 100644 --- a/ci/README.md +++ b/ci/README.md @@ -41,13 +41,13 @@ The remaining architectures look like: the generated binary to actually verify the tests pass. * The MUSL build just has to download a MUSL compiler and target libraries and then otherwise runs tests normally. -* iOS builds need an extra linker flag currently, but beyond that they're built - as standard as everything else. +* iOS and tvOS is tested using [`cargo-apple-runner`][cargo-apple-runner]. * The BSD builds, currently OpenBSD and FreeBSD, use QEMU to boot up a system and compile/run tests. More information on that below. [Actions config]: https://github.com/rust-lang/libc/tree/HEAD/.github/workflows [android-docker]: https://github.com/rust-lang/libc/blob/HEAD/ci/docker/x86_64-linux-android/Dockerfile +[cargo-apple-runner]: https://github.com/madsmtm/cargo-apple-runner ## QEMU diff --git a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile index a5e685318ad0a..87400a8c0d266 100644 --- a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile +++ b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile @@ -1,22 +1,27 @@ -FROM ubuntu:23.10 +FROM ubuntu:26.04 -# FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time -RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ - /etc/apt/sources.list && \ - apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ - file \ gcc \ libc6-dev \ - patch \ qemu-system-arm \ qemu-user \ + bzip2 \ + gzip \ + cpio \ + unzip \ + rsync \ + bc \ xz-utils -ARG TEST_UCLIBC_TIME64 +# The toolchain URL should point to a compressed buildroot SDK. +# See https://buildroot.org/downloads/manual/manual.html#build-toolchain-with-buildroot +# for how to build one, or see https://github.com/rust-lang/libc/pull/5261 +# for an example toolchain. +ARG UCLIBC_TOOLCHAIN_URL COPY install-uclibc.sh / -RUN /install-uclibc.sh "$TEST_UCLIBC_TIME64" +RUN /install-uclibc.sh "$UCLIBC_TOOLCHAIN_URL" ENV PATH=$PATH:/rust/bin:/toolchain/bin \ STAGING_DIR=/toolchain/armv7-buildroot-linux-uclibceabihf/sysroot \ diff --git a/ci/install-uclibc.sh b/ci/install-uclibc.sh index 131f78f2065d0..261b3b2db47e5 100755 --- a/ci/install-uclibc.sh +++ b/ci/install-uclibc.sh @@ -1,20 +1,18 @@ #!/bin/bash # -# Installs the appropriate uclibc toolchain into /toolchain +# Builds a buildroot uclibc toolchain into /buildroot/output/host/ +# +# usage: install-uclibc.sh BUILDROOT_TOOLCHAIN_URL set -eux -time64="$1" - -if [ "${time64:-0}" != "0" ]; then - version='bleeding-edge-2025.08-1' -else - version='bleeding-edge-2024.02-1' # last version with 32-bit time_t -fi +toolchain_url="$1" mkdir /toolchain - -curl --retry 5 -L "https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--${version}.tar.bz2" | -tar xjf - -C /toolchain --strip-components=1 - +curl --retry 5 -L "$toolchain_url" | tar xzf - -C /toolchain --strip-components=1 +if ! [ -f /toolchain/relocate-sdk.sh ]; then + echo "ERROR: toolchain does not contain relocate-sdk.sh, expecting a buildroot SDK." + exit 1 +fi /toolchain/relocate-sdk.sh + diff --git a/ci/ios/deploy_and_run_on_ios_simulator.rs b/ci/ios/deploy_and_run_on_ios_simulator.rs deleted file mode 100644 index 5c2d2fbad328d..0000000000000 --- a/ci/ios/deploy_and_run_on_ios_simulator.rs +++ /dev/null @@ -1,187 +0,0 @@ -// This is a script to deploy and execute a binary on an iOS simulator. -// The primary use of this is to be able to run unit tests on the simulator and -// retrieve the results. -// -// To do this through Cargo instead, use Dinghy -// (https://github.com/snipsco/dinghy): cargo dinghy install, then cargo dinghy -// test. - -use std::fs::{ - self, - File, -}; -use std::io::Write; -use std::path::Path; -use std::process::Command; -use std::{ - env, - process, -}; - -macro_rules! t { - ($e:expr) => { - match $e { - Ok(e) => e, - Err(e) => panic!("{} failed with: {e}", stringify!($e)), - } - }; -} - -// Step one: Wrap as an app -fn package_as_simulator_app(crate_name: &str, test_binary_path: &Path) { - println!("Packaging simulator app"); - drop(fs::remove_dir_all("ios_simulator_app")); - t!(fs::create_dir("ios_simulator_app")); - t!(fs::copy( - test_binary_path, - Path::new("ios_simulator_app").join(crate_name) - )); - - let mut f = t!(File::create("ios_simulator_app/Info.plist")); - t!(f.write_all( - format!( - r#" - - - - - CFBundleExecutable - {} - CFBundleIdentifier - com.rust.unittests - - - "#, - crate_name - ) - .as_bytes() - )); -} - -// Step two: Start the iOS simulator -fn start_simulator() { - println!("Looking for iOS simulator"); - let output = t!(Command::new("xcrun").arg("simctl").arg("list").output()); - assert!(output.status.success()); - let mut simulator_exists = false; - let mut simulator_booted = false; - let mut found_rust_sim = false; - let stdout = t!(String::from_utf8(output.stdout)); - for line in stdout.lines() { - if line.contains("rust_ios") { - if found_rust_sim { - panic!( - "Duplicate rust_ios simulators found. Please \ - double-check xcrun simctl list." - ); - } - simulator_exists = true; - simulator_booted = line.contains("(Booted)"); - found_rust_sim = true; - } - } - - if simulator_exists == false { - println!("Creating iOS simulator"); - Command::new("xcrun") - .arg("simctl") - .arg("create") - .arg("rust_ios") - .arg("com.apple.CoreSimulator.SimDeviceType.iPhone-SE") - .arg("com.apple.CoreSimulator.SimRuntime.iOS-10-2") - .check_status(); - } else if simulator_booted == true { - println!("Shutting down already-booted simulator"); - Command::new("xcrun") - .arg("simctl") - .arg("shutdown") - .arg("rust_ios") - .check_status(); - } - - println!("Starting iOS simulator"); - // We can't uninstall the app (if present) as that will hang if the - // simulator isn't completely booted; just erase the simulator instead. - Command::new("xcrun") - .arg("simctl") - .arg("erase") - .arg("rust_ios") - .check_status(); - Command::new("xcrun") - .arg("simctl") - .arg("boot") - .arg("rust_ios") - .check_status(); -} - -// Step three: Install the app -fn install_app_to_simulator() { - println!("Installing app to simulator"); - Command::new("xcrun") - .arg("simctl") - .arg("install") - .arg("booted") - .arg("ios_simulator_app/") - .check_status(); -} - -// Step four: Run the app -fn run_app_on_simulator() { - println!("Running app"); - let output = t!(Command::new("xcrun") - .arg("simctl") - .arg("launch") - .arg("--console") - .arg("booted") - .arg("com.rust.unittests") - .output()); - - println!("status: {}", output.status); - println!("stdout --\n{}\n", String::from_utf8_lossy(&output.stdout)); - println!("stderr --\n{}\n", String::from_utf8_lossy(&output.stderr)); - - let stdout = String::from_utf8_lossy(&output.stdout); - let passed = stdout - .lines() - .find(|l| (l.contains("PASSED") && l.contains("tests")) || l.contains("test result: ok")) - .unwrap_or(false); - - println!("Shutting down simulator"); - Command::new("xcrun") - .arg("simctl") - .arg("shutdown") - .arg("rust_ios") - .check_status(); - if !passed { - panic!("tests didn't pass"); - } -} - -trait CheckStatus { - fn check_status(&mut self); -} - -impl CheckStatus for Command { - fn check_status(&mut self) { - println!("\trunning: {self:?}"); - assert!(t!(self.status()).success()); - } -} - -fn main() { - let args: Vec = env::args().collect(); - if args.len() != 2 { - println!("Usage: {} ", args[0]); - process::exit(-1); - } - - let test_binary_path = Path::new(&args[1]); - let crate_name = test_binary_path.file_name().unwrap(); - - package_as_simulator_app(crate_name.to_str().unwrap(), test_binary_path); - start_simulator(); - install_app_to_simulator(); - run_app_on_simulator(); -} diff --git a/ci/run-apple-simulator.sh b/ci/run-apple-simulator.sh new file mode 100755 index 0000000000000..1fcd3e7242c7f --- /dev/null +++ b/ci/run-apple-simulator.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Runs `run.sh` on a non-macOS Apple target. +# +# This requires `cargo-apple-runner`, which you can get with `cargo install cargo-apple-runner`. + +set -eux + +target="$1" + +# Find reasonable simulator device. +case "$target" in + *ios-sim) SIMULATOR_DEVICE="iPhone 17" ;; + *tvos-sim) SIMULATOR_DEVICE="Apple TV" ;; + *watchos-sim) SIMULATOR_DEVICE="Apple Watch SE 3 (40mm)" ;; + *visionos-sim) SIMULATOR_DEVICE="Apple Vision Pro" ;; + *) echo "Unknown simulator target: $target"; exit 1 ;; +esac + +# Start the simulator. +# If this fails, the user is likely already running a simulator, +# in that case we don't want to shut it down on exit. +if xcrun simctl boot "$SIMULATOR_DEVICE"; then + echo "Successfully booted simulator" + trap 'xcrun simctl shutdown "$SIMULATOR_DEVICE"' EXIT +else + echo "Didn't boot simulator; one is probably already running (?)" +fi + +# Set the Cargo runner to `cargo-apple-runner` for the simulator targets. +export CARGO_TARGET_AARCH64_APPLE_IOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_AARCH64_APPLE_TVOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_AARCH64_APPLE_VISIONOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=cargo-apple-runner +export CARGO_TARGET_X86_64_APPLE_WATCHOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_X86_64_APPLE_TVOS_RUNNER=cargo-apple-runner +export CARGO_TARGET_I386_APPLE_IOS_RUNNER=cargo-apple-runner + +# Delegate to run.sh for the rest. +"$(dirname "$0")/run.sh" "$target" diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 67ca55fadd0a2..9597ff1f3ca5a 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -27,6 +27,7 @@ if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ]; then fi run() { + export RUSTFLAGS="${RUSTFLAGS:-}" run_target="$1" echo "Building docker container for target $run_target" @@ -40,8 +41,8 @@ run() { # and test them both in `ci/run.sh` more similar to what we do with glibc, # rather than needing two separate jobs. if [[ "$run_target" = *"musl"* ]]; then - if [ -n "${TEST_MUSL_V1_2_3:-}" ]; then - export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_musl_v1_2_3" + if [ -n "${TEST_MUSL_V1_2:-}" ]; then + RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_musl_v1_2" build_args+=("--build-arg=MUSL_VERSION=new") else build_args+=("--build-arg=MUSL_VERSION=old") @@ -50,8 +51,17 @@ run() { if [ -n "${TEST_UCLIBC_TIME64:-}" ]; then build_args+=("--build-arg=TEST_UCLIBC_TIME64=1") - export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_uclibc_time64" + RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_uclibc_time64" fi + if [[ "$run_target" = *-linux-uclibc* ]]; then + if [ "${UCLIBC_TOOLCHAIN_URL:-}" ]; then + build_args+=("--build-arg=UCLIBC_TOOLCHAIN_URL=$UCLIBC_TOOLCHAIN_URL") + else + echo "Expected a URL to a UCLIBC toolchain in \$UCLIBC_TOOLCHAIN_URL" + exit 1 + fi + fi + # use -f so we can use ci/ as build context docker build "${build_args[@]}" diff --git a/ci/run.sh b/ci/run.sh index 6668b821c0a19..9c9775f498326 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -26,10 +26,18 @@ case "$target" in # FIXME(android): unit tests fail to start on Android *android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; *s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; + # ctest's own tests don't work on Apple devices, since these don't have + # host tooling such as `rustc` or a C compiler. + *ios*|*tvos*|*watchos*|*visionos*) cmd="$cmd --workspace --exclude ctest" ;; # For all other platforms, test everything in the workspace *) cmd="$cmd --workspace" ;; esac +if [ "${LIBC_CI_ZBUILD_STD:-}" ]; then + # ctest test infrastructure has no support for -Zbuild-std + cmd="$cmd --exclude ctest --exclude ctest-test" +fi + env="$(rustc --print cfg --target "$target" | sed -n 's/target_env="\(.*\)"/\1/p')" bits="$(rustc --print cfg --target "$target" | sed -n 's/target_pointer_width="\(.*\)"/\1/p')" diff --git a/ci/verify-build.py b/ci/verify-build.py index dc8ba576901b0..83863d0a7e620 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -157,6 +157,7 @@ class TargetResult: # there is no need to do this given the target tier policy, but the cost is small # and the saved churn from accidental breakage is significant, so we keep it around. Target("aarch64-unknown-freebsd", dist=False), + Target("aarch64-unknown-helenos", dist=False), Target("aarch64-unknown-hermit", dist=False), Target("aarch64-unknown-illumos", dist=False), Target("aarch64-unknown-netbsd", dist=False), @@ -171,6 +172,7 @@ class TargetResult: Target("i386-apple-ios", dist=False), Target("i686-apple-darwin", dist=False), Target("i686-unknown-haiku", dist=False), + Target("i686-unknown-helenos", dist=False), Target("i686-unknown-hurd-gnu", dist=False), Target("i686-unknown-netbsd", dist=False), Target("i686-unknown-openbsd", dist=False), @@ -183,6 +185,7 @@ class TargetResult: Target("mips64el-unknown-linux-muslabi64", dist=False), Target("mipsel-unknown-linux-gnu", dist=False), Target("mipsel-unknown-linux-musl", dist=False), + Target("powerpc-unknown-helenos", dist=False), Target("powerpc-unknown-linux-gnuspe", dist=False), Target("powerpc-unknown-netbsd", dist=False), Target("powerpc-wrs-vxworks", dist=False), @@ -204,12 +207,14 @@ class TargetResult: Target("riscv64imac-unknown-none-elf", dist=False), Target("s390x-unknown-linux-musl", dist=False), Target("sparc-unknown-linux-gnu", dist=False), + Target("sparc64-unknown-helenos", dist=False), Target("sparc64-unknown-netbsd", dist=False), Target("thumbv7em-none-eabihf", dist=False), Target("thumbv7m-none-eabi", dist=False), Target("thumbv8m.main-none-eabi", dist=False), Target("x86_64-unknown-dragonfly", dist=False), Target("x86_64-unknown-haiku", dist=False), + Target("x86_64-unknown-helenos", dist=False), Target("x86_64-unknown-hermit", dist=False), Target("x86_64-unknown-l4re-uclibc", dist=False), Target("x86_64-unknown-openbsd", dist=False), @@ -411,7 +416,7 @@ def test_target(cfg: Cfg, target: Target) -> TargetResult: if "musl" in target_env: # Check with breaking changes from musl, including 64-bit time_t on 32-bit - run(cmd, rustflags=f"{rustflags} --cfg=libc_unstable_musl_v1_2_3") + run(cmd, rustflags=f"{rustflags} --cfg=libc_unstable_musl_v1_2") # Test again without default features, i.e. without `std` run([*cmd, "--no-default-features"], rustflags=rustflags) diff --git a/ctest/src/template.rs b/ctest/src/template.rs new file mode 100644 index 0000000000000..4ed9fe559e52f --- /dev/null +++ b/ctest/src/template.rs @@ -0,0 +1,728 @@ +//! Generation of tests from templates for both Rust and C. + +use askama::Template; +use proc_macro2::Span; +use quote::ToTokens; +use syn::spanned::Spanned; + +use crate::cdecl::Constness; +use crate::ffi_items::FfiItems; +use crate::translator::{ + TranslationErrorKind, + Translator, +}; +use crate::{ + BoxStr, + Field, + MapInput, + Result, + TestGenerator, + TranslationError, + VolatileItemKind, + cdecl, +}; + +/// Represents the Rust side of the generated testing suite. +#[derive(Template, Clone)] +#[template(path = "test.rs")] +pub(crate) struct RustTestTemplate { + pub template: TestTemplate, + pub extern_keyword: BoxStr, +} + +impl RustTestTemplate { + pub(crate) fn new( + ffi_items: &FfiItems, + generator: &TestGenerator, + ) -> Result { + Ok(Self { + template: TestTemplate::new(ffi_items, generator)?, + extern_keyword: "extern".into(), + }) + } + + /// Modify the generated template such that it supports edition 2024. + pub(crate) fn edition(&mut self, edition: u32) -> &Self { + match edition { + 2021 => { + self.extern_keyword = "extern".into(); + } + 2024 => { + // For now we only use this to convert extern to unsafe extern. + self.extern_keyword = "unsafe extern".into(); + } + _ => panic!("unsupported or invalid edition: {edition}"), + } + self + } +} + +/// Represents the C side of the generated testing suite. +#[derive(Template, Clone)] +#[template(path = "test.c")] +pub(crate) struct CTestTemplate { + pub template: TestTemplate, + pub headers: Vec<(BoxStr, Vec)>, +} + +impl CTestTemplate { + pub(crate) fn new( + ffi_items: &FfiItems, + generator: &TestGenerator, + ) -> Result { + Ok(Self { + template: TestTemplate::new(ffi_items, generator)?, + headers: generator.headers.clone(), + }) + } +} + +/// Stores all information necessary for generation of tests for all items. +#[derive(Clone, Debug, Default)] +pub(crate) struct TestTemplate { + pub foreign_static_tests: Vec, + pub field_ptr_tests: Vec, + pub field_size_offset_tests: Vec, + pub roundtrip_tests: Vec, + pub foreign_fn_tests: Vec, + pub signededness_tests: Vec, + pub size_align_tests: Vec, + pub const_cstr_tests: Vec, + pub const_tests: Vec, + pub test_idents: Vec, +} + +impl TestTemplate { + /// Populate all tests for all items depending on the configuration provided. + pub(crate) fn new( + ffi_items: &FfiItems, + generator: &TestGenerator, + ) -> Result { + let helper = TranslateHelper::new(ffi_items, generator); + + let mut template = Self::default(); + template.populate_const_and_cstr_tests(&helper)?; + template.populate_size_align_tests(&helper)?; + template.populate_signededness_tests(&helper)?; + template.populate_field_size_offset_tests(&helper)?; + template.populate_field_ptr_tests(&helper)?; + template.populate_roundtrip_tests(&helper)?; + template.populate_foreign_fn_tests(&helper)?; + template.populate_foreign_static_tests(&helper)?; + + Ok(template) + } + + /// Populates tests for constants and C-str constants, keeping track of the names of each test. + fn populate_const_and_cstr_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for constant in helper.filtered_ffi_items.constants() { + if let syn::Type::Ptr(ptr) = &constant.ty + && let syn::Type::Path(path) = &*ptr.elem + && path.path.segments.last().unwrap().ident == "c_char" + && matches!(ptr.mutability, syn::PointerMutability::Const(_)) + { + let item = TestCStr { + id: constant.ident().into(), + test_name: cstr_test_ident(constant.ident()), + rust_val: constant.ident().into(), + c_val: helper.c_ident(constant).into(), + }; + self.const_cstr_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } else { + let item = TestConst { + id: constant.ident().into(), + test_name: const_test_ident(constant.ident()), + rust_val: constant.ident().into(), + rust_ty: constant.ty.to_token_stream().to_string().into_boxed_str(), + c_val: helper.c_ident(constant).into(), + c_ty: helper.c_type(constant)?.into(), + }; + self.const_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + } + + Ok(()) + } + + /// Populates size and alignment tests for aliases, structs, and unions. + /// + /// It also keeps track of the names of each test. + fn populate_size_align_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for alias in helper.filtered_ffi_items.aliases() { + let item = TestSizeAlign { + test_name: size_align_test_ident(alias.ident()), + id: alias.ident().into(), + rust_ty: alias.ident().into(), + c_ty: helper.c_type(alias)?.into(), + }; + self.size_align_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + for struct_ in helper.filtered_ffi_items.structs() { + let item = TestSizeAlign { + test_name: size_align_test_ident(struct_.ident()), + id: struct_.ident().into(), + rust_ty: struct_.ident().into(), + c_ty: helper.c_type(struct_)?.into(), + }; + self.size_align_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + for union_ in helper.filtered_ffi_items.unions() { + let item = TestSizeAlign { + test_name: size_align_test_ident(union_.ident()), + id: union_.ident().into(), + rust_ty: union_.ident().into(), + c_ty: helper.c_type(union_)?.into(), + }; + self.size_align_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates signededness tests for aliases. + /// + /// It also keeps track of the names of each test. + fn populate_signededness_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for alias in helper.filtered_ffi_items.aliases() { + let should_skip_signededness_test = helper + .generator + .skip_signededness + .as_ref() + .is_some_and(|skip| skip(alias.ident())); + + if !helper.translator.is_signed(&alias.ty) || should_skip_signededness_test { + continue; + } + let item = TestSignededness { + test_name: signededness_test_ident(alias.ident()), + id: alias.ident().into(), + c_ty: helper.c_type(alias)?.into(), + }; + self.signededness_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates field size and offset tests for structs/unions. + /// + /// It also keeps track of the names of each test. + fn populate_field_size_offset_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + let should_skip = |map_input| helper.generator.skips.iter().any(|f| f(&map_input)); + + let struct_fields = helper + .filtered_ffi_items + .structs() + .iter() + .flat_map(|struct_| struct_.fields.iter().map(move |field| (struct_, field))) + .filter(|(struct_, field)| { + !should_skip(MapInput::StructField(struct_, field)) && field.public + }) + .map(|(struct_, field)| { + ( + struct_.ident(), + field, + helper.c_type(struct_), + helper.c_ident(MapInput::StructField(struct_, field)), + ) + }); + let union_fields = helper + .filtered_ffi_items + .unions() + .iter() + .flat_map(|union_| union_.fields.iter().map(move |field| (union_, field))) + .filter(|(union_, field)| { + !should_skip(MapInput::UnionField(union_, field)) && field.public + }) + .map(|(union_, field)| { + ( + union_.ident(), + field, + helper.c_type(union_), + helper.c_ident(MapInput::UnionField(union_, field)), + ) + }); + + for (id, field, c_ty, c_field) in struct_fields.chain(union_fields) { + let item = TestFieldSizeOffset { + test_name: field_size_offset_test_ident(id, field.ident()), + id: id.into(), + c_ty: c_ty?.into(), + field: field.clone(), + c_field: c_field.into_boxed_str(), + }; + self.field_size_offset_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates roundtrip tests for aliases/structs/unions. + /// + /// It also keeps track of the names of each test. + fn populate_roundtrip_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for alias in helper.filtered_ffi_items.aliases() { + // Arrays cannot be roundtripped, and are automatically skipped. + if let syn::Type::Array(_) = alias.ty { + continue; + } + let c_ty = helper.c_type(alias)?; + self.add_roundtrip_test(helper, alias.ident(), &[], &c_ty, true); + } + for struct_ in helper.filtered_ffi_items.structs() { + let c_ty = helper.c_type(struct_)?; + self.add_roundtrip_test(helper, struct_.ident(), &struct_.fields, &c_ty, false); + } + for union_ in helper.filtered_ffi_items.unions() { + let c_ty = helper.c_type(union_)?; + self.add_roundtrip_test(helper, union_.ident(), &union_.fields, &c_ty, false); + } + + Ok(()) + } + + fn add_roundtrip_test( + &mut self, + helper: &TranslateHelper, + ident: &str, + fields: &[Field], + c_ty: &str, + is_alias: bool, + ) { + let should_skip_roundtrip_test = helper + .generator + .skip_roundtrip + .as_ref() + .is_some_and(|skip| skip(ident)); + if !should_skip_roundtrip_test { + let item = TestRoundtrip { + test_name: roundtrip_test_ident(ident), + id: ident.into(), + fields: fields.iter().filter(|f| f.public).cloned().collect(), + c_ty: c_ty.into(), + is_alias, + }; + self.roundtrip_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + } + + /// Populates field tests for structs/unions. + /// + /// It also keeps track of the names of each test. + fn populate_field_ptr_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + let should_skip = |map_input| helper.generator.skips.iter().any(|f| f(&map_input)); + + let struct_fields = helper + .filtered_ffi_items + .structs() + .iter() + .flat_map(|s| s.fields.iter().map(move |f| (s, f))) + .filter(|(s, f)| { + !(should_skip(MapInput::StructField(s, f)) + || should_skip(MapInput::StructFieldType(s, f)) + || !f.public) + }) + .map(|(s, f)| { + ( + s.ident(), + f, + helper.c_type(s), + helper.c_ident(MapInput::StructField(s, f)), + if !helper.generator.volatile_items.is_empty() + && helper + .generator + .volatile_items + .iter() + .any(|vf| vf(VolatileItemKind::StructField(s.clone(), f.clone()))) + { + "volatile " + } else { + "" + }, + ) + }); + let union_fields = helper + .filtered_ffi_items + .unions() + .iter() + .flat_map(|u| u.fields.iter().map(move |f| (u, f))) + .filter(|(u, f)| { + !(should_skip(MapInput::UnionField(u, f)) + || should_skip(MapInput::UnionFieldType(u, f)) + || !f.public) + }) + .map(|(u, f)| { + ( + u.ident(), + f, + helper.c_type(u), + helper.c_ident(MapInput::UnionField(u, f)), + "", + ) + }); + + for (id, field, c_ty, c_field, volatile_keyword) in struct_fields.chain(union_fields) { + let field_return_type = cdecl::cdecl( + &cdecl::ptr( + helper.translator.translate_type(&field.ty)?, + cdecl::Constness::Mut, + ), + format!("ctest_field_ty__{}__{}", id, field.ident()), + ) + .map_err(|_| { + TranslationError::new( + TranslationErrorKind::InvalidReturn, + &field.ty.to_token_stream().to_string(), + field.ty.span(), + ) + })? + .into_boxed_str(); + let item = TestFieldPtr { + test_name: field_ptr_test_ident(id, field.ident()), + id: id.into(), + c_ty: c_ty?.into(), + field: field.clone(), + c_field: c_field.into_boxed_str(), + volatile_keyword: volatile_keyword.into(), + field_return_type, + }; + self.field_ptr_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates tests for extern functions. + /// + /// It also keeps track of the names of each test. + fn populate_foreign_fn_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + let should_skip_fn_test = |ident| { + helper + .generator + .skip_fn_ptrcheck + .as_ref() + .is_some_and(|skip| skip(ident)) + }; + for func in helper.filtered_ffi_items.foreign_functions() { + if should_skip_fn_test(func.ident()) { + continue; + } + + let item = TestForeignFn { + test_name: foreign_fn_test_ident(func.ident()), + id: func.ident().into(), + c_val: helper.c_ident(func).into_boxed_str(), + }; + + self.foreign_fn_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates tests for foreign statics, keeping track of the names of each test. + fn populate_foreign_static_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for static_ in helper.filtered_ffi_items.foreign_statics() { + let rust_ty = static_.ty.to_token_stream().to_string().into_boxed_str(); + + let item = TestForeignStatic { + test_name: static_test_ident(static_.ident()), + id: static_.ident().into(), + c_val: helper.c_ident(static_).into_boxed_str(), + rust_ty, + }; + + self.foreign_static_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } +} + +/* Many test structures have the following fields: + * + * - `test_name`: The function name. + * - `id`: An identifier that can be used to create functions related to this type without conflict, + * usually also part of `test_name`. + * - `rust_val`: Identifier for a Rust value, with path qualifications if needed. + * - `rust_ty`: The Rust type of the relevant item, with path qualifications if needed. + * - `c_val`: Identifier for a C value (e.g. `#define`) + * - `c_ty`: The C type of the constant, qualified with `struct` or `union` if needed. + */ + +#[derive(Clone, Debug)] +pub(crate) struct TestSignededness { + pub test_name: BoxStr, + pub id: BoxStr, + pub c_ty: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestSizeAlign { + pub test_name: BoxStr, + pub id: BoxStr, + pub rust_ty: BoxStr, + pub c_ty: BoxStr, +} + +/// Information required to test a constant CStr. +#[derive(Clone, Debug)] +pub(crate) struct TestCStr { + pub test_name: BoxStr, + pub id: BoxStr, + pub rust_val: BoxStr, + pub c_val: BoxStr, +} + +/// Information required to test a constant. +#[derive(Clone, Debug)] +pub(crate) struct TestConst { + pub test_name: BoxStr, + pub id: BoxStr, + pub rust_val: BoxStr, + pub c_val: BoxStr, + pub rust_ty: BoxStr, + pub c_ty: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestFieldPtr { + pub test_name: BoxStr, + pub id: BoxStr, + pub field: Field, + pub c_field: BoxStr, + pub c_ty: BoxStr, + pub volatile_keyword: BoxStr, + pub field_return_type: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestFieldSizeOffset { + pub test_name: BoxStr, + pub id: BoxStr, + pub field: Field, + pub c_field: BoxStr, + pub c_ty: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestRoundtrip { + pub test_name: BoxStr, + pub id: BoxStr, + pub fields: Vec, + pub c_ty: BoxStr, + pub is_alias: bool, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestForeignFn { + pub test_name: BoxStr, + pub c_val: BoxStr, + pub id: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestForeignStatic { + pub test_name: BoxStr, + pub id: BoxStr, + pub c_val: BoxStr, + pub rust_ty: BoxStr, +} + +fn signededness_test_ident(ident: &str) -> BoxStr { + format!("ctest_signededness_{ident}").into() +} + +fn size_align_test_ident(ident: &str) -> BoxStr { + format!("ctest_size_align_{ident}").into() +} + +fn cstr_test_ident(ident: &str) -> BoxStr { + format!("ctest_const_cstr_{ident}").into() +} + +fn const_test_ident(ident: &str) -> BoxStr { + format!("ctest_const_{ident}").into() +} + +fn field_ptr_test_ident(ident: &str, field_ident: &str) -> BoxStr { + format!("ctest_field_ptr_{ident}_{field_ident}").into() +} + +fn field_size_offset_test_ident(ident: &str, field_ident: &str) -> BoxStr { + format!("ctest_field_size_offset_{ident}_{field_ident}").into() +} + +fn roundtrip_test_ident(ident: &str) -> BoxStr { + format!("ctest_roundtrip_{ident}").into() +} + +fn foreign_fn_test_ident(ident: &str) -> BoxStr { + format!("ctest_foreign_fn_{ident}").into() +} + +fn static_test_ident(ident: &str) -> BoxStr { + format!("ctest_static_{ident}").into() +} + +/// Wrap methods that depend on both ffi items and the generator. +pub(crate) struct TranslateHelper<'a> { + filtered_ffi_items: FfiItems, + generator: &'a TestGenerator, + translator: Translator<'a>, +} + +impl<'a> TranslateHelper<'a> { + /// Create a new translation helper. + pub(crate) fn new(ffi_items: &'a FfiItems, generator: &'a TestGenerator) -> Self { + let mut helper = Self { + filtered_ffi_items: ffi_items.clone(), + generator, + translator: Translator::new(ffi_items, generator), + }; + helper.filter_ffi_items(); + + helper + } + + /// Skips entire items such as structs, constants, and aliases from being tested. + /// + /// Does not skip specific tests or specific fields. If `skip_private` is true, + /// it will skip tests for all private items. + fn filter_ffi_items(&mut self) { + let verbose = self.generator.verbose_skip; + + let skipped = self.filtered_ffi_items.aliases.extract_if(.., |alias| { + self.generator + .skips + .iter() + .any(|f| f(&MapInput::CEnumType(alias.ident()))) + }); + + for item in skipped { + if verbose { + eprintln!("Skipping C enum type {}", item.ident()); + } + } + + let skipped = self + .filtered_ffi_items + .constants + .extract_if(.., |constant| { + self.generator.skips.iter().any(|f| { + f(&MapInput::CEnumType( + &constant.ty.to_token_stream().to_string(), + )) + }) + }); + + for item in skipped { + if verbose { + eprintln!("Skipping C enum constant {}", item.ident()); + } + } + + macro_rules! filter { + ($field:ident, $variant:ident, $label:literal) => {{ + let skipped = self.filtered_ffi_items.$field.extract_if(.., |item| { + (self.generator.skip_private && !item.public) + || self + .generator + .skips + .iter() + .any(|f| f(&MapInput::$variant(item))) + }); + for item in skipped { + if verbose { + eprintln!("Skipping {} \"{}\"", $label, item.ident()) + } + } + }}; + } + + filter!(aliases, Alias, "alias"); + filter!(constants, Const, "const"); + filter!(structs, Struct, "struct"); + filter!(unions, Union, "union"); + filter!(foreign_functions, Fn, "fn"); + filter!(foreign_statics, Static, "static"); + } + + /// Returns the equivalent C/Cpp identifier of the Rust item. + pub(crate) fn c_ident(&self, item: impl Into>) -> String { + self.generator.rty_to_cty(item) + } + + /// Returns the equivalent C/Cpp type of the Rust item. + pub(crate) fn c_type(&self, item: impl Into>) -> Result { + let item: MapInput = item.into(); + + let (ident, ty) = match item { + MapInput::Const(c) => (c.ident(), self.translator.translate_type(&c.ty)?), + MapInput::StructField(_, f) => (f.ident(), self.translator.translate_type(&f.ty)?), + MapInput::UnionField(_, f) => (f.ident(), self.translator.translate_type(&f.ty)?), + MapInput::Static(s) => (s.ident(), self.translator.translate_type(&s.ty)?), + // For functions, their type would be a bare fn signature, which would need to be saved + // inside of `Fn` when parsed. + MapInput::Fn(_) => unimplemented!(), + // For structs/unions/aliases, their type is the same as their identifier. + MapInput::Alias(a) => (a.ident(), cdecl::named(a.ident(), Constness::Mut)), + MapInput::Struct(s) => (s.ident(), cdecl::named(s.ident(), Constness::Mut)), + MapInput::Union(u) => (u.ident(), cdecl::named(u.ident(), Constness::Mut)), + + MapInput::StructType(_) => panic!("MapInput::StructType is not allowed!"), + MapInput::UnionType(_) => panic!("MapInput::UnionType is not allowed!"), + MapInput::CEnumType(_) => panic!("MapInput::CEnumType is not allowed!"), + MapInput::StructFieldType(_, _) => panic!("MapInput::StructFieldType is not allowed!"), + MapInput::UnionFieldType(_, _) => panic!("MapInput::UnionFieldType is not allowed!"), + MapInput::Type(_) => panic!("MapInput::Type is not allowed!"), + }; + + let ty = cdecl::cdecl(&ty, "".to_string()).map_err(|_| { + TranslationError::new( + TranslationErrorKind::InvalidReturn, + ident, + Span::call_site(), + ) + })?; + + let item = self.translator.map_rust_name_to_c(&ty); + + Ok(self.generator.rty_to_cty(item)) + } +} diff --git a/ctest/src/translator.rs b/ctest/src/translator.rs new file mode 100644 index 0000000000000..9f14fe65154d3 --- /dev/null +++ b/ctest/src/translator.rs @@ -0,0 +1,428 @@ +//! Translation of Rust types to C for test generation. +//! +//! Simple to semi complex types are supported only. + +use std::fmt; +use std::ops::{ + Deref, + DerefMut, +}; + +use proc_macro2::Span; +use quote::ToTokens; +use syn::spanned::Spanned; +use thiserror::Error; + +use crate::cdecl::Constness; +use crate::ffi_items::FfiItems; +use crate::{ + BoxStr, + MapInput, + TestGenerator, + cdecl, +}; + +/// An error that occurs during translation, detailing cause and location. +#[derive(Debug, Error)] +pub struct TranslationError { + #[source] + kind: TranslationErrorKind, + source: String, + span: BoxStr, +} + +impl TranslationError { + /// Create a new translation error. + pub(crate) fn new(kind: TranslationErrorKind, source: &str, span: Span) -> Self { + Self { + kind, + source: source.to_string(), + span: format!( + "{fname}:{line}:{col}", + fname = span.file(), + line = span.start().line, + col = span.start().column, + ) + .into(), + } + } +} + +impl From for askama::Error { + fn from(err: TranslationError) -> Self { + askama::Error::Custom(err.into()) + } +} + +impl fmt::Display for TranslationError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}: `{}` at {}", self.kind, self.source, self.span) + } +} + +/// Errors that can occur during the translation of a type. +#[derive(Debug, Error, PartialEq, Eq)] +pub(crate) enum TranslationErrorKind { + /// The provided type is unknown or unrecognized. + #[error("unsupported type")] + UnsupportedType, + + /// A reference to a non-primitive type was encountered, which is not supported. + #[error("references to non-primitive types are not allowed")] + NonPrimitiveReference, + + /// Lifetimes were found in the type or function signature, which are not supported. + #[error("lifetimes cannot be translated")] + HasLifetimes, + + /// A type that is not ffi compatible was found. + #[error( + "this type is not guaranteed to have a C compatible layout. See improper_ctypes_definitions lint" + )] + NotFfiCompatible, + + /// An array or function was attempted to be returned by a function. + #[error("invalid return type")] + InvalidReturn, +} + +#[derive(Clone)] +/// A Rust to C/Cxx translator. +pub(crate) struct Translator<'a> { + ffi_items: &'a FfiItems, + generator: &'a TestGenerator, +} + +impl<'a> Translator<'a> { + /// Create a new translator. + pub(crate) fn new(ffi_items: &'a FfiItems, generator: &'a TestGenerator) -> Self { + Self { + ffi_items, + generator, + } + } + + /// Translate a Rust type into its equivalent C type. + pub(crate) fn translate_type(&self, ty: &syn::Type) -> Result { + match ty { + syn::Type::Ptr(ptr) => self.translate_ptr(ptr), + syn::Type::Path(path) => self.translate_path(path), + syn::Type::Tuple(tuple) if tuple.elems.is_empty() => { + Ok(cdecl::named("void", Constness::Mut)) + } + syn::Type::Array(array) => self.translate_array(array), + syn::Type::Reference(reference) => self.translate_reference(reference), + syn::Type::FnPtr(function) => self.translate_bare_fn(function), + syn::Type::Never(_) => Ok(cdecl::named("void", Constness::Mut)), + syn::Type::Slice(slice) => Err(TranslationError::new( + TranslationErrorKind::NotFfiCompatible, + &slice.to_token_stream().to_string(), + slice.span(), + )), + syn::Type::Paren(paren) => self.translate_type(&paren.elem), + syn::Type::Group(group) => self.translate_type(&group.elem), + ty => Err(TranslationError::new( + TranslationErrorKind::UnsupportedType, + &ty.to_token_stream().to_string(), + ty.span(), + )), + } + } + + /// Translate a Rust reference to its C equivalent. + fn translate_reference( + &self, + reference: &syn::TypeReference, + ) -> Result { + match reference.elem.deref() { + syn::Type::Path(path) => { + let last_segment = path.path.segments.last().unwrap(); + let ident = last_segment.ident.to_string(); + + match ident.as_str() { + "str" => { + // &str is not ABI safe and should not be supported. + Err(TranslationError::new( + TranslationErrorKind::NotFfiCompatible, + "&str", + path.span(), + )) + } + c if is_rust_primitive(c) => { + let type_name = translate_primitive_type(&last_segment.ident.to_string()); + Ok(ptr_with_inner( + cdecl::named(&type_name, Constness::Mut), + translate_mut(reference.mutability), + )) + } + _ => Err(TranslationError::new( + TranslationErrorKind::NonPrimitiveReference, + &ident, + path.span(), + )), + } + } + syn::Type::Reference(_) + | syn::Type::Ptr(_) + | syn::Type::Array(_) + | syn::Type::FnPtr(_) => { + let ty = self.translate_type(reference.elem.deref())?; + Ok(ptr_with_inner(ty, translate_mut(reference.mutability))) + } + + _ => Err(TranslationError::new( + TranslationErrorKind::UnsupportedType, + &reference.elem.to_token_stream().to_string(), + reference.elem.span(), + )), + } + } + + /// Translate a Rust function pointer type to its C equivalent. + pub(crate) fn translate_bare_fn( + &self, + function: &syn::TypeFnPtr, + ) -> Result { + if function.lifetimes.is_some() { + return Err(TranslationError::new( + TranslationErrorKind::HasLifetimes, + &function.to_token_stream().to_string(), + function.span(), + )); + } + + let mut parameters = function + .inputs + .iter() + .map(|arg| self.translate_type(&arg.ty)) + .collect::, TranslationError>>()?; + + let return_type = match &function.output { + syn::ReturnType::Default => cdecl::named("void", Constness::Mut), + syn::ReturnType::Type(_, ty) => self.translate_type(ty)?, + }; + + if function.variadic.is_some() { + parameters.push(cdecl::variadic()); + } else if parameters.is_empty() { + parameters.push(cdecl::named("void", Constness::Mut)); + } + + Ok(cdecl::func_ptr(parameters, return_type)) + } + + /// Translate a Rust path into its C equivalent. + fn translate_path(&self, path: &syn::TypePath) -> Result { + let last = path.path.segments.last().unwrap(); + if let syn::PathArguments::AngleBracketed(args) = &last.arguments + && let syn::GenericArgument::Type(inner_ty) = args.args.first().unwrap() + { + // Option is ONLY ffi-safe if it contains a function pointer, or a reference. + match inner_ty { + syn::Type::Reference(_) | syn::Type::FnPtr(_) => { + return self.translate_type(inner_ty); + } + _ => { + return Err(TranslationError::new( + TranslationErrorKind::NotFfiCompatible, + &path.to_token_stream().to_string(), + inner_ty.span(), + )); + } + } + } + + let name = last.ident.to_string(); + let item = self.map_rust_name_to_c(&name); + + Ok(cdecl::named( + &self.generator.rty_to_cty(item), + Constness::Mut, + )) + } + + /// Translate a Rust array declaration into its C equivalent. + fn translate_array(&self, array: &syn::TypeArray) -> Result { + Ok(cdecl::array( + self.translate_type(array.elem.deref())?, + Some(&translate_expr(&array.len)), + )) + } + + /// Translate a Rust pointer into its equivalent C pointer. + fn translate_ptr(&self, ptr: &syn::TypePtr) -> Result { + let inner_type = self.translate_type(ptr.elem.deref())?; + Ok(ptr_with_inner( + inner_type, + translate_ptr_mut(&ptr.mutability), + )) + } + + /// Determine whether a C type is a signed type. + /// + /// For primitive types it checks against a known list of signed types, but for aliases + /// which are the only thing other than primitives that can be signed, it recursively checks + /// the underlying type of the alias. + pub(crate) fn is_signed(&self, ty: &syn::Type) -> bool { + match ty { + syn::Type::Path(path) => { + let ident = path.path.segments.last().unwrap().ident.clone(); + if let Some(aliased) = self.ffi_items.aliases().iter().find(|a| ident == a.ident()) + { + return self.is_signed(&aliased.ty); + } + match translate_primitive_type(&ident.to_string()).as_str() { + "char" | "short" | "long" | "long long" | "size_t" | "ssize_t" => true, + s => { + s.starts_with("int") + || s.starts_with("uint") | s.starts_with("signed ") + || s.starts_with("unsigned ") + } + } + } + _ => false, + } + } + + pub(crate) fn map_rust_name_to_c<'name>(&self, name: &'name str) -> MapInput<'name> { + if self.ffi_items.contains_struct(name) { + MapInput::StructType(name) + } else if self.ffi_items.contains_union(name) { + MapInput::UnionType(name) + } else if self.generator.c_enums.iter().any(|f| f(name)) { + MapInput::CEnumType(name) + } else { + MapInput::Type(name) + } + } +} + +/// Translate Rust mutability from a raw pointer to C non-constness. +fn translate_ptr_mut(mutability: &syn::PointerMutability) -> Constness { + match mutability { + syn::PointerMutability::Const(_) => Constness::Const, + syn::PointerMutability::Mut(_) => Constness::Mut, + } +} + +/// Translate Rust mutability from a reference to C non-constness. +fn translate_mut(mutability: Option) -> Constness { + mutability.map_or(Constness::Const, |_| Constness::Mut) +} + +/// Translate a Rust primitive type into its C equivalent. +pub(crate) fn translate_primitive_type(ty: &str) -> String { + match ty { + "usize" => "size_t".to_string(), + "isize" => "ssize_t".to_string(), + "u8" => "uint8_t".to_string(), + "u16" => "uint16_t".to_string(), + "u32" => "uint32_t".to_string(), + "u64" => "uint64_t".to_string(), + "u128" => "unsigned __int128".to_string(), + "i8" => "int8_t".to_string(), + "i16" => "int16_t".to_string(), + "i32" => "int32_t".to_string(), + "i64" => "int64_t".to_string(), + "i128" => "__int128".to_string(), + "f32" => "float".to_string(), + "f64" => "double".to_string(), + "()" => "void".to_string(), + + "c_longdouble" | "c_long_double" => "long double".to_string(), + ty if ty.starts_with("c_") => { + let ty = &ty[2..].replace("long", " long"); + match ty.as_str() { + "short" => "short".to_string(), + s if s.starts_with('u') => format!("unsigned {}", &s[1..]), + s if s.starts_with('s') => format!("signed {}", &s[1..]), + s => s.to_string(), + } + } + // Pass typedefs as is. + s => s.to_string(), + } +} + +/// Construct a CTy and modify the constness of the inner type. +/// +/// Basically, `syn` always gives us the `constness` of the inner type of a pointer. +/// However `cdecl::ptr` wants the `constness` of the pointer. So we just modify +/// the way it is built so that `cdecl::ptr` takes the `constness` of the inner type. +pub(crate) fn ptr_with_inner(inner: cdecl::CTy, constness: Constness) -> cdecl::CTy { + let mut ty = Box::new(inner); + match ty.deref_mut() { + cdecl::CTy::Named { name: _, qual } => qual.constness = constness, + cdecl::CTy::Ptr { ty: _, qual } => qual.constness = constness, + _ => (), + } + cdecl::CTy::Ptr { + ty, + qual: cdecl::Qual { + constness: Constness::Mut, + volatile: false, + restrict: false, + }, + } +} + +/// Translate a simple Rust expression to C. +/// +/// This function will just pass the expression as is in most cases. In more complex cases it can +/// convert `Type as u8 + 5` to `(uint8_t)CType + 5`. +pub(crate) fn translate_expr(expr: &syn::Expr) -> String { + match expr { + syn::Expr::Index(i) => { + let base = translate_expr(&i.expr); + let index = translate_expr(&i.index); + format!("{base}[{index}]") + } + syn::Expr::Lit(l) => match &l.lit { + syn::Lit::Int(i) => { + let suffix = translate_primitive_type(i.suffix()); + let val = i.base10_digits().to_string(); + if suffix.is_empty() { + val + } else { + format!("({suffix}){val}") + } + } + _ => l.to_token_stream().to_string(), + }, + syn::Expr::Path(p) => p.path.segments.last().unwrap().ident.to_string(), + syn::Expr::Cast(c) => { + let val = translate_expr(&c.expr); + let ty = translate_primitive_type(&c.ty.to_token_stream().to_string()); + format!("({ty}){val}") + } + syn::Expr::Binary(b) => { + let left = translate_expr(&b.left); + let op = b.op.to_token_stream().to_string(); + let right = translate_expr(&b.right); + format!("{left} {op} {right}") + } + expr => expr.to_token_stream().to_string(), + } +} + +/// Return whether a type is a Rust primitive type. +fn is_rust_primitive(ty: &str) -> bool { + let rustc_types = [ + "usize", "u8", "u16", "u32", "u64", "u128", "isize", "i8", "i16", "i32", "i64", "i128", + "f32", "f64", + ]; + ty.starts_with("c_") || rustc_types.contains(&ty) +} + +/// Translate ABI of a rust extern function to its C equivalent. +#[expect(unused)] +pub(crate) fn translate_abi(abi: &syn::Abi, target: &str) -> Option<&'static str> { + let abi_name = abi.name.as_ref().map(|lit| lit.value()); + + match abi_name.as_deref() { + Some("stdcall") => "__stdcall ".into(), + Some("system") if target.contains("i686-pc-windows") => "__stdcall ".into(), + Some("C") | Some("system") | None => None, + Some(a) => panic!("unknown ABI: {a}"), + } +} diff --git a/etc/libc-util.py b/etc/libc-util.py index fc5f81f832b5d..2181abf264d0b 100755 --- a/etc/libc-util.py +++ b/etc/libc-util.py @@ -429,7 +429,7 @@ def prepare() -> "CheckAllTargets": new.attributes = base.attributes | {"time_bits": "64"} new.target_dir = base.target_dir / "time64" new.extra_rustflags = base.extra_rustflags + [ - "--cfg=libc_unstable_musl_v1_2_3" + "--cfg=libc_unstable_musl_v1_2" ] new_checks.append(new) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 12be9b3fafb70..3244561d35695 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -13,7 +13,7 @@ cfg-if = "1.0.4" libc = { path = "..", version = "0.2.189", default-features = false } [dev-dependencies] -syn = { version = "2.0.108", features = ["full", "visit"] } +syn = { version = "3.0.0", features = ["full", "visit"] } proc-macro2 = { version = "1.0.103", features = ["span-locations"] } glob = "0.3.3" annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 597f75f1cfd73..f2d787fdc1f72 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -1,6 +1,7 @@ #![allow(clippy::match_like_matches_macro)] mod semver; +mod target; use std::env; use std::env::VarError; @@ -13,76 +14,71 @@ use std::sync::LazyLock; use regex::Regex; -fn do_cc() { - // NOTE: family could be one of: unix, windows, wasm, or multiple values - // (e.g. "unix,wasm") - let family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); - let target = env::var("TARGET").unwrap(); - if family.contains("unix") || target.contains("cygwin") { - let exclude = ["redox", "wasi", "wali", "qurt"]; - if !exclude.iter().any(|x| target.contains(x)) { +use crate::target::PointerWidth::P32; +use crate::target::Target; + +fn do_cc(t: &Target) { + if t.families.iter().any(|x| x == "unix") || t.cygwin() { + let exclude = t.redox() || t.wasi() || t.wali() || t.qurt(); + if !exclude { let mut cmsg = cc::Build::new(); cmsg.file("src/cmsg.c"); - if target.contains("solaris") || target.contains("illumos") { + if t.solaris() || t.illumos() { cmsg.define("_XOPEN_SOURCE", "700"); } cmsg.compile("cmsg"); } - if (target.contains("linux") && !target.contains("wasm32")) - || target.contains("android") - || target.contains("emscripten") - || target.contains("fuchsia") - || target.contains("dragonfly") - || target.contains("bsd") - || target.contains("cygwin") + if t.linux() + || t.android() + || t.emscripten() + || t.fuchsia() + || t.dragonfly() + || t.triple.contains("bsd") + || t.cygwin() { cc::Build::new().file("src/makedev.c").compile("makedev"); } } - if target.contains("android") || (target.contains("linux") && !target.contains("wasm32")) { + if (t.android() || t.linux()) && !t.wali() { cc::Build::new().file("src/errqueue.c").compile("errqueue"); } - if target.contains("linux") && !target.contains("android") && !target.contains("wasm32") { + if t.linux() && !t.wali() { cc::Build::new().file("src/nlmsg.c").compile("nlmsg"); } - if (target.contains("linux") && !target.contains("wasm32")) - || target.contains("l4re") - || target.contains("android") - || target.contains("emscripten") - || target.contains("solaris") - || target.contains("illumos") + if (t.linux() || t.l4re() || t.android() || t.emscripten() || t.solaris() || t.illumos()) + && !t.wali() { cc::Build::new().file("src/sigrt.c").compile("sigrt"); } } -fn do_ctest() { - match &env::var("TARGET").unwrap() { - t if t.contains("android") => test_android(t), - t if t.contains("apple") => test_apple(t), - t if t.contains("dragonfly") => test_dragonflybsd(t), - t if t.contains("emscripten") => test_emscripten(t), - t if t.contains("freebsd") => test_freebsd(t), - t if t.contains("haiku") => test_haiku(t), - t if t.contains("l4re") => test_linux(t), - t if t.contains("linux") => test_linux(t), - t if t.contains("netbsd") => test_netbsd(t), - t if t.contains("openbsd") => test_openbsd(t), - t if t.contains("cygwin") => test_cygwin(t), - t if t.contains("redox") => test_redox(t), - t if t.contains("solaris") => test_solarish(t), - t if t.contains("illumos") => test_solarish(t), - t if t.contains("wasi") => test_wasi(t), - t if t.contains("windows") => test_windows(t), - t if t.contains("vxworks") => test_vxworks(t), - t if t.contains("nto-qnx") => test_neutrino(t), +fn do_ctest(t: &Target) { + match t { + t if t.android() => test_android(t), + t if t.apple() => test_apple(t), + t if t.dragonfly() => test_dragonflybsd(t), + t if t.emscripten() => test_emscripten(t), + t if t.freebsd() => test_freebsd(t), + t if t.haiku() => test_haiku(t), + t if t.l4re() => test_linux(t), + t if t.linux() => test_linux(t), + t if t.netbsd() => test_netbsd(t), + t if t.openbsd() => test_openbsd(t), + t if t.cygwin() => test_cygwin(t), + t if t.redox() => test_redox(t), + t if t.solaris() => test_solarish(t), + t if t.illumos() => test_solarish(t), + t if t.wasi() => test_wasi(t), + t if t.win() => test_windows(t), + t if t.vxworks() => test_vxworks(t), + t if t.nto() => test_neutrino(t), // QuRT ctest requires a sched_yield stub (static inline in SDK). - t if t.contains("qurt") => return, - t if t.contains("aix") => return test_aix(t), - t => panic!("unknown target {t}"), + t if t.qurt() => return, + t if t.aix() => return test_aix(t), + t => panic!("unknown target {t:?}"), } } @@ -105,11 +101,13 @@ fn ctest_cfg() -> ctest::TestGenerator { fn main() { // Avoid unnecessary re-building. println!("cargo:rerun-if-changed=."); + let t = Target::from_env(); + // Ensure version checking works, even if we don't use it. LazyLock::force(&VERSIONS); - do_cc(); - do_ctest(); + do_cc(&t); + do_ctest(&t); semver::do_semver(); } @@ -135,11 +133,14 @@ macro_rules! headers { }; } -fn test_apple(target: &str) { - assert!(target.contains("apple")); - let x86_64 = target.contains("x86_64"); - let i686 = target.contains("i686"); - let macos = VERSIONS.macos; +fn test_apple(t: &Target) { + assert!(t.apple()); + let x86_64 = t.x86_64(); + let x86_32 = t.x86_32(); + let macos = t.macos(); + let tvos = t.tvos(); + let watchos = t.watchos(); + let apple = VERSIONS.apple; let mut cfg = ctest_cfg(); @@ -167,35 +168,36 @@ fn test_apple(target: &str) { "ifaddrs.h", "langinfo.h", "libgen.h", - "libproc.h", + (macos, "libproc.h"), "limits.h", "locale.h", "mach-o/dyld.h", - "mach/mach_init.h", + (macos, "mach/mach_init.h"), "mach/mach.h", - "mach/mach_time.h", - "mach/mach_types.h", - "mach/mach_vm.h", + (macos, "mach/mach_time.h"), + (macos, "mach/mach_types.h"), + (macos, "mach/mach_vm.h"), "mach/thread_act.h", "mach/thread_policy.h", "malloc/malloc.h", - "net/bpf.h", - "net/dlil.h", + (macos, "net/bpf.h"), + (macos, "net/dlil.h"), "net/if.h", - "net/if_arp.h", + (macos, "net/if_arp.h"), "net/if_dl.h", - "net/if_mib.h", - "net/if_utun.h", + (macos, "net/if_mib.h"), + (macos, "net/if_utun.h"), "net/if_var.h", - "net/ndrv.h", - "net/route.h", + (macos, "net/ndrv.h"), + (macos, "net/route.h"), "netdb.h", - "netinet/if_ether.h", + (macos, "netinet/if_ether.h"), "netinet/in.h", "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", - "netinet6/in6_var.h", + "netinet6/scope6_var.h", + (macos, "netinet6/in6_var.h"), "os/clock.h", "os/lock.h", "os/signpost.h", @@ -226,13 +228,13 @@ fn test_apple(target: &str) { "sys/file.h", "sys/ioctl.h", "sys/ipc.h", - "sys/kern_control.h", + (macos, "sys/kern_control.h"), "sys/mman.h", "sys/mount.h", - "sys/proc_info.h", - "sys/ptrace.h", + (macos, "sys/proc_info.h"), + (macos, "sys/ptrace.h"), "sys/quota.h", - "sys/random.h", + (macos, "sys/random.h"), "sys/resource.h", "sys/sem.h", "sys/shm.h", @@ -240,7 +242,7 @@ fn test_apple(target: &str) { "sys/sockio.h", "sys/stat.h", "sys/statvfs.h", - "sys/sys_domain.h", + (macos, "sys/sys_domain.h"), "sys/sysctl.h", "sys/time.h", "sys/times.h", @@ -261,7 +263,7 @@ fn test_apple(target: &str) { "utmpx.h", "wchar.h", "xlocale.h", - (x86_64, "crt_externs.h"), + "crt_externs.h", ); cfg.skip_struct(move |s| { @@ -297,11 +299,11 @@ fn test_apple(target: &str) { // https://github.com/apple-oss-distributions/xnu/commit/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea "ELAST" => true, - // FIXME(macos): bumped up on macOS 27, it's sizeof `vm_statistics64_data_t` - "HOST_VM_INFO64_COUNT" => macos.unwrap() < (27, 0), + // FIXME(macos): bumped up on macOS/iOS/... 27, it's sizeof `vm_statistics64_data_t` + "HOST_VM_INFO64_COUNT" => apple.unwrap() < (27, 0), - // FIXME(macos): bumped up on macOS 27, from 16 to 32 - "AIO_LISTIO_MAX" => macos.unwrap() < (27, 0), + // FIXME(macos): bumped up on macOS/iOS/... 27, from 16 to 32 + "AIO_LISTIO_MAX" => apple.unwrap() < (27, 0), _ => false, } @@ -309,8 +311,8 @@ fn test_apple(target: &str) { cfg.skip_alias(move |ty| { match ty.ident() { - // FIXME(macos): The size is changed in macOS 27. - "vm_statistics64_data_t" => macos.unwrap() < (27, 0), + // FIXME(macos): The size is changed in macOS/iOS/... 27. + "vm_statistics64_data_t" => apple.unwrap() < (27, 0), _ => false, } }); @@ -324,6 +326,10 @@ fn test_apple(target: &str) { "close" if x86_64 => true, // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 "res_init" => true, + // https://github.com/rust-lang/libc/issues/5409 + "getentropy" => !macos, + // https://github.com/rust-lang/libc/issues/5410 + ident if ident.starts_with("posix_spawn") => tvos || watchos, _ => false, } }); @@ -387,20 +393,20 @@ fn test_apple(target: &str) { cfg.skip_roundtrip(move |s| match s { // FIXME(macos): this type has the wrong ABI - "max_align_t" if i686 => true, + "max_align_t" if x86_32 => true, _ => false, }); ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_openbsd(target: &str) { - assert!(target.contains("openbsd")); +fn test_openbsd(t: &Target) { + assert!(t.openbsd()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); - let x86_64 = target.contains("x86_64"); + let x86_64 = t.x86_64(); headers!( cfg, @@ -603,8 +609,8 @@ fn test_openbsd(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_cygwin(target: &str) { - assert!(target.contains("cygwin")); +fn test_cygwin(t: &Target) { + assert!(t.cygwin()); let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); @@ -777,14 +783,14 @@ fn test_cygwin(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_windows(target: &str) { - assert!(target.contains("windows")); - let gnu = target.contains("gnu"); - let i686 = target.contains("i686"); +fn test_windows(t: &Target) { + assert!(t.win()); + let gnu = t.gnu(); + let x86_32 = t.x86_32(); let mut cfg = ctest_cfg(); - if target.contains("msvc") { + if t.msvc() { cfg.flag("/wd4324"); } cfg.define("_WIN32_WINNT", Some("0x8000")); @@ -801,7 +807,7 @@ fn test_windows(target: &str) { // Needed for the Windows `time_t` test. println!("cargo::rustc-check-cfg=cfg(gnu_time_bits64)"); - if i686 && gnu && win_gnu_x86_time64 { + if x86_32 && gnu && win_gnu_x86_time64 { cfg.cfg("gnu_time_bits64", None); println!("cargo::rustc-cfg=gnu_time_bits64"); } @@ -863,14 +869,14 @@ fn test_windows(target: &str) { "SSIZE_T" if !gnu => true, "ssize_t" if !gnu => true, // FIXME(windows): The size and alignment of this type are incorrect - "time_t" if gnu && i686 && !win_gnu_x86_time64 => true, + "time_t" if gnu && x86_32 && !win_gnu_x86_time64 => true, _ => false, }); cfg.skip_struct(move |struct_| { match struct_.ident() { // FIXME(windows): The size and alignment of this struct are incorrect - "timespec" if gnu && i686 => true, + "timespec" if gnu && x86_32 => true, // Extern types "FILE" | "fpos_t" | "timezone" => true, _ => false, @@ -917,8 +923,8 @@ fn test_windows(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_redox(target: &str) { - assert!(target.contains("redox")); +fn test_redox(t: &Target) { + assert!(t.redox()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); @@ -967,10 +973,10 @@ fn test_redox(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_solarish(target: &str) { - let is_solaris = target.contains("solaris"); - let is_illumos = target.contains("illumos"); - assert!(is_solaris || is_illumos); +fn test_solarish(t: &Target) { + let solaris = t.solaris(); + let illumos = t.illumos(); + assert!(solaris || illumos); // ctest generates arguments supported only by clang, so make sure to run with CC=clang. // While debugging, "CFLAGS=-ferror-limit=" is useful to get more error output. @@ -983,7 +989,7 @@ fn test_solarish(target: &str) { // FIXME(solaris): This should be removed once new Nix crate is released. // See comment in src/unix/solarish/solaris.rs for these. - if is_solaris { + if solaris { cfg.define("O_DIRECT", Some("0x2000000")); cfg.define("SIGINFO", Some("41")); } @@ -1070,11 +1076,11 @@ fn test_solarish(target: &str) { "wchar.h", ); - if is_illumos { + if illumos { headers!(cfg, "sys/epoll.h", "sys/eventfd.h", "sys/timerfd.h",); } - if is_solaris { + if solaris { headers!(cfg, "sys/lgrp_user_impl.h",); } @@ -1132,7 +1138,7 @@ fn test_solarish(target: &str) { // EPOLLEXCLUSIVE is a relatively recent addition to the epoll interface and may not be // defined on older systems. It is, however, safe to use on systems which do not // explicitly support it. (A no-op is an acceptable implementation of EPOLLEXCLUSIVE.) - "EPOLLEXCLUSIVE" if is_illumos => true, + "EPOLLEXCLUSIVE" if illumos => true, // FIXME(illumos) // illumos has changed this constant, see https://www.illumos.org/issues/16200 for details. @@ -1141,7 +1147,7 @@ fn test_solarish(target: &str) { // https://github.com/illumos/sysroot/pull/5, however this will still predate the new value. // When this does eventually make it to the sysroot we should update it in this crate and // remove this test skip. - "PTHREAD_MUTEX_DEFAULT" if is_illumos => true, + "PTHREAD_MUTEX_DEFAULT" if illumos => true, _ => false, }); @@ -1160,7 +1166,7 @@ fn test_solarish(target: &str) { // the union handling is a mess x if x.contains("door_desc_t_") => true, // a bunch of solaris-only fields - "utmpx" if is_illumos => true, + "utmpx" if illumos => true, // Extern types "DIR" | "FILE" | "fpos_t" | "timezone" | "ucred_t" => true, @@ -1198,7 +1204,7 @@ fn test_solarish(target: &str) { // The LX brand (integrated into some illumos distros) commandeered several of the // `uc_filler` fields to use for brand-specific state. - ("ucontext_t", "uc_filler" | "uc_brand_data") if is_illumos => true, + ("ucontext_t", "uc_filler" | "uc_brand_data") if illumos => true, _ => false, } @@ -1231,9 +1237,9 @@ fn test_solarish(target: &str) { "fexecve" => true, // Solaris-different - "getpwent_r" | "getgrent_r" | "updwtmpx" if is_illumos => true, - "madvise" | "mprotect" if is_illumos => true, - "door_call" | "door_return" | "door_create" if is_illumos => true, + "getpwent_r" | "getgrent_r" | "updwtmpx" if illumos => true, + "madvise" | "mprotect" if illumos => true, + "door_call" | "door_return" | "door_create" if illumos => true, // The compat functions use these "native" functions linked to their // non-prefixed implementations in libc. @@ -1251,7 +1257,7 @@ fn test_solarish(target: &str) { // redefine_extname symbol in order to preserve compatibility. // Until better symbol binding story is figured out, it must be // excluded from the tests. - "getifaddrs" if is_illumos => true, + "getifaddrs" if illumos => true, // FIXME(ctest): Our API is unsound. The Rust API allows aliasing // pointers, but the C API requires pointers not to alias. @@ -1261,7 +1267,7 @@ fn test_solarish(target: &str) { // Exists on illumos too but, for now, is // [a recent addition](https://www.illumos.org/issues/17094). - "secure_getenv" if is_illumos => true, + "secure_getenv" if illumos => true, _ => false, } @@ -1270,8 +1276,8 @@ fn test_solarish(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_netbsd(target: &str) { - assert!(target.contains("netbsd")); +fn test_netbsd(t: &Target) { + assert!(t.netbsd()); let mut cfg = ctest_cfg(); // Assume netbsd10 but check for netbsd9 for test config. @@ -1581,8 +1587,8 @@ fn test_netbsd(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_dragonflybsd(target: &str) { - assert!(target.contains("dragonfly")); +fn test_dragonflybsd(t: &Target) { + assert!(t.dragonfly()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); @@ -1945,9 +1951,9 @@ fn which_dragonfly() -> Option { parse_dragonfly_version(stdout.trim()) } -fn test_wasi(target: &str) { - assert!(target.contains("wasi")); - let p2 = target.contains("wasip2"); +fn test_wasi(t: &Target) { + assert!(t.wasi()); + let p2 = t.wasip2(); let wasi_sdk = VERSIONS.wasi_sdk.unwrap(); let mut cfg = ctest_cfg(); @@ -2057,15 +2063,10 @@ fn test_wasi(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_android(target: &str) { - assert!(target.contains("android")); - let target_pointer_width = match target { - t if t.contains("aarch64") || t.contains("x86_64") => 64, - t if t.contains("i686") || t.contains("arm") => 32, - t => panic!("unsupported target: {t}"), - }; - let x86 = target.contains("i686") || target.contains("x86_64"); - let aarch64 = target.contains("aarch64"); +fn test_android(t: &Target) { + assert!(t.android()); + let x86 = t.x86(); + let aarch64 = t.aarch64(); // The API level the NDK toolchain targets, which caps the available libc // API surface (see `Versions`). Detection is required, so unwrap and let a // toolchain we can't read fail loudly rather than silently skip every test. @@ -2169,7 +2170,7 @@ fn test_android(target: &str) { "xlocale.h", // time64_t is not defined for 64-bit targets If included it will // generate the error 'Your time_t is already 64-bit' - (target_pointer_width == 32, "time64.h"), + (t.p32(), "time64.h"), (x86, "sys/reg.h"), ); @@ -2225,6 +2226,9 @@ fn test_android(target: &str) { cfg.rename_type(move |ty| match ty { "Ioctl" => Some("int".to_string()), + // `stat64` is an alias of `struct stat`, so it needs the "struct" prefix: + // the bare name refers to the `stat64()` function in C. + "stat64" => Some("struct stat64".to_string()), _ => None, }); @@ -2280,8 +2284,6 @@ fn test_android(target: &str) { // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. "termios2" => true, - // uc_sigmask and uc_sigmask64 of ucontext_t are an anonymous union - "ucontext_t" => true, // 'private' type "prop_info" => true, @@ -2377,6 +2379,11 @@ fn test_android(target: &str) { | "NTF_EXT_LOCKED" | "ALG_SET_DRBG_ENTROPY" => true, + // FIXME(android): NDK r28 minimum required + | "STATX_SUBVOL" + | "STATX_WRITE_ATOMIC" + | "STATX_ATTR_WRITE_ATOMIC" => true, + // FIXME(android): Something has been changed on r26b: | "NFNL_SUBSYS_COUNT" | "NF_NETDEV_NUMHOOKS" @@ -2551,17 +2558,20 @@ fn test_android(target: &str) { ("ifreq", "ifr_ifru") => true, ("ifconf", "ifc_ifcu") => true, + // uc_sigmask and uc_sigmask64 are an anonymous union + ("ucontext_t", "uc_sigmask" | "uc_sigmask64" | "uc_sigmask__c_anonymous_union") => true, + _ => false, } }); ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); - test_linux_like_apis(target); + test_linux_like_apis(t); } -fn test_freebsd(target: &str) { - assert!(target.contains("freebsd")); +fn test_freebsd(t: &Target) { + assert!(t.freebsd()); let mut cfg = ctest_cfg(); // FIXME: this can be removed in 1-2 releases @@ -3265,7 +3275,7 @@ fn test_freebsd(target: &str) { _ => false, } }); - if target.contains("arm") { + if t.arm32() { cfg.skip_roundtrip(move |s| match s { // Can't return an array from a C function. "__gregset_t" => true, @@ -3279,8 +3289,8 @@ fn test_freebsd(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_emscripten(target: &str) { - assert!(target.contains("emscripten")); +fn test_emscripten(t: &Target) { + assert!(t.emscripten()); let emscripten = VERSIONS.emscripten.unwrap(); let mut cfg = ctest_cfg(); @@ -3328,6 +3338,9 @@ fn test_emscripten(target: &str) { "stdio.h", "stdlib.h", "string.h", + // `sys/epoll.h` was restored in Emscripten 6.0.2 + // https://github.com/emscripten-core/emscripten/pull/27206 + (emscripten >= (6, 0, 2), "sys/epoll.h"), "sys/file.h", "sys/ioctl.h", "sys/ipc.h", @@ -3403,11 +3416,11 @@ fn test_emscripten(target: &str) { } }); - cfg.skip_union(|union_| { + cfg.skip_union(move |union_| { match union_.ident() { - // No epoll support - // https://github.com/emscripten-core/emscripten/issues/5033 - ty if ty.starts_with("epoll") => true, + // `sys/epoll.h` was restored in Emscripten 6.0.2 + // https://github.com/emscripten-core/emscripten/pull/27206 + ty if ty.starts_with("epoll") => emscripten < (6, 0, 2), _ => false, } @@ -3434,9 +3447,9 @@ fn test_emscripten(target: &str) { // Extern types "DIR" | "FILE" | "fpos_t" | "fpos64_t" | "timezone" => true, - // No epoll support - // https://github.com/emscripten-core/emscripten/issues/5033 - ty if ty.starts_with("epoll") => true, + // `sys/epoll.h` was restored in Emscripten 6.0.2 + // https://github.com/emscripten-core/emscripten/pull/27206 + ty if ty.starts_with("epoll") => emscripten < (6, 0, 2), ty if ty.starts_with("signalfd") => true, _ => false, @@ -3450,7 +3463,15 @@ fn test_emscripten(target: &str) { "execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true, // Emscripten's `pthread_kill` used to only be linkable when building with `-pthread` - "pthread_kill" if emscripten < (6, 0) => true, + "pthread_kill" if emscripten < (6, 0, 0) => true, + + // epoll support was added in Emscripten 6.0.8 + // https://github.com/emscripten-core/emscripten/pull/27207 + "epoll_create" | "epoll_create1" | "epoll_ctl" | "epoll_wait" | "epoll_pwait" + if emscripten < (6, 0, 8) => + { + true + } _ => false, } @@ -3461,9 +3482,9 @@ fn test_emscripten(target: &str) { // FIXME(emscripten): emscripten uses different constants to constructs these n if n.contains("__SIZEOF_PTHREAD") => true, - // No epoll support - // https://github.com/emscripten-core/emscripten/issues/5033 - n if n.starts_with("EPOLL") => true, + // `sys/epoll.h` was restored in Emscripten 6.0.2 + // https://github.com/emscripten-core/emscripten/pull/27206 + n if n.starts_with("EPOLL") => emscripten < (6, 0, 2), // No ptrace.h // https://github.com/emscripten-core/emscripten/pull/17704 @@ -3535,11 +3556,11 @@ fn test_emscripten(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_neutrino(target: &str) { - assert!(target.contains("nto-qnx")); +fn test_neutrino(t: &Target) { + assert!(t.nto()); let mut cfg = ctest_cfg(); - if target.ends_with("_iosock") { + if t.nto_iosock() { let qnx_target_val = env::var("QNX_TARGET") .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); @@ -3570,7 +3591,6 @@ fn test_neutrino(target: &str) { "limits.h", "sys/link.h", "locale.h", - "sys/malloc.h", "rcheck/malloc.h", "malloc.h", "mqueue.h", @@ -3634,7 +3654,6 @@ fn test_neutrino(target: &str) { "nl_types.h", "langinfo.h", "unix.h", - "nbutil.h", "aio.h", "net/bpf.h", "net/if_dl.h", @@ -3645,6 +3664,20 @@ fn test_neutrino(target: &str) { //"sys/asyncmsg.h", ); + // add QNX version specific header files + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + match target_os.as_str() { + "nto" => { + headers!(cfg, "sys/malloc.h", "nbutil.h",); + } + "qnx" => { + headers!(cfg, "sys/neutrino.h",); + } + _ => { + panic!("unexpected QNX target_os value: {target_os}") + } + } + // Create and include a header file containing // items which are not included in any official // header file. @@ -3717,7 +3750,7 @@ fn test_neutrino(target: &str) { "_channel_connect_attr" => true, // Extern types - "DIR" | "FILE" | "fpos_t" => true, + "DIR" | "FILE" | "fpos_t" | "timezone" => true, _ => false, } @@ -3731,6 +3764,15 @@ fn test_neutrino(target: &str) { "SIG_IGN" => true, "SIG_ERR" => true, + // On QNX7.x these constants are defined in `pcap/bpf.h` but we pass `net/bpf.h` to + // `ctest`. Both header files cannot be included at the same time because of + // `ifdef` include guards. As `ctest` only produces one test program we cannot + // test `pcap/bpf.h` separately + "BPF_MOD" | "BPF_XOR" => target_os == "nto", + // The value of this constant can changed from one QNX patchset to the next one so we + // skip it. The corresponding Rust binding is also marked as `#[deprecated]` + "RLIM_NLIMITS" => true, + _ => false, } }); @@ -3789,6 +3831,7 @@ fn test_neutrino(target: &str) { | ("sigevent", "__sigev_un2") // union | ("sigaction", "sa_sigaction") // sighandler_t type is super weird | ("syspage_entry", "__reserved") // does not exist + | ("ifreq", "ifr_ifru") // ifr_ifru is an anonymous union ) }); @@ -3809,8 +3852,8 @@ fn which_vxworks() -> Option<(u32, u32)> { Some((major, minor)) } -fn test_vxworks(target: &str) { - assert!(target.contains("vxworks")); +fn test_vxworks(t: &Target) { + assert!(t.vxworks()); let mut cfg = ctest_cfg(); @@ -3948,14 +3991,8 @@ fn test_vxworks(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { - let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default(); - if target.contains("gnu") - && target.contains("linux") - && !target.ends_with("x32") - && !target.contains("riscv32") - && pointer_width == "32" - { +fn config_gnu_bits(t: &Target, cfg: &mut ctest::TestGenerator) { + if t.gnu() && t.linux() && !t.x32() && !t.riscv32() && t.pointer_width == P32 { let defaultbits = "32"; let mut tb_env = env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS"); @@ -3997,24 +4034,17 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { } // This also covers the L4Re targets since they have a similar API surface -fn test_linux(target: &str) { - assert!(target.contains("linux") || target.contains("l4re")); - - // FIXME(linux32): Some 32 bit targets use old kernel headers because newer distros enforce 64 - // bit time. Use this to avoid skipping tests also on 64 bit targets. - let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH") - .unwrap_or_default() - .parse::() - .unwrap_or_default(); +fn test_linux(t: &Target) { + assert!(t.linux() || t.l4re()); // target_os - let linux = target.contains("linux"); - let l4re = target.contains("l4re"); + let linux = t.linux(); + let l4re = t.l4re(); // target_env - let gnu = target.contains("gnu"); - let musl = target.contains("musl") || target.contains("ohos") || target.contains("pauthtest"); - let uclibc = target.contains("uclibc"); + let gnu = t.gnu(); + let musl = t.musl(); + let uclibc = t.uclibc(); match (l4re, gnu, musl, uclibc) { (false, true, false, false) => (), @@ -4027,61 +4057,58 @@ fn test_linux(target: &str) { ), } - let arm = target.contains("arm"); - let eabihf = target.contains("eabihf"); - let aarch64 = target.contains("aarch64"); - let i686 = target.contains("i686"); - let ppc = target.contains("powerpc"); - let ppc64 = target.contains("powerpc64"); - let ppc64le = target.contains("powerpc64le"); - let _ppc64be = target.contains("powerpc64-"); - let ppc32 = ppc && !ppc64; - let s390x = target.contains("s390x"); - let sparc = target.contains("sparc"); - let sparc64 = target.contains("sparc64"); - let x32 = target.contains("x32"); - let x86_32 = target.contains("i686"); - let x86_64 = target.contains("x86_64"); - let gnueabihf = target.contains("gnueabihf"); - let x86_64_gnux32 = target.contains("gnux32") && x86_64; - let riscv64 = target.contains("riscv64"); - let hexagon = target.contains("hexagon"); - let loongarch64 = target.contains("loongarch64"); - let wasm32 = target.contains("wasm32"); - let uclibc = target.contains("uclibc"); - let mips = target.contains("mips"); - let mips64 = target.contains("mips64"); - let mips32 = mips && !mips64; - let pauthtest = target.contains("pauthtest"); - let b32 = arm || target.contains("hexagon") || mips32 || ppc32 || x86_32; + let arm32 = t.arm32(); + let eabihf = t.eabihf(); + let aarch64 = t.aarch64(); + let ppc = t.ppc(); + let ppc64 = t.ppc64(); + let ppc64le = t.ppc64le(); + let ppc32 = t.ppc32(); + let s390x = t.s390x(); + let sparc = t.sparc(); + let sparc64 = t.sparc64(); + let x32 = t.x32(); + let x86_32 = t.x86_32(); + let x86_64 = t.x86_64(); + let gnueabihf = t.eabihf() && t.gnu(); + let x86_64_gnux32 = x86_64 && t.gnu() && x32; + let riscv64 = t.riscv64(); + let hexagon = t.hexagon(); + let loongarch64 = t.loongarch64(); + let wasm32 = t.wasm32(); + let uclibc = t.uclibc(); + let mips = t.mips(); + let mips32 = t.mips32(); + let pauthtest = t.pauthtest(); + let p32 = t.p32(); let versions = &*VERSIONS; let kernel = match versions.linux { Some(v) => v, None if l4re => (0, 0), - None => panic!("failed to detect kernel version for Linux target {target}"), + None => panic!("failed to detect kernel version for Linux target {t:?}",), }; - let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3"); - if musl_v1_2_3 { + let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); + if musl_v1_2 { assert!(musl); } // Some platforms only exist with recent musl. Keep in sync with libc's build.rs. if musl && (loongarch64 || hexagon || pauthtest/* || ohos */) { - musl_v1_2_3 = true; + musl_v1_2 = true; } - let old_musl = musl && !musl_v1_2_3; + let old_musl = musl && !musl_v1_2; let mut cfg = ctest_cfg(); - if musl_v1_2_3 { - cfg.cfg("musl_v1_2_3", None); - if b32 { + if musl_v1_2 { + cfg.cfg("musl_v1_2", None); + if p32 { cfg.cfg("musl32_time64", None); cfg.cfg("linux_time_bits64", None); } - if arm || ppc32 || x86_32 || mips32 { + if arm32 || ppc32 || x86_32 || mips32 { cfg.cfg("musl_redir_time64", None); } } @@ -4096,7 +4123,7 @@ fn test_linux(target: &str) { // glibc versions older than 2.29. .define("__GLIBC_USE_DEPRECATED_SCANF", None); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); // The L4Re libc headers contain some L4Re helper functions which are not needed for the libc // interface and must not be added to the libc crate if l4re { @@ -4206,7 +4233,10 @@ fn test_linux(target: &str) { // ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162 // Also unavailable on gnueabihf with glibc 2.30. // https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1 - ((x86_64 || x86_32 || arm) && !gnueabihf && !l4re, "sys/io.h"), + ( + (x86_64 || x86_32 || arm32) && !gnueabihf && !l4re, + "sys/io.h" + ), // `sys/reg.h` is only available on x86 and x86_64 ((x86_64 || x86_32) && !l4re, "sys/reg.h"), // sysctl system call is deprecated and not available on musl @@ -4342,7 +4372,7 @@ fn test_linux(target: &str) { "Ioctl" => Some("int".to_string()), // LFS64 types have been removed in musl 1.2.4+ "off64_t" if musl => Some("off_t".to_string()), - "fsword_t" if uclibc => Some("__SWORD_TYPE".to_string()), + "__sword_type" if uclibc => Some("__SWORD_TYPE".to_string()), _ => None, } }); @@ -4403,6 +4433,10 @@ fn test_linux(target: &str) { // specific type. "Ioctl" => true, + // This type was renamed to more closely match upstream's + // `__SWORD_TYPE`; It now goes by `__sword_type`. + "fsword_t" if uclibc => true, + t => { if musl { // LFS64 types have been removed in musl 1.2.4+ @@ -4487,7 +4521,7 @@ fn test_linux(target: &str) { // https://github.com/torvalds/linux/commit/341ac980eab90ac1f6c22ee9f9da83ed9604d899 // The previous version of the struct was removed in 6.11 due to a bug. // https://github.com/torvalds/linux/commit/32654bbd6313b4cfc82297e6634fa9725c3c900f - "xdp_umem_reg" if musl || pointer_width == 32 => true, + "xdp_umem_reg" if musl || p32 => true, // FIXME(1.0,linux): A new field was added to `xsk_tx_metadata_request` in linux 6.15. // https://github.com/torvalds/linux/commit/ca4419f15abd19ba8be1e109661b60f9f5b6c9f0 @@ -4526,15 +4560,15 @@ fn test_linux(target: &str) { // FIXME(musl): Struct has changed for new musl versions "tcp_info" if musl => true, - // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. - "statx" | "statx_timestamp" if musl => true, + // Added in musl 1.2.5 + "statx" | "statx_timestamp" if old_musl => true, // FIXME(musl): New fields in newer versions "utmpx" if !old_musl => true, // FIXME(linux): Requires >= 6.16 kernel headers. // On 64 bits the size did not change, skip only for 32 bits. - "ptrace_syscall_info" if pointer_width == 32 => true, + "ptrace_syscall_info" if p32 => true, // not in sys/fanotify.h in uclibc "fanotify_event_info_header" | "fanotify_event_info_fid" if uclibc => true, @@ -4620,16 +4654,10 @@ fn test_linux(target: &str) { } } if musl { - // LFS64 types have been removed in musl 1.2.4+ - if name.starts_with("RLIM64") { - return true; - } - // CI fails because musl targets use Linux v4 kernel - if name.starts_with("NI_IDN") { - return true; - } - match name { + // LFS64 types have been removed in musl 1.2.4+ + x if x.starts_with("RLIM64") && musl_v1_2 => return true, + // FIXME: Does not exist on non-x86 architectures, slated for removal // in libc in 1.0 "MAP_32BIT" if ppc64 => return true, @@ -4681,11 +4709,14 @@ fn test_linux(target: &str) { | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => return true, + // Not present in musl, deprecated in libc. + "NI_IDN" => return true, + /* Added in versions more recent than what we test */ // Since 1.2.0 - "SO_DETACH_REUSEPORT_BPF" => return true, + "SO_DETACH_REUSEPORT_BPF" if old_musl => return true, // Since 1.2.3 - "SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" => return true, + "SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" if old_musl => return true, // FIXME(musl): value was updated in new musl "RLIM_NLIMITS" => return true, @@ -4693,129 +4724,15 @@ fn test_linux(target: &str) { // FIXME(musl): Values changed in newer musl versions on these arches "O_LARGEFILE" if riscv64 || x86_64 => return true, + // musl 1.2.2 was the first version where this appeared at. + "SIGEV_THREAD_ID" if old_musl => return true, + _ => (), } } if uclibc { match name { - // The canonical uClibc toolchain, bootlin bleeding-edge-2024.02-1, - // uses linux 5.15, so several constants are not available. - - // requires linux 5.16 - "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" - | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" - | "PR_SCHED_CORE_SCOPE_THREAD" - | "NF_NETDEV_EGRESS" - | "SO_RESERVE_MEM" => return true, - - // TLS_CIPHER_SM4_[GC]CM requires linux 5.16 - "TLS_CIPHER_SM4_CCM_IV_SIZE" - | "TLS_CIPHER_SM4_CCM_KEY_SIZE" - | "TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE" - | "TLS_CIPHER_SM4_CCM_SALT_SIZE" - | "TLS_CIPHER_SM4_CCM_TAG_SIZE" - | "TLS_CIPHER_SM4_CCM" - | "TLS_CIPHER_SM4_GCM_IV_SIZE" - | "TLS_CIPHER_SM4_GCM_KEY_SIZE" - | "TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE" - | "TLS_CIPHER_SM4_GCM_SALT_SIZE" - | "TLS_CIPHER_SM4_GCM_TAG_SIZE" - | "TLS_CIPHER_SM4_GCM" => return true, - - // requires linux 5.17 - "PR_SET_VMA_ANON_NAME" - | "PR_SET_VMA" - | "RTNLGRP_MCTP_IFADDR" => return true, - - // requires linux 5.18 - "RTNLGRP_STATS" - | "RTNLGRP_TUNNEL" - | "TLS_TX_ZEROCOPY_RO" - | "MADV_DONTNEED_LOCKED" - | "NFQA_PRIORITY" - | "SO_TXREHASH" => return true, - - // requires linux 5.19 - "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" - | "NLM_F_BULK" - | "SO_RCVMARK" - | "TLS_INFO_ZC_RO_TX" => return true, - - // CAN_* consts requiring linux 6.0 - "CAN_BUS_OFF_THRESHOLD" - | "CAN_CTRLMODE_TDC_AUTO" - | "CAN_CTRLMODE_TDC_MANUAL" - | "CAN_ERR_CNT" - | "CAN_ERROR_PASSIVE_THRESHOLD" - | "CAN_ERROR_WARNING_THRESHOLD" => return true, - - // requires linux 6.0 - "IFF_NO_CARRIER" - | "TLS_INFO_RX_NO_PAD" - | "TLS_RX_EXPECT_NO_PAD" => return true, - - // CAN_* consts requiring linux 6.1 - "CAN_RAW_XL_FRAMES" - | "CANXL_HDR_SIZE" - | "CANXL_MAX_DLC_MASK" - | "CANXL_MAX_DLC" - | "CANXL_MAX_DLEN" - | "CANXL_MAX_MTU" - | "CANXL_MIN_DLC" - | "CANXL_MIN_DLEN" - | "CANXL_MIN_MTU" - | "CANXL_MTU" - | "CANXL_PRIO_BITS" - | "CANXL_PRIO_MASK" - | "CANXL_SEC" - | "CANXL_XLF" => return true, - - // TLS_CIPHER_ARIA_GCM_* requires linux 6.1 - "TLS_CIPHER_ARIA_GCM_128_IV_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_KEY_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_SALT_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_TAG_SIZE" - | "TLS_CIPHER_ARIA_GCM_128" - | "TLS_CIPHER_ARIA_GCM_256_IV_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_KEY_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_SALT_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_TAG_SIZE" - | "TLS_CIPHER_ARIA_GCM_256" => return true, - - // requires linux 6.2 - "ALG_SET_KEY_BY_KEY_SERIAL" - | "PACKET_FANOUT_FLAG_IGNORE_OUTGOING" - | "SOF_TIMESTAMPING_OPT_ID_TCP" - | "TUN_F_USO4" - | "TUN_F_USO6" => return true, - - // FAN_* consts require kernel 6.3 - "FAN_INFO" - | "FAN_RESPONSE_INFO_AUDIT_RULE" - | "FAN_RESPONSE_INFO_NONE" => return true, - - // requires linux 6.3 - "MFD_EXEC" - | "MFD_NOEXEC_SEAL" - | "PR_GET_MDWE" - | "PR_SET_MDWE" => return true, - - // requires linux 6.4 - "PACKET_VNET_HDR_SZ" => return true, - "PR_GET_MEMORY_MERGE" => return true, - "PR_SET_MEMORY_MERGE" => return true, - - // requires linux 6.5 - "SO_PASSPIDFD" - | "SO_PEERPIDFD" => return true, - - // requires linux 6.6 - "PR_MDWE_NO_INHERIT" - | "PR_MDWE_REFUSE_EXEC_GAIN" => return true, - // defined as a synonym for EM_ARC_COMPACT in gnu but not uclibc "EM_ARC_A5" => return true, @@ -4859,6 +4776,10 @@ fn test_linux(target: &str) { | "UDP_GRO" | "UDP_SEGMENT" => return true, + // FIXME: once uclibc catches up with the kernel headers, remove. + // See https://github.com/rust-lang/libc/issues/1896 + "IPPROTO_MAX" => return true, + _ => (), } } @@ -4900,11 +4821,11 @@ fn test_linux(target: &str) { "SOMAXCONN" if gnu => true, // Requires >= 6.9 kernel headers. - n if (arm || ppc32) && n.starts_with("FUTEX2_") => kernel < (6, 9), + n if (arm32 || ppc32) && n.starts_with("FUTEX2_") => kernel < (6, 9), // FIXME(linux): Not defined on ARM, gnueabihf, mips, musl, PowerPC, riscv64, s390x, and sparc64. "SYS_memfd_secret" - if arm | gnueabihf | mips | musl | ppc | riscv64 | s390x | sparc64 => + if arm32 | gnueabihf | mips | musl | ppc | riscv64 | s390x | sparc64 => { true } @@ -4981,7 +4902,7 @@ fn test_linux(target: &str) { } // FIXME(linux32): Requires >= 6.6 kernel headers. - "XDP_USE_SG" | "XDP_PKT_CONTD" if pointer_width == 32 => kernel < (6, 6), + "XDP_USE_SG" | "XDP_PKT_CONTD" if p32 => kernel < (6, 6), // FIXME(linux): Missing only on this platform for some reason "PR_MDWE_NO_INHERIT" if gnueabihf => true, @@ -4992,7 +4913,7 @@ fn test_linux(target: &str) { | "XDP_TXMD_FLAGS_TIMESTAMP" | "XDP_TXMD_FLAGS_CHECKSUM" | "XDP_TX_METADATA" - if musl || pointer_width == 32 => + if musl || p32 => { musl || kernel < (6, 8) } @@ -5046,6 +4967,12 @@ fn test_linux(target: &str) { "PTRACE_SET_SYSCALL_INFO" => kernel < (6, 16), "TLS_INFO_TX_MAX_PAYLOAD_LEN" | "TLS_INFO_MAX" => kernel < (6, 19), + // statx mask and attribute bits + "STATX_MNT_ID_UNIQUE" => kernel < (6, 8), + "STATX_SUBVOL" => kernel < (6, 10), + "STATX_WRITE_ATOMIC" | "STATX_ATTR_WRITE_ATOMIC" => kernel < (6, 11), + "STATX_DIO_READ_ALIGN" => kernel < (6, 14), + // Changed value recently "SW_MAX" | "SW_CNT" => kernel < (6, 16), @@ -5156,15 +5083,14 @@ fn test_linux(target: &str) { // assume it's a int instead. "getnameinfo" if uclibc => true, - // FIXME(musl): This needs musl 1.2.2 or later, which is newer than what we test with - // on CI. - "gettid" | "reallocarray" if musl => true, + // Added in musl 1.2.2 + "gettid" | "reallocarray" if old_musl => true, // Needs musl 1.2.3 or later. - "pthread_getname_np" if musl => true, + "pthread_getname_np" if old_musl => true, + // Added in musl 1.2.5 + "preadv2" | "pwritev2" if old_musl => true, // Added in musl 1.2.5 - "preadv2" | "pwritev2" if musl => true, - // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. - "statx" if musl => true, + "statx" if old_musl => true, // FIXME(musl): Supported since musl 1.2.6 but not yet in CI. "renameat2" if musl => true, @@ -5274,7 +5200,7 @@ fn test_linux(target: &str) { ("timex", f) if f.starts_with("__unused") => true, // // FIXME(linux): It now takes mode_t since glibc 2.31 on some targets. ("ipc_perm", "mode") - if ((x86_64 || i686 || arm || riscv64) && gnu || x86_64_gnux32) => + if ((x86_64 || x86_32 || arm32 || riscv64) && gnu || x86_64_gnux32) => { true } @@ -5294,7 +5220,7 @@ fn test_linux(target: &str) { // the `ifc_ifcu` field is an anonymous union ("ifconf", "ifc_ifcu") => true, // glibc uses a single array `uregs` instead of individual fields. - ("user_regs", _) if arm => true, + ("user_regs", _) if arm32 => true, // the `ifr_ifrn` field is an anonymous union ("iwreq", "ifr_ifrn") => true, // the `key` field is a zero-sized array @@ -5321,9 +5247,12 @@ fn test_linux(target: &str) { } // invalid application of 'sizeof' to incomplete type 'long unsigned int[]' ("mcontext_t", "__extcontext") if musl && loongarch64 => true, - // FIXME(#4121): a new field was added from `f_spare` - ("statvfs", "__f_spare") => true, - ("statvfs64", "__f_spare") => true, + // glibc 2.39 took one of the six spares for `f_type` + ("statvfs" | "statvfs64", "f_type" | "__f_spare") + if gnu && versions.glibc.unwrap() < (2, 39) => + { + true + } // the `xsk_tx_metadata_union` field is an anonymous union ("xsk_tx_metadata", "xsk_tx_metadata_union") => true, // After musl 1.2.0, the type becomes `int` instead of `long`. @@ -5365,7 +5294,7 @@ fn test_linux(target: &str) { "bcm_msg_head" => true, // FIXME(linux): the call ABI of max_align_t is incorrect on these platforms: - "max_align_t" if i686 => true, + "max_align_t" if x86_32 => true, _ => false, }); @@ -5410,25 +5339,25 @@ fn test_linux(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); if !l4re { - test_linux_like_apis(target); + test_linux_like_apis(t); } } // This function tests APIs that are incompatible to test when other APIs // are included (e.g. because including both sets of headers clashes) -fn test_linux_like_apis(target: &str) { - let gnu = target.contains("gnu"); - let musl = target.contains("musl") || target.contains("ohos") || target.contains("pauthtest"); - let linux = target.contains("linux"); - let wali = target.contains("linux") && target.contains("wasm32"); - let emscripten = target.contains("emscripten"); - let android = target.contains("android"); +fn test_linux_like_apis(t: &Target) { + let gnu = t.gnu(); + let musl = t.musl(); + let linux = t.linux(); + let wali = t.wali(); + let emscripten = t.emscripten(); + let android = t.android(); assert!(linux || android || emscripten); let mut cfg = ctest_cfg(); if linux || android || emscripten { // test strerror_r from the `string.h` header - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); cfg.header("string.h") .skip_alias(|_| true) @@ -5461,7 +5390,7 @@ fn test_linux_like_apis(target: &str) { .skip_fn(|_| true) .skip_const(move |constant| !fnctl_constants.contains(&constant.ident())); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); if musl { cfg.header("fcntl.h"); } else { @@ -5474,7 +5403,7 @@ fn test_linux_like_apis(target: &str) { let mut cfg = ctest_cfg(); if (linux && !wali) || android { // test termios - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); let termios_constants = [ "BOTHER", "IBSHIFT", "TCGETS2", "TCSETS2", "TCSETSW2", "TCSETSF2", @@ -5513,7 +5442,7 @@ fn test_linux_like_apis(target: &str) { .skip_union(|_| true) .skip_const(move |constant| !ipv6_constants.contains(&constant.ident())); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); headers!(cfg, "linux/in6.h",); ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_ipv6.rs").unwrap(); @@ -5535,7 +5464,7 @@ fn test_linux_like_apis(target: &str) { .skip_struct(move |struct_| !elf_structs.contains(&struct_.ident())) .skip_alias(move |alias| !elf_structs.contains(&alias.ident())); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_elf.rs").unwrap(); } @@ -5543,7 +5472,7 @@ fn test_linux_like_apis(target: &str) { if (linux && !wali) || android { // Test `ARPHRD_CAN`. let mut cfg = ctest_cfg(); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); cfg.header("linux/if_arp.h") .skip_fn(|_| true) .skip_static(|_| true) @@ -5557,8 +5486,8 @@ fn test_linux_like_apis(target: &str) { } } -fn test_haiku(target: &str) { - assert!(target.contains("haiku")); +fn test_haiku(t: &Target) { + assert!(t.haiku()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); @@ -5890,8 +5819,8 @@ fn test_haiku(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_aix(target: &str) { - assert!(target.contains("aix")); +fn test_aix(t: &Target) { + assert!(t.aix()); // ctest generates arguments supported only by clang, so make sure to // run with CC=clang. While debugging, "CFLAGS=-ferror-limit=" @@ -6103,6 +6032,7 @@ fn test_aix(target: &str) { match s.ident() { // The field 'u' is actually a unnamed union in the AIX header. "poll_ctl_ext" if field.ident() == "u" => true, + "pollfd_ext_t" if field.ident() == "u" => true, // The field 'data' is actually a unnamed union in the AIX header. "pollfd_ext" if field.ident() == "data" => true, @@ -6192,8 +6122,8 @@ fn test_aix(target: &str) { // QuRT ctest is disabled: sched_yield is static inline in the SDK (no // linkable symbol). A stub or --defsym is needed. The semver test works. #[allow(dead_code)] -fn test_qurt(target: &str) { - assert!(target.contains("qurt")); +fn test_qurt(t: &Target) { + assert!(t.qurt()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); @@ -6436,8 +6366,8 @@ struct Versions { freebsd: Option<(u32, u32)>, openbsd: Option<(u32, u32)>, netbsd: Option<(u32, u32)>, - macos: Option<(u32, u32)>, - emscripten: Option<(u32, u32)>, + apple: Option<(u32, u32)>, + emscripten: Option<(u32, u32, u32)>, wasi_sdk: Option<(u32, WasiVersion)>, /// Android API level (no minor version). android: Option, @@ -6478,18 +6408,21 @@ impl Versions { #if defined(__FreeBSD__) \ || defined(__NetBSD__) \ - || defined(__OpenBSD__) \ - || defined(__APPLE__) + || defined(__OpenBSD__) /* FreeBSD: __FreeBSD_version (MMmmRxx string, e.g. 1600018) * NetBSD: __NetBSD_Version__ (MMmmrrpp00 string, e.g. 1001000000) * OpenBSD: OpenBSD (release date, e.g. 202510) and OpenBSDM_m (e.g. OpenBSD7_8) - * Apple: __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_M_m (e.g. __MAC_26_5) */ #include "sys/param.h" #endif + #if defined(__APPLE__) + /* Apple: __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_M_m (e.g. __MAC_26_5) */ + #include "Availability.h" + #endif + #ifdef __EMSCRIPTEN__ - /* Provides __EMSCRIPTEN_MAJOR__, __EMSCRIPTEN_MINOR__ */ + /* Provides __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__ */ #include "emscripten/version.h" #endif @@ -6527,7 +6460,7 @@ impl Versions { // Allow spaces everywhere so we match things like `\n # define foo bar \n`. let re = Regex::new(r"^\s*#\s*define\s+(\w+)\s+(.*?)\s*$").unwrap(); let obsd_re = Regex::new(r"^OpenBSD(\d+)_(\d+)$").unwrap(); - let mac_re = Regex::new(r"^__MAC_(\d+)_(\d+)").unwrap(); + let apple_re = Regex::new(r"^__[A-Z]*_(\d+)_(\d+)").unwrap(); for line in out.lines() { let Some(caps) = re.captures(line) else { @@ -6550,11 +6483,19 @@ impl Versions { // the other version macros above and let a missing value fail loudly at // the unwrap in `test_android` rather than silently skipping tests. "__ANDROID_MIN_SDK_VERSION__" => ret.android = Some(value.parse().unwrap()), - "__MAC_OS_X_VERSION_MAX_ALLOWED" => { - let caps = mac_re.captures(value).unwrap(); + "__MAC_OS_X_VERSION_MAX_ALLOWED" + | "__IPHONE_OS_VERSION_MAX_ALLOWED" + | "__WATCH_OS_VERSION_MAX_ALLOWED" + | "__TV_OS_VERSION_MAX_ALLOWED" + | "__VISION_OS_VERSION_MAX_ALLOWED" => { + let caps = apple_re.captures(value).unwrap(); let major: u32 = caps[1].parse().unwrap(); let minor: u32 = caps[2].parse().unwrap(); - ret.macos = Some((major, minor)); + // Override any previous value. + // + // (`__IPHONE_OS_VERSION_MAX_ALLOWED` is defined first, + // and is set on watchOS, tvOS and visionOS too). + ret.apple = Some((major, minor)); } "__FreeBSD_version" => { // Format: MmmRxx where M is major (possibly multi-digit), mm is minor, R @@ -6576,11 +6517,23 @@ impl Versions { let minor: u32 = caps[2].parse().unwrap(); ret.openbsd = Some((major, minor)); } - "__EMSCRIPTEN_major__" => { - ret.emscripten.get_or_insert_default().0 = value.parse().unwrap() + // Versions before 5.0.1 define the lowercase names as integers; 5.0.1 and + // later define the uppercase names as integers and the lowercase names as + // non-integer aliases of them. + "__EMSCRIPTEN_major__" | "__EMSCRIPTEN_MAJOR__" => { + if let Ok(v) = value.parse() { + ret.emscripten.get_or_insert_default().0 = v; + } + } + "__EMSCRIPTEN_minor__" | "__EMSCRIPTEN_MINOR__" => { + if let Ok(v) = value.parse() { + ret.emscripten.get_or_insert_default().1 = v; + } } - "__EMSCRIPTEN_minor__" => { - ret.emscripten.get_or_insert_default().1 = value.parse().unwrap() + "__EMSCRIPTEN_tiny__" | "__EMSCRIPTEN_TINY__" => { + if let Ok(v) = value.parse() { + ret.emscripten.get_or_insert_default().2 = v; + } } "__wasi_sdk_major__" => { ret.wasi_sdk.get_or_insert_default().0 = value.parse().unwrap() diff --git a/libc-test/build/semver.rs b/libc-test/build/semver.rs index e5339fe4faee5..a9b1b66ad5577 100644 --- a/libc-test/build/semver.rs +++ b/libc-test/build/semver.rs @@ -33,10 +33,13 @@ pub(crate) fn do_semver() { // NOTE: Android doesn't include the unix file (or the Linux file) because // there are some many definitions missing it's actually easier just to // maintain a file for Android. - // NOTE: AIX and L4Re do not include the unix file because there are + // NOTE: AIX, L4Re and QNX do not include the unix file because there are // definitions missing on these systems. It is easier to maintain separate // files for them. - if family != os && !matches!(os.as_str(), "android" | "aix" | "l4re") && os != "vxworks" { + if family != os + && !matches!(os.as_str(), "android" | "aix" | "l4re" | "nto" | "qnx") + && os != "vxworks" + { process_semver_file(&mut output, &mut semver_root, &family); } // We don't do semver for unknown targets. diff --git a/libc-test/build/target.rs b/libc-test/build/target.rs new file mode 100644 index 0000000000000..e1fd3b1fe0e86 --- /dev/null +++ b/libc-test/build/target.rs @@ -0,0 +1,348 @@ +use std::env; +use std::path::PathBuf; + +#[derive(Debug)] +#[allow(dead_code)] +pub struct Target { + // Info about the target + pub triple: String, + pub triple_split: Vec, + pub arch: String, + pub abi: String, + pub endian: Endian, + pub env: String, + pub families: Vec, + pub os: String, + pub pointer_width: PointerWidth, + pub target_features: Vec, + pub vendor: String, + + // General build info + pub manifest_dir: PathBuf, + pub out_dir: PathBuf, + pub cargo_features: Vec, +} + +impl Target { + pub fn from_env() -> Self { + let triple = env::var("TARGET").unwrap(); + let triple_split = triple.split('-').map(ToOwned::to_owned).collect(); + let families = env::var("CARGO_CFG_TARGET_FAMILY") + .map(|feats| feats.split(',').map(ToOwned::to_owned).collect()) + .unwrap_or_default(); + let target_features = env::var("CARGO_CFG_TARGET_FEATURE") + .map(|feats| feats.split(',').map(ToOwned::to_owned).collect()) + .unwrap_or_default(); + let cargo_features = env::vars() + .filter_map(|(name, _value)| name.strip_prefix("CARGO_FEATURE_").map(ToOwned::to_owned)) + .map(|s| s.to_lowercase().replace("_", "-")) + .collect(); + let pointer_width = match env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap().as_str() { + "32" => PointerWidth::P32, + "64" => PointerWidth::P64, + x => panic!("unsupported pointer width {x}"), + }; + let endian = match env::var("CARGO_CFG_TARGET_ENDIAN").unwrap().as_str() { + "little" => Endian::Little, + "big" => Endian::Big, + x => panic!("unsupported endian {x}"), + }; + + Self { + triple, + triple_split, + arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(), + abi: env::var("CARGO_CFG_TARGET_ABI").unwrap(), + endian, + env: env::var("CARGO_CFG_TARGET_ENV").unwrap(), + families, + os: env::var("CARGO_CFG_TARGET_OS").unwrap(), + pointer_width, + target_features, + vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(), + + manifest_dir: PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()), + out_dir: PathBuf::from(env::var("OUT_DIR").unwrap()), + cargo_features, + } + } +} + +#[allow(dead_code)] +impl Target { + /* arch */ + + pub fn aarch64(&self) -> bool { + self.arch == "aarch64" + } + + pub fn arm32(&self) -> bool { + self.arch == "arm" + } + + pub fn hexagon(&self) -> bool { + self.arch == "hexagon" + } + + pub fn loongarch32(&self) -> bool { + self.arch == "loongarch32" + } + + pub fn loongarch64(&self) -> bool { + self.arch == "loongarch64" + } + + pub fn loongarch(&self) -> bool { + self.loongarch32() || self.loongarch64() + } + + pub fn mips32(&self) -> bool { + self.arch == "mips32" || self.arch == "mips32r6" + } + + pub fn mips64(&self) -> bool { + self.arch == "mips64" || self.arch == "mips64r6" + } + + pub fn mips(&self) -> bool { + self.mips32() || self.mips64() + } + + pub fn ppc32(&self) -> bool { + self.arch == "powerpc" + } + + pub fn ppc64(&self) -> bool { + self.arch == "powerpc64" + } + + pub fn ppc64be(&self) -> bool { + self.ppc64() && self.endian == Endian::Big + } + + pub fn ppc64le(&self) -> bool { + self.ppc64() && self.endian == Endian::Little + } + + pub fn ppc(&self) -> bool { + self.ppc32() || self.ppc64() + } + + pub fn riscv32(&self) -> bool { + self.arch == "riscv32" + } + + pub fn riscv64(&self) -> bool { + self.arch == "riscv64" + } + + pub fn riscv(&self) -> bool { + self.riscv32() || self.riscv64() + } + + pub fn s390x(&self) -> bool { + self.arch == "s390x" + } + + pub fn sparc32(&self) -> bool { + self.arch == "sparc" + } + + pub fn sparc64(&self) -> bool { + self.arch == "sparc64" + } + + pub fn sparc(&self) -> bool { + self.sparc32() || self.sparc64() + } + + pub fn wasm32(&self) -> bool { + self.arch == "wasm32" + } + + pub fn x86_32(&self) -> bool { + self.arch == "x86" + } + + pub fn x86_64(&self) -> bool { + self.arch == "x86_64" + } + + pub fn x86(&self) -> bool { + self.x86_32() || self.x86_64() + } + + /* abi */ + + pub fn eabihf(&self) -> bool { + self.abi == "eabihf" + } + + pub fn pauthtest(&self) -> bool { + self.abi == "pauthtest" + } + + pub fn x32(&self) -> bool { + self.abi == "x32" + } + + /* env */ + + pub fn gnu(&self) -> bool { + self.env == "gnu" + } + + pub fn msvc(&self) -> bool { + self.env == "msvc" + } + + pub fn musl(&self) -> bool { + self.env == "musl" || self.env == "ohos" + } + + pub fn nto_iosock(&self) -> bool { + self.env.contains("nto") && self.env.contains("iosock") + } + + pub fn uclibc(&self) -> bool { + self.env == "uclibc" + } + + /* os */ + + pub fn aix(&self) -> bool { + self.os == "aix" + } + + pub fn android(&self) -> bool { + self.os == "android" + } + + pub fn cygwin(&self) -> bool { + self.os == "cygwin" + } + + pub fn dragonfly(&self) -> bool { + self.os == "dragonfly" + } + + pub fn emscripten(&self) -> bool { + self.os == "emscripten" + } + + pub fn freebsd(&self) -> bool { + self.os == "freebsd" + } + + pub fn fuchsia(&self) -> bool { + self.os == "fuchsia" + } + + pub fn haiku(&self) -> bool { + self.os == "haiku" + } + + pub fn illumos(&self) -> bool { + self.os == "illumos" + } + + pub fn l4re(&self) -> bool { + self.os == "l4re" + } + + pub fn linux(&self) -> bool { + self.os == "linux" + } + + pub fn netbsd(&self) -> bool { + self.os == "netbsd" + } + + pub fn nto(&self) -> bool { + self.os == "nto" + } + + pub fn openbsd(&self) -> bool { + self.os == "openbsd" + } + + pub fn qurt(&self) -> bool { + self.os == "qurt" + } + + pub fn redox(&self) -> bool { + self.os == "redox" + } + + pub fn solaris(&self) -> bool { + self.os == "solaris" + } + + pub fn vxworks(&self) -> bool { + self.os == "vxworks" + } + + pub fn wali(&self) -> bool { + self.os == "linux" && self.wasm32() + } + + pub fn wasi(&self) -> bool { + self.os == "wasi" + } + + pub fn wasip2(&self) -> bool { + self.wasi() && self.env == "p2" + } + + pub fn win(&self) -> bool { + self.os == "windows" + } + + pub fn macos(&self) -> bool { + self.os == "macos" + } + + pub fn ios(&self) -> bool { + self.os == "ios" + } + + pub fn tvos(&self) -> bool { + self.os == "tvos" + } + + pub fn watchos(&self) -> bool { + self.os == "watchos" + } + + pub fn visionos(&self) -> bool { + self.os == "visionos" + } + + /* vendor */ + + pub fn apple(&self) -> bool { + self.vendor == "apple" + } + + /* other */ + + pub fn p32(&self) -> bool { + self.pointer_width == PointerWidth::P32 + } + + pub fn p64(&self) -> bool { + self.pointer_width == PointerWidth::P64 + } +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum PointerWidth { + P32, + P64, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Endian { + Little, + Big, +} diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index ac82c5576f34c..aa337c44d3a13 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -1789,10 +1789,10 @@ _W_SFWTED _W_SLWTED _W_STOPPED _W_STRC +__c_anonymous_ld_info__file +__c_anonymous_pollfd_ext_t_u __context64 __extctx_t -__ld_info_file -__pollfd_ext_u __tm_context_t __vmx_context_t __vmxreg_t @@ -2182,7 +2182,7 @@ poll poll_ctl poll_ctl_ext pollfd -pollfd_ext +pollfd_ext_t pollset_create pollset_ctl pollset_destroy diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 2a7110250a0cc..3ab27db12416f 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -46,7 +46,6 @@ AF_ROUTE AF_SIP AF_SNA AF_SYSTEM -AF_SYS_CONTROL AIO_ALLDONE AIO_CANCELED AIO_LISTIO_MAX @@ -65,12 +64,6 @@ AI_V4MAPPED_CFG ALTWERASE ALT_DIGITS AM_STR -ARPOP_REPLY -ARPOP_REQUEST -ATF_COM -ATF_PERM -ATF_PUBL -ATF_USETRAILERS ATTR_BIT_MAP_COUNT ATTR_CMNEXT_CLONEID ATTR_CMNEXT_EXT_FLAGS @@ -162,31 +155,7 @@ B14400 B28800 B7200 B76800 -BIOCFLUSH -BIOCGBLEN -BIOCGDLT -BIOCGDLTLIST -BIOCGETIF -BIOCGHDRCMPLT -BIOCGRSIG -BIOCGRTIMEOUT -BIOCGSEESENT -BIOCGSTATS -BIOCIMMEDIATE -BIOCPROMISC -BIOCSBLEN -BIOCSDLT -BIOCSETF -BIOCSETFNR -BIOCSETIF -BIOCSHDRCMPLT -BIOCSRSIG -BIOCSRTIMEOUT -BIOCSSEESENT -BIOCVERSION BOOT_TIME -BPF_ALIGNMENT -BPF_WORDALIGN BS0 BS1 BSDLY @@ -280,7 +249,6 @@ CTLFLAG_RD CTLFLAG_RW CTLFLAG_SECURE CTLFLAG_WR -CTLIOCGINFO CTLTYPE CTLTYPE_INT CTLTYPE_NODE @@ -310,20 +278,6 @@ DAY_6 DAY_7 DEAD_PROCESS DIR_MNTSTATUS_MNTPOINT -DLT_ARCNET -DLT_ATM_RFC1483 -DLT_AX25 -DLT_CHAOS -DLT_EN10MB -DLT_EN3MB -DLT_FDDI -DLT_IEEE802 -DLT_LOOP -DLT_NULL -DLT_PPP -DLT_PRONET -DLT_RAW -DLT_SLIP DT_UNKNOWN D_FMT D_MD_ORDER @@ -528,19 +482,6 @@ IFF_RUNNING IFF_SIMPLEX IFF_UP IMAXBEL -IN6_IFF_ANYCAST -IN6_IFF_AUTOCONF -IN6_IFF_CLAT46 -IN6_IFF_DEPRECATED -IN6_IFF_DETACHED -IN6_IFF_DUPLICATED -IN6_IFF_DYNAMIC -IN6_IFF_NODAD -IN6_IFF_NOPFX -IN6_IFF_OPTIMISTIC -IN6_IFF_SECURED -IN6_IFF_TEMPORARY -IN6_IFF_TENTATIVE INIT_PROCESS IOV_MAX IPC_CREAT @@ -995,6 +936,7 @@ MS_DEACTIVATE MS_KILLPAGES NANOSECOND NET_RT_DUMP +NET_RT_DUMP2 NET_RT_FLAGS NET_RT_IFLIST NET_RT_IFLIST2 @@ -1147,12 +1089,6 @@ PRIO_DARWIN_BG PRIO_DARWIN_NONUI PRIO_DARWIN_PROCESS PRIO_DARWIN_THREAD -PROC_CSM_ALL -PROC_CSM_NOSMT -PROC_CSM_TECS -PROC_PIDTASKALLINFO -PROC_PIDTASKINFO -PROC_PIDTHREADINFO PTHREAD_CANCELED PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_DEFERRED @@ -1177,24 +1113,6 @@ PTHREAD_PROCESS_SHARED PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_SYSTEM PTHREAD_STACK_MIN -PT_ATTACH -PT_ATTACHEXC -PT_CONTINUE -PT_DENY_ATTACH -PT_DETACH -PT_FIRSTMACH -PT_FORCEQUOTA -PT_KILL -PT_READ_D -PT_READ_I -PT_READ_U -PT_SIGEXC -PT_STEP -PT_THUPDATE -PT_TRACE_ME -PT_WRITE_D -PT_WRITE_I -PT_WRITE_U P_ALL P_PGID P_PID @@ -1252,86 +1170,11 @@ RLIMIT_RSS RLIMIT_STACK RLIM_INFINITY RLIM_NLIMITS -RTAX_AUTHOR -RTAX_BRD -RTAX_DST -RTAX_GATEWAY -RTAX_GENMASK -RTAX_IFA -RTAX_IFP -RTAX_MAX -RTAX_NETMASK -RTA_AUTHOR -RTA_BRD -RTA_DST -RTA_GATEWAY -RTA_GENMASK -RTA_IFA -RTA_IFP -RTA_NETMASK -RTF_BLACKHOLE -RTF_BROADCAST -RTF_CLONING -RTF_CONDEMNED -RTF_DEAD -RTF_DELCLONE -RTF_DONE -RTF_DYNAMIC -RTF_GATEWAY -RTF_GLOBAL -RTF_HOST -RTF_IFREF -RTF_IFSCOPE -RTF_LLINFO -RTF_LOCAL -RTF_MODIFIED -RTF_MULTICAST -RTF_NOIFREF -RTF_PINNED -RTF_PRCLONING -RTF_PROTO1 -RTF_PROTO2 -RTF_PROTO3 -RTF_PROXY -RTF_REJECT -RTF_ROUTER -RTF_STATIC -RTF_UP -RTF_WASCLONED -RTF_XRESOLVE RTLD_FIRST RTLD_NEXT RTLD_NODELETE RTLD_NOLOAD RTLD_SELF -RTM_ADD -RTM_CHANGE -RTM_DELADDR -RTM_DELETE -RTM_DELMADDR -RTM_GET -RTM_GET2 -RTM_IFINFO -RTM_IFINFO2 -RTM_LOCK -RTM_LOSING -RTM_MISS -RTM_NEWADDR -RTM_NEWMADDR -RTM_NEWMADDR2 -RTM_OLDADD -RTM_OLDDEL -RTM_REDIRECT -RTM_RESOLVE -RTM_VERSION -RTV_EXPIRE -RTV_HOPCOUNT -RTV_MTU -RTV_RPIPE -RTV_RTT -RTV_RTTVAR -RTV_SPIPE -RTV_SSTHRESH RUN_LVL RUSAGE_CHILDREN RUSAGE_SELF @@ -1384,7 +1227,6 @@ SIOCGETVLAN SIOCGHIWAT SIOCGIF6LOWPAN SIOCGIFADDR -SIOCGIFAFLAG_IN6 SIOCGIFALTMTU SIOCGIFASYNCMAP SIOCGIFBOND @@ -1491,8 +1333,6 @@ ST_RDONLY SUPERPAGE_NONE SUPERPAGE_SIZE_2MB SUPERPAGE_SIZE_ANY -SYSPROTO_CONTROL -SYSPROTO_EVENT S_IEXEC S_IREAD S_IWRITE @@ -1696,8 +1536,6 @@ USER_STREAM_MAX USER_TZNAME_MAX UTIME_NOW UTIME_OMIT -UTUN_OPT_FLAGS -UTUN_OPT_IFNAME VDISCARD VDSUSP VLNEXT @@ -1720,6 +1558,10 @@ VM_FLAGS_SUPERPAGE_SIZE_ANY VM_FLAGS_USER_ALLOCATE VM_FLAGS_USER_MAP VM_FLAGS_USER_REMAP +VM_INHERIT_COPY +VM_INHERIT_DONATE_COPY +VM_INHERIT_NONE +VM_INHERIT_SHARE VM_LOADAVG VM_MACHFACTOR VM_MAKE_TAG @@ -2029,13 +1871,8 @@ __PTHREAD_MUTEX_SIZE__ __PTHREAD_ONCE_SIZE__ __PTHREAD_RWLOCKATTR_SIZE__ __PTHREAD_RWLOCK_SIZE__ -__c_anonymous_bfl_u __darwin_mcontext64 __error -_dyld_get_image_header -_dyld_get_image_name -_dyld_get_image_vmaddr_slide -_dyld_image_count abs acct aio_cancel @@ -2049,7 +1886,6 @@ aiocb arc4random arc4random_buf arc4random_uniform -arphdr asctime asctime_r attrgroup_t @@ -2063,11 +1899,6 @@ backtrace_symbols backtrace_symbols_fd basename boolean_t -bpf_dltlist -bpf_hdr -bpf_insn -bpf_program -brk bsearch chflags chroot @@ -2088,7 +1919,6 @@ cpu_subtype_t cpu_type_t ctime ctime_r -ctl_info devname difftime dirfd @@ -2100,8 +1930,6 @@ endgrent endpwent endservent endutxent -exchangedata -execvP faccessat fchdir fchflags @@ -2171,7 +1999,6 @@ group_source_req host_cpu_load_info host_cpu_load_info_data_t host_cpu_load_info_t -icmp6_ifstat iconv iconv_close iconv_open @@ -2187,9 +2014,6 @@ ifconf ifkpi ifreq image_offset -in6_addrlifetime -in6_ifreq -in6_ifstat in6_pktinfo in_pktinfo initgroups @@ -2205,6 +2029,8 @@ key_t killpg kqueue labs +lchflags +lchmod lio_listio listxattr load_command @@ -2213,18 +2039,9 @@ lockf log2phys login_tty lutimes -mach_absolute_time mach_error_string mach_error_t -mach_header -mach_header_64 -mach_host_self -mach_port_t -mach_thread_self -mach_timebase_info -mach_timebase_info_data_t mach_vm_address_t -mach_vm_map mach_vm_offset_t mach_vm_size_t madvise @@ -2328,27 +2145,6 @@ posix_spawnattr_setsigmask posix_spawnattr_t posix_spawnp preadv -proc_bsdinfo -proc_bsdshortinfo -proc_kmsgbuf -proc_libversion -proc_listallpids -proc_listchildpids -proc_listpgrppids -proc_listpids -proc_name -proc_pidfdinfo -proc_pidfileportinfo -proc_pidinfo -proc_pidpath -proc_regionfilename -proc_set_csm -proc_set_no_smt -proc_setthread_csm -proc_setthread_no_smt -proc_taskallinfo -proc_taskinfo -proc_threadinfo pseudo_AF_HDRCMPLT pseudo_AF_KEY pseudo_AF_PIP @@ -2384,11 +2180,6 @@ pthread_introspection_getspecific_np pthread_introspection_hook_install pthread_introspection_hook_t pthread_introspection_setspecific_np -pthread_jit_write_callback_t -pthread_jit_write_freeze_callbacks_np -pthread_jit_write_protect_np -pthread_jit_write_protect_supported_np -pthread_jit_write_with_callback_np pthread_kill pthread_main_np pthread_mutexattr_getpshared @@ -2401,7 +2192,6 @@ pthread_set_qos_class_self_np pthread_setname_np pthread_setschedparam pthread_stack_frame_decode_np -ptrace pututxline pwritev qsort @@ -2426,7 +2216,6 @@ renamex_np sa_endpoints_t sae_associd_t sae_connid_t -sbrk sched_get_priority_max sched_get_priority_min sched_param @@ -2467,14 +2256,11 @@ shmctl shmdt shmget shmid_ds -sigaltstack sigevent siginfo_t sigsuspend sigwait -sockaddr_ctl sockaddr_dl -sockaddr_inarp srand stack_t statfs @@ -2488,7 +2274,6 @@ strptime strsignal strtonum sync -syscall sysctl sysctlbyname sysctlnametomib diff --git a/libc-test/semver/cygwin.txt b/libc-test/semver/cygwin.txt index a978f7312d9c3..691271e61ac7b 100644 --- a/libc-test/semver/cygwin.txt +++ b/libc-test/semver/cygwin.txt @@ -653,6 +653,12 @@ eaccess endpwent erand48 euidaccess +execl +execle +execlp +execv +execve +execvp execvpe explicit_bzero faccessat @@ -666,6 +672,7 @@ ffsll fls flsl flsll +fork forkpty freelocale fstatfs @@ -859,6 +866,7 @@ strncasecmp_l strptime strsep sync +system telldir timer_create timer_delete diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 8cabbf2b63499..cef23201ff9c3 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -382,6 +382,10 @@ IFF_SMART IFF_STATICARP IFF_UP IMAXBEL +INHERIT_COPY +INHERIT_NONE +INHERIT_SHARE +INHERIT_ZERO INIT_PROCESS IOV_MAX IPC_CREAT @@ -1371,8 +1375,14 @@ eui64_aton eui64_hostton eui64_ntoa eui64_ntohost +execl +execle +execlp exect +execv execvP +execve +execvp exit_status explicit_bzero extattr_delete_file @@ -1385,6 +1395,7 @@ fdatasync fdopendir fexecve fmemopen +fork forkpty fparseln freeifaddrs @@ -1685,6 +1696,7 @@ syscall sysctl sysctlbyname sysctlnametomib +system telldir timex truncate diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 35f7d85de5181..879b096a39b14 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,4 +1,30 @@ AT_EACCESS +EPOLLERR +EPOLLET +EPOLLEXCLUSIVE +EPOLLHUP +EPOLLIN +EPOLLMSG +EPOLLONESHOT +EPOLLOUT +EPOLLPRI +EPOLLRDBAND +EPOLLRDHUP +EPOLLRDNORM +EPOLLWAKEUP +EPOLLWRBAND +EPOLLWRNORM +EPOLL_CLOEXEC +EPOLL_CTL_ADD +EPOLL_CTL_DEL +EPOLL_CTL_MOD +SIGEV_THREAD_ID +epoll_create +epoll_create1 +epoll_ctl +epoll_event +epoll_pwait +epoll_wait getentropy getgrgid getgrgid_r @@ -7,4 +33,3 @@ getgrnam_r getpwnam_r getpwuid_r in6_pktinfo -posix_fallocate64 diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 2cdacfe842cca..dd380534a4d35 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -546,6 +546,10 @@ IN6_IFF_NODAD IN6_IFF_PREFER_SOURCE IN6_IFF_TEMPORARY IN6_IFF_TENTATIVE +INHERIT_COPY +INHERIT_NONE +INHERIT_SHARE +INHERIT_ZERO INIT_PROCESS IOV_MAX IPC_CREAT @@ -1998,8 +2002,14 @@ eui64_ntoa eui64_ntohost eventfd_read eventfd_write +execl +execle +execlp exect +execv execvP +execve +execvp execvpe explicit_bzero extattr_delete_fd @@ -2034,6 +2044,7 @@ fls flsl flsll fmemopen +fork forkpty fparseln freeifaddrs @@ -2126,6 +2137,7 @@ kld_load kqueue labs lchflags +lchmod lcong48 lio_listio lockf @@ -2459,6 +2471,7 @@ syscall sysctl sysctlbyname sysctlnametomib +system tcp_fastopen tcp_function_set tcp_info diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index 88bd6db31a7e0..656ff4d6c0b13 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -1276,6 +1276,12 @@ duplocale endpwent epoll_event eventfd +execl +execle +execlp +execv +execve +execvp execvpe faccessat fallocate @@ -1291,6 +1297,7 @@ ff_ramp_effect ff_replay ff_rumble_effect ff_trigger +fork fpos64_t freeifaddrs freelocale @@ -1466,6 +1473,7 @@ sync sync_file_range syscall sysinfo +system tee telldir termios2 diff --git a/libc-test/semver/hermit.txt b/libc-test/semver/hermit.txt index 43ca11b6acf74..6212926d41003 100644 --- a/libc-test/semver/hermit.txt +++ b/libc-test/semver/hermit.txt @@ -185,7 +185,7 @@ IP_TTL MSG_PEEK O_APPEND O_CREAT -O_DIRECTORY +O_DIRECTORY O_EXCL O_NONBLOCK O_RDONLY @@ -246,6 +246,13 @@ S_IXUSR TCP_NODELAY addrinfo dirent64 +execl +execle +execlp +execv +execve +execvp +fork in6_addr in_addr iovec diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index f66ee1d873226..9a575222f29a3 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -22,6 +22,13 @@ TFD_NONBLOCK TFD_TIMER_ABSTIME TFD_TIMER_CANCEL_ON_SET _CS_PATH +execl +execle +execlp +execv +execve +execvp +fork posix_fadvise posix_fallocate posix_spawn_file_actions_addfchdir_np @@ -30,6 +37,7 @@ pthread_attr_getstackaddr pthread_attr_setstack ptsname_r syncfs +system timerfd_create timerfd_gettime timerfd_settime diff --git a/libc-test/semver/ios.txt b/libc-test/semver/ios.txt index 1a5fcd2ac3fe2..ea09d96dccf56 100644 --- a/libc-test/semver/ios.txt +++ b/libc-test/semver/ios.txt @@ -1,3 +1,17 @@ __darwin_arm_exception_state64 __darwin_arm_neon_state64 __darwin_arm_thread_state64 +brk +exchangedata +execl +execle +execlp +execv +execvP +execve +execvp +fork +sbrk +sigaltstack +syscall +task_set_info diff --git a/libc-test/semver/l4re.txt b/libc-test/semver/l4re.txt index e4a8a79a28a11..d49b9dd89a195 100644 --- a/libc-test/semver/l4re.txt +++ b/libc-test/semver/l4re.txt @@ -1495,6 +1495,7 @@ SIGCONT SIGEV_NONE SIGEV_SIGNAL SIGEV_THREAD +SIGEV_THREAD_ID SIGFPE SIGHUP SIGILL diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 4fbcf053c022a..d846885a12c82 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -402,7 +402,6 @@ RWF_NOWAIT RWF_SYNC SECURITYFS_MAGIC SELINUX_MAGIC -SIGEV_THREAD_ID SMACK_MAGIC SMB_SUPER_MAGIC SOL_CAIF @@ -425,20 +424,25 @@ STATX_ATTR_IMMUTABLE STATX_ATTR_MOUNT_ROOT STATX_ATTR_NODUMP STATX_ATTR_VERITY +STATX_ATTR_WRITE_ATOMIC STATX_BASIC_STATS STATX_BLOCKS STATX_BTIME STATX_CTIME STATX_DIOALIGN +STATX_DIO_READ_ALIGN STATX_GID STATX_INO STATX_MNT_ID +STATX_MNT_ID_UNIQUE STATX_MODE STATX_MTIME STATX_NLINK STATX_SIZE +STATX_SUBVOL STATX_TYPE STATX_UID +STATX_WRITE_ATOMIC STATX__RESERVED STA_CLK STA_CLOCKERR diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 737874f32ce30..ba6693d4d2f6f 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -727,6 +727,7 @@ ETH_P_IPX ETH_P_IRDA ETH_P_LAT ETH_P_LINK_CTL +ETH_P_LLDP ETH_P_LOCALTALK ETH_P_LOOP ETH_P_LOOPBACK @@ -3029,6 +3030,7 @@ SHORT_INODE SIGEV_NONE SIGEV_SIGNAL SIGEV_THREAD +SIGEV_THREAD_ID SIGIO SIGPOLL SIGPWR @@ -4098,6 +4100,12 @@ erand48 eventfd eventfd_read eventfd_write +execl +execle +execlp +execv +execve +execvp execvpe faccessat fallocate @@ -4128,6 +4136,7 @@ file_handle flistxattr fmemopen fopen64 +fork forkpty fpos64_t fread_unlocked @@ -4552,6 +4561,7 @@ sync_file_range syncfs syscall sysinfo +system tee telldir timer_create diff --git a/libc-test/semver/macos.txt b/libc-test/semver/macos.txt index 048c8a120329b..ceba7a449d8be 100644 --- a/libc-test/semver/macos.txt +++ b/libc-test/semver/macos.txt @@ -1,7 +1,238 @@ +AF_SYS_CONTROL +ARPOP_REPLY +ARPOP_REQUEST +ATF_COM +ATF_PERM +ATF_PUBL +ATF_USETRAILERS +BIOCFLUSH +BIOCGBLEN +BIOCGDLT +BIOCGDLTLIST +BIOCGETIF +BIOCGHDRCMPLT +BIOCGRSIG +BIOCGRTIMEOUT +BIOCGSEESENT +BIOCGSTATS +BIOCIMMEDIATE +BIOCPROMISC +BIOCSBLEN +BIOCSDLT +BIOCSETF +BIOCSETFNR +BIOCSETIF +BIOCSHDRCMPLT +BIOCSRSIG +BIOCSRTIMEOUT +BIOCSSEESENT +BIOCVERSION +BPF_ALIGNMENT +BPF_WORDALIGN CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_RAW_APPROX CLOCK_UPTIME_RAW CLOCK_UPTIME_RAW_APPROX +CTLIOCGINFO +DLT_ARCNET +DLT_ATM_RFC1483 +DLT_AX25 +DLT_CHAOS +DLT_EN10MB +DLT_EN3MB +DLT_FDDI +DLT_IEEE802 +DLT_LOOP +DLT_NULL +DLT_PPP +DLT_PRONET +DLT_RAW +DLT_SLIP +IN6_IFF_ANYCAST +IN6_IFF_AUTOCONF +IN6_IFF_CLAT46 +IN6_IFF_DEPRECATED +IN6_IFF_DETACHED +IN6_IFF_DUPLICATED +IN6_IFF_DYNAMIC +IN6_IFF_NODAD +IN6_IFF_NOPFX +IN6_IFF_OPTIMISTIC +IN6_IFF_SECURED +IN6_IFF_TEMPORARY +IN6_IFF_TENTATIVE +PROC_CSM_ALL +PROC_CSM_NOSMT +PROC_CSM_TECS +PROC_PIDTASKALLINFO +PROC_PIDTASKINFO +PROC_PIDTHREADINFO +PT_ATTACH +PT_ATTACHEXC +PT_CONTINUE +PT_DENY_ATTACH +PT_DETACH +PT_FIRSTMACH +PT_FORCEQUOTA +PT_KILL +PT_READ_D +PT_READ_I +PT_READ_U +PT_SIGEXC +PT_STEP +PT_THUPDATE +PT_TRACE_ME +PT_WRITE_D +PT_WRITE_I +PT_WRITE_U +RTAX_AUTHOR +RTAX_BRD +RTAX_DST +RTAX_GATEWAY +RTAX_GENMASK +RTAX_IFA +RTAX_IFP +RTAX_MAX +RTAX_NETMASK +RTA_AUTHOR +RTA_BRD +RTA_DST +RTA_GATEWAY +RTA_GENMASK +RTA_IFA +RTA_IFP +RTA_NETMASK +RTF_BLACKHOLE +RTF_BROADCAST +RTF_CLONING +RTF_CONDEMNED +RTF_DEAD +RTF_DELCLONE +RTF_DONE +RTF_DYNAMIC +RTF_GATEWAY +RTF_GLOBAL +RTF_HOST +RTF_IFREF +RTF_IFSCOPE +RTF_LLINFO +RTF_LOCAL +RTF_MODIFIED +RTF_MULTICAST +RTF_NOIFREF +RTF_PINNED +RTF_PRCLONING +RTF_PROTO1 +RTF_PROTO2 +RTF_PROTO3 +RTF_PROXY +RTF_REJECT +RTF_ROUTER +RTF_STATIC +RTF_UP +RTF_WASCLONED +RTF_XRESOLVE +RTM_ADD +RTM_CHANGE +RTM_DELADDR +RTM_DELETE +RTM_DELMADDR +RTM_GET +RTM_GET2 +RTM_IFINFO +RTM_IFINFO2 +RTM_LOCK +RTM_LOSING +RTM_MISS +RTM_NEWADDR +RTM_NEWMADDR +RTM_NEWMADDR2 +RTM_OLDADD +RTM_OLDDEL +RTM_REDIRECT +RTM_RESOLVE +RTM_VERSION +RTV_EXPIRE +RTV_HOPCOUNT +RTV_MTU +RTV_RPIPE +RTV_RTT +RTV_RTTVAR +RTV_SPIPE +RTV_SSTHRESH +SIOCGIFAFLAG_IN6 +SYSPROTO_CONTROL +SYSPROTO_EVENT +UTUN_OPT_FLAGS +UTUN_OPT_IFNAME +__c_anonymous_bfl_u +_dyld_get_image_header +_dyld_get_image_name +_dyld_get_image_vmaddr_slide +_dyld_image_count +arphdr +bpf_dltlist +bpf_hdr +bpf_insn +bpf_program +brk clock_settime +ctl_info +exchangedata +execl +execle +execlp +execv +execvP +execve +execvp +fork +gethostuuid +icmp6_ifstat +in6_addrlifetime +in6_ifreq +in6_ifstat +mach_absolute_time +mach_header +mach_header_64 +mach_host_self +mach_port_t +mach_thread_self +mach_timebase_info +mach_timebase_info_data_t +mach_vm_map memmem +proc_bsdinfo +proc_bsdshortinfo +proc_kmsgbuf +proc_libversion +proc_listallpids +proc_listchildpids +proc_listpgrppids +proc_listpids +proc_name +proc_pidfdinfo +proc_pidfileportinfo +proc_pidinfo +proc_pidpath +proc_regionfilename +proc_set_csm +proc_set_no_smt +proc_setthread_csm +proc_setthread_no_smt +proc_taskallinfo +proc_taskinfo +proc_threadinfo +pthread_jit_write_callback_t +pthread_jit_write_freeze_callbacks_np +pthread_jit_write_protect_np +pthread_jit_write_protect_supported_np +pthread_jit_write_with_callback_np +ptrace +sbrk +sigaltstack +sockaddr_ctl +sockaddr_inarp +syscall +system task_set_info diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 182d4e2b5a7b2..44d9380d1260d 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -650,6 +650,11 @@ MAP_ALIGNMENT_MASK MAP_ALIGNMENT_SHIFT MAP_FILE MAP_HASSEMAPHORE +MAP_INHERIT_COPY +MAP_INHERIT_DONATE_COPY +MAP_INHERIT_NONE +MAP_INHERIT_SHARE +MAP_INHERIT_ZERO MAP_NORESERVE MAP_REMAPDUP MAP_RENAME @@ -1298,6 +1303,12 @@ estrndup estrtoi estrtou evasprintf +execl +execle +execlp +execv +execve +execvp explicit_memset extattr_delete_fd extattr_delete_file @@ -1322,6 +1333,7 @@ fgetxattr flags_to_string flistxattr fmemopen +fork forkpty freeifaddrs freelocale @@ -1410,6 +1422,7 @@ labs lastlog lastlogx lchflags +lchmod lcong48 lgetxattr lio_listio @@ -1621,6 +1634,7 @@ sysctl sysctlbyname sysctldesc sysctlnametomib +system tcp_info telldir timer_create @@ -1648,4 +1662,4 @@ utmpxname utrace uucred wait4 -waitid \ No newline at end of file +waitid diff --git a/libc-test/semver/nto.txt b/libc-test/semver/nto.txt new file mode 100644 index 0000000000000..4fe337edf2b12 --- /dev/null +++ b/libc-test/semver/nto.txt @@ -0,0 +1,886 @@ +AF_INET +AF_INET6 +AF_UNIX +AF_UNSPEC +B0 +B110 +B115200 +B1200 +B134 +B150 +B1800 +B19200 +B200 +B2400 +B300 +B38400 +B4800 +B50 +B57600 +B600 +B75 +B9600 +BRKINT +CLOCAL +CLOCK_MONOTONIC +CLOCK_REALTIME +CREAD +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTOPB +DIR +Dl_info +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EAFNOSUPPORT +EAGAIN +EAI_SYSTEM +EALREADY +EBADF +EBADMSG +EBUSY +ECANCELED +ECHILD +ECHO +ECHOE +ECHOK +ECHONL +ECONNABORTED +ECONNREFUSED +ECONNRESET +EDEADLK +EDESTADDRREQ +EDOM +EDQUOT +EEXIST +EFAULT +EFBIG +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +ELOOP +EMFILE +EMLINK +EMSGSIZE +ENAMETOOLONG +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOBUFS +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOMEM +ENOMSG +ENOPROTOOPT +ENOSPC +ENOSYS +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTSOCK +ENOTTY +ENXIO +EOPNOTSUPP +EOVERFLOW +EPERM +EPFNOSUPPORT +EPIPE +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERANGE +EROFS +ESHUTDOWN +ESPIPE +ESRCH +ESTALE +ETIMEDOUT +ETXTBSY +EWOULDBLOCK +EXDEV +EXIT_FAILURE +EXIT_SUCCESS +FD_CLOEXEC +FD_CLR +FD_ISSET +FD_SET +FD_SETSIZE +FD_ZERO +FILE +FIOCLEX +FIONBIO +FNM_CASEFOLD +FNM_NOESCAPE +FNM_NOMATCH +FNM_PATHNAME +FNM_PERIOD +F_DUPFD +F_DUPFD_CLOEXEC +F_GETFD +F_GETFL +F_GETLK +F_OK +F_SETFD +F_SETFL +F_SETLK +F_SETLKW +HUPCL +ICANON +ICRNL +IEXTEN +IFNAMSIZ +IF_NAMESIZE +IGNBRK +IGNCR +IGNPAR +IN6ADDR_ANY_INIT +IN6ADDR_LOOPBACK_INIT +INADDR_ANY +INADDR_BROADCAST +INADDR_LOOPBACK +INADDR_NONE +INLCR +INPCK +INT_MAX +INT_MIN +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IP +IPPROTO_IPV6 +IPPROTO_TCP +IPPROTO_UDP +IPV6_MULTICAST_HOPS +IPV6_MULTICAST_IF +IPV6_MULTICAST_LOOP +IPV6_UNICAST_HOPS +IPV6_V6ONLY +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MULTICAST_IF +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_TTL +ISIG +ISTRIP +IXANY +IXOFF +IXON +LOG_ALERT +LOG_AUTH +LOG_CONS +LOG_CRIT +LOG_DAEMON +LOG_DEBUG +LOG_EMERG +LOG_ERR +LOG_FACMASK +LOG_INFO +LOG_KERN +LOG_LOCAL0 +LOG_LOCAL1 +LOG_LOCAL2 +LOG_LOCAL3 +LOG_LOCAL4 +LOG_LOCAL5 +LOG_LOCAL6 +LOG_LOCAL7 +LOG_LPR +LOG_MAIL +LOG_NDELAY +LOG_NEWS +LOG_NOTICE +LOG_NOWAIT +LOG_ODELAY +LOG_PID +LOG_PRIMASK +LOG_SYSLOG +LOG_USER +LOG_UUCP +LOG_WARNING +MAP_ANON +MAP_ANONYMOUS +MAP_FAILED +MAP_FIXED +MAP_PRIVATE +MAP_SHARED +MSG_CTRUNC +MSG_DONTROUTE +MSG_EOR +MSG_OOB +MSG_PEEK +MSG_TRUNC +MSG_WAITALL +MS_ASYNC +MS_INVALIDATE +MS_SYNC +NCCS +NI_MAXHOST +NOFLSH +OCRNL +ONLCR +ONLRET +ONOCR +OPOST +O_ACCMODE +O_APPEND +O_CLOEXEC +O_CREAT +O_DIRECTORY +O_EXCL +O_NOFOLLOW +O_NONBLOCK +O_RDONLY +O_RDWR +O_TRUNC +O_WRONLY +PARENB +PARMRK +PARODD +PATH_MAX +PF_INET +PF_INET6 +PF_UNIX +PF_UNSPEC +POLLERR +POLLHUP +POLLIN +POLLNVAL +POLLOUT +POLLPRI +PRIO_PGRP +PRIO_PROCESS +PRIO_USER +PROT_EXEC +PROT_NONE +PROT_READ +PROT_WRITE +PTHREAD_COND_INITIALIZER +PTHREAD_MUTEX_INITIALIZER +PTHREAD_MUTEX_NORMAL +PTHREAD_MUTEX_RECURSIVE +PTHREAD_RWLOCK_INITIALIZER +RTLD_DEFAULT +RTLD_GLOBAL +RTLD_LAZY +RTLD_LOCAL +RTLD_NOW +R_OK +SA_NOCLDSTOP +SA_NOCLDWAIT +SA_NODEFER +SA_RESETHAND +SA_SIGINFO +SEEK_CUR +SEEK_END +SEEK_SET +SHUT_RD +SHUT_RDWR +SHUT_WR +SIGABRT +SIGALRM +SIGBUS +SIGCHLD +SIGCONT +SIGFPE +SIGHUP +SIGILL +SIGINT +SIGIOT +SIGKILL +SIGPIPE +SIGPROF +SIGQUIT +SIGSEGV +SIGSTOP +SIGSYS +SIGTERM +SIGTRAP +SIGTSTP +SIGTTIN +SIGTTOU +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ +SIG_BLOCK +SIG_DFL +SIG_ERR +SIG_IGN +SIG_SETMASK +SIG_UNBLOCK +SOCK_DGRAM +SOCK_SEQPACKET +SOCK_STREAM +SOL_SOCKET +SO_ACCEPTCONN +SO_BROADCAST +SO_DEBUG +SO_DONTROUTE +SO_ERROR +SO_KEEPALIVE +SO_LINGER +SO_OOBINLINE +SO_RCVBUF +SO_RCVLOWAT +SO_RCVTIMEO +SO_REUSEADDR +SO_SNDBUF +SO_SNDLOWAT +SO_SNDTIMEO +SO_TYPE +STDERR_FILENO +STDIN_FILENO +STDOUT_FILENO +S_IFBLK +S_IFCHR +S_IFDIR +S_IFIFO +S_IFLNK +S_IFMT +S_IFREG +S_IFSOCK +S_IRGRP +S_IROTH +S_IRUSR +S_IRWXG +S_IRWXO +S_IRWXU +S_ISGID +S_ISUID +S_ISVTX +S_IWGRP +S_IWOTH +S_IWUSR +S_IXGRP +S_IXOTH +S_IXUSR +TCIFLUSH +TCIOFF +TCIOFLUSH +TCION +TCOFLUSH +TCOOFF +TCOON +TCP_NODELAY +TCSADRAIN +TCSAFLUSH +TCSANOW +TIOCGWINSZ +TIOCSWINSZ +TOSTOP +VEOF +VEOL +VEOL2 +VERASE +VINTR +VKILL +VMIN +VQUIT +VSTART +VSTOP +VSUSP +VTIME +WCONTINUED +WCOREDUMP +WEXITSTATUS +WIFCONTINUED +WIFEXITED +WIFSIGNALED +WIFSTOPPED +WNOHANG +WSTOPSIG +WTERMSIG +WUNTRACED +W_OK +X_OK +_PC_CHOWN_RESTRICTED +_PC_LINK_MAX +_PC_MAX_CANON +_PC_MAX_INPUT +_PC_NAME_MAX +_PC_NO_TRUNC +_PC_PATH_MAX +_PC_PIPE_BUF +_PC_VDISABLE +_SC_ARG_MAX +_SC_CHILD_MAX +_SC_CLK_TCK +_SC_HOST_NAME_MAX +_SC_NGROUPS_MAX +_SC_OPEN_MAX +_SC_PAGESIZE +_SC_PAGE_SIZE +_SC_STREAM_MAX +_SC_SYMLOOP_MAX +_SC_TTY_NAME_MAX +_SC_TZNAME_MAX +_SC_VERSION +_exit +abort +accept +access +addrinfo +alarm +aligned_alloc +atexit +atof +atoi +atol +atoll +bind +blkcnt_t +blksize_t +c_char +c_double +c_float +c_int +c_long +c_longlong +c_schar +c_short +c_uchar +c_uint +c_ulong +c_ulonglong +c_ushort +c_void +calloc +cc_t +cfgetispeed +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +chdir +chmod +chown +clock_gettime +clock_t +clockid_t +close +closedir +closelog +confstr +connect +creat +dev_t +dirent +dladdr +dlclose +dlerror +dlopen +dlsym +dup +dup2 +execl +execle +execlp +execv +execve +execvp +exit +fchmod +fchmodat +fchown +fchownat +fclose +fcntl +fd_set +fdopen +feof +ferror +fflush +fgetc +fgetpos +fgets +fileno +flock +fnmatch +fopen +fork +fpathconf +fpos_t +fprintf +fputc +fputs +fread +free +freeaddrinfo +freopen +fsblkcnt_t +fscanf +fseek +fseeko +fsetpos +fsfilcnt_t +fstat +fstatat +fstatvfs +fsync +ftell +ftello +ftruncate +futimens +fwrite +gai_strerror +getaddrinfo +getchar +getchar_unlocked +getcwd +getegid +getenv +geteuid +getgid +getgroups +gethostname +getlogin +getopt +getpeername +getpgid +getpgrp +getpid +getppid +getprotobyname +getprotobynumber +getpwnam +getpwuid +getservbyname +getsockname +getsockopt +gettimeofday +getuid +gid_t +gmtime +gmtime_r +grantpt +group +hostent +hstrerror +htonl +htons +if_indextoname +if_nametoindex +in6_addr +in6addr_any +in6addr_loopback +in_addr +in_addr_t +in_port_t +ino_t +int16_t +int32_t +int64_t +int8_t +intmax_t +intptr_t +ioctl +iovec +ip_mreq +ipv6_mreq +isalnum +isalpha +isatty +isblank +iscntrl +isdigit +isgraph +islower +isprint +ispunct +isspace +isupper +isxdigit +itimerval +kill +lchown +lconv +linger +link +linkat +listen +locale_t +localeconv +localtime +localtime_r +lseek +lstat +malloc +memccpy +memchr +memcmp +memcpy +memmove +memset +mkdir +mkdtemp +mkfifo +mknod +mkstemp +mktime +mlock +mlockall +mmap +mode_t +mprotect +msync +munlock +munlockall +munmap +nanosleep +nfds_t +nlink_t +ntohl +ntohs +off_t +open +opendir +openlog +passwd +pathconf +pclose +perror +pid_t +pipe +poll +pollfd +posix_memalign +posix_openpt +pread +printf +protoent +pselect +pthread_attr_destroy +pthread_attr_getstacksize +pthread_attr_init +pthread_attr_setdetachstate +pthread_attr_setstacksize +pthread_attr_t +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_t +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_init +pthread_condattr_t +pthread_create +pthread_detach +pthread_equal +pthread_exit +pthread_getspecific +pthread_join +pthread_key_create +pthread_key_delete +pthread_key_t +pthread_mutex_destroy +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_t +pthread_mutex_trylock +pthread_mutex_unlock +pthread_mutexattr_destroy +pthread_mutexattr_init +pthread_mutexattr_settype +pthread_mutexattr_t +pthread_rwlock_destroy +pthread_rwlock_init +pthread_rwlock_rdlock +pthread_rwlock_t +pthread_rwlock_tryrdlock +pthread_rwlock_trywrlock +pthread_rwlock_unlock +pthread_rwlock_wrlock +pthread_rwlockattr_destroy +pthread_rwlockattr_init +pthread_rwlockattr_t +pthread_self +pthread_setspecific +pthread_t +ptrdiff_t +ptsname +putchar +putchar_unlocked +putenv +puts +pwrite +raise +read +readdir +readlink +readv +realloc +realpath +recv +recvfrom +remove +rename +renameat +res_init +rewind +rewinddir +rlim_t +rlimit +rmdir +rusage +sa_family_t +scanf +sched_yield +select +sem_post +sem_t +sem_trywait +sem_wait +send +sendto +servent +setbuf +setegid +setenv +seteuid +setgid +setlocale +setlogmask +setpgid +setregid +setreuid +setsid +setsockopt +setuid +setvbuf +shm_open +shm_unlink +shutdown +sigaction +sigaddset +sigdelset +sigemptyset +sigfillset +sighandler_t +sigismember +signal +sigpending +sigprocmask +sigset_t +sigval +size_t +sleep +snprintf +sockaddr +sockaddr_in +sockaddr_in6 +sockaddr_storage +sockaddr_un +socket +socketpair +socklen_t +speed_t +sprintf +sscanf +ssize_t +stat +statvfs +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strerror_r +strlen +strncat +strncmp +strncpy +strnlen +strpbrk +strrchr +strspn +strstr +strtod +strtof +strtok +strtol +strtoll +strtoul +strtoull +strxfrm +suseconds_t +symlink +symlinkat +sysconf +syslog +system +tcdrain +tcflag_t +tcflow +tcflush +tcgetattr +tcgetpgrp +tcgetsid +tcsendbreak +tcsetattr +tcsetpgrp +termios +time +time_t +timegm +times +timespec +timeval +timezone +tm +tmpfile +tmpnam +tms +tolower +toupper +ttyname +uid_t +uint16_t +uint32_t +uint64_t +uint8_t +uintmax_t +uintptr_t +umask +uname +ungetc +unlink +unlinkat +unlockpt +unsetenv +usleep +utimbuf +utime +utimes +utsname +wait +waitpid +wchar_t +wcslen +wcstombs +winsize +wmemchr +write +writev diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index cc84b0bb7ff18..8e2ca1d9f00b5 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -260,8 +260,35 @@ GLOB_NOMATCH GLOB_NOSORT GLOB_NOSPACE GLOB_NOSYS +HW_BATTERY +HW_BATTERY_CHARGEMODE +HW_BATTERY_CHARGESTART +HW_BATTERY_CHARGESTOP +HW_BYTEORDER +HW_CPUSPEED +HW_DISKCOUNT +HW_DISKNAMES +HW_DISKSTATS +HW_MACHINE +HW_MODEL HW_NCPU +HW_NCPUFOUND HW_NCPUONLINE +HW_PAGESIZE +HW_PERFPOLICY +HW_PHYSMEM +HW_PHYSMEM64 +HW_POWER +HW_PRODUCT +HW_SENSORS +HW_SERIALNO +HW_SETPERF +HW_UCOMNAMES +HW_USERMEM +HW_USERMEM64 +HW_UUID +HW_VENDOR +HW_VERSION IFF_ALLMULTI IFF_BROADCAST IFF_DEBUG @@ -514,6 +541,10 @@ MAP_CONCEAL MAP_COPY MAP_FILE MAP_HASSEMAPHORE +MAP_INHERIT_COPY +MAP_INHERIT_NONE +MAP_INHERIT_SHARE +MAP_INHERIT_ZERO MAP_NOEXTEND MAP_NORESERVE MAP_RENAME @@ -833,6 +864,8 @@ RTF_MPLS RTF_MULTICAST RTF_PROTO3 RTLD_NEXT +RTLD_NODELETE +RTLD_NOLOAD RTLD_SELF RTM_80211INFO RTM_BFD @@ -1129,6 +1162,12 @@ endgrent endpwent endservent erand48 +execl +execle +execlp +execv +execve +execvp execvpe explicit_bzero export_args @@ -1138,6 +1177,7 @@ fchflags fdatasync fdopendir fmemopen +fork forkpty freeifaddrs freelocale @@ -1377,6 +1417,7 @@ strtonum sync syscall sysctl +system tcp_info telldir tmpfs_args diff --git a/libc-test/semver/qnx.txt b/libc-test/semver/qnx.txt new file mode 100644 index 0000000000000..955f6fba9bffe --- /dev/null +++ b/libc-test/semver/qnx.txt @@ -0,0 +1,888 @@ +AF_INET +AF_INET6 +AF_UNIX +AF_UNSPEC +B0 +B110 +B115200 +B1200 +B134 +B150 +B1800 +B19200 +B200 +B2400 +B300 +B38400 +B4800 +B50 +B57600 +B600 +B75 +B9600 +BRKINT +CLOCAL +CLOCK_MONOTONIC +CLOCK_REALTIME +CREAD +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTOPB +DIR +Dl_info +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EAFNOSUPPORT +EAGAIN +EAI_SYSTEM +EALREADY +EBADF +EBADMSG +EBUSY +ECANCELED +ECHILD +ECHO +ECHOE +ECHOK +ECHONL +ECONNABORTED +ECONNREFUSED +ECONNRESET +EDEADLK +EDESTADDRREQ +EDOM +EDQUOT +EEXIST +EFAULT +EFBIG +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +ELOOP +EMFILE +EMLINK +EMSGSIZE +ENAMETOOLONG +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOBUFS +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOMEM +ENOMSG +ENOPROTOOPT +ENOSPC +ENOSYS +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTSOCK +ENOTTY +ENXIO +EOPNOTSUPP +EOVERFLOW +EPERM +EPFNOSUPPORT +EPIPE +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERANGE +EROFS +ESHUTDOWN +ESPIPE +ESRCH +ESTALE +ETIMEDOUT +ETXTBSY +EWOULDBLOCK +EXDEV +EXIT_FAILURE +EXIT_SUCCESS +FD_CLOEXEC +FD_CLR +FD_ISSET +FD_SET +FD_SETSIZE +FD_ZERO +FILE +FIOCLEX +FIONBIO +FNM_CASEFOLD +FNM_NOESCAPE +FNM_NOMATCH +FNM_PATHNAME +FNM_PERIOD +F_DUPFD +F_DUPFD_CLOEXEC +F_GETFD +F_GETFL +F_GETLK +F_OK +F_SETFD +F_SETFL +F_SETLK +F_SETLKW +HUPCL +ICANON +ICRNL +IEXTEN +IFNAMSIZ +IF_NAMESIZE +IGNBRK +IGNCR +IGNPAR +IN6ADDR_ANY_INIT +IN6ADDR_LOOPBACK_INIT +INADDR_ANY +INADDR_BROADCAST +INADDR_LOOPBACK +INADDR_NONE +INLCR +INPCK +INT_MAX +INT_MIN +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IP +IPPROTO_IPV6 +IPPROTO_TCP +IPPROTO_UDP +IPV6_MULTICAST_HOPS +IPV6_MULTICAST_IF +IPV6_MULTICAST_LOOP +IPV6_UNICAST_HOPS +IPV6_V6ONLY +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MULTICAST_IF +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_TTL +ISIG +ISTRIP +IXANY +IXOFF +IXON +LOG_ALERT +LOG_AUTH +LOG_CONS +LOG_CRIT +LOG_DAEMON +LOG_DEBUG +LOG_EMERG +LOG_ERR +LOG_FACMASK +LOG_INFO +LOG_KERN +LOG_LOCAL0 +LOG_LOCAL1 +LOG_LOCAL2 +LOG_LOCAL3 +LOG_LOCAL4 +LOG_LOCAL5 +LOG_LOCAL6 +LOG_LOCAL7 +LOG_LPR +LOG_MAIL +LOG_NDELAY +LOG_NEWS +LOG_NOTICE +LOG_NOWAIT +LOG_ODELAY +LOG_PID +LOG_PRIMASK +LOG_SYSLOG +LOG_USER +LOG_UUCP +LOG_WARNING +MAP_ANON +MAP_ANONYMOUS +MAP_FAILED +MAP_FIXED +MAP_PRIVATE +MAP_SHARED +MSG_CTRUNC +MSG_DONTROUTE +MSG_EOR +MSG_OOB +MSG_PEEK +MSG_TRUNC +MSG_WAITALL +MS_ASYNC +MS_INVALIDATE +MS_SYNC +NCCS +NI_MAXHOST +NOFLSH +OCRNL +ONLCR +ONLRET +ONOCR +OPOST +O_ACCMODE +O_APPEND +O_CLOEXEC +O_CREAT +O_DIRECTORY +O_EXCL +O_NOFOLLOW +O_NONBLOCK +O_RDONLY +O_RDWR +O_TRUNC +O_WRONLY +PARENB +PARMRK +PARODD +PATH_MAX +PF_INET +PF_INET6 +PF_UNIX +PF_UNSPEC +POLLERR +POLLHUP +POLLIN +POLLNVAL +POLLOUT +POLLPRI +PRIO_PGRP +PRIO_PROCESS +PRIO_USER +PROT_EXEC +PROT_NONE +PROT_READ +PROT_WRITE +PTHREAD_COND_INITIALIZER +PTHREAD_MUTEX_INITIALIZER +PTHREAD_MUTEX_NORMAL +PTHREAD_MUTEX_RECURSIVE +PTHREAD_RWLOCK_INITIALIZER +RTLD_DEFAULT +RTLD_GLOBAL +RTLD_LAZY +RTLD_LOCAL +RTLD_NOW +R_OK +SA_NOCLDSTOP +SA_NOCLDWAIT +SA_NODEFER +SA_ONSTACK +SA_RESETHAND +SA_SIGINFO +SEEK_CUR +SEEK_END +SEEK_SET +SHUT_RD +SHUT_RDWR +SHUT_WR +SIGABRT +SIGALRM +SIGBUS +SIGCHLD +SIGCONT +SIGFPE +SIGHUP +SIGILL +SIGINT +SIGIOT +SIGKILL +SIGPIPE +SIGPROF +SIGQUIT +SIGSEGV +SIGSTOP +SIGSYS +SIGTERM +SIGTRAP +SIGTSTP +SIGTTIN +SIGTTOU +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ +SIG_BLOCK +SIG_DFL +SIG_ERR +SIG_IGN +SIG_SETMASK +SIG_UNBLOCK +SOCK_DGRAM +SOCK_SEQPACKET +SOCK_STREAM +SOL_SOCKET +SO_ACCEPTCONN +SO_BROADCAST +SO_DEBUG +SO_DONTROUTE +SO_ERROR +SO_KEEPALIVE +SO_LINGER +SO_OOBINLINE +SO_RCVBUF +SO_RCVLOWAT +SO_RCVTIMEO +SO_REUSEADDR +SO_SNDBUF +SO_SNDLOWAT +SO_SNDTIMEO +SO_TYPE +STDERR_FILENO +STDIN_FILENO +STDOUT_FILENO +S_IFBLK +S_IFCHR +S_IFDIR +S_IFIFO +S_IFLNK +S_IFMT +S_IFREG +S_IFSOCK +S_IRGRP +S_IROTH +S_IRUSR +S_IRWXG +S_IRWXO +S_IRWXU +S_ISGID +S_ISUID +S_ISVTX +S_IWGRP +S_IWOTH +S_IWUSR +S_IXGRP +S_IXOTH +S_IXUSR +TCIFLUSH +TCIOFF +TCIOFLUSH +TCION +TCOFLUSH +TCOOFF +TCOON +TCP_NODELAY +TCSADRAIN +TCSAFLUSH +TCSANOW +TIOCGWINSZ +TIOCSWINSZ +TOSTOP +VEOF +VEOL +VEOL2 +VERASE +VINTR +VKILL +VMIN +VQUIT +VSTART +VSTOP +VSUSP +VTIME +WCONTINUED +WCOREDUMP +WEXITSTATUS +WIFCONTINUED +WIFEXITED +WIFSIGNALED +WIFSTOPPED +WNOHANG +WSTOPSIG +WTERMSIG +WUNTRACED +W_OK +X_OK +_PC_CHOWN_RESTRICTED +_PC_LINK_MAX +_PC_MAX_CANON +_PC_MAX_INPUT +_PC_NAME_MAX +_PC_NO_TRUNC +_PC_PATH_MAX +_PC_PIPE_BUF +_PC_VDISABLE +_SC_ARG_MAX +_SC_CHILD_MAX +_SC_CLK_TCK +_SC_HOST_NAME_MAX +_SC_NGROUPS_MAX +_SC_OPEN_MAX +_SC_PAGESIZE +_SC_PAGE_SIZE +_SC_STREAM_MAX +_SC_SYMLOOP_MAX +_SC_TTY_NAME_MAX +_SC_TZNAME_MAX +_SC_VERSION +_exit +abort +accept +access +addrinfo +alarm +aligned_alloc +atexit +atof +atoi +atol +atoll +bind +blkcnt_t +blksize_t +c_char +c_double +c_float +c_int +c_long +c_longlong +c_schar +c_short +c_uchar +c_uint +c_ulong +c_ulonglong +c_ushort +c_void +calloc +cc_t +cfgetispeed +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +cfsetspeed +chdir +chmod +chown +clock_gettime +clock_t +clockid_t +close +closedir +closelog +confstr +connect +creat +dev_t +dirent +dladdr +dlclose +dlerror +dlopen +dlsym +dup +dup2 +execl +execle +execlp +execv +execve +execvp +exit +fchmod +fchmodat +fchown +fchownat +fclose +fcntl +fd_set +fdopen +feof +ferror +fflush +fgetc +fgetpos +fgets +fileno +flock +fnmatch +fopen +fork +fpathconf +fpos_t +fprintf +fputc +fputs +fread +free +freeaddrinfo +freopen +fsblkcnt_t +fscanf +fseek +fseeko +fsetpos +fsfilcnt_t +fstat +fstatat +fstatvfs +fsync +ftell +ftello +ftruncate +futimens +fwrite +gai_strerror +getaddrinfo +getchar +getchar_unlocked +getcwd +getegid +getenv +geteuid +getgid +getgroups +gethostname +getlogin +getopt +getpeername +getpgid +getpgrp +getpid +getppid +getprotobyname +getprotobynumber +getpwnam +getpwuid +getservbyname +getsockname +getsockopt +gettimeofday +getuid +gid_t +gmtime +gmtime_r +grantpt +group +hostent +hstrerror +htonl +htons +if_indextoname +if_nametoindex +in6_addr +in6addr_any +in6addr_loopback +in_addr +in_addr_t +in_port_t +ino_t +int16_t +int32_t +int64_t +int8_t +intmax_t +intptr_t +ioctl +iovec +ip_mreq +ipv6_mreq +isalnum +isalpha +isatty +isblank +iscntrl +isdigit +isgraph +islower +isprint +ispunct +isspace +isupper +isxdigit +itimerval +kill +lchown +lconv +linger +link +linkat +listen +locale_t +localeconv +localtime +localtime_r +lseek +lstat +malloc +memccpy +memchr +memcmp +memcpy +memmove +memset +mkdir +mkdtemp +mkfifo +mknod +mkstemp +mktime +mlock +mlockall +mmap +mode_t +mprotect +msync +munlock +munlockall +munmap +nanosleep +nfds_t +nlink_t +ntohl +ntohs +off_t +open +opendir +openlog +passwd +pathconf +pclose +perror +pid_t +pipe +poll +pollfd +posix_memalign +posix_openpt +pread +printf +protoent +pselect +pthread_attr_destroy +pthread_attr_getstacksize +pthread_attr_init +pthread_attr_setdetachstate +pthread_attr_setstacksize +pthread_attr_t +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_t +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_init +pthread_condattr_t +pthread_create +pthread_detach +pthread_equal +pthread_exit +pthread_getspecific +pthread_join +pthread_key_create +pthread_key_delete +pthread_key_t +pthread_mutex_destroy +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_t +pthread_mutex_trylock +pthread_mutex_unlock +pthread_mutexattr_destroy +pthread_mutexattr_init +pthread_mutexattr_settype +pthread_mutexattr_t +pthread_rwlock_destroy +pthread_rwlock_init +pthread_rwlock_rdlock +pthread_rwlock_t +pthread_rwlock_tryrdlock +pthread_rwlock_trywrlock +pthread_rwlock_unlock +pthread_rwlock_wrlock +pthread_rwlockattr_destroy +pthread_rwlockattr_init +pthread_rwlockattr_t +pthread_self +pthread_setspecific +pthread_t +ptrdiff_t +ptsname +putchar +putchar_unlocked +putenv +puts +pwrite +raise +read +readdir +readlink +readv +realloc +realpath +recv +recvfrom +remove +rename +renameat +res_init +rewind +rewinddir +rlim_t +rlimit +rmdir +rusage +sa_family_t +scanf +sched_yield +select +sem_post +sem_t +sem_trywait +sem_wait +send +sendto +servent +setbuf +setegid +setenv +seteuid +setgid +setlocale +setlogmask +setpgid +setregid +setreuid +setsid +setsockopt +setuid +setvbuf +shm_open +shm_unlink +shutdown +sigaction +sigaddset +sigdelset +sigemptyset +sigfillset +sighandler_t +sigismember +signal +sigpending +sigprocmask +sigset_t +sigval +size_t +sleep +snprintf +sockaddr +sockaddr_in +sockaddr_in6 +sockaddr_storage +sockaddr_un +socket +socketpair +socklen_t +speed_t +sprintf +sscanf +ssize_t +stat +statvfs +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strerror_r +strlen +strncat +strncmp +strncpy +strnlen +strpbrk +strrchr +strspn +strstr +strtod +strtof +strtok +strtol +strtoll +strtoul +strtoull +strxfrm +suseconds_t +symlink +symlinkat +sysconf +syslog +system +tcdrain +tcflag_t +tcflow +tcflush +tcgetattr +tcgetpgrp +tcgetsid +tcsendbreak +tcsetattr +tcsetpgrp +termios +time +time_t +timegm +times +timespec +timeval +timezone +tm +tmpfile +tmpnam +tms +tolower +toupper +ttyname +uid_t +uint16_t +uint32_t +uint64_t +uint8_t +uintmax_t +uintptr_t +umask +uname +ungetc +unlink +unlinkat +unlockpt +unsetenv +usleep +utimbuf +utime +utimes +utsname +wait +waitpid +wchar_t +wcslen +wcstombs +winsize +wmemchr +write +writev diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index ef9caaed63e42..8753284191f4b 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -301,6 +301,7 @@ chroot clearerr clock_getres clock_gettime +clock_settime difftime dirfd endgrent @@ -311,11 +312,18 @@ epoll_create1 epoll_ctl epoll_event epoll_wait +execl +execle +execlp +execv +execve +execvp explicit_bzero faccessat fchdir fdopendir fmemopen +fork getdtablesize getgrent getgrgid @@ -346,6 +354,7 @@ open_memstream open_wmemstream openat openpty +pause pipe2 pthread_condattr_setclock qsort @@ -378,5 +387,6 @@ strlcpy strncasecmp strndup strsignal +system ttyname_r utimensat diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index fb596019d5370..86af2ec6a4c94 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -46,6 +46,13 @@ aio_waitn aio_write aiocb bind +execl +execle +execlp +execv +execve +execvp +fork in6_pktinfo in_pktinfo lio_listio @@ -81,3 +88,4 @@ sendmsg sigqueue strftime strftime_l +system diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 052c24178dfcc..07b6a9cd61c40 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -505,12 +505,6 @@ dlopen dlsym dup dup2 -execl -execle -execlp -execv -execve -execvp exit fchmod fchmodat @@ -530,7 +524,6 @@ fileno flock fnmatch fopen -fork fpathconf fpos_t fprintf @@ -845,7 +838,6 @@ symlink symlinkat sysconf syslog -system tcdrain tcflag_t tcflow diff --git a/libc-test/semver/wasi.txt b/libc-test/semver/wasi.txt index 510c73fd16e70..7fa658bb78021 100644 --- a/libc-test/semver/wasi.txt +++ b/libc-test/semver/wasi.txt @@ -1,6 +1,13 @@ FD_ISSET FD_SET FD_ZERO +LC_ALL +LC_COLLATE +LC_CTYPE +LC_MESSAGES +LC_MONETARY +LC_NUMERIC +LC_TIME SOCK_CLOEXEC SOCK_NONBLOCK SOL_SOCKET diff --git a/libc-test/tests/makedev.rs b/libc-test/tests/makedev.rs index 9e76b30acfb79..6620294ce0385 100644 --- a/libc-test/tests/makedev.rs +++ b/libc-test/tests/makedev.rs @@ -44,13 +44,7 @@ cfg_if::cfg_if! { ))] { pub type MajorRetType = libc::c_int; pub type MinorRetType = libc::c_int; - } else if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos" - ))] { + } else if #[cfg(target_vendor = "apple")] { pub type MajorRetType = i32; pub type MinorRetType = i32; } diff --git a/libc-test/tests/style.rs b/libc-test/tests/style.rs index 3cc70586d15e8..be734f2a1184a 100644 --- a/libc-test/tests/style.rs +++ b/libc-test/tests/style.rs @@ -29,6 +29,15 @@ const SKIP_PREFIXES: &[&str] = &[ ]; #[test] +#[cfg_attr( + any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + ), + ignore = "source code is not available for cross-compiled tests" +)] fn check_style() { let src_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../src"); walk(&src_root).unwrap(); diff --git a/libc-test/tests/style_lib/mod.rs b/libc-test/tests/style_lib/mod.rs index d436dcaaa2800..aabdbf7aefa13 100644 --- a/libc-test/tests/style_lib/mod.rs +++ b/libc-test/tests/style_lib/mod.rs @@ -55,7 +55,7 @@ const ALLOWED_POSITIVE_S_CFGS: &[&str] = &[ "gnu_file_offset_bits64", "gnu_time_bits64", "musl32_time64", - "musl_v1_2_3", + "musl_v1_2", ]; pub type Error = Box; diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index bb139ba1d43ba..57ee24142aadc 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -319,9 +319,9 @@ s! { __next: *mut c_void, __prev: *mut c_void, #[cfg(target_pointer_width = "32")] - __dummy4: [c_char; 24], + __dummy4: Padding<[c_char; 24]>, #[cfg(target_pointer_width = "64")] - __dummy4: [c_char; 16], + __dummy4: Padding<[c_char; 16]>, } // FIXME(1.0): This should not implement `PartialEq` @@ -786,7 +786,7 @@ s! { pub f_fsid: c_ulong, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct stack_t { @@ -1127,8 +1127,10 @@ s_no_extra_traits! { pub const HOST_NAME_MAX: c_int = 255; -pub const INT_MIN: c_int = -1 - 0x7fffffff; -pub const INT_MAX: c_int = 0x7fffffff; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; diff --git a/src/helenos.rs b/src/helenos.rs new file mode 100644 index 0000000000000..96253c1d58925 --- /dev/null +++ b/src/helenos.rs @@ -0,0 +1,77 @@ +use crate::prelude::*; +use crate::{ + errno_t, + timespec, +}; + +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; + +// uspace/lib/posix/include/posix/pthread.h +pub type pthread_key_t = c_int; + +// uspace/lib/posix/include/posix/sys/types.h +pub type clockid_t = c_int; +pub type pid_t = c_int; + +s! { + // common/include/adt/list.h + pub struct link_t { + pub next: *mut link_t, + pub prev: *mut link_t, + } + + pub struct list_t { + pub head: link_t, + } +} + +// uspace/lib/posix/include/posix/time.h +pub const CLOCK_REALTIME: clockid_t = 0; +pub const CLOCK_MONOTONIC: clockid_t = 1; + +// 'static inline' functions from libc +// common/include/adt/list.h +f! { + pub safe fn list_initialize(list: &mut list_t) -> () { + list.head.next = &mut list.head; + list.head.prev = &mut list.head; + } +} + +extern "C" { + // common/include/str_error.h + pub fn str_error(err: errno_t) -> *const c_char; + pub fn str_error_name(err: errno_t) -> *const c_char; + + // uspace/lib/posix/include/posix/pthread.h + pub fn pthread_key_create( + key: *mut pthread_key_t, + destructor: Option, + ) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + + // uspace/lib/posix/include/posix/time.h + pub fn clock_getres(clock_id: clockid_t, res: *mut timespec) -> c_int; + pub fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int; + pub fn clock_settime(clock_id: clockid_t, tp: *const timespec) -> c_int; + pub fn clock_nanosleep( + clock_id: clockid_t, + flags: c_int, + rqtp: *const timespec, + rmtp: *mut timespec, + ) -> c_int; + + // uspace/lib/posix/include/posix/unistd.h + pub fn getpid() -> pid_t; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn chdir(buf: *const c_char) -> c_int; + pub static environ: *const *const c_char; + pub fn isatty(fd: c_int) -> c_int; +} diff --git a/src/hermit.rs b/src/hermit.rs index 04699b1ecbb3d..ae39e73eed35b 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -51,8 +51,8 @@ s! { } pub struct iovec { - iov_base: *mut c_void, - iov_len: usize, + pub iov_base: *mut c_void, + pub iov_len: usize, } pub struct pollfd { diff --git a/src/lib.rs b/src/lib.rs index a95a967e73626..671e2c7dc81be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -254,6 +254,14 @@ cfg_if! { mod unix; pub use crate::unix::*; + prelude!(); + } else if #[cfg(target_os = "helenos")] { + mod primitives; + pub use primitives::*; + + mod helenos; + pub use self::helenos::*; + prelude!(); } else if #[cfg(target_os = "hermit")] { mod primitives; diff --git a/src/macros.rs b/src/macros.rs index d82febea32410..587438c5ec869 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -215,37 +215,26 @@ macro_rules! s_paren { /// Most structs will prefer to use [`s`]. macro_rules! s_no_extra_traits { ($( - $(#[$attr:meta])* + $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_no_extra_traits!(it: $(#[$attr])* $pub $t $i { $($field)* }); + s_no_extra_traits!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( - #[repr(C)] - #[::core::prelude::v1::derive( - ::core::clone::Clone, - ::core::marker::Copy, - )] - $(#[$attr])* - $pub union $i { $($field)* } - - #[allow(deprecated)] - 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:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( + union_with_debug! { + $(#$attr)* $pub union $i { $($field)* } } ); - (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( #[repr(C)] #[::core::prelude::v1::derive( ::core::clone::Clone, ::core::marker::Copy, ::core::fmt::Debug, )] - $(#[$attr])* + $(#$attr)* $pub struct $i { $($field)* } ); } @@ -253,19 +242,19 @@ macro_rules! s_no_extra_traits { /// Like [`s`], but also generates a `Default` impl for every struct in the block. macro_rules! s_with_default { ($( - $(#[$attr:meta])* + $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_with_default!(it: $(#[$attr])* $pub $t $i { $($field)* }); + s_with_default!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( + (it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( compile_error!( "unions cannot derive extra traits, use s_no_extra_traits_with_default instead" ); ); - (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( struct_with_default! { attrs: { #[repr(C)] @@ -280,7 +269,7 @@ macro_rules! s_with_default { )] #[allow(deprecated)] } - $(#[$attr])* $pub struct $i { $($field)* } + $(#$attr)* $pub struct $i { $($field)* } } ); } @@ -291,29 +280,19 @@ macro_rules! s_with_default { /// union type supplies its own default via `#[custom_default(...)]`. macro_rules! s_no_extra_traits_with_default { ($( - $(#[$attr:meta])* + $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_no_extra_traits_with_default!(it: $(#[$attr])* $pub $t $i { $($field)* }); + s_no_extra_traits_with_default!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( - #[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:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( + union_with_debug! { + $(#$attr)* $pub union $i { $($field)* } } ); - (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( struct_with_default! { attrs: { #[repr(C)] @@ -323,11 +302,109 @@ macro_rules! s_no_extra_traits_with_default { ::core::fmt::Debug, )] } - $(#[$attr])* $pub struct $i { $($field)* } + $(#$attr)* $pub struct $i { $($field)* } } ); } +/// Emit a union plus its `Debug` impl. +/// +/// Unions can't derive `Debug`, so it is written out here. Attributes are split like +/// [`struct_with_default`] does. Everything goes on the union, but only the `cfg`s are repeated +/// on the impl, otherwise a union that is configured out leaves an impl behind. +macro_rules! union_with_debug { + ( + $(#$attr:tt)* + $vis:vis union $name:ident { $($body:tt)* } + ) => { + union_with_debug! { + @split_attrs + cfg_attrs: { } + other_attrs: { } + remaining_attrs: { $(#$attr)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // a `cfg` also has to gate the impl + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #[cfg($($cfg:tt)*)] + $($tail:tt)* + } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + union_with_debug! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* #[cfg($($cfg)*)] } + other_attrs: { $($other_attrs)* } + remaining_attrs: { $($tail)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // anything else belongs to the union only + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #$other:tt + $($tail:tt)* + } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + union_with_debug! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* #$other } + remaining_attrs: { $($tail)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // done + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + )] + $($other_attrs)* + $($cfg_attrs)* + $vis union $name { $($body)* } + + $($cfg_attrs)* + #[allow(deprecated)] + impl ::core::fmt::Debug for $name { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct(::core::stringify!($name)).finish_non_exhaustive() + } + } + }; +} + /// Emit a struct with the given derive attributes plus a generated `Default` impl. /// /// Fields default to `Default::default()`. A field whose default can't be derived must carry @@ -338,17 +415,92 @@ macro_rules! s_no_extra_traits_with_default { /// for `Default`. If it does not exist, `Default::default()` is used instead. In either case, the /// field is added to `processed_fields` with `#[custom_default]` stripped if necessary, and /// `struct_with_default` is invoked again with the remaining fields. +/// +/// Attributes are split into `cfg_attrs` and `other_attrs` before the fields are scanned. Both +/// go on the struct, but only the `cfg`s are repeated on the `Default` impl. A `cfg` decides +/// whether the type exists at all, so without it a configured-out struct leaves an impl behind +/// referring to a type that isn't there. macro_rules! struct_with_default { // entry; `attrs` is the attribute block the caller wants on the struct (repr, derives, etc.), // which is merged with the struct's own attributes. ( attrs: { $($attrs:tt)* } - $(#[$attr:meta])* + $(#$attr:tt)* $vis:vis struct $name:ident { $($body:tt)* } + ) => { + struct_with_default! { + @split_attrs + cfg_attrs: { } + other_attrs: { } + remaining_attrs: { $($attrs)* $(#$attr)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // a `cfg` also has to gate the impl + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #[cfg($($cfg:tt)*)] + $($tail:tt)* + } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + struct_with_default! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* #[cfg($($cfg)*)] } + other_attrs: { $($other_attrs)* } + remaining_attrs: { $($tail)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // anything else belongs to the struct only + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #$other:tt + $($tail:tt)* + } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + struct_with_default! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* #$other } + remaining_attrs: { $($tail)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // attributes are split, move on to the fields + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } ) => { struct_with_default! { @struct - attrs: { $($attrs)* $(#[$attr])* } + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* } vis: { $vis } name: { $name } processed_fields: { } @@ -360,7 +512,8 @@ macro_rules! struct_with_default { // field led by #[custom_default(...)] ( @struct - attrs: { $($attrs:tt)* } + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } @@ -374,7 +527,8 @@ macro_rules! struct_with_default { ) => { struct_with_default! { @struct - attrs: { $($attrs)* } + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* } vis: { $vis } name: { $name } processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } @@ -389,7 +543,8 @@ macro_rules! struct_with_default { // plain field ( @struct - attrs: { $($attrs:tt)* } + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } @@ -402,7 +557,8 @@ macro_rules! struct_with_default { ) => { struct_with_default! { @struct - attrs: { $($attrs)* } + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* } vis: { $vis } name: { $name } processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } @@ -417,16 +573,21 @@ macro_rules! struct_with_default { // done ( @struct - attrs: { $($attrs:tt)* } + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } processed_field_defaults: { $($processed_field_defaults:tt)* } remaining_fields: { } ) => { - $($attrs)* + $($other_attrs)* + $($cfg_attrs)* $vis struct $name { $($processed_fields)* } + $($cfg_attrs)* + // The impl names the type and its fields, which warns if either is deprecated. + #[allow(deprecated)] impl ::core::default::Default for $name { // Field attributes (`#[cfg]`, doc comments) get forwarded to the initializer too. // Docs are harmless there but trip the lint, so silence it. @@ -964,6 +1125,31 @@ mod tests { assert_eq!(s.x, 0); assert_eq!(unsafe { s.u.a }, 0); } + + #[test] + fn s_with_default_keeps_struct_cfg() { + // The opposite of the configured-out types in `macro_checks`. With the `cfg` true the + // type and its `Default` both exist, and the other attributes still apply. + s_with_default! { + #[cfg(true)] + #[repr(align(8))] + /// a doc comment + struct EnabledCfg { + a: u32, + #[cfg(target_arch = "x86_64")] + x86_only: u8, + #[custom_default([1; 40])] + buf: [u8; 40], + } + } + + let s = EnabledCfg::default(); + assert_eq!(s.a, 0); + assert_eq!(s.buf, [1u8; 40]); + assert_eq!(align_of::(), 8); + #[cfg(target_arch = "x86_64")] + assert_eq!(s.x86_only, 0); + } } #[cfg(test)] @@ -1040,4 +1226,65 @@ mod macro_checks { assert_impls_default::(); assert_impls_default::(); } + + // Types configured out entirely, checking that the generated impls carry the same `cfg` as + // the type. Without it they fail to compile with "cannot find type". + s_with_default! { + #[cfg(false)] + pub struct S5 { + pub a: u32, + #[custom_default([1; 64])] + pub buf: [u8; 64], + } + } + + s_no_extra_traits! { + #[cfg(false)] + pub union U4 { + pub a: u32, + b: f32, + } + } + + s_no_extra_traits_with_default! { + #[cfg(false)] + pub union U5 { + pub a: u32, + b: f32, + } + + #[cfg(false)] + pub struct S6 { + pub a: u32, + } + } + + // The generated impls name the type and its fields, so they need to allow deprecation. + // `deny` turns the warning into an error if that ever stops being the case. + mod deprecated_checks { + #![deny(deprecated)] + + s_with_default! { + #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] + pub struct S7 { + pub a: u32, + } + } + + s_no_extra_traits! { + #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] + pub union U6 { + pub a: u32, + b: f32, + } + } + + s_no_extra_traits_with_default! { + #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] + pub union U7 { + pub a: u32, + b: f32, + } + } + } } diff --git a/src/new/apple/xnu/mach/i386/_structs.rs b/src/new/apple/xnu/mach/i386/_structs.rs index 15822f7710de8..2c4fecf178e72 100644 --- a/src/new/apple/xnu/mach/i386/_structs.rs +++ b/src/new/apple/xnu/mach/i386/_structs.rs @@ -86,7 +86,7 @@ s! { pub __fpu_xmm15: __darwin_xmm_reg, // FIXME(apple): 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], + __fpu_rsrv4: Padding<[u32; 24]>, pub __fpu_reserved1: c_int, } } diff --git a/src/new/apple/xnu/net/mod.rs b/src/new/apple/xnu/net/mod.rs index c2844db51cf88..967a0a07462cd 100644 --- a/src/new/apple/xnu/net/mod.rs +++ b/src/new/apple/xnu/net/mod.rs @@ -2,4 +2,5 @@ //! //! +#[cfg(target_os = "macos")] pub(crate) mod bpf; diff --git a/src/new/apple/xnu/netinet6/mod.rs b/src/new/apple/xnu/netinet6/mod.rs index 1592863f7314e..daebfb61bedf7 100644 --- a/src/new/apple/xnu/netinet6/mod.rs +++ b/src/new/apple/xnu/netinet6/mod.rs @@ -2,4 +2,5 @@ //! //! +#[cfg(target_os = "macos")] pub(crate) mod in6_var; diff --git a/src/new/emscripten/sched.rs b/src/new/emscripten/sched.rs index 3bf854ef33c29..fadadac2404b9 100644 --- a/src/new/emscripten/sched.rs +++ b/src/new/emscripten/sched.rs @@ -1,7 +1,7 @@ use crate::prelude::*; cfg_if! { - if #[cfg(musl_v1_2_3)] { + if #[cfg(musl_v1_2)] { s! { struct __c_anon_sched_param__reserved2 { __reserved1: crate::time_t, diff --git a/src/new/glibc/bits/signum_generic.rs b/src/new/glibc/bits/signum_generic.rs new file mode 100644 index 0000000000000..4dacf29dc6bc0 --- /dev/null +++ b/src/new/glibc/bits/signum_generic.rs @@ -0,0 +1,19 @@ +//! Header: `bits/signum-generic.h` + +use crate::prelude::*; + +pub const SIGINT: c_int = 2; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGSEGV: c_int = 11; +pub const SIGTERM: c_int = 15; + +pub const SIGHUP: c_int = 1; +pub const SIGQUIT: c_int = 3; +pub const SIGTRAP: c_int = 5; +pub const SIGKILL: c_int = 9; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; + +pub use super::super::sysdeps::unix::linux::bits::signum_arch::*; diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index 86dec42d6a784..15441a20852e7 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -6,6 +6,14 @@ //! This module structure is modeled after glibc's source tree. Its build system selects headers //! from different locations based on the platform, which we mimic here with reexports. +/// Source directory: `bits/` +/// +/// +mod bits { + #[cfg(target_os = "linux")] + pub(crate) mod signum_generic; +} + /// Source directory: `posix/` /// /// @@ -13,6 +21,17 @@ mod posix { pub(crate) mod unistd; } +#[cfg(target_os = "linux")] +pub(crate) mod signal; + +/// Source directory: `io/sys/` +/// +/// +pub(crate) mod sys { + #[cfg(target_os = "linux")] + pub(crate) mod statvfs; +} + /// Source directory: `sysdeps/` /// /// @@ -29,6 +48,7 @@ mod sysdeps { pub(crate) use posix::*; // FIXME(pthread): eventually all platforms should use this module #[cfg(target_os = "linux")] -pub(crate) use sysdeps::nptl::*; +#[allow(unused)] +pub(crate) use sysdeps::nptl::pthread; #[cfg(target_os = "linux")] -pub(crate) use sysdeps::unix::linux::*; +pub(crate) use sysdeps::unix::linux::net; diff --git a/src/new/glibc/signal.rs b/src/new/glibc/signal.rs new file mode 100644 index 0000000000000..f91997f45acbd --- /dev/null +++ b/src/new/glibc/signal.rs @@ -0,0 +1,10 @@ +//! Header: `signal/signal.h` + +pub use super::bits::signum_generic::*; +pub use super::sysdeps::unix::linux::bits::sigaction::*; +pub use super::sysdeps::unix::linux::bits::types::siginfo_t::*; +use crate::prelude::*; + +extern "C" { + pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) -> c_int; +} diff --git a/src/new/glibc/sys/statvfs.rs b/src/new/glibc/sys/statvfs.rs new file mode 100644 index 0000000000000..e1d7cf08e85d0 --- /dev/null +++ b/src/new/glibc/sys/statvfs.rs @@ -0,0 +1,15 @@ +//! Header: `io/sys/statvfs.h` + +pub use super::super::sysdeps::unix::linux::bits::statvfs::*; +use crate::prelude::*; + +extern "C" { + #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] + pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] + pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; +} diff --git a/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs new file mode 100644 index 0000000000000..86c54bcd2393d --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs @@ -0,0 +1,31 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/sigaction.h` + +use crate::prelude::*; + +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, + // This function should be unsafe everywhere but is currently only done on + // newer arches. + #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] + pub sa_restorer: Option, + #[cfg(not(any(target_arch = "riscv32", target_arch = "riscv64")))] + pub sa_restorer: Option, + } +} + +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 0x00000002; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); + +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const SIG_SETMASK: c_int = 2; diff --git a/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs b/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs new file mode 100644 index 0000000000000..40357358fce2d --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs @@ -0,0 +1,28 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/signum-arch.h` + +use crate::prelude::*; + +pub const SIGSTKFLT: c_int = 16; +pub const SIGPWR: c_int = 30; + +pub const SIGBUS: c_int = 7; +pub const SIGSYS: c_int = 31; + +pub const SIGURG: c_int = 23; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGCONT: c_int = 18; +pub const SIGCHLD: c_int = 17; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGPOLL: c_int = 29; +pub const SIGXFSZ: c_int = 25; +pub const SIGXCPU: c_int = 24; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; + +pub const SIGWINCH: c_int = 28; + +pub const SIGIO: c_int = SIGPOLL; diff --git a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs new file mode 100644 index 0000000000000..03fc1ac847278 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs @@ -0,0 +1,56 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/statvfs.h` + +use crate::prelude::*; + +s! { + 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, + // Mirrors `_STATVFSBUF_F_UNUSED` in the header. x32 is excluded because + // its `__SYSCALL_WORDSIZE` is 64, aarch64 because glibc always sets + // `__WORDSIZE` to 64. + #[cfg(all( + target_pointer_width = "32", + not(any(target_arch = "x86_64", target_arch = "aarch64")) + ))] + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub f_type: c_uint, + __f_spare: Padding<[c_int; 5]>, + } + + 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, + // FIXME(riscv32): glibc declares this field on riscv32 too, but we have + // never declared it here. + #[cfg(all( + target_pointer_width = "32", + not(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv32" + )) + ))] + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub f_type: c_uint, + __f_spare: Padding<[c_int; 5]>, + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs b/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs new file mode 100644 index 0000000000000..834a5cfede828 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs @@ -0,0 +1,5 @@ +//! Source directory: `sysdeps/unix/sysv/linux/bits/types` +//! +//! + +pub(crate) mod siginfo_t; diff --git a/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs b/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs new file mode 100644 index 0000000000000..bd112f102e2ae --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs @@ -0,0 +1,267 @@ +//! Source header: `sysdeps/unix/sysv/linux/bits/types/siginfo_t.h` +//! +//! Note this module corresponds with multiple header files upstream. The above +//! header file contains the generic definition, while other +//! architecture-specific definitions live upstream at +//! `sysdeps/unix/sysv/linux//bits/siginfo-arch.h`. Currently, the +//! following set of header files are contained in this one Rust module: +//! +//! - `sysdeps/unix/sysv/linux/bits/types/siginfo_t.h` +//! - `sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h` +//! - `sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h` +//! - `sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h` +//! +//! + +use crate::prelude::*; + +const __SI_MAX_SIZE: usize = 128; +const __SI_PAD_SIZE: usize = if cfg!(target_pointer_width = "64") { + __SI_MAX_SIZE / size_of::() - 4 +} else { + __SI_MAX_SIZE / size_of::() - 3 +}; + +cfg_if! { + if #[cfg(target_arch = "sparc64")] { + type __SI_BAND_TYPE = c_int; + } else { + type __SI_BAND_TYPE = c_long; + } +} + +#[repr(C)] +#[cfg_attr( + all(target_arch = "x86_64", target_pointer_width = "32"), + repr(align(4)) +)] +#[derive(Clone, Copy, Debug)] +struct __SI_CLOCK_T(crate::clock_t); + +s_no_extra_traits! { + #[cfg_attr( + all(target_arch = "x86_64", target_pointer_width = "32"), + repr(align(8)) + )] + pub struct siginfo_t { + pub si_signo: c_int, + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6" + ))] + pub si_code: c_int, + + pub si_errno: c_int, + + #[cfg(not(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6" + )))] + pub si_code: c_int, + + #[cfg(target_pointer_width = "64")] + __pad0: Padding, + _sifields: __c_anonymous_siginfo_t__si_fields, + } + + union __c_anonymous_siginfo_t__si_fields { + _pad: [c_int; __SI_PAD_SIZE], + _kill: __c_anonymous__si_fields__kill, + _timer: __c_anonymous__si_fields__timer, + _rt: __c_anonymous__si_fields__rt, + _sigchld: __c_anonymous__si_fields__sigchld, + _sigfault: __c_anonymous__si_fields__sigfault, + _sigpoll: __c_anonymous__si_fields__sigpoll, + _sigsys: __c_anonymous__si_fields__sigsys, + } + + struct __c_anonymous__si_fields__kill { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + } + + struct __c_anonymous__si_fields__timer { + si_tid: c_int, + si_overrun: c_int, + si_sigval: crate::sigval, + } + + struct __c_anonymous__si_fields__rt { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_sigval: crate::sigval, + } + + struct __c_anonymous__si_fields__sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: __SI_CLOCK_T, + si_stime: __SI_CLOCK_T, + } + + struct __c_anonymous__si_fields__sigfault { + si_addr: *mut c_void, + #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] + _si_trapno: c_int, + si_addr_lsb: c_short, + _bounds: __c_anonymous__sigfault__bounds, + } + + struct __c_anonymous__si_fields__sigpoll { + si_band: __SI_BAND_TYPE, + si_fd: c_int, + } + + struct __c_anonymous__si_fields__sigsys { + _call_addr: *mut c_void, + _syscall: c_int, + _arch: c_uint, + } + + union __c_anonymous__sigfault__bounds { + _addr_bnd: __c_anonymous__bounds__addr_bnd, + _pkey: u32, + } + + struct __c_anonymous__bounds__addr_bnd { + _lower: *mut c_void, + _upper: *mut c_void, + } +} + +impl siginfo_t { + #[inline] + pub const unsafe fn si_pid(&self) -> crate::pid_t { + unsafe { self._sifields._kill.si_pid } + } + + #[inline] + pub const unsafe fn si_uid(&self) -> crate::uid_t { + unsafe { self._sifields._kill.si_uid } + } + + #[inline] + pub const unsafe fn si_timerid(&self) -> c_int { + unsafe { self._sifields._timer.si_tid } + } + + #[inline] + pub const unsafe fn si_overrun(&self) -> c_int { + unsafe { self._sifields._timer.si_overrun } + } + + #[inline] + pub const unsafe fn si_status(&self) -> c_int { + unsafe { self._sifields._sigchld.si_status } + } + + #[inline] + pub const unsafe fn si_utime(&self) -> crate::clock_t { + unsafe { self._sifields._sigchld.si_utime.0 } + } + + #[inline] + pub const unsafe fn si_stime(&self) -> crate::clock_t { + unsafe { self._sifields._sigchld.si_stime.0 } + } + + #[inline] + pub const unsafe fn si_value(&self) -> crate::sigval { + unsafe { self._sifields._rt.si_sigval } + } + + #[inline] + pub unsafe fn si_int(&self) -> c_int { + // DIFF(main): sigval is a union on `main`, struct on `libc-0.2`. The cast means + // this can't be const at the MSRV. + unsafe { self._sifields._rt.si_sigval.sival_ptr as usize as c_int } + } + + #[inline] + pub const unsafe fn si_ptr(&self) -> *mut c_void { + unsafe { self._sifields._rt.si_sigval.sival_ptr } + } + + #[inline] + pub const unsafe fn si_addr(&self) -> *mut c_void { + unsafe { self._sifields._sigfault.si_addr } + } + + #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] + #[inline] + pub const unsafe fn si_trapno(&self) -> c_int { + unsafe { self._sifields._sigfault._si_trapno } + } + + #[inline] + pub const unsafe fn si_addr_lsb(&self) -> c_short { + unsafe { self._sifields._sigfault.si_addr_lsb } + } + + #[inline] + pub const unsafe fn si_lower(&self) -> *mut c_void { + unsafe { self._sifields._sigfault._bounds._addr_bnd._lower } + } + + #[inline] + pub const unsafe fn si_upper(&self) -> *mut c_void { + unsafe { self._sifields._sigfault._bounds._addr_bnd._upper } + } + + #[inline] + pub const unsafe fn si_pkey(&self) -> u32 { + unsafe { self._sifields._sigfault._bounds._pkey } + } + + #[inline] + pub const unsafe fn si_band(&self) -> __SI_BAND_TYPE { + unsafe { self._sifields._sigpoll.si_band } + } + + #[inline] + pub const unsafe fn si_fd(&self) -> c_int { + unsafe { self._sifields._sigpoll.si_fd } + } + + #[inline] + pub const unsafe fn si_call_addr(&self) -> *mut c_void { + unsafe { self._sifields._sigsys._call_addr } + } + + #[inline] + pub const unsafe fn si_syscall(&self) -> c_int { + unsafe { self._sifields._sigsys._syscall } + } + + #[inline] + pub const unsafe fn si_arch(&self) -> c_uint { + unsafe { self._sifields._sigsys._arch } + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for siginfo_t { + fn eq(&self, other: &Self) -> bool { + (self.si_signo, self.si_errno, self.si_code) + == (other.si_signo, other.si_errno, other.si_code) + } + } + + impl Eq for siginfo_t {} + + impl core::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_errno.hash(state); + self.si_code.hash(state); + } + } + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs new file mode 100644 index 0000000000000..344b386acf4b5 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs @@ -0,0 +1,29 @@ +//! Header: `sysdeps/unix/sysv/linux/mips/bits/sigaction.h` + +use crate::prelude::*; + +s! { + // + // 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, + #[cfg(target_pointer_width = "32")] + _resv: Padding<[c_int; 1]>, + } +} + +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 0x00010000; +pub const SA_SIGINFO: c_int = 0x00000008; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); + +pub const SIG_BLOCK: c_int = 0x1; +pub const SIG_UNBLOCK: c_int = 0x2; +pub const SIG_SETMASK: c_int = 3; diff --git a/src/new/glibc/sysdeps/unix/linux/mips/bits/signum_arch.rs b/src/new/glibc/sysdeps/unix/linux/mips/bits/signum_arch.rs new file mode 100644 index 0000000000000..9e4f492eab386 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/mips/bits/signum_arch.rs @@ -0,0 +1,28 @@ +//! Header: `sysdeps/unix/sysv/linux/mips/bits/signum-arch.h` + +use crate::prelude::*; + +pub const SIGEMT: c_int = 7; +pub const SIGPWR: c_int = 19; + +pub const SIGBUS: c_int = 10; +pub const SIGSYS: c_int = 12; + +pub const SIGURG: c_int = 21; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGCONT: c_int = 25; +pub const SIGCHLD: c_int = 18; +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGPOLL: c_int = 22; +pub const SIGXCPU: c_int = 30; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGXFSZ: c_int = 31; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; + +pub const SIGWINCH: c_int = 20; + +pub const SIGIO: c_int = SIGPOLL; diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs index 21dac17fc0b27..f3d704d63e55d 100644 --- a/src/new/glibc/sysdeps/unix/linux/mod.rs +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -2,6 +2,44 @@ //! //! +/// Directory: `sysdeps/unix/sysv/linux/bits` +pub(crate) mod bits { + #[cfg_attr( + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips", + target_arch = "mips32r6", + ), + path = "../mips/bits/sigaction.rs" + )] + #[cfg_attr(target_arch = "s390x", path = "../s390/bits/sigaction.rs")] + #[cfg_attr( + any(target_arch = "sparc", target_arch = "sparc64"), + path = "../sparc/bits/sigaction.rs" + )] + pub(crate) mod sigaction; + + #[cfg_attr( + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips", + target_arch = "mips32r6", + ), + path = "../mips/bits/signum_arch.rs" + )] + #[cfg_attr( + any(target_arch = "sparc", target_arch = "sparc64"), + path = "../sparc/bits/signum_arch.rs" + )] + pub(crate) mod signum_arch; + + pub(crate) mod statvfs; + + pub(crate) mod types; +} + /// Directory: `net/` /// /// Source directory: `sysdeps/unix/sysv/linux/net` diff --git a/src/new/glibc/sysdeps/unix/linux/s390/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/s390/bits/sigaction.rs new file mode 100644 index 0000000000000..9707ab3bfa562 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/s390/bits/sigaction.rs @@ -0,0 +1,27 @@ +//! Header: `sysdeps/unix/sysv/linux/s390/bits/sigaction.h` + +use crate::prelude::*; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + __glibc_reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + pub sa_mask: crate::sigset_t, + } +} + +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 2; +pub const SA_SIGINFO: c_int = 4; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); + +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const SIG_SETMASK: c_int = 2; diff --git a/src/new/glibc/sysdeps/unix/linux/sparc/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/sparc/bits/sigaction.rs new file mode 100644 index 0000000000000..9cdfd7efd024b --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/sparc/bits/sigaction.rs @@ -0,0 +1,28 @@ +//! Header: `sysdeps/unix/sysv/linux/sparc/bits/sigaction.h` + +use crate::prelude::*; + +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, + #[cfg(target_pointer_width = "64")] + __reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + } +} + +pub const SA_NOCLDSTOP: c_int = 0x00000008; +pub const SA_NOCLDWAIT: c_int = 0x100; +pub const SA_SIGINFO: c_int = 0x200; +pub const SA_ONSTACK: c_int = 1; +pub const SA_RESTART: c_int = 0x2; +pub const SA_NODEFER: c_int = 0x20; +pub const SA_RESETHAND: c_int = 0x4; + +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 4; diff --git a/src/new/glibc/sysdeps/unix/linux/sparc/bits/signum_arch.rs b/src/new/glibc/sysdeps/unix/linux/sparc/bits/signum_arch.rs new file mode 100644 index 0000000000000..0a946482fdac4 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/sparc/bits/signum_arch.rs @@ -0,0 +1,28 @@ +//! Header: `sysdeps/unix/sysv/linux/sparc/bits/signum-arch.h` + +use crate::prelude::*; + +pub const SIGEMT: c_int = 7; +pub const SIGPWR: c_int = 29; + +pub const SIGBUS: c_int = 10; +pub const SIGSYS: c_int = 12; + +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 SIGPOLL: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGXFSZ: c_int = 25; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; + +pub const SIGWINCH: c_int = 28; + +pub const SIGIO: c_int = SIGPOLL; diff --git a/src/new/helenos/abi/errno.rs b/src/new/helenos/abi/errno.rs new file mode 100644 index 0000000000000..040298a720359 --- /dev/null +++ b/src/new/helenos/abi/errno.rs @@ -0,0 +1,43 @@ +//! HelenOS errno codes +//! +//! * Header file: + +use crate::errno_t; + +pub const EOK: errno_t = 0; +pub const ENOENT: errno_t = 1; +pub const ENOMEM: errno_t = 2; +pub const ELIMIT: errno_t = 3; +pub const EREFUSED: errno_t = 4; +pub const EFORWARD: errno_t = 5; +pub const EPERM: errno_t = 6; +pub const EHANGUP: errno_t = 7; +pub const EPARTY: errno_t = 8; +pub const EEXIST: errno_t = 9; +pub const EBADMEM: errno_t = 10; +pub const ENOTSUP: errno_t = 11; +pub const EADDRNOTAVAIL: errno_t = 12; +pub const ETIMEOUT: errno_t = 13; +pub const EINVAL: errno_t = 14; +pub const EBUSY: errno_t = 15; +pub const EOVERFLOW: errno_t = 16; +pub const EINTR: errno_t = 17; +pub const EMFILE: errno_t = 18; +pub const ENAMETOOLONG: errno_t = 19; +pub const EISDIR: errno_t = 20; +pub const ENOTDIR: errno_t = 21; +pub const ENOSPC: errno_t = 22; +pub const ENOTEMPTY: errno_t = 23; +pub const EBADF: errno_t = 24; +pub const EDOM: errno_t = 25; +pub const ERANGE: errno_t = 26; +pub const EXDEV: errno_t = 27; +pub const EIO: errno_t = 28; +pub const EMLINK: errno_t = 29; +pub const ENXIO: errno_t = 30; +pub const ENOFS: errno_t = 31; +pub const EBADCHECKSUM: errno_t = 32; +pub const ESTALL: errno_t = 33; +pub const EEMPTY: errno_t = 34; +pub const ENAK: errno_t = 35; +pub const EAGAIN: errno_t = 36; diff --git a/src/new/helenos/bits.rs b/src/new/helenos/bits.rs new file mode 100644 index 0000000000000..bcb704d8cb038 --- /dev/null +++ b/src/new/helenos/bits.rs @@ -0,0 +1,9 @@ +//! HelenOS ABI bits +//! +//! * Headers: + +// `errno.h` +pub type errno_t = crate::c_int; + +// `native.h` +pub type sysarg_t = crate::uintptr_t; diff --git a/src/new/helenos/dirent_mod.rs b/src/new/helenos/dirent_mod.rs new file mode 100644 index 0000000000000..5fb426e78a404 --- /dev/null +++ b/src/new/helenos/dirent_mod.rs @@ -0,0 +1,25 @@ +//! HelenOS directory entry API +//! +//! * Header file: + +// The module is named to avoid name collision with the dirent struct, which causes issues with +// wildcard imports in the parent module. + +use crate::prelude::*; + +s! { + pub struct dirent { + pub d_name: [c_char; 256], + } +} + +extern_ty! { + pub type DIR; +} + +extern "C" { + pub fn opendir(name: *const c_char) -> *mut DIR; + pub fn readdir(dir: *mut DIR) -> *mut dirent; + pub fn closedir(dir: *mut DIR) -> c_int; + pub fn rewinddir(dir: *mut DIR); +} diff --git a/src/new/helenos/errno.rs b/src/new/helenos/errno.rs new file mode 100644 index 0000000000000..09b303fa5fa3e --- /dev/null +++ b/src/new/helenos/errno.rs @@ -0,0 +1,7 @@ +//! HelenOS errno handling +//! +//! * Header file: + +extern "C" { + pub fn __errno() -> *mut crate::errno_t; +} diff --git a/src/new/helenos/fibril.rs b/src/new/helenos/fibril.rs new file mode 100644 index 0000000000000..7027578e977c1 --- /dev/null +++ b/src/new/helenos/fibril.rs @@ -0,0 +1,33 @@ +//! HelenOS fibrils API +//! +//! * Header file: + +use crate::errno_t; +use crate::prelude::*; +pub use crate::time::*; + +pub type fid_t = *mut fibril_t; + +s! { + pub struct fibril_owner_info_t { + pub owned_by: *mut fibril_t, + } +} + +extern_ty! { + pub type fibril_t; +} + +extern "C" { + pub fn fibril_create_generic( + func: unsafe extern "C" fn(*mut c_void) -> errno_t, + arg: *mut c_void, + stacksize: size_t, + ) -> fid_t; + pub fn fibril_start(f: fid_t); + pub fn fibril_exit(retval: c_long) -> !; + pub fn fibril_detach(f: fid_t); + pub fn fibril_yield(); + pub fn fibril_usleep(usec: usec_t); + pub fn fibril_get_id() -> fid_t; +} diff --git a/src/new/helenos/fibril_synch.rs b/src/new/helenos/fibril_synch.rs new file mode 100644 index 0000000000000..2d58a862022e2 --- /dev/null +++ b/src/new/helenos/fibril_synch.rs @@ -0,0 +1,64 @@ +//! HelenOS fibril synchronization primitives +//! +//! * Header file: + +pub use crate::fibril::*; +use crate::prelude::*; +use crate::{ + errno_t, + list_initialize, + list_t, +}; + +s! { + pub struct fibril_mutex_t { + pub oi: fibril_owner_info_t, + pub counter: c_int, + pub waiters: list_t, + } + + pub struct fibril_rwlock_t { + pub oi: fibril_owner_info_t, + pub writers: c_uint, + pub readers: c_uint, + pub waiters: list_t, + } + + pub struct fibril_condvar_t { + pub waiters: list_t, + } +} + +f! { + pub safe fn fibril_mutex_initialize(fm: &mut fibril_mutex_t) -> () { + fm.oi.owned_by = ptr::null_mut(); + fm.counter = 1; + list_initialize(&mut fm.waiters); + } +} + +extern "C" { + pub fn fibril_mutex_lock(mutex: *mut fibril_mutex_t); + pub fn fibril_mutex_unlock(mutex: *mut fibril_mutex_t); + pub fn fibril_mutex_trylock(mutex: *mut fibril_mutex_t) -> bool; + pub fn fibril_mutex_is_locked(mutex: *mut fibril_mutex_t) -> bool; + + pub fn fibril_rwlock_initialize(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_read_lock(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_write_lock(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_read_unlock(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_write_unlock(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_is_read_locked(rwlock: *mut fibril_rwlock_t) -> bool; + pub fn fibril_rwlock_is_write_locked(rwlock: *mut fibril_rwlock_t) -> bool; + pub fn fibril_rwlock_is_locked(rwlock: *mut fibril_rwlock_t) -> bool; + + pub fn fibril_condvar_initialize(condvar: *mut fibril_condvar_t); + pub fn fibril_condvar_wait(condvar: *mut fibril_condvar_t, mutex: *mut fibril_mutex_t); + pub fn fibril_condvar_wait_timeout( + condvar: *mut fibril_condvar_t, + mutex: *mut fibril_mutex_t, + timeout: usec_t, + ) -> errno_t; + pub fn fibril_condvar_signal(condvar: *mut fibril_condvar_t); + pub fn fibril_condvar_broadcast(condvar: *mut fibril_condvar_t); +} diff --git a/src/new/helenos/inet/addr.rs b/src/new/helenos/inet/addr.rs new file mode 100644 index 0000000000000..3fab343546650 --- /dev/null +++ b/src/new/helenos/inet/addr.rs @@ -0,0 +1,26 @@ +//! HelenOS internet address types +//! +//! * Header file: + +pub type addr32_t = u32; +pub type addr128_t = [u8; 16]; + +c_enum! { + #[repr(u32)] + pub enum ip_ver_t { + pub ip_any, + pub ip_v4, + pub ip_v6, + } +} +s_no_extra_traits! { + pub union __inet_addr_t_addr_union { + pub addr: addr32_t, + pub addr6: addr128_t, + } + + pub struct inet_addr_t { + pub version: ip_ver_t, + pub addr: __inet_addr_t_addr_union, + } +} diff --git a/src/new/helenos/inet/dnsr.rs b/src/new/helenos/inet/dnsr.rs new file mode 100644 index 0000000000000..4389ace086fce --- /dev/null +++ b/src/new/helenos/inet/dnsr.rs @@ -0,0 +1,23 @@ +//! HelenOS DNS resolver API +//! +//! * Header file: + +use crate::errno_t; +pub use crate::inet::addr::*; +use crate::prelude::*; + +s_no_extra_traits! { + pub struct dnsr_hostinfo_t { + pub cname: *mut c_char, + pub addr: inet_addr_t, + } +} + +extern "C" { + pub fn dnsr_name2host( + name: *const c_char, + info: *mut *mut dnsr_hostinfo_t, + ipver: ip_ver_t, + ) -> errno_t; + pub fn dnsr_hostinfo_destroy(info: *mut dnsr_hostinfo_t); +} diff --git a/src/new/helenos/inet/endpoint.rs b/src/new/helenos/inet/endpoint.rs new file mode 100644 index 0000000000000..2f8fecc88309d --- /dev/null +++ b/src/new/helenos/inet/endpoint.rs @@ -0,0 +1,23 @@ +//! HelenOS internet endpoint types +//! +//! * Header file: + +pub use crate::inet::addr::*; +pub use crate::loc::*; + +s_no_extra_traits! { + pub struct inet_ep2_t { + pub local_link: service_id_t, + pub local: inet_ep_t, + pub remote: inet_ep_t, + } + + pub struct inet_ep_t { + pub addr: inet_addr_t, + pub port: u16, + } +} +extern "C" { + pub fn inet_ep_init(ep: *mut inet_ep_t); + pub fn inet_ep2_init(epp: *mut inet_ep2_t); +} diff --git a/src/new/helenos/inet/tcp.rs b/src/new/helenos/inet/tcp.rs new file mode 100644 index 0000000000000..59a901d5af2b6 --- /dev/null +++ b/src/new/helenos/inet/tcp.rs @@ -0,0 +1,74 @@ +//! HelenOS TCP API +//! +//! * Header file: + +use crate::errno_t; +pub use crate::inet::endpoint::*; +use crate::prelude::*; + +s_no_extra_traits! { + pub struct tcp_cb_t { + pub connected: Option, + pub conn_failed: Option, + pub conn_reset: Option, + pub data_avail: Option, + pub urg_data: Option, + } + pub struct tcp_listen_cb_t { + pub new_conn: + Option, + } +} + +extern_ty! { + pub type tcp_t; + pub type tcp_conn_t; + pub type tcp_listener_t; +} + +extern "C" { + pub fn tcp_create(tcp: *mut *mut tcp_t) -> errno_t; + pub fn tcp_destroy(tcp: *mut tcp_t); + + pub fn tcp_conn_create( + tcp: *mut tcp_t, + epp: *mut inet_ep2_t, + callbacks: *mut tcp_cb_t, + arg: *mut c_void, + conn: *mut *mut tcp_conn_t, + ) -> errno_t; + pub fn tcp_conn_destroy(conn: *mut tcp_conn_t); + + pub fn tcp_listener_create( + tcp: *mut tcp_t, + ep: *mut inet_ep_t, + listen_callbacks: *mut tcp_listen_cb_t, + listen_arg: *mut c_void, + conn_callbacks: *mut tcp_cb_t, + conn_arg: *mut c_void, + listener: *mut *mut tcp_listener_t, + ) -> errno_t; + pub fn tcp_listener_destroy(listener: *mut tcp_listener_t); + + pub fn tcp_conn_userptr(conn: *mut tcp_conn_t) -> *mut c_void; + pub fn tcp_listener_userptr(listener: *mut tcp_listener_t) -> *mut c_void; + + pub fn tcp_conn_wait_connected(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_send(conn: *mut tcp_conn_t, buf: *const c_void, len: size_t) -> errno_t; + pub fn tcp_conn_send_fin(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_push(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_reset(conn: *mut tcp_conn_t) -> errno_t; + + pub fn tcp_conn_recv( + conn: *mut tcp_conn_t, + buf: *mut c_void, + bufsize: size_t, + received_len: *mut size_t, + ) -> errno_t; + pub fn tcp_conn_recv_wait( + conn: *mut tcp_conn_t, + buf: *mut c_void, + bufsize: size_t, + received_len: *mut size_t, + ) -> errno_t; +} diff --git a/src/new/helenos/ipc/mod.rs b/src/new/helenos/ipc/mod.rs new file mode 100644 index 0000000000000..f7fa66ec789c3 --- /dev/null +++ b/src/new/helenos/ipc/mod.rs @@ -0,0 +1,12 @@ +//! HelenOS IPC types +//! +//! Headers: + +pub(crate) mod loc { + pub type service_id_t = crate::sysarg_t; +} + +pub(crate) mod vfs { + pub type fs_handle_t = i16; + pub type fs_index_t = u32; +} diff --git a/src/new/helenos/loc.rs b/src/new/helenos/loc.rs new file mode 100644 index 0000000000000..0cf367785713b --- /dev/null +++ b/src/new/helenos/loc.rs @@ -0,0 +1,5 @@ +//! HelenOS libc/loc +//! +//! * Header file: + +pub use crate::ipc::loc::*; diff --git a/src/new/helenos/mod.rs b/src/new/helenos/mod.rs new file mode 100644 index 0000000000000..3e19ea26f87fa --- /dev/null +++ b/src/new/helenos/mod.rs @@ -0,0 +1,29 @@ +//! HelenOS libraries +//! +//! * HelenOS source tree: (libraries are in uspace/lib, some bits are in abi and common) + +pub(crate) mod abi { + pub(crate) mod errno; +} +pub(crate) mod bits; +pub(crate) mod dirent_mod; +pub(crate) mod errno; +pub(crate) mod fibril; +pub(crate) mod fibril_synch; +pub(crate) mod inet { + pub(crate) mod addr; + pub(crate) mod dnsr; + pub(crate) mod endpoint; + pub(crate) mod tcp; +} +pub(crate) mod ipc; +pub(crate) mod loc; +pub(crate) mod offset; +pub(crate) mod stdio; +pub(crate) mod stdlib; +pub(crate) mod time; +pub(crate) mod vfs { + // The module layout mirrors the `vfs/vfs.h` header path. + #[allow(clippy::module_inception)] + pub(crate) mod vfs; +} diff --git a/src/new/helenos/offset.rs b/src/new/helenos/offset.rs new file mode 100644 index 0000000000000..131d3d72f09ca --- /dev/null +++ b/src/new/helenos/offset.rs @@ -0,0 +1,5 @@ +//! HelenOS libc offset types +//! +//! * Header file: + +pub type aoff64_t = u64; diff --git a/src/new/helenos/stdio.rs b/src/new/helenos/stdio.rs new file mode 100644 index 0000000000000..8cd785c09b490 --- /dev/null +++ b/src/new/helenos/stdio.rs @@ -0,0 +1,34 @@ +//! HelenOS libc standard I/O APIs +//! +//! * Header file: + +use crate::prelude::*; + +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; + +extern_ty! { + pub type FILE; +} + +extern "C" { + pub static stdin: *mut FILE; + pub static stdout: *mut FILE; + pub static stderr: *mut FILE; + + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn fclose(stream: *mut FILE) -> c_int; + pub fn fflush(stream: *mut FILE) -> c_int; + + pub fn fread(buf: *mut c_void, size: size_t, nmemb: size_t, stream: *mut FILE) -> size_t; + pub fn fwrite(buf: *const c_void, size: size_t, nmemb: size_t, stream: *mut FILE) -> size_t; + + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + + pub fn fileno(stream: *mut FILE) -> c_int; +} diff --git a/src/new/helenos/stdlib.rs b/src/new/helenos/stdlib.rs new file mode 100644 index 0000000000000..1f92a3de4fa55 --- /dev/null +++ b/src/new/helenos/stdlib.rs @@ -0,0 +1,18 @@ +use crate::prelude::*; + +extern "C" { + pub fn malloc(size: usize) -> *mut c_void; + pub fn calloc(nmemb: usize, size: usize) -> *mut c_void; + pub fn realloc(addr: *mut c_void, size: usize) -> *mut c_void; + pub fn free(addr: *mut c_void); + + pub fn memalign(align: usize, size: usize) -> *mut c_void; + + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn exit(code: c_int) -> !; + pub fn abort() -> !; + + pub fn getenv(env: *const c_char) -> *mut c_char; +} diff --git a/src/new/helenos/time.rs b/src/new/helenos/time.rs new file mode 100644 index 0000000000000..0175af24c0061 --- /dev/null +++ b/src/new/helenos/time.rs @@ -0,0 +1,19 @@ +//! HelenOS time handling +//! +//! * Header file: + +use crate::prelude::*; + +pub type time_t = c_longlong; +pub type usec_t = c_longlong; + +s_with_default! { + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } +} + +extern "C" { + pub fn getuptime(tp: *mut timespec); +} diff --git a/src/new/helenos/vfs/vfs.rs b/src/new/helenos/vfs/vfs.rs new file mode 100644 index 0000000000000..df296b4e7cd99 --- /dev/null +++ b/src/new/helenos/vfs/vfs.rs @@ -0,0 +1,43 @@ +//! HelenOS libc virtual file system APIs +//! +//! * Header file: + +use crate::errno_t; +pub use crate::ipc::loc::*; +pub use crate::ipc::vfs::*; +pub use crate::offset::*; +use crate::prelude::*; +pub use crate::stdio::*; + +s! { + pub struct vfs_stat_t { + pub fs_handle: fs_handle_t, + pub service_id: service_id_t, + pub index: fs_index_t, + pub lnkcnt: c_uint, + pub is_file: bool, + pub is_directory: bool, + pub size: aoff64_t, + pub service: service_id_t, + } +} + +c_enum! { + pub enum vfs_file_kind_t { + pub KIND_FILE, + pub KIND_DIRECTORY, + } +} + +extern "C" { + pub fn vfs_fhandle(file: *mut FILE, handle: *mut c_int) -> errno_t; + pub fn vfs_stat(handle: c_int, stat: *mut vfs_stat_t) -> errno_t; + pub fn vfs_link_path( + path: *const c_char, + kind: vfs_file_kind_t, + linkedfd: *mut c_int, + ) -> errno_t; + pub fn vfs_unlink_path(path: *const c_char) -> errno_t; + pub fn vfs_rename_path(oldpath: *const c_char, newpath: *const c_char) -> errno_t; + pub fn vfs_stat_path(path: *const c_char, stat: *mut vfs_stat_t) -> errno_t; +} diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index d50523c12e82d..989e854c45270 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -44,7 +44,7 @@ s_with_default! { // FIXME(1.0): this field was renamed to `len` in Linux 5.11 pub can_dlc: u8, __pad: Padding, - __res0: u8, + __res0: Padding, pub len8_dlc: u8, pub data: [u8; CAN_MAX_DLEN], } @@ -60,8 +60,8 @@ s_with_default! { pub can_id: canid_t, pub len: u8, pub flags: u8, - __res0: u8, - __res1: u8, + __res0: Padding, + __res1: Padding, #[custom_default([0; CANFD_MAX_DLEN])] pub data: [u8; CANFD_MAX_DLEN], } diff --git a/src/new/mod.rs b/src/new/mod.rs index 13479209d23c9..8f12b20afa993 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -72,6 +72,9 @@ cfg_if! { } else if #[cfg(target_os = "haiku")] { mod haiku; pub(crate) use haiku::*; + } else if #[cfg(target_os = "helenos")] { + mod helenos; + pub(crate) use helenos::*; } else if #[cfg(target_os = "hermit")] { mod hermit_abi; // pub(crate) use hermit_abi::*; @@ -194,11 +197,20 @@ cfg_if! { pub use linux::sctp::*; pub use linux::tls::*; pub use linux::types::*; + #[cfg(target_env = "uclibc")] + pub use sysdeps::linux::common::bits::siginfo::*; + #[cfg(target_env = "gnu")] - pub use net::route::*; + pub use self::{ + net::route::*, + signal::*, + sys::statvfs::*, + }; } else if #[cfg(target_vendor = "apple")] { + #[cfg(target_os = "macos")] pub use net::bpf::*; pub use netinet::tcp::*; + #[cfg(target_os = "macos")] pub use netinet6::in6_var::*; pub use pthread_::introspection::*; pub use pthread_::pthread_spis::*; @@ -223,6 +235,7 @@ cfg_if! { pub use utmpx_::*; } else if #[cfg(target_os = "openbsd")] { pub use sys::ipc::*; + pub use sys::sysctl::*; } else if #[cfg(any(target_os = "nto", target_os = "qnx"))] { pub use net::bpf::*; pub use net::if_::*; @@ -235,12 +248,23 @@ cfg_if! { pub use sys::file::*; pub use sys::ioccom::*; pub use sys::socket::*; + } else if #[cfg(target_os = "helenos")] { + pub use abi::errno::*; + pub use bits::*; + pub use dirent_mod::*; + pub use errno::*; + pub use fibril_synch::*; + pub use inet::dnsr::*; + pub use inet::tcp::*; + pub use stdlib::*; + pub use vfs::vfs::*; } } // Per-env headers we export cfg_if! { if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + pub use signal::*; pub use sys::socket::*; } } diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs index 9edb38255422b..e85523b3f88ef 100644 --- a/src/new/musl/mod.rs +++ b/src/new/musl/mod.rs @@ -31,4 +31,5 @@ pub(crate) mod sys { } pub(crate) mod sched; +pub(crate) mod signal; pub(crate) mod unistd; diff --git a/src/new/musl/sched.rs b/src/new/musl/sched.rs index 3bf854ef33c29..fadadac2404b9 100644 --- a/src/new/musl/sched.rs +++ b/src/new/musl/sched.rs @@ -1,7 +1,7 @@ use crate::prelude::*; cfg_if! { - if #[cfg(musl_v1_2_3)] { + if #[cfg(musl_v1_2)] { s! { struct __c_anon_sched_param__reserved2 { __reserved1: crate::time_t, diff --git a/src/new/musl/signal.rs b/src/new/musl/signal.rs new file mode 100644 index 0000000000000..3fa4fab66eb11 --- /dev/null +++ b/src/new/musl/signal.rs @@ -0,0 +1,226 @@ +//! Header source: `include/signal.h` +//! +//! * Headers: (official) +//! * Headers: (mirror) + +use crate::prelude::*; + +s_no_extra_traits! { + // `mips*` targets swap the `s_errno` and `s_code` fields otherwise this + // struct is target-agnostic (see + // ) + pub struct siginfo_t { + pub si_signo: c_int, + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6" + ))] + pub si_code: c_int, + + pub si_errno: c_int, + + #[cfg(not(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6" + )))] + pub si_code: c_int, + + __si_fields: __c_anonymous_siginfo_t___si_fields, + } + + union __c_anonymous_siginfo_t___si_fields { + __pad: [c_char; 128 - 2 * size_of::() - size_of::()], + __si_common: __c_anonymous___si_fields___si_common, + __sigfault: __c_anonymous___si_fields___sigfault, + __sigpoll: __c_anonymous___si_fields___sigpoll, + __sigsys: __c_anonymous___si_fields___sigsys, + } + + struct __c_anonymous___si_fields___si_common { + __first: __c_anonymous___si_common___first, + __second: __c_anonymous___si_common___second, + } + + struct __c_anonymous___si_fields___sigfault { + si_addr: *mut c_void, + si_addr_lsb: c_short, + __first: __c_anonymous___sigfault___first, + } + + struct __c_anonymous___si_fields___sigpoll { + si_band: c_long, + si_fd: c_int, + } + + struct __c_anonymous___si_fields___sigsys { + si_call_addr: *mut c_void, + si_syscall: c_int, + si_arch: c_uint, + } + + struct __c_anonymous___si_common___first { + __piduid: __c_anonymous___first___piduid, + __timer: __c_anonymous___first___timer, + } + + struct __c_anonymous___si_common___second { + si_value: crate::sigval, + __sigchld: __c_anonymous___second___sigchld, + } + + struct __c_anonymous___sigfault___first { + __addr_band: __c_anonymous___first___addr_band, + si_pkey: c_uint, + } + + struct __c_anonymous___first___piduid { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + } + + struct __c_anonymous___first___timer { + si_timerid: c_int, + si_overrun: c_int, + } + + struct __c_anonymous___second___sigchld { + si_status: c_int, + si_utime: crate::clock_t, + si_stime: crate::clock_t, + } + + struct __c_anonymous___first___addr_band { + si_lower: *mut c_void, + si_upper: *mut c_void, + } +} + +impl siginfo_t { + #[inline] + pub const unsafe fn si_pid(&self) -> crate::pid_t { + unsafe { self.__si_fields.__si_common.__first.__piduid.si_pid } + } + + #[inline] + pub const unsafe fn si_uid(&self) -> crate::uid_t { + unsafe { self.__si_fields.__si_common.__first.__piduid.si_uid } + } + + #[inline] + pub const unsafe fn si_status(&self) -> c_int { + unsafe { self.__si_fields.__si_common.__second.__sigchld.si_status } + } + + #[inline] + pub const unsafe fn si_utime(&self) -> crate::clock_t { + unsafe { self.__si_fields.__si_common.__second.__sigchld.si_utime } + } + + #[inline] + pub const unsafe fn si_stime(&self) -> crate::clock_t { + unsafe { self.__si_fields.__si_common.__second.__sigchld.si_stime } + } + + #[inline] + pub const unsafe fn si_value(&self) -> crate::sigval { + unsafe { self.__si_fields.__si_common.__second.si_value } + } + + #[inline] + pub const unsafe fn si_addr(&self) -> *mut c_void { + unsafe { self.__si_fields.__sigfault.si_addr } + } + + #[inline] + pub const unsafe fn si_addr_lsb(&self) -> c_short { + unsafe { self.__si_fields.__sigfault.si_addr_lsb } + } + + #[inline] + pub const unsafe fn si_lower(&self) -> *mut c_void { + unsafe { self.__si_fields.__sigfault.__first.__addr_band.si_lower } + } + + #[inline] + pub const unsafe fn si_upper(&self) -> *mut c_void { + unsafe { self.__si_fields.__sigfault.__first.__addr_band.si_upper } + } + + #[inline] + pub const unsafe fn si_pkey(&self) -> c_uint { + unsafe { self.__si_fields.__sigfault.__first.si_pkey } + } + + #[inline] + pub const unsafe fn si_band(&self) -> c_long { + unsafe { self.__si_fields.__sigpoll.si_band } + } + + #[inline] + pub const unsafe fn si_fd(&self) -> c_int { + unsafe { self.__si_fields.__sigpoll.si_fd } + } + + #[inline] + pub const unsafe fn si_timerid(&self) -> c_int { + unsafe { self.__si_fields.__si_common.__first.__timer.si_timerid } + } + + #[inline] + pub const unsafe fn si_overrun(&self) -> c_int { + unsafe { self.__si_fields.__si_common.__first.__timer.si_overrun } + } + + #[inline] + pub const unsafe fn si_ptr(&self) -> *mut c_void { + unsafe { self.__si_fields.__si_common.__second.si_value.sival_ptr } + } + + #[inline] + pub unsafe fn si_int(&self) -> c_int { + // DIFF(main): sigval is a union on `main`, struct on `libc-0.2`. The cast means + // this can't be const at the MSRV. + unsafe { self.__si_fields.__si_common.__second.si_value.sival_ptr as usize as c_int } + } + + #[inline] + pub const unsafe fn si_call_addr(&self) -> *mut c_void { + unsafe { self.__si_fields.__sigsys.si_call_addr } + } + + #[inline] + pub const unsafe fn si_syscall(&self) -> c_int { + unsafe { self.__si_fields.__sigsys.si_syscall } + } + + #[inline] + pub const unsafe fn si_arch(&self) -> c_uint { + unsafe { self.__si_fields.__sigsys.si_arch } + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for siginfo_t { + fn eq(&self, other: &Self) -> bool { + (self.si_signo, self.si_errno, self.si_code) + == (other.si_signo, other.si_errno, other.si_code) + } + } + + impl Eq for siginfo_t {} + + impl core::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_errno.hash(state); + self.si_code.hash(state); + } + } + } +} diff --git a/src/new/netbsd/sys/statvfs.rs b/src/new/netbsd/sys/statvfs.rs index eee3766300ce6..2e8fe5e202164 100644 --- a/src/new/netbsd/sys/statvfs.rs +++ b/src/new/netbsd/sys/statvfs.rs @@ -36,7 +36,7 @@ s! { pub f_owner: crate::uid_t, // This type is updated in a future version - f_spare: [u32; 4], + f_spare: Padding<[u32; 4]>, pub f_fstypename: [c_char; _VFS_NAMELEN], pub f_mntonname: [c_char; _VFS_MNAMELEN], diff --git a/src/new/nto/net/if_.rs b/src/new/nto/net/if_.rs index d71c1bb24b32e..93789ec95aa06 100644 --- a/src/new/nto/net/if_.rs +++ b/src/new/nto/net/if_.rs @@ -1,5 +1,31 @@ use crate::prelude::*; +// `s_no_extra_traits` produces an `impl` block so the `#[cfg]` attribute needs +// to go *outside* the macro +#[cfg(target_os = "nto")] +s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_space: crate::sockaddr_storage, + pub ifru_flags: c_short, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_dlt: c_int, + pub ifru_value: c_uint, + pub ifru_data: *mut c_char, + pub ifru_b: __c_anonymous_ifru_b, + pub ifru_fibmask: c_int, + } + + pub struct __c_anonymous_ifru_b { + pub b_buflen: u32, + pub b_buf: *mut c_void, + } +} + +#[cfg(target_os = "qnx")] s_no_extra_traits! { pub union __c_anonymous_ifr_ifru { pub ifru_addr: crate::sockaddr, @@ -17,16 +43,25 @@ s_no_extra_traits! { pub ifru_cap: [c_int; 2], pub ifru_fib: c_uint, pub ifru_vlan_pcp: c_uchar, + pub ifru_nv: ifreq_nv_req, + } + + pub struct ifreq_buffer { + pub length: size_t, + pub buffer: *mut c_void, + } + + pub struct ifreq_nv_req { + pub buf_length: c_uint, + pub length: c_uint, + pub buffer: *mut c_void, } +} +s_no_extra_traits! { pub struct ifreq { /// if name, e.g. "en0" pub ifr_name: [c_char; crate::IFNAMSIZ], pub ifr_ifru: __c_anonymous_ifr_ifru, } - - pub struct ifreq_buffer { - pub length: size_t, - pub buffer: *mut c_void, - } } diff --git a/src/new/openbsd/sys/mod.rs b/src/new/openbsd/sys/mod.rs index d72038e438781..94d4e8db38a29 100644 --- a/src/new/openbsd/sys/mod.rs +++ b/src/new/openbsd/sys/mod.rs @@ -3,3 +3,4 @@ //! pub(crate) mod ipc; +pub(crate) mod sysctl; diff --git a/src/new/openbsd/sys/sysctl.rs b/src/new/openbsd/sys/sysctl.rs new file mode 100644 index 0000000000000..f52fc26a2016a --- /dev/null +++ b/src/new/openbsd/sys/sysctl.rs @@ -0,0 +1,35 @@ +//! Header: `sys/sysctl.h` +//! +//! + +use crate::prelude::*; + +pub const HW_MACHINE: c_int = 1; +pub const HW_MODEL: c_int = 2; +pub const HW_BYTEORDER: c_int = 4; +pub const HW_PHYSMEM: c_int = 5; +pub const HW_USERMEM: c_int = 6; +pub const HW_PAGESIZE: c_int = 7; +pub const HW_DISKNAMES: c_int = 8; +pub const HW_DISKSTATS: c_int = 9; +pub const HW_DISKCOUNT: c_int = 10; +pub const HW_SENSORS: c_int = 11; +pub const HW_CPUSPEED: c_int = 12; +pub const HW_SETPERF: c_int = 13; +pub const HW_VENDOR: c_int = 14; +pub const HW_PRODUCT: c_int = 15; +pub const HW_VERSION: c_int = 16; +pub const HW_SERIALNO: c_int = 17; +pub const HW_UUID: c_int = 18; +pub const HW_PHYSMEM64: c_int = 19; +pub const HW_USERMEM64: c_int = 20; +pub const HW_NCPUFOUND: c_int = 21; +pub const HW_PERFPOLICY: c_int = 23; +pub const HW_NCPUONLINE: c_int = 25; +pub const HW_POWER: c_int = 26; +pub const HW_BATTERY: c_int = 27; +pub const HW_UCOMNAMES: c_int = 28; + +pub const HW_BATTERY_CHARGEMODE: c_int = 1; +pub const HW_BATTERY_CHARGESTART: c_int = 2; +pub const HW_BATTERY_CHARGESTOP: c_int = 3; diff --git a/src/new/qurt/limits.rs b/src/new/qurt/limits.rs index 8bf772cebd17d..f94da1a8a5cbd 100644 --- a/src/new/qurt/limits.rs +++ b/src/new/qurt/limits.rs @@ -5,24 +5,38 @@ use crate::prelude::*; // Character properties pub const CHAR_BIT: c_uint = 8; -pub const CHAR_MAX: c_char = 255; // unsigned char on Hexagon -pub const CHAR_MIN: c_char = 0; -pub const SCHAR_MAX: i8 = 127; -pub const SCHAR_MIN: i8 = -128; -pub const UCHAR_MAX: c_uchar = 255; +#[deprecated(since = "0.2.190", note = "Use `c_char::MAX` instead.")] +pub const CHAR_MAX: c_char = c_char::MAX; // unsigned char on Hexagon +#[deprecated(since = "0.2.190", note = "Use `c_char::MIN` instead.")] +pub const CHAR_MIN: c_char = c_char::MIN; +#[deprecated(since = "0.2.190", note = "Use `i8::MAX` instead.")] +pub const SCHAR_MAX: i8 = i8::MAX; +#[deprecated(since = "0.2.190", note = "Use `i8::MIN` instead.")] +pub const SCHAR_MIN: i8 = i8::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_uchar::MAX` instead.")] +pub const UCHAR_MAX: c_uchar = c_uchar::MAX; // Integer properties -pub const INT_MAX: c_int = 2147483647; -pub const INT_MIN: c_int = -2147483647 - 1; -pub const UINT_MAX: c_uint = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_uint::MAX` instead.")] +pub const UINT_MAX: c_uint = c_uint::MAX; -pub const LONG_MAX: c_long = 2147483647; -pub const LONG_MIN: c_long = -2147483647 - 1; -pub const ULONG_MAX: c_ulong = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `c_long::MAX` instead.")] +pub const LONG_MAX: c_long = c_long::MAX; +#[deprecated(since = "0.2.190", note = "Use `c_long::MIN` instead.")] +pub const LONG_MIN: c_long = c_long::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_ulong::MAX` instead.")] +pub const ULONG_MAX: c_ulong = c_ulong::MAX; -pub const SHRT_MAX: c_short = 32767; -pub const SHRT_MIN: c_short = -32768; -pub const USHRT_MAX: c_ushort = 65535; +#[deprecated(since = "0.2.190", note = "Use `c_short::MAX` instead.")] +pub const SHRT_MAX: c_short = c_short::MAX; +#[deprecated(since = "0.2.190", note = "Use `c_short::MIN` instead.")] +pub const SHRT_MIN: c_short = c_short::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_ushort::MAX` instead.")] +pub const USHRT_MAX: c_ushort = c_ushort::MAX; // POSIX Limits pub const ARG_MAX: c_int = 4096; diff --git a/src/new/uclibc/mod.rs b/src/new/uclibc/mod.rs index 6bf83ef2e1d38..6f99b4e95c0cb 100644 --- a/src/new/uclibc/mod.rs +++ b/src/new/uclibc/mod.rs @@ -4,4 +4,14 @@ //! * Headers: (mirror) pub(crate) mod pthread; + +/// Directory source: `libc/sysdeps` +/// +/// * Headers: (official) +/// * Headers: (mirror) +pub(crate) mod sysdeps { + #[cfg(target_os = "linux")] + pub(crate) mod linux; +} + pub(crate) mod unistd; diff --git a/src/new/uclibc/sysdeps/linux/common/bits/mod.rs b/src/new/uclibc/sysdeps/linux/common/bits/mod.rs new file mode 100644 index 0000000000000..bdb8c91ddc9c2 --- /dev/null +++ b/src/new/uclibc/sysdeps/linux/common/bits/mod.rs @@ -0,0 +1,6 @@ +//! Directory source: `libc/sysdeps/linux/common/bits` +//! +//! * Headers: (official) +//! * Headers: (mirror) + +pub(crate) mod siginfo; diff --git a/src/new/uclibc/sysdeps/linux/common/bits/siginfo.rs b/src/new/uclibc/sysdeps/linux/common/bits/siginfo.rs new file mode 100644 index 0000000000000..68102af02ad9d --- /dev/null +++ b/src/new/uclibc/sysdeps/linux/common/bits/siginfo.rs @@ -0,0 +1,229 @@ +//! Header source: `libc/sysdeps/linux/common/bits/siginfo.h` +//! +//! Note this header file unifies all header files in upstream uClibc-ng for +//! both the generic definition and the architecture-specific definitions. +//! Currently, this Rust module has the definitions for the following set of +//! header files: +//! +//! - `libc/sysdeps/linux/common/bits/siginfo.h` +//! - `libc/sysdeps/linux/mips/bits/siginfo.h` +//! +//! * Headers: (official) +//! * Headers: (mirror) + +use crate::prelude::*; + +const __SI_MAX_SIZE: usize = 128; +const __SI_PAD_SIZE: usize = if cfg!(target_pointer_width = "64") { + __SI_MAX_SIZE / size_of::() - 4 +} else { + __SI_MAX_SIZE / size_of::() - 3 +}; + +s_no_extra_traits! { + pub struct siginfo_t { + pub si_signo: c_int, + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + ))] + pub si_code: c_int, + + pub si_errno: c_int, + + #[cfg(not(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + )))] + pub si_code: c_int, + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + ))] + __pad0: Padding<[c_int; __SI_MAX_SIZE / size_of::() - __SI_PAD_SIZE - 3]>, + + _sifields: __c_anonymous_siginfo_t__si_fields, + } + + union __c_anonymous_siginfo_t__si_fields { + _pad: Padding<[c_int; __SI_PAD_SIZE]>, + _kill: __c_anonymous__si_fields__kill, + _timer: __c_anonymous__si_fields__timer, + _rt: __c_anonymous__si_fields__rt, + _sigchld: __c_anonymous__si_fields__sigchld, + _sigfault: __c_anonymous__si_fields__sigfault, + _sigpoll: __c_anonymous__si_fields__sigpoll, + _sigsys: __c_anonymous__si_fields__sigsys, + } + + struct __c_anonymous__si_fields__kill { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + } + + struct __c_anonymous__si_fields__timer { + si_tid: c_int, + si_overrun: c_int, + si_sigval: crate::sigval, + } + + struct __c_anonymous__si_fields__rt { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_sigval: crate::sigval, + } + + struct __c_anonymous__si_fields__sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: crate::clock_t, + si_stime: crate::clock_t, + } + + struct __c_anonymous__si_fields__sigfault { + si_addr: *mut c_void, + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + ))] + si_addr_lsb: c_short, + } + + struct __c_anonymous__si_fields__sigpoll { + si_band: c_long, + si_fd: c_int, + } + + struct __c_anonymous__si_fields__sigsys { + _call_addr: *mut c_void, + _syscall: c_int, + _arch: c_uint, + } +} + +impl siginfo_t { + #[inline] + pub const unsafe fn si_pid(&self) -> crate::pid_t { + unsafe { self._sifields._kill.si_pid } + } + + #[inline] + pub const unsafe fn si_uid(&self) -> crate::uid_t { + unsafe { self._sifields._kill.si_uid } + } + + #[inline] + pub const unsafe fn si_timerid(&self) -> c_int { + unsafe { self._sifields._timer.si_tid } + } + + #[inline] + pub const unsafe fn si_overrun(&self) -> c_int { + unsafe { self._sifields._timer.si_overrun } + } + + #[inline] + pub const unsafe fn si_status(&self) -> c_int { + unsafe { self._sifields._sigchld.si_status } + } + + #[inline] + pub const unsafe fn si_utime(&self) -> crate::clock_t { + unsafe { self._sifields._sigchld.si_utime } + } + + #[inline] + pub const unsafe fn si_stime(&self) -> crate::clock_t { + unsafe { self._sifields._sigchld.si_stime } + } + + #[inline] + pub const unsafe fn si_value(&self) -> crate::sigval { + unsafe { self._sifields._rt.si_sigval } + } + + #[inline] + pub unsafe fn si_int(&self) -> c_int { + // DIFF(main): sigval is a union on `main`, struct on `libc-0.2`. The cast means + // this can't be const at the MSRV. + unsafe { self._sifields._rt.si_sigval.sival_ptr as usize as c_int } + } + + #[inline] + pub const unsafe fn si_ptr(&self) -> *mut c_void { + unsafe { self._sifields._rt.si_sigval.sival_ptr } + } + + #[inline] + pub const unsafe fn si_addr(&self) -> *mut c_void { + unsafe { self._sifields._sigfault.si_addr } + } + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + ))] + #[inline] + pub const unsafe fn si_addr_lsb(&self) -> c_short { + unsafe { self._sifields._sigfault.si_addr_lsb } + } + + #[inline] + pub const unsafe fn si_band(&self) -> c_long { + unsafe { self._sifields._sigpoll.si_band } + } + + #[inline] + pub const unsafe fn si_fd(&self) -> c_int { + unsafe { self._sifields._sigpoll.si_fd } + } + + #[inline] + pub const unsafe fn si_call_addr(&self) -> *mut c_void { + unsafe { self._sifields._sigsys._call_addr } + } + + #[inline] + pub const unsafe fn si_syscall(&self) -> c_int { + unsafe { self._sifields._sigsys._syscall } + } + + #[inline] + pub const unsafe fn si_arch(&self) -> c_uint { + unsafe { self._sifields._sigsys._arch } + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for siginfo_t { + fn eq(&self, other: &Self) -> bool { + (self.si_signo, self.si_code, self.si_errno) + == (other.si_signo, other.si_code, other.si_errno) + } + } + + impl Eq for siginfo_t {} + + impl core::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_code.hash(state); + self.si_errno.hash(state); + } + } + } +} diff --git a/src/new/uclibc/sysdeps/linux/mod.rs b/src/new/uclibc/sysdeps/linux/mod.rs new file mode 100644 index 0000000000000..130b2f927d254 --- /dev/null +++ b/src/new/uclibc/sysdeps/linux/mod.rs @@ -0,0 +1,12 @@ +//! Directory source: `libc/sysdeps/linux` +//! +//! * Headers: (official) +//! * Headers: (mirror) + +/// Directory source: `libc/sysdeps/linux/common` +/// +/// * Headers: (official) +/// * Headers: (mirror) +pub(crate) mod common { + pub(crate) mod bits; +} diff --git a/src/sgx.rs b/src/sgx.rs index 9cf9c6d3b41b8..6f891fce16748 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -11,5 +11,7 @@ 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; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX; diff --git a/src/solid/mod.rs b/src/solid/mod.rs index d14dcf88d270f..7184ccf05719c 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -176,8 +176,10 @@ s! { } } -pub const INT_MIN: c_int = -2147483648; -pub const INT_MAX: c_int = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX; pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; diff --git a/src/switch.rs b/src/switch.rs index 2d202dd61fc5d..1d2d724bd91e4 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -13,5 +13,7 @@ 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; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX; diff --git a/src/types.rs b/src/types.rs index 7be6e78bce3fe..02bb2d33ce890 100644 --- a/src/types.rs +++ b/src/types.rs @@ -117,8 +117,10 @@ pub(crate) const fn u32_cast_ioctl(x: u32) -> crate::Ioctl { #[allow(unused)] pub(crate) const fn u8_slice_cast_char_slice(x: &[u8]) -> &[c_char] { assert!(size_of::() == size_of::()); + let len = x.len(); + let ptr = x.as_ptr(); // SAFETY: same repr, possibly just a sign cast - unsafe { mem::transmute::<&[u8], &[c_char]>(x) } + unsafe { core::slice::from_raw_parts(ptr.cast::(), len) } } /// Replace bytes in an array with those from a slice. This is a polyfill for `[T]::copy_from_slice` diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index a7c2d6e275502..a0e86fada7a64 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -10,6 +10,7 @@ pub type blkcnt_t = c_long; pub type clock_t = c_int; pub type daddr_t = c_long; pub type dev_t = c_ulong; +// FIXME(1.0,deprecate): lfs binding to be removed pub type fpos64_t = c_longlong; pub type fsblkcnt_t = c_ulong; pub type fsfilcnt_t = c_ulong; @@ -21,6 +22,7 @@ pub type rlim_t = c_ulong; pub type speed_t = c_uint; pub type tcflag_t = c_uint; pub type time_t = c_long; +// FIXME(1.0,deprecate): lfs binding to be removed pub type time64_t = i64; pub type timer_t = c_long; pub type wchar_t = c_uint; @@ -33,6 +35,7 @@ pub type suseconds_t = c_int; pub type useconds_t = c_uint; pub type off_t = c_long; pub type offset_t = c_longlong; +// FIXME(1.0,deprecate): lfs binding to be removed pub type off64_t = c_longlong; pub type idtype_t = c_uint; @@ -48,6 +51,7 @@ pub type nl_item = c_int; pub type mqd_t = c_int; pub type shmatt_t = c_ulong; pub type regoff_t = c_long; +// FIXME(1.0,deprecate): lfs binding to be removed pub type rlim64_t = c_ulonglong; pub type sem_t = c_int; @@ -113,6 +117,7 @@ s! { pub c_cc: [crate::cc_t; crate::NCCS], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct flock64 { pub l_type: c_short, pub l_whence: c_short, @@ -133,6 +138,7 @@ s! { pub msg_flags: c_int, } + // FIXME(1.0,deprecate,32): lfs binding to be removed. pub struct statvfs64 { pub f_bsize: crate::blksize64_t, pub f_frsize: crate::blksize64_t, @@ -266,6 +272,7 @@ s! { pub tv_nsec: c_int, } + // FIXME(1.0,deprecate,64): lfs binding to be removed pub struct statfs64 { pub f_version: c_int, pub f_type: c_int, @@ -436,6 +443,7 @@ s! { __unused: Padding<[*mut c_void; 34]>, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, @@ -459,6 +467,7 @@ s! { shm_reserved1: Padding, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct stat64 { pub st_dev: dev_t, pub st_ino: ino_t, @@ -825,7 +834,7 @@ pub const BIOCGETIF: c_int = 0x4020426b; pub const BIOCSETIF: c_int = u32_cast_int(0x8020426c); pub const BPF_ABS: c_int = 32; pub const BPF_ADD: c_int = 0; -pub const BPF_ALIGNMENT: c_ulong = 4; +pub const BPF_ALIGNMENT: size_t = size_of::(); pub const BPF_ALU: c_int = 4; pub const BPF_AND: c_int = 80; pub const BPF_B: c_int = 16; @@ -2914,23 +2923,33 @@ extern "C" { pub fn ffsl(value: c_long) -> c_int; pub fn ffsll(value: c_longlong) -> c_int; pub fn fgetgrent(file: *mut crate::FILE) -> *mut crate::group; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; pub fn fgetpwent(file: *mut crate::FILE) -> *mut crate::passwd; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn freelocale(loc: crate::locale_t); + // FIXME(1.0,deprecate): lfs binding to be removed pub fn freopen64( filename: *const c_char, mode: *const c_char, file: *mut crate::FILE, ) -> *mut crate::FILE; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fseeko64(stream: *mut crate::FILE, offset: off64_t, whence: c_int) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const fpos64_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; + // FIXME(1.0,deprecate,32): lfs binding to be removed pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftello64(stream: *mut crate::FILE) -> off64_t; pub fn ftok(path: *const c_char, id: c_int) -> crate::key_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; pub fn getcontext(ucp: *mut ucontext_t) -> c_int; @@ -2988,6 +3007,7 @@ extern "C" { result: *mut *mut passwd, ) -> c_int; pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn getrlimit64(resource: c_int, rlim: *mut rlimit64) -> c_int; pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; @@ -3039,7 +3059,9 @@ extern "C" { width: size_t, compar: Option c_int>, ) -> *mut c_void; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn madvise(addr: caddr_t, len: size_t, advice: c_int) -> c_int; pub fn makecontext(ucp: *mut crate::ucontext_t, func: extern "C" fn(), argc: c_int, ...); @@ -3109,6 +3131,7 @@ extern "C" { pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; pub fn nl_langinfo_l(item: crate::nl_item, loc: crate::locale_t) -> *mut c_char; pub fn nrand48(xseed: *mut c_ushort) -> c_long; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; pub fn pollset_create(maxfd: c_int) -> pollset_t; pub fn pollset_ctl(ps: pollset_t, pollctl_array: *mut poll_ctl, array_length: c_int) -> c_int; @@ -3122,8 +3145,10 @@ extern "C" { pub fn pollset_query(ps: pollset_t, pollfd_query: *mut crate::pollfd) -> c_int; pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn posix_fadvise64(fd: c_int, offset: off64_t, len: off64_t, advise: c_int) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; pub fn posix_spawn( @@ -3198,6 +3223,7 @@ extern "C" { argv: *const *mut c_char, envp: *const *mut c_char, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) -> ssize_t; pub fn ptrace64( @@ -3209,6 +3235,7 @@ extern "C" { ) -> c_int; pub fn pututline(u: *const utmp) -> *mut utmp; pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: off64_t) -> ssize_t; pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) -> ssize_t; @@ -3297,6 +3324,7 @@ extern "C" { pub fn setpriority(which: c_int, who: id_t, priority: c_int) -> c_int; pub fn setpwent(); pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; pub fn setitimer( @@ -3324,10 +3352,14 @@ extern "C" { pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int; pub fn srand(seed: c_uint); pub fn srand48(seed: c_long); + // FIXME(1.0,deprecate): lfs binding to be removed pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn stat64at(dirfd: c_int, path: *const c_char, buf: *mut stat64, flags: c_int) -> c_int; pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; + // FIXME(1.0,deprecate,32): lfs binding to be removed pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; pub fn statx(path: *const c_char, buf: *mut stat, length: c_int, command: c_int) -> c_int; pub fn strcasecmp_l( @@ -3369,6 +3401,7 @@ extern "C" { new_value: *const crate::itimerspec, old_value: *mut crate::itimerspec, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; pub fn uname(buf: *mut crate::utsname) -> c_int; pub fn updwtmp(file: *const c_char, u: *const utmp); diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index cd439044d196f..37f0d0f743cbe 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -1,4 +1,3 @@ -use crate::off_t; use crate::prelude::*; // Define lock_data_instrumented as an empty enum @@ -6,6 +5,8 @@ extern_ty! { pub type lock_data_instrumented; } +pub type simple_lock_data = c_int; + s! { pub struct sigset_t { pub ss_set: [c_ulong; 4], @@ -21,8 +22,8 @@ s! { 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 l_start: crate::off_t, + pub l_len: crate::off_t, } pub struct statvfs { @@ -34,7 +35,7 @@ s! { 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_fsid: crate::fsid_t, pub f_basetype: [c_char; 16], pub f_flag: c_ulong, pub f_namemax: c_ulong, @@ -78,8 +79,8 @@ s! { pub st_type: c_uint, pub st_gen: c_uint, st_reserved: Padding<[c_uint; 9]>, - pub st_padto_ll: c_uint, - pub st_size: off_t, + st_padto_ll: Padding, + pub st_size: crate::off_t, } pub struct statfs { @@ -107,7 +108,7 @@ s! { pub aio_lio_opcode: c_int, pub aio_fildes: c_int, pub aio_word1: c_int, - pub aio_offset: off_t, + pub aio_offset: crate::off_t, pub aio_buf: *mut c_void, pub aio_return: ssize_t, pub aio_errno: c_int, @@ -126,11 +127,11 @@ s! { } pub struct __vmx_context_t { - pub __vr: [crate::__vmxreg_t; 32], - pub __pad1: [c_uint; 3], + pub __vr: [__vmxreg_t; 32], + __pad1: Padding<[c_uint; 3]>, pub __vscr: c_uint, pub __vrsave: c_uint, - pub __pad2: [c_uint; 3], + __pad2: Padding<[c_uint; 3]>, } pub struct __vsx_context_t { @@ -138,8 +139,8 @@ s! { } pub struct __tm_context_t { - pub vmx: crate::__vmx_context_t, - pub vsx: crate::__vsx_context_t, + pub vmx: __vmx_context_t, + pub vsx: __vsx_context_t, pub gpr: [c_ulonglong; 32], pub lr: c_ulonglong, pub ctr: c_ulonglong, @@ -158,7 +159,7 @@ s! { pub tmcontext: c_char, pub tmstate: c_char, pub prevowner: c_char, - pub pad: [c_char; 5], + pad: Padding<[c_char; 5]>, } pub struct __context64 { @@ -176,7 +177,7 @@ s! { pub fpeu: c_char, pub fpinfo: c_char, pub fpscr24_31: c_char, - pub pad: [c_char; 1], + pad: Padding<[c_char; 1]>, pub excp_type: c_int, } @@ -187,24 +188,24 @@ s! { pub struct __extctx_t { pub __flags: c_uint, pub __rsvd1: [c_uint; 3], - pub __vmx: crate::__vmx_context_t, + pub __vmx: __vmx_context_t, pub __ukeys: [c_uint; 2], - pub __vsx: crate::__vsx_context_t, - pub __tm: crate::__tm_context_t, + pub __vsx: __vsx_context_t, + pub __tm: __tm_context_t, __reserved: Padding<[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, + __sc_onstack: c_int, + pub uc_sigmask: sigset_t, + __sc_uerror: c_int, + pub uc_mcontext: 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], + __extctx: *mut __extctx_t, + __extctx_magic: c_int, + __pad: Padding<[c_int; 1]>, } pub struct utmpx { @@ -215,17 +216,17 @@ s! { 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], + __dbl_word_pad: Padding, + __reservedA: Padding<[c_int; 2]>, + __reservedV: Padding<[c_int; 6]>, } pub struct pthread_spinlock_t { - pub __sp_word: [c_long; 3], + __sp_word: [c_long; 3], } pub struct pthread_barrier_t { - pub __br_word: [c_long; 5], + __br_word: [c_long; 5], } pub struct msqid_ds { @@ -255,19 +256,50 @@ s! { 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], + __si_flags: c_int, + __pad: Padding<[c_int; 3]>, } - pub struct pollfd_ext { + pub struct pollfd_ext_t { pub fd: c_int, pub events: c_short, pub revents: c_short, - pub data: __pollfd_ext_u, + pub u: __c_anonymous_pollfd_ext_t_u, + } +} + +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 } } s_no_extra_traits! { + pub union _simple_lock { + _slock: simple_lock_data, + _slockp: *mut lock_data_instrumented, + } + + #[deprecated( + since = "0.2.187", + note = "Use `_simple_lock` instead. This type doesn't exist upstream." + )] pub union _kernel_simple_lock { pub _slock: c_long, pub _slockp: *mut lock_data_instrumented, @@ -275,30 +307,31 @@ s_no_extra_traits! { 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, + unsafe extern "C" fn( + *mut file, + crate::uio_rw, + *mut c_void, + c_long, + *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, + unsafe extern "C" fn(*mut file, c_long, crate::caddr_t, c_long, 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, + unsafe extern "C" fn( + *mut file, + c_int, + c_ushort, + *mut c_ushort, + Option, + ) -> c_int, >, pub fo_close: Option c_int>, pub fo_fstat: Option c_int>, } + #[repr(align(256))] pub struct file { pub f_flag: c_long, pub f_count: c_int, @@ -306,12 +339,12 @@ s_no_extra_traits! { 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, + pub f_offset: crate::offset_t, + pub f_dir_off: crate::off_t, // 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_lock: _simple_lock, + pub f_offset_lock: _simple_lock, pub f_vinfo: crate::caddr_t, pub f_ops: *mut fileops_t, pub f_parentp: crate::caddr_t, @@ -319,16 +352,10 @@ s_no_extra_traits! { 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 _file: __c_anonymous_ld_info__file, pub ldinfo_textorg: *mut c_void, pub ldinfo_textsize: c_ulong, pub ldinfo_dataorg: *mut c_void, @@ -336,7 +363,13 @@ s_no_extra_traits! { pub ldinfo_filename: [c_char; 2], } - pub union __pollfd_ext_u { + pub union __c_anonymous_ld_info__file { + pub _ldinfo_fd: c_int, + pub _ldinfo_fp: *mut file, + pub _core_offset: c_long, + } + + pub union __c_anonymous_pollfd_ext_t_u { pub addr: *mut c_void, pub data32: u32, pub data: u64, @@ -347,32 +380,10 @@ s_no_extra_traits! { } } -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 __pollfd_ext_u { - fn eq(&self, other: &__pollfd_ext_u) -> bool { + impl PartialEq for __c_anonymous_pollfd_ext_t_u { + fn eq(&self, other: &__c_anonymous_pollfd_ext_t_u) -> bool { unsafe { self.addr == other.addr && self.data32 == other.data32 @@ -380,8 +391,8 @@ cfg_if! { } } } - impl Eq for __pollfd_ext_u {} - impl hash::Hash for __pollfd_ext_u { + impl Eq for __c_anonymous_pollfd_ext_t_u {} + impl hash::Hash for __c_anonymous_pollfd_ext_t_u { fn hash(&self, state: &mut H) { unsafe { self.addr.hash(state); @@ -406,6 +417,7 @@ cfg_if! { } } +// pthread.h pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { __mt_word: [0, 2, 0, 0, 0, 0, 0, 0], }; @@ -415,11 +427,11 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { 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], }; +// sys/resource.h pub const RLIM_INFINITY: c_ulong = 0x7fffffffffffffff; extern "C" { diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index d6016483a6c42..f6e861abc3434 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -37,6 +37,7 @@ s! { pub ifi_reserved2: u32, } + #[cfg(target_os = "macos")] pub struct bpf_hdr { pub bh_tstamp: crate::timeval, pub bh_caplen: u32, @@ -56,11 +57,17 @@ s_no_extra_traits! { } } -pub const BIOCSETF: c_ulong = 0x80084267; -pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; -pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; -pub const BIOCSETFNR: c_ulong = 0x8008427e; +cfg_if! { + if #[cfg(target_os = "macos")] { + pub const BIOCSETF: c_ulong = 0x80084267; + pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; + pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; + pub const BIOCSETFNR: c_ulong = 0x8008427e; + } +} extern "C" { + // `exchangedata` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_ulong) -> c_int; } diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index a973f3db11ec3..541d16e3e5608 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -41,6 +41,7 @@ s! { pub ifi_reserved2: u32, } + #[cfg(target_os = "macos")] pub struct bpf_hdr { pub bh_tstamp: crate::timeval32, pub bh_caplen: u32, @@ -49,12 +50,18 @@ s! { } } -pub const BIOCSETF: c_ulong = 0x80104267; -pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; -pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; -pub const BIOCSETFNR: c_ulong = 0x8010427e; +cfg_if! { + if #[cfg(target_os = "macos")] { + pub const BIOCSETF: c_ulong = 0x80104267; + pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; + pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; + pub const BIOCSETFNR: c_ulong = 0x8010427e; + } +} extern "C" { + // `exchangedata` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_uint) -> c_int; } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 6aed401bbb009..2a953eda0b07d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -130,6 +130,7 @@ pub type thread_latency_qos_policy_t = *mut thread_latency_qos_policy; pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy; pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy; +#[cfg(target_os = "macos")] pub type pthread_jit_write_callback_t = Option c_int>; pub type os_clockid_t = u32; @@ -175,6 +176,7 @@ pub type copyfile_callback_t = Option< pub type attrgroup_t = u32; pub type vol_capabilities_set_t = [u32; 4]; +#[cfg(target_os = "macos")] deprecated_mach! { pub type mach_timebase_info_data_t = mach_timebase_info; } @@ -303,6 +305,7 @@ s! { pub ai_next: *mut addrinfo, } + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub struct mach_timebase_info { pub numer: u32, @@ -483,6 +486,7 @@ s! { pub ifmam_refcount: i32, } + #[cfg(target_os = "macos")] pub struct rt_metrics { pub rmx_locks: u32, pub rmx_mtu: u32, @@ -500,6 +504,7 @@ s! { pub rmx_filler: [u32; 3], } + #[cfg(target_os = "macos")] pub struct rt_msghdr { pub rtm_msglen: c_ushort, pub rtm_version: c_uchar, @@ -515,6 +520,7 @@ s! { pub rtm_rmx: rt_metrics, } + #[cfg(target_os = "macos")] pub struct rt_msghdr2 { pub rtm_msglen: c_ushort, pub rtm_version: c_uchar, @@ -582,6 +588,7 @@ s! { pub int_n_sign_posn: c_char, } + #[cfg(target_os = "macos")] pub struct proc_taskinfo { pub pti_virtual_size: u64, pub pti_resident_size: u64, @@ -603,6 +610,7 @@ s! { pub pti_priority: i32, } + #[cfg(target_os = "macos")] pub struct proc_bsdinfo { pub pbi_flags: u32, pub pbi_status: u32, @@ -628,6 +636,7 @@ s! { pub pbi_start_tvusec: u64, } + #[cfg(target_os = "macos")] pub struct proc_bsdshortinfo { /// Process ID. pub pbsi_pid: u32, @@ -654,9 +663,10 @@ s! { /// Current SVGID on process. pub pbsi_svgid: crate::gid_t, /// Reserved for future use. - pbsi_rfu: u32, + pbsi_rfu: Padding, } + #[cfg(target_os = "macos")] pub struct proc_taskallinfo { pub pbsd: proc_bsdinfo, pub ptinfo: proc_taskinfo, @@ -677,6 +687,7 @@ s! { pub cr_groups: [crate::gid_t; 16], } + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub struct mach_header { pub magic: u32, @@ -688,6 +699,7 @@ s! { pub flags: u32, } + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub struct mach_header_64 { pub magic: u32, @@ -744,6 +756,7 @@ s! { pub sdl_data: [c_char; 12], } + #[cfg(target_os = "macos")] pub struct sockaddr_inarp { pub sin_len: c_uchar, pub sin_family: c_uchar, @@ -754,6 +767,7 @@ s! { pub sin_other: c_ushort, } + #[cfg(target_os = "macos")] pub struct sockaddr_ctl { pub sc_len: c_uchar, pub sc_family: c_uchar, @@ -787,15 +801,14 @@ s! { } // sys/sem.h - pub struct sembuf { pub sem_num: c_ushort, pub sem_op: c_short, pub sem_flg: c_short, } - // sys/shm.h - + // sys/if_arp.h + #[cfg(target_os = "macos")] pub struct arphdr { pub ar_hrd: u16, pub ar_pro: u16, @@ -809,6 +822,7 @@ s! { } // net/ndrv.h + #[cfg(target_os = "macos")] pub struct sockaddr_ndrv { pub snd_len: c_uchar, pub snd_family: c_uchar, @@ -909,6 +923,7 @@ s! { pub size: crate::vm_size_t, } + #[cfg(target_os = "macos")] pub struct vinfo_stat { pub vst_dev: u32, pub vst_mode: u16, @@ -933,6 +948,7 @@ s! { pub vst_qspare: [i64; 2], } + #[cfg(target_os = "macos")] pub struct vnode_info { pub vi_stat: vinfo_stat, pub vi_type: c_int, @@ -940,6 +956,7 @@ s! { pub vi_fsid: crate::fsid_t, } + #[cfg(target_os = "macos")] pub struct vnode_info_path { pub vip_vi: vnode_info, // Normally it's `vip_path: [c_char; MAXPATHLEN]` but because libc supports an old rustc @@ -947,6 +964,7 @@ s! { pub vip_path: [[c_char; 32]; 32], } + #[cfg(target_os = "macos")] pub struct proc_vnodepathinfo { pub pvi_cdir: vnode_info_path, pub pvi_rdir: vnode_info_path, @@ -1182,6 +1200,7 @@ s! { pub tcpi_rxretransmitpackets: u64, } + #[cfg(target_os = "macos")] pub struct in6_addrlifetime { pub ia6t_expire: time_t, pub ia6t_preferred: time_t, @@ -1189,6 +1208,7 @@ s! { pub ia6t_pltime: u32, } + #[cfg(target_os = "macos")] pub struct in6_ifstat { pub ifs6_in_receive: crate::u_quad_t, pub ifs6_in_hdrerr: crate::u_quad_t, @@ -1217,6 +1237,7 @@ s! { pub ifs6_defrtr_expiry_cnt: crate::u_quad_t, } + #[cfg(target_os = "macos")] pub struct icmp6_ifstat { pub ifs6_in_msg: crate::u_quad_t, pub ifs6_in_error: crate::u_quad_t, @@ -1260,6 +1281,7 @@ s! { } // net/if_mib.h + #[cfg(target_os = "macos")] pub struct ifmibdata { /// Name of interface pub ifmd_name: [c_char; crate::IFNAMSIZ], @@ -1279,6 +1301,7 @@ s! { pub ifmd_data: if_data64, } + #[cfg(target_os = "macos")] pub struct ifs_iso_8802_3 { pub dot3StatsAlignmentErrors: u32, pub dot3StatsFCSErrors: u32, @@ -1299,12 +1322,14 @@ s! { } // kern_control.h + #[cfg(target_os = "macos")] pub struct ctl_info { pub ctl_id: u32, pub ctl_name: [c_char; MAX_KCTL_NAME], } // sys/proc_info.h + #[cfg(target_os = "macos")] pub struct proc_fdinfo { pub proc_fd: i32, pub proc_fdtype: u32, @@ -1347,6 +1372,7 @@ s! { pub shm_internal: *mut c_void, } + #[cfg(target_os = "macos")] pub struct proc_threadinfo { pub pth_user_time: u64, pub pth_system_time: u64, @@ -1648,6 +1674,7 @@ s! { pub ifr_ifru: __c_anonymous_ifr_ifru, } + #[cfg(target_os = "macos")] pub struct in6_ifreq { pub ifr_name: [c_char; crate::IFNAMSIZ], pub ifr_ifru: __c_anonymous_ifr_ifru6, @@ -1688,19 +1715,25 @@ s_no_extra_traits! { pub ifcu_buf: *mut c_char, pub ifcu_req: *mut ifreq, } +} - pub union __c_anonymous_ifr_ifru6 { - pub ifru_addr: crate::sockaddr_in6, - pub ifru_dstaddr: crate::sockaddr_in6, - pub ifru_flags: c_int, - pub ifru_flags6: c_int, - pub ifru_metrics: c_int, - pub ifru_intval: c_int, - pub ifru_data: *mut c_char, - pub ifru_lifetime: in6_addrlifetime, - pub ifru_stat: in6_ifstat, - pub ifru_icmp6stat: icmp6_ifstat, - pub ifru_scope_id: [u32; SCOPE6_ID_MAX], +cfg_if! { + if #[cfg(target_os = "macos")] { + s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru6 { + pub ifru_addr: crate::sockaddr_in6, + pub ifru_dstaddr: crate::sockaddr_in6, + pub ifru_flags: c_int, + pub ifru_flags6: c_int, + pub ifru_metrics: c_int, + pub ifru_intval: c_int, + pub ifru_data: *mut c_char, + pub ifru_lifetime: in6_addrlifetime, + pub ifru_stat: in6_ifstat, + pub ifru_icmp6stat: icmp6_ifstat, + pub ifru_scope_id: [u32; SCOPE6_ID_MAX], + } + } } } @@ -1868,6 +1901,7 @@ cfg_if! { } } + #[cfg(target_os = "macos")] impl PartialEq for __c_anonymous_ifr_ifru6 { fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool { unsafe { @@ -1887,8 +1921,10 @@ cfg_if! { } } + #[cfg(target_os = "macos")] impl Eq for __c_anonymous_ifr_ifru6 {} + #[cfg(target_os = "macos")] impl hash::Hash for __c_anonymous_ifr_ifru6 { fn hash(&self, state: &mut H) { unsafe { @@ -2155,25 +2191,30 @@ pub const PROT_READ: c_int = 1; pub const PROT_WRITE: c_int = 2; pub const PROT_EXEC: c_int = 4; -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_READ_U: c_int = 3; -pub const PT_WRITE_I: c_int = 4; -pub const PT_WRITE_D: c_int = 5; -pub const PT_WRITE_U: c_int = 6; -pub const PT_CONTINUE: c_int = 7; -pub const PT_KILL: c_int = 8; -pub const PT_STEP: c_int = 9; -pub const PT_ATTACH: c_int = 10; -pub const PT_DETACH: c_int = 11; -pub const PT_SIGEXC: c_int = 12; -pub const PT_THUPDATE: c_int = 13; -pub const PT_ATTACHEXC: c_int = 14; - -pub const PT_FORCEQUOTA: c_int = 30; -pub const PT_DENY_ATTACH: c_int = 31; -pub const PT_FIRSTMACH: c_int = 32; +cfg_if! { + if #[cfg(target_os = "macos")] { + // ptrace.h + 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_READ_U: c_int = 3; + pub const PT_WRITE_I: c_int = 4; + pub const PT_WRITE_D: c_int = 5; + pub const PT_WRITE_U: c_int = 6; + pub const PT_CONTINUE: c_int = 7; + pub const PT_KILL: c_int = 8; + pub const PT_STEP: c_int = 9; + pub const PT_ATTACH: c_int = 10; + pub const PT_DETACH: c_int = 11; + pub const PT_SIGEXC: c_int = 12; + pub const PT_THUPDATE: c_int = 13; + pub const PT_ATTACHEXC: c_int = 14; + + pub const PT_FORCEQUOTA: c_int = 30; + pub const PT_DENY_ATTACH: c_int = 31; + pub const PT_FIRSTMACH: c_int = 32; + } +} pub const MAP_FILE: c_int = 0x0000; pub const MAP_SHARED: c_int = 0x0001; @@ -2595,7 +2636,11 @@ pub const MINCORE_MODIFIED: c_int = 0x4; pub const MINCORE_REFERENCED_OTHER: c_int = 0x8; pub const MINCORE_MODIFIED_OTHER: c_int = 0x10; -pub const CTLIOCGINFO: c_ulong = 0xc0644e03; +cfg_if! { + if #[cfg(target_os = "macos")] { + pub const CTLIOCGINFO: c_ulong = 0xc0644e03; + } +} // // sys/netinet/in.h @@ -2863,10 +2908,15 @@ pub const pseudo_AF_HDRCMPLT: c_int = 35; pub const AF_IEEE80211: c_int = 37; pub const AF_UTUN: c_int = 38; pub const AF_VSOCK: c_int = 40; -pub const AF_SYS_CONTROL: c_int = 2; -pub const SYSPROTO_EVENT: c_int = 1; -pub const SYSPROTO_CONTROL: c_int = 2; +cfg_if! { + if #[cfg(target_os = "macos")] { + // sys/sys_domain.h + pub const AF_SYS_CONTROL: c_int = 2; + pub const SYSPROTO_EVENT: c_int = 1; + pub const SYSPROTO_CONTROL: c_int = 2; + } +} pub const PF_UNSPEC: c_int = AF_UNSPEC; pub const PF_LOCAL: c_int = AF_LOCAL; @@ -3564,6 +3614,10 @@ pub const VM_PROT_NONE: crate::vm_prot_t = 0x00; pub const VM_PROT_READ: crate::vm_prot_t = 0x01; pub const VM_PROT_WRITE: crate::vm_prot_t = 0x02; pub const VM_PROT_EXECUTE: crate::vm_prot_t = 0x04; +pub const VM_INHERIT_SHARE: c_int = 0; +pub const VM_INHERIT_COPY: c_int = 1; +pub const VM_INHERIT_NONE: c_int = 2; +pub const VM_INHERIT_DONATE_COPY: c_int = 3; pub const MEMORY_OBJECT_NULL: crate::memory_object_t = 0; pub const HW_MACHINE: c_int = 1; pub const HW_MODEL: c_int = 2; @@ -3697,85 +3751,97 @@ pub const XATTR_NODEFAULT: c_int = 0x0010; pub const XATTR_SHOWCOMPRESSION: c_int = 0x0020; pub const NET_RT_IFLIST2: c_int = 0x0006; +pub const NET_RT_DUMP2: c_int = 0x0007; -// net/route.h -pub const RTF_DELCLONE: c_int = 0x80; -pub const RTF_CLONING: c_int = 0x100; -pub const RTF_XRESOLVE: c_int = 0x200; -pub const RTF_LLINFO: c_int = 0x400; -pub const RTF_NOIFREF: c_int = 0x2000; -pub const RTF_PRCLONING: c_int = 0x10000; -pub const RTF_WASCLONED: c_int = 0x20000; -pub const RTF_PROTO3: c_int = 0x40000; -pub const RTF_PINNED: c_int = 0x100000; -pub const RTF_LOCAL: c_int = 0x200000; -pub const RTF_BROADCAST: c_int = 0x400000; -pub const RTF_MULTICAST: c_int = 0x800000; -pub const RTF_IFSCOPE: c_int = 0x1000000; -pub const RTF_CONDEMNED: c_int = 0x2000000; -pub const RTF_IFREF: c_int = 0x4000000; -pub const RTF_PROXY: c_int = 0x8000000; -pub const RTF_ROUTER: c_int = 0x10000000; -pub const RTF_DEAD: c_int = 0x20000000; -pub const RTF_GLOBAL: c_int = 0x40000000; - -pub const RTM_VERSION: c_int = 5; - -// Message types -pub const RTM_LOCK: c_int = 0x8; -pub const RTM_OLDADD: c_int = 0x9; -pub const RTM_OLDDEL: c_int = 0xa; -pub const RTM_RESOLVE: c_int = 0xb; -pub const RTM_NEWADDR: c_int = 0xc; -pub const RTM_DELADDR: c_int = 0xd; -pub const RTM_IFINFO: c_int = 0xe; -pub const RTM_NEWMADDR: c_int = 0xf; -pub const RTM_DELMADDR: c_int = 0x10; -pub const RTM_IFINFO2: c_int = 0x12; -pub const RTM_NEWMADDR2: c_int = 0x13; -pub const RTM_GET2: c_int = 0x14; - -// Bitmask values for rtm_inits and rmx_locks. -pub const RTV_MTU: c_int = 0x1; -pub const RTV_HOPCOUNT: c_int = 0x2; -pub const RTV_EXPIRE: c_int = 0x4; -pub const RTV_RPIPE: c_int = 0x8; -pub const RTV_SPIPE: c_int = 0x10; -pub const RTV_SSTHRESH: c_int = 0x20; -pub const RTV_RTT: c_int = 0x40; -pub const RTV_RTTVAR: c_int = 0x80; - -/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) -/// for details. -pub const RTAX_MAX: c_int = 8; +cfg_if! { + if #[cfg(target_os = "macos")] { + // net/route.h + pub const RTF_DELCLONE: c_int = 0x80; + pub const RTF_CLONING: c_int = 0x100; + pub const RTF_XRESOLVE: c_int = 0x200; + pub const RTF_LLINFO: c_int = 0x400; + pub const RTF_NOIFREF: c_int = 0x2000; + pub const RTF_PRCLONING: c_int = 0x10000; + pub const RTF_WASCLONED: c_int = 0x20000; + pub const RTF_PROTO3: c_int = 0x40000; + pub const RTF_PINNED: c_int = 0x100000; + pub const RTF_LOCAL: c_int = 0x200000; + pub const RTF_BROADCAST: c_int = 0x400000; + pub const RTF_MULTICAST: c_int = 0x800000; + pub const RTF_IFSCOPE: c_int = 0x1000000; + pub const RTF_CONDEMNED: c_int = 0x2000000; + pub const RTF_IFREF: c_int = 0x4000000; + pub const RTF_PROXY: c_int = 0x8000000; + pub const RTF_ROUTER: c_int = 0x10000000; + pub const RTF_DEAD: c_int = 0x20000000; + pub const RTF_GLOBAL: c_int = 0x40000000; + + pub const RTM_VERSION: c_int = 5; + + // Message types + pub const RTM_LOCK: c_int = 0x8; + pub const RTM_OLDADD: c_int = 0x9; + pub const RTM_OLDDEL: c_int = 0xa; + pub const RTM_RESOLVE: c_int = 0xb; + pub const RTM_NEWADDR: c_int = 0xc; + pub const RTM_DELADDR: c_int = 0xd; + pub const RTM_IFINFO: c_int = 0xe; + pub const RTM_NEWMADDR: c_int = 0xf; + pub const RTM_DELMADDR: c_int = 0x10; + pub const RTM_IFINFO2: c_int = 0x12; + pub const RTM_NEWMADDR2: c_int = 0x13; + pub const RTM_GET2: c_int = 0x14; + + // Bitmask values for rtm_inits and rmx_locks. + pub const RTV_MTU: c_int = 0x1; + pub const RTV_HOPCOUNT: c_int = 0x2; + pub const RTV_EXPIRE: c_int = 0x4; + pub const RTV_RPIPE: c_int = 0x8; + pub const RTV_SPIPE: c_int = 0x10; + pub const RTV_SSTHRESH: c_int = 0x20; + pub const RTV_RTT: c_int = 0x40; + pub const RTV_RTTVAR: c_int = 0x80; + + /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) + /// for details. + pub const RTAX_MAX: c_int = 8; + } +} pub const KERN_PROCARGS2: c_int = 49; -pub const PROC_PIDTASKALLINFO: c_int = 2; -pub const PROC_PIDTBSDINFO: c_int = 3; -pub const PROC_PIDTASKINFO: c_int = 4; -pub const PROC_PIDTHREADINFO: c_int = 5; -pub const PROC_PIDVNODEPATHINFO: c_int = 9; -pub const PROC_PIDT_SHORTBSDINFO: c_int = 13; -pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096; - -pub const PROC_PIDLISTFDS: c_int = 1; -pub const PROC_PIDLISTFD_SIZE: c_int = size_of::() as c_int; -pub const PROX_FDTYPE_ATALK: c_int = 0; -pub const PROX_FDTYPE_VNODE: c_int = 1; -pub const PROX_FDTYPE_SOCKET: c_int = 2; -pub const PROX_FDTYPE_PSHM: c_int = 3; -pub const PROX_FDTYPE_PSEM: c_int = 4; -pub const PROX_FDTYPE_KQUEUE: c_int = 5; -pub const PROX_FDTYPE_PIPE: c_int = 6; -pub const PROX_FDTYPE_FSEVENTS: c_int = 7; -pub const PROX_FDTYPE_NETPOLICY: c_int = 9; -pub const PROX_FDTYPE_CHANNEL: c_int = 10; -pub const PROX_FDTYPE_NEXUS: c_int = 11; - -pub const PROC_CSM_ALL: c_uint = 0x0001; -pub const PROC_CSM_NOSMT: c_uint = 0x0002; -pub const PROC_CSM_TECS: c_uint = 0x0004; +cfg_if! { + if #[cfg(target_os = "macos")] { + // sys/proc_info.h + pub const PROC_PIDTASKALLINFO: c_int = 2; + pub const PROC_PIDTBSDINFO: c_int = 3; + pub const PROC_PIDTASKINFO: c_int = 4; + pub const PROC_PIDTHREADINFO: c_int = 5; + pub const PROC_PIDVNODEPATHINFO: c_int = 9; + pub const PROC_PIDT_SHORTBSDINFO: c_int = 13; + pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096; + + pub const PROC_PIDLISTFDS: c_int = 1; + pub const PROC_PIDLISTFD_SIZE: c_int = size_of::() as c_int; + pub const PROX_FDTYPE_ATALK: c_int = 0; + pub const PROX_FDTYPE_VNODE: c_int = 1; + pub const PROX_FDTYPE_SOCKET: c_int = 2; + pub const PROX_FDTYPE_PSHM: c_int = 3; + pub const PROX_FDTYPE_PSEM: c_int = 4; + pub const PROX_FDTYPE_KQUEUE: c_int = 5; + pub const PROX_FDTYPE_PIPE: c_int = 6; + pub const PROX_FDTYPE_FSEVENTS: c_int = 7; + pub const PROX_FDTYPE_NETPOLICY: c_int = 9; + pub const PROX_FDTYPE_CHANNEL: c_int = 10; + pub const PROX_FDTYPE_NEXUS: c_int = 11; + + // libproc.h + pub const PROC_CSM_ALL: c_uint = 0x0001; + pub const PROC_CSM_NOSMT: c_uint = 0x0002; + pub const PROC_CSM_TECS: c_uint = 0x0004; + } +} + pub const MAXCOMLEN: usize = 16; pub const MAXTHREADNAMESIZE: usize = 64; @@ -3787,9 +3853,13 @@ pub const LC_SEGMENT_64: u32 = 0x19; pub const MH_MAGIC: u32 = 0xfeedface; pub const MH_MAGIC_64: u32 = 0xfeedfacf; -// net/if_utun.h -pub const UTUN_OPT_FLAGS: c_int = 1; -pub const UTUN_OPT_IFNAME: c_int = 2; +cfg_if! { + if #[cfg(target_os = "macos")] { + // net/if_utun.h + pub const UTUN_OPT_FLAGS: c_int = 1; + pub const UTUN_OPT_IFNAME: c_int = 2; + } +} // sys/mount.h pub const MNT_NODEV: c_int = 0x00000010; @@ -4312,34 +4382,38 @@ pub const MACH_TASK_BASIC_INFO_COUNT: u32 = pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = (size_of::() / size_of::()) as mach_msg_type_number_t; -// bsd/net/if_mib.h -/// Non-interface-specific -pub const IFMIB_SYSTEM: c_int = 1; -/// Per-interface data table -pub const IFMIB_IFDATA: c_int = 2; -/// All interfaces data at once -pub const IFMIB_IFALLDATA: c_int = 3; - -/// Generic stats for all kinds of ifaces -pub const IFDATA_GENERAL: c_int = 1; -/// Specific to the type of interface -pub const IFDATA_LINKSPECIFIC: c_int = 2; -/// Addresses assigned to interface -pub const IFDATA_ADDRS: c_int = 3; -/// Multicast addresses assigned to interface -pub const IFDATA_MULTIADDRS: c_int = 4; - -/// Number of interfaces configured -pub const IFMIB_IFCOUNT: c_int = 1; - -/// Functions not specific to a type of iface -pub const NETLINK_GENERIC: c_int = 0; - -pub const DOT3COMPLIANCE_STATS: c_int = 1; -pub const DOT3COMPLIANCE_COLLS: c_int = 2; - -// kern_control.h -pub const MAX_KCTL_NAME: usize = 96; +cfg_if! { + if #[cfg(target_os = "macos")] { + // bsd/net/if_mib.h + /// Non-interface-specific + pub const IFMIB_SYSTEM: c_int = 1; + /// Per-interface data table + pub const IFMIB_IFDATA: c_int = 2; + /// All interfaces data at once + pub const IFMIB_IFALLDATA: c_int = 3; + + /// Generic stats for all kinds of ifaces + pub const IFDATA_GENERAL: c_int = 1; + /// Specific to the type of interface + pub const IFDATA_LINKSPECIFIC: c_int = 2; + /// Addresses assigned to interface + pub const IFDATA_ADDRS: c_int = 3; + /// Multicast addresses assigned to interface + pub const IFDATA_MULTIADDRS: c_int = 4; + + /// Number of interfaces configured + pub const IFMIB_IFCOUNT: c_int = 1; + + /// Functions not specific to a type of iface + pub const NETLINK_GENERIC: c_int = 0; + + pub const DOT3COMPLIANCE_STATS: c_int = 1; + pub const DOT3COMPLIANCE_COLLS: c_int = 2; + + // kern_control.h + pub const MAX_KCTL_NAME: usize = 96; + } +} f! { pub unsafe fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { @@ -4424,6 +4498,8 @@ extern "C" { pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; pub fn chflags(path: *const c_char, flags: c_uint) -> c_int; pub fn fchflags(fd: c_int, flags: c_uint) -> c_int; + pub fn lchflags(path: *const c_char, flags: c_uint) -> c_int; + pub fn lchmod(path: *const c_char, mode: mode_t) -> c_int; pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn lio_listio( @@ -4505,13 +4581,17 @@ extern "C" { newp: *mut c_void, newlen: size_t, ) -> c_int; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_absolute_time() -> u64; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] #[allow(deprecated)] pub fn mach_timebase_info(info: *mut crate::mach_timebase_info) -> c_int; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_host_self() -> mach_port_t; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_thread_self() -> mach_port_t; pub fn pthread_cond_timedwait_relative_np( @@ -4546,7 +4626,9 @@ extern "C" { pub fn pthread_main_np() -> c_int; pub fn pthread_threadid_np(thread: crate::pthread_t, thread_id: *mut u64) -> c_int; + #[cfg(target_os = "macos")] pub fn pthread_jit_write_protect_np(enabled: c_int); + #[cfg(target_os = "macos")] pub fn pthread_jit_write_protect_supported_np() -> c_int; // An array of pthread_jit_write_with_callback_np must declare // the list of callbacks e.g. @@ -4554,10 +4636,12 @@ extern "C" { // static callbacks: [libc::pthread_jit_write_callback_t; 2] = [native_jit_write_cb, // std::mem::transmute::(std::ptr::null())]; // (a handy PTHREAD_JIT_WRITE_CALLBACK_NP macro for other languages). + #[cfg(target_os = "macos")] pub fn pthread_jit_write_with_callback_np( callback: crate::pthread_jit_write_callback_t, ctx: *mut c_void, ) -> c_int; + #[cfg(target_os = "macos")] pub fn pthread_jit_write_freeze_callbacks_np(); pub fn pthread_cpu_number_np(cpu_number_out: *mut size_t) -> c_int; @@ -4643,12 +4727,12 @@ extern "C" { ); pub fn backtrace_async(array: *mut *mut c_void, length: size_t, task_id: *mut u32) -> size_t; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "statfs$INODE64" )] pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "fstatfs$INODE64" )] pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; @@ -4676,6 +4760,7 @@ extern "C" { data: *mut c_void, ) -> c_int; pub fn fmount(src: *const c_char, fd: c_int, flags: c_int, data: *mut c_void) -> c_int; + #[cfg(target_os = "macos")] pub fn ptrace(request: c_int, pid: crate::pid_t, addr: *mut c_char, data: c_int) -> c_int; pub fn quotactl(special: *const c_char, cmd: c_int, id: c_int, data: *mut c_char) -> c_int; pub fn sethostname(name: *const c_char, len: c_int) -> c_int; @@ -4784,16 +4869,24 @@ extern "C" { infop: *mut crate::siginfo_t, options: c_int, ) -> c_int; + // `brk` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn brk(addr: *const c_void) -> *mut c_void; + // `sbrk` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn sbrk(increment: c_int) -> *mut c_void; pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_image_count() -> u32; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] #[allow(deprecated)] pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> intptr_t; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_get_image_name(image_index: u32) -> *const c_char; @@ -4901,12 +4994,12 @@ extern "C" { pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "getmntinfo$INODE64" )] pub fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "getfsstat$INODE64" )] pub fn getfsstat(mntbufp: *mut statfs, bufsize: c_int, flags: c_int) -> c_int; @@ -4982,52 +5075,10 @@ extern "C" { ) -> *mut c_void; pub fn malloc_zone_free(zone: *mut crate::malloc_zone_t, ptr: *mut c_void); - pub fn proc_listpids(t: u32, typeinfo: u32, buffer: *mut c_void, buffersize: c_int) -> c_int; - pub fn proc_listallpids(buffer: *mut c_void, buffersize: c_int) -> c_int; - pub fn proc_listpgrppids(pgrpid: crate::pid_t, buffer: *mut c_void, buffersize: c_int) - -> c_int; - pub fn proc_listchildpids(ppid: crate::pid_t, buffer: *mut c_void, buffersize: c_int) -> c_int; - pub fn proc_pidinfo( - pid: c_int, - flavor: c_int, - arg: u64, - buffer: *mut c_void, - buffersize: c_int, - ) -> c_int; - pub fn proc_pidfdinfo( - pid: c_int, - fd: c_int, - flavor: c_int, - buffer: *mut c_void, - buffersize: c_int, - ) -> c_int; - pub fn proc_pidfileportinfo( - pid: c_int, - fileport: u32, - flavor: c_int, - buffer: *mut c_void, - buffersize: c_int, - ) -> c_int; - pub fn proc_pidpath(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; - pub fn proc_name(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; - pub fn proc_regionfilename( - pid: c_int, - address: u64, - buffer: *mut c_void, - buffersize: u32, - ) -> c_int; - pub fn proc_kmsgbuf(buffer: *mut c_void, buffersize: u32) -> c_int; - pub fn proc_libversion(major: *mut c_int, minor: *mut c_int) -> c_int; - pub fn proc_pid_rusage(pid: c_int, flavor: c_int, buffer: *mut rusage_info_t) -> c_int; - - // Available from Big Sur - pub fn proc_set_no_smt() -> c_int; - pub fn proc_setthread_no_smt() -> c_int; - pub fn proc_set_csm(flags: u32) -> c_int; - pub fn proc_setthread_csm(flags: u32) -> c_int; /// # Notes /// /// `id` is of type [`uuid_t`]. + #[cfg(target_os = "macos")] pub fn gethostuuid(id: *mut u8, timeout: *const crate::timespec) -> c_int; pub fn gethostid() -> c_long; @@ -5046,6 +5097,7 @@ extern "C" { pub fn _NSGetEnviron() -> *mut *mut *mut c_char; pub fn _NSGetProgname() -> *mut *mut c_char; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_vm_map( target_task: crate::vm_map_t, @@ -5088,6 +5140,7 @@ extern "C" { out_processor_infoCnt: *mut mach_msg_type_number_t, ) -> crate::kern_return_t; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub static mut mach_task_self_: crate::mach_port_t; pub fn task_for_pid( @@ -5194,6 +5247,9 @@ extern "C" { pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int; + + // exec* marked as prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execvP( file: *const c_char, search_path: *const c_char, @@ -5210,25 +5266,79 @@ extern "C" { } #[allow(deprecated)] +#[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub unsafe fn mach_task_self() -> crate::mach_port_t { mach_task_self_ } cfg_if! { + // Prohibited on iOS/tvOS/watchOS/visionOS if #[cfg(target_os = "macos")] { extern "C" { pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + + // libproc.h + pub fn proc_listpids( + t: u32, + typeinfo: u32, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_listallpids(buffer: *mut c_void, buffersize: c_int) -> c_int; + pub fn proc_listpgrppids( + pgrpid: crate::pid_t, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_listchildpids( + ppid: crate::pid_t, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidinfo( + pid: c_int, + flavor: c_int, + arg: u64, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidfdinfo( + pid: c_int, + fd: c_int, + flavor: c_int, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidfileportinfo( + pid: c_int, + fileport: u32, + flavor: c_int, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidpath(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_name(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_regionfilename( + pid: c_int, + address: u64, + buffer: *mut c_void, + buffersize: u32, + ) -> c_int; + pub fn proc_kmsgbuf(buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_libversion(major: *mut c_int, minor: *mut c_int) -> c_int; + pub fn proc_pid_rusage(pid: c_int, flavor: c_int, buffer: *mut rusage_info_t) -> c_int; + // Available from Big Sur + pub fn proc_set_no_smt() -> c_int; + pub fn proc_setthread_no_smt() -> c_int; + pub fn proc_set_csm(flags: u32) -> c_int; + pub fn proc_setthread_csm(flags: u32) -> c_int; } } } + cfg_if! { - if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "visionos" - ))] { + if #[cfg(target_vendor = "apple")] { extern "C" { pub fn memmem( haystack: *const c_void, @@ -5236,6 +5346,8 @@ cfg_if! { needle: *const c_void, needlelen: size_t, ) -> *mut c_void; + // `task_set_info` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn task_set_info( target_task: crate::task_t, flavor: crate::task_flavor_t, diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index cbe02efd58ae9..95f7e305e4577 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -339,7 +339,7 @@ s! { pub kp_auxflags: c_int, pub kp_lwp: crate::kinfo_lwp, pub kp_ktaddr: crate::uintptr_t, - kp_spare: [c_int; 2], + kp_spare: Padding<[c_int; 2]>, } pub struct cpuctl_msr_args_t { @@ -397,7 +397,7 @@ s! { } pub struct statfs { - __spare2: c_long, + __spare2: Padding, pub f_bsize: c_long, pub f_iosize: c_long, pub f_blocks: c_long, @@ -415,10 +415,10 @@ s! { pub f_mntonname: [c_char; 80], pub f_syncreads: c_long, pub f_asyncreads: c_long, - __spares1: c_short, + __spares1: Padding, pub f_mntfromname: [c_char; 80], - __spares2: c_short, - __spare: [c_long; 2], + __spares2: Padding, + __spare: Padding<[c_long; 2]>, } pub struct sigevent { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 91fb88d1b0605..4b6e184dd4c4c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -234,11 +234,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[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], diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index eebf3cba8bde5..36244d162b2dc 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -281,11 +281,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], pub f_mntfromname: [c_char; 1024], pub f_mntonname: [c_char; 1024], diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 39c01538701b6..e9be37bec742e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -294,11 +294,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], pub f_mntfromname: [c_char; 1024], pub f_mntonname: [c_char; 1024], diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index a84c185488ca3..29c7a86b098dd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -296,11 +296,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], pub f_mntfromname: [c_char; 1024], pub f_mntonname: [c_char; 1024], diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 08f9e5e43e6b5..026abe1d50f94 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -298,11 +298,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], pub f_mntfromname: [c_char; 1024], pub f_mntonname: [c_char; 1024], diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index eb4951ffc7e6b..4a72335df97c2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -258,14 +258,14 @@ s! { pub aio_offset: off_t, pub aio_buf: *mut c_void, pub aio_nbytes: size_t, - __unused1: [c_int; 2], - __unused2: *mut c_void, + __unused1: Padding<[c_int; 2]>, + __unused2: Padding<*mut c_void>, pub aio_lio_opcode: c_int, pub aio_reqprio: c_int, // unused 3 through 5 are the __aiocb_private structure - __unused3: c_long, - __unused4: c_long, - __unused5: *mut c_void, + __unused3: Padding, + __unused4: Padding, + __unused5: Padding<*mut c_void>, pub aio_sigevent: sigevent, } @@ -438,14 +438,14 @@ s! { m_rb_link: crate::uintptr_t, #[cfg(target_pointer_width = "32")] m_pad: Padding, - m_spare: [u32; 2], + m_spare: Padding<[u32; 2]>, } pub struct ucond { c_has_waiters: u32, c_flags: u32, c_clockid: u32, - c_spare: [u32; 1], + c_spare: Padding<[u32; 1]>, } pub struct uuid { @@ -505,9 +505,9 @@ s! { #[cfg(not(freebsd11))] pub kve_vn_rdev: u64, #[cfg(not(freebsd11))] - _kve_is_spare: [c_int; 8], + _kve_is_spare: Padding<[c_int; 8]>, #[cfg(freebsd11)] - _kve_is_spare: [c_int; 12], + _kve_is_spare: Padding<[c_int; 12]>, pub kve_path: [[c_char; 32]; 32], } @@ -1665,9 +1665,9 @@ s! { _priv: [u8; 304], // FIXME(freebsd): this is really a giant union pub kf_status: u16, _kf_pad1: Padding, - _kf_ispare0: c_int, + _kf_ispare0: Padding, pub kf_cap_rights: crate::cap_rights_t, - _kf_cap_spare: u64, + _kf_cap_spare: Padding, pub kf_path: [c_char; crate::PATH_MAX as usize], } } @@ -1733,17 +1733,17 @@ s_no_extra_traits! { pub uc_link: *mut crate::ucontext_t, pub uc_stack: crate::stack_t, pub uc_flags: c_int, - __spare__: [c_int; 4], + __spare__: Padding<[c_int; 4]>, } #[repr(align(8))] pub struct xinpgen { pub xig_len: ksize_t, pub xig_count: u32, - _xig_spare32: u32, + _xig_spare32: Padding, pub xig_gen: inp_gen_t, pub xig_sogen: so_gen_t, - _xig_spare64: [u64; 4], + _xig_spare64: Padding<[u64; 4]>, } pub struct in_addr_4in6 { @@ -1775,8 +1775,8 @@ s_no_extra_traits! { // Note: this field is called `gen` in upstream FreeBSD, but `gen` is // reserved keyword in Rust since the 2024 Edition, hence `gennum`. pub gennum: u64, - _rsrv1: [u64; 8], - _rsrv2: [u32; 8], + _rsrv1: Padding<[u64; 8]>, + _rsrv2: Padding<[u32; 8]>, pub iv: [u8; 32], pub cipher_algorithm: i32, pub auth_algorithm: i32, @@ -5037,6 +5037,8 @@ extern "C" { symbol: *const c_char, version: *const c_char, ) -> *mut c_void; + + pub fn lchmod(path: *const c_char, mode: crate::mode_t) -> c_int; } #[link(name = "memstat")] diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4e3b5372cd34c..f1aeb6c5a60f3 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -579,6 +579,12 @@ pub const MAP_ANONYMOUS: c_int = MAP_ANON; pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; +// minherit syscall inherit values +pub const INHERIT_SHARE: c_int = 0; +pub const INHERIT_COPY: c_int = 1; +pub const INHERIT_NONE: c_int = 2; +pub const INHERIT_ZERO: c_int = 3; + pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index a734ec4776a5a..1d408b0a339ed 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -40,15 +40,7 @@ s! { 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" - )))] + #[cfg(not(any(target_vendor = "apple", target_os = "netbsd", target_os = "openbsd")))] pub pw_fields: c_int, } @@ -391,8 +383,14 @@ pub const POLLRDBAND: c_short = 0x080; pub const POLLWRBAND: c_short = 0x100; cfg_if! { - // Not yet implemented on NetBSD - if #[cfg(not(any(target_os = "netbsd")))] { + // Not yet implemented on NetBSD, and not present on iOS/tvOS/watchOS/visionOS. + if #[cfg(not(any( + target_os = "netbsd", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )))] { pub const BIOCGBLEN: c_ulong = 0x40044266; pub const BIOCSBLEN: c_ulong = 0xc0044266; pub const BIOCFLUSH: c_uint = 0x20004268; @@ -405,10 +403,13 @@ cfg_if! { pub const BIOCVERSION: c_ulong = 0x40044271; pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; - pub const SIOCGIFADDR: c_ulong = 0xc0206921; } } +// Not yet implemented on NetBSD. +#[cfg(not(target_os = "netbsd"))] +pub const SIOCGIFADDR: c_ulong = 0xc0206921; + cfg_if! { // Redefined in `new/apple` if #[cfg(not(target_vendor = "apple"))] { @@ -425,48 +426,58 @@ 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; +cfg_if! { + // Not present on iOS/tvOS/watchOS/visionOS + if #[cfg(not(any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )))] { + // 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 unsafe fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { @@ -555,7 +566,6 @@ extern "C" { 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(); @@ -572,7 +582,7 @@ extern "C" { 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")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "glob$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] @@ -617,6 +627,7 @@ extern "C" { )] pub fn telldir(dirp: *mut crate::DIR) -> c_long; pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn minherit(addr: *mut c_void, len: size_t, inherit: c_int) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), @@ -687,6 +698,8 @@ extern "C" { link_name = "sigaltstack$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + // `sigaltstack` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigsuspend14")] pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; @@ -848,13 +861,17 @@ extern "C" { } cfg_if! { - if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos" - ))] { + // `syscall` is prohibited on tvOS and watchOS (and strongly discouraged + // on iOS and macOS). + if #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] { + extern "C" { + pub fn syscall(num: c_int, ...) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(target_vendor = "apple")] { mod apple; pub use self::apple::*; } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] { diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index e0206af04f8f1..c429dd78c0f1f 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -14,7 +14,7 @@ s! { pub struct mcontext_t { pub __gregs: [crate::greg_t; 32], pub __fregs: __fregset, - __spare: [crate::greg_t; 8], + __spare: Padding<[crate::greg_t; 8]>, } pub struct ucontext_t { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 75e4008fc3328..134a4e5fdebbd 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -263,7 +263,7 @@ s! { ptm_owner: crate::pthread_t, ptm_waiters: *mut u8, ptm_recursed: c_uint, - ptm_spare2: *mut c_void, + ptm_spare2: Padding<*mut c_void>, } pub struct pthread_mutexattr_t { @@ -1112,6 +1112,13 @@ pub const MAP_ALIGNMENT_64PB: c_int = 56 << MAP_ALIGNMENT_SHIFT; // mremap flag pub const MAP_REMAPDUP: c_int = 0x004; +// minherit syscall inherit values +pub const MAP_INHERIT_SHARE: c_int = 0; +pub const MAP_INHERIT_COPY: c_int = 1; +pub const MAP_INHERIT_NONE: c_int = 2; +pub const MAP_INHERIT_DONATE_COPY: c_int = 3; +pub const MAP_INHERIT_ZERO: c_int = 4; + pub const DCCP_TYPE_REQUEST: c_int = 0; pub const DCCP_TYPE_RESPONSE: c_int = 1; pub const DCCP_TYPE_DATA: c_int = 2; @@ -1334,7 +1341,7 @@ cfg_if! { ptm_waiters: ptr::null_mut(), ptm_owner: 0, ptm_recursed: 0, - ptm_spare2: ptr::null_mut(), + ptm_spare2: Padding::new(ptr::null_mut()), }; } else { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { @@ -1344,7 +1351,7 @@ cfg_if! { ptm_waiters: ptr::null_mut(), ptm_owner: 0, ptm_recursed: 0, - ptm_spare2: ptr::null_mut(), + ptm_spare2: Padding::new(ptr::null_mut()), }; } } @@ -1869,7 +1876,7 @@ f! { } pub const safe fn WIFSTOPPED(status: c_int) -> bool { - (status & 0o177) == 0o177 + (status & 0o177) == 0o177 && !WIFCONTINUED(status) } pub const safe fn WIFCONTINUED(status: c_int) -> bool { @@ -1911,6 +1918,7 @@ extern "C" { pub fn chflags(path: *const c_char, flags: c_ulong) -> c_int; pub fn fchflags(fd: c_int, flags: c_ulong) -> c_int; pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int; + pub fn lchmod(path: *const c_char, mode: crate::mode_t) -> c_int; pub fn extattr_list_fd( fd: c_int, diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index 05c0cd55cb80d..d4832b0883484 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -17,7 +17,7 @@ s! { pub struct mcontext_t { pub __gregs: __gregset_t, pub __fregs: __fregset_t, - __spare: [crate::__greg_t; 7], + __spare: Padding<[crate::__greg_t; 7]>, } } diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 8b35121af917a..cd6f9854cfb20 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1102,6 +1102,12 @@ pub const MAP_NORESERVE: c_int = 0x0000; pub const MAP_HASSEMAPHORE: c_int = 0x0000; pub const MAP_TRYFIXED: c_int = 0; +// minherit syscall inherit values +pub const MAP_INHERIT_SHARE: c_int = 0; +pub const MAP_INHERIT_COPY: c_int = 1; +pub const MAP_INHERIT_NONE: c_int = 2; +pub const MAP_INHERIT_ZERO: c_int = 3; + pub const EIPSEC: c_int = 82; pub const ENOMEDIUM: c_int = 85; pub const EMEDIUMTYPE: c_int = 86; @@ -1338,6 +1344,8 @@ pub const NI_DGRAM: c_int = 16; pub const NI_MAXHOST: size_t = 256; pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_NODELETE: c_int = 0x400; +pub const RTLD_NOLOAD: c_int = 0x800; pub const CTL_MAXNAME: c_int = 12; @@ -1359,8 +1367,6 @@ pub const CTL_DDB: c_int = 9; pub const CTL_VFS: c_int = 10; pub const CTL_MAXID: c_int = 11; -pub const HW_NCPUONLINE: c_int = 25; - pub const KERN_OSTYPE: c_int = 1; pub const KERN_OSRELEASE: c_int = 2; pub const KERN_OSREV: c_int = 3; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index d3d1792135eae..2b2eca29b6d12 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -1,7 +1,10 @@ #![allow(dead_code)] -use crate::c_schar; use crate::prelude::*; +use crate::{ + c_schar, + ptrdiff_t, +}; // types pub type __s16_type = c_short; @@ -2634,43 +2637,80 @@ pub const TCP_REPAIR_OFF: c_int = 0; pub const TCP_REPAIR_OFF_NO_WP: c_int = -1; // stdint.h -pub const INT8_MIN: i8 = -128; -pub const INT16_MIN: i16 = -32768; -pub const INT32_MIN: i32 = -2147483648; -pub const INT8_MAX: i8 = 127; -pub const INT16_MAX: i16 = 32767; -pub const INT32_MAX: i32 = 2147483647; -pub const UINT8_MAX: u8 = 255; -pub const UINT16_MAX: u16 = 65535; -pub const UINT32_MAX: u32 = 4294967295; -pub const INT_LEAST8_MIN: int_least8_t = -128; -pub const INT_LEAST16_MIN: int_least16_t = -32768; -pub const INT_LEAST32_MIN: int_least32_t = -2147483648; -pub const INT_LEAST8_MAX: int_least8_t = 127; -pub const INT_LEAST16_MAX: int_least16_t = 32767; -pub const INT_LEAST32_MAX: int_least32_t = 2147483647; -pub const UINT_LEAST8_MAX: uint_least8_t = 255; -pub const UINT_LEAST16_MAX: uint_least16_t = 65535; -pub const UINT_LEAST32_MAX: uint_least32_t = 4294967295; -pub const INT_FAST8_MIN: int_fast8_t = -128; -pub const INT_FAST16_MIN: int_fast16_t = -2147483648; -pub const INT_FAST32_MIN: int_fast32_t = -2147483648; -pub const INT_FAST8_MAX: int_fast8_t = 127; -pub const INT_FAST16_MAX: int_fast16_t = 2147483647; -pub const INT_FAST32_MAX: int_fast32_t = 2147483647; -pub const UINT_FAST8_MAX: uint_fast8_t = 255; -pub const UINT_FAST16_MAX: uint_fast16_t = 4294967295; -pub const UINT_FAST32_MAX: uint_fast32_t = 4294967295; -pub const INTPTR_MIN: __intptr_t = -2147483648; -pub const INTPTR_MAX: __intptr_t = 2147483647; -pub const UINTPTR_MAX: usize = 4294967295; -pub const PTRDIFF_MIN: __ptrdiff_t = -2147483648; -pub const PTRDIFF_MAX: __ptrdiff_t = 2147483647; -pub const SIG_ATOMIC_MIN: __sig_atomic_t = -2147483648; -pub const SIG_ATOMIC_MAX: __sig_atomic_t = 2147483647; -pub const SIZE_MAX: usize = 4294967295; -pub const WINT_MIN: wint_t = 0; -pub const WINT_MAX: wint_t = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `i8::MIN` instead.")] +pub const INT8_MIN: i8 = i8::MIN; +#[deprecated(since = "0.2.190", note = "Use `i16::MIN` instead.")] +pub const INT16_MIN: i16 = i16::MIN; +#[deprecated(since = "0.2.190", note = "Use `i32::MIN` instead.")] +pub const INT32_MIN: i32 = i32::MIN; +#[deprecated(since = "0.2.190", note = "Use `i8::MAX` instead.")] +pub const INT8_MAX: i8 = i8::MAX; +#[deprecated(since = "0.2.190", note = "Use `i16::MAX` instead.")] +pub const INT16_MAX: i16 = i16::MAX; +#[deprecated(since = "0.2.190", note = "Use `i32::MAX` instead.")] +pub const INT32_MAX: i32 = i32::MAX; +#[deprecated(since = "0.2.190", note = "Use `u8::MAX` instead.")] +pub const UINT8_MAX: u8 = u8::MAX; +#[deprecated(since = "0.2.190", note = "Use `u16::MAX` instead.")] +pub const UINT16_MAX: u16 = u16::MAX; +#[deprecated(since = "0.2.190", note = "Use `u32::MAX` instead.")] +pub const UINT32_MAX: u32 = u32::MAX; +#[deprecated(since = "0.2.190", note = "Use `int_least8_t::MIN` instead.")] +pub const INT_LEAST8_MIN: int_least8_t = int_least8_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `int_least16_t::MIN` instead.")] +pub const INT_LEAST16_MIN: int_least16_t = int_least16_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `int_least32_t::MIN` instead.")] +pub const INT_LEAST32_MIN: int_least32_t = int_least32_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `int_least8_t::MAX` instead.")] +pub const INT_LEAST8_MAX: int_least8_t = int_least8_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `int_least16_t::MAX` instead.")] +pub const INT_LEAST16_MAX: int_least16_t = int_least16_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `int_least32_t::MAX` instead.")] +pub const INT_LEAST32_MAX: int_least32_t = int_least32_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `uint_least8_t::MAX` instead.")] +pub const UINT_LEAST8_MAX: uint_least8_t = uint_least8_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `uint_least16_t::MAX` instead.")] +pub const UINT_LEAST16_MAX: uint_least16_t = uint_least16_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `uint_least32_t::MAX` instead.")] +pub const UINT_LEAST32_MAX: uint_least32_t = uint_least32_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `int_fast8_t::MIN` instead.")] +pub const INT_FAST8_MIN: int_fast8_t = int_fast8_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `int_fast16_t::MIN` instead.")] +pub const INT_FAST16_MIN: int_fast16_t = int_fast16_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `int_fast32_t::MIN` instead.")] +pub const INT_FAST32_MIN: int_fast32_t = int_fast32_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `int_fast8_t::MAX` instead.")] +pub const INT_FAST8_MAX: int_fast8_t = int_fast8_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `int_fast16_t::MAX` instead.")] +pub const INT_FAST16_MAX: int_fast16_t = int_fast16_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `int_fast32_t::MAX` instead.")] +pub const INT_FAST32_MAX: int_fast32_t = int_fast32_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `uint_fast8_t::MAX` instead.")] +pub const UINT_FAST8_MAX: uint_fast8_t = uint_fast8_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `uint_fast16_t::MAX` instead.")] +pub const UINT_FAST16_MAX: uint_fast16_t = uint_fast16_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `uint_fast32_t::MAX` instead.")] +pub const UINT_FAST32_MAX: uint_fast32_t = uint_fast32_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `intptr_t::MIN` instead.")] +pub const INTPTR_MIN: intptr_t = intptr_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `intptr_t::MAX` instead.")] +pub const INTPTR_MAX: intptr_t = intptr_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `uintptr_t::MAX` instead.")] +pub const UINTPTR_MAX: uintptr_t = uintptr_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `ptrdiff_t::MIN` instead.")] +pub const PTRDIFF_MIN: ptrdiff_t = ptrdiff_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `ptrdiff_t::MAX` instead.")] +pub const PTRDIFF_MAX: ptrdiff_t = ptrdiff_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const SIG_ATOMIC_MIN: __sig_atomic_t = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const SIG_ATOMIC_MAX: __sig_atomic_t = c_int::MAX; +#[deprecated(since = "0.2.190", note = "Use `size_t::MAX` instead.")] +pub const SIZE_MAX: size_t = size_t::MAX; +#[deprecated(since = "0.2.190", note = "Use `wint_t::MIN` instead.")] +pub const WINT_MIN: wint_t = wint_t::MIN; +#[deprecated(since = "0.2.190", note = "Use `wint_t::MAX` instead.")] +pub const WINT_MAX: wint_t = wint_t::MAX; pub const INT8_WIDTH: usize = 8; pub const UINT8_WIDTH: usize = 8; pub const INT16_WIDTH: usize = 16; diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index 0fe599fe53141..789287b495031 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -31,7 +31,7 @@ s! { pub struct __c_anonymous_uc_sigmask_with_padding { pub uc_sigmask: crate::sigset_t, - /* Android has a wrong (smaller) sigset_t on x86. */ + /* Android has a wrong (smaller) sigset_t on ARM. */ __padding_rt_sigset: Padding, } diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index 056200313a33a..4f298d7041801 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -8,6 +8,9 @@ pub type off64_t = c_longlong; pub type sigset_t = c_ulong; pub type socklen_t = i32; pub type time64_t = i64; +// `struct stat64` is a synonym for `struct stat`, provided by Bionic for source +// compatibility with other systems. +pub type stat64 = stat; s! { // FIXME(1.0): This should not implement `PartialEq` @@ -24,6 +27,9 @@ s! { pub rlim_max: u64, } + // Note that the 32-bit `dev_t`, `ino_t`, `off_t` and `blkcnt_t` typedefs do + // not match the wider fields Bionic actually uses here, so they cannot be + // spelled with those aliases. pub struct stat { pub st_dev: c_ulonglong, __pad0: Padding<[c_uchar; 4]>, @@ -37,33 +43,11 @@ s! { pub st_size: c_longlong, pub st_blksize: crate::blksize_t, pub st_blocks: c_ulonglong, - pub st_atime: c_long, + pub st_atime: crate::time_t, pub st_atime_nsec: c_long, - pub st_mtime: c_long, + pub st_mtime: crate::time_t, 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: Padding<[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: Padding<[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: crate::time_t, pub st_ctime_nsec: c_long, pub st_ino: c_ulonglong, } diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index c8c48e5d90894..39918d2de2e1d 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -27,6 +27,7 @@ s! { __unused5: Padding, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -62,6 +63,9 @@ s! { pub uc_link: *mut ucontext_t, pub uc_stack: crate::stack_t, pub uc_sigmask: crate::sigset_t, + /* The kernel adds extra padding after uc_sigmask to match + * glibc sigset_t on ARM64. */ + __padding: Padding<[c_char; 128 - size_of::()]>, pub uc_mcontext: mcontext_t, } diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index a1f7c393998da..e3c14ee1d08ef 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -4,6 +4,7 @@ use crate::prelude::*; // but may be wrong for mips64 pub type mode_t = u32; +// FIXME(1.0,deprecate): lfs binding to be removed pub type off64_t = i64; pub type socklen_t = u32; @@ -21,6 +22,7 @@ s! { pub sa_restorer: Option, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct rlimit64 { pub rlim_cur: c_ulonglong, pub rlim_max: c_ulonglong, @@ -78,6 +80,7 @@ s! { pub _f: [c_char; 0], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct statfs64 { pub f_type: u64, pub f_bsize: u64, @@ -93,6 +96,7 @@ s! { pub f_spare: [u64; 4], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct statvfs64 { pub f_bsize: c_ulong, pub f_frsize: c_ulong, @@ -105,7 +109,7 @@ s! { pub f_fsid: c_ulong, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct pthread_barrier_t { @@ -135,6 +139,7 @@ s! { __reserved: Padding<[c_char; 36]>, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct sigset64_t { __bits: [c_ulong; 1], } diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index 12f87304e7420..2d68a99b5a73d 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -28,6 +28,7 @@ s! { __unused5: Padding, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, 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 de358edd5d41a..ef8a87970b9a9 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -25,6 +25,7 @@ s! { __unused: Padding<[c_long; 3]>, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 29dc9d3ed2ea0..7102140a26d3e 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -36,6 +36,7 @@ pub type nfds_t = c_uint; pub type rlim_t = c_ulong; pub type dev_t = c_ulong; pub type ino_t = c_ulong; +// FIXME(1.0,deprecate): lfs binding to be removed pub type ino64_t = u64; pub type __CPU_BITTYPE = c_ulong; pub type idtype_t = c_int; @@ -114,6 +115,7 @@ s! { pub l_pid: crate::pid_t, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct flock64 { pub l_type: c_short, pub l_whence: c_short, @@ -534,6 +536,7 @@ s! { pub d_name: [c_char; 256], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct dirent64 { pub d_ino: u64, pub d_off: i64, @@ -1839,8 +1842,6 @@ pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); pub const NLA_ALIGNTO: c_int = 4; -pub const SIGEV_THREAD_ID: c_int = 4; - pub const CIBAUD: crate::tcflag_t = 0o02003600000; pub const CBAUDEX: crate::tcflag_t = 0o010000; @@ -1980,7 +1981,7 @@ pub const NF_BR_POST_ROUTING: c_int = 4; pub const NF_BR_BROUTING: c_int = 5; pub const NF_BR_NUMHOOKS: c_int = 6; -pub const NF_BR_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_BR_PRI_FIRST: c_int = c_int::MIN; pub const NF_BR_PRI_NAT_DST_BRIDGED: c_int = -300; pub const NF_BR_PRI_FILTER_BRIDGED: c_int = -200; pub const NF_BR_PRI_BRNF: c_int = 0; @@ -1990,7 +1991,7 @@ pub const NF_BR_PRI_NAT_SRC: c_int = 300; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_BR_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv4.h pub const NF_IP_PRE_ROUTING: c_int = 0; @@ -2000,7 +2001,7 @@ pub const NF_IP_LOCAL_OUT: c_int = 3; pub const NF_IP_POST_ROUTING: c_int = 4; pub const NF_IP_NUMHOOKS: c_int = 5; -pub const NF_IP_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP_PRI_FIRST: c_int = c_int::MIN; pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: c_int = -450; pub const NF_IP_PRI_CONNTRACK_DEFRAG: c_int = -400; pub const NF_IP_PRI_RAW: c_int = -300; @@ -2013,11 +2014,11 @@ pub const NF_IP_PRI_SECURITY: c_int = 50; pub const NF_IP_PRI_NAT_SRC: c_int = 100; pub const NF_IP_PRI_SELINUX_LAST: c_int = 225; pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300; -pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = c_int::MAX; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_IP_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv6.h pub const NF_IP6_PRE_ROUTING: c_int = 0; @@ -2027,7 +2028,7 @@ pub const NF_IP6_LOCAL_OUT: c_int = 3; pub const NF_IP6_POST_ROUTING: c_int = 4; pub const NF_IP6_NUMHOOKS: c_int = 5; -pub const NF_IP6_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP6_PRI_FIRST: c_int = c_int::MIN; pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: c_int = -450; pub const NF_IP6_PRI_CONNTRACK_DEFRAG: c_int = -400; pub const NF_IP6_PRI_RAW: c_int = -300; @@ -2043,7 +2044,7 @@ pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_IP6_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv6/ip6_tables.h pub const IP6T_SO_ORIGINAL_DST: c_int = 80; @@ -3510,7 +3511,9 @@ extern "C" { pub fn setgrent(); pub fn endgrent(); pub fn getgrent() -> *mut crate::group; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn getrlimit64(resource: c_int, rlim: *mut rlimit64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; @@ -3520,6 +3523,7 @@ extern "C" { new_limit: *const crate::rlimit, old_limit: *mut crate::rlimit, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn prlimit64( pid: crate::pid_t, resource: c_int, @@ -3580,8 +3584,10 @@ extern "C" { pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); pub fn telldir(dirp: *mut crate::DIR) -> c_long; pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; pub fn getxattr( path: *const c_char, @@ -3738,6 +3744,7 @@ extern "C" { param: *const crate::sched_param, ) -> c_int; pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn sendfile64(out_fd: c_int, in_fd: c_int, offset: *mut off64_t, count: size_t) -> ssize_t; pub fn setfsgid(gid: crate::gid_t) -> c_int; pub fn setfsuid(uid: crate::uid_t) -> c_int; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 184e3958e3d03..6d1d9f27d1da2 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -28,20 +28,39 @@ pub type fsfilcnt_t = u32; pub type rlim_t = u64; pub type nlink_t = u32; -pub type ino64_t = crate::ino_t; +// FIXME(1.0,deprecate): lfs binding to be removed +pub type ino64_t = ino_t; + +// FIXME(1.0,deprecate): lfs binding to be removed pub type off64_t = off_t; -pub type blkcnt64_t = crate::blkcnt_t; -pub type rlim64_t = crate::rlim_t; +//FIXME(1.0,deprecate): lfs binding to be removed +pub type blkcnt64_t = blkcnt_t; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type rlim64_t = rlim_t; + +//FIXME(1.0,deprecate): lfs binding to be removed pub type rlimit64 = crate::rlimit; -pub type flock64 = crate::flock; -pub type stat64 = crate::stat; -pub type statfs64 = crate::statfs; -pub type statvfs64 = crate::statvfs; -pub type dirent64 = crate::dirent; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type flock64 = flock; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type stat64 = stat; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type statfs64 = statfs; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type statvfs64 = statvfs; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type dirent64 = dirent; extern_ty! { - pub type fpos64_t; // FIXME(emscripten): fill this out with a struct + //FIXME(1.0,deprecate): lfs binding to be removed + pub type fpos64_t; } s! { @@ -93,7 +112,7 @@ s! { __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct signalfd_siginfo { @@ -788,6 +807,8 @@ pub const O_TRUNC: c_int = 512; pub const O_NOATIME: c_int = 0o1000000; pub const O_CLOEXEC: c_int = 0x80000; +pub const EPOLL_CLOEXEC: c_int = 0x80000; + // Defined as wasi value. pub const EPERM: c_int = 63; pub const ENOENT: c_int = 44; @@ -1458,8 +1479,26 @@ extern "C" { timeout: *const crate::timespec, ) -> c_int; pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn epoll_create(size: c_int) -> c_int; + pub fn epoll_create1(flags: c_int) -> c_int; + pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; + pub fn epoll_wait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + ) -> c_int; + pub fn epoll_pwait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + sigmask: *const crate::sigset_t, + ) -> c_int; } // Alias to 64 to mimic glibc's LFS64 support mod lfs64; + +// FIXME(1.0,deprecate): lfs bindings to be removed pub use self::lfs64::*; diff --git a/src/unix/linux_like/l4re/mod.rs b/src/unix/linux_like/l4re/mod.rs index 5ac4868f7d1c2..b3c768623f7f7 100644 --- a/src/unix/linux_like/l4re/mod.rs +++ b/src/unix/linux_like/l4re/mod.rs @@ -10,10 +10,6 @@ pub type pthread_t = *mut c_void; pub type dev_t = u64; pub type socklen_t = u32; pub type mode_t = u32; -pub type ino64_t = u64; -pub type off64_t = i64; -pub type blkcnt64_t = i64; -pub type rlim64_t = u64; pub type nfds_t = c_ulong; pub type nl_item = c_int; pub type idtype_t = c_uint; @@ -22,6 +18,40 @@ pub type pthread_key_t = c_uint; pub type pthread_once_t = c_int; pub type pthread_spinlock_t = c_int; +#[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `ino_t` instead. LFS is being phased out, see rust-lang/libc#4805." + ) +)] +pub type ino64_t = u64; +#[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `off_t` instead. LFS is being phased out, see rust-lang/libc#4805." + ) +)] +pub type off64_t = i64; +#[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `blkcnt_t` instead. LFS is being phased out, see + rust-lang/libc#4805." + ) +)] +pub type blkcnt64_t = i64; +#[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `rlim_t` instead. LFS is being phased out, see rust-lang/libc#4805." + ) +)] +pub type rlim64_t = u64; + s! { /// CPU sets. pub struct l4_sched_cpu_set_t { diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index 06add53ad9eae..cced9a7be4408 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -1,4 +1,3 @@ -use crate::off64_t; use crate::prelude::*; pub type shmatt_t = c_ulong; @@ -10,6 +9,12 @@ pub type __priority_which_t = c_uint; pub type _pthread_descr = *mut c_void; pub type __pthread_cond_align_t = c_long; +#[cfg(target_pointer_width = "64")] +pub type __sword_type = c_long; + +#[cfg(target_pointer_width = "32")] +pub type __sword_type = c_int; + cfg_if! { if #[cfg(doc)] { // Used in `linux::arch` to define ioctl constants. @@ -44,48 +49,33 @@ s! { } pub struct statfs { - pub f_type: fsword_t, - pub f_bsize: fsword_t, + pub f_type: __sword_type, + pub f_bsize: __sword_type, 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_fsid: crate::fsid_t, - pub f_namelen: fsword_t, - pub f_frsize: fsword_t, - pub f_flags: fsword_t, - pub f_spare: [fsword_t; 4], + pub f_namelen: __sword_type, + pub f_frsize: __sword_type, + pub f_flags: __sword_type, + pub f_spare: [__sword_type; 4], } pub struct statfs64 { - pub f_type: fsword_t, - pub f_bsize: fsword_t, + pub f_type: __sword_type, + pub f_bsize: __sword_type, pub f_blocks: crate::fsblkcnt64_t, pub f_bfree: crate::fsblkcnt64_t, pub f_bavail: crate::fsblkcnt64_t, pub f_files: crate::fsfilcnt64_t, pub f_ffree: crate::fsfilcnt64_t, pub f_fsid: crate::fsid_t, - pub f_namelen: fsword_t, - pub f_frsize: fsword_t, - pub f_flags: fsword_t, - pub f_spare: [fsword_t; 4], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsfilcnt64_t, - pub f_bfree: crate::fsfilcnt64_t, - pub f_bavail: crate::fsfilcnt64_t, - pub f_files: crate::fsfilcnt64_t, - pub f_ffree: crate::fsfilcnt64_t, - pub f_favail: crate::fsfilcnt64_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], + pub f_namelen: __sword_type, + pub f_frsize: __sword_type, + pub f_flags: __sword_type, + pub f_spare: [__sword_type; 4], } pub struct ipc_perm { @@ -99,11 +89,11 @@ s! { #[cfg(target_pointer_width = "64")] pub mode: c_uint, #[cfg(target_pointer_width = "32")] - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct statvfs { @@ -116,15 +106,30 @@ s! { pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, pub f_favail: crate::fsfilcnt_t, - #[cfg(target_endian = "little")] pub f_fsid: c_ulong, #[cfg(target_pointer_width = "32")] - __f_unused: c_int, - #[cfg(target_endian = "big")] + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: Padding<[c_int; 6]>, + } + + pub struct statvfs64 { + // Different than GNU! + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_favail: crate::fsfilcnt64_t, pub f_fsid: c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct sysinfo { @@ -232,7 +237,7 @@ s! { pub struct pthread_cond_t { __c_lock: _pthread_fastlock, __c_waiting: _pthread_descr, - __padding: [u8; PTHREAD_COND_PADDING_SIZE], + __padding: Padding<[u8; PTHREAD_COND_PADDING_SIZE]>, __align: __pthread_cond_align_t, } @@ -241,7 +246,7 @@ s! { } pub struct pthread_mutex_t { - __m_reserved: c_int, + __m_reserved: Padding, __m_count: c_int, __m_owner: _pthread_descr, __m_kind: c_int, @@ -300,8 +305,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } } @@ -386,8 +391,6 @@ pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; -pub const SIGEV_THREAD_ID: c_int = 4; - pub const AF_VSOCK: c_int = 40; pub const POSIX_FADV_DONTNEED: c_int = 4; @@ -412,6 +415,8 @@ pub const ENOTSUP: c_int = EOPNOTSUPP; pub const IPV6_JOIN_GROUP: c_int = 20; pub const IPV6_LEAVE_GROUP: c_int = 21; +pub const IPPROTO_MAX: c_int = 256; + // Different than Gnu. pub const FILENAME_MAX: c_uint = 4095; @@ -479,7 +484,7 @@ pub const __LOCK_INITIALIZER: _pthread_fastlock = _pthread_fastlock { }; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __m_reserved: 0, + __m_reserved: Padding::new(0), __m_count: 0, __m_owner: ptr::null_mut(), __m_kind: PTHREAD_MUTEX_TIMED_NP, @@ -494,7 +499,7 @@ const PTHREAD_COND_PADDING_SIZE: usize = 48 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __c_lock: __LOCK_INITIALIZER, __c_waiting: ptr::null_mut(), - __padding: [0; PTHREAD_COND_PADDING_SIZE], + __padding: Padding::new([0; PTHREAD_COND_PADDING_SIZE]), __align: 0, }; @@ -538,10 +543,26 @@ extern "C" { flags: c_int, ) -> c_int; - pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; - pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; - + 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; + + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `getrlimit` instead. LFS is being phased out, see rust-lang/libc#4805." + ), + allow(deprecated) + )] pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `setrlimit` instead. LFS is being phased out, see rust-lang/libc#4805." + ), + allow(deprecated) + )] pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) -> c_int; pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; diff --git a/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs b/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs index ed62740e99ed6..b6ae57d870571 100644 --- a/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs @@ -11,13 +11,22 @@ pub type fsfilcnt_t = c_ulong; pub type ino_t = c_ulong; pub type nlink_t = c_ulong; pub type off_t = c_long; +#[deprecated(since = "0.2.190", note = "Use `__sword_type` instead.")] pub type fsword_t = c_long; pub type suseconds_t = c_long; pub type blksize_t = c_long; pub type blkcnt_t = c_long; +#[deprecated( + since = "0.2.190", + note = "Use `fsblkcnt_t` instead. LFS is being phased out, see rust-lang/libc#4805." +)] pub type fsblkcnt64_t = c_ulong; +#[deprecated( + since = "0.2.190", + note = "Use `fsfilcnt_t` instead. LFS is being phased out, see rust-lang/libc#4805." +)] pub type fsfilcnt64_t = c_ulong; pub type __u32 = c_uint; @@ -25,41 +34,39 @@ pub type __u64 = c_ulong; s! { pub struct stat { - pub st_dev: c_ulong, + pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, - // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of - // nlink and mode are swapped on 64 bit systems. pub st_nlink: 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: c_ulong, + __pad0: Padding, + pub st_rdev: crate::dev_t, pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, + pub st_blocks: crate::blkcnt_t, pub st_atim: crate::timespec, pub st_mtim: crate::timespec, pub st_ctim: crate::timespec, - __uclibc_unused: [c_long; 3], + __uclibc_unused: Padding<[c_long; 3]>, } pub struct stat64 { - pub st_dev: c_ulong, + pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, pub st_nlink: 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: c_ulong, + __pad0: Padding, + pub st_rdev: crate::dev_t, pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, + pub st_blocks: crate::blkcnt_t, pub st_atim: crate::timespec, pub st_mtim: crate::timespec, pub st_ctim: crate::timespec, - st_pad4: [c_long; 3], + __uclibc_unused: Padding<[c_long; 3]>, } #[allow(unpredictable_function_pointer_comparisons)] @@ -96,6 +103,14 @@ s! { pub l_pid: crate::pid_t, } + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + pub struct termios { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, 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 84503af35e23a..bec3d1083093e 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -7,15 +7,6 @@ use crate::{ pub type wchar_t = u32; 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, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -30,7 +21,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { @@ -112,22 +103,6 @@ s! { pub f_spare: [crate::__fsword_t; 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, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, @@ -167,21 +142,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -370,9 +330,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -396,29 +353,6 @@ pub const F_SETOWN: c_int = 8; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -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 SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; pub const CBAUD: crate::tcflag_t = 0o0010017; diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 5a9ca13b2bc54..c754ec000ea4c 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -7,15 +7,6 @@ use crate::{ pub type wchar_t = u32; 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, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -29,7 +20,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { @@ -99,22 +90,6 @@ s! { pub f_spare: [crate::__fsword_t; 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, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, @@ -148,21 +123,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -296,9 +256,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -316,29 +273,6 @@ pub const F_SETOWN: c_int = 8; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -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 SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; pub const CBAUD: crate::tcflag_t = 0o0010017; diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index 323f7b56c3002..ec5a057cddf55 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -7,15 +7,6 @@ use crate::{ pub type wchar_t = i32; 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, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -30,7 +21,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { @@ -99,22 +90,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt64_t, - pub f_bfree: crate::fsblkcnt64_t, - pub f_bavail: crate::fsblkcnt64_t, - pub f_files: crate::fsblkcnt64_t, - pub f_ffree: crate::fsblkcnt64_t, - pub f_favail: crate::fsblkcnt64_t, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, @@ -148,14 +123,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -289,9 +256,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -314,29 +278,6 @@ pub const POLLWRBAND: c_short = 0x200; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -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 SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; pub const CBAUD: crate::tcflag_t = 0o0010017; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 936551c2bcbbb..a4cc330710db7 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -132,7 +132,7 @@ s! { pub f_namelen: c_long, pub f_flags: c_long, - f_spare: [c_long; 5], + f_spare: Padding<[c_long; 5]>, } pub struct statfs64 { @@ -150,45 +150,12 @@ s! { pub f_spare: [c_long; 5], } - 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, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - // 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, - _resv: [c_int; 1], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_size: size_t, pub ss_flags: c_int, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - pub _pad: [c_int; 29], - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -765,33 +732,6 @@ pub const MAP_STACK: c_int = 0x40000; pub const SOCK_STREAM: c_int = 2; pub const SOCK_DGRAM: c_int = 1; -pub const SA_SIGINFO: c_int = 0x00000008; -pub const SA_NOCLDWAIT: c_int = 0x00010000; - -pub const SIGEMT: c_int = 7; -pub const SIGCHLD: c_int = 18; -pub const SIGBUS: c_int = 10; -pub const SIGTTIN: c_int = 26; -pub const SIGTTOU: c_int = 27; -pub const SIGXCPU: c_int = 30; -pub const SIGXFSZ: c_int = 31; -pub const SIGVTALRM: c_int = 28; -pub const SIGPROF: c_int = 29; -pub const SIGWINCH: c_int = 20; -pub const SIGUSR1: c_int = 16; -pub const SIGUSR2: c_int = 17; -pub const SIGCONT: c_int = 25; -pub const SIGSTOP: c_int = 23; -pub const SIGTSTP: c_int = 24; -pub const SIGURG: c_int = 21; -pub const SIGIO: c_int = 22; -pub const SIGSYS: c_int = 12; -pub const SIGPOLL: c_int = 22; -pub const SIGPWR: c_int = 19; -pub const SIG_SETMASK: c_int = 3; -pub const SIG_BLOCK: c_int = 0x1; -pub const SIG_UNBLOCK: c_int = 0x2; - pub const POLLWRNORM: c_short = 0x004; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 6363132fde03a..e86b0c469475c 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -125,22 +125,6 @@ cfg_if! { } s! { - 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, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct pthread_attr_t { __size: [u32; 9], } @@ -299,8 +283,6 @@ cfg_if! { pub const O_PATH: c_int = 0x1000000; pub const O_TMPFILE: c_int = 0x2000000 | O_DIRECTORY; - pub const SA_ONSTACK: c_int = 1; - pub const PTRACE_DETACH: c_uint = 11; pub const F_RDLCK: c_int = 1; @@ -329,11 +311,6 @@ cfg_if! { pub const EPROTO: c_int = 86; pub const EDOTDOT: c_int = 88; - pub const SA_NODEFER: c_int = 0x20; - pub const SA_RESETHAND: c_int = 0x4; - pub const SA_RESTART: c_int = 0x2; - pub const SA_NOCLDSTOP: c_int = 0x00000008; - pub const EPOLL_CLOEXEC: c_int = 0x400000; pub const EFD_CLOEXEC: c_int = 0x400000; @@ -342,8 +319,6 @@ cfg_if! { pub const O_PATH: c_int = 0o10000000; pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; - pub const SA_ONSTACK: c_int = 0x08000000; - pub const PTRACE_DETACH: c_uint = 17; pub const F_RDLCK: c_int = 0; @@ -371,11 +346,6 @@ cfg_if! { pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; - pub const SA_NODEFER: c_int = 0x40000000; - pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); - pub const SA_RESTART: c_int = 0x10000000; - pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index ac946d0ac3dd8..30f85c9fb6885 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -7,15 +7,6 @@ use crate::{ pub type wchar_t = i32; 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, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -30,7 +21,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { @@ -141,22 +132,6 @@ s! { pub f_spare: [crate::__fsword_t; 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, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, #[cfg(gnu_time_bits64)] @@ -201,21 +176,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -345,9 +305,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -371,29 +328,6 @@ pub const F_SETOWN: c_int = 8; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -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 SIGSTKSZ: size_t = 0x4000; pub const MINSIGSTKSZ: size_t = 4096; pub const CBAUD: crate::tcflag_t = 0xff; diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 5484a68bd1ec1..610fa4065ba6e 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -75,51 +75,12 @@ s! { pub f_spare: [c_long; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt64_t, - pub f_bfree: crate::fsblkcnt64_t, - pub f_bavail: crate::fsblkcnt64_t, - pub f_files: crate::fsfilcnt64_t, - pub f_ffree: crate::fsfilcnt64_t, - pub f_favail: crate::fsfilcnt64_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], - } - - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, pub ss_size: size_t, } - // 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, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -335,31 +296,6 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_SIGINFO: c_int = 4; -pub const SA_NOCLDWAIT: c_int = 2; -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 SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0; -pub const SIG_UNBLOCK: c_int = 1; pub const POLLWRNORM: c_short = 256; pub const POLLWRBAND: c_short = 512; pub const O_ASYNC: c_int = 8192; diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 4cee14cc5d340..95ad74af2e4c4 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -9,15 +9,6 @@ use crate::{ pub type wchar_t = i32; 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, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -32,15 +23,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], - } - - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { @@ -127,22 +110,6 @@ s! { pub f_spare: [crate::__fsword_t; 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, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -316,33 +283,6 @@ pub const ERFKILL: c_int = 134; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_SIGINFO: c_int = 0x200; -pub const SA_NOCLDWAIT: c_int = 0x100; - -pub const SIGEMT: c_int = 7; -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 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 SIGPOLL: c_int = 23; -pub const SIGPWR: c_int = 29; -pub const SIG_SETMASK: c_int = 4; -pub const SIG_BLOCK: c_int = 1; -pub const SIG_UNBLOCK: c_int = 2; - pub const POLLWRNORM: c_short = 4; pub const POLLWRBAND: c_short = 0x100; 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 52919b02c5b94..cbfae20a68a97 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -8,15 +8,6 @@ pub type wchar_t = i32; pub type greg_t = i32; 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, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -31,7 +22,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { @@ -186,22 +177,6 @@ s! { pub f_spare: [crate::__fsword_t; 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, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, @@ -241,21 +216,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -416,9 +376,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -447,29 +404,6 @@ pub const POLLWRBAND: c_short = 0x200; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -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 SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; pub const CBAUD: crate::tcflag_t = 0o0010017; 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 e294f1f132bed..714e609b88b6d 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -12,17 +12,6 @@ pub type blksize_t = i32; pub type suseconds_t = i64; 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, - #[cfg(target_arch = "sparc64")] - __reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -36,7 +25,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { @@ -114,36 +103,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - 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_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - 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_attr_t { __size: [usize; 8], } @@ -181,21 +140,6 @@ s! { __unused5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -361,34 +305,6 @@ pub const POSIX_FADV_NOREUSE: c_int = 5; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - -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 SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; @@ -437,11 +353,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index b02be364a6a30..7cea157c63d16 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -101,70 +101,16 @@ s! { pub l_pid: crate::pid_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_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - 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_attr_t { __size: [c_ulong; 7], } - // 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, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, pub ss_size: size_t, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [u64; 0], - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -724,36 +670,6 @@ pub const SOCK_DGRAM: c_int = 2; pub const SFD_NONBLOCK: c_int = 0x800; pub const SFD_CLOEXEC: c_int = 0x080000; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; -pub const SIG_BLOCK: c_int = 0; -pub const SIG_UNBLOCK: c_int = 1; -pub const SIG_SETMASK: c_int = 2; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGSTKFLT: c_int = 16; -pub const SIGCHLD: c_int = 17; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -pub const SIGURG: 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 SIGIO: c_int = 29; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIGSYS: c_int = 31; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index e5aea2547156c..07fe19471b76d 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -46,7 +46,7 @@ s! { pub f_fsid: crate::fsid_t, pub f_namelen: c_long, - f_spare: [c_long; 6], + f_spare: Padding<[c_long; 6]>, } pub struct flock { @@ -103,63 +103,16 @@ s! { pub f_spare: [c_long; 5], } - 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_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - 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_attr_t { __size: [c_ulong; 7], } - // 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, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_size: size_t, pub ss_flags: c_int, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - _pad: Padding, - _pad2: Padding<[c_long; 14]>, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -581,11 +534,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; @@ -708,34 +656,6 @@ pub const MAP_HUGETLB: c_int = 0x080000; pub const SOCK_STREAM: c_int = 2; pub const SOCK_DGRAM: c_int = 1; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000008; -pub const SA_NOCLDWAIT: c_int = 0x00010000; - -pub const SIGEMT: c_int = 7; -pub const SIGCHLD: c_int = 18; -pub const SIGBUS: c_int = 10; -pub const SIGTTIN: c_int = 26; -pub const SIGTTOU: c_int = 27; -pub const SIGXCPU: c_int = 30; -pub const SIGXFSZ: c_int = 31; -pub const SIGVTALRM: c_int = 28; -pub const SIGPROF: c_int = 29; -pub const SIGWINCH: c_int = 20; -pub const SIGUSR1: c_int = 16; -pub const SIGUSR2: c_int = 17; -pub const SIGCONT: c_int = 25; -pub const SIGSTOP: c_int = 23; -pub const SIGTSTP: c_int = 24; -pub const SIGURG: c_int = 21; -pub const SIGIO: c_int = 22; -pub const SIGSYS: c_int = 12; -pub const SIGPOLL: c_int = 22; -pub const SIGPWR: c_int = 19; -pub const SIG_SETMASK: c_int = 3; -pub const SIG_BLOCK: c_int = 0x1; -pub const SIG_UNBLOCK: c_int = 0x2; - pub const POLLWRNORM: c_short = 0x004; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 51f71a8402a76..ecccfdb48cd44 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -14,17 +14,6 @@ pub type gregset_t = [c_ulong; __NGREG]; pub type fpregset_t = [c_ulong; __NFPREG]; 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, - #[cfg(target_arch = "sparc64")] - __reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -38,7 +27,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { @@ -114,36 +103,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - 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_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - 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_attr_t { __size: [u64; 7], } @@ -174,21 +133,6 @@ s! { __unused5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -396,34 +340,6 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - -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 SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; @@ -476,11 +392,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 3371f0337e498..d58948c951df9 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -93,66 +93,12 @@ s! { pub f_spare: [c_long; 4], } - 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_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt64_t, - pub f_bfree: crate::fsblkcnt64_t, - pub f_bavail: crate::fsblkcnt64_t, - pub f_files: crate::fsfilcnt64_t, - pub f_ffree: crate::fsfilcnt64_t, - pub f_favail: crate::fsfilcnt64_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], - } - - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, pub ss_size: size_t, } - // 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, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -392,32 +338,6 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 134217728; -pub const SA_SIGINFO: c_int = 4; -pub const SA_NOCLDWAIT: c_int = 2; -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 SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0; -pub const SIG_UNBLOCK: c_int = 1; pub const POLLWRNORM: c_short = 256; pub const POLLWRBAND: c_short = 512; pub const O_ASYNC: c_int = 8192; @@ -457,10 +377,6 @@ pub const ESRMNT: c_int = 69; pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 1073741824; -pub const SA_RESETHAND: c_int = -2147483648; -pub const SA_RESTART: c_int = 268435456; -pub const SA_NOCLDSTOP: c_int = 1; pub const EPOLL_CLOEXEC: c_int = 524288; pub const EFD_CLOEXEC: c_int = 524288; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 2c54c68d2b82a..1dcc87aa8d0ae 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -13,16 +13,6 @@ pub type wchar_t = i32; pub type greg_t = u64; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - __glibc_reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - pub sa_mask: crate::sigset_t, - } - pub struct statfs { pub f_type: c_uint, pub f_bsize: c_uint, @@ -35,7 +25,7 @@ s! { pub f_namelen: c_uint, pub f_frsize: c_uint, pub f_flags: c_uint, - f_spare: [c_uint; 4], + f_spare: Padding<[c_uint; 4]>, } pub struct flock { @@ -54,14 +44,6 @@ s! { pub l_pid: crate::pid_t, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding, - _pad2: Padding<[c_long; 14]>, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -140,21 +122,6 @@ s! { __unused5: Padding, } - 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_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct __psw_t { pub mask: u64, pub addr: u64, @@ -195,21 +162,6 @@ s! { pub f_flags: c_uint, pub f_spare: [c_uint; 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], - } } s_no_extra_traits! { @@ -278,11 +230,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; @@ -312,13 +259,8 @@ pub const O_APPEND: c_int = 1024; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; pub const O_NONBLOCK: c_int = 2048; -pub const SA_NOCLDWAIT: c_int = 2; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 4; -pub const SIGBUS: c_int = 7; pub const SIGSTKSZ: size_t = 0x2000; pub const MINSIGSTKSZ: size_t = 2048; -pub const SIG_SETMASK: c_int = 2; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -417,28 +359,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -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 SIGCHLD: c_int = 17; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; - pub const O_ASYNC: c_int = 0x2000; pub const O_NDELAY: c_int = 0x800; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index e58bfd33f849d..80c5528892b3c 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -12,17 +12,6 @@ pub type blksize_t = i64; pub type suseconds_t = i32; 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, - #[cfg(target_arch = "sparc64")] - __reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -36,22 +25,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], - } - - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [usize; 0], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { @@ -136,36 +110,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - 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_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - 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_attr_t { __size: [u64; 7], } @@ -321,34 +265,6 @@ pub const ERFKILL: c_int = 134; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 1; -pub const SA_SIGINFO: c_int = 0x200; -pub const SA_NOCLDWAIT: c_int = 0x100; - -pub const SIGEMT: c_int = 7; -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 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 SIGPOLL: c_int = 23; -pub const SIGPWR: c_int = 29; -pub const SIG_SETMASK: c_int = 4; -pub const SIG_BLOCK: c_int = 1; -pub const SIG_UNBLOCK: c_int = 2; - pub const POLLWRNORM: c_short = 4; pub const POLLWRBAND: c_short = 0x100; @@ -400,11 +316,6 @@ pub const ECOMM: c_int = 85; pub const EPROTO: c_int = 86; pub const EDOTDOT: c_int = 88; -pub const SA_NODEFER: c_int = 0x20; -pub const SA_RESETHAND: c_int = 0x4; -pub const SA_RESTART: c_int = 0x2; -pub const SA_NOCLDSTOP: c_int = 0x00000008; - pub const EPOLL_CLOEXEC: c_int = 0x400000; pub const EFD_CLOEXEC: c_int = 0x400000; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 8c5f3e5a1800d..1f3209f529f5f 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -13,17 +13,6 @@ pub type greg_t = i64; pub type suseconds_t = i64; 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, - #[cfg(target_arch = "sparc64")] - __reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -37,7 +26,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { @@ -56,21 +45,6 @@ s! { pub l_pid: crate::pid_t, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -134,21 +108,6 @@ s! { pub f_spare: [crate::__fsword_t; 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_attr_t { #[cfg(target_pointer_width = "32")] __size: [u32; 8], @@ -426,34 +385,6 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - -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 SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; @@ -507,11 +438,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; 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 4c179540436b6..f95bb8729d01b 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 @@ -1,22 +1,5 @@ use crate::prelude::*; -s! { - 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_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } -} - pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; 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 183eccc43f5e0..41b77f64c1dfc 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 @@ -1,22 +1,5 @@ use crate::prelude::*; -s! { - 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_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } -} - pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 44; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index b8c62331fa608..297ec8e959bb5 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -430,32 +430,6 @@ s! { } } -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_void { - #[repr(C)] - struct siginfo_sigfault { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - si_addr: *mut c_void, - } - (*(self as *const siginfo_t).cast::()).si_addr - } - - pub unsafe fn si_value(&self) -> crate::sigval { - #[repr(C)] - struct siginfo_timer { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - _si_tid: c_int, - _si_overrun: c_int, - si_sigval: crate::sigval, - } - (*(self as *const siginfo_t).cast::()).si_sigval - } -} - s_no_extra_traits! { // linux/if_ether.h @@ -465,55 +439,6 @@ s_no_extra_traits! { pub h_source: [c_uchar; crate::ETH_ALEN as usize], pub h_proto: crate::__be16, } - - // Internal, for casts to access union fields - struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, - } - - // Internal, for casts to access union fields - union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, - } - - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, - } -} - -impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t).cast::()).sifields - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - self.sifields().sigchld.si_pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - self.sifields().sigchld.si_uid - } - - pub unsafe fn si_status(&self) -> c_int { - self.sifields().sigchld.si_status - } - - pub unsafe fn si_utime(&self) -> c_long { - self.sifields().sigchld.si_utime - } - - pub unsafe fn si_stime(&self) -> c_long { - self.sifields().sigchld.si_stime - } } s_no_extra_traits! { @@ -679,8 +604,6 @@ pub const PF_NFC: c_int = AF_NFC; pub const PF_VSOCK: c_int = AF_VSOCK; pub const PF_XDP: c_int = AF_XDP; -pub const SIGEV_THREAD_ID: c_int = 4; - pub const BUFSIZ: c_uint = 8192; pub const TMP_MAX: c_uint = 238328; pub const FOPEN_MAX: c_uint = 16; @@ -768,19 +691,6 @@ pub const O_ACCMODE: c_int = 3; pub const ST_RELATIME: c_ulong = 4096; pub const NI_MAXHOST: crate::socklen_t = 1025; -// 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. -cfg_if! { - if #[cfg(not(target_arch = "s390x"))] { - pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; - pub const XFS_SUPER_MAGIC: c_long = 0x58465342; - } else if #[cfg(target_arch = "s390x")] { - pub const BINDERFS_SUPER_MAGIC: c_uint = 0x6c6f6f70; - pub const XFS_SUPER_MAGIC: c_uint = 0x58465342; - } -} - pub const CPU_SETSIZE: c_int = 0x400; pub const PTRACE_TRACEME: c_uint = 0; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index ed3ac804ef6eb..7ed918f41eff7 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -387,7 +387,7 @@ s! { pub t: ptp_clock_time, index: c_uint, flags: c_uint, - rsv: [c_uint; 2], + rsv: Padding<[c_uint; 2]>, } // linux/wireless.h @@ -1011,7 +1011,7 @@ s! { } cfg_if! { - if #[cfg(not(target_env = "gnu"))] { + if #[cfg(not(any(target_env = "gnu", target_env = "uclibc")))] { extern_ty! { // FIXME(1.0,deprecate): lfs binding to be removed pub type fpos64_t; // FIXME(linux): fill this out with a struct @@ -1326,6 +1326,11 @@ pub const IPV6_FREEBIND: c_int = 78; pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x000fffff; pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0ff00000; +// netinet/in.h +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +pub const IPPROTO_MAX: c_int = 263; + // SO_MEMINFO offsets pub const SK_MEMINFO_RMEM_ALLOC: c_int = 0; pub const SK_MEMINFO_RCVBUF: c_int = 1; @@ -1471,6 +1476,7 @@ pub const ETH_P_AOE: c_int = 0x88A2; pub const ETH_P_8021AD: c_int = 0x88A8; pub const ETH_P_802_EX1: c_int = 0x88B5; pub const ETH_P_TIPC: c_int = 0x88CA; +pub const ETH_P_LLDP: c_int = 0x88CC; pub const ETH_P_MACSEC: c_int = 0x88E5; pub const ETH_P_8021AH: c_int = 0x88E7; pub const ETH_P_MVRP: c_int = 0x88F5; @@ -1775,7 +1781,7 @@ pub const NF_BR_POST_ROUTING: c_int = 4; pub const NF_BR_BROUTING: c_int = 5; pub const NF_BR_NUMHOOKS: c_int = 6; -pub const NF_BR_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_BR_PRI_FIRST: c_int = c_int::MIN; pub const NF_BR_PRI_NAT_DST_BRIDGED: c_int = -300; pub const NF_BR_PRI_FILTER_BRIDGED: c_int = -200; pub const NF_BR_PRI_BRNF: c_int = 0; @@ -1785,7 +1791,7 @@ pub const NF_BR_PRI_NAT_SRC: c_int = 300; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_BR_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv4.h pub const NF_IP_PRE_ROUTING: c_int = 0; @@ -1795,7 +1801,7 @@ pub const NF_IP_LOCAL_OUT: c_int = 3; pub const NF_IP_POST_ROUTING: c_int = 4; pub const NF_IP_NUMHOOKS: c_int = 5; -pub const NF_IP_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP_PRI_FIRST: c_int = c_int::MIN; pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: c_int = -450; pub const NF_IP_PRI_CONNTRACK_DEFRAG: c_int = -400; pub const NF_IP_PRI_RAW: c_int = -300; @@ -1808,11 +1814,11 @@ pub const NF_IP_PRI_SECURITY: c_int = 50; pub const NF_IP_PRI_NAT_SRC: c_int = 100; pub const NF_IP_PRI_SELINUX_LAST: c_int = 225; pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300; -pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = c_int::MAX; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_IP_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv6.h pub const NF_IP6_PRE_ROUTING: c_int = 0; @@ -1822,7 +1828,7 @@ pub const NF_IP6_LOCAL_OUT: c_int = 3; pub const NF_IP6_POST_ROUTING: c_int = 4; pub const NF_IP6_NUMHOOKS: c_int = 5; -pub const NF_IP6_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP6_PRI_FIRST: c_int = c_int::MIN; pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: c_int = -450; pub const NF_IP6_PRI_CONNTRACK_DEFRAG: c_int = -400; pub const NF_IP6_PRI_RAW: c_int = -300; @@ -1838,7 +1844,7 @@ pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_IP6_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv6/ip6_tables.h pub const IP6T_SO_ORIGINAL_DST: c_int = 80; @@ -2551,6 +2557,20 @@ pub const IN_ONLYDIR: u32 = 0x0100_0000; pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; +// uapi/linux/magic.h +// 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. +cfg_if! { + if #[cfg(not(target_arch = "s390x"))] { + pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; + pub const XFS_SUPER_MAGIC: c_long = 0x58465342; + } else if #[cfg(target_arch = "s390x")] { + pub const BINDERFS_SUPER_MAGIC: c_uint = 0x6c6f6f70; + pub const XFS_SUPER_MAGIC: c_uint = 0x58465342; + } +} + // uapi/linux/securebits.h const SECURE_NOROOT: c_int = 0; const SECURE_NOROOT_LOCKED: c_int = 1; @@ -3562,10 +3582,10 @@ extern "C" { #[cfg_attr(musl_redir_time64, link_name = "__sigtimedwait_time64")] pub fn sigtimedwait( set: *const sigset_t, - info: *mut siginfo_t, + info: *mut crate::siginfo_t, timeout: *const crate::timespec, ) -> c_int; - pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut crate::siginfo_t) -> c_int; pub fn accept4(fd: c_int, addr: *mut crate::sockaddr, len: *mut socklen_t, flg: c_int) -> c_int; pub fn reboot(how_to: c_int) -> c_int; 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 81ea674f6b041..bed83460fbc21 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -25,7 +25,7 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub st_ino: crate::ino_t, pub st_atime: crate::time_t, @@ -47,7 +47,7 @@ s! { #[cfg(all(musl32_time64, target_endian = "little"))] __pad2: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] pub st_ino: crate::ino_t, } @@ -63,9 +63,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed @@ -119,7 +119,7 @@ s! { __pad2: Padding, #[cfg(musl32_time64)] - __pad3: c_ulong, + __pad3: Padding, #[cfg(musl32_time64)] shm_atime: crate::time_t, #[cfg(musl32_time64)] diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index c99411c15e7ed..32e1f67de99f0 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -46,9 +46,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 8beb5abcdab6a..6b814096d8907 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -23,11 +23,11 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub st_blksize: crate::blksize_t, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] __st_padding3: Padding, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, @@ -49,16 +49,16 @@ s! { #[cfg(all(musl32_time64, target_endian = "little"))] __pad2: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] pub st_blksize: crate::blksize_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] __st_padding3: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] pub st_blocks: crate::blkcnt_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] __st_padding4: Padding<[c_long; 14]>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] __st_padding4: Padding<[c_long; 2]>, } @@ -74,9 +74,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 00b5015084ca2..648723676f378 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -35,7 +35,7 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] __unused: Padding<[c_long; 2]>, pub st_atime: crate::time_t, @@ -57,7 +57,7 @@ s! { #[cfg(all(musl32_time64, target_endian = "little"))] __pad2: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] __unused: Padding<[c_long; 2]>, } @@ -73,9 +73,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed 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 38fcf64c3ea53..430b5186b9ca8 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -25,7 +25,7 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub st_ino: crate::ino_t, pub st_atime: crate::time_t, @@ -41,7 +41,7 @@ s! { #[cfg(musl32_time64)] __pad2: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] pub st_ino: crate::ino_t, } @@ -61,9 +61,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed @@ -117,7 +117,7 @@ s! { __pad2: Padding, #[cfg(musl32_time64)] - __pad3: c_ulong, + __pad3: Padding, #[cfg(musl32_time64)] shm_atime: crate::time_t, #[cfg(musl32_time64)] 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 1821cf5572f9d..85fa1c07350d8 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -36,9 +36,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed @@ -51,9 +51,9 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __seq: c_int, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "The type of this field has changed from c_ushort to c_int, diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index fd1321ffd64d5..5b811078d1f7f 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -37,9 +37,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index ef500af952b62..b791d31e63da4 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -51,9 +51,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index b536c0290eb9c..d30307c6689a8 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -11,9 +11,9 @@ pub type statfs64 = statfs; s! { pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs index 09e07acc21a59..15d80594816fa 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -30,9 +30,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed 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 b66ae26733dd2..48890ff35ae23 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 @@ -98,9 +98,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 99acc27c81a1e..3641134f1f31c 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -57,83 +57,6 @@ cfg_if! { } } -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_void { - #[repr(C)] - struct siginfo_sigfault { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - si_addr: *mut c_void, - } - (*(self as *const siginfo_t).cast::()).si_addr - } - - pub unsafe fn si_value(&self) -> crate::sigval { - #[repr(C)] - struct siginfo_si_value { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - _si_timerid: c_int, - _si_overrun: c_int, - si_value: crate::sigval, - } - (*(self as *const siginfo_t).cast::()).si_value - } -} - -s_no_extra_traits! { - // Internal, for casts to access union fields - struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, - } - - // Internal, for casts to access union fields - union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, - } - - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, - } -} - -impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t).cast::()).sifields - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - self.sifields().sigchld.si_pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - self.sifields().sigchld.si_uid - } - - pub unsafe fn si_status(&self) -> c_int { - self.sifields().sigchld.si_status - } - - pub unsafe fn si_utime(&self) -> c_long { - self.sifields().sigchld.si_utime - } - - pub unsafe fn si_stime(&self) -> c_long { - self.sifields().sigchld.si_stime - } -} - s! { pub struct aiocb { pub aio_fildes: c_int, @@ -149,7 +72,7 @@ s! { pub aio_offset: off_t, __next: *mut c_void, __prev: *mut c_void, - __dummy4: [c_char; 32 - 2 * size_of::<*const ()>()], + __dummy4: Padding<[c_char; 32 - 2 * size_of::<*const ()>()]>, } #[repr(align(8))] @@ -172,25 +95,45 @@ s! { pub sa_restorer: Option, } - // `mips*` targets swap the `s_errno` and `s_code` fields otherwise this struct is - // target-agnostic (see https://www.openwall.com/lists/musl/2016/01/27/1/2) - // - // FIXME(union): C implementation uses unions - pub struct siginfo_t { - pub si_signo: c_int, - #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] - pub si_errno: c_int, - pub si_code: c_int, - #[cfg(any(target_arch = "mips", target_arch = "mips64"))] - pub si_errno: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on https://github.com/rust-lang/libc/pull/1316 \ - if you're using this field" - )] - pub _pad: [c_int; 29], - _align: [usize; 0], + // musl's uint64_t is an unsigned long instead of an unsigned long long on + // 64-bit targets, so it's not a __u64 (which is c_ulonglong), but rather a + // real u64. This is also how we handle musl's uint64_t elsewhere. + pub struct statx { + pub stx_mask: u32, + pub stx_blksize: u32, + pub stx_attributes: u64, + pub stx_nlink: u32, + pub stx_uid: u32, + pub stx_gid: u32, + pub stx_mode: u16, + __statx_pad1: Padding<[u16; 1]>, + pub stx_ino: u64, + pub stx_size: u64, + pub stx_blocks: u64, + pub stx_attributes_mask: u64, + pub stx_atime: statx_timestamp, + pub stx_btime: statx_timestamp, + pub stx_ctime: statx_timestamp, + pub stx_mtime: statx_timestamp, + pub stx_rdev_major: u32, + pub stx_rdev_minor: u32, + pub stx_dev_major: u32, + pub stx_dev_minor: u32, + pub stx_mnt_id: u64, + pub stx_dio_mem_align: u32, + pub stx_dio_offset_align: u32, + pub stx_subvol: u64, + pub stx_atomic_write_unit_min: u32, + pub stx_atomic_write_unit_max: u32, + pub stx_atomic_write_segments_max: u32, + __statx_pad2: Padding<[u32; 1]>, + __statx_pad3: Padding<[u64; 9]>, + } + + pub struct statx_timestamp { + pub tv_sec: i64, + pub tv_nsec: u32, + __statx_timestamp_pad1: Padding<[i32; 1]>, } pub struct statvfs { @@ -466,7 +409,7 @@ s! { pub ut_host: [c_char; 256], pub ut_exit: __exit_status, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "The ABI of this field has changed from c_long to c_int with padding, \ @@ -474,14 +417,14 @@ s! { )] pub ut_session: c_long, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] #[cfg(not(target_endian = "little"))] __ut_pad2: Padding, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub ut_session: c_int, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] #[cfg(target_endian = "little")] __ut_pad2: Padding, @@ -599,7 +542,7 @@ pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; // Value was changed in 1.2.4 -pub const CPU_SETSIZE: c_int = if cfg!(musl_v1_2_3) { 1024 } else { 128 }; +pub const CPU_SETSIZE: c_int = if cfg!(musl_v1_2) { 1024 } else { 128 }; pub const PTRACE_TRACEME: c_int = 0; pub const PTRACE_PEEKTEXT: c_int = 1; diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 9d255b7388fcd..493acf40da090 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -152,7 +152,7 @@ s! { __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct sigset_t { @@ -179,13 +179,6 @@ s! { pub c_ospeed: crate::speed_t, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - pub _pad: [c_int; 29], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -227,10 +220,13 @@ s! { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused1: Padding, pub shm_dtime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused2: Padding, pub shm_ctime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index 2c253f0164f11..cc85abc132385 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -97,13 +97,6 @@ s! { __val: [c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - pub _pad: [c_int; 29], - } - pub struct glob64_t { pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, @@ -181,7 +174,7 @@ s! { pub f_fsid: crate::fsid_t, pub f_namelen: c_long, - f_spare: [c_long; 6], + f_spare: Padding<[c_long; 6]>, } pub struct statfs64 { diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index a6a63a33a93b3..4a80ff1cc9267 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -79,14 +79,6 @@ s! { __size: [c_ulong; 16], } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - _pad: Padding, - _pad2: Padding<[c_long; 14]>, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -139,7 +131,7 @@ s! { pub f_fsid: crate::fsid_t, pub f_namelen: c_long, - f_spare: [c_long; 6], + f_spare: Padding<[c_long; 6]>, } pub struct msghdr { diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 6c3d8013f9173..0075bddee94ec 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -52,7 +52,7 @@ s! { pub f_fsid: c_ulong, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct regex_t { @@ -133,82 +133,16 @@ s! { pub tcpi_rcv_space: u32, pub tcpi_total_retrans: u32, } -} - -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_void { - #[repr(C)] - struct siginfo_sigfault { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - si_addr: *mut c_void, - } - (*(self as *const siginfo_t).cast::()).si_addr - } - - pub unsafe fn si_value(&self) -> crate::sigval { - #[repr(C)] - struct siginfo_si_value { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - _si_timerid: c_int, - _si_overrun: c_int, - si_value: crate::sigval, - } - (*(self as *const siginfo_t).cast::()).si_value - } -} -s_no_extra_traits! { - // Internal, for casts to access union fields - struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, + pub struct mbstate_t { + __mask: crate::wchar_t, + __wc: crate::wchar_t, } - // Internal, for casts to access union fields - union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, - } - - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, - } -} - -impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t).cast::()).sifields - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - self.sifields().sigchld.si_pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - self.sifields().sigchld.si_uid - } - - pub unsafe fn si_status(&self) -> c_int { - self.sifields().sigchld.si_status - } - - pub unsafe fn si_utime(&self) -> c_long { - self.sifields().sigchld.si_utime - } - - pub unsafe fn si_stime(&self) -> c_long { - self.sifields().sigchld.si_stime + pub struct fpos64_t { + __pos: off64_t, + __mbstate: crate::mbstate_t, + __mblen_pending: c_int, } } @@ -216,16 +150,8 @@ pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; -pub const SIGEV_THREAD_ID: c_int = 4; - pub const AF_VSOCK: c_int = 40; -// 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. -pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; -pub const XFS_SUPER_MAGIC: c_long = 0x58465342; - pub const PTRACE_TRACEME: c_int = 0; pub const PTRACE_PEEKTEXT: c_int = 1; pub const PTRACE_PEEKDATA: c_int = 2; diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index cd9f45699d590..60e5cfe72500d 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -51,14 +51,6 @@ s! { __sched_priority: c_int, } - pub struct siginfo_t { - si_signo: c_int, // signal number - si_errno: c_int, // if not zero: error value of signal, see errno.h - si_code: c_int, // signal code - pub _pad: [c_int; 28], // unported union - _align: [usize; 0], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, // segment size in bytes @@ -82,8 +74,8 @@ s! { pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __ignored1: c_ulong, - __ignored2: c_ulong, + __ignored1: Padding, + __ignored2: Padding, } pub struct sockaddr { @@ -168,7 +160,7 @@ s! { pub f_fsid: crate::fsid_t, pub f_namelen: fsword_t, pub f_frsize: fsword_t, - f_spare: [fsword_t; 5], + f_spare: Padding<[fsword_t; 5]>, } pub struct statfs64 { @@ -199,7 +191,7 @@ s! { __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct msghdr { diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 60a9138ef4781..f8a0b45e610cd 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -795,7 +795,6 @@ pub const EM_M32R: u16 = 88; pub const EM_MN10300: u16 = 89; pub const EM_MN10200: u16 = 90; pub const EM_PJ: u16 = 91; -#[cfg(not(target_env = "uclibc"))] pub const EM_OPENRISC: u16 = 92; #[cfg(target_env = "uclibc")] pub const EM_OR1K: u16 = 92; @@ -876,7 +875,6 @@ pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value // wherever it is defined. pub const AT_SYSINFO_EHDR: c_ulong = 33; -#[cfg(not(target_env = "uclibc"))] pub const AT_MINSIGSTKSZ: c_ulong = 51; pub const GLOB_ERR: c_int = 1 << 0; @@ -945,11 +943,6 @@ pub const PTHREAD_EXPLICIT_SCHED: c_int = 1; #[cfg(not(target_os = "l4re"))] pub const __SIZEOF_PTHREAD_COND_T: usize = 48; -// netinet/in.h -// NOTE: These are in addition to the constants defined in src/unix/mod.rs - -pub const IPPROTO_MAX: c_int = 263; - // System V IPC pub const IPC_PRIVATE: crate::key_t = 0; @@ -1005,6 +998,10 @@ pub const NI_NOFQDN: c_int = 4; pub const NI_NAMEREQD: c_int = 8; pub const NI_DGRAM: c_int = 16; #[cfg(not(target_env = "uclibc"))] +#[cfg_attr( + target_env = "musl", + deprecated(since = "0.2.190", note = "not present in musl") +)] pub const NI_IDN: c_int = 32; cfg_if! { @@ -1931,18 +1928,56 @@ extern "C" { cfg_if! { if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] { extern "C" { + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64",), + deprecated( + since = "0.2.190", + note = "Use `freopen` instead. LFS is being phased out, see \ + rust-lang/libc#4805." + ) + )] pub fn freopen64( filename: *const c_char, mode: *const c_char, file: *mut crate::FILE, ) -> *mut crate::FILE; + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `fseeko` instead. LFS is being phased out, see rust-lang/libc#4805." + ) + )] pub fn fseeko64( stream: *mut crate::FILE, + #[cfg(any( + not(target_os = "l4re"), + all(target_os = "l4re", not(target_pointer_width = "64")) + ))] offset: crate::off64_t, + #[cfg(all(target_os = "l4re", target_pointer_width = "64"))] offset: crate::off_t, whence: c_int, ) -> c_int; + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `fsetpos` instead. LFS is being phased out, see \ + rust-lang/libc#4805." + ) + )] pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const crate::fpos64_t) -> c_int; + #[cfg(any( + not(target_os = "l4re"), + all(target_os = "l4re", not(target_pointer_width = "64")) + ))] pub fn ftello64(stream: *mut crate::FILE) -> crate::off64_t; + #[cfg(all(target_os = "l4re", target_pointer_width = "64"))] + #[deprecated( + since = "0.2.190", + note = "Use `ftello` instead. LFS is being phased out, see rust-lang/libc#4805." + )] + pub fn ftello64(stream: *mut crate::FILE) -> crate::off_t; } } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 7951abf33f4d0..64fea11708e70 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -267,11 +267,7 @@ cfg_if! { } cfg_if! { - if #[cfg(any( - target_env = "gnu", - target_os = "android", - all(target_env = "musl", musl_v1_2_3) - ))] { + if #[cfg(any(target_env = "gnu", target_os = "android"))] { s! { pub struct statx { pub stx_mask: crate::__u32, @@ -435,8 +431,6 @@ pub const F_SEAL_WRITE: c_int = 0x0008; // FIXME(#235): Include file sealing fcntls once we have a way to verify them. -pub const SIGTRAP: c_int = 5; - pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 1; @@ -485,17 +479,24 @@ 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 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 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; + +cfg_if! { + // defined in src/new/glibc + if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] { + 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 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; @@ -510,6 +511,8 @@ pub const XATTR_REPLACE: c_int = 0x2; cfg_if! { if #[cfg(target_os = "android")] { pub const RLIM64_INFINITY: c_ulonglong = !0; + } else if #[cfg(all(target_os = "l4re", target_pointer_width = "64"))] { + pub const RLIM64_INFINITY: crate::rlim_t = !0; } else { pub const RLIM64_INFINITY: crate::rlim64_t = !0; } @@ -1296,6 +1299,7 @@ pub const CLD_CONTINUED: c_int = 6; pub const SIGEV_SIGNAL: c_int = 0; pub const SIGEV_NONE: c_int = 1; pub const SIGEV_THREAD: c_int = 2; +pub const SIGEV_THREAD_ID: c_int = 4; pub const P_ALL: idtype_t = 0; pub const P_PID: idtype_t = 1; @@ -1648,8 +1652,8 @@ cfg_if! { cfg_if! { if #[cfg(any( target_env = "gnu", + target_env = "musl", target_os = "android", - all(target_env = "musl", musl_v1_2_3), target_os = "l4re" ))] { pub const AT_STATX_SYNC_TYPE: c_int = 0x6000; @@ -1672,6 +1676,12 @@ cfg_if! { pub const STATX_ALL: c_uint = 0x0fff; pub const STATX_MNT_ID: c_uint = 0x1000; pub const STATX_DIOALIGN: c_uint = 0x2000; + pub const STATX_MNT_ID_UNIQUE: c_uint = 0x00004000; + pub const STATX_SUBVOL: c_uint = 0x00008000; + pub const STATX_WRITE_ATOMIC: c_uint = 0x00010000; + // Not in the Android NDK as of r29. + #[cfg(not(target_os = "android"))] + pub const STATX_DIO_READ_ALIGN: c_uint = 0x00020000; pub const STATX__RESERVED: c_int = u32_cast_int(0x80000000); pub const STATX_ATTR_COMPRESSED: c_int = 0x0004; pub const STATX_ATTR_IMMUTABLE: c_int = 0x0010; @@ -1682,6 +1692,7 @@ cfg_if! { pub const STATX_ATTR_MOUNT_ROOT: c_int = 0x2000; pub const STATX_ATTR_VERITY: c_int = 0x100000; pub const STATX_ATTR_DAX: c_int = 0x200000; + pub const STATX_ATTR_WRITE_ATOMIC: c_int = 0x00400000; } } @@ -2099,26 +2110,51 @@ cfg_if! { target_os = "emscripten", )))] { extern "C" { + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")] + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")] #[cfg(not(target_os = "l4re"))] + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstatat64( dirfd: c_int, pathname: *const c_char, buf: *mut stat64, flags: c_int, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] #[cfg(not(target_os = "l4re"))] + // FIXME(1.0,deprecate): lfs binding to be removed pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn mmap64( addr: *mut c_void, len: size_t, @@ -2127,22 +2163,41 @@ cfg_if! { fd: c_int, offset: off64_t, ) -> *mut c_void; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn openat64(fd: c_int, path: *const c_char, oflag: c_int, ...) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn posix_fadvise64( fd: c_int, offset: off64_t, len: off64_t, advise: c_int, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn pwrite64( fd: c_int, buf: *const c_void, count: size_t, offset: off64_t, ) -> ssize_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn readdir64_r( dirp: *mut crate::DIR, entry: *mut crate::dirent64, @@ -2150,7 +2205,13 @@ cfg_if! { ) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")] #[cfg(not(target_os = "l4re"))] + // FIXME(1.0,deprecate): lfs binding to be removed pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; } } @@ -2164,12 +2225,14 @@ cfg_if! { target_os = "emscripten", )))] { extern "C" { + // FIXME(1.0,deprecate): lfs binding to be removed pub fn preadv64( fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t, ) -> ssize_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn pwritev64( fd: c_int, iov: *const crate::iovec, @@ -2206,8 +2269,8 @@ cfg_if! { cfg_if! { if #[cfg(any( target_env = "gnu", + target_env = "musl", target_os = "android", - all(target_env = "musl", musl_v1_2_3) ))] { extern "C" { pub fn statx( diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e331089b38317..d0bf81b624671 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -231,8 +231,10 @@ s! { } } -pub const INT_MIN: c_int = -2147483648; -pub const INT_MAX: c_int = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; @@ -353,13 +355,23 @@ 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], }; -pub const ARPOP_REQUEST: u16 = 1; -pub const ARPOP_REPLY: u16 = 2; +cfg_if! { + // Not present on iOS/tvOS/watchOS/visionOS + if #[cfg(not(any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )))] { + pub const ARPOP_REQUEST: u16 = 1; + pub const ARPOP_REPLY: u16 = 2; -pub const ATF_COM: c_int = 0x02; -pub const ATF_PERM: c_int = 0x04; -pub const ATF_PUBL: c_int = 0x08; -pub const ATF_USETRAILERS: c_int = 0x10; + pub const ATF_COM: c_int = 0x02; + pub const ATF_PERM: c_int = 0x04; + pub const ATF_PUBL: c_int = 0x08; + pub const ATF_USETRAILERS: c_int = 0x10; + } +} cfg_if! { if #[cfg(any(target_os = "nto", target_os = "qnx", target_os = "aix"))] { @@ -384,7 +396,7 @@ cfg_if! { cfg_if! { if #[cfg(any( - target_os = "macos", + target_vendor = "apple", target_os = "freebsd", target_os = "dragonfly", target_os = "android", @@ -400,7 +412,7 @@ cfg_if! { cfg_if! { if #[cfg(any( - target_os = "macos", + target_vendor = "apple", target_os = "freebsd", target_os = "dragonfly", target_os = "android", @@ -572,11 +584,7 @@ cfg_if! { #[link(name = "c", cfg(not(target_feature = "crt-static")))] extern "C" {} } else if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", + target_vendor = "apple", target_os = "android", target_os = "openbsd", target_os = "nto", @@ -749,6 +757,13 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "system$UNIX2003" )] + // Not available on iOS/tvOS/watchOS/visionOS + #[cfg(not(any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + )))] pub fn system(s: *const c_char) -> c_int; pub fn getenv(s: *const c_char) -> *mut c_char; @@ -926,7 +941,7 @@ extern "C" { pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "fstat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] @@ -945,7 +960,7 @@ extern "C" { pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "stat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] @@ -1013,7 +1028,7 @@ extern "C" { pub fn fdopendir(fd: c_int) -> *mut crate::DIR; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "readdir$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] @@ -1051,7 +1066,7 @@ extern "C" { #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")] pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "fstatat$INODE64" )] #[cfg_attr( @@ -1110,19 +1125,27 @@ extern "C" { pub fn dup(fd: c_int) -> c_int; pub fn dup2(src: c_int, dst: c_int) -> c_int; + // exec* marked as prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execlp(file: *const c_char, arg0: *const c_char, ...) -> c_int; // DIFF(main): changed to `*const *mut` in e77f551de9 + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execv(prog: *const c_char, argv: *const *const c_char) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execve( prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char, ) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn fork() -> pid_t; pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; @@ -1148,6 +1171,11 @@ extern "C" { #[cfg_attr(gnu_file_offset_bits64, link_name = "lseek64")] pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; pub fn pathconf(path: *const c_char, name: c_int) -> c_long; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pause$UNIX2003" + )] + pub fn pause() -> c_int; pub fn pipe(fds: *mut c_int) -> c_int; pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; @@ -1263,7 +1291,7 @@ extern "C" { pub fn if_indextoname(ifindex: c_uint, ifname: *mut c_char) -> *mut c_char; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "lstat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] @@ -1311,16 +1339,7 @@ extern "C" { #[cfg_attr(musl_redir_time64, link_name = "__getrusage_time64")] pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; - #[cfg_attr( - any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos" - ), - link_name = "realpath$DARWIN_EXTSN" - )] + #[cfg_attr(target_vendor = "apple", link_name = "realpath$DARWIN_EXTSN")] pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; #[cfg_attr(target_os = "netbsd", link_name = "__times13")] @@ -1498,16 +1517,7 @@ extern "C" { ), link_name = "__res_init" )] - #[cfg_attr( - any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos" - ), - link_name = "res_9_init" - )] + #[cfg_attr(target_vendor = "apple", link_name = "res_9_init")] #[cfg_attr(target_os = "aix", link_name = "_res_init")] #[cfg(not(target_os = "l4re"))] pub fn res_init() -> c_int; @@ -1630,8 +1640,10 @@ extern "C" { pub fn sem_wait(sem: *mut sem_t) -> c_int; pub fn sem_trywait(sem: *mut sem_t) -> c_int; pub fn sem_post(sem: *mut sem_t) -> c_int; + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int; + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int; @@ -2191,7 +2203,7 @@ cfg_if! { target_os = "dragonfly", target_os = "emscripten", target_os = "hurd", - target_os = "macos", + target_vendor = "apple", target_os = "openbsd", target_os = "l4re", )))] { @@ -2243,12 +2255,7 @@ cfg_if! { extern "C" { pub fn getsid(pid: pid_t) -> pid_t; #[cfg_attr( - all(target_os = "macos", target_arch = "x86"), - link_name = "pause$UNIX2003" - )] - pub fn pause() -> c_int; - #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "readdir_r$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] @@ -2312,6 +2319,7 @@ cfg_if! { #[cfg(not(target_os = "l4re"))] pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE; pub fn atexit(cb: extern "C" fn()) -> c_int; + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")] pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) -> c_int; @@ -2486,11 +2494,7 @@ cfg_if! { mod linux_like; pub use self::linux_like::*; } else if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", + target_vendor = "apple", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs deleted file mode 100644 index a559cf4da59fd..0000000000000 --- a/src/unix/newlib/arm/mod.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::prelude::*; - -pub type clock_t = c_long; -pub type wchar_t = u32; - -s! { - pub struct sockaddr { - pub sa_family: crate::sa_family_t, - pub sa_data: [c_char; 14], - } - - pub struct sockaddr_in6 { - pub sin6_family: crate::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 sockaddr_in { - pub sin_family: crate::sa_family_t, - pub sin_port: crate::in_port_t, - pub sin_addr: crate::in_addr, - pub sin_zero: [u8; 8], - } - - pub struct sockaddr_storage { - pub ss_family: crate::sa_family_t, - __ss_padding: Padding<[u8; 26]>, - } -} - -pub const AF_INET6: c_int = 23; - -pub const FIONBIO: c_ulong = 1; - -pub const POLLIN: c_short = 0x1; -pub const POLLPRI: c_short = 0x2; -pub const POLLHUP: c_short = 0x4; -pub const POLLERR: c_short = 0x8; -pub const POLLOUT: c_short = 0x10; -pub const POLLNVAL: c_short = 0x20; - -pub const SOL_SOCKET: c_int = 65535; - -pub const MSG_OOB: c_int = 1; -pub const MSG_PEEK: c_int = 2; -pub const MSG_DONTWAIT: c_int = 4; -pub const MSG_DONTROUTE: c_int = 0; -pub const MSG_WAITALL: c_int = 0; -pub const MSG_MORE: c_int = 0; -pub const MSG_NOSIGNAL: c_int = 0; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index ab12da1d6fe08..933bc2eb8f6f3 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -3,13 +3,23 @@ use crate::prelude::*; pub type blkcnt_t = i32; pub type blksize_t = i32; -pub type clockid_t = c_ulong; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub type clockid_t = c_int; + } else { + pub type clockid_t = c_ulong; + } +} cfg_if! { if #[cfg(any(target_os = "espidf", target_os = "vita"))] { pub type dev_t = c_short; pub type ino_t = c_ushort; pub type off_t = c_long; + } else if #[cfg(target_os = "rtems")] { + pub type dev_t = u64; + pub type ino_t = u64; + pub type off_t = i64; } else if #[cfg(any(target_arch = "arm", target_arch = "powerpc"))] { pub type dev_t = u32; pub type ino_t = u32; @@ -29,7 +39,13 @@ pub type nfds_t = u32; pub type nlink_t = c_ushort; pub type pthread_t = c_ulong; pub type pthread_key_t = c_uint; -pub type rlim_t = u32; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub type rlim_t = i64; + } else { + pub type rlim_t = u32; + } +} cfg_if! { if #[cfg(target_os = "horizon")] { @@ -369,6 +385,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { cfg_if! { if #[cfg(target_os = "espidf")] { pub const NCCS: usize = 11; + } else if #[cfg(target_os = "rtems")] { + pub const NCCS: usize = 20; } else { pub const NCCS: usize = 32; } @@ -428,7 +446,7 @@ pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; cfg_if! { if #[cfg(any(target_os = "horizon", target_os = "espidf"))] { pub const FD_SETSIZE: usize = 64; - } else if #[cfg(target_os = "vita")] { + } else if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const FD_SETSIZE: usize = 256; } else { pub const FD_SETSIZE: usize = 1024; @@ -560,7 +578,7 @@ pub const O_NONBLOCK: c_int = 16384; pub const O_ACCMODE: c_int = 3; cfg_if! { - if #[cfg(target_os = "espidf")] { + if #[cfg(any(target_os = "espidf", target_os = "rtems"))] { pub const O_CLOEXEC: c_int = 0x40000; } else { pub const O_CLOEXEC: c_int = 0x80000; @@ -606,6 +624,8 @@ pub const PF_INET: c_int = 2; cfg_if! { if #[cfg(target_os = "espidf")] { pub const PF_INET6: c_int = 10; + } else if #[cfg(target_os = "rtems")] { + pub const PF_INET6: c_int = 28; } else { pub const PF_INET6: c_int = 23; } @@ -667,7 +687,13 @@ cfg_if! { } pub const SO_TYPE: c_int = 0x1008; -pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub const SOCK_CLOEXEC: c_int = 0x10000000; + } else { + pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + } +} pub const INET_ADDRSTRLEN: c_int = 16; @@ -691,7 +717,7 @@ pub const IFF_ALTPHYS: c_int = IFF_LINK2; // use alternate physical connection pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const TCP_NODELAY: c_int = 1; pub const TCP_MAXSEG: c_int = 2; } else if #[cfg(target_os = "espidf")] { @@ -727,7 +753,7 @@ cfg_if! { } } cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const IP_TTL: c_int = 4; } else if #[cfg(target_os = "espidf")] { pub const IP_TTL: c_int = 2; @@ -749,7 +775,7 @@ cfg_if! { } cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const IP_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13; } else if #[cfg(target_os = "espidf")] { @@ -784,6 +810,11 @@ cfg_if! { pub const NO_DATA: c_int = 211; pub const NO_RECOVERY: c_int = 212; pub const TRY_AGAIN: c_int = 213; + } else if #[cfg(target_os = "rtems")] { + pub const HOST_NOT_FOUND: c_int = 1; + pub const TRY_AGAIN: c_int = 2; + pub const NO_RECOVERY: c_int = 3; + pub const NO_DATA: c_int = 4; } else { pub const HOST_NOT_FOUND: c_int = 1; pub const NO_DATA: c_int = 2; @@ -791,7 +822,13 @@ cfg_if! { pub const TRY_AGAIN: c_int = 4; } } -pub const NO_ADDRESS: c_int = 2; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub const NO_ADDRESS: c_int = NO_DATA; + } else { + pub const NO_ADDRESS: c_int = 2; + } +} pub const AI_PASSIVE: c_int = 1; pub const AI_CANONNAME: c_int = 2; @@ -800,6 +837,9 @@ cfg_if! { if #[cfg(target_os = "espidf")] { pub const AI_NUMERICSERV: c_int = 8; pub const AI_ADDRCONFIG: c_int = 64; + } else if #[cfg(target_os = "rtems")] { + pub const AI_NUMERICSERV: c_int = 0x00000008; + pub const AI_ADDRCONFIG: c_int = 0x00000400; } else { pub const AI_NUMERICSERV: c_int = 0; pub const AI_ADDRCONFIG: c_int = 0; @@ -812,7 +852,7 @@ pub const NI_NOFQDN: c_int = 1; pub const NI_NUMERICHOST: c_int = 2; pub const NI_NAMEREQD: c_int = 4; cfg_if! { - if #[cfg(target_os = "espidf")] { + if #[cfg(any(target_os = "espidf", target_os = "rtems"))] { pub const NI_NUMERICSERV: c_int = 8; pub const NI_DGRAM: c_int = 16; } else { @@ -828,6 +868,11 @@ cfg_if! { pub const EAI_MEMORY: c_int = 203; pub const EAI_NONAME: c_int = 200; pub const EAI_SOCKTYPE: c_int = 10; + } else if #[cfg(target_os = "rtems")] { + pub const EAI_FAMILY: c_int = 5; + pub const EAI_MEMORY: c_int = 6; + pub const EAI_NONAME: c_int = 8; + pub const EAI_SOCKTYPE: c_int = 10; } else if #[cfg(not(target_os = "vita"))] { pub const EAI_FAMILY: c_int = -303; pub const EAI_MEMORY: c_int = -304; @@ -978,17 +1023,10 @@ cfg_if! { } else if #[cfg(target_os = "vita")] { mod vita; pub use self::vita::*; - } else if #[cfg(target_arch = "arm")] { - mod arm; - pub use self::arm::*; - } else { - core::compile_error!("unsupported target"); - } -} - -cfg_if! { - if #[cfg(target_os = "rtems")] { + } else if #[cfg(target_os = "rtems")] { mod rtems; pub use self::rtems::*; + } else { + core::compile_error!("unsupported target"); } } diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs index 9ed423096e8db..71405e2c3a942 100644 --- a/src/unix/newlib/rtems/mod.rs +++ b/src/unix/newlib/rtems/mod.rs @@ -1,15 +1,70 @@ -// defined in architecture specific module - use crate::prelude::*; +// RTEMS defines `clock_t` as `__uint64_t` (`` via +// ``), not `long` as plain newlib arm targets did. +pub type clock_t = u64; +pub type wchar_t = u32; + s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: crate::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 sockaddr_un { + pub sun_len: u8, pub sun_family: crate::sa_family_t, - pub sun_path: [c_char; 108usize], + pub sun_path: [c_char; 104usize], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[u8; 112]>, } } pub const AF_UNIX: c_int = 1; +pub const AF_INET6: c_int = 28; + +pub const FIONBIO: c_ulong = 0x8004667e; + +pub const POLLIN: c_short = 0x0001; +pub const POLLPRI: c_short = 0x0002; +pub const POLLOUT: c_short = 0x0004; +pub const POLLERR: c_short = 0x0008; +pub const POLLHUP: c_short = 0x0010; +pub const POLLNVAL: c_short = 0x0020; + +pub const SOL_SOCKET: c_int = 0xffff; + +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_WAITALL: c_int = 0x40; +pub const MSG_DONTWAIT: c_int = 0x80; +pub const MSG_NOSIGNAL: c_int = 0x20000; +pub const MSG_MORE: c_int = 0; pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void; diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index eac685243b917..faec373cbec92 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -81,6 +81,8 @@ pub type posix_spawnattr_t = crate::uintptr_t; pub type pthread_mutex_t = crate::sync_t; pub type pthread_mutexattr_t = crate::_sync_attr; +#[cfg(target_os = "qnx")] +pub type pthread_rwlock_t = crate::sync_t; pub type pthread_cond_t = crate::sync_t; pub type pthread_condattr_t = crate::_sync_attr; pub type pthread_rwlockattr_t = crate::_sync_attr; @@ -282,7 +284,7 @@ s! { pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, pub gl_flags: c_int, - pub gl_errfunc: extern "C" fn(*const c_char, c_int) -> c_int, + pub gl_errfunc: Option c_int>, __unused1: Padding<*mut c_void>, __unused2: Padding<*mut c_void>, @@ -458,6 +460,7 @@ s! { pub c_ospeed: crate::speed_t, } + #[cfg(target_os = "nto")] pub struct mallinfo { pub arena: c_int, pub ordblks: c_int, @@ -471,6 +474,20 @@ s! { pub keepcost: c_int, } + #[cfg(target_os = "qnx")] + pub struct mallinfo { + pub arena: size_t, + pub ordblks: size_t, + pub smblks: size_t, + pub hblks: size_t, + pub hblkhd: size_t, + pub usmblks: size_t, + pub fsmblks: size_t, + pub uordblks: size_t, + pub fordblks: size_t, + pub keepcost: size_t, + } + pub struct flock { pub l_type: i16, pub l_whence: i16, @@ -494,7 +511,7 @@ s! { pub f_basetype: [c_char; 16], pub f_flag: c_ulong, pub f_namemax: c_ulong, - f_filler: [c_uint; 21], + f_filler: Padding<[c_uint; 21]>, } pub struct aiocb { @@ -542,6 +559,7 @@ s! { } // FIXME(1.0): This should not implement `PartialEq` + #[cfg(target_os = "nto")] #[allow(unpredictable_function_pointer_comparisons)] pub struct _thread_attr { pub __flags: c_int, @@ -552,7 +570,22 @@ s! { pub __param: crate::__sched_param, pub __guardsize: c_uint, pub __prealloc: c_uint, - __spare: [c_int; 2], + __spare: Padding<[c_int; 2]>, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[cfg(target_os = "qnx")] + #[allow(unpredictable_function_pointer_comparisons)] + pub struct _thread_attr { + pub __flags: c_int, + pub __stacksize: size_t, + pub __stackaddr: *mut c_void, + __reserved0: Padding, + pub __policy: c_int, + pub __param: crate::__sched_param, + pub __guardsize: c_uint, + pub __prealloc: c_uint, + __reserved1: Padding, } pub struct _sync_attr { @@ -655,7 +688,10 @@ s! { } pub struct sigset_t { + #[cfg(target_os = "nto")] __val: [u32; 2], + #[cfg(target_os = "qnx")] // different alignment + __val: u64, } pub struct mq_attr { @@ -702,10 +738,14 @@ s_no_extra_traits! { #[repr(align(4))] pub struct pthread_barrier_t { - // union + #[cfg(target_os = "qnx")] + __pad: Padding<[u8; 8]>, // union + #[cfg(target_os = "nto")] __pad: Padding<[u8; 28]>, // union } + // `target_os = "qnx"` is handled by a `type` alias + #[cfg(target_os = "nto")] pub struct pthread_rwlock_t { pub __active: c_int, pub __blockedwriters: c_int, @@ -1048,7 +1088,7 @@ pub const POLLRDBAND: c_short = 0x0004; pub const IPTOS_LOWDELAY: u8 = 0x10; pub const IPTOS_THROUGHPUT: u8 = 0x08; pub const IPTOS_RELIABILITY: u8 = 0x04; -pub const IPTOS_MINCOST: u8 = 0x02; +pub const IPTOS_MINCOST: u8 = if cfg!(target_os = "nto") { 0x02 } else { 0x00 }; pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0; pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0; @@ -1218,11 +1258,27 @@ pub const IN_MOVE_SELF: u32 = 0x00000800; pub const IN_UNMOUNT: u32 = 0x00002000; pub const IN_Q_OVERFLOW: u32 = 0x00004000; pub const IN_IGNORED: u32 = 0x00008000; -pub const IN_ONLYDIR: u32 = 0x01000000; -pub const IN_DONT_FOLLOW: u32 = 0x02000000; +pub const IN_ONLYDIR: u32 = if cfg!(target_os = "nto") { + 0x01000000 +} else { + 0x00400000 +}; +pub const IN_DONT_FOLLOW: u32 = if cfg!(target_os = "nto") { + 0x02000000 +} else { + 0x00100000 +}; -pub const IN_ISDIR: u32 = 0x40000000; -pub const IN_ONESHOT: u32 = 0x80000000; +pub const IN_ISDIR: u32 = if cfg!(target_os = "nto") { + 0x40000000 +} else { + 0x00010000 +}; +pub const IN_ONESHOT: u32 = if cfg!(target_os = "nto") { + 0x80000000 +} else { + 0x00800000 +}; pub const REG_EXTENDED: c_int = 0o0001; pub const REG_ICASE: c_int = 0o0002; @@ -1656,9 +1712,10 @@ pub const ENOTSUP: c_int = 48; pub const BUFSIZ: c_uint = 1024; pub const TMP_MAX: c_uint = 26 * 26 * 26; pub const FOPEN_MAX: c_uint = 16; -pub const FILENAME_MAX: c_uint = 255; +pub const FILENAME_MAX: c_uint = if cfg!(target_os = "nto") { 255 } else { 1024 }; pub const NI_MAXHOST: crate::socklen_t = 1025; +#[cfg(target_os = "nto")] // removed in QNX8 pub const M_KEEP: c_int = 4; pub const REG_STARTEND: c_int = 0o00004; pub const VEOF: usize = 4; @@ -1700,6 +1757,8 @@ pub const SOCK_CLOEXEC: c_int = 0x10000000; pub const SA_SIGINFO: c_int = 0x0002; pub const SA_NOCLDWAIT: c_int = 0x0020; pub const SA_NODEFER: c_int = 0x0010; +#[cfg(target_os = "qnx")] // QNX8 only +pub const SA_ONSTACK: c_int = 0x0008; pub const SA_RESETHAND: c_int = 0x0004; pub const SA_NOCLDSTOP: c_int = 0x0001; @@ -1994,6 +2053,7 @@ pub const KERN_PROF: c_int = 16; pub const KERN_SAVED_IDS: c_int = 20; pub const KERN_SECURELVL: c_int = 9; pub const KERN_VERSION: c_int = 4; +#[cfg(target_os = "nto")] // removed in QNX8 pub const KERN_VNODE: c_int = 13; pub const LC_ALL: c_int = 63; @@ -2005,8 +2065,11 @@ pub const LC_NUMERIC: c_int = 8; pub const LC_TIME: c_int = 16; pub const MAP_STACK: c_int = 0x00001000; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const MNT_NOEXEC: c_int = 0x02; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const MNT_NOSUID: c_int = 0x04; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const MNT_RDONLY: c_int = 0x01; pub const NET_RT_DUMP: c_int = 1; @@ -2073,11 +2136,11 @@ pub const RLIMIT_RSS: c_int = 6; pub const RLIMIT_STACK: c_int = 3; pub const RLIMIT_VMEM: c_int = 6; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] -pub const RLIM_NLIMITS: c_int = 14; +pub const RLIM_NLIMITS: c_int = if cfg!(target_os = "nto") { 14 } else { 19 }; pub const SCHED_ADJTOHEAD: c_int = 5; pub const SCHED_ADJTOTAIL: c_int = 6; -pub const SCHED_MAXPOLICY: c_int = 7; +pub const SCHED_MAXPOLICY: c_int = if cfg!(target_os = "nto") { 7 } else { 9 }; pub const SCHED_SETPRIO: c_int = 7; pub const SCHED_SPORADIC: c_int = 4; @@ -2086,8 +2149,8 @@ pub const SIGCLD: c_int = SIGCHLD; pub const SIGDEADLK: c_int = 7; pub const SIGEMT: c_int = 7; pub const SIGEV_NONE: c_int = 0; -pub const SIGEV_SIGNAL: c_int = 129; -pub const SIGEV_THREAD: c_int = 135; +pub const SIGEV_SIGNAL: c_int = if cfg!(target_os = "nto") { 129 } else { 1 }; +pub const SIGEV_THREAD: c_int = if cfg!(target_os = "nto") { 135 } else { 7 }; pub const SO_USELOOPBACK: c_int = 0x0040; pub const _SS_ALIGNSIZE: usize = size_of::(); pub const _SS_MAXSIZE: usize = 128; @@ -2211,7 +2274,11 @@ pub const PTHREAD_CREATE_DETACHED: c_int = 0x01; pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; pub const PTHREAD_MUTEX_NORMAL: c_int = 3; -pub const PTHREAD_STACK_MIN: size_t = 256; +pub const PTHREAD_STACK_MIN: size_t = if cfg!(target_os = "nto") { + 256 +} else { + 4 * 1024 +}; pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; pub const PTHREAD_MUTEX_STALLED: c_int = 0x00; pub const PTHREAD_MUTEX_ROBUST: c_int = 0x10; @@ -2239,6 +2306,7 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __u: CLOCK_REALTIME as u32, __owner: 0xfffffffb, }; +#[cfg(target_os = "nto")] pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __active: 0, __blockedwriters: 0, @@ -2250,6 +2318,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __owner: -2i32 as c_uint, __spare: 0, }; +#[cfg(target_os = "qnx")] +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __u: 0, __owner: 0 }; const fn _CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) @@ -2398,6 +2468,8 @@ f! { // In QNX <=7.0, libregex functions were included in libc itself. #[link(name = "socket")] #[cfg_attr(not(target_env = "nto70"), link(name = "regex"))] +// `inotify_*` functions are provided by `fsnotify` on QNX 8.0 +#[cfg_attr(target_os = "qnx", link(name = "fsnotify"))] extern "C" { 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; @@ -2826,12 +2898,12 @@ extern "C" { pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; pub fn sysctl( - _: *const c_int, - _: c_uint, - _: *mut c_void, - _: *mut size_t, - _: *const c_void, - _: size_t, + name: *const c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *const c_void, + newlen: size_t, ) -> c_int; pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; diff --git a/src/unix/nto/neutrino.rs b/src/unix/nto/neutrino.rs index f360605d1902e..b2603f8b1a1fc 100644 --- a/src/unix/nto/neutrino.rs +++ b/src/unix/nto/neutrino.rs @@ -172,6 +172,7 @@ s! { pub tick_nsec_inc: i32, } + #[cfg(target_os = "nto")] pub struct qtime_entry { pub cycles_per_sec: u64, pub nsec_tod_adjust: u64, // volatile @@ -190,7 +191,26 @@ s! { pub nsec_stable: u64, // volatile pub timer_load_max: u64, pub timer_prog_time: u32, - spare: [u32; 7], + spare: Padding<[u32; 7]>, + } + + #[cfg(target_os = "qnx")] + pub struct qtime_entry { + pub cycles_per_sec: u64, + pub nsec_tod_adjust: u64, // volatile + pub nsec_inc: u32, + pub boot_time: u32, + pub adjust: _clockadjust, + pub timer_period: u32, + pub timer_scale: i32, + pub intr: i32, + pub epoch: u32, + pub flags: u32, + pub rr_interval_mul: u32, + pub timer_load_max: u64, + pub boot_cc: u64, + pub tick_period_cc: u64, + spare: Padding<[u64; 3]>, } pub struct _sched_info { @@ -219,6 +239,7 @@ s! { } s_no_extra_traits! { + #[cfg(target_os = "nto")] #[repr(align(8))] pub struct syspage_entry { pub size: u16, @@ -240,14 +261,38 @@ s_no_extra_traits! { pub smp: syspage_entry_info, pub pminfo: syspage_entry_info, pub old_mdriver: syspage_entry_info, - spare0: [u32; 1], - __reserved: Padding<[u8; 160]>, // anonymous union with architecture dependent structs + spare0: Padding<[u32; 1]>, + __reserved: Padding<[u64; 20]>, // anonymous union with architecture dependent structs pub new_asinfo: syspage_array_info, pub new_cpuinfo: syspage_array_info, pub new_cacheattr: syspage_array_info, pub new_intrinfo: syspage_array_info, pub new_mdriver: syspage_array_info, } + + #[cfg(target_os = "qnx")] + #[repr(align(8))] + pub struct syspage_entry { + pub size: u16, + pub total_size: u16, + pub type_: u16, + pub num_cpu: u16, + pub system_private: syspage_entry_info, + version: [u16; 2], // inline struct + pub hwinfo: syspage_entry_info, + pub qtime: syspage_entry_info, + pub callout: syspage_entry_info, + pub typed_strings: syspage_entry_info, + pub strings: syspage_entry_info, + pub smp: syspage_entry_info, + __reserved: Padding<[u64; 20]>, // anonymous union with architecture dependent structs + pub asinfo: syspage_array_info, + pub cpuinfo: syspage_array_info, + pub cacheattr: syspage_array_info, + pub intrinfo: syspage_array_info, + pub hypinfo: syspage_entry_info, + pub cluster: syspage_array_info, + } } pub const SYSMGR_PID: u32 = 1; @@ -262,7 +307,9 @@ pub const STATE_STOPPED: c_int = 0x03; pub const STATE_SEND: c_int = 0x04; pub const STATE_RECEIVE: c_int = 0x05; pub const STATE_REPLY: c_int = 0x06; +#[cfg(target_os = "nto")] // removed in QNX8 pub const STATE_STACK: c_int = 0x07; +#[cfg(target_os = "nto")] // removed in QNX8 pub const STATE_WAITTHREAD: c_int = 0x08; pub const STATE_WAITPAGE: c_int = 0x09; pub const STATE_SIGSUSPEND: c_int = 0x0a; @@ -274,9 +321,14 @@ pub const STATE_JOIN: c_int = 0x0f; pub const STATE_INTR: c_int = 0x10; pub const STATE_SEM: c_int = 0x11; pub const STATE_WAITCTX: c_int = 0x12; +#[cfg(target_os = "nto")] // removed in QNX8 pub const STATE_NET_SEND: c_int = 0x13; +#[cfg(target_os = "nto")] // removed in QNX8 pub const STATE_NET_REPLY: c_int = 0x14; +#[cfg(target_os = "nto")] pub const STATE_MAX: c_int = 0x18; +#[cfg(target_os = "qnx")] +pub const STATE_MAX: c_int = 63; pub const _NTO_TIMEOUT_RECEIVE: i32 = 1 << STATE_RECEIVE; pub const _NTO_TIMEOUT_SEND: i32 = 1 << STATE_SEND; @@ -294,10 +346,12 @@ pub const _NTO_MI_ENDIAN_BIG: u32 = 1; pub const _NTO_MI_ENDIAN_DIFF: u32 = 2; pub const _NTO_MI_UNBLOCK_REQ: u32 = 256; pub const _NTO_MI_NET_CRED_DIRTY: u32 = 512; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const _NTO_MI_CONSTRAINED: u32 = 1024; pub const _NTO_MI_CHROOT: u32 = 2048; pub const _NTO_MI_BITS_64: u32 = 4096; pub const _NTO_MI_BITS_DIFF: u32 = 8192; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const _NTO_MI_SANDBOX: u32 = 16384; pub const _NTO_CI_ENDIAN_BIG: u32 = 1; @@ -307,7 +361,9 @@ pub const _NTO_CI_STOPPED: u32 = 128; pub const _NTO_CI_UNABLE: u32 = 256; pub const _NTO_CI_TYPE_ID: u32 = 512; pub const _NTO_CI_CHROOT: u32 = 2048; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_CI_BITS_64: u32 = 4096; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_CI_SANDBOX: u32 = 16384; pub const _NTO_CI_LOADER: u32 = 32768; pub const _NTO_CI_FULL_GROUPS: u32 = 2147483648; @@ -351,6 +407,7 @@ pub const _NTO_PF_TERMING: u32 = 4; pub const _NTO_PF_ZOMBIE: u32 = 8; pub const _NTO_PF_NOZOMBIE: u32 = 16; pub const _NTO_PF_FORKED: u32 = 32; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_ORPHAN_PGRP: u32 = 64; pub const _NTO_PF_STOPPED: u32 = 128; pub const _NTO_PF_DEBUG_STOPPED: u32 = 256; @@ -359,33 +416,50 @@ pub const _NTO_PF_NOISYNC: u32 = 1024; pub const _NTO_PF_CONTINUED: u32 = 2048; pub const _NTO_PF_CHECK_INTR: u32 = 4096; pub const _NTO_PF_COREDUMP: u32 = 8192; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_RING0: u32 = 32768; pub const _NTO_PF_SLEADER: u32 = 65536; pub const _NTO_PF_WAITINFO: u32 = 131072; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_DESTROYALL: u32 = 524288; pub const _NTO_PF_NOCOREDUMP: u32 = 1048576; pub const _NTO_PF_WAITDONE: u32 = 4194304; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_TERM_WAITING: u32 = 8388608; pub const _NTO_PF_ASLR: u32 = 16777216; pub const _NTO_PF_EXECED: u32 = 33554432; pub const _NTO_PF_APP_STOPPED: u32 = 67108864; pub const _NTO_PF_64BIT: u32 = 134217728; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_NET: u32 = 268435456; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_NOLAZYSTACK: u32 = 536870912; pub const _NTO_PF_NOEXEC_STACK: u32 = 1073741824; pub const _NTO_PF_LOADER_PERMS: u32 = 2147483648; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_INTR_PENDING: u32 = 65536; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_DETACHED: u32 = 131072; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_SHR_MUTEX: u32 = 262144; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_SHR_MUTEX_EUID: u32 = 524288; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_THREADS_HOLD: u32 = 1048576; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_UNBLOCK_REQ: u32 = 4194304; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_ALIGN_FAULT: u32 = 16777216; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_SSTEP: u32 = 33554432; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_ALLOCED_STACK: u32 = 67108864; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_NOMULTISIG: u32 = 134217728; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_LOW_LATENCY: u32 = 268435456; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_IOPRIV: u32 = 2147483648; pub const _NTO_TCTL_IO_PRIV: u32 = 1; @@ -394,15 +468,20 @@ pub const _NTO_TCTL_THREADS_CONT: u32 = 3; pub const _NTO_TCTL_RUNMASK: u32 = 4; pub const _NTO_TCTL_ALIGN_FAULT: u32 = 5; pub const _NTO_TCTL_RUNMASK_GET_AND_SET: u32 = 6; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_PERFCOUNT: u32 = 7; pub const _NTO_TCTL_ONE_THREAD_HOLD: u32 = 8; pub const _NTO_TCTL_ONE_THREAD_CONT: u32 = 9; pub const _NTO_TCTL_RUNMASK_GET_AND_SET_INHERIT: u32 = 10; pub const _NTO_TCTL_NAME: u32 = 11; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_RCM_GET_AND_SET: u32 = 12; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_SHR_MUTEX: u32 = 13; pub const _NTO_TCTL_IO: u32 = 14; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_NET_KIF_GET_AND_SET: u32 = 15; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_LOW_LATENCY: u32 = 16; pub const _NTO_TCTL_ADD_EXIT_EVENT: u32 = 17; pub const _NTO_TCTL_DEL_EXIT_EVENT: u32 = 18; @@ -424,7 +503,9 @@ pub const _NTO_CHF_SENDER_LEN: u32 = 32; pub const _NTO_CHF_COID_DISCONNECT: u32 = 64; pub const _NTO_CHF_REPLY_LEN: u32 = 128; pub const _NTO_CHF_PULSE_POOL: u32 = 256; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_CHF_ASYNC_NONBLOCK: u32 = 512; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_CHF_ASYNC: u32 = 1024; pub const _NTO_CHF_GLOBAL: u32 = 2048; pub const _NTO_CHF_PRIVATE: u32 = 4096; @@ -437,13 +518,19 @@ pub const _NTO_CHO_CUSTOM_EVENT: u32 = 1; pub const _NTO_COF_CLOEXEC: u32 = 1; pub const _NTO_COF_DEAD: u32 = 2; pub const _NTO_COF_NOSHARE: u32 = 64; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_NETCON: u32 = 128; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_NONBLOCK: u32 = 256; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_ASYNC: u32 = 512; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_GLOBAL: u32 = 1024; pub const _NTO_COF_NOEVENT: u32 = 2048; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_INSECURE: u32 = 4096; pub const _NTO_COF_REG_EVENTS: u32 = 8192; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_UNREG_EVENTS: u32 = 16384; pub const _NTO_COF_MASK: u32 = 65535; @@ -452,8 +539,18 @@ pub const _NTO_SIDE_CHANNEL: u32 = 1073741824; pub const _NTO_CONNECTION_SCOID: u32 = 65536; pub const _NTO_GLOBAL_CHANNEL: u32 = 1073741824; -pub const _NTO_TIMEOUT_MASK: u32 = (1 << STATE_MAX) - 1; -pub const _NTO_TIMEOUT_ACTIVE: u32 = 1 << STATE_MAX; +const STATE_TIMEOUT_MAX: u8 = 24; +pub const _NTO_TIMEOUT_MASK: u32 = if cfg!(target_os = "nto") { + (1 << STATE_MAX) - 1 +} else { + (1 << STATE_TIMEOUT_MAX) - 1 +}; +pub const _NTO_TIMEOUT_ACTIVE: u32 = if cfg!(target_os = "nto") { + 1 << STATE_MAX +} else { + 1 << STATE_TIMEOUT_MAX +}; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TIMEOUT_IMMEDIATE: u32 = 1 << (STATE_MAX + 1); pub const _NTO_IC_LATENCY: u32 = 0; @@ -476,31 +573,54 @@ pub const _NTO_HOOK_OVERDRIVE: u32 = 2147418114; pub const _NTO_HOOK_LAST: u32 = 2147418114; pub const _NTO_HOOK_IDLE2_FLAG: u32 = 32768; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_CMD_SLEEP_SETUP: u32 = 1; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_CMD_SLEEP_BLOCK: u32 = 2; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_CMD_SLEEP_WAKEUP: u32 = 4; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_CMD_SLEEP_ONLINE: u32 = 8; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_NEEDS_BLOCK: u32 = 1; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_NEEDS_WAKEUP: u32 = 2; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_NEEDS_ONLINE: u32 = 4; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_SYNC_TIME: u32 = 16; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_SYNC_TLB: u32 = 32; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_SUGGEST_OFFLINE: u32 = 256; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_SLEEP_MODE_REACHED: u32 = 512; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_DELIVER_INTRS: u32 = 1024; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_READIOV_SEND: u32 = 0; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_READIOV_REPLY: u32 = 1; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_VTID: u32 = 2147483648; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_PATHSIGN: u32 = 32768; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_OP_MASK: u32 = 255; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_VERIFY: u32 = 0; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_CALCULATE: u32 = 1; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_CALCULATE_REUSE: u32 = 2; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_PATHSIGN_VERIFY: u32 = 32768; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_PATHSIGN_CALCULATE: u32 = 32769; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_PATHSIGN_CALCULATE_REUSE: u32 = 32770; pub const _NTO_SCTL_SETPRIOCEILING: u32 = 1; @@ -517,6 +637,7 @@ extern "C" { pub fn ChannelCreate(__flags: c_uint) -> c_int; pub fn ChannelCreate_r(__flags: c_uint) -> c_int; pub fn ChannelCreatePulsePool(__flags: c_uint, __config: *const nto_channel_config) -> c_int; + #[cfg(target_os = "nto")] pub fn ChannelCreateExt( __flags: c_uint, __mode: crate::mode_t, @@ -763,12 +884,14 @@ extern "C" { __bytes: usize, __info: *mut _msg_info64, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReceivePulsev( __chid: c_int, __iov: *const crate::iovec, __parts: usize, __info: *mut _msg_info64, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReceivePulsev_r( __chid: c_int, __iov: *const crate::iovec, @@ -799,6 +922,7 @@ extern "C" { __iov: *const crate::iovec, __parts: usize, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReadiov( __rcvid: c_int, __iov: *const crate::iovec, @@ -806,6 +930,7 @@ extern "C" { __offset: usize, __flags: c_int, ) -> isize; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReadiov_r( __rcvid: c_int, __iov: *const crate::iovec, @@ -872,6 +997,7 @@ extern "C" { pub fn MsgUnregisterEvent_r(__event: *const crate::sigevent) -> c_int; pub fn MsgInfo(__rcvid: c_int, __info: *mut _msg_info64) -> c_int; pub fn MsgInfo_r(__rcvid: c_int, __info: *mut _msg_info64) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgKeyData( __rcvid: c_int, __oper: c_int, @@ -880,6 +1006,7 @@ extern "C" { __iov: *const crate::iovec, __parts: c_int, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgKeyData_r( __rcvid: c_int, __oper: c_int, @@ -892,13 +1019,16 @@ extern "C" { pub fn MsgError_r(__rcvid: c_int, __err: c_int) -> c_int; pub fn MsgCurrent(__rcvid: c_int) -> c_int; pub fn MsgCurrent_r(__rcvid: c_int) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgSendAsyncGbl( __coid: c_int, __smsg: *const c_void, __sbytes: usize, __msg_prio: c_uint, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgSendAsync(__coid: c_int) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReceiveAsyncGbl( __chid: c_int, __rmsg: *mut c_void, @@ -906,6 +1036,7 @@ extern "C" { __info: *mut _msg_info64, __coid: c_int, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReceiveAsync(__chid: c_int, __iov: *const crate::iovec, __parts: c_uint) -> c_int; pub fn MsgPause(__rcvid: c_int, __cookie: c_uint) -> c_int; pub fn MsgPause_r(__rcvid: c_int, __cookie: c_uint) -> c_int; @@ -943,6 +1074,7 @@ extern "C" { __value: *const crate::sigval, ) -> c_int; pub fn SignalReturn(__info: *mut _sighandler_info) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn SignalFault(__sigcode: c_uint, __regs: *mut c_void, __refaddr: usize) -> c_int; pub fn SignalAction( __pid: crate::pid_t, @@ -1087,12 +1219,14 @@ extern "C" { pub fn InterruptDetach_r(__id: c_int) -> c_int; pub fn InterruptWait(__flags: c_int, __timeout: *const u64) -> c_int; pub fn InterruptWait_r(__flags: c_int, __timeout: *const u64) -> c_int; + #[cfg(target_os = "nto")] // declaration exists but symbol was removed in QNX8 pub fn InterruptCharacteristic( __type: c_int, __id: c_int, __new: *mut c_uint, __old: *mut c_uint, ) -> c_int; + #[cfg(target_os = "nto")] // declaration exists but symbol was removed in QNX8 pub fn InterruptCharacteristic_r( __type: c_int, __id: c_int, @@ -1134,12 +1268,14 @@ extern "C" { pub fn SchedJobCreate_r(__job: *mut nto_job_t) -> c_int; pub fn SchedJobDestroy(__job: *mut nto_job_t) -> c_int; pub fn SchedJobDestroy_r(__job: *mut nto_job_t) -> c_int; + #[cfg(target_os = "nto")] // declaration exists but symbol was removed in QNX8 pub fn SchedWaypoint( __job: *mut nto_job_t, __new: *const i64, __max: *const i64, __old: *mut i64, ) -> c_int; + #[cfg(target_os = "nto")] // declaration exists but symbol was removed in QNX8 pub fn SchedWaypoint_r( __job: *mut nto_job_t, __new: *const i64, @@ -1220,7 +1356,9 @@ extern "C" { pub fn SyncMutexLock_r(__sync: *mut crate::sync_t) -> c_int; pub fn SyncMutexUnlock(__sync: *mut crate::sync_t) -> c_int; pub fn SyncMutexUnlock_r(__sync: *mut crate::sync_t) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn SyncMutexRevive(__sync: *mut crate::sync_t) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn SyncMutexRevive_r(__sync: *mut crate::sync_t) -> c_int; pub fn SyncCondvarWait(__sync: *mut crate::sync_t, __mutex: *mut crate::sync_t) -> c_int; pub fn SyncCondvarWait_r(__sync: *mut crate::sync_t, __mutex: *mut crate::sync_t) -> c_int; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index b1100342b8bce..2380bba1ba40f 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -473,23 +473,23 @@ pub const F_GETFL: i32 = 0x2; pub const F_SETFD: i32 = 8; pub const F_SETFL: i32 = 9; // open flag settings for open() (and related APIs) -pub const O_RDONLY: i32 = 0x1; -pub const O_WRONLY: i32 = 0x2; -pub const O_RDWR: i32 = 0x3; -pub const O_CREAT: i32 = 0x4; -pub const O_EXCL: i32 = 0x8; -pub const O_NOCTTY: i32 = 0x0; -pub const O_TRUNC: i32 = 0x20; -pub const O_APPEND: i32 = 0x10; -pub const O_NONBLOCK: i32 = 0x40; -pub const O_DSYNC: i32 = 0x80; -pub const O_DIRECT: i32 = 0x200; -pub const O_LARGEFILE: i32 = 0x2000; -pub const O_DIRECTORY: i32 = 0x800; -pub const O_NOFOLLOW: i32 = 0x1000; +pub const O_RDONLY: i32 = 0x0; +pub const O_WRONLY: i32 = 0x1; +pub const O_RDWR: i32 = 0x2; +pub const O_CREAT: i32 = 0x40; +pub const O_EXCL: i32 = 0x80; +pub const O_NOCTTY: i32 = 0x100; +pub const O_TRUNC: i32 = 0x200; +pub const O_APPEND: i32 = 0x400; +pub const O_NONBLOCK: i32 = 0x800; +pub const O_DSYNC: i32 = 0x1000; +pub const O_DIRECT: i32 = 0x4000; +pub const O_LARGEFILE: i32 = 0x8000; +pub const O_DIRECTORY: i32 = 0x10000; +pub const O_NOFOLLOW: i32 = 0x20000; pub const O_NOATIME: i32 = 0x40000; -pub const O_CLOEXEC: i32 = 0x400; -pub const O_ACCMODE: i32 = 0x0003; +pub const O_CLOEXEC: i32 = 0x80000; +pub const O_ACCMODE: i32 = 0x3; pub const AT_FDCWD: i32 = -100; pub const AT_REMOVEDIR: i32 = 0x200; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index ce0efa12ebd6c..4e21f57b3e187 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -28,8 +28,19 @@ pub type suseconds_t = c_int; pub type tcflag_t = u32; pub type time_t = c_longlong; pub type id_t = c_uint; +pub type pid_t = c_int; pub type uid_t = c_int; pub type gid_t = c_int; +pub type ucontext_t = ucontext; +pub type stack_t = sigaltstack; +pub type siginfo_t = siginfo; +#[cfg(any( + target_arch = "x86", + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64" +))] +pub type mcontext_t = mcontext; extern_ty! { pub type timezone; @@ -157,12 +168,21 @@ s! { pub sa_mask: crate::sigset_t, } - pub struct siginfo_t { + pub struct siginfo { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], + pub si_pid: pid_t, + pub si_uid: uid_t, + pub si_addr: *mut c_void, + pub si_status: c_int, + pub si_value: crate::sigval, + } + + pub struct sigaltstack { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, } pub struct sockaddr { @@ -255,47 +275,147 @@ s! { pub struct pthread_attr_t { bytes: [u8; _PTHREAD_ATTR_SIZE], } + #[repr(align(4))] pub struct pthread_barrier_t { bytes: [u8; _PTHREAD_BARRIER_SIZE], } + #[repr(align(4))] pub struct pthread_barrierattr_t { bytes: [u8; _PTHREAD_BARRIERATTR_SIZE], } + #[repr(align(4))] pub struct pthread_mutex_t { bytes: [u8; _PTHREAD_MUTEX_SIZE], } + #[repr(align(4))] pub struct pthread_rwlock_t { bytes: [u8; _PTHREAD_RWLOCK_SIZE], } + #[repr(align(4))] pub struct pthread_mutexattr_t { bytes: [u8; _PTHREAD_MUTEXATTR_SIZE], } + #[repr(align(1))] pub struct pthread_rwlockattr_t { bytes: [u8; _PTHREAD_RWLOCKATTR_SIZE], } + #[repr(align(4))] pub struct pthread_cond_t { bytes: [u8; _PTHREAD_COND_SIZE], } + #[repr(align(4))] pub struct pthread_condattr_t { bytes: [u8; _PTHREAD_CONDATTR_SIZE], } + #[repr(align(4))] pub struct pthread_once_t { bytes: [u8; _PTHREAD_ONCE_SIZE], } + #[repr(align(4))] pub struct pthread_spinlock_t { bytes: [u8; _PTHREAD_SPINLOCK_SIZE], } + + pub struct ucontext { + #[cfg(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64" + ))] + _pad: [c_ulong; 1], // pad from 7*8 to 64 + + #[cfg(target_arch = "x86")] + _pad: [c_ulong; 3], // pad from 9*4 to 12*4 + + pub uc_link: *mut ucontext_t, + pub uc_stack: stack_t, + pub uc_sigmask: sigset_t, + _sival: c_ulong, + _sigcode: c_uint, + _signum: c_uint, + pub uc_mcontext: mcontext_t, + } + + #[cfg(target_arch = "x86")] + pub struct mcontext { + _opaque: [c_uchar; 512], + } + + #[cfg(target_arch = "x86_64")] + pub struct mcontext { + pub ymm_upper: [[c_ulong; 2]; 16], + pub fxsave: [[c_ulong; 2]; 29], + pub r15: c_ulong, // fxsave "available" +0 + pub r14: c_ulong, // available +8 + pub r13: c_ulong, // available +16 + pub r12: c_ulong, // available +24 + pub rbp: c_ulong, // available +32 + pub rbx: c_ulong, // available +40 + pub r11: c_ulong, // outside fxsave, and so on + 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 rflags: c_ulong, + pub rip: c_ulong, + pub rsp: c_ulong, + } + + #[cfg(target_arch = "aarch64")] + pub struct mcontext { + _opaque: [c_uchar; 272], + } + + #[cfg(target_arch = "riscv64")] + pub struct mcontext { + _opaque: [c_uchar; 520], + } } + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_code(&self) -> c_int { + self.si_code + } + + pub unsafe fn si_errno(&self) -> c_int { + self.si_errno + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> uid_t { + self.si_uid + } + + pub unsafe fn si_value(&self) -> crate::sigval { + self.si_value + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status + } +} + const _PTHREAD_ATTR_SIZE: usize = 32; const _PTHREAD_RWLOCKATTR_SIZE: usize = 1; const _PTHREAD_RWLOCK_SIZE: usize = 4; @@ -673,6 +793,9 @@ pub const SA_NODEFER: c_int = 0x1000_0000; pub const SA_RESETHAND: c_int = 0x2000_0000; pub const SA_NOCLDSTOP: c_int = 0x4000_0000; +pub const SS_ONSTACK: c_int = 0x00000001; +pub const SS_DISABLE: c_int = 0x00000002; + // sys/file.h pub const LOCK_SH: c_int = 1; pub const LOCK_EX: c_int = 2; @@ -1334,6 +1457,7 @@ extern "C" { timeout: *const crate::timespec, ) -> c_int; pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; // stdlib.h pub fn getsubopt( @@ -1432,6 +1556,7 @@ extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; pub fn strftime( s: *mut c_char, max: size_t, diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index b336c316ba2a4..86f2d7ebee975 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -87,7 +87,7 @@ s_no_extra_traits! { pub union door_desc_t__d_data { pub d_desc: door_desc_t__d_data__d_desc, - d_resv: [c_int; 5], /* Check out /usr/include/sys/door.h */ + d_resv: Padding<[c_int; 5]>, /* Check out /usr/include/sys/door.h */ } pub struct door_desc_t { diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 91e0a9dab4bee..07bf8b49ec4dc 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -680,8 +680,10 @@ pub const EAI_SERVICE: c_int = 9; pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; -pub const INT_MAX: c_int = 0x7fffffff; -pub const INT_MIN: c_int = -INT_MAX - 1; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index a21aa4f32635f..b386ecf696ea4 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -554,6 +554,14 @@ pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_ #[allow(unused_unsafe)] pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; +pub const LC_CTYPE: c_int = 0; +pub const LC_NUMERIC: c_int = 1; +pub const LC_TIME: c_int = 2; +pub const LC_COLLATE: c_int = 3; +pub const LC_MONETARY: c_int = 4; +pub const LC_MESSAGES: c_int = 5; +pub const LC_ALL: c_int = 6; + pub const ABDAY_1: crate::nl_item = 0x20000; pub const ABDAY_2: crate::nl_item = 0x20001; pub const ABDAY_3: crate::nl_item = 0x20002; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 67e8df3b46dc2..d2d6c281346a9 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -96,8 +96,10 @@ s! { } } -pub const INT_MIN: c_int = -2147483648; -pub const INT_MAX: c_int = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX; pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; diff --git a/src/xous.rs b/src/xous.rs index 2415fd42824e1..713eab6f4107a 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -14,5 +14,7 @@ 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; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] +pub const INT_MIN: c_int = c_int::MIN; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] +pub const INT_MAX: c_int = c_int::MAX;