diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fdc77ccc27fd2..bf6aa9bc50f18 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-26.04 timeout-minutes: 10 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup Rust toolchain @@ -44,7 +44,7 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - run: rustup update stable --no-self-update @@ -75,14 +75,14 @@ jobs: env: TOOLCHAIN: ${{ matrix.toolchain }} steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh - name: Install semver-checks - uses: taiki-e/install-action@a6b2e2dcd845ddd7f509ce4f3ed3d922b80cc5d9 # v2.84.0 + uses: taiki-e/install-action@6a1bd70eaac3c8bdf093356838d7ee09fda951cf # v2.85.5 if: matrix.toolchain == 'stable' with: tool: cargo-semver-checks @@ -133,8 +133,6 @@ jobs: os: windows-11-arm - target: aarch64-unknown-linux-gnu os: ubuntu-26.04-arm - - target: i686-pc-windows-gnu - os: windows-2025 - target: i686-pc-windows-msvc os: windows-2025 - target: i686-unknown-linux-gnu @@ -148,7 +146,7 @@ jobs: env: TARGET: ${{ matrix.target }} steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup Rust toolchain @@ -231,7 +229,6 @@ jobs: - target: x86_64-apple-darwin os: macos-26-intel - target: x86_64-linux-android - env: { TEST_CUTTLEFISH: 1 } # Keep in sync with the Android build pinned in ci/cuttlefish-setup.sh artifact-tag: android17 # FIXME: Exec format error (os error 8) @@ -251,7 +248,7 @@ jobs: env: TARGET: ${{ matrix.target }} steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup Rust toolchain @@ -303,7 +300,7 @@ jobs: - target: x86_64-unknown-illumos timeout-minutes: 25 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Test on FreeBSD @@ -334,7 +331,7 @@ jobs: run: ./ci/bsd-run.sh ${{ matrix.target }} - name: Test on NetBSD - uses: vmactions/netbsd-vm@0c26a4c4a5e234038862a4a53a00c905b8a107c9 # v1.4.2 + uses: vmactions/netbsd-vm@e7ac71b97abbe8437cec8859a5acf72dfa6a8be0 # v1.4.5 if: contains(matrix.target, 'netbsd') with: release: "10.1" @@ -363,11 +360,12 @@ jobs: runs-on: ubuntu-26.04 timeout-minutes: 10 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Install Rust - run: rustup update nightly --no-self-update && rustup default nightly + # 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 - run: cargo doc --workspace --no-deps @@ -379,12 +377,12 @@ jobs: timeout-minutes: 10 steps: - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Run zizmor - uses: zizmorcore/zizmor-action@192e21d79ab29983730a13d1382995c2307fbcaa # v0.5.7 + uses: zizmorcore/zizmor-action@6fc4b006235f201fdab3722e17240ab420d580e5 # v0.6.1 # 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/.github/workflows/publish_0.2.yml b/.github/workflows/publish_0.2.yml index a3d921b2ac075..6a86d8bbb84bf 100644 --- a/.github/workflows/publish_0.2.yml +++ b/.github/workflows/publish_0.2.yml @@ -15,9 +15,10 @@ jobs: release-plz: name: Release-plz v0.2 runs-on: ubuntu-latest + environment: release steps: - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false @@ -27,7 +28,6 @@ jobs: uses: release-plz/action@2eb1d8bcb770b4c48ccfaad919734b38b51958c9 # v0.5.131 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} with: # FIXME(release): release-pr is broken since we have two release tracks for # `libc` :( diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5a5ac3ed43c23..35fcba6404ba7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -116,7 +116,7 @@ Please include permalinks to headers in commit messages for all API changes. Common sources include: * Linux uapi: https://github.com/torvalds/linux/tree/master/include/uapi -* Glibc: https://sourceware.org/git/?p=glibc.git;a=tree +* 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 diff --git a/Cargo.lock b/Cargo.lock index 12bcc4cf55b24..70bfea50a5c57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" dependencies = [ "memchr", ] @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.3.0" +version = "1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8" +checksum = "0ad534f4357a5264cce5019c989cf66a4f0dc4e0d1b1d15f8aacec0ff7360273" dependencies = [ "find-msvc-tools", "shlex", @@ -114,15 +114,15 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" +checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890" [[package]] name = "glob" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" [[package]] name = "itoa" @@ -196,9 +196,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.16" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" dependencies = [ "aho-corasick", "memchr", @@ -249,7 +249,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn 3.0.2", + "syn 3.0.4", ] [[package]] @@ -284,9 +284,9 @@ dependencies = [ [[package]] name = "syn" -version = "3.0.2" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a207d6d6a2b7fc470b80443726053f18a2481b7e1eee970597051596567987a3" +checksum = "e6275cddf4610d1775e6d1fe9469b2e77d0f39fd98fb7450901b821e0c53649f" dependencies = [ "proc-macro2", "quote", @@ -295,22 +295,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.19" +version = "2.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.19" +version = "2.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" dependencies = [ "proc-macro2", "quote", - "syn 3.0.2", + "syn 3.0.4", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 380dd89fb693f..5ac3f724f41fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,15 @@ name = "libc" version = "0.2.189" keywords = ["libc", "ffi", "bindings", "operating", "system"] categories = ["external-ffi-bindings", "no-std", "os"] -exclude = ["/ci/*", "/.github/*", "/triagebot.toml", "cherry-pick-stable.sh"] +include = [ + "/src", + "/tests", + "/examples", + "/build.rs", + "/CHANGELOG*", + "/LICENSE*", + "/README*", +] description = "Raw FFI bindings to platform libraries like libc." edition = "2021" license = "MIT OR Apache-2.0" @@ -34,7 +42,6 @@ targets = [ "arm-unknown-linux-gnueabihf", "armv7-unknown-linux-gnueabihf", "armv7-unknown-linux-ohos", - "i686-pc-windows-gnu", "loongarch64-unknown-linux-gnu", "loongarch64-unknown-linux-musl", "powerpc-unknown-linux-gnu", @@ -72,6 +79,7 @@ targets = [ "i586-unknown-linux-gnu", "i586-unknown-linux-musl", "i686-linux-android", + "i686-pc-windows-gnu", "i686-unknown-freebsd", "i686-unknown-linux-musl", "nvptx64-nvidia-cuda", @@ -128,6 +136,7 @@ targets = [ "powerpc64-ibm-aix", "powerpc64-unknown-freebsd", "powerpc64-unknown-linux-gnu", + "powerpc64-unknown-linux-gnuelfv2", "powerpc64-wrs-vxworks", "riscv32-wrs-vxworks", "riscv32gc-unknown-linux-musl", diff --git a/build.rs b/build.rs index 67da9c63b02f1..4a5e154f85a27 100644 --- a/build.rs +++ b/build.rs @@ -30,6 +30,7 @@ const ALLOWED_CFGS: &[&str] = &[ // GNU to expose a 64-bit `time_t`. "gnu_time_bits64", "libc_deny_warnings", + "libc_elfv2", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", @@ -92,9 +93,12 @@ fn main() { let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); let target_abi = env::var("CARGO_CFG_TARGET_ABI").unwrap_or_default(); - // FIXME(msrv): Once the MSRV is 1.78, use `cfg(target_abi = "pauthtest")` - // directly instead of translating it to `libc_pauthtest`. `target_abi` - // cannot be used directly in cfg expressions on the current MSRV. + // FIXME(msrv): Once the MSRV is 1.78, use `cfg(target_abi)` directly instead + // of translating its values. `target_abi` cannot be used directly in cfg + // expressions on the current MSRV. + if target_abi == "elfv2" { + set_cfg("libc_elfv2"); + } if target_abi == "pauthtest" { set_cfg("libc_pauthtest"); } @@ -147,6 +151,13 @@ fn main() { } let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3"); + 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" + ); + musl_v1_2_3 |= old_musl_v1_2_3 != "0"; + } // OpenHarmony uses a fork of the musl libc let musl = target_env == "musl" || target_env == "ohos"; @@ -177,7 +188,7 @@ fn main() { } if target_env == "gnu" - && matches!(target_os.as_str(), "linux" | "windows") + && matches!(target_os.as_str(), "linux" | "windows" | "hurd") && target_ptr_width == "32" && target_arch != "riscv32" && target_arch != "x86_64" diff --git a/ci/android-install-sdk.sh b/ci/android-install-sdk.sh index 43e1153dcd331..fa1e021ede5b4 100755 --- a/ci/android-install-sdk.sh +++ b/ci/android-install-sdk.sh @@ -14,25 +14,31 @@ mkdir -p sdk/cmdline-tools wget -q --tries=20 "https://dl.google.com/android/repository/commandlinetools-linux-${sdk}_latest.zip" unzip -q -d sdk/cmdline-tools "commandlinetools-linux-${sdk}_latest.zip" -case "$1" in +# The API level is passed in (arg 2) so it stays a single source of truth +# shared with the CC wrapper name in the Dockerfile; only the image variant +# is arch-specific here. +arch="$1" +api="$2" +if [ -z "${api}" ]; then + echo "usage: $0 " + exit 1 +fi + +case "${arch}" in arm | armv7) - api=24 image="system-images;android-${api};default;armeabi-v7a" ;; aarch64) - api=24 image="system-images;android-${api};google_apis;arm64-v8a" ;; i686) - api=28 image="system-images;android-${api};default;x86" ;; x86_64) - api=28 image="system-images;android-${api};default;x86_64" ;; *) - echo "invalid arch: $1" + echo "invalid arch: ${arch}" exit 1 ;; esac @@ -66,7 +72,7 @@ cp /android/android-emulator-package.xml /android/sdk/emulator/package.xml echo "no" | ./sdk/cmdline-tools/tools/bin/avdmanager create avd \ - --name "${1}" \ + --name "${arch}" \ --package "${image}" | grep -v = || true rm -rf "commandlinetools-linux-${sdk}_latest.zip" emulator-linux_x64-9058569.zip diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index 91c074150f94d..5d0ee0f9c1e4a 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -18,18 +18,22 @@ WORKDIR /android/ COPY android* /android/ ENV ANDROID_ARCH=aarch64 +# Single source of truth for the API level: it selects the emulator system +# image (passed to android-install-sdk.sh) and names the CC wrapper below, so +# the toolchain can never drift from the image the tests run on. +ARG ANDROID_API=24 ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools RUN /android/android-install-ndk.sh -RUN /android/android-install-sdk.sh $ANDROID_ARCH +RUN /android/android-install-sdk.sh $ANDROID_ARCH $ANDROID_API RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* ENV PATH=$PATH:/rust/bin \ - CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android28-clang \ + CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android${ANDROID_API}-clang \ CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \ - CC_aarch64_linux_android=aarch64-linux-android28-clang \ + CC_aarch64_linux_android=aarch64-linux-android${ANDROID_API}-clang \ AR_aarch64_linux_android=llvm-ar \ HOME=/tmp diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index 657ff81097c7e..3317d53cbfcaf 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -18,18 +18,22 @@ WORKDIR /android/ COPY android* /android/ ENV ANDROID_ARCH=arm +# Single source of truth for the API level: it selects the emulator system +# image (passed to android-install-sdk.sh) and names the CC wrapper below, so +# the toolchain can never drift from the image the tests run on. +ARG ANDROID_API=24 ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools RUN /android/android-install-ndk.sh -RUN /android/android-install-sdk.sh $ANDROID_ARCH +RUN /android/android-install-sdk.sh $ANDROID_ARCH $ANDROID_API RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* ENV PATH=$PATH:/rust/bin \ - CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi28-clang \ + CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi${ANDROID_API}-clang \ CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=/tmp/runtest \ - CC_arm_linux_androideabi=armv7a-linux-androideabi28-clang \ + CC_arm_linux_androideabi=armv7a-linux-androideabi${ANDROID_API}-clang \ AR_arm_linux_androideabi=llvm-ar \ HOME=/tmp diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index 62eee968057bc..6b0e08d2cfcf7 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:26.04 +FROM debian:13 RUN apt-get update && apt-get install -y --no-install-recommends \ adb \ @@ -21,15 +21,19 @@ RUN curl -fsSL https://us-apt.pkg.dev/doc/repo-signing-key.gpg \ WORKDIR /android/ ENV ANDROID_ARCH=x86_64 +# The API level we compile against: this only names the CC wrapper and the toolchain we use. +# The Android Cuttlefish device is pinned separately and is newer, i.e. capable of testing +# newer APIs. The toolchain wrapper is held at the same baseline as arm/aarch64 for now. +ARG ANDROID_API=24 COPY android-install-ndk.sh /android/ RUN /android/android-install-ndk.sh ENV PATH=$PATH:/rust/bin:/android/linux-x86_64/bin \ ANDROID_SERIAL=127.0.0.1:6520 \ - CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android28-clang \ + CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android${ANDROID_API}-clang \ CARGO_TARGET_X86_64_LINUX_ANDROID_RUNNER=/tmp/runtest \ - CC_x86_64_linux_android=x86_64-linux-android28-clang \ - CXX_x86_64_linux_android=x86_64-linux-android28-clang++ \ + CC_x86_64_linux_android=x86_64-linux-android${ANDROID_API}-clang \ + CXX_x86_64_linux_android=x86_64-linux-android${ANDROID_API}-clang++ \ AR_x86_64_linux_android=llvm-ar \ HOME=/tmp diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 218fa4e1ca0f7..67ca55fadd0a2 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -59,13 +59,11 @@ run() { mkdir -p target extra_args=() - if [ -n "${TEST_CUTTLEFISH:-}" ]; then - # Cuttlefish-based Android targets boot their virtual device inside - # the container (see cuttlefish-entrypoint.sh in the target's docker - # dir): pass the virtualization device nodes and let the entrypoint - # create its tap networking. It starts as root and drops to an - # unprivileged user matching HOST_UID for the device and the tests. - # Same flags as upstream's containerized Cuttlefish CI. + # x86_64-linux-android boots a Cuttlefish virtual device inside the + # container. Give it the virtualization device nodes and NET_ADMIN it needs. + # These are the same flags Google's android-cuttlefish project uses for its + # own containerized CI. + if [ "$run_target" = "x86_64-linux-android" ]; then extra_args+=( --device /dev/kvm --device /dev/net/tun diff --git a/ci/style.py b/ci/style.py index e6c45ddfe80b6..ca3afa2bdf2fc 100755 --- a/ci/style.py +++ b/ci/style.py @@ -19,7 +19,7 @@ def main(): # if `CI` is set, do a check rather than overwriting check_only = os.getenv("CI") is not None - run(["rustfmt", "-V"]) + run(["rustfmt", "+nightly", "-V"]) fmt_files = [] for dir in FMT_DIRS: @@ -33,9 +33,9 @@ def main(): # Run once from workspace root to get everything that wasn't handled as an # individual file. if check_only: - run(["cargo", "fmt", "--check"]) + run(["cargo", "+nightly", "fmt", "--check"]) else: - run(["cargo", "fmt"]) + run(["cargo", "+nightly", "fmt"]) for file in iglob("libc-test/semver/*.txt"): check_semver_file(Path(file)) @@ -112,7 +112,7 @@ def enum_sub(m: re.Match) -> str: # Invoke rustfmt passing via stdin/stdout so we don't need to write the file. Exits # on failure. - cmd = ["rustfmt", "--config-path=.rustfmt.toml"] + cmd = ["rustfmt", "+nightly", "--config-path=.rustfmt.toml"] if check_only: res = check_output(cmd + ["--check"], input=text) diff --git a/ci/verify-build.py b/ci/verify-build.py index b41ad8a9e07ca..dc8ba576901b0 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -98,7 +98,6 @@ class TargetResult: Target("arm-unknown-linux-gnueabihf"), Target("armv7-unknown-linux-gnueabihf"), Target("armv7-unknown-linux-ohos", min_toolchain=Toolchain.STABLE), - Target("i686-pc-windows-gnu"), Target("loongarch64-unknown-linux-gnu", min_toolchain=Toolchain.STABLE), Target("loongarch64-unknown-linux-musl", min_toolchain=Toolchain.STABLE), Target("powerpc-unknown-linux-gnu"), @@ -136,6 +135,7 @@ class TargetResult: Target("i586-unknown-linux-gnu"), Target("i586-unknown-linux-musl"), Target("i686-linux-android"), + Target("i686-pc-windows-gnu"), Target("i686-unknown-freebsd"), Target("i686-unknown-linux-musl"), Target("nvptx64-nvidia-cuda", min_toolchain=Toolchain.STABLE), @@ -189,6 +189,7 @@ class TargetResult: Target("powerpc-wrs-vxworks-spe", dist=False), Target("powerpc64-ibm-aix", dist=False), Target("powerpc64-unknown-freebsd", dist=False), + Target("powerpc64-unknown-linux-gnuelfv2", dist=False), Target("powerpc64-wrs-vxworks", dist=False), Target("riscv32-wrs-vxworks", dist=False), Target("riscv32gc-unknown-linux-gnu", dist=False), diff --git a/ci/wasi.sh b/ci/wasi.sh index 2648aa38207d7..d4ba4bb64af01 100755 --- a/ci/wasi.sh +++ b/ci/wasi.sh @@ -11,8 +11,8 @@ apt-get install -y --no-install-recommends \ # Wasmtime is used to execute tests and wasi-sdk is used to compile tests. # Download appropriate versions here and configure various flags below. -wasmtime=38.0.2 -wasi_sdk=29 +wasmtime=47.0.2 +wasi_sdk=33 curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | tar xJf - diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 2bc12a29fee5a..12be9b3fafb70 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -6,6 +6,7 @@ publish = false edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" +build = "build/main.rs" [dependencies] cfg-if = "1.0.4" @@ -18,7 +19,7 @@ glob = "0.3.3" annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } [build-dependencies] -cc = "1.2.43" +cc = "1.4.2" # Use the in-tree `ctest` from the `main` branch via crates.io ctest = "0.5.0-beta.3" regex = "1.13.0" diff --git a/libc-test/build.rs b/libc-test/build/main.rs old mode 100644 new mode 100755 similarity index 96% rename from libc-test/build.rs rename to libc-test/build/main.rs index ef5e4a939a4f1..597f75f1cfd73 --- a/libc-test/build.rs +++ b/libc-test/build/main.rs @@ -1,26 +1,15 @@ #![allow(clippy::match_like_matches_macro)] +mod semver; + +use std::env; use std::env::VarError; -use std::fs::File; -use std::io::{ - BufRead, - BufReader, - BufWriter, - Write, -}; -use std::path::{ - Path, - PathBuf, -}; +use std::io::Write; use std::process::{ Command, Stdio, }; use std::sync::LazyLock; -use std::{ - env, - io, -}; use regex::Regex; @@ -56,6 +45,9 @@ fn do_cc() { if target.contains("android") || (target.contains("linux") && !target.contains("wasm32")) { cc::Build::new().file("src/errqueue.c").compile("errqueue"); } + if target.contains("linux") && !target.contains("android") && !target.contains("wasm32") { + cc::Build::new().file("src/nlmsg.c").compile("nlmsg"); + } if (target.contains("linux") && !target.contains("wasm32")) || target.contains("l4re") || target.contains("android") @@ -110,90 +102,15 @@ fn ctest_cfg() -> ctest::TestGenerator { cfg } -fn do_semver() { - let mut out = PathBuf::from(env::var("OUT_DIR").unwrap()); - out.push("semver.rs"); - let mut output = BufWriter::new(File::create(&out).unwrap()); - - let family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); - let vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap(); - let os = env::var("CARGO_CFG_TARGET_OS").unwrap(); - let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); - let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); - - // `libc-test/semver` dir. - let mut semver_root = PathBuf::from("semver"); - - // NOTE: Windows has the same `family` as `os`, no point in including it - // twice. - // 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 - // 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" { - process_semver_file(&mut output, &mut semver_root, &family); - } - // We don't do semver for unknown targets. - if vendor != "unknown" { - process_semver_file(&mut output, &mut semver_root, &vendor); - } - process_semver_file(&mut output, &mut semver_root, &os); - let os_arch = format!("{os}-{arch}"); - process_semver_file(&mut output, &mut semver_root, &os_arch); - if !target_env.is_empty() { - let os_env = format!("{os}-{target_env}"); - process_semver_file(&mut output, &mut semver_root, &os_env); - - let os_env_arch = format!("{os}-{target_env}-{arch}"); - process_semver_file(&mut output, &mut semver_root, &os_env_arch); - } -} - -fn process_semver_file>(output: &mut W, path: &mut PathBuf, file: P) { - // NOTE: `path` is reused between calls, so always remove the file again. - path.push(file); - path.set_extension("txt"); - - println!("cargo:rerun-if-changed={}", path.display()); - let input_file = match File::open(&*path) { - Ok(file) => file, - Err(ref err) if err.kind() == io::ErrorKind::NotFound => { - path.pop(); - return; - } - Err(err) => panic!("unexpected error opening file: {err}"), - }; - let input = BufReader::new(input_file); - - writeln!(output, "// Source: {}.", path.display()).unwrap(); - output.write_all(b"use libc::{\n").unwrap(); - for line in input.lines() { - let line = line.unwrap().into_bytes(); - match line.first() { - // Ignore comments and empty lines. - Some(b'#') | None => continue, - _ => { - output.write_all(b" ").unwrap(); - output.write_all(&line).unwrap(); - output.write_all(b",\n").unwrap(); - } - } - } - output.write_all(b"};\n\n").unwrap(); - path.pop(); -} - fn main() { // Avoid unnecessary re-building. - println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=."); // Ensure version checking works, even if we don't use it. LazyLock::force(&VERSIONS); do_cc(); do_ctest(); - do_semver(); + semver::do_semver(); } macro_rules! headers { @@ -372,10 +289,6 @@ fn test_apple(target: &str) { match constant.ident() { // They're declared via `deprecated_mach` and we don't support it anymore. x if x.starts_with("VM_FLAGS_") => true, - // FIXME(deprecated): These OSX constants are removed in Sierra. - // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html - "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, - // FIXME(deprecated): Removed since 12.0.1 / xnu-8019.41.5. See `ttycom.h` at // https://github.com/apple-oss-distributions/xnu/commit/e6231be02a03711ca404e5121a151b24afbff733 "TIOCREMOTE" => true, @@ -1542,7 +1455,6 @@ fn test_netbsd(target: &str) { cfg.skip_const(move |constant| { match constant.ident() { "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - "SIGUNUSED" => true, // removed in glibc 2.26 // deprecated, obsolete upstream "PT_LWPINFO" | "PL_EVENT_NONE" | "PL_EVENT_SIGNAL" | "PL_EVENT_SUSPENDED" => true, @@ -2036,6 +1948,7 @@ fn which_dragonfly() -> Option { fn test_wasi(target: &str) { assert!(target.contains("wasi")); let p2 = target.contains("wasip2"); + let wasi_sdk = VERSIONS.wasi_sdk.unwrap(); let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); @@ -2099,6 +2012,15 @@ fn test_wasi(target: &str) { // used here to generate a pointer to them in bindings so skip these tests. cfg.skip_static(|s| s.ident().starts_with("_CLOCK_")); + match wasi_sdk.1 { + WasiVersion::P1 => {} + // This was removed in wasip2 target for wasi-sdk-30+, but it's just a + // typedef, so ignore it. + _ => { + cfg.skip_alias(|s| s.ident() == "__wasi_rights_t"); + } + } + cfg.skip_const(|c| match c.ident() { // These constants aren't yet defined in wasi-libc. // Exposing them is being tracked by https://github.com/WebAssembly/wasi-libc/issues/531. @@ -2144,10 +2066,18 @@ fn test_android(target: &str) { }; let x86 = target.contains("i686") || target.contains("x86_64"); let aarch64 = target.contains("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. + let android = VERSIONS.android.unwrap(); let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); + // This ensure we avoid the `ioctl` overload for request parameters that use + // an unsigned integer instead of a signed integer. + cfg.define("BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD", None); + headers!( cfg, "arpa/inet.h", @@ -2339,8 +2269,7 @@ fn test_android(target: &str) { "posix_spawn_file_actions_t" => true, "posix_spawnattr_t" => true, - // Added in API level 24 - "if_nameindex" => true, + "if_nameindex" if android < 24 => true, _ => false, } @@ -2394,14 +2323,8 @@ fn test_android(target: &str) { // The `ARPHRD_CAN` is tested in the `linux_if_arp.rs` tests: "ARPHRD_CAN" => true, - // FIXME(deprecated): deprecated: not available in any header - // See: https://github.com/rust-lang/libc/issues/1356 - "ENOATTR" => true, - // FIXME(android): still necessary? "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME(deprecated): deprecated - removed in glibc 2.26 - "SIGUNUSED" => true, // Needs a newer Android SDK for the definition "P_PIDFD" => true, @@ -2455,7 +2378,6 @@ fn test_android(target: &str) { | "ALG_SET_DRBG_ENTROPY" => true, // FIXME(android): Something has been changed on r26b: - | "IPPROTO_MAX" | "NFNL_SUBSYS_COUNT" | "NF_NETDEV_NUMHOOKS" | "NFT_MSG_MAX" @@ -2541,8 +2463,11 @@ fn test_android(target: &str) { "reallocarray" => true, "__system_property_wait" => true, - // Added in API level 30, but tests use level 28. - "memfd_create" | "mlock2" | "renameat2" | "statx" | "statx_timestamp" => true, + "memfd_create" | "mlock2" | "renameat2" | "statx" | "statx_timestamp" + if android < 30 => + { + true + } // Added in API level 33, but tests use level 28. "preadv2" | "pwritev2" => true, @@ -2550,34 +2475,23 @@ fn test_android(target: &str) { // Added in glibc 2.25. "getentropy" => true, - // Added in API level 28, but some tests use level 24. - "getrandom" => true, - - // Added in API level 28, but some tests use level 24. - "syncfs" => true, - - // Added in API level 28, but some tests use level 24. - "pthread_attr_getinheritsched" | "pthread_attr_setinheritsched" => true, - // Added in API level 28, but some tests use level 24. - "fread_unlocked" | "fwrite_unlocked" | "fgets_unlocked" | "fflush_unlocked" => true, + "getrandom" | "syncfs" | "aligned_alloc" if android < 28 => true, - // Added in API level 28, but some tests use level 24. - "aligned_alloc" => true, + "pthread_attr_getinheritsched" | "pthread_attr_setinheritsched" if android < 28 => true, - // Added in API level 26, but some tests use level 24. - "getgrent" => true, - - // Added in API level 26, but some tests use level 24. - "setgrent" => true, - - // Added in API level 26, but some tests use level 24. - "endgrent" => true, + "fread_unlocked" | "fwrite_unlocked" | "fgets_unlocked" | "fflush_unlocked" + if android < 28 => + { + true + } - // Added in API level 26, but some tests use level 24. - "getpwent" | "setpwent" | "endpwent" => true, + "getgrent" | "setgrent" | "endgrent" | "getpwent" | "setpwent" | "endpwent" + if android < 26 => + { + true + } - // Added in API level 26, but some tests use level 24. - "getdomainname" | "setdomainname" => true, + "getdomainname" | "setdomainname" if android < 26 => true, // FIXME(android): bad function pointers: "isalnum" | "isalpha" | "iscntrl" | "isdigit" | "isgraph" | "islower" | "isprint" @@ -2587,10 +2501,21 @@ fn test_android(target: &str) { // Added in API level 24 "if_nameindex" | "if_freenameindex" => true, - // FIXME(ctest): In our current method of testing, we cast the function to a `void *`, - // which is not possible for functions that have been overloaded. - "ioctl" => true, + _ => false, + } + }); + cfg.skip_fn_ptrcheck(move |func| { + match func { + // termios functions are inlines below API 28, so + // their C-side address never matches the symbol Rust links. + "tcdrain" | "tcflow" | "tcflush" | "tcgetattr" | "tcgetsid" | "tcsendbreak" + | "tcsetattr" | "cfgetispeed" | "cfgetospeed" | "cfmakeraw" | "cfsetispeed" + | "cfsetospeed" | "cfsetspeed" + if android < 28 => + { + true + } _ => false, } }); @@ -2886,11 +2811,6 @@ fn test_freebsd(target: &str) { true } - // FIXME(deprecated): These are deprecated - remove in a couple of releases. - // These constants were removed in FreeBSD 11 (svn r273250) but will - // still be accepted and ignored at runtime. - "MAP_RENAME" | "MAP_NORESERVE" => true, - // FIXME(deprecated): These are deprecated - remove in a couple of releases. // These constants were removed in FreeBSD 11 (svn r262489), // and they've never had any legitimate use outside of the @@ -2942,12 +2862,6 @@ fn test_freebsd(target: &str) { // had any legitimate use outside of the base system anyway. "CTL_P1003_1B_MAXID" => true, - // This was renamed in FreeBSD 12.2 and 13 (r352486). - "CTL_UNSPEC" | "CTL_SYSCTL" => true, - - // This was renamed in FreeBSD 12.2 and 13 (r350749). - "IPPROTO_SEP" | "IPPROTO_DCCP" => true, - // This was changed to 96(0x60) in FreeBSD 13: // https://github.com/freebsd/freebsd/ // commit/06b00ceaa914a3907e4e27bad924f44612bae1d7 @@ -3544,10 +3458,6 @@ fn test_emscripten(target: &str) { cfg.skip_const(move |constant| { match constant.ident() { - // FIXME(deprecated): deprecated - SIGNUNUSED was removed in glibc 2.26 - // users should use SIGSYS instead - "SIGUNUSED" => true, - // FIXME(emscripten): emscripten uses different constants to constructs these n if n.contains("__SIZEOF_PTHREAD") => true, @@ -4143,6 +4053,7 @@ fn test_linux(target: &str) { 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 versions = &*VERSIONS; let kernel = match versions.linux { Some(v) => v, @@ -4150,17 +4061,21 @@ fn test_linux(target: &str) { None => panic!("failed to detect kernel version for Linux target {target}"), }; - // Force modern musl also for pauthtest. - let musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") || pauthtest; + let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3"); if musl_v1_2_3 { assert!(musl); } - let old_musl = musl && !musl_v1_2_3; - let b32 = arm || target.contains("hexagon") || mips32 || ppc32 || x86_32; + // 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; + } + + let old_musl = musl && !musl_v1_2_3; let mut cfg = ctest_cfg(); - if (musl_v1_2_3 || loongarch64 || hexagon) && musl { + + if musl_v1_2_3 { cfg.cfg("musl_v1_2_3", None); if b32 { cfg.cfg("musl32_time64", None); @@ -4170,6 +4085,7 @@ fn test_linux(target: &str) { cfg.cfg("musl_redir_time64", None); } } + let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64"); if uclibc && uclibc_use_time64 { cfg.cfg("linux_time_bits64", None); @@ -4513,7 +4429,7 @@ fn test_linux(target: &str) { // FIXME(rust-lang/rust#43894): pass by value for structs that are not an even 32/64 bits // on big-endian systems corrupts the value for unknown reasons. - if (sparc64 || ppc || ppc64 || s390x) + if (sparc64 || ppc || s390x) && (ty == "sockaddr_pkt" || ty == "tpacket_auxdata" || ty == "tpacket_hdr_variant1" @@ -4557,7 +4473,7 @@ fn test_linux(target: &str) { // FIXME(ppc): tests fail due to a field type mismatch (`long long unsigned` vs // `long unsigned`). - "clone_args" if ppc64 => true, + "clone_args" if ppc64 && gnu => true, // Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15) // Might differ between kernel versions @@ -4971,14 +4887,6 @@ fn test_linux(target: &str) { // because including `linux/if_arp.h` causes some conflicts: "ARPHRD_CAN" => true, - // FIXME(deprecated): deprecated: not available in any header - // See: https://github.com/rust-lang/libc/issues/1356 - "ENOATTR" => true, - - // FIXME(deprecated): SIGUNUSED was removed in glibc 2.26 - // Users should use SIGSYS instead. - "SIGUNUSED" => true, - // FIXME(linux): conflicts with glibc headers and is tested in // `linux_termios.rs` below: "BOTHER" | "IBSHIFT" | "TCGETS2" | "TCSETS2" | "TCSETSW2" | "TCSETSF2" => true, @@ -4991,12 +4899,6 @@ fn test_linux(target: &str) { // We should do so after a while. "SOMAXCONN" if gnu => true, - // deprecated: not available from Linux kernel 5.6: - "VMADDR_CID_RESERVED" => true, - - // FIXME(value): IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP: - "IPPROTO_MAX" => true, - // Requires >= 6.9 kernel headers. n if (arm || ppc32) && n.starts_with("FUTEX2_") => kernel < (6, 9), @@ -5045,7 +4947,7 @@ fn test_linux(target: &str) { "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" if gnu => true, // FIXME(linux): The below is no longer const in glibc 2.34: - // https://github.com/bminor/glibc/commit/5d98a7dae955bafa6740c26eaba9c86060ae0344 + // https://github.com/sailfishos-mirror/glibc/commit/5d98a7dae955bafa6740c26eaba9c86060ae0344 "PTHREAD_STACK_MIN" | "SIGSTKSZ" | "MINSIGSTKSZ" if gnu => true, // value changed @@ -5116,6 +5018,8 @@ fn test_linux(target: &str) { | "PF_BLOCK_TS" | "PF_SUSPEND_TASK" => true, "EPIOCSPARAMS" | "EPIOCGPARAMS" if old_musl => true, + // Changed value + "IPPROTO_MAX" if old_musl => true, // FIXME(linux): Requires >= 6.6 kernel headers. "SECCOMP_IOCTL_NOTIF_SET_FLAGS" => kernel < (6, 6), @@ -5218,6 +5122,8 @@ fn test_linux(target: &str) { "posix_spawn_file_actions_addclosefrom_np" if gnu && sparc64 => true, // Needs glibc 2.35 or later. "posix_spawn_file_actions_addtcsetpgrp_np" if gnu && sparc64 => true, + // Needs glibc 2.42 or later. + "pthread_gettid_np" if gnu && versions.glibc.unwrap() < (2, 42) => true, // FIXME(linux): Deprecated since glibc 2.30. Remove fn once upstream does. "sysctl" if gnu => true, @@ -5450,30 +5356,6 @@ fn test_linux(target: &str) { // FIXME(union): This is actually a union. "fpreg_t" if s390x => true, - // The test doesn't work on some env: - "ipv6_mreq" - | "ip_mreq_source" - | "sockaddr_in6" - | "sockaddr_ll" - | "in_pktinfo" - | "arpreq" - | "arpreq_old" - | "sockaddr_un" - | "ff_constant_effect" - | "ff_ramp_effect" - | "ff_condition_effect" - | "Elf32_Ehdr" - | "Elf32_Chdr" - | "ucred" - | "in6_pktinfo" - | "sockaddr_nl" - | "termios" - | "nlmsgerr" - if sparc64 && gnu => - { - true - } - // The following types contain Flexible Array Member fields which have unspecified calling // convention. The roundtripping tests deliberately pass the structs by value to check "by // value" layout consistency, but this would be UB for the these types. @@ -5483,7 +5365,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 || ppc64 => true, + "max_align_t" if i686 => true, _ => false, }); @@ -5844,9 +5726,6 @@ fn test_haiku(target: &str) { "Elf64_Phdr" => true, - // is an union - "cpuid_info" => true, - _ => false, } }); @@ -5933,11 +5812,9 @@ fn test_haiku(target: &str) { // these are actually unions, but we cannot represent it well ("siginfo_t", "sigval") => true, - ("sem_t", "named_sem_id") => true, ("sigaction", "sa_sigaction") => true, ("sigevent", "sigev_value") => true, ("fpu_state", "_fpreg") => true, - ("cpu_topology_node_info", "data") => true, // these fields have a simplified data definition in libc ("fpu_state", "_xmm") => true, ("savefpu", "_fp_ymm") => true, @@ -6343,10 +6220,6 @@ fn test_qurt(target: &str) { // These are compatibility stubs in libc, not from QuRT headers "stat" | "tm" | "timespec" | "timeval" | "itimerspec" | "dirent" | "DIR" | "termios" | "rlimit" | "rusage" | "flock" | "div_t" | "ldiv_t" | "lldiv_t" => true, - // sigaction: sa_handler/sa_sigaction are a union in C but separate fields in Rust - "sigaction" => true, - // sem_t is typedef of anonymous struct in C (no struct tag) - "sem_t" => true, _ => false, } }); @@ -6565,6 +6438,17 @@ struct Versions { netbsd: Option<(u32, u32)>, macos: Option<(u32, u32)>, emscripten: Option<(u32, u32)>, + wasi_sdk: Option<(u32, WasiVersion)>, + /// Android API level (no minor version). + android: Option, +} + +#[derive(Clone, Copy, Debug, Default)] +enum WasiVersion { + #[default] + P1, + P2, + P3, } impl Versions { @@ -6585,6 +6469,13 @@ impl Versions { #include "gnu/libc-version.h" #endif + #ifdef __ANDROID__ + /* The clang driver predefines __ANDROID_MIN_SDK_VERSION__ from the API level + * in the target triple; including api-level.h ensures it is defined even on + * toolchains that leave it to the header. */ + #include "android/api-level.h" + #endif + #if defined(__FreeBSD__) \ || defined(__NetBSD__) \ || defined(__OpenBSD__) \ @@ -6601,6 +6492,11 @@ impl Versions { /* Provides __EMSCRIPTEN_MAJOR__, __EMSCRIPTEN_MINOR__ */ #include "emscripten/version.h" #endif + + #if __has_include() + /* provides __wasi_sdk_major__, __wasi_sdk_version__ */ + #include + #endif "#; let mut ret = Versions::default(); @@ -6649,6 +6545,11 @@ impl Versions { } "__GLIBC__" => ret.glibc.get_or_insert_default().0 = value.parse().unwrap(), "__GLIBC_MINOR__" => ret.glibc.get_or_insert_default().1 = value.parse().unwrap(), + // Clang 12+ predefines the target API level here as a plain integer. + // Every NDK wrapper we build with carries an API level, so parse it like + // 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(); let major: u32 = caps[1].parse().unwrap(); @@ -6681,6 +6582,12 @@ impl Versions { "__EMSCRIPTEN_minor__" => { ret.emscripten.get_or_insert_default().1 = value.parse().unwrap() } + "__wasi_sdk_major__" => { + ret.wasi_sdk.get_or_insert_default().0 = value.parse().unwrap() + } + "__wasip1__" => ret.wasi_sdk.get_or_insert_default().1 = WasiVersion::P1, + "__wasip2__" => ret.wasi_sdk.get_or_insert_default().1 = WasiVersion::P2, + "__wasip3__" => ret.wasi_sdk.get_or_insert_default().1 = WasiVersion::P3, _ => (), } } diff --git a/libc-test/build/semver.rs b/libc-test/build/semver.rs new file mode 100644 index 0000000000000..e5339fe4faee5 --- /dev/null +++ b/libc-test/build/semver.rs @@ -0,0 +1,90 @@ +use std::fs::File; +use std::io::{ + BufRead, + BufReader, + BufWriter, + Write, +}; +use std::path::{ + Path, + PathBuf, +}; +use std::{ + env, + io, +}; + +pub(crate) fn do_semver() { + let mut out = PathBuf::from(env::var("OUT_DIR").unwrap()); + out.push("semver.rs"); + let mut output = BufWriter::new(File::create(&out).unwrap()); + + let family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + let vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap(); + let os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); + + // `libc-test/semver` dir. + let mut semver_root = PathBuf::from("semver"); + + // NOTE: Windows has the same `family` as `os`, no point in including it + // twice. + // 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 + // 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" { + process_semver_file(&mut output, &mut semver_root, &family); + } + // We don't do semver for unknown targets. + if vendor != "unknown" { + process_semver_file(&mut output, &mut semver_root, &vendor); + } + process_semver_file(&mut output, &mut semver_root, &os); + let os_arch = format!("{os}-{arch}"); + process_semver_file(&mut output, &mut semver_root, &os_arch); + if !target_env.is_empty() { + let os_env = format!("{os}-{target_env}"); + process_semver_file(&mut output, &mut semver_root, &os_env); + + let os_env_arch = format!("{os}-{target_env}-{arch}"); + process_semver_file(&mut output, &mut semver_root, &os_env_arch); + } +} + +fn process_semver_file>(output: &mut W, path: &mut PathBuf, file: P) { + // NOTE: `path` is reused between calls, so always remove the file again. + path.push(file); + path.set_extension("txt"); + + println!("cargo:rerun-if-changed={}", path.display()); + let input_file = match File::open(&*path) { + Ok(file) => file, + Err(ref err) if err.kind() == io::ErrorKind::NotFound => { + path.pop(); + return; + } + Err(err) => panic!("unexpected error opening file: {err}"), + }; + let input = BufReader::new(input_file); + + writeln!(output, "// Source: {}.", path.display()).unwrap(); + output.write_all(b"use libc::{\n").unwrap(); + for line in input.lines() { + let line = line.unwrap().into_bytes(); + match line.first() { + // Ignore comments and empty lines. + Some(b'#') | None => continue, + _ => { + output.write_all(b" ").unwrap(); + output.write_all(&line).unwrap(); + output.write_all(b",\n").unwrap(); + } + } + } + output.write_all(b"};\n\n").unwrap(); + path.pop(); +} diff --git a/libc-test/semver/TODO-linux.txt b/libc-test/semver/TODO-linux.txt index 4dee6991cd9f0..4bb8b1b60286b 100644 --- a/libc-test/semver/TODO-linux.txt +++ b/libc-test/semver/TODO-linux.txt @@ -61,10 +61,8 @@ SO_ZEROCOPY SYS__llseek SYS__newselect SYS__sysctl -SYS_create_module SYS_fadvise64 SYS_fstatat64 -SYS_get_kernel_syms SYS_get_thread_area SYS_getrlimit SYS_migrate_pages @@ -72,7 +70,6 @@ SYS_mmap SYS_nfsservctl SYS_pread64 SYS_pwrite64 -SYS_query_module SYS_set_thread_area SYS_uselib fsblkcnt64_t diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 6e99aea99f908..7ddd3dbb65a11 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -433,7 +433,6 @@ ENETRESET ENETUNREACH ENFILE ENOANO -ENOATTR ENOBUFS ENOCSI ENODATA @@ -2300,6 +2299,7 @@ RTLD_DEFAULT RTLD_GLOBAL RTLD_LAZY RTLD_LOCAL +RTLD_NEXT RTLD_NODELETE RTLD_NOLOAD RTLD_NOW @@ -2491,7 +2491,6 @@ SIGTRAP SIGTSTP SIGTTIN SIGTTOU -SIGUNUSED SIGURG SIGUSR1 SIGUSR2 @@ -2639,12 +2638,15 @@ SOL_UDP SOL_X25 SOMAXCONN SO_ACCEPTCONN +SO_ATTACH_REUSEPORT_CBPF +SO_ATTACH_REUSEPORT_EBPF SO_BINDTODEVICE SO_BINDTOIFINDEX SO_BROADCAST SO_BSDCOMPAT SO_BUSY_POLL SO_DEBUG +SO_DETACH_REUSEPORT_BPF SO_DOMAIN SO_DONTROUTE SO_EE_OFFENDER @@ -3632,6 +3634,8 @@ gmtime gmtime_r grantpt group +group_req +group_source_req hostent id_t idtype_t @@ -3852,6 +3856,7 @@ pthread_getattr_np pthread_getcpuclockid pthread_getschedparam pthread_getspecific +pthread_gettid_np pthread_join pthread_key_create pthread_key_delete diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 1a714992cdad6..2a7110250a0cc 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -186,6 +186,7 @@ BIOCSSEESENT BIOCVERSION BOOT_TIME BPF_ALIGNMENT +BPF_WORDALIGN BS0 BS1 BSDLY @@ -909,6 +910,14 @@ MAXPHASE MAXSEC MAXTC MAXTHREADNAMESIZE +MAX_SACK_BLKS +MAX_TCPOPTLEN +MCAST_BLOCK_SOURCE +MCAST_JOIN_GROUP +MCAST_JOIN_SOURCE_GROUP +MCAST_LEAVE_GROUP +MCAST_LEAVE_SOURCE_GROUP +MCAST_UNBLOCK_SOURCE MCL_CURRENT MCL_FUTURE MDMBUF @@ -1492,12 +1501,45 @@ TAB1 TAB2 TAB3 TABDLY +TCPOLEN_ACCECN_COUNTER +TCPOLEN_ACCECN_EMPTY +TCPOLEN_CC +TCPOLEN_CC_APPA +TCPOLEN_EOL +TCPOLEN_FASTOPEN_REQ +TCPOLEN_MAXSEG +TCPOLEN_NOP +TCPOLEN_SACK +TCPOLEN_SACKHDR +TCPOLEN_SACK_PERMITTED +TCPOLEN_SIGNATURE +TCPOLEN_TIMESTAMP +TCPOLEN_TSTAMP_APPA +TCPOLEN_WINDOW +TCPOPT_ACCECN0 +TCPOPT_ACCECN1 +TCPOPT_CC +TCPOPT_CCECHO +TCPOPT_CCNEW +TCPOPT_EOL +TCPOPT_FASTOPEN +TCPOPT_MAXSEG +TCPOPT_NOP +TCPOPT_SACK +TCPOPT_SACK_HDR +TCPOPT_SACK_PERMITTED +TCPOPT_SACK_PERMIT_HDR +TCPOPT_SIGNATURE +TCPOPT_TIMESTAMP +TCPOPT_TSTAMP_HDR +TCPOPT_WINDOW TCP_CONNECTION_INFO TCP_FASTOPEN TCP_KEEPALIVE TCP_KEEPCNT TCP_KEEPINTVL TCP_MAXSEG +TCP_MAX_SACK TCP_NOOPT TCP_NOPUSH THOUSEP @@ -1525,14 +1567,27 @@ THREAD_THROUGHPUT_QOS_POLICY THREAD_THROUGHPUT_QOS_POLICY_COUNT THREAD_TIME_CONSTRAINT_POLICY THREAD_TIME_CONSTRAINT_POLICY_COUNT +TH_ACCEPT +TH_ACE +TH_ACK +TH_AE +TH_CWR +TH_ECE +TH_FIN +TH_FLAGS +TH_FLAGS_ALL TH_FLAGS_GLOBAL_FORCED_IDLE TH_FLAGS_IDLE TH_FLAGS_SWAPPED +TH_PUSH +TH_RST TH_STATE_HALTED TH_STATE_RUNNING TH_STATE_STOPPED TH_STATE_UNINTERRUPTIBLE TH_STATE_WAITING +TH_SYN +TH_URG TIME_DEL TIME_ERROR TIME_INS @@ -2111,6 +2166,8 @@ getxattr glob glob_t globfree +group_req +group_source_req host_cpu_load_info host_cpu_load_info_data_t host_cpu_load_info_t diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 4636e3761465a..8cabbf2b63499 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -115,6 +115,7 @@ BIOCSSEESENT BIOCVERSION BOOT_TIME BPF_ALIGNMENT +BPF_WORDALIGN BTUARTDISC BUFSIZ BUS_ADRALN diff --git a/libc-test/semver/espidf.txt b/libc-test/semver/espidf.txt index cdef4f09bc0eb..f9f9089b9e371 100644 --- a/libc-test/semver/espidf.txt +++ b/libc-test/semver/espidf.txt @@ -32,6 +32,7 @@ SIGSEGV SIGTERM SOL_SOCKET SOMAXCONN +__errno cmsghdr dirent eventfd diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index a7218afae8195..2cdacfe842cca 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -142,6 +142,7 @@ BIOCSSEESENT BIOCVERSION BOOT_TIME BPF_ALIGNMENT +BPF_WORDALIGN BUFSIZ BUS_ADRALN BUS_ADRERR @@ -861,6 +862,12 @@ MAXFREQ MAXPHASE MAXSEC MAXTC +MCAST_BLOCK_SOURCE +MCAST_JOIN_GROUP +MCAST_JOIN_SOURCE_GROUP +MCAST_LEAVE_GROUP +MCAST_LEAVE_SOURCE_GROUP +MCAST_UNBLOCK_SOURCE MCL_CURRENT MCL_FUTURE MDMBUF @@ -2074,6 +2081,8 @@ getutxuser glob glob_t globfree +group_req +group_source_req hexdump humanize_number icmp6_ifstat @@ -2314,6 +2323,8 @@ regfree register_t regmatch_t regoff_t +rt_metrics +rt_msghdr rtprio rtprio_thread sallocx diff --git a/libc-test/semver/l4re.txt b/libc-test/semver/l4re.txt index 04fdedd37ae85..e4a8a79a28a11 100644 --- a/libc-test/semver/l4re.txt +++ b/libc-test/semver/l4re.txt @@ -2201,6 +2201,8 @@ gid_t gmtime gmtime_r group +group_req +group_source_req hostent hstrerror iconv diff --git a/libc-test/semver/linux-aarch64.txt b/libc-test/semver/linux-aarch64.txt index 03a312bcc13dc..940f2662affd4 100644 --- a/libc-test/semver/linux-aarch64.txt +++ b/libc-test/semver/linux-aarch64.txt @@ -53,7 +53,6 @@ FICLONERANGE MADV_SOFT_OFFLINE MAP_SYNC SIGSTKFLT -SIGUNUSED SKF_AD_ALU_XOR_X SKF_AD_CPU SKF_AD_HATYPE diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index c5e2ae6247063..4fbcf053c022a 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -600,6 +600,7 @@ dlmopen dlvsym eaccess endutxent +environ epoll_pwait2 ethhdr euidaccess @@ -662,6 +663,7 @@ process_vm_readv process_vm_writev pthread_attr_getaffinity_np pthread_attr_setaffinity_np +pthread_gettid_np pthread_rwlockattr_getkind_np pthread_rwlockattr_getpshared pthread_rwlockattr_setkind_np diff --git a/libc-test/semver/linux-i686.txt b/libc-test/semver/linux-i686.txt index 2649e3249a76b..c7f6082f564f7 100644 --- a/libc-test/semver/linux-i686.txt +++ b/libc-test/semver/linux-i686.txt @@ -67,7 +67,6 @@ REG_SS REG_TRAPNO REG_UESP SIGSTKFLT -SIGUNUSED SO_BSDCOMPAT SO_NO_CHECK SO_PRIORITY @@ -85,7 +84,6 @@ SYS_chmod SYS_chown SYS_chown32 SYS_creat -SYS_create_module SYS_dup2 SYS_epoll_create SYS_epoll_wait @@ -102,7 +100,6 @@ SYS_fstatfs64 SYS_ftime SYS_ftruncate64 SYS_futimesat -SYS_get_kernel_syms SYS_get_thread_area SYS_getdents SYS_getegid32 @@ -148,7 +145,6 @@ SYS_poll SYS_prof SYS_profil SYS_putpmsg -SYS_query_module SYS_readdir SYS_readlink SYS_rename diff --git a/libc-test/semver/linux-loongarch64.txt b/libc-test/semver/linux-loongarch64.txt index b3a7a13fbc101..2b5af5ab684da 100644 --- a/libc-test/semver/linux-loongarch64.txt +++ b/libc-test/semver/linux-loongarch64.txt @@ -57,7 +57,6 @@ NFT_MSG_NEWOBJ SCM_TIMESTAMPNS SCM_WIFI_STATUS SIGSTKFLT -SIGUNUSED SKF_AD_ALU_XOR_X SKF_AD_CPU SKF_AD_HATYPE diff --git a/libc-test/semver/linux-mips.txt b/libc-test/semver/linux-mips.txt index 8d98f5604df0f..d12fd3a9cf1d5 100644 --- a/libc-test/semver/linux-mips.txt +++ b/libc-test/semver/linux-mips.txt @@ -24,7 +24,6 @@ SYS_cacheflush SYS_chmod SYS_chown SYS_creat -SYS_create_module SYS_dup2 SYS_epoll_create SYS_epoll_wait @@ -37,7 +36,6 @@ SYS_fstatfs64 SYS_ftime SYS_ftruncate64 SYS_futimesat -SYS_get_kernel_syms SYS_getdents SYS_getpgrp SYS_getpmsg @@ -68,7 +66,6 @@ SYS_poll SYS_prof SYS_profil SYS_putpmsg -SYS_query_module SYS_readdir SYS_readlink SYS_recv diff --git a/libc-test/semver/linux-powerpc.txt b/libc-test/semver/linux-powerpc.txt index a559c891a4f95..d84eba1927ba5 100644 --- a/libc-test/semver/linux-powerpc.txt +++ b/libc-test/semver/linux-powerpc.txt @@ -13,7 +13,6 @@ PTRACE_GETREGS PTRACE_SETFPREGS PTRACE_SETREGS SIGSTKFLT -SIGUNUSED SO_BSDCOMPAT SO_NO_CHECK SO_PRIORITY @@ -30,7 +29,6 @@ SYS_break SYS_chmod SYS_chown SYS_creat -SYS_create_module SYS_dup2 SYS_epoll_create SYS_epoll_wait @@ -46,7 +44,6 @@ SYS_fstatfs64 SYS_ftime SYS_ftruncate64 SYS_futimesat -SYS_get_kernel_syms SYS_getdents SYS_getpgrp SYS_getpmsg @@ -85,7 +82,6 @@ SYS_poll SYS_prof SYS_profil SYS_putpmsg -SYS_query_module SYS_readdir SYS_readlink SYS_recv diff --git a/libc-test/semver/linux-powerpc64.txt b/libc-test/semver/linux-powerpc64.txt index f6564fd2ae586..1e4a55d5b33a0 100644 --- a/libc-test/semver/linux-powerpc64.txt +++ b/libc-test/semver/linux-powerpc64.txt @@ -11,7 +11,6 @@ NFT_MSG_NEWOBJ SCM_TIMESTAMPNS SCM_WIFI_STATUS SIGSTKFLT -SIGUNUSED SO_ATTACH_BPF SO_ATTACH_FILTER SO_BPF_EXTENSIONS @@ -44,7 +43,6 @@ SYS_break SYS_chmod SYS_chown SYS_creat -SYS_create_module SYS_dup2 SYS_epoll_create SYS_epoll_wait @@ -54,7 +52,6 @@ SYS_fstat SYS_fstatfs64 SYS_ftime SYS_futimesat -SYS_get_kernel_syms SYS_getdents SYS_getpgrp SYS_getpmsg @@ -91,7 +88,6 @@ SYS_poll SYS_prof SYS_profil SYS_putpmsg -SYS_query_module SYS_readdir SYS_readlink SYS_recv diff --git a/libc-test/semver/linux-s390x.txt b/libc-test/semver/linux-s390x.txt index f2a16a6d8fe62..7012300d9ba27 100644 --- a/libc-test/semver/linux-s390x.txt +++ b/libc-test/semver/linux-s390x.txt @@ -22,7 +22,6 @@ NFT_MSG_GETOBJ NFT_MSG_GETOBJ_RESET NFT_MSG_NEWOBJ SIGSTKFLT -SIGUNUSED SO_BSDCOMPAT SO_PRIORITY SO_PROTOCOL @@ -34,7 +33,6 @@ SYS_bdflush SYS_chmod SYS_chown SYS_creat -SYS_create_module SYS_dup2 SYS_epoll_create SYS_epoll_wait @@ -44,7 +42,6 @@ SYS_fork SYS_fstat SYS_fstatfs64 SYS_futimesat -SYS_get_kernel_syms SYS_getdents SYS_getpgrp SYS_getpmsg @@ -64,7 +61,6 @@ SYS_pause SYS_pipe SYS_poll SYS_putpmsg -SYS_query_module SYS_readdir SYS_readlink SYS_rename @@ -104,4 +100,5 @@ flock64 fpreg_t fpregset_t greg_t +max_align_t termios2 diff --git a/libc-test/semver/linux-sparc64.txt b/libc-test/semver/linux-sparc64.txt index 95ab0c2b84fc5..241f8c866ab20 100644 --- a/libc-test/semver/linux-sparc64.txt +++ b/libc-test/semver/linux-sparc64.txt @@ -29,7 +29,6 @@ SYS_bdflush SYS_chmod SYS_chown SYS_creat -SYS_create_module SYS_dup2 SYS_epoll_create SYS_epoll_wait @@ -43,7 +42,6 @@ SYS_fstat64 SYS_fstatat64 SYS_fstatfs64 SYS_futimesat -SYS_get_kernel_syms SYS_getdents SYS_getdomainname SYS_getpagesize @@ -67,7 +65,6 @@ SYS_pciconfig_write SYS_perfctr SYS_pipe SYS_poll -SYS_query_module SYS_readdir SYS_readlink SYS_rename diff --git a/libc-test/semver/linux-x86_64.txt b/libc-test/semver/linux-x86_64.txt index 9d62f8cd3cd35..f39c4c1e22a83 100644 --- a/libc-test/semver/linux-x86_64.txt +++ b/libc-test/semver/linux-x86_64.txt @@ -66,7 +66,6 @@ REG_EFL REG_ERR REG_TRAPNO SIGSTKFLT -SIGUNUSED SKF_AD_ALU_XOR_X SKF_AD_CPU SKF_AD_HATYPE diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 3fd80eac8297c..737874f32ce30 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -627,7 +627,6 @@ EM_XTENSA EM_ZSP ENAVAIL ENOANO -ENOATTR ENOCSI ENODATA ENOKEY @@ -2145,11 +2144,18 @@ NLA_F_NESTED NLA_F_NET_BYTEORDER NLA_TYPE_MASK NLDLY +NLMSG_ALIGN +NLMSG_DATA NLMSG_DONE NLMSG_ERROR +NLMSG_LENGTH NLMSG_MIN_TYPE +NLMSG_NEXT NLMSG_NOOP +NLMSG_OK NLMSG_OVERRUN +NLMSG_PAYLOAD +NLMSG_SPACE NLM_F_ACK NLM_F_ACK_TLVS NLM_F_APPEND @@ -3772,7 +3778,6 @@ VMADDR_CID_ANY VMADDR_CID_HOST VMADDR_CID_HYPERVISOR VMADDR_CID_LOCAL -VMADDR_CID_RESERVED VMADDR_PORT_ANY VREPRINT VSWTC @@ -4177,6 +4182,8 @@ getspnam getspnam_r gettid getxattr +group_req +group_source_req hasmntopt hwtstamp_config iconv diff --git a/libc-test/semver/vxworks.txt b/libc-test/semver/vxworks.txt index 35d795a706e8a..ea796fef7b80c 100644 --- a/libc-test/semver/vxworks.txt +++ b/libc-test/semver/vxworks.txt @@ -623,7 +623,6 @@ pipe poll pollfd posix_memalign -pread printf protoent pthread_attr_destroy @@ -680,7 +679,6 @@ putchar putchar_unlocked putenv puts -pwrite raise read readdir diff --git a/libc-test/semver/wasi-p2.txt b/libc-test/semver/wasi-p2.txt index 2d1bc774ab30d..31ab3679baff0 100644 --- a/libc-test/semver/wasi-p2.txt +++ b/libc-test/semver/wasi-p2.txt @@ -24,9 +24,7 @@ SHUT_RD SHUT_RDWR SHUT_WR SOCK_DGRAM -SOCK_NONBLOCK SOCK_STREAM -SOL_SOCKET SO_ACCEPTCONN SO_BROADCAST SO_DOMAIN @@ -39,7 +37,6 @@ SO_RCVTIMEO SO_REUSEADDR SO_SNDBUF SO_SNDTIMEO -SO_TYPE TCP_KEEPCNT TCP_KEEPIDLE TCP_KEEPINTVL diff --git a/libc-test/semver/wasi.txt b/libc-test/semver/wasi.txt index 5e7ab4b5192c8..510c73fd16e70 100644 --- a/libc-test/semver/wasi.txt +++ b/libc-test/semver/wasi.txt @@ -1,6 +1,10 @@ FD_ISSET FD_SET FD_ZERO +SOCK_CLOEXEC +SOCK_NONBLOCK +SOL_SOCKET +SO_TYPE _SC_2_CHAR_TERM _SC_2_C_BIND _SC_2_C_DEV diff --git a/libc-test/src/nlmsg.c b/libc-test/src/nlmsg.c new file mode 100644 index 0000000000000..a10c61b9b6c20 --- /dev/null +++ b/libc-test/src/nlmsg.c @@ -0,0 +1,35 @@ +#include +#include + +// Since the NLMSG_* helpers are macros instead of functions, they aren't +// available to FFI. libc must reimplement them, which is error-prone. This +// file provides FFI access to the actual macros so they can be tested against +// the Rust reimplementation. + +int nlmsg_align_ffi(size_t size) { + return NLMSG_ALIGN(size); +} + +int nlmsg_length_ffi(size_t size) { + return NLMSG_LENGTH(size); +} + +int nlmsg_space_ffi(size_t size) { + return NLMSG_SPACE(size); +} + +void *nlmsg_data_ffi(struct nlmsghdr *nlh) { + return NLMSG_DATA(nlh); +} + +struct nlmsghdr *nlmsg_next_ffi(struct nlmsghdr *nlh, int *size) { + return NLMSG_NEXT(nlh, *size); +} + +int nlmsg_ok_ffi(struct nlmsghdr *nlh, int size) { + return NLMSG_OK(nlh, size); +} + +int nlmsg_payload_ffi(struct nlmsghdr *nlh, int size) { + return NLMSG_PAYLOAD(nlh, size); +} diff --git a/libc-test/tests/nlmsg.rs b/libc-test/tests/nlmsg.rs new file mode 100644 index 0000000000000..5d33e21653551 --- /dev/null +++ b/libc-test/tests/nlmsg.rs @@ -0,0 +1,108 @@ +//! Compare libc's NLMSG_* functions against the actual C macros, for various inputs. + +#![cfg(target_os = "linux")] + +use libc::{ + self, + c_int, + c_void, + nlmsghdr, + size_t, +}; + +extern "C" { + fn nlmsg_align_ffi(size: size_t) -> c_int; + fn nlmsg_length_ffi(size: size_t) -> c_int; + fn nlmsg_space_ffi(size: size_t) -> c_int; + fn nlmsg_data_ffi(nlh: *mut nlmsghdr) -> *mut c_void; + fn nlmsg_next_ffi(nlh: *mut nlmsghdr, size: *mut c_int) -> *mut nlmsghdr; + fn nlmsg_ok_ffi(nlh: *mut nlmsghdr, size: c_int) -> c_int; + fn nlmsg_payload_ffi(nlh: *mut nlmsghdr, size: c_int) -> c_int; +} + +#[test] +fn test_sizes() { + for size in [0, 1, 2, 3, 4, 5, 15, 16, 17, 100, 4095, 4096] { + assert_eq!(libc::NLMSG_ALIGN(size), unsafe { nlmsg_align_ffi(size) }); + assert_eq!(libc::NLMSG_LENGTH(size), unsafe { nlmsg_length_ffi(size) }); + assert_eq!(libc::NLMSG_SPACE(size), unsafe { nlmsg_space_ffi(size) }); + } +} + +/// Write message headers with lengths `lens` into `buf`, at NLMSG_ALIGN spacing. +/// +/// `[u32]` keeps the buffer 4-byte aligned for `nlmsghdr`; NLMSG_ALIGN keeps every +/// message offset a multiple of 4, so each header dereference stays aligned. +fn fill(buf: &mut [u32], lens: &[u32]) -> c_int { + let mut total = 0; + for len in lens { + assert!(total + size_of::() <= size_of_val(buf)); + let hdr = nlmsghdr { + nlmsg_len: *len, + nlmsg_type: 0, + nlmsg_flags: 0, + nlmsg_seq: 0, + nlmsg_pid: 0, + }; + unsafe { + buf.as_mut_ptr() + .cast::() + .add(total) + .cast::() + .write(hdr); + } + total += libc::NLMSG_ALIGN(*len as size_t) as usize; + } + assert!(total <= size_of_val(buf)); + total as c_int +} + +// Walk a multipart message with the Rust and C implementations in lockstep, +// comparing every step. +#[test] +fn test_walk() { + let mut buf = [0u32; 32]; + let total = fill(&mut buf, &[21, 16, 30]); + + let mut nlh = buf.as_mut_ptr().cast::(); + let mut len = total; + let mut len_c = total; + let mut seen = 0; + loop { + let ok = unsafe { libc::NLMSG_OK(nlh, len) }; + assert_eq!(ok, unsafe { nlmsg_ok_ffi(nlh, len_c) } != 0); + if !ok { + break; + } + unsafe { + assert_eq!(libc::NLMSG_DATA(nlh), nlmsg_data_ffi(nlh)); + for size in [0, 4, 8] { + assert_eq!(libc::NLMSG_PAYLOAD(nlh, size), nlmsg_payload_ffi(nlh, size)); + } + } + let next = unsafe { libc::NLMSG_NEXT(nlh, &mut len) }; + let next_c = unsafe { nlmsg_next_ffi(nlh, &mut len_c) }; + assert_eq!(next, next_c); + assert_eq!(len, len_c); + nlh = next; + seen += 1; + } + assert_eq!(seen, 3); + assert_eq!(len, 0); +} + +// Boundary cases for the validity check: exact fit, short buffer, truncated +// header, message longer than the remaining buffer. +#[test] +fn test_ok_boundaries() { + let mut buf = [0u32; 32]; + for (nlmsg_len, len) in [(16, 16), (16, 15), (8, 16), (100, 16)] { + fill(&mut buf, &[nlmsg_len]); + let nlh = buf.as_mut_ptr().cast::(); + assert_eq!( + unsafe { libc::NLMSG_OK(nlh, len) }, + unsafe { nlmsg_ok_ffi(nlh, len) } != 0, + "nlmsg_len={nlmsg_len} len={len}" + ); + } +} diff --git a/src/fuchsia/aarch64.rs b/src/fuchsia/aarch64.rs index 93090f7238d7a..690c62f277c20 100644 --- a/src/fuchsia/aarch64.rs +++ b/src/fuchsia/aarch64.rs @@ -1,10 +1,12 @@ use crate::off_t; use crate::prelude::*; +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub type __u64 = c_ulonglong; pub type wchar_t = u32; -pub type nlink_t = c_ulong; -pub type blksize_t = c_long; s! { pub struct stat { @@ -15,10 +17,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad0: Padding, + __pad: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad1: Padding, + __pad2: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -29,6 +31,11 @@ s! { __unused: Padding<[c_uint; 2]>, } + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -51,6 +58,11 @@ s! { __unused: Padding<[c_uint; 2]>, } + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct ipc_perm { pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, @@ -62,6 +74,25 @@ s! { __unused1: Padding, __unused2: Padding, } + + // FIXME(f128): __reserved is meant to be an array of `long double`s. That + // requires native support for `f128`. This is currently missing. + pub struct mcontext_t { + pub fault_address: c_ulong, + pub regs: [c_ulong; 31], + pub sp: c_ulong, + pub pc: c_ulong, + pub pstate: c_ulong, + __reserved: Padding<[i128; 256]>, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut crate::ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: crate::mcontext_t, + } } // From https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/bits/signal.h;l=20-21;drc=0827b18ab9540c46f8037f407d17ea15a79e9ba7 diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 4c2dcec5957ea..bb139ba1d43ba 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -18,34 +18,61 @@ pub type intptr_t = isize; pub type uintptr_t = usize; pub type ssize_t = isize; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; +pub type pid_t = c_int; +pub type uid_t = c_uint; +pub type gid_t = c_uint; pub type in_addr_t = u32; pub type in_port_t = u16; pub type sighandler_t = size_t; pub type cc_t = c_uchar; -pub type sa_family_t = u16; +pub type sa_family_t = c_ushort; pub type pthread_key_t = c_uint; pub type speed_t = c_uint; pub type tcflag_t = c_uint; pub type clockid_t = c_int; pub type key_t = c_int; pub type id_t = c_uint; -pub type useconds_t = u32; -pub type dev_t = u64; -pub type socklen_t = u32; +pub type useconds_t = c_uint; +pub type dev_t = c_ulonglong; +pub type socklen_t = c_uint; pub type pthread_t = c_ulong; -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 mqd_t = c_int; +pub type mode_t = c_uint; pub type nfds_t = c_ulong; pub type nl_item = c_int; pub type idtype_t = c_uint; -pub type loff_t = c_longlong; +pub type loff_t = crate::off_t; +pub type nlink_t = c_ulong; +pub type blksize_t = c_long; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] +pub type mqd_t = c_int; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] +pub type off64_t = i64; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] +pub type ino64_t = u64; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] +pub type blkcnt64_t = i64; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] +pub type rlim64_t = u64; pub type __u8 = c_uchar; pub type __u16 = c_ushort; @@ -76,12 +103,30 @@ pub type msgqnum_t = c_ulong; pub type msglen_t = c_ulong; pub type fsblkcnt_t = c_ulonglong; pub type fsfilcnt_t = c_ulonglong; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub type rlim_t = c_ulonglong; +#[deprecated( + since = "0.2.189", + note = "Use `statfs` instead. This type does not exist upstream and will \ + eventually be removed." +)] +pub type statfs64 = statfs; + extern_ty! { pub type timezone; pub type DIR; - pub type fpos64_t; // FIXME(fuchsia): fill this out with a struct + + #[deprecated( + since = "0.2.189", + note = "Use `fpos_t` instead. This type does not exist upstream and \ + will eventually be removed." + )] + pub type fpos64_t; } // Deprecated impls: see #5296 @@ -115,8 +160,11 @@ s! { pub tv_nsec: c_long, } - // FIXME(fuchsia): the rlimit and rusage related functions and types don't exist - // within zircon. Are there reasons for keeping them around? + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, @@ -363,7 +411,7 @@ s! { } pub struct fd_set { - fds_bits: [c_ulong; FD_SETSIZE as usize / ULONG_SIZE], + fds_bits: [c_ulong; FD_SETSIZE as usize / 8 / size_of::()], } pub struct tm { @@ -395,6 +443,12 @@ s! { pub dli_saddr: *mut c_void, } + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] + #[allow(deprecated)] pub struct epoll_event { pub events: u32, pub u64: u64, @@ -427,6 +481,11 @@ s! { pub int_n_sign_posn: c_char, } + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, @@ -436,13 +495,8 @@ s! { pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, - pub gl_flags: c_int, - - __unused1: Padding<*mut c_void>, - __unused2: Padding<*mut c_void>, - __unused3: Padding<*mut c_void>, - __unused4: Padding<*mut c_void>, - __unused5: Padding<*mut c_void>, + __dummy1: Padding, + __dummy2: Padding<[*mut c_void; 5]>, } pub struct ifaddrs { @@ -486,15 +540,10 @@ 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(all(target_pointer_width = "32", not(target_arch = "x86_64")))] - __f_unused: Padding, - #[cfg(target_endian = "big")] 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 dqblk { @@ -544,10 +593,7 @@ s! { } pub struct cpu_set_t { - #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] - bits: [u32; 32], - #[cfg(not(all(target_pointer_width = "32", not(target_arch = "x86_64"))))] - bits: [u64; 16], + __bits: [c_ulonglong; 128 / size_of::()], } pub struct if_nameindex { @@ -672,6 +718,11 @@ s! { pub weak_magnitude: crate::__u16, } + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct ff_effect { pub type_: crate::__u16, pub id: crate::__s16, @@ -686,23 +737,10 @@ s! { } pub struct dl_phdr_info { - #[cfg(target_pointer_width = "64")] pub dlpi_addr: Elf64_Addr, - #[cfg(target_pointer_width = "32")] - pub dlpi_addr: Elf32_Addr, - pub dlpi_name: *const c_char, - - #[cfg(target_pointer_width = "64")] pub dlpi_phdr: *const Elf64_Phdr, - #[cfg(target_pointer_width = "32")] - pub dlpi_phdr: *const Elf32_Phdr, - - #[cfg(target_pointer_width = "64")] pub dlpi_phnum: Elf64_Half, - #[cfg(target_pointer_width = "32")] - pub dlpi_phnum: Elf32_Half, - pub dlpi_adds: c_ulonglong, pub dlpi_subs: c_ulonglong, pub dlpi_tls_modid: size_t, @@ -731,21 +769,11 @@ s! { pub p_align: Elf64_Xword, } - pub struct statfs64 { - pub f_type: c_ulong, - pub f_bsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_fsid: crate::fsid_t, - pub f_namelen: c_ulong, - pub f_frsize: c_ulong, - pub f_flags: c_ulong, - pub f_spare: [c_ulong; 4], - } - + #[deprecated( + since = "0.2.189", + note = "Use `statvfs` instead. This type does not exist upstream and \ + will eventually be removed." + )] pub struct statvfs64 { pub f_bsize: c_ulong, pub f_frsize: c_ulong, @@ -768,11 +796,19 @@ s! { } pub struct pthread_attr_t { - __size: [u64; 7], + __name: *const c_char, + __c11: c_int, + _a_stacksize: crate::size_t, + _a_guardsize: crate::size_t, + _a_stackaddr: *mut c_void, + _a_detach: c_int, + _a_sched: c_int, + _a_policy: c_int, + _a_prio: c_int, } pub struct sigset_t { - __val: [c_ulong; 16], + __bits: [c_ulong; 128 / size_of::()], } pub struct shmid_ds { @@ -837,17 +873,23 @@ s! { } pub struct sem_t { - __val: [c_int; 8], + _s_value: c_int, + _s_waiters: c_int, } + #[repr(align(8))] pub struct siginfo_t { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - pub _pad: [c_int; 29], - _align: [usize; 0], + __si_fields: Padding<__c_anonymous_siginfo_t___si_fields>, } + #[deprecated( + since = "0.2.189", + note = "Use `termios`. This type does not exist upstream and will \ + eventually be removed." + )] pub struct termios2 { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, @@ -864,29 +906,23 @@ s! { pub ipi6_ifindex: c_uint, } - #[cfg_attr( - any(target_pointer_width = "32", target_arch = "x86_64"), - repr(align(4)) - )] - #[cfg_attr( - not(any(target_pointer_width = "32", target_arch = "x86_64")), - repr(align(8)) - )] pub struct pthread_mutexattr_t { - size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T], + __attr: c_uint, } - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] pub struct pthread_rwlockattr_t { - size: [u8; crate::__SIZEOF_PTHREAD_RWLOCKATTR_T], + __attr: [c_uint; 2], } - #[repr(align(4))] pub struct pthread_condattr_t { - size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], + __attr: c_uint, } + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct sysinfo { pub uptime: c_ulong, pub loads: [c_ulong; 3], @@ -911,13 +947,14 @@ s! { pub struct sockaddr_storage { pub ss_family: sa_family_t, - __ss_pad2: Padding<[u8; 128 - 2 - 8]>, - __ss_align: size_t, + __ss_padding: + Padding<[c_char; 128 - size_of::() - size_of::()]>, + __ss_align: c_ulong, } pub struct utsname { pub sysname: [c_char; 65], - pub nodename: [c_char; 65], + pub nodename: [c_char; HOST_NAME_MAX as usize + 1], pub release: [c_char; 65], pub version: [c_char; 65], pub machine: [c_char; 65], @@ -925,13 +962,19 @@ s! { } pub struct dirent { - pub d_ino: crate::ino_t, + pub d_ino: ino_t, pub d_off: off_t, pub d_reclen: c_ushort, pub d_type: c_uchar, pub d_name: [c_char; 256], } + #[deprecated( + since = "0.2.189", + note = "Use `dirent` instead. This type does not exist upstream and \ + will eventually be removed." + )] + #[allow(deprecated)] pub struct dirent64 { pub d_ino: crate::ino64_t, pub d_off: off64_t, @@ -940,8 +983,11 @@ s! { pub d_name: [c_char; 256], } - // x32 compatibility - // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct mq_attr { #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] pub mq_flags: i64, @@ -966,6 +1012,11 @@ s! { pad: Padding<[c_long; 4]>, } + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct sockaddr_nl { pub nl_family: crate::sa_family_t, nl_pad: Padding, @@ -979,60 +1030,105 @@ s! { pub sigev_value: crate::sigval, pub sigev_signo: c_int, pub sigev_notify: c_int, - pub sigev_notify_function: fn(crate::sigval), + pub sigev_notify_function: Option, pub sigev_notify_attributes: *mut pthread_attr_t, - pub __pad: [c_char; 56 - 3 * 8], + __pad: Padding<[c_char; 56 - 3 * size_of::()]>, } - #[cfg_attr( - all( - target_pointer_width = "32", - any(target_arch = "arm", target_arch = "x86_64") - ), - repr(align(4)) - )] - #[cfg_attr( - any( - target_pointer_width = "64", - not(any(target_arch = "arm", target_arch = "x86_64")) - ), - repr(align(8)) - )] pub struct pthread_mutex_t { - size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T], + _m_attr: c_uint, + _m_lock: c_int, + _m_waiters: c_int, + _m_count: c_int, } - #[cfg_attr( - all( - target_pointer_width = "32", - any(target_arch = "arm", target_arch = "x86_64") - ), - repr(align(4)) - )] - #[cfg_attr( - any( - target_pointer_width = "64", - not(any(target_arch = "arm", target_arch = "x86_64")) - ), - repr(align(8)) - )] pub struct pthread_rwlock_t { - size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T], + _rw_lock: c_int, + _rw_waiters: c_int, } - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_arch = "x86", repr(align(4)))] - #[cfg_attr(not(target_arch = "x86"), repr(align(8)))] pub struct pthread_cond_t { - size: [u8; crate::__SIZEOF_PTHREAD_COND_T], + _c_head: *mut c_void, + _c_clock: c_int, + _c_tail: *mut c_void, + _c_lock: c_int, + } +} + +s_no_extra_traits! { + pub union fpos_t { + __opaque: [c_char; 16], + __align: c_double, + } + + pub union __c_anonymous_siginfo_t___si_fields { + __pad: Padding<[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, + } + + pub struct __c_anonymous___si_fields___si_common { + __first: Padding<__c_anonymous___si_common___first>, + __second: Padding<__c_anonymous___si_common___second>, + } + + pub union __c_anonymous___si_common___first { + __piduid: __c_anonymous___first___piduid, + __timer: __c_anonymous___first___timer, + } + + pub struct __c_anonymous___first___piduid { + si_pid: pid_t, + si_uid: uid_t, + } + + pub struct __c_anonymous___first___timer { + si_timerid: c_int, + si_overrun: c_int, + } + + pub union __c_anonymous___si_common___second { + si_value: sigval, + __sigchld: __c_anonymous___second___sigchld, + } + + pub struct __c_anonymous___second___sigchld { + si_status: c_int, + si_utime: clock_t, + si_stime: clock_t, + } + + pub struct __c_anonymous___si_fields___sigfault { + si_addr: *mut c_void, + si_dadr_lsb: c_short, + __addr_bnd: __c_anonymous___sigfault___addr_bnd, + } + + pub struct __c_anonymous___sigfault___addr_bnd { + si_lower: *mut c_void, + si_upper: *mut c_void, + } + + pub struct __c_anonymous___si_fields___sigpoll { + si_band: c_long, + si_fd: c_int, + } + + pub struct __c_anonymous___si_fields___sigsys { + si_call_addr: *mut c_void, + si_syscall: c_int, + si_arch: c_uint, } } // PUB_CONST -pub const INT_MIN: c_int = -2147483648; -pub const INT_MAX: c_int = 2147483647; +pub const HOST_NAME_MAX: c_int = 255; + +pub const INT_MIN: c_int = -1 - 0x7fffffff; +pub const INT_MAX: c_int = 0x7fffffff; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; @@ -1052,7 +1148,7 @@ pub const FD_CLOEXEC: c_int = 0x1; pub const USRQUOTA: c_int = 0; pub const GRPQUOTA: c_int = 1; -pub const SIGIOT: c_int = 6; +pub const SIGIOT: c_int = SIGABRT; pub const S_ISUID: mode_t = 0o4000; pub const S_ISGID: mode_t = 0o2000; @@ -1982,7 +2078,20 @@ pub const _SC_XOPEN_STREAMS: c_int = 246; pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; +#[deprecated( + since = "0.2.189", + note = "This constant does not exist upstream and will eventually be \ + removed." +)] +#[allow(deprecated)] pub const RLIM_SAVED_MAX: crate::rlim_t = RLIM_INFINITY; + +#[deprecated( + since = "0.2.189", + note = "This constant does not exist upstream and will eventually be \ + removed." +)] +#[allow(deprecated)] pub const RLIM_SAVED_CUR: crate::rlim_t = RLIM_INFINITY; pub const GLOB_ERR: c_int = 1 << 0; @@ -2035,13 +2144,20 @@ pub const RTLD_NOW: c_int = 0x2; pub const TCP_MD5SIG: c_int = 14; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [0; __SIZEOF_PTHREAD_MUTEX_T], + _m_attr: 0, + _m_lock: 0, + _m_waiters: 0, + _m_count: 0, }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [0; __SIZEOF_PTHREAD_COND_T], + _c_head: ptr::null_mut(), + _c_clock: 0, + _c_tail: ptr::null_mut(), + _c_lock: 0, }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + _rw_lock: 0, + _rw_waiters: 0, }; pub const PTHREAD_MUTEX_NORMAL: c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; @@ -2049,6 +2165,11 @@ pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; pub const PTHREAD_PROCESS_SHARED: c_int = 1; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub const __SIZEOF_PTHREAD_COND_T: usize = 48; pub const RENAME_NOREPLACE: c_int = 1; @@ -2526,12 +2647,34 @@ pub const POSIX_FADV_NOREUSE: c_int = 5; pub const POSIX_MADV_DONTNEED: c_int = 4; +#[deprecated( + since = "0.2.189", + note = "This constant does not exist upstream and will eventually be \ + removed." +)] +#[allow(deprecated)] pub const RLIM_INFINITY: crate::rlim_t = !0; + +#[deprecated( + since = "0.2.189", + note = "This constant does not exist upstream and will eventually be \ + removed." +)] +#[allow(deprecated)] pub const RLIMIT_RTTIME: c_int = 15; -#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + +#[deprecated( + since = "0.2.189", + note = "This constant does not exist upstream and will eventually be \ + removed." +)] pub const RLIMIT_NLIMITS: c_int = 16; +#[deprecated( + since = "0.2.189", + note = "This constant does not exist upstream and will eventually be \ + removed." +)] #[allow(deprecated)] -#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIM_NLIMITS: c_int = RLIMIT_NLIMITS; pub const MAP_ANONYMOUS: c_int = MAP_ANON; @@ -2552,8 +2695,22 @@ pub const TCP_TIMESTAMP: c_int = 24; pub const SIGUNUSED: c_int = crate::SIGSYS; +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const CPU_SETSIZE: c_int = 128; @@ -2692,7 +2849,16 @@ pub const B3000000: crate::speed_t = 0o010015; pub const B3500000: crate::speed_t = 0o010016; pub const B4000000: crate::speed_t = 0o010017; +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const O_ASYNC: c_int = 0x00000400; @@ -2956,17 +3122,6 @@ pub const O_NOFOLLOW: c_int = 0x00000080; pub const HUGETLB_FLAG_ENCODE_SHIFT: u32 = 26; pub const MAP_HUGE_SHIFT: u32 = 26; -// intentionally not public, only used for fd_set -cfg_if! { - if #[cfg(target_pointer_width = "32")] { - const ULONG_SIZE: usize = 32; - } else if #[cfg(target_pointer_width = "64")] { - const ULONG_SIZE: usize = 64; - } else { - // Unknown target_pointer_width - } -} - // END_PUB_CONST f! { @@ -2995,31 +3150,34 @@ f! { } pub unsafe fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - cpuset.bits.fill(0); + cpuset.__bits.fill(0); } pub unsafe fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc - let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - cpuset.bits[idx] |= 1 << offset; - () + if !(cpu / 8 >= size_of::()) { + cpuset.__bits[cpu / 8 / size_of::()] |= 1 << (cpu % (8 * size_of::())); + } } pub unsafe fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc - let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - cpuset.bits[idx] &= !(1 << offset); - () + if !(cpu / 8 >= size_of::()) { + cpuset.__bits[cpu / 8 / size_of::()] &= + !(1 << (cpu % (8 * size_of::()))); + } } pub unsafe fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); - let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - 0 != (cpuset.bits[idx] & (1 << offset)) + if !(cpu / 8 >= size_of::()) { + (cpuset.__bits[cpu / 8 / size_of::()] + & (1 << (cpu % (8 * size_of::())))) + != 0 + } else { + false + } } pub unsafe fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { - set1.bits == set2.bits + set1.__bits == set2.__bits } pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { @@ -3055,9 +3213,7 @@ f! { pub const unsafe fn CMSG_LEN(len: c_uint) -> c_uint { (CMSG_ALIGN(size_of::()) + len as size_t) as c_uint } -} -safe_f! { pub const safe fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } @@ -3141,7 +3297,6 @@ extern "C" {} extern_ty! { pub type FILE; - pub type fpos_t; // FIXME(fuchsia): fill this out with a struct } extern "C" { @@ -3758,7 +3913,7 @@ extern "C" { pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; - pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t; + pub fn readahead(fd: c_int, offset: off_t, count: size_t) -> ssize_t; pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int; pub fn timerfd_create(clockid: c_int, flags: c_int) -> c_int; pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; @@ -3798,7 +3953,7 @@ extern "C" { pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); - pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; + pub fn sync_file_range(fd: c_int, offset: off_t, nbytes: off_t, flags: c_uint) -> c_int; pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; pub fn freeifaddrs(ifa: *mut crate::ifaddrs); diff --git a/src/fuchsia/riscv64.rs b/src/fuchsia/riscv64.rs index bc93cc3bff0a9..75ecea9adffa9 100644 --- a/src/fuchsia/riscv64.rs +++ b/src/fuchsia/riscv64.rs @@ -1,14 +1,19 @@ -use crate::off_t; use crate::prelude::*; // From psABI Calling Convention for RV64 +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub type __u64 = c_ulonglong; pub type wchar_t = i32; -pub type nlink_t = c_ulong; -pub type blksize_t = c_long; - +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -17,9 +22,9 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: Padding, + __pad0: Padding, pub st_rdev: crate::dev_t, - pub st_size: off_t, + pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, @@ -32,6 +37,11 @@ s! { } // Not actually used, IPC calls just return ENOSYS + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct ipc_perm { pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, @@ -43,4 +53,16 @@ s! { __unused1: Padding, __unused2: Padding, } + + pub struct mcontext_t { + pub regs: [c_ulong; 32], + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut crate::ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: crate::mcontext_t, + } } diff --git a/src/fuchsia/x86_64.rs b/src/fuchsia/x86_64.rs index fc42cd9810985..ab9927eb09974 100644 --- a/src/fuchsia/x86_64.rs +++ b/src/fuchsia/x86_64.rs @@ -2,11 +2,41 @@ use crate::off_t; use crate::prelude::*; pub type wchar_t = i32; -pub type nlink_t = u64; -pub type blksize_t = c_long; + +#[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be removed." +)] pub type __u64 = c_ulonglong; +pub type gregset_t = [c_ulonglong; 23]; +pub type fpregset_t = *mut _fpstate; + s! { + pub struct _fpstate { + pub cwd: c_ushort, + pub swd: c_ushort, + pub ftw: c_ushort, + pub fop: c_ushort, + pub rip: c_ulonglong, + pub rdp: c_ulonglong, + pub mxcsr: c_uint, + pub mxcr_mask: c_uint, + pub _st: [__c_anonymous__fpstate__st; 8], + pub _xmm: [__c_anonymous__fpstate__xmm; 16], + padding: Padding<[c_uint; 24]>, + } + + pub struct __c_anonymous__fpstate__st { + pub significand: [c_ushort; 4], + pub exponent: c_ushort, + padding: Padding<[c_ushort; 3]>, + } + + pub struct __c_anonymous__fpstate__xmm { + pub element: [c_uint; 4], + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -14,7 +44,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: Padding, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -28,6 +58,11 @@ s! { __unused: Padding<[c_long; 3]>, } + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino64_t, @@ -50,9 +85,25 @@ s! { } pub struct mcontext_t { - __private: [u64; 32], + pub gregs: crate::gregset_t, + pub fpregs: crate::fpregset_t, + __reserved1: Padding<[c_ulonglong; 8]>, } + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: crate::mcontext_t, + pub uc_sigmask: crate::sigset_t, + __fpregs_mem: [c_ulong; 64], + } + + #[deprecated( + since = "0.2.189", + note = "This type does not exist upstream and will eventually be \ + removed." + )] pub struct ipc_perm { pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, @@ -64,15 +115,6 @@ s! { __unused1: Padding, __unused2: Padding, } - - pub struct ucontext_t { - pub uc_flags: c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: crate::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask: crate::sigset_t, - __private: [u8; 512], - } } // offsets in user_regs_structs, from sys/reg.h diff --git a/src/macros.rs b/src/macros.rs index 0271d326aa1b4..d82febea32410 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -230,6 +230,7 @@ macro_rules! s_no_extra_traits { $(#[$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() @@ -249,6 +250,194 @@ 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])* + $pub:vis $t:ident $i:ident { $($field:tt)* } + )*) => ($( + s_with_default!(it: $(#[$attr])* $pub $t $i { $($field)* }); + )*); + + (it: $(#[$attr:meta])* $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)* }) => ( + struct_with_default! { + attrs: { + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(PartialEq, Eq, Hash) + )] + #[allow(deprecated)] + } + $(#[$attr])* $pub struct $i { $($field)* } + } + ); +} + +/// Like [`s_no_extra_traits`], but also generates a `Default` impl for every struct in the block. +/// +/// Unions are emitted just like `s_no_extra_traits!` does, with no `Default`. A struct field of +/// union type supplies its own default via `#[custom_default(...)]`. +macro_rules! s_no_extra_traits_with_default { + ($( + $(#[$attr:meta])* + $pub:vis $t:ident $i:ident { $($field:tt)* } + )*) => ($( + 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:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + struct_with_default! { + attrs: { + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + } + $(#[$attr])* $pub struct $i { $($field)* } + } + ); +} + +/// 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 +/// `#[custom_default(EXPR)]` as its *first* attribute, and `EXPR` is used instead. +/// +/// This works by scanning each field for `#[custom_default]` attributes. If one exists, the +/// attribute's contents are added to `processed_field_defaults` and will be used in the expansion +/// 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. +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])* + $vis:vis struct $name:ident { $($body:tt)* } + ) => { + struct_with_default! { + @struct + attrs: { $($attrs)* $(#[$attr])* } + vis: { $vis } + name: { $name } + processed_fields: { } + processed_field_defaults: { } + remaining_fields: { $($body)* } + } + }; + + // field led by #[custom_default(...)] + ( + @struct + attrs: { $($attrs:tt)* } + vis: { $vis:vis } + name: { $name:ident } + processed_fields: { $($processed_fields:tt)* } + processed_field_defaults: { $($processed_field_defaults:tt)* } + remaining_fields: { + #[custom_default($default:expr)] + $(#[$fattr:meta])* + $fvis:vis $fname:ident: $fty:ty, + $($tail:tt)* + } + ) => { + struct_with_default! { + @struct + attrs: { $($attrs)* } + vis: { $vis } + name: { $name } + processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } + processed_field_defaults: { + $($processed_field_defaults)* + $(#[$fattr])* $fname: $default, + } + remaining_fields: { $($tail)* } + } + }; + + // plain field + ( + @struct + attrs: { $($attrs:tt)* } + vis: { $vis:vis } + name: { $name:ident } + processed_fields: { $($processed_fields:tt)* } + processed_field_defaults: { $($processed_field_defaults:tt)* } + remaining_fields: { + $(#[$fattr:meta])* + $fvis:vis $fname:ident: $fty:ty, + $($tail:tt)* + } + ) => { + struct_with_default! { + @struct + attrs: { $($attrs)* } + vis: { $vis } + name: { $name } + processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } + processed_field_defaults: { + $($processed_field_defaults)* + $(#[$fattr])* $fname: ::core::default::Default::default(), + } + remaining_fields: { $($tail)* } + } + }; + + // done + ( + @struct + attrs: { $($attrs:tt)* } + vis: { $vis:vis } + name: { $name:ident } + processed_fields: { $($processed_fields:tt)* } + processed_field_defaults: { $($processed_field_defaults:tt)* } + remaining_fields: { } + ) => { + $($attrs)* + $vis struct $name { $($processed_fields)* } + + 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. + #[allow(unused_doc_comments)] + fn default() -> Self { + Self { $($processed_field_defaults)* } + } + } + }; +} + /// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, /// and `Copy`, but these aren't meaningful for extern types so they should eventually /// be removed. @@ -402,36 +591,59 @@ macro_rules! c_enum { (@ty) => { $crate::prelude::CEnumRepr }; } -/// Define a `unsafe` function. +/// Define a function that can be either `safe` or `unsafe` and optionally `const`. This always +/// marks the function inline and adds `extern "C"`. macro_rules! f { ($( $(#[$attr:meta])* - pub $(const $($const_dummy:literal)?)? unsafe + pub $(const $($const_dummy:literal)?)? + $(unsafe $($unsafe_dummy:literal)?)? $(safe $($safe_dummy:literal)?)? fn $i:ident ($($arg:ident: $argty:ty),* $(,)?) -> $ret:ty $body:block )+) => {$( + f! { + @single + $(#[$attr])* + pub $(const $($const_dummy)?)? + $(unsafe $($unsafe_dummy)?)? $(safe $($safe_dummy)?)? + fn $i ($($arg: $argty),*) -> $ret + $body + } + )+}; + + (@single + $(#[$attr:meta])* + pub $(const $($const_dummy:literal)?)? unsafe + fn $i:ident ($($arg:ident: $argty:ty),* $(,)?) -> $ret:ty + $body:block + ) => { #[inline] $(#[$attr])* pub $(const $($const_dummy)?)? unsafe extern "C" fn $i ($($arg: $argty),*) -> $ret $body - )+}; -} + }; -/// Define a safe function. -macro_rules! safe_f { - ($( + (@single $(#[$attr:meta])* pub $(const $($const_dummy:literal)?)? safe fn $i:ident ($($arg:ident: $argty:ty),* $(,)?) -> $ret:ty $body:block - )+) => {$( + ) => { #[inline] $(#[$attr])* pub $(const $($const_dummy)?)? extern "C" fn $i ($($arg: $argty),*) -> $ret $body - )+}; + }; + + (@single + pub $(const $($const_dummy:literal)?)? + fn $i:ident ($($arg:ident: $argty:ty),* $(,)?) -> $ret:ty + $body:block + ) => { + compile_error!("either `safe` or `unsafe` must be specified"); + }; } // This macro is used to deprecate items that should be accessed via the mach2 crate @@ -631,6 +843,29 @@ mod tests { assert_eq!(PRIV_ON_1, 42u16); } + #[test] + #[deny(unused_unsafe)] + fn f_safety() { + // Enusure the created functions are safe / unsafe / const as expected + f! { + pub unsafe fn unsafe_foo() -> u32 { 100 } + pub const unsafe fn const_unsafe_foo() -> u32 { 101 } + pub safe fn safe_foo() -> u32 { 200 } + pub const safe fn const_safe_foo() -> u32 { 201 } + } + + assert_eq!(unsafe { unsafe_foo() }, 100u32); + assert_eq!(const { unsafe { const_unsafe_foo() } }, 101u32); + assert_eq!(safe_foo(), 200u32); + assert_eq!(const { const_safe_foo() }, 201u32); + + // Check the ABI + let _: unsafe extern "C" fn() -> u32 = unsafe_foo; + let _: unsafe extern "C" fn() -> u32 = const_unsafe_foo; + let _: extern "C" fn() -> u32 = safe_foo; + let _: extern "C" fn() -> u32 = const_safe_foo; + } + fn type_id_of_val(_: &T) -> TypeId { TypeId::of::() } @@ -654,6 +889,81 @@ mod tests { assert_eq!(core::mem::offset_of!(Off1, c), offset_of!(Off1, c)); assert_eq!(core::mem::offset_of!(Off1, d), offset_of!(Off1, d)); } + + #[test] + fn s_with_default_uses_custom_default() { + // A non-default value proves `custom_default` is used rather than a derived default. + s_with_default! { + struct CustomDefault { + a: u32, + #[custom_default([1; 64])] + buf: [u8; 64], + } + } + + let s = CustomDefault::default(); + assert_eq!(s.a, 0); + assert_eq!(s.buf, [1u8; 64]); + } + + #[test] + fn s_with_default_keeps_field_attrs() { + // If `custom_default` stripping ate the other field attributes, the two `a` fields + // would collide. + s_with_default! { + struct FieldAttrs { + #[cfg(target_arch = "x86_64")] + a: u8, + #[cfg(not(target_arch = "x86_64"))] + a: u64, + } + } + + let s = FieldAttrs::default(); + #[cfg(target_arch = "x86_64")] + assert_eq!(s.a, 0u8); + #[cfg(not(target_arch = "x86_64"))] + assert_eq!(s.a, 0u64); + } + + #[test] + fn s_with_default_single_cfg_field() { + // this field only exists on x86_64, so its default init needs the same cfg or + // Default won't build on other arches + s_with_default! { + struct SingleCfg { + common: u32, + #[cfg(target_arch = "x86_64")] + x86_only: u64, + } + } + + let s = SingleCfg::default(); + assert_eq!(s.common, 0); + #[cfg(target_arch = "x86_64")] + assert_eq!(s.x86_only, 0); + } + + #[test] + fn s_no_extra_traits_with_default_zeroes_union() { + // A union field's default is supplied by `custom_default(unsafe { mem::zeroed })`. + s_no_extra_traits_with_default! { + union U { + a: u32, + b: f32, + } + + struct HasUnion { + x: u16, + #[custom_default(unsafe { ::core::mem::zeroed::() })] + u: U, + } + } + + let s = HasUnion::default(); + assert_eq!(s.x, 0); + assert_eq!(unsafe { s.u.a }, 0); + } } #[cfg(test)] @@ -697,4 +1007,37 @@ mod macro_checks { type Foo; pub type Bar; } + + s_with_default! { + pub struct S3 { + pub a: u32, + #[custom_default([1; 64])] + pub buf: [u8; 64], + } + + struct S3Priv { + pub a: u32, + b: u32, + } + } + + s_no_extra_traits_with_default! { + pub union U3 { + pub a: u32, + b: f32, + } + + pub struct S4 { + pub a: u32, + #[custom_default(unsafe { ::core::mem::zeroed::() })] + pub u: U3, + } + } + + fn assert_impls_default() {} + + fn check_default() { + assert_impls_default::(); + assert_impls_default::(); + } } diff --git a/src/new/apple/xnu/mod.rs b/src/new/apple/xnu/mod.rs index a81d38db55d55..84fd8cbeb9745 100644 --- a/src/new/apple/xnu/mod.rs +++ b/src/new/apple/xnu/mod.rs @@ -4,7 +4,7 @@ /// Directory: `arm/` /// -/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/arm +/// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] pub(crate) mod arm { pub(crate) mod _mcontext; @@ -12,7 +12,7 @@ pub(crate) mod arm { /// Directory: `i386/` /// -/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/i386 +/// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub(crate) mod i386 { pub(crate) mod _mcontext; @@ -22,13 +22,15 @@ pub(crate) mod mach; /// Directory: `machine/` /// -/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/machine +/// pub(crate) mod machine { pub(crate) mod _mcontext; } pub(crate) mod net; +pub(crate) mod netinet; + pub(crate) mod netinet6; pub(crate) mod sys; diff --git a/src/new/apple/xnu/net/bpf.rs b/src/new/apple/xnu/net/bpf.rs index dc0aae84de28f..2f938c577088e 100644 --- a/src/new/apple/xnu/net/bpf.rs +++ b/src/new/apple/xnu/net/bpf.rs @@ -47,7 +47,11 @@ pub const DLT_ATM_RFC1483: c_uint = 11; // LLC/SNAP encapsulated atm pub const DLT_RAW: c_uint = 12; // raw IP pub const DLT_LOOP: c_uint = 108; -pub const BPF_ALIGNMENT: c_int = size_of::() as c_int; +pub const BPF_ALIGNMENT: size_t = size_of::(); + +pub const fn BPF_WORDALIGN(x: usize) -> usize { + (x + (BPF_ALIGNMENT as usize - 1)) & !(BPF_ALIGNMENT as usize - 1) +} pub const BIOCGRSIG: c_ulong = _IOR::('B' as c_ulong, 114); pub const BIOCSRSIG: c_ulong = _IOW::('B' as c_ulong, 115); diff --git a/src/new/apple/xnu/netinet/mod.rs b/src/new/apple/xnu/netinet/mod.rs new file mode 100644 index 0000000000000..fef0661876196 --- /dev/null +++ b/src/new/apple/xnu/netinet/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `netinet/` +//! +//! + +pub(crate) mod tcp; diff --git a/src/new/apple/xnu/netinet/tcp.rs b/src/new/apple/xnu/netinet/tcp.rs new file mode 100644 index 0000000000000..feb51c80e5085 --- /dev/null +++ b/src/new/apple/xnu/netinet/tcp.rs @@ -0,0 +1,84 @@ +//! Header: `netinet/tcp.h` +//! +//! + +use crate::prelude::*; + +// TCP header flags. These are numbered as if `th_x2` and `th_flags` were one +// field, with `th_flags` as the low octet, so `TH_AE` (0x100) and `TH_ACE` +// (which spans both) do not fit in `th_flags` alone. +pub const TH_FIN: c_int = 0x01; +pub const TH_SYN: c_int = 0x02; +pub const TH_RST: c_int = 0x04; +pub const TH_PUSH: c_int = 0x08; +pub const TH_ACK: c_int = 0x10; +pub const TH_URG: c_int = 0x20; +pub const TH_ECE: c_int = 0x40; +pub const TH_CWR: c_int = 0x80; +pub const TH_AE: c_int = 0x100; + +pub const TH_FLAGS: c_int = TH_FIN | TH_SYN | TH_RST | TH_ACK | TH_URG | TH_ECE | TH_CWR; +pub const TH_FLAGS_ALL: c_int = TH_FLAGS | TH_PUSH; +pub const TH_ACCEPT: c_int = TH_FIN | TH_SYN | TH_RST | TH_ACK; +pub const TH_ACE: c_int = TH_AE | TH_CWR | TH_ECE; + +// TCP option kinds and their lengths. +pub const TCPOPT_EOL: c_int = 0; +pub const TCPOLEN_EOL: c_int = 1; +pub const TCPOPT_NOP: c_int = 1; +pub const TCPOLEN_NOP: c_int = 1; +pub const TCPOPT_MAXSEG: c_int = 2; +pub const TCPOLEN_MAXSEG: c_int = 4; +pub const TCPOPT_WINDOW: c_int = 3; +pub const TCPOLEN_WINDOW: c_int = 3; +/// SACK capability in SYN. +pub const TCPOPT_SACK_PERMITTED: c_int = 4; +pub const TCPOLEN_SACK_PERMITTED: c_int = 2; +pub const TCPOPT_SACK: c_int = 5; +pub const TCPOLEN_SACKHDR: c_int = 2; +/// Length of one SACK block. +pub const TCPOLEN_SACK: c_int = 8; +pub const TCPOPT_TIMESTAMP: c_int = 8; +pub const TCPOLEN_TIMESTAMP: c_int = 10; +/// RFC 1323 appendix A. +pub const TCPOLEN_TSTAMP_APPA: c_int = TCPOLEN_TIMESTAMP + 2; +pub const TCPOPT_TSTAMP_HDR: c_int = + (TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP; + +/// Absolute maximum TCP options length. +pub const MAX_TCPOPTLEN: c_int = 40; + +/// CC options: RFC 1644. +pub const TCPOPT_CC: c_int = 11; +pub const TCPOPT_CCNEW: c_int = 12; +pub const TCPOPT_CCECHO: c_int = 13; +pub const TCPOLEN_CC: c_int = 6; +pub const TCPOLEN_CC_APPA: c_int = TCPOLEN_CC + 2; + +/// Keyed MD5: RFC 2385. +pub const TCPOPT_SIGNATURE: c_int = 19; +pub const TCPOLEN_SIGNATURE: c_int = 18; + +pub const TCPOPT_FASTOPEN: c_int = 34; +pub const TCPOLEN_FASTOPEN_REQ: c_int = 2; + +/// AccECN order 0. +pub const TCPOPT_ACCECN0: c_int = 172; +/// AccECN order 1. +pub const TCPOPT_ACCECN1: c_int = 174; +/// Empty option contains kind and length. +pub const TCPOLEN_ACCECN_EMPTY: c_int = 2; +/// Length of each AccECN counter. +pub const TCPOLEN_ACCECN_COUNTER: c_int = 3; + +pub const TCPOPT_SACK_PERMIT_HDR: c_int = + (TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_SACK_PERMITTED << 8) | TCPOLEN_SACK_PERMITTED; +pub const TCPOPT_SACK_HDR: c_int = (TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_SACK << 8); + +/// Maximum number of SACK blocks stored at the sender. +/// +/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) +/// for details. +pub const MAX_SACK_BLKS: c_int = 6; +/// Maximum number of SACKs sent in any segment. +pub const TCP_MAX_SACK: c_int = 4; diff --git a/src/new/apple/xnu/sys/mod.rs b/src/new/apple/xnu/sys/mod.rs index 8c7108c63aa74..b670ae5bc0b08 100644 --- a/src/new/apple/xnu/sys/mod.rs +++ b/src/new/apple/xnu/sys/mod.rs @@ -9,7 +9,7 @@ pub(crate) mod ttycom; /// Directory: `sys/_types` /// -/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys/_types +/// pub(crate) mod _types { pub(crate) mod _ucontext; } diff --git a/src/new/bionic_libc/pthread.rs b/src/new/bionic_libc/pthread.rs index 4997547ff0905..db62dc4ce7844 100644 --- a/src/new/bionic_libc/pthread.rs +++ b/src/new/bionic_libc/pthread.rs @@ -2,6 +2,7 @@ pub use crate::new::common::linux_like::pthread::{ pthread_getattr_np, + pthread_gettid_np, pthread_setname_np, }; pub use crate::new::common::posix::pthread::{ diff --git a/src/new/common/linux_like/pthread.rs b/src/new/common/linux_like/pthread.rs index b54d385f9c05f..e76b704142a7c 100644 --- a/src/new/common/linux_like/pthread.rs +++ b/src/new/common/linux_like/pthread.rs @@ -13,6 +13,9 @@ extern "C" { #[cfg(target_os = "linux")] pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; + #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))] + pub fn pthread_gettid_np(thread: crate::pthread_t) -> crate::pid_t; + #[cfg(any(target_os = "linux", target_os = "l4re"))] pub fn pthread_setaffinity_np( thread: crate::pthread_t, diff --git a/src/new/freebsd/net/dlt.rs b/src/new/freebsd/net/dlt.rs index e3dddce93040c..25dee59d517ca 100644 --- a/src/new/freebsd/net/dlt.rs +++ b/src/new/freebsd/net/dlt.rs @@ -1,6 +1,6 @@ //! Header: `net/dlt.h` //! -//! https://github.com/freebsd/freebsd-src/blob/main/sys/net/dlt.h +//! use crate::prelude::*; diff --git a/src/new/freebsd/net/if_mib.rs b/src/new/freebsd/net/if_mib.rs new file mode 100644 index 0000000000000..319510d6211ce --- /dev/null +++ b/src/new/freebsd/net/if_mib.rs @@ -0,0 +1,48 @@ +//! Header: `net/if_mib.h` +//! +//! + +use crate::prelude::*; + +/// non-interface-specific +pub const IFMIB_SYSTEM: c_int = 1; +/// per-interface data table +pub const IFMIB_IFDATA: c_int = 2; + +/// 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; +/// driver name and unit +pub const IFDATA_DRIVERNAME: c_int = 3; + +/// 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; + +pub const dot3ChipSetAMD7990: c_int = 1; +pub const dot3ChipSetAMD79900: c_int = 2; +pub const dot3ChipSetAMD79C940: c_int = 3; + +pub const dot3ChipSetIntel82586: c_int = 1; +pub const dot3ChipSetIntel82596: c_int = 2; +pub const dot3ChipSetIntel82557: c_int = 3; + +pub const dot3ChipSetNational8390: c_int = 1; +pub const dot3ChipSetNationalSonic: c_int = 2; + +pub const dot3ChipSetFujitsu86950: c_int = 1; + +pub const dot3ChipSetDigitalDC21040: c_int = 1; +pub const dot3ChipSetDigitalDC21140: c_int = 2; +pub const dot3ChipSetDigitalDC21041: c_int = 3; +pub const dot3ChipSetDigitalDC21140A: c_int = 4; +pub const dot3ChipSetDigitalDC21142: c_int = 5; + +pub const dot3ChipSetWesternDigital83C690: c_int = 1; +pub const dot3ChipSetWesternDigital83C790: c_int = 2; diff --git a/src/new/freebsd/net/mod.rs b/src/new/freebsd/net/mod.rs index e270c54938cb5..d39cb6c32d728 100644 --- a/src/new/freebsd/net/mod.rs +++ b/src/new/freebsd/net/mod.rs @@ -1,5 +1,7 @@ //! Directory: `net/` //! -//! https://github.com/freebsd/freebsd-src/tree/main/sys/net +//! pub(crate) mod dlt; +pub(crate) mod if_mib; +pub(crate) mod route; diff --git a/src/new/freebsd/net/route.rs b/src/new/freebsd/net/route.rs new file mode 100644 index 0000000000000..a67faeda2e0bf --- /dev/null +++ b/src/new/freebsd/net/route.rs @@ -0,0 +1,39 @@ +//! Header: `net/route.h` +//! +//! + +use crate::prelude::*; + +s_with_default! { + pub struct rt_metrics { + pub rmx_locks: c_ulong, + pub rmx_mtu: c_ulong, + pub rmx_hopcount: c_ulong, + pub rmx_expire: c_ulong, + pub rmx_recvpipe: c_ulong, + pub rmx_sendpipe: c_ulong, + pub rmx_ssthresh: c_ulong, + pub rmx_rtt: c_ulong, + pub rmx_rttvar: c_ulong, + pub rmx_pksent: c_ulong, + pub rmx_weight: c_ulong, + pub rmx_nhidx: c_ulong, + rmx_filler: Padding<[c_ulong; 2]>, + } + + pub struct rt_msghdr { + pub rtm_msglen: c_ushort, + pub rtm_version: c_uchar, + pub rtm_type: c_uchar, + pub rtm_index: c_ushort, + _rtm_spare1: Padding, + pub rtm_flags: c_int, + pub rtm_addrs: c_int, + pub rtm_pid: crate::pid_t, + pub rtm_seq: c_int, + pub rtm_errno: c_int, + pub rtm_fmask: c_int, + pub rtm_inits: c_ulong, + pub rtm_rmx: rt_metrics, + } +} diff --git a/src/new/freebsd/netinet6/in6_var.rs b/src/new/freebsd/netinet6/in6_var.rs index f9e45306bffb5..710c851028482 100644 --- a/src/new/freebsd/netinet6/in6_var.rs +++ b/src/new/freebsd/netinet6/in6_var.rs @@ -1,6 +1,6 @@ //! Header: `netinet6/in6_var.h` //! -//! https://github.com/freebsd/freebsd-src/blob/main/sys/netinet6/in6_var.h +//! use crate::prelude::*; use crate::sys::ioccom::*; diff --git a/src/new/freebsd/netinet6/mod.rs b/src/new/freebsd/netinet6/mod.rs index 848e809aaa8c3..8aa8f09b5c391 100644 --- a/src/new/freebsd/netinet6/mod.rs +++ b/src/new/freebsd/netinet6/mod.rs @@ -1,5 +1,5 @@ //! Directory: `netinet6/` //! -//! https://github.com/freebsd/freebsd-src/tree/main/sys/netinet6 +//! pub(crate) mod in6_var; diff --git a/src/new/freebsd/sys/file.rs b/src/new/freebsd/sys/file.rs index 3072c1de7d763..b2d752e6ef2ad 100644 --- a/src/new/freebsd/sys/file.rs +++ b/src/new/freebsd/sys/file.rs @@ -1,6 +1,6 @@ //! Header: `sys/file.h` //! -//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/file.h +//! use crate::prelude::*; diff --git a/src/new/freebsd/sys/ioccom.rs b/src/new/freebsd/sys/ioccom.rs index 64261b90671b6..758d9de1245ad 100644 --- a/src/new/freebsd/sys/ioccom.rs +++ b/src/new/freebsd/sys/ioccom.rs @@ -1,6 +1,6 @@ //! Header: `sys/ioccom.h` //! -//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/ioccom.h +//! use crate::prelude::*; diff --git a/src/new/freebsd/sys/mod.rs b/src/new/freebsd/sys/mod.rs index 4afb1d48b8645..0aea439f24f87 100644 --- a/src/new/freebsd/sys/mod.rs +++ b/src/new/freebsd/sys/mod.rs @@ -1,6 +1,6 @@ //! Directory: `sys/` //! -//! https://github.com/freebsd/freebsd-src/tree/main/sys/sys' +//! pub(crate) mod file; pub(crate) mod ioccom; diff --git a/src/new/freebsd/sys/socket.rs b/src/new/freebsd/sys/socket.rs index ba528729d9585..8b3394f37c5dc 100644 --- a/src/new/freebsd/sys/socket.rs +++ b/src/new/freebsd/sys/socket.rs @@ -1,6 +1,6 @@ //! Header: `sys/socket.h` //! -//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/socket.h +//! use crate::prelude::*; diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index e11c026f3c586..86dec42d6a784 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -1,21 +1,21 @@ //! GNU libc. //! //! * Headers: (official) -//! * Headers: (mirror) +//! * Headers: (mirror) //! //! 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: `posix/` /// -/// +/// mod posix { pub(crate) mod unistd; } /// Source directory: `sysdeps/` /// -/// +/// mod sysdeps { // FIXME(pthread): eventually all platforms should use this module #[cfg(target_os = "linux")] diff --git a/src/new/glibc/posix/unistd.rs b/src/new/glibc/posix/unistd.rs index 907066c458df2..96ee83b17ecb8 100644 --- a/src/new/glibc/posix/unistd.rs +++ b/src/new/glibc/posix/unistd.rs @@ -1,6 +1,6 @@ //! Header: `unistd.h` //! -//! +//! pub use crate::new::common::posix::unistd::{ STDERR_FILENO, diff --git a/src/new/glibc/sysdeps/nptl/mod.rs b/src/new/glibc/sysdeps/nptl/mod.rs index 92b8e9a22df45..6ea74cd9412e2 100644 --- a/src/new/glibc/sysdeps/nptl/mod.rs +++ b/src/new/glibc/sysdeps/nptl/mod.rs @@ -2,7 +2,7 @@ //! //! Native POSIX threading library. //! -//! +//! pub(crate) mod bits { #[cfg_attr( diff --git a/src/new/glibc/sysdeps/nptl/pthread.rs b/src/new/glibc/sysdeps/nptl/pthread.rs index cefc9e3002a41..0d094945c98ea 100644 --- a/src/new/glibc/sysdeps/nptl/pthread.rs +++ b/src/new/glibc/sysdeps/nptl/pthread.rs @@ -1,6 +1,6 @@ //! Source header: `sysdeps/nptl/pthread.h` //! -//! +//! use super::bits::struct_mutex::*; use crate::prelude::*; @@ -28,6 +28,7 @@ pub use crate::new::common::linux_like::pthread::{ pthread_getaffinity_np, pthread_getattr_np, pthread_getname_np, + pthread_gettid_np, pthread_setaffinity_np, pthread_setname_np, }; diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs index 0ecee596c5b12..21dac17fc0b27 100644 --- a/src/new/glibc/sysdeps/unix/linux/mod.rs +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -1,6 +1,6 @@ //! Source directory: `sysdeps/unix/sysv/linux` (the `sysv` is flattened). //! -//! +//! /// Directory: `net/` /// diff --git a/src/new/glibc/sysdeps/unix/linux/net/route.rs b/src/new/glibc/sysdeps/unix/linux/net/route.rs index 2851451652df0..1da2b47ebbb4a 100644 --- a/src/new/glibc/sysdeps/unix/linux/net/route.rs +++ b/src/new/glibc/sysdeps/unix/linux/net/route.rs @@ -1,7 +1,7 @@ //! Header: `net/route.h` //! //! Source header: `sysdeps/unix/sysv/linux/net/route.h` -//! +//! use crate::prelude::*; diff --git a/src/new/glibc/sysdeps/unix/mod.rs b/src/new/glibc/sysdeps/unix/mod.rs index 55a895d4d0de2..a2159e0b7339e 100644 --- a/src/new/glibc/sysdeps/unix/mod.rs +++ b/src/new/glibc/sysdeps/unix/mod.rs @@ -1,6 +1,6 @@ //! Source directory: `sysdeps/unix/` //! -//! +//! #[cfg(target_os = "linux")] pub(crate) mod linux; diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index c4ae2da584345..d50523c12e82d 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -37,7 +37,7 @@ pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF; pub const CANXL_MIN_DLEN: usize = 1; pub const CANXL_MAX_DLEN: usize = 2048; -s! { +s_with_default! { #[repr(align(8))] pub struct can_frame { pub can_id: canid_t, @@ -54,7 +54,7 @@ pub const CANFD_BRS: c_int = 0x01; pub const CANFD_ESI: c_int = 0x02; pub const CANFD_FDF: c_int = 0x04; -s! { +s_with_default! { #[repr(align(8))] pub struct canfd_frame { pub can_id: canid_t, @@ -62,6 +62,7 @@ s! { pub flags: u8, __res0: u8, __res1: u8, + #[custom_default([0; CANFD_MAX_DLEN])] pub data: [u8; CANFD_MAX_DLEN], } } @@ -69,13 +70,14 @@ s! { pub const CANXL_XLF: c_int = 0x80; pub const CANXL_SEC: c_int = 0x01; -s! { +s_with_default! { pub struct canxl_frame { pub prio: canid_t, pub flags: u8, pub sdt: u8, pub len: u16, pub af: u32, + #[custom_default([0; CANXL_MAX_DLEN])] pub data: [u8; CANXL_MAX_DLEN], } } @@ -101,10 +103,11 @@ pub const CAN_NPROTO: c_int = 8; pub const SOL_CAN_BASE: c_int = 100; -s_no_extra_traits! { +s_no_extra_traits_with_default! { pub struct sockaddr_can { pub can_family: crate::sa_family_t, pub can_ifindex: c_int, + #[custom_default(unsafe { mem::zeroed::<__c_anonymous_sockaddr_can_can_addr>() })] pub can_addr: __c_anonymous_sockaddr_can_can_addr, } diff --git a/src/new/linux_uapi/linux/netlink.rs b/src/new/linux_uapi/linux/netlink.rs index eb78ecac964d2..2e517dae1476d 100644 --- a/src/new/linux_uapi/linux/netlink.rs +++ b/src/new/linux_uapi/linux/netlink.rs @@ -67,6 +67,47 @@ pub const NLM_F_NONREC: c_int = 0x100; pub const NLM_F_CAPPED: c_int = 0x100; pub const NLM_F_ACK_TLVS: c_int = 0x200; +const NLMSG_ALIGNTO: c_uint = 4; + +const NLMSG_HDRLEN: c_int = NLMSG_ALIGN(size_of::()); + +f! { + pub const safe fn NLMSG_ALIGN(size: size_t) -> c_int { + ((size + NLMSG_ALIGNTO as size_t - 1) & !(NLMSG_ALIGNTO as size_t - 1)) as c_int + } + + pub const safe fn NLMSG_LENGTH(size: size_t) -> c_int { + size as c_int + NLMSG_HDRLEN + } + + pub const safe fn NLMSG_SPACE(size: size_t) -> c_int { + NLMSG_ALIGN(NLMSG_LENGTH(size) as size_t) + } + + pub unsafe fn NLMSG_DATA(nlh: *mut nlmsghdr) -> *mut c_void { + nlh.cast::() + .wrapping_add(NLMSG_HDRLEN as usize) + .cast::() + } + + pub unsafe fn NLMSG_NEXT(nlh: *mut nlmsghdr, size: &mut c_int) -> *mut nlmsghdr { + *size -= NLMSG_ALIGN((*nlh).nlmsg_len as size_t); + nlh.cast::() + .wrapping_add(NLMSG_ALIGN((*nlh).nlmsg_len as size_t) as usize) + .cast::() + } + + pub unsafe fn NLMSG_OK(nlh: *const nlmsghdr, size: c_int) -> bool { + size >= size_of::() as c_int + && (*nlh).nlmsg_len >= size_of::() as c_uint + && (*nlh).nlmsg_len <= size as c_uint + } + + pub unsafe fn NLMSG_PAYLOAD(nlh: *const nlmsghdr, size: c_int) -> c_int { + (*nlh).nlmsg_len as c_int - NLMSG_SPACE(size as size_t) + } +} + pub const NLMSG_NOOP: c_int = 0x1; pub const NLMSG_ERROR: c_int = 0x2; pub const NLMSG_DONE: c_int = 0x3; diff --git a/src/new/linux_uapi/linux/sctp.rs b/src/new/linux_uapi/linux/sctp.rs index 3a9ad6d19b5bb..5fe843c25d7b8 100644 --- a/src/new/linux_uapi/linux/sctp.rs +++ b/src/new/linux_uapi/linux/sctp.rs @@ -74,9 +74,7 @@ f! { *flags &= !SCTP_PR_SCTP_MASK; *flags |= policy; } -} -safe_f! { pub const safe fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool { policy == SCTP_PR_SCTP_TTL } diff --git a/src/new/mod.rs b/src/new/mod.rs index f4387e7aa9dac..13479209d23c9 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -198,6 +198,7 @@ cfg_if! { pub use net::route::*; } else if #[cfg(target_vendor = "apple")] { pub use net::bpf::*; + pub use netinet::tcp::*; pub use netinet6::in6_var::*; pub use pthread_::introspection::*; pub use pthread_::pthread_spis::*; @@ -227,6 +228,9 @@ cfg_if! { pub use net::if_::*; } else if #[cfg(target_os = "freebsd")] { pub use net::dlt::*; + // FIXME(1.0,remove): these bindings should be left in a public submodule. + pub use net::if_mib::*; + pub use net::route::*; pub use netinet6::in6_var::*; pub use sys::file::*; pub use sys::ioccom::*; diff --git a/src/new/musl/arch/generic/mod.rs b/src/new/musl/arch/generic/mod.rs index ac02505c882bf..a51a3dfa74933 100644 --- a/src/new/musl/arch/generic/mod.rs +++ b/src/new/musl/arch/generic/mod.rs @@ -1,6 +1,7 @@ //! Source directory: `arch/generic/` //! -//! +//! * Headers: (official) +//! * Headers: (mirror) pub(crate) mod bits { // Currently unused diff --git a/src/new/musl/arch/mips/mod.rs b/src/new/musl/arch/mips/mod.rs index 2f02036d254ce..ce546c654a611 100644 --- a/src/new/musl/arch/mips/mod.rs +++ b/src/new/musl/arch/mips/mod.rs @@ -1,6 +1,7 @@ //! Source directory: `arch/mips/` //! -//! +//! * Headers: (official) +//! * Headers: (mirror) pub(crate) mod bits { pub(crate) mod socket; diff --git a/src/new/musl/arch/mips64/mod.rs b/src/new/musl/arch/mips64/mod.rs index 6a45b067b998e..0e01c9742c412 100644 --- a/src/new/musl/arch/mips64/mod.rs +++ b/src/new/musl/arch/mips64/mod.rs @@ -1,6 +1,7 @@ //! Source directory: `arch/mips64/` //! -//! +//! * Headers: (official) +//! * Headers: (mirror) pub(crate) mod bits { pub(crate) mod socket; diff --git a/src/new/musl/arch/mod.rs b/src/new/musl/arch/mod.rs index 514d7b4bdfea7..d4a717895a176 100644 --- a/src/new/musl/arch/mod.rs +++ b/src/new/musl/arch/mod.rs @@ -1,6 +1,7 @@ //! Source directory: `arch/` //! -//! +//! * Headers: (official) +//! * Headers: (mirror) pub(crate) mod generic; diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs index a6551c342da67..9edb38255422b 100644 --- a/src/new/musl/mod.rs +++ b/src/new/musl/mod.rs @@ -24,7 +24,8 @@ pub(crate) mod pthread; /// Directory: `sys/` /// -/// +/// * Headers: (official) +/// * Headers: (mirror) pub(crate) mod sys { pub(crate) mod socket; } diff --git a/src/new/musl/pthread.rs b/src/new/musl/pthread.rs index 0d578bc9665dc..1190a92120cc9 100644 --- a/src/new/musl/pthread.rs +++ b/src/new/musl/pthread.rs @@ -1,6 +1,7 @@ //! Header: `pthread.h` //! -//! +//! * Headers: (official) +//! * Headers: (mirror) pub use crate::new::common::linux_like::pthread::{ pthread_getaffinity_np, diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs index 7d3f495955458..8083ddc2a7dc4 100644 --- a/src/new/musl/sys/socket.rs +++ b/src/new/musl/sys/socket.rs @@ -1,6 +1,7 @@ //! Header: `sys/socket.h` //! -//! +//! * Headers: (official) +//! * Headers: (mirror) use crate::prelude::*; diff --git a/src/new/netbsd/net/if_.rs b/src/new/netbsd/net/if_.rs index 68f2d91626903..3a47f0319219f 100644 --- a/src/new/netbsd/net/if_.rs +++ b/src/new/netbsd/net/if_.rs @@ -50,7 +50,7 @@ pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast s! { - #[repr(C, align(8))] + #[repr(align(8))] pub struct if_msghdr { pub ifm_msglen: c_ushort, pub ifm_version: c_uchar, diff --git a/src/new/netbsd/sys/mod.rs b/src/new/netbsd/sys/mod.rs index b7255d87b309d..11be69d6ad2e9 100644 --- a/src/new/netbsd/sys/mod.rs +++ b/src/new/netbsd/sys/mod.rs @@ -1,6 +1,6 @@ //! Directory: `sys/` //! -//! https://github.com/NetBSD/src/tree/trunk/sys/sys +//! pub(crate) mod file; pub(crate) mod ipc; diff --git a/src/new/openbsd/sys/mod.rs b/src/new/openbsd/sys/mod.rs index 7ba77c537356e..d72038e438781 100644 --- a/src/new/openbsd/sys/mod.rs +++ b/src/new/openbsd/sys/mod.rs @@ -1,5 +1,5 @@ //! Directory: `sys/` //! -//! https://github.com/openbsd/src/tree/trunk/sys/sys +//! pub(crate) mod ipc; diff --git a/src/new/redox/mod.rs b/src/new/redox/mod.rs index cf7806a2437ad..32cd7e72ac32c 100644 --- a/src/new/redox/mod.rs +++ b/src/new/redox/mod.rs @@ -1,3 +1,4 @@ //! Redox libc. //! -//! * Headers: +//! * Headers: (official) +//! * Headers: (mirror) diff --git a/src/new/relibc/mod.rs b/src/new/relibc/mod.rs index d2449123218a1..ec16241025316 100644 --- a/src/new/relibc/mod.rs +++ b/src/new/relibc/mod.rs @@ -1,5 +1,6 @@ //! Redox OS libc. //! -//! * Headers: +//! * Headers: (official) +//! * Headers: (mirror) pub(crate) mod unistd; diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index daf4cf31fd1e8..7605764ab08e2 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -1337,8 +1337,7 @@ pub fn errno() -> c_int { pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; let size_of_mask = size_of_val(&cpuset.bits[0]); - - for i in cpuset.bits[..(size / size_of_mask)].iter() { + for i in &cpuset.bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 6f5a02a284e83..a7c2d6e275502 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2516,9 +2516,7 @@ f! { let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } -} -safe_f! { pub const safe fn WIFSTOPPED(status: c_int) -> bool { (status & _W_STOPPED) != 0 } diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index e71378cccf07e..d6016483a6c42 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -56,10 +56,6 @@ s_no_extra_traits! { } } -#[doc(hidden)] -#[deprecated(since = "0.2.55")] -pub const NET_RT_MAXID: c_int = 10; - pub const BIOCSETF: c_ulong = 0x80084267; pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index 359aa79780dde..a973f3db11ec3 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -49,10 +49,6 @@ s! { } } -#[doc(hidden)] -#[deprecated(since = "0.2.55")] -pub const NET_RT_MAXID: c_int = 11; - pub const BIOCSETF: c_ulong = 0x80104267; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index ab6736a5c0a51..6aed401bbb009 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1398,6 +1398,20 @@ s! { __ss_pad2: Padding<[u8; 112]>, } + // netinet/in.h: RFC 3678 multicast group membership requests. + #[repr(packed(4))] + pub struct group_req { + pub gr_interface: u32, + pub gr_group: crate::sockaddr_storage, + } + + #[repr(packed(4))] + pub struct group_source_req { + pub gsr_interface: u32, + pub gsr_group: crate::sockaddr_storage, + pub gsr_source: crate::sockaddr_storage, + } + pub struct utmpx { pub ut_user: [c_char; _UTX_USERSIZE], pub ut_id: [c_char; _UTX_IDSIZE], @@ -2438,7 +2452,7 @@ pub const F_GLOBAL_NOCACHE: c_int = 55; pub const F_NODIRECT: c_int = 62; pub const F_LOG2PHYS_EXT: c_int = 65; pub const F_BARRIERFSYNC: c_int = 85; -// See https://github.com/apple/darwin-xnu/blob/main/bsd/sys/fcntl.h +// See https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/fcntl.h pub const F_OFD_SETLK: c_int = 90; /* Acquire or release open file description lock */ pub const F_OFD_SETLKW: c_int = 91; /* (as F_OFD_SETLK but blocking if conflicting lock) */ pub const F_OFD_GETLK: c_int = 92; /* Examine OFD lock */ @@ -2800,6 +2814,14 @@ pub const IPPROTO_MAX: c_int = 256; /// last return value of *_input(), meaning "all job for this pkt is done". pub const IPPROTO_DONE: c_int = 257; +// RFC 3678 protocol-independent multicast +pub const MCAST_JOIN_GROUP: c_int = 80; +pub const MCAST_LEAVE_GROUP: c_int = 81; +pub const MCAST_JOIN_SOURCE_GROUP: c_int = 82; +pub const MCAST_LEAVE_SOURCE_GROUP: c_int = 83; +pub const MCAST_BLOCK_SOURCE: c_int = 84; +pub const MCAST_UNBLOCK_SOURCE: c_int = 85; + pub const AF_UNSPEC: c_int = 0; pub const AF_LOCAL: c_int = 1; pub const AF_UNIX: c_int = AF_LOCAL; @@ -3246,17 +3268,11 @@ pub const NOTE_LEASE_RELEASE: u32 = 0x00000400; pub const NOTE_EXIT: u32 = 0x80000000; pub const NOTE_FORK: u32 = 0x40000000; pub const NOTE_EXEC: u32 = 0x20000000; -#[doc(hidden)] -#[deprecated(since = "0.2.49", note = "Deprecated since MacOSX 10.9")] -pub const NOTE_REAP: u32 = 0x10000000; pub const NOTE_SIGNAL: u32 = 0x08000000; pub const NOTE_EXITSTATUS: u32 = 0x04000000; pub const NOTE_EXIT_DETAIL: u32 = 0x02000000; pub const NOTE_PDATAMASK: u32 = 0x000fffff; pub const NOTE_PCTRLMASK: u32 = 0xfff00000; -#[doc(hidden)] -#[deprecated(since = "0.2.49", note = "Deprecated since MacOSX 10.9")] -pub const NOTE_EXIT_REPARENTED: u32 = 0x00080000; pub const NOTE_EXIT_DETAIL_MASK: u32 = 0x00070000; pub const NOTE_EXIT_DECRYPTFAIL: u32 = 0x00010000; pub const NOTE_EXIT_MEMORY: u32 = 0x00020000; @@ -3464,12 +3480,6 @@ pub const KERN_KDSETRTCDEC: c_int = 15; pub const KERN_KDGETENTROPY: c_int = 16; pub const KERN_KDWRITETR: c_int = 17; pub const KERN_KDWRITEMAP: c_int = 18; -#[doc(hidden)] -#[deprecated(since = "0.2.49", note = "Removed in MacOSX 10.12")] -pub const KERN_KDENABLE_BG_TRACE: c_int = 19; -#[doc(hidden)] -#[deprecated(since = "0.2.49", note = "Removed in MacOSX 10.12")] -pub const KERN_KDDISABLE_BG_TRACE: c_int = 20; pub const KERN_KDREADCURTHRMAP: c_int = 21; pub const KERN_KDSET_TYPEFILTER: c_int = 22; pub const KERN_KDBUFWAIT: c_int = 23; @@ -4361,9 +4371,7 @@ f! { pub const unsafe fn VM_MAKE_TAG(id: u8) -> u32 { (id as u32) << 24u32 } -} -safe_f! { pub const safe fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } @@ -4399,16 +4407,6 @@ safe_f! { extern "C" { pub fn setgrent(); - #[doc(hidden)] - #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.5")] - #[cfg_attr(not(target_arch = "aarch64"), link_name = "daemon$1050")] - pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; - #[doc(hidden)] - #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.10")] - pub fn sem_destroy(sem: *mut sem_t) -> c_int; - #[doc(hidden)] - #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.10")] - pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; pub fn aio_read(aiocbp: *mut aiocb) -> c_int; pub fn aio_write(aiocbp: *mut aiocb) -> c_int; pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 773acc66f4373..cbe02efd58ae9 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1266,22 +1266,18 @@ f! { pub unsafe fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); cpuset.ary[idx] |= 1 << offset; - () } pub unsafe fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); cpuset.ary[idx] &= !(1 << offset); - () } pub unsafe fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); 0 != cpuset.ary[idx] & (1 << offset) } -} -safe_f! { pub const safe fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 1bf913bc533d9..91fb88d1b0605 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -271,7 +271,7 @@ pub const MINCORE_SUPER: c_int = 0x20; /// max length of devicename pub const SPECNAMELEN: c_int = 63; -safe_f! { +f! { pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 8fd49615df38c..eebf3cba8bde5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -317,7 +317,7 @@ pub const KI_NSPARE_PTR: usize = 6; pub const MINCORE_SUPER: c_int = 0x20; -safe_f! { +f! { pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 2858cbfe755df..39c01538701b6 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -339,7 +339,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x20; -safe_f! { +f! { pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 12beb34e4e6cd..a84c185488ca3 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -341,7 +341,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x60; -safe_f! { +f! { pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 92c263f487834..08f9e5e43e6b5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -343,7 +343,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x60; -safe_f! { +f! { pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 0d1491bcf9a61..eb4951ffc7e6b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -280,12 +280,24 @@ s! { pub ip6: *mut crate::in6_addr, } + // netinet/in.h: RFC 3678 multicast group membership requests pub struct ip_mreq_source { pub imr_multiaddr: crate::in_addr, pub imr_sourceaddr: crate::in_addr, pub imr_interface: crate::in_addr, } + pub struct group_req { + pub gr_interface: u32, + pub gr_group: crate::sockaddr_storage, + } + + pub struct group_source_req { + pub gsr_interface: u32, + pub gsr_group: crate::sockaddr_storage, + pub gsr_source: crate::sockaddr_storage, + } + pub struct statvfs { pub f_bavail: crate::fsblkcnt_t, pub f_bfree: crate::fsblkcnt_t, @@ -2278,12 +2290,6 @@ pub const NOTE_ABSTIME: u32 = 0x00000010; pub const MADV_PROTECT: c_int = 10; -#[doc(hidden)] -#[deprecated( - since = "0.2.72", - note = "CTL_UNSPEC is deprecated. Use CTL_SYSCTL instead" -)] -pub const CTL_UNSPEC: c_int = 0; pub const CTL_SYSCTL: c_int = 0; pub const CTL_KERN: c_int = 1; pub const CTL_VM: c_int = 2; @@ -2751,13 +2757,6 @@ pub const IFF_POINTOPOINT: c_int = 0x10; pub const IFF_KNOWSEPOCH: c_int = 0x20; /// (d) resources allocated pub const IFF_RUNNING: c_int = 0x40; -#[doc(hidden)] -#[deprecated( - since = "0.2.54", - note = "IFF_DRV_RUNNING is deprecated. Use the portable IFF_RUNNING instead" -)] -/// (d) resources allocate -pub const IFF_DRV_RUNNING: c_int = 0x40; /// (n) no address resolution protocol pub const IFF_NOARP: c_int = 0x80; /// (n) receive all packets @@ -2766,10 +2765,6 @@ pub const IFF_PROMISC: c_int = 0x100; pub const IFF_ALLMULTI: c_int = 0x200; /// (d) tx hardware queue is full pub const IFF_OACTIVE: c_int = 0x400; -#[doc(hidden)] -#[deprecated(since = "0.2.54", note = "Use the portable `IFF_OACTIVE` instead")] -/// (d) tx hardware queue is full -pub const IFF_DRV_OACTIVE: c_int = 0x400; /// (i) can't hear own transmissions pub const IFF_SIMPLEX: c_int = 0x800; /// per link layer defined bit @@ -2908,51 +2903,6 @@ pub const IFDR_MSG_SIZE: c_int = 64; pub const IFDR_REASON_MSG: c_int = 1; pub const IFDR_REASON_VENDOR: c_int = 2; -// sys/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; - -/// 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; -/// driver name and unit -pub const IFDATA_DRIVERNAME: c_int = 3; - -/// 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; - -pub const dot3ChipSetAMD7990: c_int = 1; -pub const dot3ChipSetAMD79900: c_int = 2; -pub const dot3ChipSetAMD79C940: c_int = 3; - -pub const dot3ChipSetIntel82586: c_int = 1; -pub const dot3ChipSetIntel82596: c_int = 2; -pub const dot3ChipSetIntel82557: c_int = 3; - -pub const dot3ChipSetNational8390: c_int = 1; -pub const dot3ChipSetNationalSonic: c_int = 2; - -pub const dot3ChipSetFujitsu86950: c_int = 1; - -pub const dot3ChipSetDigitalDC21040: c_int = 1; -pub const dot3ChipSetDigitalDC21140: c_int = 2; -pub const dot3ChipSetDigitalDC21041: c_int = 3; -pub const dot3ChipSetDigitalDC21140A: c_int = 4; -pub const dot3ChipSetDigitalDC21142: c_int = 5; - -pub const dot3ChipSetWesternDigital83C690: c_int = 1; -pub const dot3ChipSetWesternDigital83C790: c_int = 2; - // sys/netinet/in.h // Protocols (RFC 1700) // NOTE: These are in addition to the constants defined in src/unix/mod.rs @@ -3019,12 +2969,6 @@ pub const IPPROTO_BLT: c_int = 30; pub const IPPROTO_NSP: c_int = 31; /// Merit Internodal pub const IPPROTO_INP: c_int = 32; -#[doc(hidden)] -#[deprecated( - since = "0.2.72", - note = "IPPROTO_SEP is deprecated. Use IPPROTO_DCCP instead" -)] -pub const IPPROTO_SEP: c_int = 33; /// Datagram Congestion Control Protocol pub const IPPROTO_DCCP: c_int = 33; /// Third Party Connect @@ -3198,6 +3142,14 @@ pub const IPPROTO_DIVERT: c_int = 258; /// SeND pseudo-protocol pub const IPPROTO_SEND: c_int = 259; +// RFC 3678 protocol-independent multicast +pub const MCAST_JOIN_GROUP: c_int = 80; +pub const MCAST_LEAVE_GROUP: c_int = 81; +pub const MCAST_JOIN_SOURCE_GROUP: c_int = 82; +pub const MCAST_LEAVE_SOURCE_GROUP: c_int = 83; +pub const MCAST_BLOCK_SOURCE: c_int = 84; +pub const MCAST_UNBLOCK_SOURCE: c_int = 85; + // sys/netinet/TCP.h pub const TCP_MD5SIG: c_int = 16; pub const TCP_INFO: c_int = 32; @@ -4517,19 +4469,19 @@ f! { } pub unsafe fn CPU_SET(cpu: usize, cpuset: &mut cpuset_t) -> () { - let bitset_bits = 8 * size_of::(); + let bitset_bits = 8 * size_of_val(&cpuset.__bits[0]); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] |= 1 << offset; } pub unsafe fn CPU_CLR(cpu: usize, cpuset: &mut cpuset_t) -> () { - let bitset_bits = 8 * size_of::(); + let bitset_bits = 8 * size_of_val(&cpuset.__bits[0]); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] &= !(1 << offset); } pub unsafe fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool { - let bitset_bits = 8 * size_of::(); + let bitset_bits = 8 * size_of_val(&cpuset.__bits[0]); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); 0 != cpuset.__bits[idx] & (1 << offset) } @@ -4537,9 +4489,8 @@ f! { pub unsafe fn CPU_COUNT(cpuset: &cpuset_t) -> c_int { let mut s: u32 = 0; let cpuset_size = size_of::(); - let bitset_size = size_of::(); - - for i in cpuset.__bits[..(cpuset_size / bitset_size)].iter() { + let bitset_size = size_of_val(&cpuset.__bits[0]); + for i in &cpuset.__bits[..(cpuset_size / bitset_size)] { s += i.count_ones(); } s as c_int @@ -4557,9 +4508,7 @@ f! { pub unsafe fn PROT_MAX_EXTRACT(x: c_int) -> c_int { (x >> 16) & (crate::PROT_READ | crate::PROT_WRITE | crate::PROT_EXEC) } -} -safe_f! { pub const safe fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 && status != 0x13 } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 5c9bccf38c60a..4e3b5372cd34c 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -995,18 +995,6 @@ pub const LOCK_NB: c_int = 4; pub const LOCK_UN: c_int = 8; pub const MAP_COPY: c_int = 0x0002; -#[doc(hidden)] -#[deprecated( - since = "0.2.54", - note = "Removed in FreeBSD 11, unused in DragonFlyBSD" -)] -pub const MAP_RENAME: c_int = 0x0020; -#[doc(hidden)] -#[deprecated( - since = "0.2.54", - note = "Removed in FreeBSD 11, unused in DragonFlyBSD" -)] -pub const MAP_NORESERVE: c_int = 0x0040; pub const MAP_HASSEMAPHORE: c_int = 0x0200; pub const MAP_STACK: c_int = 0x0400; pub const MAP_NOSYNC: c_int = 0x0800; @@ -1323,6 +1311,10 @@ pub const EUI64_LEN: usize = 8; // https://github.com/freebsd/freebsd/blob/HEAD/sys/net/bpf.h pub const BPF_ALIGNMENT: usize = SIZEOF_LONG; +pub const fn BPF_WORDALIGN(x: usize) -> usize { + (x + (BPF_ALIGNMENT - 1)) & !(BPF_ALIGNMENT - 1) +} + // Values for rtprio struct (prio field) and syscall (function argument) pub const RTP_PRIO_MIN: c_ushort = 0; pub const RTP_PRIO_MAX: c_ushort = 31; @@ -1447,7 +1439,7 @@ pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x08; pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; -safe_f! { +f! { pub const safe fn WIFCONTINUED(status: c_int) -> bool { status == 0x13 } diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index e0a39f2736556..a734ec4776a5a 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -500,9 +500,7 @@ f! { pub unsafe fn FD_ZERO(set: *mut fd_set) -> () { (*set).fds_bits.fill(0); } -} -safe_f! { pub const safe fn WTERMSIG(status: c_int) -> c_int { status & 0o177 } diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 43572ce590fdb..75e4008fc3328 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1859,9 +1859,7 @@ f! { pub unsafe fn PROT_MPROTECT_EXTRACT(x: c_int) -> c_int { (x >> 3) & 0x7 } -} -safe_f! { pub const safe fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 5a69b0ef35d2a..8b35121af917a 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1872,9 +1872,7 @@ f! { pub const unsafe fn CMSG_SPACE(length: c_uint) -> c_uint { (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint } -} -safe_f! { pub const safe fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index bfe1d8ff40529..5645bdd2b2dcf 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1710,7 +1710,7 @@ f! { pub unsafe fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; let size_of_mask = size_of_val(&cpuset.bits[0]); - for i in cpuset.bits[..(size / size_of_mask)].iter() { + for i in &cpuset.bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int @@ -1783,9 +1783,7 @@ f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { cmsg.offset(1).cast_mut().cast() } -} -safe_f! { pub const safe fn makedev(ma: c_uint, mi: c_uint) -> dev_t { let ma = ma as dev_t; let mi = mi as dev_t; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 011fa9f9ad072..72be53de152fa 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -368,12 +368,6 @@ s! { sa_userdata: *mut c_void, } - pub struct sem_t { - pub type_: i32, - pub named_sem_id: i32, // actually a union with unnamed_sem (i32) - padding: Padding<[i32; 2]>, - } - pub struct ucred { pub pid: crate::pid_t, pub uid: crate::uid_t, @@ -499,6 +493,19 @@ s! { } } +s_no_extra_traits! { + pub struct sem_t { + pub type_: i32, + pub named_sem_id: __c_anonymous_sem_t_u, + padding: Padding<[i32; 2]>, + } + + pub union __c_anonymous_sem_t_u { + pub named_sem_id: i32, + pub unnamed_sem: i32, + } +} + pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; pub const RAND_MAX: c_int = 2147483647; @@ -1444,9 +1451,7 @@ f! { pub unsafe fn FD_ZERO(set: *mut fd_set) -> () { (*set).fds_bits.fill(0); } -} -safe_f! { pub const safe fn WIFEXITED(status: c_int) -> bool { (status & !0xff) == 0 } diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index bc0cd5e15bd57..3700d9e71d6e1 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -650,7 +650,7 @@ pub const B_DIRECTORY_NODE: u32 = 0x04; pub const B_ANY_NODE: u32 = 0x07; // support/Errors.h -pub const B_GENERAL_ERROR_BASE: status_t = core::i32::MIN; +pub const B_GENERAL_ERROR_BASE: status_t = i32::MIN; pub const B_OS_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x1000; pub const B_APP_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x2000; pub const B_INTERFACE_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x3000; diff --git a/src/unix/hurd/b32.rs b/src/unix/hurd/b32.rs index e706789006dba..e56df6d6bf066 100644 --- a/src/unix/hurd/b32.rs +++ b/src/unix/hurd/b32.rs @@ -15,14 +15,14 @@ pub type __u_quad_t = c_ulonglong; pub type __intmax_t = c_longlong; pub type __uintmax_t = c_ulonglong; -pub type __squad_type = crate::__int64_t; -pub type __uquad_type = crate::__uint64_t; +pub type __squad_type = __int64_t; +pub type __uquad_type = __uint64_t; pub type __sword_type = c_int; pub type __uword_type = c_uint; pub type __slong32_type = c_long; pub type __ulong32_type = c_ulong; -pub type __s64_type = crate::__int64_t; -pub type __u64_type = crate::__uint64_t; +pub type __s64_type = __int64_t; +pub type __u64_type = __uint64_t; pub type __ipc_pid_t = c_ushort; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 1cc87eb268fa2..d3d1792135eae 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -77,7 +77,16 @@ pub type wchar_t = c_int; pub type wint_t = c_uint; pub type gid_t = __gid_t; pub type uid_t = __uid_t; -pub type off_t = __off_t; + +cfg_if! { + if #[cfg(any(target_pointer_width = "64", gnu_file_offset_bits64))] { + pub type off_t = __off64_t; + } else { + pub type off_t = __off_t; + } +} + +// FIXME(1.0,deprecate,64): lfs binding to be removed pub type off64_t = __off64_t; pub type useconds_t = __useconds_t; pub type pid_t = __pid_t; @@ -101,7 +110,16 @@ pub type quad_t = __quad_t; pub type u_quad_t = __u_quad_t; pub type fsid_t = __fsid_t; pub type loff_t = __loff_t; -pub type ino_t = __ino_t; + +cfg_if! { + if #[cfg(any(target_pointer_width = "64", gnu_file_offset_bits64))] { + pub type ino_t = __ino64_t; + } else { + pub type ino_t = __ino_t; + } +} + +// FIXME(1.0,deprecate,64): lfs binding to be removed pub type ino64_t = __ino64_t; pub type dev_t = __dev_t; pub type mode_t = __mode_t; @@ -129,11 +147,24 @@ pub type sigset_t = __sigset_t; pub type __fd_mask = c_long; pub type fd_mask = __fd_mask; pub type blksize_t = __blksize_t; -pub type blkcnt_t = __blkcnt_t; -pub type fsblkcnt_t = __fsblkcnt_t; -pub type fsfilcnt_t = __fsfilcnt_t; + +cfg_if! { + if #[cfg(any(target_pointer_width = "64", gnu_file_offset_bits64))] { + pub type blkcnt_t = __blkcnt64_t; + pub type fsblkcnt_t = __fsblkcnt64_t; + pub type fsfilcnt_t = __fsfilcnt64_t; + } else { + pub type blkcnt_t = __blkcnt_t; + pub type fsblkcnt_t = __fsblkcnt_t; + pub type fsfilcnt_t = __fsfilcnt_t; + } +} + +// FIXME(1.0,deprecate,64): lfs binding to be removed pub type blkcnt64_t = __blkcnt64_t; +// FIXME(1.0,deprecate,64): lfs binding to be removed pub type fsblkcnt64_t = __fsblkcnt64_t; +// FIXME(1.0,deprecate,64): lfs binding to be removed pub type fsfilcnt64_t = __fsfilcnt64_t; pub type __pthread_spinlock_t = c_int; @@ -164,7 +195,16 @@ pub type pthread_once_t = __pthread_once; pub type __rlimit_resource = c_uint; pub type __rlimit_resource_t = __rlimit_resource; -pub type rlim_t = __rlim_t; + +cfg_if! { + if #[cfg(any(target_pointer_width = "64", gnu_file_offset_bits64))] { + pub type rlim_t = __rlim64_t; + } else { + pub type rlim_t = __rlim_t; + } +} + +// FIXME(1.0,deprecate,64): lfs binding to be removed pub type rlim64_t = __rlim64_t; pub type __rusage_who = c_int; @@ -226,6 +266,7 @@ pub type nl_item = c_int; pub type iconv_t = *mut c_void; extern_ty! { + // FIXME(1.0,deprecate,64): lfs binding to be removed pub type fpos64_t; // FIXME(hurd): fill this out with a struct pub type timezone; } @@ -350,13 +391,14 @@ s! { } pub struct dirent { - pub d_ino: __ino_t, + pub d_ino: ino_t, pub d_reclen: c_ushort, pub d_type: c_uchar, pub d_namlen: c_uchar, pub d_name: [c_char; 1usize], } + // FIXME(1.0,deprecate,64): lfs binding to be removed pub struct dirent64 { pub d_ino: __ino64_t, pub d_reclen: c_ushort, @@ -449,24 +491,39 @@ s! { pub struct stat { pub st_fstype: c_int, pub st_dev: __fsid_t, /* Actually st_fsid */ - pub st_ino: __ino_t, + pub st_ino: ino_t, pub st_gen: c_uint, pub st_rdev: __dev_t, pub st_mode: __mode_t, pub st_nlink: __nlink_t, pub st_uid: __uid_t, pub st_gid: __gid_t, - pub st_size: __off_t, - pub st_atim: crate::timespec, - pub st_mtim: crate::timespec, - pub st_ctim: crate::timespec, + pub st_size: off_t, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, pub st_blksize: __blksize_t, - pub st_blocks: __blkcnt_t, + pub st_blocks: blkcnt_t, pub st_author: __uid_t, pub st_flags: c_uint, - pub st_spare: [c_int; 11usize], + st_spare: Padding< + [c_int; if cfg!(not(gnu_file_offset_bits64)) { + if size_of::<__fsid_t>() == size_of::() { + 12 + } else { + 11 + } + } else { + if size_of::<__fsid_t>() == size_of::() { + 9 + } else { + 8 + } + }], + >, } + // FIXME(1.0,deprecate,64): lfs binding to be removed pub struct stat64 { pub st_fstype: c_int, pub st_dev: __fsid_t, /* Actually st_fsid */ @@ -478,14 +535,20 @@ s! { pub st_uid: __uid_t, pub st_gid: __gid_t, pub st_size: __off64_t, - pub st_atim: crate::timespec, - pub st_mtim: crate::timespec, - pub st_ctim: crate::timespec, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, pub st_blksize: __blksize_t, pub st_blocks: __blkcnt64_t, pub st_author: __uid_t, pub st_flags: c_uint, - pub st_spare: [c_int; 8usize], + st_spare: Padding< + [c_int; if size_of::<__fsid_t>() == size_of::() { + 9 + } else { + 8 + }], + >, } pub struct statx { @@ -521,19 +584,20 @@ s! { pub struct statfs { pub f_type: c_uint, pub f_bsize: c_ulong, - pub f_blocks: __fsblkcnt_t, - pub f_bfree: __fsblkcnt_t, - pub f_bavail: __fsblkcnt_t, - pub f_files: __fsblkcnt_t, - pub f_ffree: __fsblkcnt_t, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsblkcnt_t, + pub f_ffree: fsblkcnt_t, pub f_fsid: __fsid_t, pub f_namelen: c_ulong, - pub f_favail: __fsfilcnt_t, + pub f_favail: fsfilcnt_t, pub f_frsize: c_ulong, pub f_flag: c_ulong, - pub f_spare: [c_uint; 3usize], + f_spare: Padding<[c_uint; 3usize]>, } + // FIXME(1.0,deprecate,64): lfs binding to be removed pub struct statfs64 { pub f_type: c_uint, pub f_bsize: c_ulong, @@ -547,25 +611,26 @@ s! { pub f_favail: __fsfilcnt64_t, pub f_frsize: c_ulong, pub f_flag: c_ulong, - pub f_spare: [c_uint; 3usize], + f_spare: Padding<[c_uint; 3usize]>, } pub struct statvfs { pub __f_type: c_uint, pub f_bsize: c_ulong, - pub f_blocks: __fsblkcnt_t, - pub f_bfree: __fsblkcnt_t, - pub f_bavail: __fsblkcnt_t, - pub f_files: __fsfilcnt_t, - pub f_ffree: __fsfilcnt_t, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsfilcnt_t, + pub f_ffree: fsfilcnt_t, pub f_fsid: __fsid_t, pub f_namemax: c_ulong, - pub f_favail: __fsfilcnt_t, + pub f_favail: fsfilcnt_t, pub f_frsize: c_ulong, pub f_flag: c_ulong, - pub f_spare: [c_uint; 3usize], + f_spare: Padding<[c_uint; 3usize]>, } + // FIXME(1.0,deprecate,64): lfs binding to be removed pub struct statvfs64 { pub __f_type: c_uint, pub f_bsize: c_ulong, @@ -579,7 +644,7 @@ s! { pub f_favail: __fsfilcnt64_t, pub f_frsize: c_ulong, pub f_flag: c_ulong, - pub f_spare: [c_uint; 3usize], + f_spare: Padding<[c_uint; 3usize]>, } pub struct aiocb { @@ -628,6 +693,7 @@ s! { pub __pshared: __pthread_process_shared, pub __mutex_type: __pthread_mutex_type, } + pub struct __pthread_mutex { pub __lock: c_uint, pub __owner_id: c_uint, @@ -866,6 +932,7 @@ s! { pub domainname: [c_char; _UTSNAME_LENGTH], } + // FIXME(1.0,deprecate,64): lfs binding to be removed pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, @@ -893,25 +960,30 @@ s! { pub l_type: c_int, #[cfg(target_pointer_width = "32")] pub l_whence: c_int, + #[cfg(target_pointer_width = "64")] pub l_type: c_short, #[cfg(target_pointer_width = "64")] pub l_whence: c_short, - pub l_start: __off_t, - pub l_len: __off_t, + + pub l_start: off_t, + pub l_len: off_t, pub l_pid: __pid_t, } + // FIXME(1.0,deprecate,64): lfs binding to be removed pub struct flock64 { #[cfg(target_pointer_width = "32")] pub l_type: c_int, #[cfg(target_pointer_width = "32")] pub l_whence: c_int, + #[cfg(target_pointer_width = "64")] pub l_type: c_short, #[cfg(target_pointer_width = "64")] pub l_whence: c_short, - pub l_start: __off_t, + + pub l_start: __off64_t, pub l_len: __off64_t, pub l_pid: __pid_t, } @@ -929,6 +1001,10 @@ s! { __unused5: Padding<*mut c_void>, } + #[deprecated( + since = "0.2.187", + note = "Use `glob_t` instead. The definitions are equivalent." + )] pub struct glob64_t { pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, @@ -954,10 +1030,7 @@ s! { } pub struct cpu_set_t { - #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] - bits: [u32; 32], - #[cfg(not(all(target_pointer_width = "32", not(target_arch = "x86_64"))))] - bits: [u64; 16], + __bits: [__cpu_mask; __CPU_SETSIZE / __NCPUBITS], } pub struct if_nameindex { @@ -1068,6 +1141,23 @@ impl siginfo_t { } } +s_no_extra_traits! { + pub struct fpos_t { + __pos: off_t, + __state: __mbstate_t, + } + + struct __mbstate_t { + __count: c_int, + __value: __c_anonymous___mbstate_t___value, + } + + union __c_anonymous___mbstate_t___value { + __wch: c_int, + __wchb: [c_char; 4], + } +} + // const // aio.h @@ -1189,10 +1279,18 @@ pub const __PTHREAD_SPIN_LOCK_INITIALIZER: c_int = 0; pub const PTHREAD_MUTEX_NORMAL: c_int = 0; // sys/resource.h -pub const RLIM_INFINITY: crate::rlim_t = 2147483647; -pub const RLIM64_INFINITY: crate::rlim64_t = 9223372036854775807; -pub const RLIM_SAVED_MAX: crate::rlim_t = RLIM_INFINITY; -pub const RLIM_SAVED_CUR: crate::rlim_t = RLIM_INFINITY; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const RLIM_INFINITY: rlim64_t = 0x7fffffffffffffff; + } else { + pub const RLIM_INFINITY: rlim_t = -1_isize as rlim_t; + } +} + +// FIXME(1.0,deprecate,64): lfs binding to be removed +pub const RLIM64_INFINITY: rlim64_t = 0x7fffffffffffffff; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; pub const PRIO_MIN: c_int = -20; pub const PRIO_MAX: c_int = 20; @@ -2481,6 +2579,7 @@ pub const SCHED_FIFO: c_int = 1; pub const SCHED_RR: c_int = 2; pub const _BITS_TYPES_STRUCT_SCHED_PARAM: usize = 1; pub const __CPU_SETSIZE: usize = 1024; +pub const __NCPUBITS: usize = __cpu_mask::BITS as usize; pub const CPU_SETSIZE: usize = 1024; // pthread.h @@ -3416,36 +3515,36 @@ f! { pub unsafe fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = mem::zeroed(); - let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.__bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } pub unsafe fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - cpuset.bits.fill(0); + cpuset.__bits.fill(0); } pub unsafe fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - cpuset.bits[idx] |= 1 << offset; + cpuset.__bits[idx] |= 1 << offset; } pub unsafe fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - cpuset.bits[idx] &= !(1 << offset); + cpuset.__bits[idx] &= !(1 << offset); } pub unsafe fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - 0 != (cpuset.bits[idx] & (1 << offset)) + 0 != (cpuset.__bits[idx] & (1 << offset)) } pub unsafe fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = size_of_val(&cpuset.bits[0]); - for i in cpuset.bits[..(size / size_of_mask)].iter() { + let size_of_mask = size_of_val(&cpuset.__bits[0]); + for i in &cpuset.__bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int @@ -3456,7 +3555,7 @@ f! { } pub unsafe fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { - set1.bits == set2.bits + set1.__bits == set2.__bits } pub unsafe fn IPTOS_TOS(tos: u8) -> u8 { @@ -3490,6 +3589,91 @@ f! { pub unsafe fn FD_ZERO(set: *mut fd_set) -> () { (*set).fds_bits.fill(0); } + + pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= major << 8; + dev |= minor; + dev + } + + pub const safe fn major(dev: crate::dev_t) -> c_uint { + ((dev >> 8) & 0xff) as c_uint + } + + pub const safe fn minor(dev: crate::dev_t) -> c_uint { + (dev & 0xffff00ff) as c_uint + } + + pub safe fn SIGRTMAX() -> c_int { + unsafe { __libc_current_sigrtmax() } + } + + pub safe fn SIGRTMIN() -> c_int { + unsafe { __libc_current_sigrtmin() } + } + + pub const safe fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub const safe fn WSTOPSIG(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const safe fn WIFCONTINUED(status: c_int) -> bool { + status == 0xffff + } + + pub const safe fn WIFSIGNALED(status: c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub const safe fn WTERMSIG(status: c_int) -> c_int { + status & 0x7f + } + + pub const safe fn WIFEXITED(status: c_int) -> bool { + (status & 0x7f) == 0 + } + + pub const safe fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const safe fn WCOREDUMP(status: c_int) -> bool { + (status & 0x80) != 0 + } + + pub const safe fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { + (ret << 8) | sig + } + + pub const safe fn W_STOPCODE(sig: c_int) -> c_int { + (sig << 8) | 0x7f + } + + pub const safe fn QCMD(cmd: c_int, type_: c_int) -> c_int { + (cmd << 8) | (type_ & 0x00ff) + } + + pub const safe fn IPOPT_COPIED(o: u8) -> u8 { + o & IPOPT_COPY + } + + pub const safe fn IPOPT_CLASS(o: u8) -> u8 { + o & IPOPT_CLASS_MASK + } + + pub const safe fn IPOPT_NUMBER(o: u8) -> u8 { + o & IPOPT_NUMBER_MASK + } + + pub const safe fn IPTOS_ECN(x: u8) -> u8 { + x & crate::IPTOS_ECN_MASK + } } extern "C" { @@ -3545,27 +3729,33 @@ extern "C" { pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; + // FIXME(1.0,deprecate,64): 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 readv(__fd: c_int, __iovec: *const crate::iovec, __count: c_int) -> ssize_t; pub fn writev(__fd: c_int, __iovec: *const crate::iovec, __count: c_int) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64")] pub fn preadv( __fd: c_int, __iovec: *const crate::iovec, __count: c_int, - __offset: __off_t, + __offset: off_t, ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64")] pub fn pwritev( __fd: c_int, __iovec: *const crate::iovec, __count: c_int, - __offset: __off_t, + __offset: off_t, ) -> ssize_t; + // FIXME(1.0,deprecate,64): 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,64): lfs binding to be removed pub fn pwritev64( fd: c_int, iov: *const crate::iovec, @@ -3634,13 +3824,18 @@ extern "C" { oldattr: *mut crate::mq_attr, ) -> c_int; - pub fn lseek64(__fd: c_int, __offset: __off64_t, __whence: c_int) -> __off64_t; - - pub fn lseek(__fd: c_int, __offset: __off_t, __whence: c_int) -> __off_t; + // FIXME(1.0,deprecate,64): lfs binding to be removed + pub fn lseek64(__fd: c_int, __offset: off64_t, __whence: c_int) -> off64_t; + // FIXME(1.0,deprecate,64): lfs binding to be removed + #[allow(clashing_extern_declarations)] pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fseeko64(stream: *mut crate::FILE, offset: off64_t, whence: c_int) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed + #[allow(clashing_extern_declarations)] pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const fpos64_t) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn ftello64(stream: *mut crate::FILE) -> off64_t; pub fn bind(__fd: c_int, __addr: *const sockaddr, __len: crate::socklen_t) -> c_int; @@ -3672,7 +3867,9 @@ extern "C" { addrlen: *mut crate::socklen_t, ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "sendfile64")] pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t; + // FIXME(1.0,deprecate,64): 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 shutdown(__fd: c_int, __how: c_int) -> c_int; @@ -4013,10 +4210,10 @@ extern "C" { old_value: *mut crate::itimerspec, ) -> c_int; - pub fn fstat(__fd: c_int, __buf: *mut stat) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fstat64(__fd: c_int, __buf: *mut stat64) -> c_int; - pub fn fstatat(__fd: c_int, __file: *const c_char, __buf: *mut stat, __flag: c_int) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fstatat64( __fd: c_int, __file: *const c_char, @@ -4032,41 +4229,50 @@ extern "C" { statxbuf: *mut statx, ) -> c_int; - pub fn ftruncate(__fd: c_int, __length: __off_t) -> c_int; - pub fn ftruncate64(__fd: c_int, __length: __off64_t) -> c_int; - pub fn truncate64(__file: *const c_char, __length: __off64_t) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed + pub fn ftruncate64(__fd: c_int, __length: off64_t) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed + pub fn truncate64(__file: *const c_char, __length: off64_t) -> c_int; - pub fn lstat(__file: *const c_char, __buf: *mut stat) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn lstat64(__file: *const c_char, __buf: *mut stat64) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "statfs64")] 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(__file: *const c_char, __buf: *mut statfs64) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatfs64")] pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fstatfs64(__fildes: c_int, __buf: *mut statfs64) -> c_int; - pub fn statvfs(__file: *const c_char, __buf: *mut statvfs) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn statvfs64(__file: *const c_char, __buf: *mut statvfs64) -> c_int; - pub fn fstatvfs(__fildes: c_int, __buf: *mut statvfs) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fstatvfs64(__fildes: c_int, __buf: *mut statvfs64) -> c_int; - pub fn open(__file: *const c_char, __oflag: c_int, ...) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn open64(__file: *const c_char, __oflag: c_int, ...) -> c_int; - pub fn openat(__fd: c_int, __file: *const c_char, __oflag: c_int, ...) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn openat64(__fd: c_int, __file: *const c_char, __oflag: c_int, ...) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE; + // FIXME(1.0,deprecate,64): 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,64): lfs binding to be removed pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn tmpfile64() -> *mut crate::FILE; pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; @@ -4221,20 +4427,16 @@ extern "C" { pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; - pub fn stat(__file: *const c_char, __buf: *mut stat) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn stat64(__file: *const c_char, __buf: *mut stat64) -> c_int; - pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; - pub fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64; - pub fn readdir_r( - dirp: *mut crate::DIR, - entry: *mut crate::dirent, - result: *mut *mut crate::dirent, - ) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed + pub fn readdir64(dirp: *mut crate::DIR) -> *mut dirent64; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn readdir64_r( dirp: *mut crate::DIR, - entry: *mut crate::dirent64, - result: *mut *mut crate::dirent64, + entry: *mut dirent64, + result: *mut *mut dirent64, ) -> c_int; pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); pub fn telldir(dirp: *mut crate::DIR) -> c_long; @@ -4246,13 +4448,14 @@ extern "C" { pub fn __errno_location() -> *mut c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn mmap64( __addr: *mut c_void, __len: size_t, __prot: c_int, __flags: c_int, __fd: c_int, - __offset: __off64_t, + __offset: off64_t, ) -> *mut c_void; pub fn mremap( @@ -4270,23 +4473,31 @@ extern "C" { pub fn syncfs(fd: c_int) -> c_int; pub fn fdatasync(fd: c_int) -> c_int; + #[deprecated(since = "0.2.187", note = "This routine doesn't exist upstream.")] pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fallocate64")] pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fadvise64")] pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + // FIXME(1.0,deprecate,64): 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 madvise(__addr: *mut c_void, __len: size_t, __advice: c_int) -> c_int; pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; - pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; - pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; - pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; - pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) - -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "getrlimit64")] + pub fn getrlimit(resource: __rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed + pub fn getrlimit64(resource: __rlimit_resource_t, rlim: *mut rlimit64) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "setrlimit64")] + pub fn setrlimit(resource: __rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed + pub fn setrlimit64(resource: __rlimit_resource_t, rlim: *const rlimit64) -> c_int; pub fn getpriority(which: crate::__priority_which, who: crate::id_t) -> c_int; pub fn setpriority(which: crate::__priority_which, who: crate::id_t, prio: c_int) -> c_int; @@ -4379,20 +4590,48 @@ extern "C" { pub fn regfree(preg: *mut crate::regex_t); + #[cfg_attr( + all(gnu_file_offset_bits64, gnu_time_bits64), + link_name = "__glob64_time64" + )] + #[cfg_attr( + all(gnu_file_offset_bits64, not(gnu_time_bits64)), + link_name = "glob64" + )] pub fn glob( pattern: *const c_char, flags: c_int, errfunc: Option c_int>, - pglob: *mut crate::glob_t, + pglob: *mut glob_t, ) -> c_int; - pub fn globfree(pglob: *mut crate::glob_t); - + #[cfg_attr( + all(gnu_file_offset_bits64, gnu_time_bits64), + link_name = "__globfree64_time64" + )] + #[cfg_attr( + all(gnu_file_offset_bits64, not(gnu_time_bits64)), + link_name = "globfree64" + )] + pub fn globfree(pglob: *mut glob_t); + + #[cfg_attr(gnu_time_bits64, link_name = "__glob64_time64")] + #[deprecated( + since = "0.2.187", + note = "Use `glob` instead. Their definitions are equivalent." + )] + #[allow(deprecated)] pub fn glob64( pattern: *const c_char, flags: c_int, errfunc: Option c_int>, pglob: *mut glob64_t, ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__globfree64_time64")] + #[deprecated( + since = "0.2.187", + note = "Use `globfree` instead. Their definitions are equivalent." + )] + #[allow(deprecated)] pub fn globfree64(pglob: *mut glob64_t); pub fn getxattr( @@ -4480,93 +4719,6 @@ extern "C" { pub fn gnu_get_libc_version() -> *const c_char; } -safe_f! { - pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { - let major = major as crate::dev_t; - let minor = minor as crate::dev_t; - let mut dev = 0; - dev |= major << 8; - dev |= minor; - dev - } - - pub const safe fn major(dev: crate::dev_t) -> c_uint { - ((dev >> 8) & 0xff) as c_uint - } - - pub const safe fn minor(dev: crate::dev_t) -> c_uint { - (dev & 0xffff00ff) as c_uint - } - - pub safe fn SIGRTMAX() -> c_int { - unsafe { __libc_current_sigrtmax() } - } - - pub safe fn SIGRTMIN() -> c_int { - unsafe { __libc_current_sigrtmin() } - } - - pub const safe fn WIFSTOPPED(status: c_int) -> bool { - (status & 0xff) == 0x7f - } - - pub const safe fn WSTOPSIG(status: c_int) -> c_int { - (status >> 8) & 0xff - } - - pub const safe fn WIFCONTINUED(status: c_int) -> bool { - status == 0xffff - } - - pub const safe fn WIFSIGNALED(status: c_int) -> bool { - ((status & 0x7f) + 1) as i8 >= 2 - } - - pub const safe fn WTERMSIG(status: c_int) -> c_int { - status & 0x7f - } - - pub const safe fn WIFEXITED(status: c_int) -> bool { - (status & 0x7f) == 0 - } - - pub const safe fn WEXITSTATUS(status: c_int) -> c_int { - (status >> 8) & 0xff - } - - pub const safe fn WCOREDUMP(status: c_int) -> bool { - (status & 0x80) != 0 - } - - pub const safe fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { - (ret << 8) | sig - } - - pub const safe fn W_STOPCODE(sig: c_int) -> c_int { - (sig << 8) | 0x7f - } - - pub const safe fn QCMD(cmd: c_int, type_: c_int) -> c_int { - (cmd << 8) | (type_ & 0x00ff) - } - - pub const safe fn IPOPT_COPIED(o: u8) -> u8 { - o & IPOPT_COPY - } - - pub const safe fn IPOPT_CLASS(o: u8) -> u8 { - o & IPOPT_CLASS_MASK - } - - pub const safe fn IPOPT_NUMBER(o: u8) -> u8 { - o & IPOPT_NUMBER_MASK - } - - pub const safe fn IPTOS_ECN(x: u8) -> u8 { - x & crate::IPTOS_ECN_MASK - } -} - cfg_if! { if #[cfg(target_pointer_width = "64")] { mod b64; diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index e744c324e1594..056200313a33a 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -193,6 +193,7 @@ pub const SA_SIGINFO: c_int = 0x00000004; pub const RTLD_GLOBAL: c_int = 2; pub const RTLD_NOW: c_int = 0; pub const RTLD_DEFAULT: *mut c_void = -1isize as *mut c_void; +pub const RTLD_NEXT: *mut c_void = -2isize as *mut c_void; pub const PTRACE_GETFPREGS: c_int = 14; pub const PTRACE_SETFPREGS: c_int = 15; diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index baa285e0ff63c..553ffd522bdbb 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -208,12 +208,10 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -256,8 +254,7 @@ pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; pub const SYS_vm86: c_long = 166; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 167; +// 167 was SYS_query_module pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; pub const SYS_setresgid: c_long = 170; diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index f5a204d8fe61b..a1f7c393998da 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -152,6 +152,7 @@ pub const SA_SIGINFO: c_int = 0x00000004; pub const RTLD_GLOBAL: c_int = 0x00100; pub const RTLD_NOW: c_int = 2; pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); +pub const RTLD_NEXT: *mut c_void = -1isize as *mut c_void; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, 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 6fd06b00718db..de358edd5d41a 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -369,14 +369,11 @@ pub const SYS_sethostname: c_long = 170; pub const SYS_setdomainname: c_long = 171; pub const SYS_iopl: c_long = 172; pub const SYS_ioperm: c_long = 173; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 174; +// 174 was SYS_create_module pub const SYS_init_module: c_long = 175; pub const SYS_delete_module: c_long = 176; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 177; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 178; +// 177 was SYS_get_kernel_syms +// 178 was SYS_query_module pub const SYS_quotactl: c_long = 179; pub const SYS_nfsservctl: c_long = 180; pub const SYS_getpmsg: c_long = 181; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index a29476859ba7c..93c79428518a1 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -659,7 +659,7 @@ s_no_extra_traits! { // linux/if_ether.h - #[repr(C, packed)] + #[repr(packed)] pub struct ethhdr { pub h_dest: [c_uchar; crate::ETH_ALEN as usize], pub h_source: [c_uchar; crate::ETH_ALEN as usize], @@ -997,8 +997,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGTTIN: c_int = 21; pub const SIGTTOU: c_int = 22; pub const SIGXCPU: c_int = 24; @@ -1141,7 +1139,7 @@ pub const SOCK_DCCP: c_int = 6; #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub const SOCK_PACKET: c_int = 10; -pub const IPPROTO_MAX: c_int = 256; +pub const IPPROTO_MAX: c_int = 263; pub const SOL_SOCKET: c_int = 1; pub const SOL_SCTP: c_int = 132; @@ -1220,12 +1218,15 @@ pub const SO_DOMAIN: c_int = 39; pub const SO_RXQ_OVFL: c_int = 40; pub const SO_PEEK_OFF: c_int = 42; pub const SO_BUSY_POLL: c_int = 46; +pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51; +pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52; pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54; pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58; pub const SO_BINDTOIFINDEX: c_int = 62; pub const SO_TIMESTAMP_NEW: c_int = 63; pub const SO_TIMESTAMPNS_NEW: c_int = 64; pub const SO_TIMESTAMPING_NEW: c_int = 65; +pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; @@ -2641,12 +2642,6 @@ pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15; pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16; pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17; -#[deprecated( - since = "0.2.55", - note = "ENOATTR is not available on Android; use ENODATA instead" -)] -pub const ENOATTR: c_int = crate::ENODATA; - // linux/if_alg.h pub const ALG_SET_KEY: c_int = 1; pub const ALG_SET_IV: c_int = 2; @@ -3489,14 +3484,12 @@ f! { let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] |= 1 << offset; - () } pub unsafe fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] &= !(1 << offset); - () } pub unsafe fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { @@ -3508,7 +3501,7 @@ f! { pub unsafe fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; let size_of_mask = size_of_val(&cpuset.__bits[0]); - for i in cpuset.__bits[..(size / size_of_mask)].iter() { + for i in &cpuset.__bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int @@ -3529,9 +3522,7 @@ f! { pub unsafe fn SO_EE_OFFENDER(ee: *const crate::sock_extended_err) -> *mut crate::sockaddr { ee.offset(1) as *mut crate::sockaddr } -} -safe_f! { pub const safe fn makedev(ma: c_uint, mi: c_uint) -> crate::dev_t { let ma = ma as crate::dev_t; let mi = mi as crate::dev_t; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 7a28d89269f99..184e3958e3d03 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -954,10 +954,6 @@ pub const RLIM_NLIMITS: c_int = RLIMIT_NLIMITS; pub const MAP_ANONYMOUS: c_int = MAP_ANON; -#[doc(hidden)] -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = crate::SIGSYS; - pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; @@ -1284,14 +1280,12 @@ f! { let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; - () } pub unsafe fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); - () } pub unsafe fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { @@ -1303,9 +1297,7 @@ f! { pub unsafe fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { set1.bits == set2.bits } -} -safe_f! { pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index e897946489975..06add53ad9eae 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -284,6 +284,7 @@ s! { pub __wc: crate::wchar_t, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct fpos64_t { pub __pos: crate::off64_t, pub __mbstate: __mbstate_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 d05bccf3811ac..84503af35e23a 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -407,8 +407,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_SETMASK: c_int = 2; 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 dc88c635f1168..5a9ca13b2bc54 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -327,8 +327,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_SETMASK: c_int = 2; 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 2d91f986b76a0..323f7b56c3002 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -325,8 +325,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_SETMASK: c_int = 2; @@ -551,12 +549,10 @@ pub const SYS_cacheflush: c_long = 123; pub const SYS_adjtimex_time32: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -592,8 +588,7 @@ pub const SYS_mremap: c_long = 163; pub const SYS_setresuid16: c_long = 164; pub const SYS_getresuid16: c_long = 165; pub const SYS_getpagesize: c_long = 166; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 167; +// 167 was SYS_query_module pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; pub const SYS_setresgid16: c_long = 170; 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 18bb1933925f0..936551c2bcbbb 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -384,12 +384,10 @@ pub const SYS_modify_ldt: c_long = 4000 + 123; pub const SYS_adjtimex: c_long = 4000 + 124; pub const SYS_mprotect: c_long = 4000 + 125; pub const SYS_sigprocmask: c_long = 4000 + 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 4000 + 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 4000 + 128; pub const SYS_delete_module: c_long = 4000 + 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 4000 + 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 4000 + 131; pub const SYS_getpgid: c_long = 4000 + 132; pub const SYS_fchdir: c_long = 4000 + 133; @@ -445,8 +443,7 @@ pub const SYS_socket: c_long = 4000 + 183; pub const SYS_socketpair: c_long = 4000 + 184; pub const SYS_setresuid: c_long = 4000 + 185; pub const SYS_getresuid: c_long = 4000 + 186; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 4000 + 187; +// 187 was SYS_query_module pub const SYS_poll: c_long = 4000 + 188; pub const SYS_nfsservctl: c_long = 4000 + 189; pub const SYS_setresgid: c_long = 4000 + 190; diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 11ada71ae8150..6363132fde03a 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -159,11 +159,7 @@ s! { pub totalswap: c_ulong, pub freeswap: c_ulong, pub procs: c_ushort, - #[deprecated( - since = "0.2.58", - note = "This padding field might become private in the future" - )] - pub pad: c_ushort, + pad: Padding, pub totalhigh: c_ulong, pub freehigh: c_ulong, pub mem_unit: c_uint, diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index b5d3631a6fcf2..ac946d0ac3dd8 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -382,8 +382,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_SETMASK: c_int = 2; @@ -618,12 +616,10 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -659,8 +655,7 @@ pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 166; +// 166 was SYS_query_module pub const SYS_poll: c_long = 167; pub const SYS_nfsservctl: c_long = 168; pub const SYS_setresgid: c_long = 169; 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 76b899838beec..4cee14cc5d340 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -658,8 +658,7 @@ pub const SYS_flistxattr: c_long = 180; pub const SYS_removexattr: c_long = 181; pub const SYS_lremovexattr: c_long = 182; pub const SYS_sigpending: c_long = 183; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 184; +// 184 was SYS_query_module pub const SYS_setpgid: c_long = 185; pub const SYS_fremovexattr: c_long = 186; pub const SYS_tkill: c_long = 187; @@ -696,11 +695,9 @@ pub const SYS_clone: c_long = 217; pub const SYS_ioprio_get: c_long = 218; pub const SYS_adjtimex: c_long = 219; pub const SYS_sigprocmask: c_long = 220; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 221; +// 221 was SYS_create_module pub const SYS_delete_module: c_long = 222; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 223; +// 223 was SYS_get_kernel_syms pub const SYS_getpgid: c_long = 224; pub const SYS_bdflush: c_long = 225; pub const SYS_sysfs: c_long = 226; 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 97429dad64285..52919b02c5b94 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -458,8 +458,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_SETMASK: c_int = 2; @@ -700,12 +698,10 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -742,8 +738,7 @@ pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; pub const SYS_vm86: c_long = 166; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 167; +// 167 was SYS_query_module pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; pub const SYS_setresgid: c_long = 170; 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 a4fe3ba7e7e82..e294f1f132bed 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -383,8 +383,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_SETMASK: c_int = 2; 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 01044881f691a..b02be364a6a30 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -754,7 +754,6 @@ 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 SIGUNUSED: 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 7fed1e5383838..e5aea2547156c 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -368,14 +368,11 @@ pub const SYS_swapoff: c_long = 5000 + 163; pub const SYS_reboot: c_long = 5000 + 164; pub const SYS_sethostname: c_long = 5000 + 165; pub const SYS_setdomainname: c_long = 5000 + 166; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 5000 + 167; +// 167 was SYS_create_module pub const SYS_init_module: c_long = 5000 + 168; pub const SYS_delete_module: c_long = 5000 + 169; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 5000 + 170; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 5000 + 171; +// 170 was SYS_get_kernel_syms +// 171 was SYS_query_module pub const SYS_quotactl: c_long = 5000 + 172; pub const SYS_nfsservctl: c_long = 5000 + 173; pub const SYS_getpmsg: c_long = 5000 + 174; 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 f304507243510..51f71a8402a76 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -418,8 +418,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_SETMASK: c_int = 2; @@ -734,12 +732,10 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -775,8 +771,7 @@ pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 166; +// 166 was SYS_query_module pub const SYS_poll: c_long = 167; pub const SYS_nfsservctl: c_long = 168; pub const SYS_setresgid: c_long = 169; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index c5a7cc414a32f..2c54c68d2b82a 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -239,6 +239,13 @@ cfg_if! { } } +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 3], + } +} + pub const POSIX_FADV_DONTNEED: c_int = 6; pub const POSIX_FADV_NOREUSE: c_int = 7; @@ -427,8 +434,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_BLOCK: c_int = 0x000000; @@ -654,12 +659,10 @@ pub const SYS_uname: c_long = 122; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -689,8 +692,7 @@ pub const SYS_sched_get_priority_min: c_long = 160; pub const SYS_sched_rr_get_interval: c_long = 161; pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 167; +// 167 was SYS_query_module pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; pub const SYS_prctl: c_long = 172; 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 6e3673e35d00a..e58bfd33f849d 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -692,8 +692,7 @@ pub const SYS_flistxattr: c_long = 180; pub const SYS_removexattr: c_long = 181; pub const SYS_lremovexattr: c_long = 182; pub const SYS_sigpending: c_long = 183; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 184; +// 184 was SYS_query_module pub const SYS_setpgid: c_long = 185; pub const SYS_fremovexattr: c_long = 186; pub const SYS_tkill: c_long = 187; @@ -730,11 +729,9 @@ pub const SYS_clone: c_long = 217; pub const SYS_ioprio_get: c_long = 218; pub const SYS_adjtimex: c_long = 219; pub const SYS_sigprocmask: c_long = 220; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 221; +// 221 was SYS_create_module pub const SYS_delete_module: c_long = 222; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 223; +// 223 was SYS_get_kernel_syms pub const SYS_getpgid: c_long = 224; pub const SYS_bdflush: c_long = 225; pub const SYS_sysfs: c_long = 226; 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 9658aeb4a5367..8c5f3e5a1800d 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 @@ -448,8 +448,6 @@ pub const SIGURG: c_int = 23; pub const SIGIO: c_int = 29; pub const SIGSYS: c_int = 31; pub const SIGSTKFLT: c_int = 16; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = 31; pub const SIGPOLL: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIG_SETMASK: c_int = 2; 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 9f9a618d18581..4c179540436b6 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 @@ -197,14 +197,11 @@ pub const SYS_sethostname: c_long = 170; pub const SYS_setdomainname: c_long = 171; pub const SYS_iopl: c_long = 172; pub const SYS_ioperm: c_long = 173; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 174; +// 174 was SYS_create_module pub const SYS_init_module: c_long = 175; pub const SYS_delete_module: c_long = 176; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 177; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 178; +// 177 was SYS_get_kernel_syms +// 178 was SYS_query_module pub const SYS_quotactl: c_long = 179; pub const SYS_nfsservctl: c_long = 180; pub const SYS_getpmsg: c_long = 181; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index d162a2643c364..b8c62331fa608 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -459,7 +459,7 @@ impl siginfo_t { s_no_extra_traits! { // linux/if_ether.h - #[repr(C, packed)] + #[repr(packed)] pub struct ethhdr { pub h_dest: [c_uchar; crate::ETH_ALEN as usize], pub h_source: [c_uchar; crate::ETH_ALEN as usize], @@ -1319,6 +1319,9 @@ extern "C" { pub fn mempcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; pub fn tgkill(tgid: crate::pid_t, tid: crate::pid_t, sig: c_int) -> c_int; + + // glibc provides this in with _GNU_SOURCE + pub static mut environ: *mut *mut c_char; } cfg_if! { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index a41d03d9f808c..6e848b4051e0a 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -18,6 +18,7 @@ pub type dev_t = u64; pub type socklen_t = u32; pub type mode_t = u32; pub type ino64_t = u64; +// FIXME(1.0,deprecate): lfs binding to be removed pub type off64_t = i64; pub type blkcnt64_t = i64; pub type rlim64_t = u64; @@ -1012,6 +1013,7 @@ s! { cfg_if! { if #[cfg(not(target_env = "gnu"))] { extern_ty! { + // FIXME(1.0,deprecate): lfs binding to be removed pub type fpos64_t; // FIXME(linux): fill this out with a struct } } @@ -1347,12 +1349,6 @@ pub const FALLOC_FL_ZERO_RANGE: c_int = 0x10; pub const FALLOC_FL_INSERT_RANGE: c_int = 0x20; pub const FALLOC_FL_UNSHARE_RANGE: c_int = 0x40; -#[deprecated( - since = "0.2.55", - note = "ENOATTR is not available on Linux; use ENODATA instead" -)] -pub const ENOATTR: c_int = crate::ENODATA; - pub const SO_ORIGINAL_DST: c_int = 80; pub const IP_RECVFRAGSIZE: c_int = 25; @@ -2564,12 +2560,6 @@ pub const MAP_DROPPABLE: c_int = 0x8; // uapi/linux/vm_sockets.h pub const VMADDR_CID_ANY: c_uint = 0xFFFFFFFF; pub const VMADDR_CID_HYPERVISOR: c_uint = 0; -#[deprecated( - since = "0.2.74", - note = "VMADDR_CID_RESERVED is removed since Linux v5.6 and \ - replaced with VMADDR_CID_LOCAL" -)] -pub const VMADDR_CID_RESERVED: c_uint = 1; pub const VMADDR_CID_LOCAL: c_uint = 1; pub const VMADDR_CID_HOST: c_uint = 2; pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; @@ -3528,7 +3518,10 @@ extern "C" { pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fallocate64")] pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t; + #[cfg(any(target_env = "musl", target_env = "ohos"))] + pub fn readahead(fd: c_int, offset: off_t, count: size_t) -> ssize_t; pub fn getxattr( path: *const c_char, name: *const c_char, @@ -3616,7 +3609,10 @@ extern "C" { // Not available now on Android pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; + #[cfg(any(target_env = "musl", target_env = "ohos"))] + pub fn sync_file_range(fd: c_int, offset: off_t, nbytes: off_t, flags: c_uint) -> c_int; pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: 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 26d3380eb7ba5..81ea674f6b041 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -3,8 +3,6 @@ use crate::prelude::*; pub type wchar_t = u32; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index c8c3377c53ab7..c99411c15e7ed 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -1,7 +1,6 @@ use crate::prelude::*; pub type wchar_t = u32; -pub type stat64 = crate::stat; s! { pub struct stat { 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 7edcf573d2790..8beb5abcdab6a 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -3,8 +3,6 @@ use crate::prelude::*; pub type wchar_t = c_int; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, @@ -149,6 +147,7 @@ s! { pub f_spare: [c_ulong; 5], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct statfs64 { pub f_type: c_ulong, pub f_bsize: c_ulong, @@ -613,12 +612,10 @@ pub const SYS_modify_ldt: c_long = 4000 + 123; pub const SYS_adjtimex: c_long = 4000 + 124; pub const SYS_mprotect: c_long = 4000 + 125; pub const SYS_sigprocmask: c_long = 4000 + 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 4000 + 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 4000 + 128; pub const SYS_delete_module: c_long = 4000 + 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 4000 + 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 4000 + 131; pub const SYS_getpgid: c_long = 4000 + 132; pub const SYS_fchdir: c_long = 4000 + 133; @@ -673,8 +670,7 @@ pub const SYS_socket: c_long = 4000 + 183; pub const SYS_socketpair: c_long = 4000 + 184; pub const SYS_setresuid: c_long = 4000 + 185; pub const SYS_getresuid: c_long = 4000 + 186; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 4000 + 187; +// 187 was SYS_query_module pub const SYS_poll: c_long = 4000 + 188; pub const SYS_nfsservctl: c_long = 4000 + 189; pub const SYS_setresgid: c_long = 4000 + 190; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index f0d92c0e936e7..00b5015084ca2 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -3,8 +3,6 @@ use crate::prelude::*; pub type wchar_t = i32; -pub type stat64 = stat; - s! { pub struct termios { pub c_iflag: crate::tcflag_t, @@ -556,12 +554,10 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -597,8 +593,7 @@ pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 166; +// 166 was SYS_query_module pub const SYS_poll: c_long = 167; pub const SYS_nfsservctl: c_long = 168; pub const SYS_setresgid: c_long = 169; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index 1dea8d224bf8d..0356645fe8727 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -5,8 +5,6 @@ use crate::prelude::*; pub type wchar_t = c_int; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 1a348078764f0..38fcf64c3ea53 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -3,8 +3,6 @@ use crate::prelude::*; pub type wchar_t = i32; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, @@ -573,12 +571,10 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -615,8 +611,7 @@ pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; pub const SYS_vm86: c_long = 166; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 167; +// 167 was SYS_query_module pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; pub const SYS_setresgid: c_long = 170; 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 04bbb8d223864..1821cf5572f9d 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -5,8 +5,6 @@ pub type wchar_t = u32; pub type nlink_t = u32; pub type blksize_t = c_int; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index 27853cdbf5999..fcbf8a8be7b21 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -8,8 +8,6 @@ pub type wchar_t = c_int; pub type nlink_t = c_uint; pub type blksize_t = c_int; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index dc59d58be8dd6..fd1321ffd64d5 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -5,8 +5,6 @@ pub type wchar_t = i32; pub type nlink_t = c_uint; pub type blksize_t = i64; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, @@ -74,6 +72,7 @@ s! { pub f_spare: [c_ulong; 5], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct statfs64 { pub f_type: c_ulong, pub f_bsize: c_ulong, @@ -260,14 +259,11 @@ pub const SYS_swapoff: c_long = 5000 + 163; pub const SYS_reboot: c_long = 5000 + 164; pub const SYS_sethostname: c_long = 5000 + 165; pub const SYS_setdomainname: c_long = 5000 + 166; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 5000 + 167; +// 167 was SYS_create_module pub const SYS_init_module: c_long = 5000 + 168; pub const SYS_delete_module: c_long = 5000 + 169; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 5000 + 170; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 5000 + 171; +// 170 was SYS_get_kernel_syms +// 171 was SYS_query_module pub const SYS_quotactl: c_long = 5000 + 172; pub const SYS_nfsservctl: c_long = 5000 + 173; pub const SYS_getpmsg: c_long = 5000 + 174; diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 32c380789c01e..ef500af952b62 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -5,8 +5,6 @@ pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = c_long; -pub type stat64 = stat; - s! { pub struct termios { pub c_iflag: crate::tcflag_t, @@ -363,12 +361,10 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -404,8 +400,7 @@ pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 166; +// 166 was SYS_query_module pub const SYS_poll: c_long = 167; pub const SYS_nfsservctl: c_long = 168; pub const SYS_setresgid: c_long = 169; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 4baced6f19b98..863003fe7ba5a 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -8,8 +8,6 @@ pub type wchar_t = c_int; pub type nlink_t = c_uint; pub type blksize_t = c_int; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 3291acc7bbb22..b536c0290eb9c 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -5,8 +5,9 @@ pub type blksize_t = i64; pub type nlink_t = u64; pub type wchar_t = i32; pub type greg_t = u64; + +// FIXME(1.0,deprecate): lfs binding to be removed pub type statfs64 = statfs; -pub type stat64 = stat; s! { pub struct ipc_perm { @@ -447,12 +448,10 @@ pub const SYS_uname: c_long = 122; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 127; +// 127 was SYS_create_module pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 130; +// 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; pub const SYS_fchdir: c_long = 133; @@ -483,8 +482,7 @@ pub const SYS_sched_get_priority_min: c_long = 160; pub const SYS_sched_rr_get_interval: c_long = 161; pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 167; +// 167 was SYS_query_module pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; pub const SYS_prctl: c_long = 172; 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 7064a137acca9..09e07acc21a59 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -7,8 +7,6 @@ pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = c_long; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, @@ -227,11 +225,11 @@ pub const SYS_sethostname: c_long = 170; pub const SYS_setdomainname: c_long = 171; pub const SYS_iopl: c_long = 172; pub const SYS_ioperm: c_long = 173; -pub const SYS_create_module: c_long = 174; +// 174 was SYS_create_module pub const SYS_init_module: c_long = 175; pub const SYS_delete_module: c_long = 176; -pub const SYS_get_kernel_syms: c_long = 177; -pub const SYS_query_module: c_long = 178; +// 177 was SYS_get_kernel_syms +// 178 was SYS_query_module pub const SYS_quotactl: c_long = 179; pub const SYS_nfsservctl: c_long = 180; pub const SYS_getpmsg: c_long = 181; 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 805457f16ce10..b66ae26733dd2 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 @@ -6,8 +6,6 @@ pub type nlink_t = u64; pub type blksize_t = c_long; pub type greg_t = i64; -pub type stat64 = stat; - s! { pub struct stat { pub st_dev: crate::dev_t, @@ -341,14 +339,11 @@ pub const SYS_sethostname: c_long = 170; pub const SYS_setdomainname: c_long = 171; pub const SYS_iopl: c_long = 172; pub const SYS_ioperm: c_long = 173; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 174; +// 174 was SYS_create_module pub const SYS_init_module: c_long = 175; pub const SYS_delete_module: c_long = 176; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 177; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 178; +// 177 was SYS_get_kernel_syms +// 178 was SYS_query_module pub const SYS_quotactl: c_long = 179; pub const SYS_nfsservctl: c_long = 180; pub const SYS_getpmsg: c_long = 181; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 26a7248ac608f..99acc27c81a1e 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -37,11 +37,16 @@ pub type shmatt_t = c_ulong; pub type msgqnum_t = c_ulong; pub type msglen_t = c_ulong; pub type fsblkcnt_t = c_ulonglong; -pub type fsblkcnt64_t = c_ulonglong; pub type fsfilcnt_t = c_ulonglong; -pub type fsfilcnt64_t = c_ulonglong; pub type rlim_t = c_ulonglong; +// FIXME(1.0,deprecate): lfs binding to be removed +pub type fsblkcnt64_t = c_ulonglong; +// FIXME(1.0,deprecate): lfs binding to be removed +pub type fsfilcnt64_t = c_ulonglong; +// FIXME(1.0,deprecate): lfs binding to be removed +pub type stat64 = stat; + cfg_if! { if #[cfg(doc)] { // Used in `linux::arch` to define ioctl constants. @@ -208,6 +213,7 @@ s! { __f_reserved: Padding<[c_int; 6]>, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct statvfs64 { pub f_bsize: c_ulong, pub f_frsize: c_ulong, @@ -249,6 +255,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, @@ -415,6 +422,7 @@ s! { } // MIPS/s390x implementation is special (see arch folders) + // FIXME(1.0,deprecate): lfs binding to be removed #[cfg(not(any(target_arch = "mips", target_arch = "mips64", target_arch = "s390x")))] pub struct statfs64 { pub f_type: c_ulong, @@ -585,9 +593,6 @@ pub const SOCK_PACKET: c_int = 10; pub const SOMAXCONN: c_int = 128; -#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] -pub const SIGUNUSED: c_int = crate::SIGSYS; - pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; @@ -887,6 +892,7 @@ extern "C" { } // Alias to 64 to mimic glibc's LFS64 support +// FIXME(1.0,deprecate): lfs binding to be removed mod lfs64; pub use self::lfs64::*; 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 b6c8559e78b77..2c253f0164f11 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -392,12 +392,10 @@ pub const SYS_modify_ldt: c_long = 4000 + 123; pub const SYS_adjtimex: c_long = 4000 + 124; pub const SYS_mprotect: c_long = 4000 + 125; pub const SYS_sigprocmask: c_long = 4000 + 126; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_create_module: c_long = 4000 + 127; +// 4000 + 127 was SYS_create_module pub const SYS_init_module: c_long = 4000 + 128; pub const SYS_delete_module: c_long = 4000 + 129; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_get_kernel_syms: c_long = 4000 + 130; +// 4000 + 130 was SYS_get_kernel_syms pub const SYS_quotactl: c_long = 4000 + 131; pub const SYS_getpgid: c_long = 4000 + 132; pub const SYS_fchdir: c_long = 4000 + 133; @@ -453,8 +451,7 @@ pub const SYS_socket: c_long = 4000 + 183; pub const SYS_socketpair: c_long = 4000 + 184; pub const SYS_setresuid: c_long = 4000 + 185; pub const SYS_getresuid: c_long = 4000 + 186; -#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] -pub const SYS_query_module: c_long = 4000 + 187; +// 4000 + 187 was SYS_query_module pub const SYS_poll: c_long = 4000 + 188; pub const SYS_nfsservctl: c_long = 4000 + 189; pub const SYS_setresgid: c_long = 4000 + 190; @@ -661,7 +658,6 @@ pub const SYS_process_mrelease: c_long = 4000 + 448; pub const SYS_futex_waitv: c_long = 4000 + 449; pub const SYS_set_mempolicy_home_node: c_long = 4000 + 450; -#[link(name = "util")] extern "C" { pub fn sysctl( name: *mut c_int, 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 46f3439ccb6e8..cd9f45699d590 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -246,19 +246,6 @@ s! { pub _f: [c_char; 0], } - pub struct glob_t { - // FIXME(ulibc) - pub gl_pathc: size_t, - pub gl_pathv: *mut *mut c_char, - pub gl_offs: size_t, - pub gl_flags: c_int, - __unused1: Padding<*mut c_void>, - __unused2: Padding<*mut c_void>, - __unused3: Padding<*mut c_void>, - __unused4: Padding<*mut c_void>, - __unused5: Padding<*mut c_void>, - } - pub struct cpu_set_t { // FIXME(ulibc) #[cfg(target_pointer_width = "32")] @@ -288,16 +275,6 @@ s! { } } -s_no_extra_traits! { - pub struct dirent { - pub d_ino: crate::ino64_t, - pub d_off: off64_t, - pub d_reclen: u16, - pub d_type: u8, - pub d_name: [c_char; 256], - } -} - // constants pub const ENAMETOOLONG: c_int = 36; // File name too long pub const ENOTEMPTY: c_int = 39; // Directory not empty diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 0674269182e74..60a9138ef4781 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -275,6 +275,7 @@ s! { pub val: c_int, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct rlimit64 { pub rlim_cur: crate::rlim64_t, pub rlim_max: crate::rlim64_t, @@ -297,6 +298,7 @@ s! { pub d_name: [c_char; 256], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct dirent64 { pub d_ino: crate::ino64_t, pub d_off: crate::off64_t, @@ -946,13 +948,7 @@ 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 -#[deprecated( - since = "0.2.80", - note = "This value was increased in the newer kernel \ - and we'll change this following upstream in the future release. \ - See #1896 for more info." -)] -pub const IPPROTO_MAX: c_int = 256; +pub const IPPROTO_MAX: c_int = 263; // System V IPC pub const IPC_PRIVATE: crate::key_t = 0; @@ -1562,9 +1558,7 @@ f! { pub unsafe fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword { sym << (32 + t) } -} -safe_f! { pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; @@ -1913,7 +1907,7 @@ extern "C" { longindex: *mut c_int, ) -> c_int; - #[cfg(not(target_env = "uclibc"))] + #[cfg(not(any(target_env = "uclibc", target_env = "musl", target_env = "ohos")))] pub fn copy_file_range( fd_in: c_int, off_in: *mut crate::off64_t, @@ -1922,6 +1916,16 @@ extern "C" { len: size_t, flags: c_uint, ) -> ssize_t; + + #[cfg(any(target_env = "musl", target_env = "ohos"))] + pub fn copy_file_range( + fd_in: c_int, + off_in: *mut crate::off_t, + fd_out: c_int, + off_out: *mut crate::off_t, + len: size_t, + flags: c_uint, + ) -> ssize_t; } cfg_if! { diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 9081f8472aa7e..7951abf33f4d0 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -29,12 +29,24 @@ s! { pub imr_ifindex: c_int, } + // netinet/in.h: RFC 3678 multicast group membership requests pub struct ip_mreq_source { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, pub imr_sourceaddr: in_addr, } + pub struct group_req { + pub gr_interface: u32, + pub gr_group: crate::sockaddr_storage, + } + + pub struct group_source_req { + pub gsr_interface: u32, + pub gsr_group: crate::sockaddr_storage, + pub gsr_source: crate::sockaddr_storage, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [c_char; 14], @@ -1806,9 +1818,7 @@ f! { pub unsafe fn FD_ZERO(set: *mut fd_set) -> () { (*set).fds_bits.fill(0); } -} -safe_f! { pub safe fn SIGRTMAX() -> c_int { unsafe { __libc_current_sigrtmax() } } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6c64020d49e85..e331089b38317 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -418,6 +418,23 @@ cfg_if! { } } +f! { + // It seems htonl, etc are macros on macOS. So we have to reimplement them. So let's + // reimplement them for all UNIX platforms + pub const safe fn htonl(hostlong: u32) -> u32 { + u32::to_be(hostlong) + } + pub const safe fn htons(hostshort: u16) -> u16 { + u16::to_be(hostshort) + } + pub const safe fn ntohl(netlong: u32) -> u32 { + u32::from_be(netlong) + } + pub const safe fn ntohs(netshort: u16) -> u16 { + u16::from_be(netshort) + } +} + extern "C" { pub static in6addr_loopback: in6_addr; pub static in6addr_any: in6_addr; @@ -611,7 +628,10 @@ cfg_if! { } cfg_if! { - if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] { + if #[cfg(not(any( + target_os = "hurd", + all(target_os = "linux", target_env = "gnu") + )))] { extern_ty! { pub type fpos_t; // FIXME(unix): fill this out with a struct } @@ -1702,7 +1722,8 @@ extern "C" { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "big" + target_endian = "big", + not(libc_elfv2) ), link_name = "cfgetispeed@GLIBC_2.3" )] @@ -1711,7 +1732,7 @@ extern "C" { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "little" + any(target_endian = "little", libc_elfv2) ), link_name = "cfgetispeed@GLIBC_2.17" )] @@ -1803,7 +1824,8 @@ extern "C" { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "big" + target_endian = "big", + not(libc_elfv2) ), link_name = "cfgetospeed@GLIBC_2.3" )] @@ -1812,7 +1834,7 @@ extern "C" { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "little" + any(target_endian = "little", libc_elfv2) ), link_name = "cfgetospeed@GLIBC_2.17" )] @@ -1904,7 +1926,8 @@ extern "C" { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "big" + target_endian = "big", + not(libc_elfv2) ), link_name = "cfsetispeed@GLIBC_2.3" )] @@ -1913,7 +1936,7 @@ extern "C" { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "little" + any(target_endian = "little", libc_elfv2) ), link_name = "cfsetispeed@GLIBC_2.17" )] @@ -2005,7 +2028,8 @@ extern "C" { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "big" + target_endian = "big", + not(libc_elfv2) ), link_name = "cfsetospeed@GLIBC_2.3" )] @@ -2014,7 +2038,7 @@ extern "C" { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "little" + any(target_endian = "little", libc_elfv2) ), link_name = "cfsetospeed@GLIBC_2.17" )] @@ -2126,23 +2150,6 @@ extern "C" { } -safe_f! { - // It seems htonl, etc are macros on macOS. So we have to reimplement them. So let's - // reimplement them for all UNIX platforms - pub const safe fn htonl(hostlong: u32) -> u32 { - u32::to_be(hostlong) - } - pub const safe fn htons(hostshort: u16) -> u16 { - u16::to_be(hostshort) - } - pub const safe fn ntohl(netlong: u32) -> u32 { - u32::from_be(netlong) - } - pub const safe fn ntohs(netshort: u16) -> u16 { - u16::from_be(netshort) - } -} - cfg_if! { if #[cfg(not(any( target_os = "emscripten", @@ -2413,7 +2420,8 @@ cfg_if! { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "big" + target_endian = "big", + not(libc_elfv2) ), link_name = "cfsetspeed@GLIBC_2.3" )] @@ -2422,7 +2430,7 @@ cfg_if! { target_os = "linux", target_env = "gnu", target_arch = "powerpc64", - target_endian = "little" + any(target_endian = "little", libc_elfv2) ), link_name = "cfsetspeed@GLIBC_2.17" )] diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs deleted file mode 100644 index 56c268fc5f2bb..0000000000000 --- a/src/unix/newlib/aarch64/mod.rs +++ /dev/null @@ -1,56 +0,0 @@ -use crate::prelude::*; - -pub type clock_t = c_long; -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_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_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 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 POLLOUT: c_short = 0x4; -pub const POLLERR: c_short = 0x8; -pub const POLLHUP: 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; - -pub use crate::unix::newlib::generic::{ - dirent, - sigset_t, - stat, -}; diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index 9b5978fc538c3..a559cf4da59fd 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -50,9 +50,3 @@ 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; - -pub use crate::unix::newlib::generic::{ - dirent, - sigset_t, - stat, -}; diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index b791bbe265368..f108ab82bf939 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -129,9 +129,3 @@ extern "C" { pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; } - -pub use crate::unix::newlib::generic::{ - dirent, - sigset_t, - stat, -}; diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index 0e92ccd9f907d..ab0956ef7042c 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -192,7 +192,7 @@ pub const GRND_NONBLOCK: c_uint = 0x1; pub const GRND_RANDOM: c_uint = 0x2; // Horizon OS works doesn't or can't hold any of this information -safe_f! { +f! { pub const safe fn WIFSTOPPED(_status: c_int) -> bool { false } @@ -282,5 +282,3 @@ extern "C" { pub fn gethostid() -> c_long; } - -pub use crate::unix::newlib::generic::dirent; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index d5f8bc53d6480..ab12da1d6fe08 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -6,18 +6,16 @@ pub type blksize_t = i32; pub type clockid_t = c_ulong; cfg_if! { - if #[cfg(any(target_os = "espidf"))] { + 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(any(target_os = "vita"))] { - pub type dev_t = c_short; - pub type ino_t = c_ushort; - pub type off_t = c_int; - } else { + } else if #[cfg(any(target_arch = "arm", target_arch = "powerpc"))] { pub type dev_t = u32; pub type ino_t = u32; pub type off_t = i64; + } else { + core::compile_error!("unsupported target"); } } @@ -55,12 +53,12 @@ pub type useconds_t = u32; cfg_if! { if #[cfg(any( - target_os = "horizon", - all(target_os = "espidf", not(espidf_time32)) + all(target_os = "espidf", espidf_time32), + target_os = "vita" ))] { - pub type time_t = c_longlong; + pub type time_t = c_long; } else { - pub type time_t = i32; + pub type time_t = i64; } } @@ -325,6 +323,36 @@ s! { // Unverified size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], } + + #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] + pub struct sigset_t { + __val: u32, + } + + #[cfg(not(target_os = "vita"))] + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: crate::off_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_spare4: [c_long; 2usize], + } + + #[cfg(not(target_os = "vita"))] + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_type: c_uchar, + pub d_name: [c_char; 256usize], + } } // unverified constants @@ -842,6 +870,7 @@ f! { } extern "C" { + pub fn __errno() -> *mut 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; @@ -939,8 +968,6 @@ extern "C" { pub fn uname(buf: *mut crate::utsname) -> c_int; } -mod generic; - cfg_if! { if #[cfg(target_os = "espidf")] { mod espidf; @@ -954,16 +981,8 @@ cfg_if! { } else if #[cfg(target_arch = "arm")] { mod arm; pub use self::arm::*; - } else if #[cfg(target_arch = "aarch64")] { - mod aarch64; - pub use self::aarch64::*; - } else if #[cfg(target_arch = "powerpc")] { - mod powerpc; - pub use self::powerpc::*; } else { - // Only tested on ARM so far. Other platforms might have different - // definitions for types and constants. - pub use target_arch_not_implemented; + core::compile_error!("unsupported target"); } } diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs deleted file mode 100644 index f51a1b2cbe602..0000000000000 --- a/src/unix/newlib/powerpc/mod.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::prelude::*; - -pub type clock_t = c_ulong; -pub type wchar_t = c_int; - -pub use crate::unix::newlib::generic::{ - dirent, - sigset_t, - stat, -}; - -// the newlib shipped with devkitPPC does not support the following components: -// - sockaddr -// - AF_INET6 -// - FIONBIO -// - POLL* -// - SOL_SOCKET -// - MSG_* diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs index c889f6d908d99..9ed423096e8db 100644 --- a/src/unix/newlib/rtems/mod.rs +++ b/src/unix/newlib/rtems/mod.rs @@ -86,7 +86,7 @@ pub const WUNTRACED: c_int = 2; // sys/socket.h pub const SOMAXCONN: c_int = 128; -safe_f! { +f! { pub const safe fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 6aa400ad62fc2..eac685243b917 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2343,9 +2343,7 @@ f! { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; size_of::() + size_of::() * ngrps } -} -safe_f! { pub const safe fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 774d7b0d31643..ce0efa12ebd6c 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -36,7 +36,6 @@ extern_ty! { } s! { - #[repr(C)] pub struct utsname { pub sysname: [c_char; UTSLENGTH], pub nodename: [c_char; UTSLENGTH], @@ -251,57 +250,47 @@ s! { pub gid: gid_t, } - #[cfg_attr(target_pointer_width = "32", repr(C, align(4)))] - #[cfg_attr(target_pointer_width = "64", repr(C, align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] pub struct pthread_attr_t { bytes: [u8; _PTHREAD_ATTR_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_barrier_t { bytes: [u8; _PTHREAD_BARRIER_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_barrierattr_t { bytes: [u8; _PTHREAD_BARRIERATTR_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_mutex_t { bytes: [u8; _PTHREAD_MUTEX_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_rwlock_t { bytes: [u8; _PTHREAD_RWLOCK_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_mutexattr_t { bytes: [u8; _PTHREAD_MUTEXATTR_SIZE], } - #[repr(C)] #[repr(align(1))] pub struct pthread_rwlockattr_t { bytes: [u8; _PTHREAD_RWLOCKATTR_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_cond_t { bytes: [u8; _PTHREAD_COND_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_condattr_t { bytes: [u8; _PTHREAD_CONDATTR_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_once_t { bytes: [u8; _PTHREAD_ONCE_SIZE], } - #[repr(C)] #[repr(align(4))] pub struct pthread_spinlock_t { bytes: [u8; _PTHREAD_SPINLOCK_SIZE], @@ -778,6 +767,10 @@ pub const MS_ASYNC: c_int = 0x0001; pub const MS_INVALIDATE: c_int = 0x0002; pub const MS_SYNC: c_int = 0x0004; +// sys/random.h +pub const GRND_NONBLOCK: c_uint = 1; +pub const GRND_RANDOM: c_uint = 2; + // sys/resource.h pub const RLIM_INFINITY: rlim_t = !0; pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; @@ -1145,9 +1138,7 @@ f! { pub unsafe fn FD_ZERO(set: *mut fd_set) -> () { (*set).fds_bits.fill(0); } -} -safe_f! { pub const safe fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } @@ -1389,6 +1380,9 @@ extern "C" { pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; + // sys/random.h + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + // sys/resource.h pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index b08e8a4086c63..98c61c7636534 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2275,9 +2275,7 @@ f! { pub unsafe fn FD_ZERO(set: *mut fd_set) -> () { (*set).fds_bits.fill(0); } -} -safe_f! { pub safe fn SIGRTMAX() -> c_int { unsafe { crate::sysconf(_SC_SIGRT_MAX) as c_int } } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 27e0c122bb990..91e0a9dab4bee 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1496,6 +1496,30 @@ f! { pub const unsafe fn CMSG_LEN(length: c_uint) -> c_uint { CMSG_ALIGN(size_of::()) as c_uint + length } + + // Dummy functions, these don't really exist in VxWorks. + // wait.h macros + pub const safe fn WIFEXITED(status: c_int) -> bool { + (status & 0xFF00) == 0 + } + pub const safe fn WIFSIGNALED(status: c_int) -> bool { + (status & 0xFF00) != 0 + } + pub const safe fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xFF0000) != 0 + } + pub const safe fn WEXITSTATUS(status: c_int) -> c_int { + status & 0xFF + } + pub const safe fn WIFCONTINUED(status: c_int) -> c_int { + (status >> 24) & 0xFF + } + pub const safe fn WTERMSIG(status: c_int) -> c_int { + (status >> 8) & 0xFF + } + pub const safe fn WSTOPSIG(status: c_int) -> c_int { + (status >> 16) & 0xFF + } } extern "C" { @@ -2410,33 +2434,6 @@ extern "C" { pub fn vxCpuConfiguredGet() -> crate::cpuset_t; // Get set of Configured CPU's in the system } -//Dummy functions, these don't really exist in VxWorks. - -// wait.h macros -safe_f! { - pub const safe fn WIFEXITED(status: c_int) -> bool { - (status & 0xFF00) == 0 - } - pub const safe fn WIFSIGNALED(status: c_int) -> bool { - (status & 0xFF00) != 0 - } - pub const safe fn WIFSTOPPED(status: c_int) -> bool { - (status & 0xFF0000) != 0 - } - pub const safe fn WEXITSTATUS(status: c_int) -> c_int { - status & 0xFF - } - pub const safe fn WIFCONTINUED(status: c_int) -> c_int { - (status >> 24) & 0xFF - } - pub const safe fn WTERMSIG(status: c_int) -> c_int { - (status >> 8) & 0xFF - } - pub const safe fn WSTOPSIG(status: c_int) -> c_int { - (status >> 16) & 0xFF - } -} - pub unsafe fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int { // check to see if align is a power of 2 and if align is a multiple // of sizeof(void *) diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 9bce096559e4a..a21aa4f32635f 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -31,6 +31,10 @@ pub type blkcnt_t = i64; pub type nfds_t = c_ulong; pub type wchar_t = i32; pub type nl_item = c_int; +#[cfg_attr( + not(target_env = "p1"), + deprecated(since = "0.2.190", note = "not present on wasip2/3 targets") +)] pub type __wasi_rights_t = u64; pub type locale_t = *mut __locale_struct; pub type pthread_t = *mut c_void; @@ -615,9 +619,50 @@ pub const NOEXPR: crate::nl_item = 0x50001; pub const YESSTR: crate::nl_item = 0x50002; pub const NOSTR: crate::nl_item = 0x50003; +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; +pub const PTHREAD_MUTEX_STALLED: c_int = 0; +pub const PTHREAD_MUTEX_ROBUST: c_int = 1; +pub const PTHREAD_PRIO_NONE: c_int = 0; +pub const PTHREAD_PRIO_INHERIT: c_int = 1; +pub const PTHREAD_PRIO_PROTECT: c_int = 2; +pub const PTHREAD_INHERIT_SCHED: c_int = 0; +pub const PTHREAD_EXPLICIT_SCHED: c_int = 1; +pub const PTHREAD_SCOPE_SYSTEM: c_int = 0; +pub const PTHREAD_SCOPE_PROCESS: c_int = 1; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [ptr::null_mut(); 6], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [ptr::null_mut(); 8], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [ptr::null_mut(); 12], +}; +pub const PTHREAD_ONCE_INIT: pthread_once_t = 0; +pub const PTHREAD_CANCEL_ENABLE: c_int = 0; +pub const PTHREAD_CANCEL_DISABLE: c_int = 1; +pub const PTHREAD_CANCEL_MASKED: c_int = 2; +pub const PTHREAD_CANCEL_DEFERRED: c_int = 0; +pub const PTHREAD_CANCEL_ASYNCHRONOUS: c_int = 1; +pub const PTHREAD_CANCELED: *mut c_void = usize::MAX as *mut c_void; +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1; pub const PTHREAD_STACK_MIN: usize = 2048; pub const TIMER_ABSTIME: c_int = 1; +pub const SOCK_CLOEXEC: c_int = 0x00002000; +pub const SOCK_NONBLOCK: c_int = 0x00004000; + +pub const SOL_SOCKET: c_int = 0x7fffffff; + +pub const SO_TYPE: c_int = 3; + f! { pub unsafe fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let set = &*set; @@ -1040,8 +1085,21 @@ extern "C" { pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int; pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, stacksize: *mut size_t) -> c_int; pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int; + pub fn pthread_attr_getdetachstate(attr: *const pthread_attr_t, state: *mut c_int) -> c_int; pub fn pthread_attr_setdetachstate(attr: *mut pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_attr_getguardsize(attr: *const pthread_attr_t, b: *mut size_t) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut pthread_attr_t, b: size_t) -> c_int; + pub fn pthread_attr_getstack( + attr: *const pthread_attr_t, + b: *mut *mut c_void, + c: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setstack(attr: *mut pthread_attr_t, b: *mut c_void, c: size_t) -> c_int; pub fn pthread_detach(thread: pthread_t) -> c_int; + pub fn pthread_setcancelstate(a: c_int, b: *mut c_int) -> c_int; + pub fn pthread_setcanceltype(a: c_int, b: *mut c_int) -> c_int; + pub fn pthread_testcancel(); + pub fn pthread_once(a: *mut pthread_once_t, b: extern "C" fn()) -> c_int; pub fn pthread_key_create( key: *mut pthread_key_t, @@ -1058,10 +1116,20 @@ extern "C" { pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, ts: *const timespec) -> c_int; + pub fn pthread_mutex_consistent(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_getprioceiling(lock: *mut pthread_mutex_t, b: *mut c_int) -> c_int; pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + pub fn pthread_mutexattr_getprotocol(attr: *const pthread_mutexattr_t, b: *mut c_int) -> c_int; + pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, b: *mut c_int) -> c_int; + pub fn pthread_mutexattr_getrobust(attr: *const pthread_mutexattr_t, b: *mut c_int) -> c_int; + pub fn pthread_mutexattr_gettype(attr: *const pthread_mutexattr_t, b: *mut c_int) -> c_int; + pub fn pthread_mutexattr_setprotocol(attr: *const pthread_mutexattr_t, b: c_int) -> c_int; + pub fn pthread_mutexattr_setpshared(attr: *const pthread_mutexattr_t, b: c_int) -> c_int; + pub fn pthread_mutexattr_setrobust(attr: *const pthread_mutexattr_t, b: c_int) -> c_int; pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; @@ -1075,6 +1143,8 @@ extern "C" { pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, b: c_int) -> c_int; + pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, b: *mut c_int) -> c_int; pub fn pthread_rwlock_init( lock: *mut pthread_rwlock_t, @@ -1086,8 +1156,36 @@ extern "C" { pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> c_int; pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> c_int; pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_timedrdlock(lock: *mut pthread_rwlock_t, at: *const timespec) -> c_int; + pub fn pthread_rwlock_timedwrlock(lock: *mut pthread_rwlock_t, at: *const timespec) -> c_int; pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> c_int; pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> c_int; + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, b: c_int) -> c_int; + pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, b: *mut c_int) + -> c_int; + + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, b: c_int) -> c_int; + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_barrier_init( + barrier: *mut pthread_barrier_t, + attr: *const pthread_barrierattr_t, + count: c_uint, + ) -> c_int; + pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; + pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; + pub fn pthread_barrierattr_init(attr: *mut pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_destroy(attr: *mut pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_setpshared(attr: *mut pthread_barrierattr_t, b: c_int) -> c_int; + pub fn pthread_barrierattr_getpshared( + attr: *const pthread_barrierattr_t, + b: *mut c_int, + ) -> c_int; + + pub fn pthread_getattr_np(thread: pthread_t, attr: *mut pthread_attr_t) -> c_int; } cfg_if! { diff --git a/src/wasi/p2.rs b/src/wasi/p2.rs index 7332a779396d3..2a724ac061c12 100644 --- a/src/wasi/p2.rs +++ b/src/wasi/p2.rs @@ -79,7 +79,6 @@ pub const MSG_NOSIGNAL: c_int = 0x4000; pub const MSG_PEEK: c_int = 0x0002; pub const SO_REUSEADDR: c_int = 2; -pub const SO_TYPE: c_int = 3; pub const SO_ERROR: c_int = 4; pub const SO_BROADCAST: c_int = 6; pub const SO_SNDBUF: c_int = 7; @@ -94,9 +93,6 @@ pub const SO_SNDTIMEO: c_int = 67; pub const SOCK_DGRAM: c_int = 5; pub const SOCK_STREAM: c_int = 6; -pub const SOCK_NONBLOCK: c_int = 0x00004000; - -pub const SOL_SOCKET: c_int = 0x7fffffff; pub const AF_UNSPEC: c_int = 0; pub const AF_INET: c_int = 1;