diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7a86a0e4fee4..66560f5b320f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,5 @@ name: CI +permissions: {} on: merge_group: @@ -23,10 +24,12 @@ defaults: jobs: style_check: name: Style check - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 timeout-minutes: 10 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh && rustup component add rustfmt - name: Check style @@ -36,13 +39,15 @@ jobs: name: Clippy on ${{ matrix.os }} strategy: matrix: - os: [ubuntu-24.04, macos-26, windows-2025] + os: [ubuntu-26.04, macos-26, windows-2025] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false - run: rustup update stable --no-self-update - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 # Here we use the latest stable Rust toolchain already installed by GitHub # Ideally we should run it for every target, but we cannot rely on unstable toolchains # due to Clippy not being consistent between them. @@ -64,18 +69,22 @@ jobs: only: '(aarch64|x86_64)' # just a spot check for beta - toolchain: stable - toolchain: 1.65.0 # msrv - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 timeout-minutes: 25 env: TOOLCHAIN: ${{ matrix.toolchain }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh - name: Install semver-checks - uses: taiki-e/install-action@cargo-semver-checks + uses: taiki-e/install-action@9e1e5806d4a4822de933115878265be9aaa786d9 # v2.82.2 if: matrix.toolchain == 'stable' + with: + tool: cargo-semver-checks - name: Retrieve semver baseline if: matrix.toolchain == 'stable' @@ -84,7 +93,7 @@ jobs: # FIXME(ci): These `du` statements are temporary for debugging cache - name: Target size before restoring cache run: du -sh target | sort -k 2 || true - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: key: ${{ matrix.os }}-${{ matrix.toolchain }} - name: Target size after restoring cache @@ -106,6 +115,7 @@ jobs: test_tier1: name: Test tier1 strategy: + fail-fast: false # Speed up 0.2 backport CI matrix: include: - target: aarch64-apple-darwin @@ -113,7 +123,7 @@ jobs: - target: aarch64-pc-windows-msvc os: windows-11-arm - target: aarch64-unknown-linux-gnu - os: ubuntu-24.04-arm + os: ubuntu-26.04-arm - target: i686-pc-windows-gnu os: windows-2025 - target: i686-pc-windows-msvc @@ -124,15 +134,17 @@ jobs: - target: x86_64-pc-windows-msvc os: windows-2025 - target: x86_64-unknown-linux-gnu - runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} + runs-on: ${{ matrix.os && matrix.os || 'ubuntu-26.04' }} timeout-minutes: 25 env: TARGET: ${{ matrix.target }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: key: ${{ matrix.target }} @@ -154,7 +166,7 @@ jobs: id: create_artifacts if: always() run: python3 ci/create-artifacts.py - - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 if: always() && steps.create_artifacts.outcome == 'success' with: name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} @@ -164,9 +176,8 @@ jobs: # Unlike `main` this job doesn't have `needs`, in order to speed up backports a bit test_tier2: name: Test tier2 - needs: [test_tier1, style_check] strategy: - fail-fast: true + fail-fast: false # Speed up 0.2 backport CI max-parallel: 16 matrix: include: @@ -221,15 +232,17 @@ jobs: # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu - runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} + runs-on: ${{ matrix.os && matrix.os || 'ubuntu-26.04' }} timeout-minutes: 25 env: TARGET: ${{ matrix.target }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: key: ${{ matrix.target }} @@ -251,7 +264,7 @@ jobs: id: create_artifacts if: always() run: ./ci/create-artifacts.py - - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 if: always() && steps.create_artifacts.outcome == 'success' with: name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} @@ -262,12 +275,9 @@ jobs: name: Test tier2 VM runs-on: ubuntu-latest strategy: - fail-fast: true + fail-fast: false # Speed up 0.2 backport CI matrix: include: - # FIXME(#4740): FreeBSD 13 tests are extremely flaky and fail most of the time - # - release: "13.4" - # target: x86_64-unknown-freebsd - release: "15.0" target: i686-unknown-freebsd - release: "14.4" @@ -278,9 +288,11 @@ jobs: - target: x86_64-unknown-netbsd timeout-minutes: 25 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false - name: Test on FreeBSD - uses: vmactions/freebsd-vm@v1.4.5 + uses: vmactions/freebsd-vm@b84ab5559b5a1bb4b8ee2737d2506a16e1737636 # v1.4.8 if: contains(matrix.target, 'freebsd') with: release: ${{ matrix.release }} @@ -300,7 +312,7 @@ jobs: ./ci/run.sh ${{ matrix.target }} - name: test on Solaris - uses: vmactions/solaris-vm@v1.3.2 + uses: vmactions/solaris-vm@d30dd6c228c8661ade859e36ead7660b9a62efcc # v1.3.7 if: contains(matrix.target, 'solaris') with: release: "11.4-gcc" @@ -309,15 +321,18 @@ jobs: copyback: false prepare: | set -ex - source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install) - rustc --version + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ + --profile minimal --default-toolchain nightly -y uname -a run: | - export PATH=$HOME/.rust_solaris/bin:$PATH + set -ex + . "$HOME/.cargo/env" + which rustc + rustc -Vv ./ci/run.sh ${{ matrix.target }} - name: Test on NetBSD - uses: vmactions/netbsd-vm@v1 + uses: vmactions/netbsd-vm@99816dccf75edf233ed6cd00a159e3a5b85ea373 # v1.4.0 if: contains(matrix.target, 'netbsd') with: release: "10.1" @@ -338,20 +353,37 @@ jobs: docs: name: Ensure docs build - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 timeout-minutes: 10 steps: - - uses: actions/checkout@master + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false - name: Install Rust run: rustup update nightly --no-self-update && rustup default nightly - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 - run: cargo doc --workspace --no-deps + zizmor: + name: Zizmor (Static analysis for GitHub Actions) + runs-on: ubuntu-24.04 + permissions: + security-events: write + timeout-minutes: 10 + steps: + - name: Checkout repository + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + - name: Run zizmor + uses: zizmorcore/zizmor-action@192e21d79ab29983730a13d1382995c2307fbcaa # v0.5.7 + # 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. success: name: success - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 needs: - style_check - test_tier1 @@ -360,11 +392,14 @@ jobs: - verify_build - docs - clippy - # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency + - zizmor + # GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its # dependencies fails. if: always() # make sure this is never "skipped" + env: + NEEDS: ${{ toJson(needs) }} steps: # Manually check the status of all dependencies. `if: failure()` does not work. - name: check if any dependency failed - run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' + run: jq --exit-status 'all(.result == "success")' <<< "$NEEDS" diff --git a/.github/workflows/publish_0.2.yml b/.github/workflows/publish_0.2.yml index 9327c50d8889..32182761ee7b 100644 --- a/.github/workflows/publish_0.2.yml +++ b/.github/workflows/publish_0.2.yml @@ -17,13 +17,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: fetch-depth: 0 + persist-credentials: false - name: Install Rust (rustup) run: rustup update stable --no-self-update && rustup default stable - name: Run release-plz - uses: MarcoIeni/release-plz-action@v0.5 + uses: release-plz/action@e8792575c7f2366cf6ff3ccc33ead9ace5b691c7 # v0.5.130 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index a448d888c773..1f1c1af48ecc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ keywords = ["libc", "ffi", "bindings", "operating", "system"] categories = ["external-ffi-bindings", "no-std", "os"] exclude = ["/ci/*", "/.github/*", "/triagebot.toml", "cherry-pick-stable.sh"] description = "Raw FFI bindings to platform libraries like libc." -authors = ["The Rust Project Developers"] edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" @@ -184,14 +183,11 @@ members = [ "libc-test", ] -# FIXME(msrv): These should be renamed as `[workspace.lints.*]` once MSRV is above 1.64 -# This way all crates can use it with `[lints] workspace=true` section - -[lints.rust] +[workspace.lints.rust] # FIXME(cleanup): make ident usage consistent in each file unused_qualifications = "allow" -[lints.clippy] +[workspace.lints.clippy] # Enable pedantic lints - use this manually once in a while, but don't enable by default # pedantic = { level = "warn", priority = -1 } @@ -211,6 +207,9 @@ uninlined_format_args = "allow" unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets used_underscore_binding = "allow" +[lints] +workspace = true + [package.metadata.cargo-semver-checks.lints] # Alignment is an internal detail that users must not rely upon repr_align_removed = "warn" diff --git a/build.rs b/build.rs index 34df96aa7ce0..66bd213ffc53 100644 --- a/build.rs +++ b/build.rs @@ -131,6 +131,11 @@ fn main() { } } + let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64"); + if target_env == "uclibc" && uclibc_use_time64 { + set_cfg("linux_time_bits64"); + } + let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); if linux_time_bits64 { @@ -151,10 +156,10 @@ fn main() { ) { (Ok(_), Ok(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), (Err(_), Err(_)) => (defaultbits.clone(), defaultbits.clone()), - (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb.clone()), + (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb), (Ok(tb), Err(_)) if tb == "32" => (tb, defaultbits.clone()), (Ok(_), Err(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), - (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), + (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits, fb), (Err(_), Ok(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), }; let valid_bits = ["32", "64"]; diff --git a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile index 284389360ac2..a5e685318ad0 100644 --- a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile +++ b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile @@ -14,11 +14,9 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ qemu-user \ xz-utils -RUN mkdir /toolchain - -RUN curl --retry 5 -L https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--bleeding-edge-2021.11-1.tar.bz2 | \ - tar xjf - -C /toolchain --strip-components=1 -RUN /toolchain/relocate-sdk.sh +ARG TEST_UCLIBC_TIME64 +COPY install-uclibc.sh / +RUN /install-uclibc.sh "$TEST_UCLIBC_TIME64" ENV PATH=$PATH:/rust/bin:/toolchain/bin \ STAGING_DIR=/toolchain/armv7-buildroot-linux-uclibceabihf/sysroot \ diff --git a/ci/install-uclibc.sh b/ci/install-uclibc.sh new file mode 100755 index 000000000000..131f78f2065d --- /dev/null +++ b/ci/install-uclibc.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Installs the appropriate uclibc toolchain into /toolchain + +set -eux + +time64="$1" + +if [ "${time64:-0}" != "0" ]; then + version='bleeding-edge-2025.08-1' +else + version='bleeding-edge-2024.02-1' # last version with 32-bit time_t +fi + +mkdir /toolchain + +curl --retry 5 -L "https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--${version}.tar.bz2" | +tar xjf - -C /toolchain --strip-components=1 + +/toolchain/relocate-sdk.sh diff --git a/ci/run-docker.sh b/ci/run-docker.sh index b376e8538a92..4b46b59f7bec 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -44,6 +44,11 @@ run() { fi fi + if [ -n "${TEST_UCLIBC_TIME64:-}" ]; then + build_args+=("--build-arg=TEST_UCLIBC_TIME64=1") + export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_uclibc_time64" + fi + # use -f so we can use ci/ as build context docker build "${build_args[@]}" diff --git a/ci/run.sh b/ci/run.sh index ce6ca11f4439..d7578187b5fc 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -13,8 +13,9 @@ export RUSTFLAGS="${EXTRA_RUSTFLAGS:-} ${RUSTFLAGS:-}" echo "RUSTFLAGS: '$RUSTFLAGS'" -# For logging +# Print system and libc version for logging if available uname -a +dpkg -l | grep libc- || true cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}" test_flags="--skip check_style" diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index d276a34f09ff..3c982729828e 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -3,7 +3,6 @@ name = "libc-test" version = "0.1.0" description = "A test crate for the libc crate." publish = false -authors = ["The Rust Project Developers"] edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" diff --git a/libc-test/build.rs b/libc-test/build.rs index 6378b245a860..30ac2a1155c2 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1,4 +1,3 @@ -#![deny(warnings)] #![allow(clippy::match_like_matches_macro)] use std::fs::File; @@ -20,7 +19,7 @@ use std::{ fn do_cc() { let target = env::var("TARGET").unwrap(); if cfg!(unix) || target.contains("cygwin") { - let exclude = ["redox", "wasi", "wali"]; + let exclude = ["redox", "wasi", "wali", "qurt"]; if !exclude.iter().any(|x| target.contains(x)) { let mut cmsg = cc::Build::new(); @@ -76,6 +75,8 @@ fn do_ctest() { t if t.contains("windows") => test_windows(t), t if t.contains("vxworks") => test_vxworks(t), t if t.contains("nto-qnx") => test_neutrino(t), + // QuRT ctest requires a sched_yield stub (static inline in SDK). + t if t.contains("qurt") => return, t if t.contains("aix") => return test_aix(t), t => panic!("unknown target {t}"), } @@ -2339,6 +2340,9 @@ fn test_android(target: &str) { // Added in API level 26, but some tests use level 24. "endgrent" => true, + // Added in API level 26, but some tests use level 24. + "getpwent" | "setpwent" | "endpwent" => true, + // Added in API level 26, but some tests use level 24. "getdomainname" | "setdomainname" => true, @@ -2896,6 +2900,17 @@ fn test_freebsd(target: &str) { // Added in FreeBSD 15 "DTYPE_INOTIFY" | "DTYPE_JAILDESC" if Some(15) > freebsd_ver => true, + // Added in FreeBSD 15 + "PROC_LOGSIGEXIT_CTL" + | "PROC_LOGSIGEXIT_STATUS" + | "PROC_LOGSIGEXIT_CTL_NOFORCE" + | "PROC_LOGSIGEXIT_CTL_FORCE_ENABLE" + | "PROC_LOGSIGEXIT_CTL_FORCE_DISABLE" + if Some(15) > freebsd_ver => + { + true + } + _ => false, } }); @@ -3781,10 +3796,10 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { ) { (Ok(_), Ok(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), (Err(_), Err(_)) => (defaultbits.clone(), defaultbits.clone()), - (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb.clone()), + (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb), (Ok(tb), Err(_)) if tb == "32" => (tb, defaultbits.clone()), (Ok(_), Err(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), - (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), + (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits, fb), (Err(_), Ok(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), }; let valid_bits = ["32", "64"]; @@ -3882,6 +3897,12 @@ fn test_linux(target: &str) { cfg.cfg("musl_redir_time64", None); } } + let uclibc_use_time64 = env::var("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64") + .map(|val| val != "0") + .unwrap_or(false); + if uclibc && uclibc_use_time64 { + cfg.cfg("linux_time_bits64", None); + } cfg.define("_GNU_SOURCE", None) // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are // deprecated since glibc >= 2.29. This allows Rust binaries to link against @@ -3927,6 +3948,7 @@ fn test_linux(target: &str) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", + (gnu, "netiucv/iucv.h"), (l4re, "netpacket/packet.h"), "poll.h", "pthread.h", @@ -4085,9 +4107,14 @@ fn test_linux(target: &str) { "linux/wait.h", "linux/wireless.h", "sys/fanotify.h", - // is not present on uclibc - (!uclibc, "sys/auxv.h"), + "sys/auxv.h", (gnu || musl, "linux/close_range.h"), + (uclibc, "linux/fanotify.h"), + (uclibc, "linux/auxvec.h"), + (uclibc, "linux/close_range.h"), + (uclibc, "linux/if_packet.h"), + (uclibc, "linux/elf-em.h"), + (uclibc, "sys/resource.h"), ); } @@ -4326,6 +4353,18 @@ fn test_linux(target: &str) { // On 64 bits the size did not change, skip only for 32 bits. "ptrace_syscall_info" if pointer_width == 32 => true, + "canxl_frame" + | "fanotify_event_info_header" // not in sys/fanotify.h in uclibc + | "fanotify_event_info_fid" // not in sys/fanotify.h in uclibc + | "tls12_crypto_info_sm4_gcm" + | "tls12_crypto_info_sm4_ccm" + | "tls12_crypto_info_aria_gcm_128" + | "tls12_crypto_info_aria_gcm_256" + if uclibc => + { + true + } + _ => false, } }); @@ -4333,6 +4372,14 @@ fn test_linux(target: &str) { cfg.skip_const(move |constant| { let name = constant.ident(); + // FIXME(linux): Requires newer kernel headers than CI has. These uapi/linux/mount.h + // constants (OPEN_TREE_NAMESPACE landed in v7.0, FSCONFIG_CMD_CREATE_EXCL in v6.6) + // aren't defined by the headers CI builds against on several targets (notably the + // tier2 cross sysroots), so skip on every libc until CI catches up. + if name == "OPEN_TREE_NAMESPACE" || name == "FSCONFIG_CMD_CREATE_EXCL" { + return true; + } + // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but // somewhere in the core libraries. uClibc wants 16k, but that's not enough. if l4re && name == "PTHREAD_STACK_MIN" { @@ -4355,6 +4402,11 @@ fn test_linux(target: &str) { || name.starts_with("EPOLL") || name.starts_with("F_") || name.starts_with("FALLOC_FL_") + || name.starts_with("FSCONFIG_") + || name.starts_with("FSMOUNT_") + || name.starts_with("FSOPEN_") + || name.starts_with("FSPICK_") + || name.starts_with("FUTEX2_") || name.starts_with("IFLA_") || name.starts_with("KEXEC_") || name.starts_with("MS_") @@ -4440,6 +4492,8 @@ fn test_linux(target: &str) { | "PR_SCHED_CORE_SHARE_TO" => return true, /* Added in versions more recent than what we test */ + // Since 1.2.0 + "SO_DETACH_REUSEPORT_BPF" => return true, // Since 1.2.3 "SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" => return true, @@ -4453,6 +4507,172 @@ fn test_linux(target: &str) { } } + if uclibc { + match name { + // The canonical uClibc toolchain, bootlin bleeding-edge-2024.02-1, + // uses linux 5.15, so several constants are not available. + + // requires linux 5.16 + "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" + | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" + | "PR_SCHED_CORE_SCOPE_THREAD" + | "NF_NETDEV_EGRESS" + | "SO_RESERVE_MEM" => return true, + + // TLS_CIPHER_SM4_[GC]CM requires linux 5.16 + "TLS_CIPHER_SM4_CCM_IV_SIZE" + | "TLS_CIPHER_SM4_CCM_KEY_SIZE" + | "TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE" + | "TLS_CIPHER_SM4_CCM_SALT_SIZE" + | "TLS_CIPHER_SM4_CCM_TAG_SIZE" + | "TLS_CIPHER_SM4_CCM" + | "TLS_CIPHER_SM4_GCM_IV_SIZE" + | "TLS_CIPHER_SM4_GCM_KEY_SIZE" + | "TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE" + | "TLS_CIPHER_SM4_GCM_SALT_SIZE" + | "TLS_CIPHER_SM4_GCM_TAG_SIZE" + | "TLS_CIPHER_SM4_GCM" => return true, + + // requires linux 5.17 + "PR_SET_VMA_ANON_NAME" + | "PR_SET_VMA" + | "RTNLGRP_MCTP_IFADDR" => return true, + + // requires linux 5.18 + "RTNLGRP_STATS" + | "RTNLGRP_TUNNEL" + | "TLS_TX_ZEROCOPY_RO" + | "MADV_DONTNEED_LOCKED" + | "NFQA_PRIORITY" + | "SO_TXREHASH" => return true, + + // requires linux 5.19 + "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" + | "NLM_F_BULK" + | "SO_RCVMARK" + | "TLS_INFO_ZC_RO_TX" => return true, + + // CAN_* consts requiring linux 6.0 + "CAN_BUS_OFF_THRESHOLD" + | "CAN_CTRLMODE_TDC_AUTO" + | "CAN_CTRLMODE_TDC_MANUAL" + | "CAN_ERR_CNT" + | "CAN_ERROR_PASSIVE_THRESHOLD" + | "CAN_ERROR_WARNING_THRESHOLD" => return true, + + // requires linux 6.0 + "IFF_NO_CARRIER" + | "TLS_INFO_RX_NO_PAD" + | "TLS_RX_EXPECT_NO_PAD" => return true, + + // CAN_* consts requiring linux 6.1 + "CAN_RAW_XL_FRAMES" + | "CANXL_HDR_SIZE" + | "CANXL_MAX_DLC_MASK" + | "CANXL_MAX_DLC" + | "CANXL_MAX_DLEN" + | "CANXL_MAX_MTU" + | "CANXL_MIN_DLC" + | "CANXL_MIN_DLEN" + | "CANXL_MIN_MTU" + | "CANXL_MTU" + | "CANXL_PRIO_BITS" + | "CANXL_PRIO_MASK" + | "CANXL_SEC" + | "CANXL_XLF" => return true, + + // TLS_CIPHER_ARIA_GCM_* requires linux 6.1 + "TLS_CIPHER_ARIA_GCM_128_IV_SIZE" + | "TLS_CIPHER_ARIA_GCM_128_KEY_SIZE" + | "TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE" + | "TLS_CIPHER_ARIA_GCM_128_SALT_SIZE" + | "TLS_CIPHER_ARIA_GCM_128_TAG_SIZE" + | "TLS_CIPHER_ARIA_GCM_128" + | "TLS_CIPHER_ARIA_GCM_256_IV_SIZE" + | "TLS_CIPHER_ARIA_GCM_256_KEY_SIZE" + | "TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE" + | "TLS_CIPHER_ARIA_GCM_256_SALT_SIZE" + | "TLS_CIPHER_ARIA_GCM_256_TAG_SIZE" + | "TLS_CIPHER_ARIA_GCM_256" => return true, + + // requires linux 6.2 + "ALG_SET_KEY_BY_KEY_SERIAL" + | "PACKET_FANOUT_FLAG_IGNORE_OUTGOING" + | "SOF_TIMESTAMPING_OPT_ID_TCP" + | "TUN_F_USO4" + | "TUN_F_USO6" => return true, + + // FAN_* consts require kernel 6.3 + "FAN_INFO" + | "FAN_RESPONSE_INFO_AUDIT_RULE" + | "FAN_RESPONSE_INFO_NONE" => return true, + + // requires linux 6.3 + "MFD_EXEC" + | "MFD_NOEXEC_SEAL" + | "PR_GET_MDWE" + | "PR_SET_MDWE" => return true, + + // requires linux 6.4 + "PACKET_VNET_HDR_SZ" => return true, + "PR_GET_MEMORY_MERGE" => return true, + "PR_SET_MEMORY_MERGE" => return true, + + // requires linux 6.5 + "SO_PASSPIDFD" + | "SO_PEERPIDFD" => return true, + + // requires linux 6.6 + "PR_MDWE_NO_INHERIT" + | "PR_MDWE_REFUSE_EXEC_GAIN" => return true, + + // defined as a synonym for EM_ARC_COMPACT in gnu but not uclibc + "EM_ARC_A5" => return true, + + /* + Here are a list of kernel UAPI constants which appear in linux/ headers, + but cannot be imported due to conflicts with the uclibc headers. + The conflicting linux/ header is noted. + */ + // linux/signal.h + "BUS_MCEERR_AO" + | "BUS_MCEERR_AR" + // linux/termios.h + | "EXTPROC" + // linux/inotify.h + | "IN_MASK_CREATE" + // linux/in.h + | "IPPROTO_BEETPH" + | "IPPROTO_ETHERNET" + | "IPPROTO_MPLS" + | "IPPROTO_MPTCP" + // linux/in6.h + | "IPV6_HDRINCL" + | "IPV6_MULTICAST_ALL" + | "IPV6_PMTUDISC_INTERFACE" + | "IPV6_PMTUDISC_OMIT" + | "IPV6_ROUTER_ALERT_ISOLATE" + // linux/elf.h + | "NT_PRFPREG" + // linux/sem.h + | "SEM_STAT_ANY" + // linux/shm.h + | "SHM_EXEC" + // linux/signal.h + | "SI_DETHREAD" + | "TRAP_BRANCH" + | "TRAP_HWBKPT" + | "TRAP_UNK" + // linux/timerfd.h + | "TFD_TIMER_CANCEL_ON_SET" + // linux/udp.h + | "UDP_GRO" + | "UDP_SEGMENT" => return true, + + _ => (), + } + } + match name { // These constants are not available if gnu headers have been included // and can therefore not be tested here @@ -4506,6 +4726,9 @@ fn test_linux(target: &str) { // FIXME(linux): Not yet implemented on sparc64 "SYS_clone3" if sparc64 => true, + // FIXME(linux): Requires >= 6.9 kernel headers. + n if (arm || ppc32) && n.starts_with("FUTEX2_") => true, + // FIXME(linux): Not defined on ARM, gnueabihf, mips, musl, PowerPC, riscv64, s390x, and sparc64. "SYS_memfd_secret" if arm | gnueabihf | mips | musl | ppc | riscv64 | s390x | sparc64 => @@ -4516,25 +4739,6 @@ fn test_linux(target: &str) { // Skip as this signal codes and trap reasons need newer headers "TRAP_PERF" => true, - // kernel constants not available in uclibc 1.0.34 - "EXTPROC" - | "IPPROTO_BEETPH" - | "IPPROTO_MPLS" - | "IPV6_HDRINCL" - | "IPV6_MULTICAST_ALL" - | "IPV6_PMTUDISC_INTERFACE" - | "IPV6_PMTUDISC_OMIT" - | "IPV6_ROUTER_ALERT_ISOLATE" - | "PACKET_MR_UNICAST" - | "RUSAGE_THREAD" - | "SHM_EXEC" - | "UDP_GRO" - | "UDP_SEGMENT" - if uclibc => - { - true - } - // headers conflicts with linux/pidfd.h "PIDFD_NONBLOCK" => true, // Linux >= 6.9 @@ -4575,6 +4779,10 @@ fn test_linux(target: &str) { // value changed "NF_NETDEV_NUMHOOKS" if sparc64 => true, + // Canonical uclibc latest from toolchains.bootlin.com is based on kernel 5.15, + // so opt out of tests for constants which are different in later kernels. + "NF_NETDEV_NUMHOOKS" | "RLIM_NLIMITS" | "NFT_MSG_MAX" if uclibc => true, + // DIFF(main): fixed in 1.0 with e9abac9ac2 "CLONE_CLEAR_SIGHAND" | "CLONE_INTO_CGROUP" => true, @@ -4697,6 +4905,7 @@ fn test_linux(target: &str) { let c_enums = [ "can_state", + "fsconfig_command", "membarrier_cmd", "pid_type", "proc_cn_event", @@ -4790,12 +4999,15 @@ fn test_linux(target: &str) { "preadv2" | "pwritev2" if musl => true, // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. "statx" if musl => true, + // FIXME(musl): Supported since musl 1.2.6 but not yet in CI. + "renameat2" if musl => true, // Needs glibc 2.33 or later. "mallinfo2" => true, - // Not defined in uclibc as of 1.0.34 + // Not defined in uclibc as of 1.0.45 "gettid" if uclibc => true, + "getauxval" if uclibc => true, // pthread_sigqueue uses sigval, which was initially declared // as a struct but should be defined as a union. However due @@ -4933,7 +5145,7 @@ fn test_linux(target: &str) { // FIXME(linux): `max_phase_adj` requires >= 5.19 kernel headers // the rsv field shrunk when those fields got added, so is omitted too ("ptp_clock_caps", "adjust_phase" | "max_phase_adj" | "rsv") - if loongarch64 || sparc64 => + if loongarch64 || sparc64 || uclibc => { true } @@ -4950,7 +5162,7 @@ fn test_linux(target: &str) { ("bcm_msg_head", "frames") => true, // FAM ("af_alg_iv", "iv") => true, - ("file_handle", "f_handle") if musl => true, + ("file_handle", "f_handle") if musl || uclibc => true, // FIXME(ctest): ctest does not translate the rust code which computes the padding size ("pthread_cond_t", "__padding") if l4re => true, _ => false, @@ -5822,6 +6034,246 @@ fn test_aix(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } +// QuRT ctest is disabled: sched_yield is static inline in the SDK (no +// linkable symbol). A stub or --defsym is needed. The semver test works. +#[allow(dead_code)] +fn test_qurt(target: &str) { + assert!(target.contains("qurt")); + + let mut cfg = ctest_cfg(); + cfg.flag("-Wno-deprecated-declarations"); + + // QuRT POSIX headers are in the SDK, include paths are set via + // CFLAGS_hexagon_unknown_qurt in the test runner script. + headers!( + cfg, + "pthread.h", + "pthread_types.h", + "semaphore.h", + "signal.h", + "time.h", + "fcntl.h", + "sys/types.h", + "sys/sched.h", + "sys/errno.h", + "mqueue.h", + ); + + // QuRT doesn't have all the standard unix types/structs + cfg.skip_struct(|s| { + match s.ident() { + // 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, + } + }); + + cfg.skip_alias(|ty| { + match ty.ident() { + // Skip types not defined in QuRT POSIX headers + "intptr_t" | "uintptr_t" | "ptrdiff_t" | "size_t" | "ssize_t" | "time_t" + | "suseconds_t" | "useconds_t" | "timer_t" | "dev_t" | "ino_t" | "mode_t" + | "nlink_t" | "off_t" | "blkcnt_t" | "blksize_t" | "uid_t" | "gid_t" | "socklen_t" + | "sa_family_t" | "in_addr_t" | "in_port_t" | "fpos_t" | "clock_t" | "nfds_t" + | "va_list" | "c_schar" | "wchar_t" | "errno_t" | "rlim_t" | "speed_t" | "tcflag_t" + | "sighandler_t" => true, + // fd_set is defined in mqueue.h as a struct, but libc has it as c_ulong + "fd_set" => true, + // sem_t is a struct in QuRT but an alias in libc + "sem_t" => true, + // Skip internal/compatibility types + "FILE" => true, + // These are libc internal types + t if t.starts_with("__c_anonymous_") => true, + t if t.starts_with("__uint") => true, + _ => false, + } + }); + + cfg.skip_const(|c| { + let name = c.ident(); + match name { + // Skip constants not from QuRT POSIX headers + "EOK" | "PAGESIZE" | "PAGE_SIZE" | "L_tmpnam" | "TMP_MAX" | "FOPEN_MAX" => true, + // Skip DT_* directory entry constants (not in QuRT POSIX headers) + _ if name.starts_with("DT_") => true, + // Skip CLOCK_* that aren't in the QuRT time.h directly + "CLOCK_MONOTONIC_RAW" + | "CLOCK_REALTIME_COARSE" + | "CLOCK_MONOTONIC_COARSE" + | "CLOCK_BOOTTIME" => true, + // Skip signal constants not defined in QuRT signal.h + _ if name.starts_with("SIG") + && !matches!( + name, + "SIGKILL" + | "SIGRTMIN" + | "SIGRTMAX" + | "SIGEV_NONE" + | "SIGEV_SIGNAL" + | "SIGEV_THREAD" + | "SIG_BLOCK" + | "SIG_UNBLOCK" + | "SIG_SETMASK" + ) => + { + true + } + "SA_SIGINFO" => false, + // Skip SIG_DFL, SIG_IGN, SIG_ERR (function pointers, not simple ints) + "SIG_DFL" | "SIG_IGN" | "SIG_ERR" => true, + // Skip POSIX_MSG/POSIX_NOTIF + "POSIX_MSG" | "POSIX_NOTIF" => true, + // Skip errno constants (they come from toolchain errno.h, not QuRT-specific) + _ if name.starts_with("E") + && name.len() > 1 + && name + .chars() + .all(|c| c.is_ascii_uppercase() || c.is_ascii_digit()) => + { + true + } + // Skip O_* constants that use POSIX_ prefix in QuRT + _ if name.starts_with("O_") => true, + // Skip F_* fcntl constants + _ if name.starts_with("F_") && !name.starts_with("FD_") => true, + "FD_CLOEXEC" => true, + // Skip limits constants not in QuRT headers + _ if name.starts_with("CHAR_") + || name.starts_with("SCHAR_") + || name.starts_with("UCHAR_") => + { + true + } + _ if name.starts_with("INT_") || name.starts_with("UINT_") => true, + _ if name.starts_with("LONG_") || name.starts_with("ULONG_") => true, + _ if name.starts_with("SHRT_") || name.starts_with("USHRT_") => true, + "CHAR_BIT" | "IOV_MAX" => true, + _ if name.starts_with("ARG_MAX") + || name.starts_with("CHILD_MAX") + || name.starts_with("LINK_MAX") + || name.starts_with("MAX_") + || name.starts_with("NAME_MAX") + || name.starts_with("OPEN_MAX") + || name.starts_with("PATH_MAX") + || name.starts_with("PIPE_BUF") + || name.starts_with("STREAM_MAX") + || name.starts_with("TZNAME_MAX") => + { + true + } + // Skip stdio constants + "BUFSIZ" | "FILENAME_MAX" | "EOF" => true, + // Skip stdlib constants + "EXIT_SUCCESS" | "EXIT_FAILURE" | "RAND_MAX" => true, + // Skip dlfcn constants + _ if name.starts_with("RTLD_") || name == "DL_LAZY" => true, + // Skip mman constants + _ if name.starts_with("PROT_") + || name.starts_with("MAP_") + || name.starts_with("MS_") + || name.starts_with("MCL_") => + { + true + } + // Skip stat constants + _ if name.starts_with("S_I") || name == "S_IFMT" => true, + // Skip unistd constants + _ if name.starts_with("_PC_") || name.starts_with("_SC_") => true, + "F_OK" | "X_OK" | "W_OK" | "R_OK" => true, + "SEEK_SET" | "SEEK_CUR" | "SEEK_END" => true, + "STDIN_FILENO" | "STDOUT_FILENO" | "STDERR_FILENO" => true, + // Skip TIME_CONV_SCLK_FREQ (QuRT-specific, not a standard C constant) + "TIME_CONV_SCLK_FREQ" => true, + // Skip SEM_FAILED (null pointer constant) + "SEM_FAILED" => true, + // Skip MAP_FAILED + "MAP_FAILED" => true, + _ => false, + } + }); + + cfg.skip_fn(|func| { + let name = func.ident(); + match name { + // Skip functions not from QuRT POSIX headers we're testing + "strlen" | "strcpy" | "strncpy" | "strcat" | "strncat" | "strcmp" | "strncmp" + | "strcoll" | "strxfrm" | "strchr" | "strrchr" | "strspn" | "strcspn" | "strpbrk" + | "strstr" | "strtok" | "strerror" | "memchr" | "memcmp" | "memcpy" | "memmove" + | "memset" => true, + // Skip ctype functions + "isalnum" | "isalpha" | "iscntrl" | "isdigit" | "isgraph" | "islower" | "isprint" + | "ispunct" | "isspace" | "isupper" | "isxdigit" | "tolower" | "toupper" => true, + // Skip stdio functions + "fopen" | "freopen" | "fclose" | "fflush" | "fread" | "fwrite" | "fgetc" | "fputc" + | "getchar" | "putchar" | "ungetc" | "fgets" | "fputs" | "gets" | "puts" | "printf" + | "fprintf" | "sprintf" | "snprintf" | "vprintf" | "vfprintf" | "vsprintf" + | "vsnprintf" | "scanf" | "fscanf" | "sscanf" | "fseek" | "ftell" | "rewind" + | "fgetpos" | "fsetpos" | "clearerr" | "feof" | "ferror" | "perror" | "remove" + | "rename" | "tmpfile" | "tmpnam" | "setvbuf" | "setbuf" => true, + // Skip stdlib functions + "malloc" | "calloc" | "realloc" | "free" | "abort" | "exit" | "atexit" | "getenv" + | "setenv" | "unsetenv" | "atoi" | "atol" | "atoll" | "strtol" | "strtoul" + | "strtoll" | "strtoull" | "strtod" | "strtof" | "rand" | "srand" | "qsort" + | "bsearch" | "abs" | "labs" | "llabs" | "div" | "ldiv" | "lldiv" => true, + // Skip unistd functions: QuRT has no standard unistd.h in its POSIX + // headers; these are declared via sys/types.h -> hooks/unistd.h or the + // toolchain's own sys/unistd.h, neither of which ctest traverses. + "access" | "close" | "lseek" | "read" | "write" | "ftruncate" | "unlink" | "getcwd" + | "rmdir" | "getpid" | "getppid" | "getpgid" | "getpgrp" | "getuid" | "geteuid" + | "getgid" | "getegid" | "seteuid" | "setuid" | "setpgid" | "setpgrp" | "setsid" + | "fsync" | "pathconf" | "sleep" | "sysconf" => true, + // Skip dlfcn functions + "dlopen" | "dlclose" | "dlsym" | "dlerror" => true, + // Skip mman functions + "mmap" | "munmap" | "mprotect" | "mlock" | "munlock" | "mlockall" | "munlockall" + | "msync" => true, + // Skip stat functions + "stat" | "fstat" => true, + // Skip time functions (some are in generic headers, not QuRT posix) + "time" | "clock" | "difftime" | "mktime" | "gmtime" | "gmtime_r" | "localtime" + | "localtime_r" | "asctime" | "asctime_r" | "ctime" | "ctime_r" | "strftime" + | "strptime" | "nanosleep" => true, + // Skip signal functions that use sigaction (it's a macro in QuRT) + "sigaction" => true, + // Skip signal functions from generic toolchain headers + "signal" | "raise" => true, + // Skip dir functions + "opendir" | "readdir" | "closedir" | "mkdir" => true, + // Skip aligned_alloc / posix_memalign + "aligned_alloc" | "posix_memalign" => true, + // Skip clock_getcpuclockid + "clock_getcpuclockid" => true, + // Skip sem_open/sem_close/sem_unlink + "sem_open" | "sem_close" | "sem_unlink" => true, + // Skip __errno_location (QuRT-specific) + "__errno_location" => true, + // Skip _sigaction (internal) + "_sigaction" => true, + // pthread_equal is a static inline in QuRT + "pthread_equal" => true, + // sigtimedwait is not in QuRT POSIX libraries + "sigtimedwait" => true, + _ => false, + } + }); + + // Skip field checks for opaque types + cfg.skip_struct_field(|s, f| { + // pthread_attr_t bitfield can't be checked directly + s.ident() == "pthread_attr_t" && f.ident() == "__bitfield" + }); + + cfg.skip_roundtrip(|_| true); + + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); +} + /// Attempt to execute a command and collect its output, If the command fails for whatever /// reason, return `None`. fn try_command_output(cmd: &str, args: &[&str]) -> Option { diff --git a/libc-test/semver/TODO-linux.txt b/libc-test/semver/TODO-linux.txt index 98568ab0e974..4dee6991cd9f 100644 --- a/libc-test/semver/TODO-linux.txt +++ b/libc-test/semver/TODO-linux.txt @@ -35,7 +35,6 @@ SO_CNX_ADVICE SO_COOKIE SO_DETACH_BPF SO_DETACH_FILTER -SO_DETACH_REUSEPORT_BPF SO_GET_FILTER SO_INCOMING_CPU SO_INCOMING_NAPI_ID diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index e48c6d825856..11848f0c90bd 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -656,6 +656,14 @@ FS_IOC_GETFLAGS FS_IOC_GETVERSION FS_IOC_SETFLAGS FS_IOC_SETVERSION +FUTEX2_NUMA +FUTEX2_PRIVATE +FUTEX2_SIZE_MASK +FUTEX2_SIZE_U16 +FUTEX2_SIZE_U32 +FUTEX2_SIZE_U64 +FUTEX2_SIZE_U8 +FUTEX_32 FUTEX_CLOCK_REALTIME FUTEX_CMD_MASK FUTEX_CMP_REQUEUE @@ -668,6 +676,7 @@ FUTEX_REQUEUE FUTEX_TRYLOCK_PI FUTEX_UNLOCK_PI FUTEX_WAIT +FUTEX_WAITV_MAX FUTEX_WAIT_BITSET FUTEX_WAIT_REQUEUE_PI FUTEX_WAKE @@ -1936,6 +1945,15 @@ POSIX_FADV_NORMAL POSIX_FADV_RANDOM POSIX_FADV_SEQUENTIAL POSIX_FADV_WILLNEED +POSIX_SPAWN_CLOEXEC_DEFAULT +POSIX_SPAWN_RESETIDS +POSIX_SPAWN_SETPGROUP +POSIX_SPAWN_SETSCHEDPARAM +POSIX_SPAWN_SETSCHEDULER +POSIX_SPAWN_SETSID +POSIX_SPAWN_SETSIGDEF +POSIX_SPAWN_SETSIGMASK +POSIX_SPAWN_USEVFORK PRIO_MAX PRIO_MIN PRIO_PGRP @@ -3443,6 +3461,7 @@ dup dup2 duplocale endgrent +endpwent endservent epoll_create epoll_create1 @@ -3536,6 +3555,7 @@ ftell ftello ftruncate ftruncate64 +futex_waitv futimens fwrite fwrite_unlocked @@ -3573,6 +3593,7 @@ getppid getpriority getprotobyname getprotobynumber +getpwent getpwnam getpwnam_r getpwuid @@ -3960,6 +3981,7 @@ setlogmask setns setpgid setpriority +setpwent setregid setresgid setresuid @@ -4090,6 +4112,11 @@ tgkill time time_t timegm +timer_create +timer_delete +timer_getoverrun +timer_gettime +timer_settime timerfd_create timerfd_gettime timerfd_settime diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 2a7e1ddb3ddb..1972308793dc 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -358,6 +358,7 @@ ENOPOLICY ENOSR ENOSTR ENOTBLK +ENOTCAPABLE ENOTRECOVERABLE ENOTSUP EOF @@ -380,6 +381,7 @@ ETIME ETOOMANYREFS EUSERS EVFILT_AIO +EVFILT_EXCEPT EVFILT_FS EVFILT_MACHPORT EVFILT_PROC @@ -395,6 +397,7 @@ EV_CLEAR EV_DELETE EV_DISABLE EV_DISPATCH +EV_DISPATCH2 EV_ENABLE EV_EOF EV_ERROR @@ -405,6 +408,8 @@ EV_OOBAND EV_POLL EV_RECEIPT EV_SYSFLAGS +EV_UDATA_SPECIFIC +EV_VANISHED EXTA EXTB EXTPROC @@ -1007,6 +1012,9 @@ NOTE_FFLAGSMASK NOTE_FFNOP NOTE_FFOR NOTE_FORK +NOTE_FUNLOCK +NOTE_LEASE_DOWNGRADE +NOTE_LEASE_RELEASE NOTE_LEEWAY NOTE_LINK NOTE_LOWAT @@ -1014,6 +1022,7 @@ NOTE_MACHTIME NOTE_MACH_CONTINUOUS_TIME NOTE_NONE NOTE_NSECONDS +NOTE_OOB NOTE_PCTRLMASK NOTE_PDATAMASK NOTE_RENAME @@ -2170,6 +2179,7 @@ posix_spawnattr_t posix_spawnp preadv proc_bsdinfo +proc_bsdshortinfo proc_kmsgbuf proc_libversion proc_listallpids diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 79a81624074c..866c29160a0e 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1054,6 +1054,12 @@ POSIX_SPAWN_SETSCHEDULER POSIX_SPAWN_SETSIGDEF POSIX_SPAWN_SETSIGMASK PPPDISC +PPROT_CLEAR +PPROT_DESCEND +PPROT_FLAGS +PPROT_INHERIT +PPROT_OP +PPROT_SET PROC_NO_NEW_PRIVS_CTL PROC_NO_NEW_PRIVS_DISABLE PROC_NO_NEW_PRIVS_ENABLE @@ -1451,6 +1457,7 @@ SOCK_MAXADDRLEN SOCK_NONBLOCK SOCK_RAW SOCK_RDM +SOL_LOCAL SOMAXCONN SO_ACCEPTFILTER SO_BINTIME diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index 54c3afbfbf90..f66ee1d87322 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -3,6 +3,8 @@ F_DUP2FD_CLOEXEC F_DUP2FD_CLOFORK F_DUP3FD F_DUPFD_CLOFORK +IPV6_MINHOPCOUNT +IP_MINTTL MSG_CMSG_CLOEXEC MSG_CMSG_CLOFORK O_CLOFORK diff --git a/libc-test/semver/linux-aarch64.txt b/libc-test/semver/linux-aarch64.txt index c4bce0196f8a..03a312bcc13d 100644 --- a/libc-test/semver/linux-aarch64.txt +++ b/libc-test/semver/linux-aarch64.txt @@ -76,6 +76,7 @@ SKF_NET_OFF SO_PRIORITY SO_PROTOCOL SYS_accept +SYS_fadvise64 SYS_fstat SYS_msgctl SYS_msgget @@ -90,6 +91,7 @@ SYS_semctl SYS_semget SYS_semop SYS_semtimedop +SYS_sendfile SYS_setrlimit SYS_shmat SYS_shmctl diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index d8cf94d3512c..9c5553975c6a 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -342,6 +342,7 @@ O_FSYNC PF_IB PF_MPLS PF_XDP +POSIX_SPAWN_SETSID PROC_SUPER_MAGIC PR_SET_VMA PR_SET_VMA_ANON_NAME diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 397135477743..32a26960dacb 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -28,6 +28,7 @@ OLD_TIME PF_IB PF_MPLS PF_XDP +POSIX_SPAWN_SETSID PR_SET_VMA PR_SET_VMA_ANON_NAME RUN_LVL @@ -87,6 +88,7 @@ pututxline pwritev2 pwritev64 reallocarray +renameat2 setutxent tcp_info timex diff --git a/libc-test/semver/linux-riscv64gc.txt b/libc-test/semver/linux-riscv64gc.txt index 3f0f93a13ac1..0b5f408e2e26 100644 --- a/libc-test/semver/linux-riscv64gc.txt +++ b/libc-test/semver/linux-riscv64gc.txt @@ -30,6 +30,9 @@ NFT_MSG_DELOBJ NFT_MSG_GETOBJ NFT_MSG_GETOBJ_RESET NFT_MSG_NEWOBJ +PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP +PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP +PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP SCM_TIMESTAMPNS SCM_WIFI_STATUS SIGSTKFLT diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 646696e43cde..bee77aa7564f 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -898,6 +898,21 @@ FIONCLEX FIONREAD FLUSHO FOPEN_MAX +FSCONFIG_CMD_CREATE +FSCONFIG_CMD_CREATE_EXCL +FSCONFIG_CMD_RECONFIGURE +FSCONFIG_SET_BINARY +FSCONFIG_SET_FD +FSCONFIG_SET_FLAG +FSCONFIG_SET_PATH +FSCONFIG_SET_PATH_EMPTY +FSCONFIG_SET_STRING +FSMOUNT_CLOEXEC +FSOPEN_CLOEXEC +FSPICK_CLOEXEC +FSPICK_EMPTY_PATH +FSPICK_NO_AUTOMOUNT +FSPICK_SYMLINK_NOFOLLOW FS_IOC32_GETFLAGS FS_IOC32_GETVERSION FS_IOC32_SETFLAGS @@ -906,6 +921,14 @@ FS_IOC_GETFLAGS FS_IOC_GETVERSION FS_IOC_SETFLAGS FS_IOC_SETVERSION +FUTEX2_NUMA +FUTEX2_PRIVATE +FUTEX2_SIZE_MASK +FUTEX2_SIZE_U16 +FUTEX2_SIZE_U32 +FUTEX2_SIZE_U64 +FUTEX2_SIZE_U8 +FUTEX_32 FUTEX_BITSET_MATCH_ANY FUTEX_CLOCK_REALTIME FUTEX_CMD_MASK @@ -935,6 +958,7 @@ FUTEX_TRYLOCK_PI FUTEX_UNLOCK_PI FUTEX_WAIT FUTEX_WAITERS +FUTEX_WAITV_MAX FUTEX_WAIT_BITSET FUTEX_WAIT_REQUEUE_PI FUTEX_WAKE @@ -2193,6 +2217,7 @@ OFILL OLCUC OPEN_TREE_CLOEXEC OPEN_TREE_CLONE +OPEN_TREE_NAMESPACE O_ASYNC O_DIRECT O_DSYNC @@ -2366,7 +2391,6 @@ POSIX_SPAWN_RESETIDS POSIX_SPAWN_SETPGROUP POSIX_SPAWN_SETSCHEDPARAM POSIX_SPAWN_SETSCHEDULER -POSIX_SPAWN_SETSID POSIX_SPAWN_SETSIGDEF POSIX_SPAWN_SETSIGMASK POSIX_SPAWN_USEVFORK @@ -3179,6 +3203,7 @@ SO_BINDTODEVICE SO_BUF_LOCK SO_BUSY_POLL SO_BUSY_POLL_BUDGET +SO_DETACH_REUSEPORT_BPF SO_DEVMEM_DMABUF SO_DEVMEM_DONTNEED SO_DEVMEM_LINEAR @@ -3294,6 +3319,7 @@ SYS_fstatfs SYS_fsync SYS_ftruncate SYS_futex +SYS_futex_waitv SYS_get_mempolicy SYS_get_robust_list SYS_getcpu @@ -4096,6 +4122,7 @@ freeifaddrs freelocale fremovexattr freopen64 +fsconfig_command fseeko64 fsetpos64 fsetxattr @@ -4108,6 +4135,7 @@ fstatvfs64 ftello64 ftok ftruncate64 +futex_waitv genlmsghdr getdomainname getdtablesize diff --git a/libc-test/semver/qurt.txt b/libc-test/semver/qurt.txt new file mode 100644 index 000000000000..289874aa3e35 --- /dev/null +++ b/libc-test/semver/qurt.txt @@ -0,0 +1,469 @@ +ARG_MAX +BUFSIZ +CHAR_BIT +CHAR_MAX +CHAR_MIN +CHILD_MAX +CLOCK_BOOTTIME +CLOCK_MONOTONIC_COARSE +CLOCK_MONOTONIC_RAW +CLOCK_PROCESS_CPUTIME_ID +CLOCK_REALTIME_COARSE +CLOCK_THREAD_CPUTIME_ID +DL_LAZY +DT_UNKNOWN +EADV +EBADE +EBADFD +EBADR +EBADRQC +EBADSLT +EBFONT +ECHRNG +ECOMM +EDEADLOCK +EDOTDOT +EHWPOISON +EISNAM +EKEYEXPIRED +EKEYREJECTED +EKEYREVOKED +EL2HLT +EL2NSYNC +EL3HLT +EL3RST +ELIBACC +ELIBBAD +ELIBEXEC +ELIBMAX +ELIBSCN +ELNRNG +EMEDIUMTYPE +EMULTIHOP +ENAVAIL +ENOANO +ENOCSI +ENODATA +ENOKEY +ENOLINK +ENOMEDIUM +ENONET +ENOPKG +ENOSR +ENOSTR +ENOTBLK +ENOTNAM +ENOTRECOVERABLE +ENOTSUP +ENOTUNIQ +EOF +EOK +EOWNERDEAD +EREMCHG +EREMOTE +EREMOTEIO +ERESTART +ERFKILL +ESOCKTNOSUPPORT +ESRMNT +ESTRPIPE +ETIME +ETOOMANYREFS +EUCLEAN +EUNATCH +EUSERS +EXFULL +FILENAME_MAX +FOPEN_MAX +F_RDLCK +F_UNLCK +F_WRLCK +IOV_MAX +LINK_MAX +LONG_MAX +LONG_MIN +L_tmpnam +MAP_FILE +MAP_HASSEMAPHORE +MAP_INHERIT +MAP_NORESERVE +MAP_RENAME +MAP_TRYFIXED +MAP_WIRED +MAX_CANON +MAX_INPUT +MCL_CURRENT +MCL_FUTURE +MQ_PRIO_DEFAULT +NAME_MAX +NBBY +NFDBITS +OPEN_MAX +O_DSYNC +O_FSYNC +O_NOCTTY +O_SYNC +PAGESIZE +PAGE_SIZE +PIPE_BUF +POSIX_MSG +POSIX_NOTIF +PTHREAD_CREATE_DETACHED +PTHREAD_CREATE_JOINABLE +PTHREAD_DEFAULT_PRIORITY +PTHREAD_DEFAULT_STACKSIZE +PTHREAD_EXPLICIT_SCHED +PTHREAD_INHERIT_SCHED +PTHREAD_MAX_PRIORITY +PTHREAD_MAX_STACKSIZE +PTHREAD_MAX_THREADS +PTHREAD_MIN_PRIORITY +PTHREAD_MIN_STACKSIZE +PTHREAD_MUTEX_DEFAULT +PTHREAD_MUTEX_ERRORCHECK +PTHREAD_NAME_LEN +PTHREAD_ONCE_INIT +PTHREAD_PRIO_INHERIT +PTHREAD_PRIO_NONE +PTHREAD_PRIO_PROTECT +PTHREAD_PROCESS_PRIVATE +PTHREAD_PROCESS_SHARED +PTHREAD_SCOPE_PROCESS +PTHREAD_SCOPE_SYSTEM +PTHREAD_SPINLOCK_LOCKED +PTHREAD_SPINLOCK_UNLOCKED +PTHREAD_STACK_MIN +RAND_MAX +RTLD_NEXT +RTLD_SELF +SCHAR_MAX +SCHAR_MIN +SCHED_FIFO +SCHED_OTHER +SCHED_RR +SCHED_SPORADIC +SEM_FAILED +SHRT_MAX +SHRT_MIN +SIGEV_NONE +SIGEV_SIGNAL +SIGEV_THREAD +SIGIO +SIGPOLL +SIGPWR +SIGRTMAX +SIGRTMIN +SIGSTKFLT +STREAM_MAX +TIME_CONV_SCLK_FREQ +TMP_MAX +TZNAME_MAX +UCHAR_MAX +UINT_MAX +ULONG_MAX +USHRT_MAX +_PC_2_SYMLINKS +_PC_ALLOC_SIZE_MIN +_PC_ASYNC_IO +_PC_FILESIZEBITS +_PC_PRIO_IO +_PC_REC_INCR_XFER_SIZE +_PC_REC_MAX_XFER_SIZE +_PC_REC_MIN_XFER_SIZE +_PC_REC_XFER_ALIGN +_PC_SOCK_MAXBUF +_PC_SYMLINK_MAX +_PC_SYNC_IO +_SC_2_CHAR_TERM +_SC_2_C_BIND +_SC_2_C_DEV +_SC_2_C_VERSION +_SC_2_FORT_DEV +_SC_2_FORT_RUN +_SC_2_LOCALEDEF +_SC_2_PBS +_SC_2_PBS_ACCOUNTING +_SC_2_PBS_CHECKPOINT +_SC_2_PBS_LOCATE +_SC_2_PBS_MESSAGE +_SC_2_PBS_TRACK +_SC_2_SW_DEV +_SC_2_UPE +_SC_2_VERSION +_SC_ADVISORY_INFO +_SC_AIO_LISTIO_MAX +_SC_AIO_MAX +_SC_AIO_PRIO_DELTA_MAX +_SC_ASYNCHRONOUS_IO +_SC_ATEXIT_MAX +_SC_AVPHYS_PAGES +_SC_BARRIERS +_SC_BC_BASE_MAX +_SC_BC_DIM_MAX +_SC_BC_SCALE_MAX +_SC_BC_STRING_MAX +_SC_CHARCLASS_NAME_MAX +_SC_CHAR_BIT +_SC_CHAR_MAX +_SC_CHAR_MIN +_SC_CLOCK_SELECTION +_SC_COLL_WEIGHTS_MAX +_SC_CPUTIME +_SC_DELAYTIMER_MAX +_SC_EQUIV_CLASS_MAX +_SC_EXPR_NEST_MAX +_SC_FSYNC +_SC_GETGR_R_SIZE_MAX +_SC_GETPW_R_SIZE_MAX +_SC_INT_MAX +_SC_INT_MIN +_SC_IOV_MAX +_SC_IPV6 +_SC_JOB_CONTROL +_SC_LINE_MAX +_SC_LOGIN_NAME_MAX +_SC_LONG_BIT +_SC_MAPPED_FILES +_SC_MB_LEN_MAX +_SC_MEMLOCK +_SC_MEMLOCK_RANGE +_SC_MEMORY_PROTECTION +_SC_MESSAGE_PASSING +_SC_MONOTONIC_CLOCK +_SC_MQ_OPEN_MAX +_SC_MQ_PRIO_MAX +_SC_NL_ARGMAX +_SC_NL_LANGMAX +_SC_NL_MSGMAX +_SC_NL_NMAX +_SC_NL_SETMAX +_SC_NL_TEXTMAX +_SC_NPROCESSORS_CONF +_SC_NPROCESSORS_ONLN +_SC_NZERO +_SC_PASS_MAX +_SC_PHYS_PAGES +_SC_PII +_SC_PII_INTERNET +_SC_PII_INTERNET_DGRAM +_SC_PII_INTERNET_STREAM +_SC_PII_OSI +_SC_PII_OSI_CLTS +_SC_PII_OSI_COTS +_SC_PII_OSI_M +_SC_PII_SOCKET +_SC_PII_XTI +_SC_POLL +_SC_PRIORITIZED_IO +_SC_PRIORITY_SCHEDULING +_SC_RAW_SOCKETS +_SC_READER_WRITER_LOCKS +_SC_REALTIME_SIGNALS +_SC_REGEXP +_SC_RE_DUP_MAX +_SC_RTSIG_MAX +_SC_SAVED_IDS +_SC_SCHAR_MAX +_SC_SCHAR_MIN +_SC_SELECT +_SC_SEMAPHORES +_SC_SEM_NSEMS_MAX +_SC_SEM_VALUE_MAX +_SC_SHARED_MEMORY_OBJECTS +_SC_SHELL +_SC_SHRT_MAX +_SC_SHRT_MIN +_SC_SIGQUEUE_MAX +_SC_SPAWN +_SC_SPIN_LOCKS +_SC_SPORADIC_SERVER +_SC_SSIZE_MAX +_SC_SS_REPL_MAX +_SC_SYNCHRONIZED_IO +_SC_THREADS +_SC_THREAD_ATTR_STACKADDR +_SC_THREAD_ATTR_STACKSIZE +_SC_THREAD_CPUTIME +_SC_THREAD_DESTRUCTOR_ITERATIONS +_SC_THREAD_KEYS_MAX +_SC_THREAD_PRIORITY_SCHEDULING +_SC_THREAD_PRIO_INHERIT +_SC_THREAD_PRIO_PROTECT +_SC_THREAD_PROCESS_SHARED +_SC_THREAD_ROBUST_PRIO_INHERIT +_SC_THREAD_ROBUST_PRIO_PROTECT +_SC_THREAD_SAFE_FUNCTIONS +_SC_THREAD_SPORADIC_SERVER +_SC_THREAD_STACK_MIN +_SC_THREAD_THREADS_MAX +_SC_TIMEOUTS +_SC_TIMERS +_SC_TIMER_MAX +_SC_TRACE +_SC_TRACE_EVENT_FILTER +_SC_TRACE_EVENT_NAME_MAX +_SC_TRACE_INHERIT +_SC_TRACE_LOG +_SC_TRACE_NAME_MAX +_SC_TRACE_SYS_MAX +_SC_TRACE_USER_EVENT_MAX +_SC_TYPED_MEMORY_OBJECTS +_SC_T_IOV_MAX +_SC_UCHAR_MAX +_SC_UINT_MAX +_SC_UIO_MAXIOV +_SC_ULONG_MAX +_SC_USHRT_MAX +_SC_V6_ILP32_OFF32 +_SC_V6_ILP32_OFFBIG +_SC_V6_LP64_OFF64 +_SC_V6_LPBIG_OFFBIG +_SC_V7_ILP32_OFF32 +_SC_V7_ILP32_OFFBIG +_SC_V7_LP64_OFF64 +_SC_V7_LPBIG_OFFBIG +_SC_WORD_BIT +_SC_XBS5_ILP32_OFF32 +_SC_XBS5_ILP32_OFFBIG +_SC_XBS5_LP64_OFF64 +_SC_XBS5_LPBIG_OFFBIG +_SC_XOPEN_CRYPT +_SC_XOPEN_ENH_I18N +_SC_XOPEN_LEGACY +_SC_XOPEN_REALTIME +_SC_XOPEN_REALTIME_THREADS +_SC_XOPEN_SHM +_SC_XOPEN_STREAMS +_SC_XOPEN_UNIX +_SC_XOPEN_VERSION +_SC_XOPEN_XCU_VERSION +_SC_XOPEN_XPG2 +_SC_XOPEN_XPG3 +_SC_XOPEN_XPG4 +__errno_location +_sigaction +abs +asctime +asctime_r +bsearch +clearerr +clock +clock_getcpuclockid +cpu_set_t +ctime +ctime_r +difftime +div +div_t +errno_t +gets +itimerspec +labs +ldiv +ldiv_t +llabs +lldiv +lldiv_t +mq_attr +mq_close +mq_getattr +mq_open +mq_receive +mq_send +mq_setattr +mq_timedreceive +mq_timedsend +mq_unlink +mqd_t +pthread_attr_getaffinity_np +pthread_attr_getdetachstate +pthread_attr_getguardsize +pthread_attr_getinheritsched +pthread_attr_getschedparam +pthread_attr_getscope +pthread_attr_getstack +pthread_attr_getstackaddr +pthread_attr_getthreadname +pthread_attr_gettimetestid +pthread_attr_setaffinity_np +pthread_attr_setautostack +pthread_attr_setbuspriority +pthread_attr_setinheritsched +pthread_attr_setschedparam +pthread_attr_setscope +pthread_attr_setstack +pthread_attr_setstackaddr +pthread_attr_setthreadname +pthread_attr_settimetestid +pthread_barrier_destroy +pthread_barrier_init +pthread_barrier_t +pthread_barrier_wait +pthread_barrierattr_destroy +pthread_barrierattr_getpshared +pthread_barrierattr_init +pthread_barrierattr_setpshared +pthread_barrierattr_t +pthread_cancel +pthread_condattr_getclock +pthread_condattr_getpshared +pthread_condattr_setclock +pthread_condattr_setpshared +pthread_getattr_np +pthread_getname_np +pthread_getschedparam +pthread_kill +pthread_mutex_getprioceiling +pthread_mutex_setprioceiling +pthread_mutexattr_getprioceiling +pthread_mutexattr_getprotocol +pthread_mutexattr_getpshared +pthread_mutexattr_gettype +pthread_mutexattr_setprioceiling +pthread_mutexattr_setprotocol +pthread_mutexattr_setpshared +pthread_once +pthread_once_t +pthread_rwlockattr_getpshared +pthread_rwlockattr_setpshared +pthread_setcancelstate +pthread_setcanceltype +pthread_setschedparam +pthread_setschedprio +pthread_spin_destroy +pthread_spin_init +pthread_spin_lock +pthread_spin_trylock +pthread_spin_unlock +pthread_spinlock_t +qsort +rand +sched_get_priority_max +sched_get_priority_min +sched_param +sem_close +sem_destroy +sem_getvalue +sem_init +sem_open +sem_unlink +setpgrp +sigevent +siginfo_t +sigsuspend +sigtimedwait +sigwait +srand +strftime +strptime +timer_create +timer_delete +timer_gettime +timer_settime +timer_t +useconds_t +va_list +vfprintf +vprintf +vsnprintf +vsprintf diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 95d289f9da41..ef9caaed63e4 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -4,7 +4,12 @@ ATF_COM ATF_PERM ATF_PUBL ATF_USETRAILERS +AT_EACCESS +AT_EMPTY_PATH AT_FDCWD +AT_REMOVEDIR +AT_SYMLINK_FOLLOW +AT_SYMLINK_NOFOLLOW B1000000 B1152000 B1500000 @@ -140,6 +145,7 @@ O_NOCTTY O_PATH O_SHLOCK O_SYMLINK +O_SYNC PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_ROBUST @@ -199,6 +205,8 @@ TCSETS TIOCGPGRP TIOCSCTTY TIOCSPGRP +UTIME_NOW +UTIME_OMIT UTSLENGTH VDISCARD VLNEXT @@ -291,6 +299,8 @@ __errno_location bsearch chroot clearerr +clock_getres +clock_gettime difftime dirfd endgrent @@ -302,7 +312,9 @@ epoll_ctl epoll_event epoll_wait explicit_bzero +faccessat fchdir +fdopendir fmemopen getdtablesize getgrent @@ -325,11 +337,14 @@ lockf login_tty madvise memalign +mkdirat +mknodat mkostemp mkostemps nice open_memstream open_wmemstream +openat openpty pipe2 pthread_condattr_setclock @@ -337,6 +352,7 @@ qsort reallocarray renameat2 rlim_t +seekdir sem_clockwait sem_destroy sem_getvalue @@ -363,3 +379,4 @@ strncasecmp strndup strsignal ttyname_r +utimensat diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index 9b1931c5a24f..13af17a0a7a5 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -3,6 +3,7 @@ AIO_CANCELED AIO_NOTCANCELED IPV6_BOUND_IF IPV6_DONTFRAG +IPV6_HOPLIMIT IPV6_PKTINFO IPV6_RECVTCLASS IPV6_TCLASS diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 3e35faa7b711..53b5e2ed207c 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -2985,15 +2985,11 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in cpuset.bits.iter_mut() { - *slot = 0; - } + cpuset.bits.fill(0); } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { @@ -3026,9 +3022,9 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as size_t) < size_of::() { - core::ptr::null_mut::() + ptr::null_mut() } else if __CMSG_NEXT(cmsg).add(size_of::()) >= __MHDR_END(mhdr) { - core::ptr::null_mut::() + ptr::null_mut() } else { __CMSG_NEXT(cmsg).cast() } @@ -3038,7 +3034,7 @@ f! { if (*mhdr).msg_controllen as size_t >= size_of::() { (*mhdr).msg_control.cast() } else { - core::ptr::null_mut::() + ptr::null_mut() } } diff --git a/src/new/apple/mod.rs b/src/new/apple/mod.rs index beb8caab63c2..1708cc36f1e9 100644 --- a/src/new/apple/mod.rs +++ b/src/new/apple/mod.rs @@ -16,5 +16,4 @@ mod xnu; pub(crate) use libc::*; pub(crate) use libpthread::pthread_; -pub(crate) use pthread_::pthread; pub(crate) use xnu::*; diff --git a/src/new/l4re/mod.rs b/src/new/l4re/mod.rs index cbf725f406b6..1c5c8855e7f4 100644 --- a/src/new/l4re/mod.rs +++ b/src/new/l4re/mod.rs @@ -1,3 +1,5 @@ //! L4re. //! //! * Headers: + +pub(crate) mod packet; diff --git a/src/new/l4re/packet.rs b/src/new/l4re/packet.rs new file mode 100644 index 000000000000..f9df7997ffa1 --- /dev/null +++ b/src/new/l4re/packet.rs @@ -0,0 +1,29 @@ +//! Header: `netpacket/packet.h` + +use crate::prelude::*; + +pub const PACKET_HOST: c_uchar = 0; +pub const PACKET_BROADCAST: c_uchar = 1; +pub const PACKET_MULTICAST: c_uchar = 2; +pub const PACKET_OTHERHOST: c_uchar = 3; +pub const PACKET_OUTGOING: c_uchar = 4; +pub const PACKET_LOOPBACK: c_uchar = 5; + +pub const PACKET_ADD_MEMBERSHIP: c_int = 1; +pub const PACKET_DROP_MEMBERSHIP: c_int = 2; +pub const PACKET_RECV_OUTPUT: c_int = 3; +pub const PACKET_RX_RING: c_int = 5; +pub const PACKET_STATISTICS: c_int = 6; + +s! { + pub struct packet_mreq { + pub mr_ifindex: c_int, + pub mr_type: c_ushort, + pub mr_alen: c_ushort, + pub mr_address: [c_uchar; 8], + } +} + +pub const PACKET_MR_MULTICAST: c_int = 0; +pub const PACKET_MR_PROMISC: c_int = 1; +pub const PACKET_MR_ALLMULTI: c_int = 2; diff --git a/src/new/linux_uapi/linux/if_link.rs b/src/new/linux_uapi/linux/if_link.rs new file mode 100644 index 000000000000..2c9bb5216867 --- /dev/null +++ b/src/new/linux_uapi/linux/if_link.rs @@ -0,0 +1,83 @@ +//! Header: `uapi/linux/if_link.h` + +use crate::prelude::*; + +c_enum! { + #[repr(c_ushort)] + pub enum #anon { + pub IFLA_UNSPEC, + pub IFLA_ADDRESS, + pub IFLA_BROADCAST, + pub IFLA_IFNAME, + pub IFLA_MTU, + pub IFLA_LINK, + pub IFLA_QDISC, + pub IFLA_STATS, + pub IFLA_COST, + pub IFLA_PRIORITY, + pub IFLA_MASTER, + pub IFLA_WIRELESS, + pub IFLA_PROTINFO, + pub IFLA_TXQLEN, + pub IFLA_MAP, + pub IFLA_WEIGHT, + pub IFLA_OPERSTATE, + pub IFLA_LINKMODE, + pub IFLA_LINKINFO, + pub IFLA_NET_NS_PID, + pub IFLA_IFALIAS, + pub IFLA_NUM_VF, + pub IFLA_VFINFO_LIST, + pub IFLA_STATS64, + pub IFLA_VF_PORTS, + pub IFLA_PORT_SELF, + pub IFLA_AF_SPEC, + pub IFLA_GROUP, + pub IFLA_NET_NS_FD, + pub IFLA_EXT_MASK, + pub IFLA_PROMISCUITY, + pub IFLA_NUM_TX_QUEUES, + pub IFLA_NUM_RX_QUEUES, + pub IFLA_CARRIER, + pub IFLA_PHYS_PORT_ID, + pub IFLA_CARRIER_CHANGES, + pub IFLA_PHYS_SWITCH_ID, + pub IFLA_LINK_NETNSID, + pub IFLA_PHYS_PORT_NAME, + pub IFLA_PROTO_DOWN, + pub IFLA_GSO_MAX_SEGS, + pub IFLA_GSO_MAX_SIZE, + pub IFLA_PAD, + pub IFLA_XDP, + pub IFLA_EVENT, + pub IFLA_NEW_NETNSID, + pub IFLA_IF_NETNSID, + pub IFLA_TARGET_NETNSID = IFLA_IF_NETNSID, + pub IFLA_CARRIER_UP_COUNT, + pub IFLA_CARRIER_DOWN_COUNT, + pub IFLA_NEW_IFINDEX, + pub IFLA_MIN_MTU, + pub IFLA_MAX_MTU, + pub IFLA_PROP_LIST, + pub IFLA_ALT_IFNAME, + pub IFLA_PERM_ADDRESS, + pub IFLA_PROTO_DOWN_REASON, + + pub IFLA_PARENT_DEV_NAME, + pub IFLA_PARENT_DEV_BUS_NAME, + pub IFLA_GRO_MAX_SIZE, + pub IFLA_TSO_MAX_SIZE, + pub IFLA_TSO_MAX_SEGS, + pub IFLA_ALLMULTI, + } + + #[repr(c_ushort)] + pub enum #anon { + pub IFLA_INFO_UNSPEC, + pub IFLA_INFO_KIND, + pub IFLA_INFO_DATA, + pub IFLA_INFO_XSTATS, + pub IFLA_INFO_SLAVE_KIND, + pub IFLA_INFO_SLAVE_DATA, + } +} diff --git a/src/new/linux_uapi/linux/if_packet.rs b/src/new/linux_uapi/linux/if_packet.rs new file mode 100644 index 000000000000..9c8b8dcfbe65 --- /dev/null +++ b/src/new/linux_uapi/linux/if_packet.rs @@ -0,0 +1,257 @@ +//! Header: `uapi/linux/if_packet.h` + +use crate::prelude::*; + +s! { + #[deprecated(since = "0.2.70", note = "sockaddr_ll type should be used instead")] + pub struct sockaddr_pkt { + pub spkt_family: c_ushort, + pub spkt_device: [c_uchar; 14], + pub spkt_protocol: c_ushort, + } +} + +pub const PACKET_HOST: c_uchar = 0; +pub const PACKET_BROADCAST: c_uchar = 1; +pub const PACKET_MULTICAST: c_uchar = 2; +pub const PACKET_OTHERHOST: c_uchar = 3; +pub const PACKET_OUTGOING: c_uchar = 4; +pub const PACKET_LOOPBACK: c_uchar = 5; +pub const PACKET_USER: c_uchar = 6; +pub const PACKET_KERNEL: c_uchar = 7; + +pub const PACKET_ADD_MEMBERSHIP: c_int = 1; +pub const PACKET_DROP_MEMBERSHIP: c_int = 2; +pub const PACKET_RECV_OUTPUT: c_int = 3; +pub const PACKET_RX_RING: c_int = 5; +pub const PACKET_STATISTICS: c_int = 6; +pub const PACKET_COPY_THRESH: c_int = 7; +pub const PACKET_AUXDATA: c_int = 8; +pub const PACKET_ORIGDEV: c_int = 9; +pub const PACKET_VERSION: c_int = 10; +pub const PACKET_HDRLEN: c_int = 11; +pub const PACKET_RESERVE: c_int = 12; +pub const PACKET_TX_RING: c_int = 13; +pub const PACKET_LOSS: c_int = 14; +pub const PACKET_VNET_HDR: c_int = 15; +pub const PACKET_TX_TIMESTAMP: c_int = 16; +pub const PACKET_TIMESTAMP: c_int = 17; +pub const PACKET_FANOUT: c_int = 18; +pub const PACKET_TX_HAS_OFF: c_int = 19; +pub const PACKET_QDISC_BYPASS: c_int = 20; +pub const PACKET_ROLLOVER_STATS: c_int = 21; +pub const PACKET_FANOUT_DATA: c_int = 22; +pub const PACKET_IGNORE_OUTGOING: c_int = 23; +pub const PACKET_VNET_HDR_SZ: c_int = 24; + +pub const PACKET_FANOUT_HASH: c_uint = 0; +pub const PACKET_FANOUT_LB: c_uint = 1; +pub const PACKET_FANOUT_CPU: c_uint = 2; +pub const PACKET_FANOUT_ROLLOVER: c_uint = 3; +pub const PACKET_FANOUT_RND: c_uint = 4; +pub const PACKET_FANOUT_QM: c_uint = 5; +pub const PACKET_FANOUT_CBPF: c_uint = 6; +pub const PACKET_FANOUT_EBPF: c_uint = 7; +pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000; +pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000; +pub const PACKET_FANOUT_FLAG_IGNORE_OUTGOING: c_uint = 0x4000; +pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000; + +s! { + pub struct tpacket_stats { + pub tp_packets: c_uint, + pub tp_drops: c_uint, + } + + pub struct tpacket_stats_v3 { + pub tp_packets: c_uint, + pub tp_drops: c_uint, + pub tp_freeze_q_cnt: c_uint, + } + + #[repr(align(8))] + pub struct tpacket_rollover_stats { + pub tp_all: crate::__u64, + pub tp_huge: crate::__u64, + pub tp_failed: crate::__u64, + } + + pub struct tpacket_auxdata { + pub tp_status: u32, + pub tp_len: u32, + pub tp_snaplen: u32, + pub tp_mac: u16, + pub tp_net: u16, + pub tp_vlan_tci: u16, + pub tp_vlan_tpid: u16, + } +} + +pub const TP_STATUS_KERNEL: u32 = 0; +pub const TP_STATUS_USER: u32 = 1 << 0; +pub const TP_STATUS_COPY: u32 = 1 << 1; +pub const TP_STATUS_LOSING: u32 = 1 << 2; +pub const TP_STATUS_CSUMNOTREADY: u32 = 1 << 3; +pub const TP_STATUS_VLAN_VALID: u32 = 1 << 4; +pub const TP_STATUS_BLK_TMO: u32 = 1 << 5; +pub const TP_STATUS_VLAN_TPID_VALID: u32 = 1 << 6; +pub const TP_STATUS_CSUM_VALID: u32 = 1 << 7; + +pub const TP_STATUS_AVAILABLE: u32 = 0; +pub const TP_STATUS_SEND_REQUEST: u32 = 1 << 0; +pub const TP_STATUS_SENDING: u32 = 1 << 1; +pub const TP_STATUS_WRONG_FORMAT: u32 = 1 << 2; + +pub const TP_STATUS_TS_SOFTWARE: u32 = 1 << 29; +pub const TP_STATUS_TS_SYS_HARDWARE: u32 = 1 << 30; +pub const TP_STATUS_TS_RAW_HARDWARE: u32 = 1 << 31; + +pub const TP_FT_REQ_FILL_RXHASH: u32 = 1; + +s! { + pub struct tpacket_hdr { + pub tp_status: c_ulong, + pub tp_len: c_uint, + pub tp_snaplen: c_uint, + pub tp_mac: c_ushort, + pub tp_net: c_ushort, + pub tp_sec: c_uint, + pub tp_usec: c_uint, + } +} + +pub const TPACKET_ALIGNMENT: usize = 16; +f! { + pub fn TPACKET_ALIGN(x: usize) -> usize { + (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1) + } +} +pub const TPACKET_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + size_of::(); + +s! { + pub struct tpacket2_hdr { + pub tp_status: u32, + pub tp_len: u32, + pub tp_snaplen: u32, + pub tp_mac: u16, + pub tp_net: u16, + pub tp_sec: u32, + pub tp_nsec: u32, + pub tp_vlan_tci: u16, + pub tp_vlan_tpid: u16, + pub tp_padding: [u8; 4], + } + + pub struct tpacket_hdr_variant1 { + pub tp_rxhash: u32, + pub tp_vlan_tci: u32, + pub tp_vlan_tpid: u16, + pub tp_padding: u16, + } + + pub struct tpacket3_hdr { + pub tp_next_offset: u32, + pub tp_sec: u32, + pub tp_nsec: u32, + pub tp_snaplen: u32, + pub tp_len: u32, + pub tp_status: u32, + pub tp_mac: u16, + pub tp_net: u16, + pub hv1: tpacket_hdr_variant1, + pub tp_padding: [u8; 8], + } + + pub struct tpacket_bd_ts { + pub ts_sec: c_uint, + pub ts_usec: c_uint, + } + + #[repr(align(8))] + pub struct tpacket_hdr_v1 { + pub block_status: u32, + pub num_pkts: u32, + pub offset_to_first_pkt: u32, + pub blk_len: u32, + pub seq_num: crate::__u64, + pub ts_first_pkt: tpacket_bd_ts, + pub ts_last_pkt: tpacket_bd_ts, + } +} + +s_no_extra_traits! { + pub union tpacket_bd_header_u { + pub bh1: tpacket_hdr_v1, + } + + pub struct tpacket_block_desc { + pub version: u32, + pub offset_to_priv: u32, + pub hdr: tpacket_bd_header_u, + } +} + +pub const TPACKET2_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + size_of::(); +pub const TPACKET3_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + size_of::(); + +c_enum! { + pub enum tpacket_versions { + pub TPACKET_V1, + pub TPACKET_V2, + pub TPACKET_V3, + } +} + +s! { + pub struct tpacket_req { + pub tp_block_size: c_uint, + pub tp_block_nr: c_uint, + pub tp_frame_size: c_uint, + pub tp_frame_nr: c_uint, + } + + pub struct tpacket_req3 { + pub tp_block_size: c_uint, + pub tp_block_nr: c_uint, + pub tp_frame_size: c_uint, + pub tp_frame_nr: c_uint, + pub tp_retire_blk_tov: c_uint, + pub tp_sizeof_priv: c_uint, + pub tp_feature_req_word: c_uint, + } +} + +s_no_extra_traits! { + pub union tpacket_req_u { + pub req: tpacket_req, + pub req3: tpacket_req3, + } +} + +s! { + pub struct packet_mreq { + pub mr_ifindex: c_int, + pub mr_type: c_ushort, + pub mr_alen: c_ushort, + pub mr_address: [c_uchar; 8], + } + + pub struct fanout_args { + #[cfg(target_endian = "little")] + pub id: u16, + pub type_flags: u16, + #[cfg(target_endian = "big")] + pub id: u16, + pub max_num_members: u32, + } +} + +pub const PACKET_MR_MULTICAST: c_int = 0; +pub const PACKET_MR_PROMISC: c_int = 1; +pub const PACKET_MR_ALLMULTI: c_int = 2; diff --git a/src/new/linux_uapi/linux/mod.rs b/src/new/linux_uapi/linux/mod.rs index 09e2c3ece741..248b7f2a25ec 100644 --- a/src/new/linux_uapi/linux/mod.rs +++ b/src/new/linux_uapi/linux/mod.rs @@ -3,7 +3,10 @@ //! pub(crate) mod can; +pub(crate) mod if_link; +pub(crate) mod if_packet; pub(crate) mod keyctl; pub(crate) mod membarrier; +pub(crate) mod mount; pub(crate) mod netlink; pub(crate) mod pidfd; diff --git a/src/new/linux_uapi/linux/mount.rs b/src/new/linux_uapi/linux/mount.rs new file mode 100644 index 000000000000..bf736acb4ca5 --- /dev/null +++ b/src/new/linux_uapi/linux/mount.rs @@ -0,0 +1,68 @@ +//! Header: `uapi/linux/mount.h` + +use crate::prelude::*; + +pub const MS_RMT_MASK: c_ulong = crate::MS_RDONLY + | crate::MS_SYNCHRONOUS + | crate::MS_MANDLOCK + | crate::MS_I_VERSION + | crate::MS_LAZYTIME; + +pub const OPEN_TREE_CLONE: c_uint = 0x01; +pub const OPEN_TREE_NAMESPACE: c_uint = 0x02; +pub const OPEN_TREE_CLOEXEC: c_uint = crate::O_CLOEXEC as c_uint; + +pub const MOVE_MOUNT_F_SYMLINKS: c_uint = 0x00000001; +pub const MOVE_MOUNT_F_AUTOMOUNTS: c_uint = 0x00000002; +pub const MOVE_MOUNT_F_EMPTY_PATH: c_uint = 0x00000004; +pub const MOVE_MOUNT_T_SYMLINKS: c_uint = 0x00000010; +pub const MOVE_MOUNT_T_AUTOMOUNTS: c_uint = 0x00000020; +pub const MOVE_MOUNT_T_EMPTY_PATH: c_uint = 0x00000040; +pub const MOVE_MOUNT_SET_GROUP: c_uint = 0x00000100; +pub const MOVE_MOUNT_BENEATH: c_uint = 0x00000200; + +pub const FSOPEN_CLOEXEC: c_uint = 0x00000001; + +pub const FSPICK_CLOEXEC: c_uint = 0x00000001; +pub const FSPICK_SYMLINK_NOFOLLOW: c_uint = 0x00000002; +pub const FSPICK_NO_AUTOMOUNT: c_uint = 0x00000004; +pub const FSPICK_EMPTY_PATH: c_uint = 0x00000008; + +c_enum! { + pub enum fsconfig_command { + pub FSCONFIG_SET_FLAG, + pub FSCONFIG_SET_STRING, + pub FSCONFIG_SET_BINARY, + pub FSCONFIG_SET_PATH, + pub FSCONFIG_SET_PATH_EMPTY, + pub FSCONFIG_SET_FD, + pub FSCONFIG_CMD_CREATE, + pub FSCONFIG_CMD_RECONFIGURE, + pub FSCONFIG_CMD_CREATE_EXCL, + } +} + +pub const FSMOUNT_CLOEXEC: c_uint = 0x00000001; + +pub const MOUNT_ATTR_RDONLY: u64 = 0x00000001; +pub const MOUNT_ATTR_NOSUID: u64 = 0x00000002; +pub const MOUNT_ATTR_NODEV: u64 = 0x00000004; +pub const MOUNT_ATTR_NOEXEC: u64 = 0x00000008; +pub const MOUNT_ATTR__ATIME: u64 = 0x00000070; +pub const MOUNT_ATTR_RELATIME: u64 = 0x00000000; +pub const MOUNT_ATTR_NOATIME: u64 = 0x00000010; +pub const MOUNT_ATTR_STRICTATIME: u64 = 0x00000020; +pub const MOUNT_ATTR_NODIRATIME: u64 = 0x00000080; +pub const MOUNT_ATTR_IDMAP: u64 = 0x00100000; +pub const MOUNT_ATTR_NOSYMFOLLOW: u64 = 0x00200000; + +s! { + pub struct mount_attr { + pub attr_set: crate::__u64, + pub attr_clr: crate::__u64, + pub propagation: crate::__u64, + pub userns_fd: crate::__u64, + } +} + +pub const MOUNT_ATTR_SIZE_VER0: c_int = 32; diff --git a/src/new/mod.rs b/src/new/mod.rs index 1c5d6a6e17c2..2c7e12975b73 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -104,7 +104,6 @@ cfg_if! { pub(crate) use openbsd::*; } else if #[cfg(target_os = "qurt")] { pub mod qurt; - pub use qurt::*; } else if #[cfg(target_os = "redox")] { mod redox; // pub(crate) use redox::*; @@ -181,20 +180,23 @@ cfg_if! { pub use linux::can::j1939::*; pub use linux::can::netlink::*; pub use linux::can::raw::*; - pub use linux::can::*; + pub use linux::if_link::*; + pub use linux::if_packet::*; pub use linux::keyctl::*; pub use linux::membarrier::*; + pub use linux::mount::*; pub use linux::netlink::*; pub use linux::pidfd::*; #[cfg(target_env = "gnu")] pub use net::route::*; } else if #[cfg(target_vendor = "apple")] { - pub use pthread::*; pub use pthread_::introspection::*; pub use pthread_::pthread_spis::*; pub use pthread_::spawn::*; pub use pthread_::stack_np::*; pub use signal::*; + } else if #[cfg(target_os = "l4re")] { + pub use l4re::packet::*; } else if #[cfg(target_os = "netbsd")] { pub use net::if_::*; pub use sys::file::*; diff --git a/src/new/qurt/fcntl.rs b/src/new/qurt/fcntl.rs index 0287292ad2f8..615a7128cc50 100644 --- a/src/new/qurt/fcntl.rs +++ b/src/new/qurt/fcntl.rs @@ -47,6 +47,5 @@ pub const F_UNLCK: c_int = 2; // Functions extern "C" { pub fn open(pathname: *const c_char, flags: c_int, ...) -> c_int; - pub fn creat(pathname: *const c_char, mode: mode_t) -> c_int; pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; } diff --git a/src/new/qurt/limits.rs b/src/new/qurt/limits.rs index ae1a007ff1c6..fefe069c1c19 100644 --- a/src/new/qurt/limits.rs +++ b/src/new/qurt/limits.rs @@ -7,8 +7,8 @@ use crate::prelude::*; pub const CHAR_BIT: c_uint = 8; pub const CHAR_MAX: c_char = 255; // unsigned char on Hexagon pub const CHAR_MIN: c_char = 0; -pub const SCHAR_MAX: c_schar = 127; -pub const SCHAR_MIN: c_schar = -128; +pub const SCHAR_MAX: i8 = 127; +pub const SCHAR_MIN: i8 = -128; pub const UCHAR_MAX: c_uchar = 255; // Integer properties diff --git a/src/new/qurt/mod.rs b/src/new/qurt/mod.rs index 52d7ae04881e..9b7ae151a847 100644 --- a/src/new/qurt/mod.rs +++ b/src/new/qurt/mod.rs @@ -39,15 +39,18 @@ pub type pthread_t = c_uint; pub type pthread_key_t = c_int; pub type pthread_once_t = c_int; pub type pthread_mutex_t = c_uint; -pub type pthread_mutexattr_t = c_uint; +// QuRT pthread_mutexattr_t is a struct with 4 ints (is_initialized, type, pshared, protocol) +pub type pthread_mutexattr_t = [c_uint; 4]; pub type pthread_cond_t = c_uint; -pub type pthread_condattr_t = c_uint; -pub type pthread_attr_t = c_uint; -pub type pthread_rwlock_t = c_uint; -pub type pthread_rwlockattr_t = c_uint; +// QuRT pthread_condattr_t is a struct with 3 ints (is_initialized, pshared, clock_id) +pub type pthread_condattr_t = [c_uint; 3]; +// pthread_attr_t is defined as a struct in the s! block below +pub type pthread_rwlock_t = *mut c_void; +pub type pthread_rwlockattr_t = *mut c_void; pub type pthread_spinlock_t = c_uint; pub type pthread_barrier_t = c_uint; -pub type pthread_barrierattr_t = c_uint; +// QuRT pthread_barrierattr_t is a struct with 2 ints (is_initialized, pshared) +pub type pthread_barrierattr_t = [c_uint; 2]; // Network types pub type socklen_t = c_uint; @@ -55,8 +58,8 @@ pub type sa_family_t = c_ushort; pub type in_addr_t = c_uint; pub type in_port_t = c_ushort; -// File descriptor types -pub type fd_set = c_ulong; +// File descriptor types - QuRT defines fd_set as a struct in mqueue.h +// FD_SETSIZE = 256, NFDBITS = 32, so fds_bits has 8 elements // Standard C library types extern_ty! { @@ -65,8 +68,7 @@ extern_ty! { pub type fpos_t = c_long; pub type clock_t = c_long; -// POSIX semaphore types -pub type sem_t = c_uint; +// POSIX semaphore types - QuRT sem_t is a struct with an opaque pointer // Message queue types pub type mqd_t = c_int; @@ -80,22 +82,12 @@ pub type sigset_t = c_ulong; // Variadic argument list type pub type va_list = *mut c_char; -// Additional missing types -pub type c_schar = i8; - -// Wide character type (hexagon-specific) -pub type wchar_t = u32; +// Wide character type (hexagon uses signed wchar_t) +pub type wchar_t = i32; // Error type (compatible with std expectations) pub type errno_t = c_int; -// Resource limit type (for compatibility, not fully supported on QuRT) -pub type rlim_t = c_ulong; - -// Terminal types (for compatibility, not fully supported on QuRT) -pub type speed_t = c_uint; -pub type tcflag_t = c_uint; - // Division result types and structures s! { pub struct div_t { @@ -164,43 +156,7 @@ s! { pub entry: dirent, } - // Terminal I/O structure (for compatibility, limited support on QuRT) - pub struct termios { - pub c_iflag: tcflag_t, - pub c_oflag: tcflag_t, - pub c_cflag: tcflag_t, - pub c_lflag: tcflag_t, - pub c_cc: [c_uchar; 32], - pub c_ispeed: speed_t, - pub c_ospeed: speed_t, - } - - // Resource limit structures (for compatibility, limited support on QuRT) - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long, - } - - // File lock structure (for compatibility) + // File lock structure (from toolchain generic fcntl.h) pub struct flock { pub l_type: c_short, pub l_whence: c_short, @@ -208,6 +164,30 @@ s! { pub l_len: off_t, pub l_pid: pid_t, } + + // QuRT fd_set from mqueue.h: FD_SETSIZE=256, NFDBITS=32 (sizeof(fd_mask)*8) + pub struct fd_set { + pub fds_bits: [c_ulong; 8], + } + + // QuRT sem_t from semaphore.h: struct with opaque pointer + pub struct sem_t { + pub opaque: *mut c_uint, + } + + // QuRT pthread_attr_t - matches pthread_types.h struct layout + pub struct pthread_attr_t { + pub stackaddr: *mut c_void, + pub internal_stack: c_int, + pub stacksize: size_t, + pub priority: c_int, + pub timetest_id: c_ushort, + __bitfield: c_ushort, + pub cpumask: cpu_set_t, + pub name: [c_char; 16], + pub ext_context: c_int, + pub detachstate: c_int, + } } // Additional pthread constants @@ -236,7 +216,11 @@ pub const FOPEN_MAX: c_uint = 20; pub const EOK: c_int = 0; // Semaphore constants -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); + +// fd_set constants from mqueue.h +pub const FD_SETSIZE: c_uint = 256; +pub const NFDBITS: c_uint = 32; // Page size constants (hexagon-specific) pub const PAGESIZE: size_t = 4096; @@ -256,24 +240,10 @@ pub const DT_SOCK: c_uchar = 12; extern "C" { pub fn opendir(name: *const c_char) -> *mut DIR; pub fn readdir(dirp: *mut DIR) -> *mut dirent; - pub fn closedir(dirp: *const DIR) -> c_int; + pub fn closedir(dirp: *mut DIR) -> c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; } -// Additional pthread functions -extern "C" { - pub fn pthread_attr_getstack( - attr: *const pthread_attr_t, - stackaddr: *mut *mut c_void, - stacksize: *mut size_t, - ) -> c_int; - pub fn pthread_attr_setstack( - attr: *mut pthread_attr_t, - stackaddr: *mut c_void, - stacksize: size_t, - ) -> c_int; -} - // Additional time functions extern "C" { pub fn clock_getcpuclockid(pid: pid_t, clock_id: *mut clockid_t) -> c_int; @@ -317,16 +287,6 @@ extern "C" { pub fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void; } -// Additional unistd functions -extern "C" { - pub fn fork() -> pid_t; - pub fn execve( - filename: *const c_char, - argv: *const *const c_char, - envp: *const *const c_char, - ) -> c_int; -} - // Character classification functions (ctype.h) extern "C" { pub fn isalnum(c: c_int) -> c_int; @@ -348,6 +308,7 @@ pub(crate) mod dlfcn; pub(crate) mod errno; pub(crate) mod fcntl; pub(crate) mod limits; +pub(crate) mod mqueue; pub(crate) mod pthread; pub(crate) mod semaphore; pub(crate) mod signal; @@ -362,6 +323,7 @@ pub use dlfcn::*; pub use errno::*; pub use fcntl::*; pub use limits::*; +pub use mqueue::*; pub use pthread::*; pub use semaphore::*; pub use signal::*; diff --git a/src/new/qurt/mqueue.rs b/src/new/qurt/mqueue.rs new file mode 100644 index 000000000000..88ecef584f67 --- /dev/null +++ b/src/new/qurt/mqueue.rs @@ -0,0 +1,74 @@ +//! Header: `mqueue.h` +//! +//! QuRT POSIX message queue API. Also provides select/pselect and fd_set +//! operations since these are declared in QuRT's mqueue.h. + +use super::*; +use crate::prelude::*; + +// Message queue priority constants +pub const MQ_PRIO_DEFAULT: c_int = 0; + +// Bits per byte +pub const NBBY: c_uint = 8; + +s! { + pub struct mq_attr { + pub mq_flags: c_long, + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_curmsgs: c_long, + } +} + +extern "C" { + // Message queue operations + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> mqd_t; + pub fn mq_close(mq_desc: mqd_t) -> c_int; + pub fn mq_unlink(name: *const c_char) -> c_int; + pub fn mq_send( + mqdes: mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + ) -> c_int; + pub fn mq_timedsend( + mqdes: mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + abs_timeout: *const timespec, + ) -> c_int; + pub fn mq_receive( + mqdes: mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + ) -> ssize_t; + pub fn mq_timedreceive( + mqdes: mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + abs_timeout: *const timespec, + ) -> ssize_t; + pub fn mq_getattr(mqdes: mqd_t, mqstat: *mut mq_attr) -> c_int; + pub fn mq_setattr(mqdes: mqd_t, mqstat: *const mq_attr, omqstat: *mut mq_attr) -> c_int; + + // select/pselect (declared in QuRT mqueue.h) + pub fn select( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *mut timeval, + ) -> c_int; + pub fn pselect( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *const timespec, + sigmask: *const sigset_t, + ) -> c_int; +} diff --git a/src/new/qurt/pthread.rs b/src/new/qurt/pthread.rs index 543f7874c3dc..80ae47f495ea 100644 --- a/src/new/qurt/pthread.rs +++ b/src/new/qurt/pthread.rs @@ -5,15 +5,19 @@ use super::*; use crate::prelude::*; -// Thread creation attributes -pub const PTHREAD_CREATE_JOINABLE: c_int = 0; -pub const PTHREAD_CREATE_DETACHED: c_int = 1; +// Thread creation attributes (QuRT values differ from POSIX/Linux defaults) +pub const PTHREAD_CREATE_DETACHED: c_int = 0; +pub const PTHREAD_CREATE_JOINABLE: c_int = 1; -// Mutex types -pub const PTHREAD_MUTEX_NORMAL: c_int = 0; -pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; -pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; -pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; +// Mutex types (QuRT values differ from POSIX/Linux defaults) +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 0; +pub const PTHREAD_MUTEX_NORMAL: c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = 3; + +// Process sharing +pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; +pub const PTHREAD_PROCESS_SHARED: c_int = 1; // Mutex protocol pub const PTHREAD_PRIO_NONE: c_int = 0; @@ -27,17 +31,19 @@ pub const PTHREAD_MAX_PRIORITY: c_int = 255; // Initializer constants pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0xFFFFFFFF; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0xFFFFFFFF; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = !0usize as pthread_rwlock_t; pub const PTHREAD_ONCE_INIT: pthread_once_t = 0; // Stack size pub const PTHREAD_STACK_MIN: size_t = 8192; -// Additional pthread types and attributes +// Contention scope pub const PTHREAD_SCOPE_SYSTEM: c_int = 0; pub const PTHREAD_SCOPE_PROCESS: c_int = 1; -pub const PTHREAD_INHERIT_SCHED: c_int = 0; -pub const PTHREAD_EXPLICIT_SCHED: c_int = 1; +// Scheduler inheritance (QuRT values differ from POSIX/Linux defaults) +pub const PTHREAD_EXPLICIT_SCHED: c_int = 0; +pub const PTHREAD_INHERIT_SCHED: c_int = 1; extern "C" { // Thread management @@ -51,18 +57,66 @@ extern "C" { pub fn pthread_detach(thread: pthread_t) -> c_int; pub fn pthread_exit(retval: *mut c_void) -> !; pub fn pthread_self() -> pthread_t; - pub fn pthread_equal(t1: pthread_t, t2: pthread_t) -> c_int; + // Note: pthread_equal is static inline in QuRT pthread.h, no linkable symbol + pub fn pthread_cancel(thread: pthread_t) -> c_int; + pub fn pthread_kill(thread: pthread_t, sig: c_int) -> c_int; + pub fn pthread_setcancelstate(state: c_int, oldstate: *mut c_int) -> c_int; + pub fn pthread_setcanceltype(r#type: c_int, oldtype: *mut c_int) -> c_int; + + // Thread scheduling + pub fn pthread_getschedparam( + thread: pthread_t, + policy: *mut c_int, + param: *mut sched_param, + ) -> c_int; + pub fn pthread_setschedparam( + thread: pthread_t, + policy: c_int, + param: *const sched_param, + ) -> c_int; + pub fn pthread_setschedprio(thread: pthread_t, prio: c_int) -> c_int; // Thread attributes pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int; pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stacksize: size_t) -> c_int; pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, stacksize: *mut size_t) -> c_int; + pub fn pthread_attr_setstackaddr(attr: *mut pthread_attr_t, stackaddr: *mut c_void) -> c_int; + pub fn pthread_attr_getstackaddr( + attr: *const pthread_attr_t, + stackaddr: *mut *mut c_void, + ) -> c_int; + pub fn pthread_attr_setstack( + attr: *mut pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, + ) -> c_int; + pub fn pthread_attr_getstack( + attr: *const pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; pub fn pthread_attr_setdetachstate(attr: *mut pthread_attr_t, detachstate: c_int) -> c_int; pub fn pthread_attr_getdetachstate( attr: *const pthread_attr_t, detachstate: *mut c_int, ) -> c_int; + pub fn pthread_attr_setscope(attr: *mut pthread_attr_t, scope: c_int) -> c_int; + pub fn pthread_attr_getscope(attr: *const pthread_attr_t, scope: *mut c_int) -> c_int; + pub fn pthread_attr_setinheritsched(attr: *mut pthread_attr_t, inheritsched: c_int) -> c_int; + pub fn pthread_attr_getinheritsched( + attr: *const pthread_attr_t, + inheritsched: *mut c_int, + ) -> c_int; + pub fn pthread_attr_setschedparam( + attr: *mut pthread_attr_t, + param: *const sched_param, + ) -> c_int; + pub fn pthread_attr_getschedparam( + attr: *const pthread_attr_t, + param: *mut sched_param, + ) -> c_int; + pub fn pthread_attr_getguardsize(attr: *const pthread_attr_t, guardsize: *mut size_t) -> c_int; // Mutex operations pub fn pthread_mutex_init( @@ -73,12 +127,39 @@ extern "C" { pub fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> c_int; pub fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> c_int; pub fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_getprioceiling( + mutex: *const pthread_mutex_t, + prioceiling: *mut c_int, + ) -> c_int; + pub fn pthread_mutex_setprioceiling( + mutex: *mut pthread_mutex_t, + prioceiling: c_int, + old_ceiling: *mut c_int, + ) -> c_int; // Mutex attributes 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, kind: c_int) -> c_int; pub fn pthread_mutexattr_gettype(attr: *const pthread_mutexattr_t, kind: *mut c_int) -> c_int; + pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; + pub fn pthread_mutexattr_getprotocol( + attr: *const pthread_mutexattr_t, + protocol: *mut c_int, + ) -> c_int; + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_mutexattr_setprioceiling( + attr: *mut pthread_mutexattr_t, + prioceiling: c_int, + ) -> c_int; + pub fn pthread_mutexattr_getprioceiling( + attr: *const pthread_mutexattr_t, + prioceiling: *mut c_int, + ) -> c_int; // Condition variables pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; @@ -96,6 +177,60 @@ extern "C" { 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_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut c_int, + ) -> c_int; + + // Spinlocks + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + // Barriers + 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_getpshared( + attr: *const pthread_barrierattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_barrierattr_setpshared( + attr: *mut pthread_barrierattr_t, + pshared: c_int, + ) -> c_int; + + // Read-write locks + pub fn pthread_rwlock_init( + rwlock: *mut pthread_rwlock_t, + attr: *const pthread_rwlockattr_t, + ) -> c_int; + pub fn pthread_rwlock_destroy(rwlock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_rdlock(rwlock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_tryrdlock(rwlock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_wrlock(rwlock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_trywrlock(rwlock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_unlock(rwlock: *mut pthread_rwlock_t) -> 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_getpshared( + attr: *const pthread_rwlockattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, pshared: c_int) -> c_int; // Thread-local storage pub fn pthread_key_create( @@ -109,21 +244,32 @@ extern "C" { // One-time initialization pub fn pthread_once(once_control: *mut pthread_once_t, init_routine: extern "C" fn()) -> c_int; - // GNU extensions + // GNU/QuRT non-portable extensions pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size_t) -> c_int; - + pub fn pthread_getattr_np(thread: pthread_t, attr: *mut pthread_attr_t) -> c_int; pub fn pthread_attr_setaffinity_np( attr: *mut pthread_attr_t, cpusetsize: size_t, cpuset: *const cpu_set_t, ) -> c_int; - pub fn pthread_attr_getaffinity_np( attr: *mut pthread_attr_t, cpusetsize: size_t, cpuset: *mut cpu_set_t, ) -> c_int; - // POSIX standard + // QuRT-specific thread attribute extensions + pub fn pthread_attr_setthreadname(attr: *mut pthread_attr_t, name: *const c_char) -> c_int; + pub fn pthread_attr_getthreadname( + attr: *const pthread_attr_t, + name: *mut c_char, + size: c_int, + ) -> c_int; + pub fn pthread_attr_settimetestid(attr: *mut pthread_attr_t, tid: c_uint) -> c_int; + pub fn pthread_attr_gettimetestid(attr: *const pthread_attr_t, tid: *mut c_uint) -> c_int; + pub fn pthread_attr_setautostack(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_setbuspriority(attr: *mut pthread_attr_t, bus_priority: c_ushort) -> c_int; + + // POSIX standard (declared in QuRT pthread.h) pub fn posix_memalign(memptr: *mut *mut c_void, alignment: size_t, size: size_t) -> c_int; } diff --git a/src/new/qurt/signal.rs b/src/new/qurt/signal.rs index f525fa15ff29..e5a219af5881 100644 --- a/src/new/qurt/signal.rs +++ b/src/new/qurt/signal.rs @@ -3,13 +3,14 @@ use super::*; use crate::prelude::*; -// Standard signal numbers +// Signal numbers from toolchain signal.h (non-_LINUX_C_LIB_H_ path) pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; pub const SIGQUIT: c_int = 3; pub const SIGILL: c_int = 4; pub const SIGTRAP: c_int = 5; pub const SIGABRT: c_int = 6; +pub const SIGIOT: c_int = 6; pub const SIGBUS: c_int = 7; pub const SIGFPE: c_int = 8; pub const SIGKILL: c_int = 9; @@ -29,9 +30,9 @@ pub const SIGTTOU: c_int = 22; pub const SIGURG: c_int = 23; pub const SIGXCPU: c_int = 24; pub const SIGXFSZ: c_int = 25; -pub const SIGVTALRM: c_int = 26; pub const SIGPROF: c_int = 27; pub const SIGWINCH: c_int = 28; +pub const SIGPOLL: c_int = 29; pub const SIGIO: c_int = 29; pub const SIGPWR: c_int = 30; pub const SIGSYS: c_int = 31; @@ -61,12 +62,16 @@ pub const SA_SIGINFO: c_int = 1; pub type sighandler_t = size_t; // Signal structures based on QuRT SDK headers -s! { - pub struct sigval { + +// sigval is a union in C (4 bytes on 32-bit hexagon) +s_no_extra_traits! { + pub union sigval { pub sival_int: c_int, pub sival_ptr: *mut c_void, } +} +s! { pub struct sigevent { pub sigev_notify: c_int, pub sigev_signo: c_int, @@ -90,23 +95,17 @@ s! { } extern "C" { + // From generic signal.h (toolchain) pub fn signal(sig: c_int, handler: sighandler_t) -> sighandler_t; - pub fn kill(pid: pid_t, sig: c_int) -> c_int; pub fn raise(sig: c_int) -> c_int; - pub fn alarm(seconds: c_uint) -> c_uint; - pub fn pause() -> c_int; - // Signal mask functions + // QuRT POSIX signal functions pub fn sigemptyset(set: *mut sigset_t) -> c_int; pub fn sigfillset(set: *mut sigset_t) -> c_int; pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int; pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int; pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int; - pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; - pub fn sigpending(set: *mut sigset_t) -> c_int; pub fn sigsuspend(mask: *const sigset_t) -> c_int; - - // QuRT-specific signal functions pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; pub fn _sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int; pub fn sigtimedwait( diff --git a/src/new/qurt/sys/sched.rs b/src/new/qurt/sys/sched.rs index 56fed5ba0089..d56a4bc65e64 100644 --- a/src/new/qurt/sys/sched.rs +++ b/src/new/qurt/sys/sched.rs @@ -18,6 +18,9 @@ s! { } extern "C" { + // Note: sched_yield is static inline in QuRT sys/sched.h, so there is no + // linkable symbol in the SDK libraries. Programs must provide their own + // implementation or use --defsym=sched_yield=abort at link time. pub fn sched_yield() -> c_int; pub fn sched_get_priority_max(policy: c_int) -> c_int; pub fn sched_get_priority_min(policy: c_int) -> c_int; diff --git a/src/new/qurt/time.rs b/src/new/qurt/time.rs index ab6f4453dbea..732297ecbd64 100644 --- a/src/new/qurt/time.rs +++ b/src/new/qurt/time.rs @@ -31,4 +31,15 @@ extern "C" { pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut tm) -> *mut c_char; pub fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int; pub fn nanosleep(req: *const timespec, rem: *mut timespec) -> c_int; + + // POSIX timer functions (from QuRT time.h) + pub fn timer_create(clockid: clockid_t, evp: *mut sigevent, timerid: *mut timer_t) -> c_int; + pub fn timer_delete(timerid: timer_t) -> c_int; + pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> c_int; + pub fn timer_settime( + timerid: timer_t, + flags: c_int, + value: *const itimerspec, + ovalue: *mut itimerspec, + ) -> c_int; } diff --git a/src/new/qurt/unistd.rs b/src/new/qurt/unistd.rs index b973b60e6676..654d02a38a9d 100644 --- a/src/new/qurt/unistd.rs +++ b/src/new/qurt/unistd.rs @@ -239,10 +239,26 @@ extern "C" { // Process operations pub fn getpid() -> pid_t; + pub fn getppid() -> pid_t; + pub fn getpgid(pid: pid_t) -> pid_t; + pub fn getpgrp() -> pid_t; + pub fn getuid() -> uid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getegid() -> gid_t; + pub fn seteuid(uid: uid_t) -> c_int; + pub fn setuid(uid: uid_t) -> c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; + pub fn setpgrp() -> pid_t; + pub fn setsid() -> pid_t; // Sleep functions pub fn sleep(seconds: c_uint) -> c_uint; + // Sync operations + pub fn fsync(fd: c_int) -> c_int; + // System configuration pub fn sysconf(name: c_int) -> c_long; + pub fn pathconf(path: *const c_char, name: c_int) -> c_long; } diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index 89a30a888a5b..7a5c81554b54 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -41,7 +41,7 @@ pub type pthread_spinlock_t = c_int; pub type off_t = i64; -pub type time_t = c_long; +pub type time_t = i64; pub type clock_t = c_long; diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 71d041f7b52f..3791ef9a6624 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2415,7 +2415,7 @@ f! { if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control as *mut cmsghdr } else { - core::ptr::null_mut::() + ptr::null_mut() } } @@ -2426,7 +2426,7 @@ f! { if (cmsg as usize + (*cmsg).cmsg_len as usize + size_of::()) > ((*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize) { - core::ptr::null_mut::() + ptr::null_mut() } else { // AIX does not have any alignment/padding for ancillary data, so we don't need _CMSG_ALIGN here. (cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr @@ -2447,9 +2447,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index ff0e24a90a1d..9b06c6d62267 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -628,6 +628,35 @@ s! { pub pbi_start_tvusec: u64, } + pub struct proc_bsdshortinfo { + /// Process ID. + pub pbsi_pid: u32, + /// Process parent ID. + pub pbsi_ppid: u32, + /// Process perp ID. + pub pbsi_pgid: u32, + /// `p_stat` value: `SZOMB`, `SRUN`, etc. + pub pbsi_status: u32, + /// Up to 16 characters of process name. + pub pbsi_comm: [c_char; MAXCOMLEN], + /// 64bit, emulated, etc. + pub pbsi_flags: u32, + /// Current UID on process. + pub pbsi_uid: crate::uid_t, + /// Current GID on process. + pub pbsi_gid: crate::gid_t, + /// Current RUID on process. + pub pbsi_ruid: crate::uid_t, + /// Current RGID on process. + pub pbsi_rgid: crate::gid_t, + /// Current SVUID on process. + pub pbsi_svuid: crate::uid_t, + /// Current SVGID on process. + pub pbsi_svgid: crate::gid_t, + /// Reserved for future use. + pbsi_rfu: u32, + } + pub struct proc_taskallinfo { pub pbsd: proc_bsdinfo, pub ptinfo: proc_taskinfo, @@ -1521,6 +1550,7 @@ s! { pub external_page_count: natural_t, pub internal_page_count: natural_t, pub total_uncompressed_pages_in_compressor: u64, + pub swapped_count: u64, } #[repr(packed(4))] @@ -2301,7 +2331,11 @@ pub const ENOPOLICY: c_int = 103; pub const ENOTRECOVERABLE: c_int = 104; pub const EOWNERDEAD: c_int = 105; pub const EQFULL: c_int = 106; -pub const ELAST: c_int = 106; +pub const ENOTCAPABLE: c_int = 107; + +/// This symbols is prone to change across releases upstream. +/// See the [usage guidelines](crate::#usage-guidelines) for details and use. +pub const ELAST: c_int = 107; pub const EAI_AGAIN: c_int = 2; pub const EAI_BADFLAGS: c_int = 3; @@ -3168,6 +3202,7 @@ pub const EVFILT_MACHPORT: i16 = -8; pub const EVFILT_FS: i16 = -9; pub const EVFILT_USER: i16 = -10; pub const EVFILT_VM: i16 = -12; +pub const EVFILT_EXCEPT: i16 = -15; pub const EV_ADD: u16 = 0x1; pub const EV_DELETE: u16 = 0x2; @@ -3177,6 +3212,9 @@ pub const EV_ONESHOT: u16 = 0x10; pub const EV_CLEAR: u16 = 0x20; pub const EV_RECEIPT: u16 = 0x40; pub const EV_DISPATCH: u16 = 0x80; +pub const EV_UDATA_SPECIFIC: u16 = 0x0100; +pub const EV_DISPATCH2: u16 = EV_DISPATCH | EV_UDATA_SPECIFIC; +pub const EV_VANISHED: u16 = 0x0200; pub const EV_FLAG0: u16 = 0x1000; pub const EV_POLL: u16 = 0x1000; pub const EV_FLAG1: u16 = 0x2000; @@ -3197,6 +3235,7 @@ pub const NOTE_FFCOPY: u32 = 0xc0000000; pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_OOB: u32 = 0x00000002; pub const NOTE_DELETE: u32 = 0x00000001; pub const NOTE_WRITE: u32 = 0x00000002; pub const NOTE_EXTEND: u32 = 0x00000004; @@ -3205,6 +3244,9 @@ pub const NOTE_LINK: u32 = 0x00000010; pub const NOTE_RENAME: u32 = 0x00000020; pub const NOTE_REVOKE: u32 = 0x00000040; pub const NOTE_NONE: u32 = 0x00000080; +pub const NOTE_FUNLOCK: u32 = 0x00000100; +pub const NOTE_LEASE_DOWNGRADE: u32 = 0x00000200; +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; @@ -3685,6 +3727,7 @@ pub const PROC_PIDTBSDINFO: c_int = 3; pub const PROC_PIDTASKINFO: c_int = 4; pub const PROC_PIDTHREADINFO: c_int = 5; pub const PROC_PIDVNODEPATHINFO: c_int = 9; +pub const PROC_PIDT_SHORTBSDINFO: c_int = 13; pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096; pub const PROC_PIDLISTFDS: c_int = 1; @@ -4250,7 +4293,7 @@ f! { let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next + __DARWIN_ALIGN32(size_of::()) > max { - core::ptr::null_mut() + ptr::null_mut() } else { next as *mut cmsghdr } diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 60e7989bbde3..4aedc2618287 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -548,7 +548,11 @@ pub const ENOMEDIUM: c_int = 93; pub const ENOTRECOVERABLE: c_int = 94; pub const EOWNERDEAD: c_int = 95; pub const EASYNC: c_int = 99; + +/// This symbols is prone to change across releases upstream. +/// See the [usage guidelines](crate::#usage-guidelines) for details and use. pub const ELAST: c_int = 99; + pub const RLIMIT_POSIXLOCKS: c_int = 11; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIM_NLIMITS: crate::rlim_t = 12; @@ -1189,7 +1193,7 @@ f! { if next <= max { (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } else { - core::ptr::null_mut::() + ptr::null_mut() } } @@ -1198,9 +1202,7 @@ f! { } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in cpuset.ary.iter_mut() { - *slot = 0; - } + cpuset.ary.fill(0); } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index e04fcc0cd82d..9cbc7a7390f7 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -258,7 +258,10 @@ s! { } } +/// This symbols is prone to change across releases upstream. +/// See the [usage guidelines](crate::#usage-guidelines) for details and use. pub const ELAST: c_int = 96; + pub const RAND_MAX: c_int = 0x7fff_fffd; pub const KI_NSPARE_PTR: usize = 6; pub const MINCORE_SUPER: c_int = 0x20; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 34979f8884d7..19fa5984cd88 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -304,6 +304,9 @@ s! { } pub const RAND_MAX: c_int = 0x7fff_fffd; + +/// This symbols is prone to change across releases upstream. +/// See the [usage guidelines](crate::#usage-guidelines) for details and use. pub const ELAST: c_int = 97; /// max length of devicename diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 6ef62be3c0a2..73b798d97d7f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -317,6 +317,9 @@ s! { } pub const RAND_MAX: c_int = 0x7fff_ffff; + +/// This symbols is prone to change across releases upstream. +/// See the [usage guidelines](crate::#usage-guidelines) for details and use. pub const ELAST: c_int = 97; pub const KF_TYPE_EVENTFD: c_int = 13; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index f2753cebcec9..e2c72828d98b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -319,6 +319,9 @@ s! { } pub const RAND_MAX: c_int = 0x7fff_ffff; + +/// This symbols is prone to change across releases upstream. +/// See the [usage guidelines](crate::#usage-guidelines) for details and use. pub const ELAST: c_int = 97; pub const KF_TYPE_EVENTFD: c_int = 13; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index d9d93687850c..7f05c8144a91 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -321,6 +321,9 @@ s! { } pub const RAND_MAX: c_int = 0x7fff_ffff; + +/// This symbols is prone to change across releases upstream. +/// See the [usage guidelines](crate::#usage-guidelines) for details and use. pub const ELAST: c_int = 97; pub const KF_TYPE_EVENTFD: c_int = 13; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 233026cc7837..d70caabf5687 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -2608,6 +2608,11 @@ pub const PROC_NO_NEW_PRIVS_CTL: c_int = 19; pub const PROC_NO_NEW_PRIVS_STATUS: c_int = 20; pub const PROC_WXMAP_CTL: c_int = 21; pub const PROC_WXMAP_STATUS: c_int = 22; +pub const PROC_LOGSIGEXIT_CTL: c_int = 23; +pub const PROC_LOGSIGEXIT_STATUS: c_int = 24; +pub const PROC_LOGSIGEXIT_CTL_NOFORCE: c_int = 1; +pub const PROC_LOGSIGEXIT_CTL_FORCE_ENABLE: c_int = 2; +pub const PROC_LOGSIGEXIT_CTL_FORCE_DISABLE: c_int = 3; pub const PROC_PROCCTL_MD_MIN: c_int = 0x10000000; pub const PPROT_SET: c_int = 1; @@ -4269,6 +4274,8 @@ pub const KCMP_FILES: c_int = 102; pub const KCMP_SIGHAND: c_int = 103; pub const KCMP_VM: c_int = 104; +pub const SOL_LOCAL: c_int = 0; + pub const fn MAP_ALIGNED(a: c_int) -> c_int { a << 24 } @@ -4293,7 +4300,7 @@ f! { let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - core::ptr::null_mut::() + ptr::null_mut() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } @@ -4321,19 +4328,15 @@ f! { } pub fn uname(buf: *mut crate::utsname) -> c_int { - __xuname(256, buf as *mut c_void) + __xuname(256, buf.cast()) } pub fn CPU_ZERO(cpuset: &mut cpuset_t) -> () { - for slot in cpuset.__bits.iter_mut() { - *slot = 0; - } + cpuset.__bits.fill(0); } pub fn CPU_FILL(cpuset: &mut cpuset_t) -> () { - for slot in cpuset.__bits.iter_mut() { - *slot = !0; - } + cpuset.__bits.fill(!0); } pub fn CPU_SET(cpu: usize, cpuset: &mut cpuset_t) -> () { @@ -4423,6 +4426,14 @@ safe_f! { pub const fn PR_SCTP_VALID_POLICY(x: c_int) -> bool { PR_SCTP_POLICY(x) <= SCTP_PR_SCTP_MAX } + + pub const fn PPROT_OP(o: c_int) -> c_int { + o & 0xf + } + + pub const fn PPROT_FLAGS(o: c_int) -> c_int { + o & !0xf + } } cfg_if! { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index cb4781735986..fb54288d1f26 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -495,9 +495,9 @@ pub const RTAX_BRD: c_int = 7; f! { pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { if (*mhdr).msg_controllen as usize >= size_of::() { - (*mhdr).msg_control.cast::() + (*mhdr).msg_control.cast() } else { - core::ptr::null_mut() + ptr::null_mut() } } @@ -522,9 +522,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in &mut (*set).fds_bits { - *slot = 0; - } + (*set).fds_bits.fill(0); } } diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index f3d027ce3432..a0930169442c 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -84,7 +84,7 @@ impl siginfo_t { __pad1: Padding, _pid: crate::pid_t, } - (*(self as *const siginfo_t as *const siginfo_timer))._pid + (*(self as *const siginfo_t).cast::())._pid } pub unsafe fn si_uid(&self) -> crate::uid_t { @@ -98,7 +98,7 @@ impl siginfo_t { _pid: crate::pid_t, _uid: crate::uid_t, } - (*(self as *const siginfo_t as *const siginfo_timer))._uid + (*(self as *const siginfo_t).cast::())._uid } pub unsafe fn si_value(&self) -> crate::sigval { @@ -113,7 +113,7 @@ impl siginfo_t { _uid: crate::uid_t, value: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_timer)).value + (*(self as *const siginfo_t).cast::()).value } pub unsafe fn si_status(&self) -> c_int { @@ -128,7 +128,7 @@ impl siginfo_t { _uid: crate::uid_t, status: c_int, } - (*(self as *const siginfo_t as *const siginfo_timer)).status + (*(self as *const siginfo_t).cast::()).status } } @@ -1331,20 +1331,20 @@ cfg_if! { ptm_pad1: Padding::new([0; 3]), ptm_unused: Padding::new(0), ptm_pad2: Padding::new([0; 3]), - ptm_waiters: 0 as *mut _, + ptm_waiters: ptr::null_mut(), ptm_owner: 0, ptm_recursed: 0, - ptm_spare2: 0 as *mut _, + ptm_spare2: ptr::null_mut(), }; } else { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ptm_magic: 0x33330003, ptm_errorcheck: 0, ptm_unused: Padding::new(0), - ptm_waiters: 0 as *mut _, + ptm_waiters: ptr::null_mut(), ptm_owner: 0, ptm_recursed: 0, - ptm_spare2: 0 as *mut _, + ptm_spare2: ptr::null_mut(), }; } } @@ -1352,21 +1352,21 @@ cfg_if! { pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ptc_magic: 0x55550005, ptc_lock: 0, - ptc_waiters_first: 0 as *mut _, - ptc_waiters_last: 0 as *mut _, - ptc_mutex: 0 as *mut _, - ptc_private: 0 as *mut _, + ptc_waiters_first: ptr::null_mut(), + ptc_waiters_last: ptr::null_mut(), + ptc_mutex: ptr::null_mut(), + ptc_private: ptr::null_mut(), }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { ptr_magic: 0x99990009, ptr_interlock: 0, - ptr_rblocked_first: 0 as *mut _, - ptr_rblocked_last: 0 as *mut _, - ptr_wblocked_first: 0 as *mut _, - ptr_wblocked_last: 0 as *mut _, + ptr_rblocked_first: ptr::null_mut(), + ptr_rblocked_last: ptr::null_mut(), + ptr_wblocked_first: ptr::null_mut(), + ptr_wblocked_last: ptr::null_mut(), ptr_nreaders: 0, ptr_owner: 0, - ptr_private: 0 as *mut _, + ptr_private: ptr::null_mut(), }; pub const PTHREAD_MUTEX_NORMAL: c_int = 0; pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; @@ -1825,7 +1825,7 @@ f! { let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - core::ptr::null_mut::() + ptr::null_mut() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } @@ -2234,7 +2234,7 @@ extern "C" { pub fn _lwp_park( clock: crate::clockid_t, flags: c_int, - ts: *const crate::timespec, + ts: *mut crate::timespec, unpark: crate::lwpid_t, hint: *const c_void, unparkhint: *mut c_void, diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index b6e70f9871d4..1d3fd62b76b1 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -865,7 +865,7 @@ impl siginfo_t { _stime: crate::clock_t, _status: crate::c_int, } - (*(self as *const siginfo_t as *const siginfo_proc))._status + (*(self as *const siginfo_t).cast::())._status } } @@ -945,6 +945,9 @@ pub const EBADMSG: c_int = 92; pub const ENOTRECOVERABLE: c_int = 93; pub const EOWNERDEAD: c_int = 94; pub const EPROTO: c_int = 95; + +/// This symbols is prone to change across releases upstream. +/// See the [usage guidelines](crate::#usage-guidelines) for details and use. pub const ELAST: c_int = 95; pub const F_DUPFD_CLOEXEC: c_int = 10; @@ -1852,7 +1855,7 @@ f! { let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - core::ptr::null_mut::() + ptr::null_mut() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 0c093a4c1772..c712c03ff5b3 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -534,7 +534,7 @@ impl siginfo_t { _si_errno: c_int, si_addr: *mut c_void, } - (*(self as *const siginfo_t as *const siginfo_si_addr)).si_addr + (*(self as *const siginfo_t).cast::()).si_addr } pub unsafe fn si_status(&self) -> c_int { @@ -547,7 +547,7 @@ impl siginfo_t { _si_errno: c_int, si_status: c_int, } - (*(self as *const siginfo_t as *const siginfo_sigchld)).si_status + (*(self as *const siginfo_t).cast::()).si_status } pub unsafe fn si_pid(&self) -> pid_t { @@ -568,7 +568,7 @@ impl siginfo_t { _si_errno: c_int, si_value: sigval, } - (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + (*(self as *const siginfo_t).cast::()).si_value } } @@ -1020,7 +1020,7 @@ pub const LC_TIME_MASK: c_int = 1 << 5; pub const LC_MESSAGES_MASK: c_int = 1 << 6; pub const LC_GLOBAL_LOCALE: locale_t = -1isize as locale_t; -pub const SEM_FAILED: *mut sem_t = core::ptr::null_mut(); +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); pub const ST_RDONLY: c_ulong = 0x80000; pub const ST_NOSUID: c_ulong = 0; @@ -1691,9 +1691,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { @@ -1712,10 +1710,9 @@ f! { } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in cpuset.bits.iter_mut() { - *slot = 0; - } + cpuset.bits.fill(0); } + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); if cpu < size_in_bits { @@ -1762,7 +1759,7 @@ f! { if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control.cast() } else { - core::ptr::null_mut() + ptr::null_mut() } } @@ -1770,7 +1767,7 @@ f! { let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next as usize + CMSG_ALIGN(size_of::()) as usize > max { - core::ptr::null_mut() + ptr::null_mut() } else { next } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index cbb6464ed84b..dd9d6fdb136f 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1098,7 +1098,7 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { flags: 0, unused: Padding::new(0), - mutex: 0 as *mut _, + mutex: ptr::null_mut(), waiter_count: 0, lock: 0, }; @@ -1109,7 +1109,7 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { lock_count: 0, reader_count: 0, writer_count: 0, - waiters: [0 as *mut _; 2], + waiters: [ptr::null_mut(); 2], }; pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; @@ -1385,9 +1385,9 @@ const fn CMSG_ALIGN(len: usize) -> usize { f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { if (*mhdr).msg_controllen as usize >= size_of::() { - (*mhdr).msg_control as *mut cmsghdr + (*mhdr).msg_control.cast() } else { - core::ptr::null_mut::() + ptr::null_mut() } } @@ -1412,7 +1412,7 @@ f! { + CMSG_ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - core::ptr::null_mut::() + ptr::null_mut() } else { (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } @@ -1439,9 +1439,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } } diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 99ceab8a7519..9c86f72638a3 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -905,7 +905,7 @@ pub const B_XATTR_TYPE: u32 = haiku_constant!('X', 'A', 'T', 'R'); pub const B_NETWORK_ADDRESS_TYPE: u32 = haiku_constant!('N', 'W', 'A', 'D'); pub const B_MIME_STRING_TYPE: u32 = haiku_constant!('M', 'I', 'M', 'S'); pub const B_ASCII_TYPE: u32 = haiku_constant!('T', 'E', 'X', 'T'); -pub const B_APP_IMAGE_SYMBOL: *const c_void = core::ptr::null(); +pub const B_APP_IMAGE_SYMBOL: *const c_void = ptr::null(); extern "C" { // kernel/OS.h diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 74b77d96f007..4e01ab6ca6db 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3336,19 +3336,19 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __lock: __PTHREAD_SPIN_LOCK_INITIALIZER, - __queue: 0i64 as *mut __pthread, - __attr: 0i64 as *mut __pthread_condattr, + __queue: ptr::null_mut(), + __attr: ptr::null_mut(), __wrefs: 0, - __data: 0i64 as *mut c_void, + __data: ptr::null_mut(), }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __held: __PTHREAD_SPIN_LOCK_INITIALIZER, __lock: __PTHREAD_SPIN_LOCK_INITIALIZER, __readers: 0, - __readerqueue: 0i64 as *mut __pthread, - __writerqueue: 0i64 as *mut __pthread, - __attr: 0i64 as *mut __pthread_rwlockattr, - __data: 0i64 as *mut c_void, + __readerqueue: ptr::null_mut(), + __writerqueue: ptr::null_mut(), + __attr: ptr::null_mut(), + __data: ptr::null_mut(), }; pub const PTHREAD_STACK_MIN: size_t = 0; @@ -3363,9 +3363,9 @@ const fn CMSG_ALIGN(len: usize) -> usize { f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { if (*mhdr).msg_controllen as usize >= size_of::() { - (*mhdr).msg_control.cast::() + (*mhdr).msg_control.cast() } else { - core::ptr::null_mut::() + ptr::null_mut() } } @@ -3383,16 +3383,16 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::() { - return core::ptr::null_mut::(); + return ptr::null_mut(); } let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max || next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max { - core::ptr::null_mut::() + ptr::null_mut() } else { - next.cast::() + next.cast() } } @@ -3403,9 +3403,7 @@ f! { } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in cpuset.bits.iter_mut() { - *slot = 0; - } + cpuset.bits.fill(0); } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { @@ -3472,9 +3470,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 31d1dba3ecf1..a94406842461 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -742,6 +742,15 @@ pub const FILENAME_MAX: c_uint = 4096; pub const FOPEN_MAX: c_uint = 20; pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const POSIX_SPAWN_RESETIDS: c_short = 1; +pub const POSIX_SPAWN_SETPGROUP: c_short = 2; +pub const POSIX_SPAWN_SETSIGDEF: c_short = 4; +pub const POSIX_SPAWN_SETSIGMASK: c_short = 8; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_short = 16; +pub const POSIX_SPAWN_SETSCHEDULER: c_short = 32; +pub const POSIX_SPAWN_USEVFORK: c_short = 64; +pub const POSIX_SPAWN_SETSID: c_short = 128; +pub const POSIX_SPAWN_CLOEXEC_DEFAULT: c_short = 256; pub const L_tmpnam: c_uint = 4096; pub const TMP_MAX: c_uint = 308915776; pub const _PC_LINK_MAX: c_int = 1; @@ -2613,6 +2622,16 @@ pub const FUTEX_PRIVATE_FLAG: c_int = 128; pub const FUTEX_CLOCK_REALTIME: c_int = 256; pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); +pub const FUTEX2_SIZE_U8: c_int = 0x00; +pub const FUTEX2_SIZE_U16: c_int = 0x01; +pub const FUTEX2_SIZE_U32: c_int = 0x02; +pub const FUTEX2_SIZE_U64: c_int = 0x03; +pub const FUTEX2_NUMA: c_int = 0x04; +pub const FUTEX2_PRIVATE: c_int = FUTEX_PRIVATE_FLAG; +pub const FUTEX2_SIZE_MASK: c_int = 0x03; +pub const FUTEX_32: c_int = FUTEX2_SIZE_U32; +pub const FUTEX_WAITV_MAX: c_int = 128; + // linux/errqueue.h pub const SO_EE_ORIGIN_NONE: u8 = 0; pub const SO_EE_ORIGIN_LOCAL: u8 = 1; @@ -3123,7 +3142,6 @@ pub const KERN_PROF: c_int = 6; pub const KERN_NODENAME: c_int = 7; pub const KERN_DOMAINNAME: c_int = 8; pub const KERN_PANIC: c_int = 15; -pub const KERN_REALROOTDEV: c_int = 16; pub const KERN_SPARC_REBOOT: c_int = 21; pub const KERN_CTLALTDEL: c_int = 22; pub const KERN_PRINTK: c_int = 23; @@ -3193,7 +3211,6 @@ pub const VM_SWAPPINESS: c_int = 19; pub const VM_LOWMEM_RESERVE_RATIO: c_int = 20; pub const VM_MIN_FREE_KBYTES: c_int = 21; pub const VM_MAX_MAP_COUNT: c_int = 22; -pub const VM_LAPTOP_MODE: c_int = 23; pub const VM_BLOCK_DUMP: c_int = 24; pub const VM_HUGETLB_GROUP: c_int = 25; pub const VM_VFS_CACHE_PRESSURE: c_int = 26; @@ -3322,9 +3339,9 @@ f! { let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max { - core::ptr::null_mut::() + ptr::null_mut() } else { - next as *mut cmsghdr + next.cast() } } @@ -3335,9 +3352,7 @@ f! { } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in cpuset.__bits.iter_mut() { - *slot = 0; - } + cpuset.__bits.fill(0); } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { @@ -3403,6 +3418,9 @@ safe_f! { } extern "C" { + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; pub fn setgrent(); pub fn endgrent(); pub fn getgrent() -> *mut crate::group; @@ -3533,6 +3551,20 @@ extern "C" { new_value: *const itimerspec, old_value: *mut itimerspec, ) -> c_int; + pub fn timer_create( + clockid: crate::clockid_t, + sevp: *mut crate::sigevent, + timerid: *mut crate::timer_t, + ) -> c_int; + pub fn timer_delete(timerid: crate::timer_t) -> c_int; + pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; + pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; + pub fn timer_settime( + timerid: crate::timer_t, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; pub fn syscall(num: c_long, ...) -> c_long; pub fn sched_getaffinity( pid: crate::pid_t, @@ -3788,7 +3820,7 @@ impl siginfo_t { _si_code: c_int, si_addr: *mut c_void, } - (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + (*(self as *const siginfo_t).cast::()).si_addr } pub unsafe fn si_value(&self) -> crate::sigval { @@ -3801,13 +3833,13 @@ impl siginfo_t { _si_overrun: c_int, si_sigval: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval + (*(self as *const siginfo_t).cast::()).si_sigval } } impl siginfo_t { unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields + &(*(self as *const siginfo_t).cast::()).sifields } pub unsafe fn si_pid(&self) -> crate::pid_t { diff --git a/src/unix/linux_like/emscripten/lfs64.rs b/src/unix/linux_like/emscripten/lfs64.rs index 501540943889..5ced3277a73f 100644 --- a/src/unix/linux_like/emscripten/lfs64.rs +++ b/src/unix/linux_like/emscripten/lfs64.rs @@ -10,7 +10,7 @@ pub unsafe extern "C" fn creat64(path: *const c_char, mode: crate::mode_t) -> c_ #[inline] pub unsafe extern "C" fn fgetpos64(stream: *mut crate::FILE, pos: *mut crate::fpos64_t) -> c_int { - crate::fgetpos(stream, pos as *mut _) + crate::fgetpos(stream, pos.cast()) } #[inline] @@ -38,12 +38,12 @@ pub unsafe extern "C" fn fseeko64( #[inline] pub unsafe extern "C" fn fsetpos64(stream: *mut crate::FILE, pos: *const crate::fpos64_t) -> c_int { - crate::fsetpos(stream, pos as *mut _) + crate::fsetpos(stream, pos.cast()) } #[inline] pub unsafe extern "C" fn fstat64(fildes: c_int, buf: *mut crate::stat64) -> c_int { - crate::fstat(fildes, buf as *mut _) + crate::fstat(fildes, buf.cast()) } #[inline] @@ -53,17 +53,17 @@ pub unsafe extern "C" fn fstatat64( buf: *mut crate::stat64, flag: c_int, ) -> c_int { - crate::fstatat(fd, path, buf as *mut _, flag) + crate::fstatat(fd, path, buf.cast(), flag) } #[inline] pub unsafe extern "C" fn fstatfs64(fd: c_int, buf: *mut crate::statfs64) -> c_int { - crate::fstatfs(fd, buf as *mut _) + crate::fstatfs(fd, buf.cast()) } #[inline] pub unsafe extern "C" fn fstatvfs64(fd: c_int, buf: *mut crate::statvfs64) -> c_int { - crate::fstatvfs(fd, buf as *mut _) + crate::fstatvfs(fd, buf.cast()) } #[inline] @@ -78,7 +78,7 @@ pub unsafe extern "C" fn ftruncate64(fd: c_int, length: off64_t) -> c_int { #[inline] pub unsafe extern "C" fn getrlimit64(resource: c_int, rlim: *mut crate::rlimit64) -> c_int { - crate::getrlimit(resource, rlim as *mut _) + crate::getrlimit(resource, rlim.cast()) } #[inline] @@ -88,7 +88,7 @@ pub unsafe extern "C" fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> o #[inline] pub unsafe extern "C" fn lstat64(path: *const c_char, buf: *mut crate::stat64) -> c_int { - crate::lstat(path, buf as *mut _) + crate::lstat(path, buf.cast()) } #[inline] @@ -171,7 +171,7 @@ pub unsafe extern "C" fn pwritev64( #[inline] pub unsafe extern "C" fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64 { - crate::readdir(dirp) as *mut _ + crate::readdir(dirp).cast() } #[inline] @@ -180,27 +180,27 @@ pub unsafe extern "C" fn readdir64_r( entry: *mut crate::dirent64, result: *mut *mut crate::dirent64, ) -> c_int { - crate::readdir_r(dirp, entry as *mut _, result as *mut _) + crate::readdir_r(dirp, entry.cast(), result.cast()) } #[inline] pub unsafe extern "C" fn setrlimit64(resource: c_int, rlim: *const crate::rlimit64) -> c_int { - crate::setrlimit(resource, rlim as *mut _) + crate::setrlimit(resource, rlim.cast()) } #[inline] pub unsafe extern "C" fn stat64(pathname: *const c_char, statbuf: *mut crate::stat64) -> c_int { - crate::stat(pathname, statbuf as *mut _) + crate::stat(pathname, statbuf.cast()) } #[inline] pub unsafe extern "C" fn statfs64(pathname: *const c_char, buf: *mut crate::statfs64) -> c_int { - crate::statfs(pathname, buf as *mut _) + crate::statfs(pathname, buf.cast()) } #[inline] pub unsafe extern "C" fn statvfs64(path: *const c_char, buf: *mut crate::statvfs64) -> c_int { - crate::statvfs(path, buf as *mut _) + crate::statvfs(path, buf.cast()) } #[inline] diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 711ed8f8b4c3..128025d81378 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -188,7 +188,8 @@ s! { } pub struct pthread_attr_t { - __size: [u32; 11], + // 11 pointer-width words: 44 bytes on wasm32, 88 on wasm64 (MEMORY64). + __size: [usize; 11], } pub struct sigset_t { @@ -1064,8 +1065,14 @@ pub const SO_RXQ_OVFL: c_int = 40; pub const SO_PEEK_OFF: c_int = 42; pub const SO_BUSY_POLL: c_int = 46; +#[cfg(target_pointer_width = "32")] pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +#[cfg(target_pointer_width = "64")] +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +#[cfg(target_pointer_width = "32")] pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +#[cfg(target_pointer_width = "64")] +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; @@ -1253,21 +1260,19 @@ pub const SOMAXCONN: c_int = 128; f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::() { - return core::ptr::null_mut::(); + return ptr::null_mut(); } let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize >= max { - core::ptr::null_mut::() + ptr::null_mut() } else { - next as *mut cmsghdr + next.cast() } } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in cpuset.bits.iter_mut() { - *slot = 0; - } + cpuset.bits.fill(0); } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index e593ad76d4fc..b3dba2c37766 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -456,7 +456,7 @@ pub const __LOCK_INITIALIZER: _pthread_fastlock = _pthread_fastlock { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { __m_reserved: 0, __m_count: 0, - __m_owner: core::ptr::null_mut(), + __m_owner: ptr::null_mut(), __m_kind: PTHREAD_MUTEX_TIMED_NP, __m_lock: __LOCK_INITIALIZER, }; @@ -468,7 +468,7 @@ const PTHREAD_COND_PADDING_SIZE: usize = 48 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __c_lock: __LOCK_INITIALIZER, - __c_waiting: core::ptr::null_mut(), + __c_waiting: ptr::null_mut(), __padding: [0; PTHREAD_COND_PADDING_SIZE], __align: 0, }; @@ -476,9 +476,9 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __rw_lock: __LOCK_INITIALIZER, __rw_readers: 0, - __rw_writer: core::ptr::null_mut(), - __rw_read_waiting: core::ptr::null_mut(), - __rw_write_waiting: core::ptr::null_mut(), + __rw_writer: ptr::null_mut(), + __rw_read_waiting: ptr::null_mut(), + __rw_write_waiting: ptr::null_mut(), __rw_kind: PTHREAD_RWLOCK_DEFAULT_NP, __rw_pshared: crate::PTHREAD_PROCESS_PRIVATE, }; diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 37b751715e44..cf70367f8e6b 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -143,9 +143,9 @@ cfg_if! { pub const SO_TIMESTAMPING_NEW: c_int = 65; pub const SO_RCVTIMEO_NEW: c_int = 66; pub const SO_SNDTIMEO_NEW: c_int = 67; - pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; } } +pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; pub const SO_PREFER_BUSY_POLL: c_int = 69; pub const SO_BUSY_POLL_BUDGET: c_int = 70; pub const SO_NETNS_COOKIE: c_int = 71; diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 78eec0ff55ac..12d46eb72d5a 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -117,7 +117,7 @@ cfg_if! { } } -// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; +pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; pub const SO_PREFER_BUSY_POLL: c_int = 69; pub const SO_BUSY_POLL_BUDGET: c_int = 70; pub const SO_NETNS_COOKIE: c_int = 71; diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index b5a3557a705b..41908261721b 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -105,7 +105,7 @@ pub const SO_ZEROCOPY: c_int = 60; pub const SO_TXTIME: c_int = 61; pub const SCM_TXTIME: c_int = SO_TXTIME; pub const SO_BINDTOIFINDEX: c_int = 62; -// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; +pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; pub const SO_PREFER_BUSY_POLL: c_int = 69; pub const SO_BUSY_POLL_BUDGET: c_int = 70; pub const SO_NETNS_COOKIE: c_int = 71; diff --git a/src/unix/linux_like/linux/arch/sparc/mod.rs b/src/unix/linux_like/linux/arch/sparc/mod.rs index 006156ee0c0e..40899e97f21c 100644 --- a/src/unix/linux_like/linux/arch/sparc/mod.rs +++ b/src/unix/linux_like/linux/arch/sparc/mod.rs @@ -94,7 +94,7 @@ pub const SO_TIMESTAMPING: c_int = 0x0023; // pub const SO_TIMESTAMPING_NEW: c_int = 0x0043; // pub const SO_RCVTIMEO_NEW: c_int = 0x0044; // pub const SO_SNDTIMEO_NEW: c_int = 0x0045; -// pub const SO_DETACH_REUSEPORT_BPF: c_int = 0x0047; +pub const SO_DETACH_REUSEPORT_BPF: c_int = 0x0047; pub const SO_PREFER_BUSY_POLL: c_int = 0x0048; pub const SO_BUSY_POLL_BUDGET: c_int = 0x0049; pub const SO_NETNS_COOKIE: c_int = 0x0050; 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 b8c55dc33c89..beafaf4e2d47 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -712,6 +712,7 @@ pub const SYS_pread64: c_long = 67; pub const SYS_pwrite64: c_long = 68; pub const SYS_preadv: c_long = 69; pub const SYS_pwritev: c_long = 70; +pub const SYS_sendfile: c_long = 71; pub const SYS_pselect6: c_long = 72; pub const SYS_ppoll: c_long = 73; pub const SYS_signalfd4: c_long = 74; @@ -863,6 +864,7 @@ pub const SYS_keyctl: c_long = 219; pub const SYS_clone: c_long = 220; pub const SYS_execve: c_long = 221; pub const SYS_mmap: c_long = 222; +pub const SYS_fadvise64: c_long = 223; pub const SYS_swapon: c_long = 224; pub const SYS_swapoff: c_long = 225; pub const SYS_mprotect: c_long = 226; diff --git a/src/unix/linux_like/linux/gnu/b64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mod.rs index 3d442a6d8129..16b7bef085fe 100644 --- a/src/unix/linux_like/linux/gnu/b64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mod.rs @@ -98,6 +98,17 @@ s! { __glibc_reserved4: Padding, } + // net/iucv/iucv.h + + pub struct sockaddr_iucv { + pub siucv_family: crate::sa_family_t, + __siucv_port: Padding, // unused crate::in_port_t + __siucv_addr: Padding, // unused crate::in_addr_t + pub siucv_nodeid: [c_char; 8], + pub siucv_user_id: [c_char; 8], + pub siucv_name: [c_char; 8], + } + pub struct timex { pub modes: c_uint, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index cbb1502ebcc0..10438234b6e6 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -4,6 +4,7 @@ use crate::prelude::*; use crate::{ off64_t, off_t, + pthread_mutex_t, }; pub type wchar_t = c_int; @@ -293,6 +294,49 @@ s_no_extra_traits! { } } +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; pub const VEOF: usize = 4; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 65e94a19a517..494ad6c7ee68 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -545,8 +545,6 @@ pub const PRIO_PROCESS: crate::__priority_which_t = 0; pub const PRIO_PGRP: crate::__priority_which_t = 1; pub const PRIO_USER: crate::__priority_which_t = 2; -pub const MS_RMT_MASK: c_ulong = 0x02800051; - pub const __UT_LINESIZE: usize = 32; pub const __UT_NAMESIZE: usize = 32; pub const __UT_HOSTSIZE: usize = 256; @@ -832,16 +830,6 @@ pub const M_ARENA_MAX: c_int = -8; pub const SOMAXCONN: c_int = 4096; -// linux/mount.h -pub const MOVE_MOUNT_F_SYMLINKS: c_uint = 0x00000001; -pub const MOVE_MOUNT_F_AUTOMOUNTS: c_uint = 0x00000002; -pub const MOVE_MOUNT_F_EMPTY_PATH: c_uint = 0x00000004; -pub const MOVE_MOUNT_T_SYMLINKS: c_uint = 0x00000010; -pub const MOVE_MOUNT_T_AUTOMOUNTS: c_uint = 0x00000020; -pub const MOVE_MOUNT_T_EMPTY_PATH: c_uint = 0x00000040; -pub const MOVE_MOUNT_SET_GROUP: c_uint = 0x00000100; -pub const MOVE_MOUNT_BENEATH: c_uint = 0x00000200; - // sys/timex.h pub const ADJ_OFFSET: c_uint = 0x0001; pub const ADJ_FREQUENCY: c_uint = 0x0002; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index e58849b4e08f..6d762623da75 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -37,15 +37,6 @@ pub type sctp_assoc_t = __s32; pub type eventfd_t = u64; -e! { - #[repr(u32)] - pub enum tpacket_versions { - TPACKET_V1, - TPACKET_V2, - TPACKET_V3, - } -} - c_enum! { pub enum pid_type { pub PIDTYPE_PID, @@ -94,126 +85,6 @@ s! { _pad: Padding<[u8; 28]>, } - pub struct fanout_args { - #[cfg(target_endian = "little")] - pub id: __u16, - pub type_flags: __u16, - #[cfg(target_endian = "big")] - pub id: __u16, - pub max_num_members: __u32, - } - - #[deprecated(since = "0.2.70", note = "sockaddr_ll type must be used instead")] - pub struct sockaddr_pkt { - pub spkt_family: c_ushort, - pub spkt_device: [c_uchar; 14], - pub spkt_protocol: c_ushort, - } - - pub struct tpacket_auxdata { - pub tp_status: __u32, - pub tp_len: __u32, - pub tp_snaplen: __u32, - pub tp_mac: __u16, - pub tp_net: __u16, - pub tp_vlan_tci: __u16, - pub tp_vlan_tpid: __u16, - } - - pub struct tpacket_hdr { - pub tp_status: c_ulong, - pub tp_len: c_uint, - pub tp_snaplen: c_uint, - pub tp_mac: c_ushort, - pub tp_net: c_ushort, - pub tp_sec: c_uint, - pub tp_usec: c_uint, - } - - pub struct tpacket_hdr_variant1 { - pub tp_rxhash: __u32, - pub tp_vlan_tci: __u32, - pub tp_vlan_tpid: __u16, - pub tp_padding: __u16, - } - - pub struct tpacket2_hdr { - pub tp_status: __u32, - pub tp_len: __u32, - pub tp_snaplen: __u32, - pub tp_mac: __u16, - pub tp_net: __u16, - pub tp_sec: __u32, - pub tp_nsec: __u32, - pub tp_vlan_tci: __u16, - pub tp_vlan_tpid: __u16, - pub tp_padding: [__u8; 4], - } - - pub struct tpacket_req { - pub tp_block_size: c_uint, - pub tp_block_nr: c_uint, - pub tp_frame_size: c_uint, - pub tp_frame_nr: c_uint, - } - - pub struct tpacket_req3 { - pub tp_block_size: c_uint, - pub tp_block_nr: c_uint, - pub tp_frame_size: c_uint, - pub tp_frame_nr: c_uint, - pub tp_retire_blk_tov: c_uint, - pub tp_sizeof_priv: c_uint, - pub tp_feature_req_word: c_uint, - } - - #[repr(align(8))] - pub struct tpacket_rollover_stats { - pub tp_all: crate::__u64, - pub tp_huge: crate::__u64, - pub tp_failed: crate::__u64, - } - - pub struct tpacket_stats { - pub tp_packets: c_uint, - pub tp_drops: c_uint, - } - - pub struct tpacket_stats_v3 { - pub tp_packets: c_uint, - pub tp_drops: c_uint, - pub tp_freeze_q_cnt: c_uint, - } - - pub struct tpacket3_hdr { - pub tp_next_offset: __u32, - pub tp_sec: __u32, - pub tp_nsec: __u32, - pub tp_snaplen: __u32, - pub tp_len: __u32, - pub tp_status: __u32, - pub tp_mac: __u16, - pub tp_net: __u16, - pub hv1: crate::tpacket_hdr_variant1, - pub tp_padding: [__u8; 8], - } - - pub struct tpacket_bd_ts { - pub ts_sec: c_uint, - pub ts_usec: c_uint, - } - - #[repr(align(8))] - pub struct tpacket_hdr_v1 { - pub block_status: __u32, - pub num_pkts: __u32, - pub offset_to_first_pkt: __u32, - pub blk_len: __u32, - pub seq_num: crate::__u64, - pub ts_first_pkt: crate::tpacket_bd_ts, - pub ts_last_pkt: crate::tpacket_bd_ts, - } - // System V IPC pub struct msginfo { pub msgpool: c_int, @@ -994,15 +865,6 @@ s! { pub csum_offset: __u16, } - // linux/mount.h - - pub struct mount_attr { - pub attr_set: crate::__u64, - pub attr_clr: crate::__u64, - pub propagation: crate::__u64, - pub userns_fd: crate::__u64, - } - // linux/nsfs.h pub struct mnt_ns_info { pub size: crate::__u32, @@ -1304,21 +1166,6 @@ s_no_extra_traits! { pub iv: [c_uchar; 0], } - pub union tpacket_req_u { - pub req: crate::tpacket_req, - pub req3: crate::tpacket_req3, - } - - pub union tpacket_bd_header_u { - pub bh1: crate::tpacket_hdr_v1, - } - - pub struct tpacket_block_desc { - pub version: __u32, - pub offset_to_priv: __u32, - pub hdr: crate::tpacket_bd_header_u, - } - // linux/net_tstamp.h pub struct sock_txtime { pub clockid: crate::clockid_t, @@ -1421,8 +1268,9 @@ cfg_if! { } } -pub const POSIX_SPAWN_USEVFORK: c_int = 64; -pub const POSIX_SPAWN_SETSID: c_int = 128; +pub const POSIX_SPAWN_USEVFORK: c_short = 64; +#[cfg(not(target_env = "uclibc"))] +pub const POSIX_SPAWN_SETSID: c_short = 128; pub const F_SEAL_FUTURE_WRITE: c_int = 0x0010; pub const F_SEAL_EXEC: c_int = 0x0020; @@ -1476,78 +1324,6 @@ pub const RWF_NOAPPEND: c_int = 0x00000020; pub const RWF_ATOMIC: c_int = 0x00000040; pub const RWF_DONTCACHE: c_int = 0x00000080; -// linux/if_link.h -pub const IFLA_UNSPEC: c_ushort = 0; -pub const IFLA_ADDRESS: c_ushort = 1; -pub const IFLA_BROADCAST: c_ushort = 2; -pub const IFLA_IFNAME: c_ushort = 3; -pub const IFLA_MTU: c_ushort = 4; -pub const IFLA_LINK: c_ushort = 5; -pub const IFLA_QDISC: c_ushort = 6; -pub const IFLA_STATS: c_ushort = 7; -pub const IFLA_COST: c_ushort = 8; -pub const IFLA_PRIORITY: c_ushort = 9; -pub const IFLA_MASTER: c_ushort = 10; -pub const IFLA_WIRELESS: c_ushort = 11; -pub const IFLA_PROTINFO: c_ushort = 12; -pub const IFLA_TXQLEN: c_ushort = 13; -pub const IFLA_MAP: c_ushort = 14; -pub const IFLA_WEIGHT: c_ushort = 15; -pub const IFLA_OPERSTATE: c_ushort = 16; -pub const IFLA_LINKMODE: c_ushort = 17; -pub const IFLA_LINKINFO: c_ushort = 18; -pub const IFLA_NET_NS_PID: c_ushort = 19; -pub const IFLA_IFALIAS: c_ushort = 20; -pub const IFLA_NUM_VF: c_ushort = 21; -pub const IFLA_VFINFO_LIST: c_ushort = 22; -pub const IFLA_STATS64: c_ushort = 23; -pub const IFLA_VF_PORTS: c_ushort = 24; -pub const IFLA_PORT_SELF: c_ushort = 25; -pub const IFLA_AF_SPEC: c_ushort = 26; -pub const IFLA_GROUP: c_ushort = 27; -pub const IFLA_NET_NS_FD: c_ushort = 28; -pub const IFLA_EXT_MASK: c_ushort = 29; -pub const IFLA_PROMISCUITY: c_ushort = 30; -pub const IFLA_NUM_TX_QUEUES: c_ushort = 31; -pub const IFLA_NUM_RX_QUEUES: c_ushort = 32; -pub const IFLA_CARRIER: c_ushort = 33; -pub const IFLA_PHYS_PORT_ID: c_ushort = 34; -pub const IFLA_CARRIER_CHANGES: c_ushort = 35; -pub const IFLA_PHYS_SWITCH_ID: c_ushort = 36; -pub const IFLA_LINK_NETNSID: c_ushort = 37; -pub const IFLA_PHYS_PORT_NAME: c_ushort = 38; -pub const IFLA_PROTO_DOWN: c_ushort = 39; -pub const IFLA_GSO_MAX_SEGS: c_ushort = 40; -pub const IFLA_GSO_MAX_SIZE: c_ushort = 41; -pub const IFLA_PAD: c_ushort = 42; -pub const IFLA_XDP: c_ushort = 43; -pub const IFLA_EVENT: c_ushort = 44; -pub const IFLA_NEW_NETNSID: c_ushort = 45; -pub const IFLA_IF_NETNSID: c_ushort = 46; -pub const IFLA_TARGET_NETNSID: c_ushort = IFLA_IF_NETNSID; -pub const IFLA_CARRIER_UP_COUNT: c_ushort = 47; -pub const IFLA_CARRIER_DOWN_COUNT: c_ushort = 48; -pub const IFLA_NEW_IFINDEX: c_ushort = 49; -pub const IFLA_MIN_MTU: c_ushort = 50; -pub const IFLA_MAX_MTU: c_ushort = 51; -pub const IFLA_PROP_LIST: c_ushort = 52; -pub const IFLA_ALT_IFNAME: c_ushort = 53; -pub const IFLA_PERM_ADDRESS: c_ushort = 54; -pub const IFLA_PROTO_DOWN_REASON: c_ushort = 55; -pub const IFLA_PARENT_DEV_NAME: c_ushort = 56; -pub const IFLA_PARENT_DEV_BUS_NAME: c_ushort = 57; -pub const IFLA_GRO_MAX_SIZE: c_ushort = 58; -pub const IFLA_TSO_MAX_SIZE: c_ushort = 59; -pub const IFLA_TSO_MAX_SEGS: c_ushort = 60; -pub const IFLA_ALLMULTI: c_ushort = 61; - -pub const IFLA_INFO_UNSPEC: c_ushort = 0; -pub const IFLA_INFO_KIND: c_ushort = 1; -pub const IFLA_INFO_DATA: c_ushort = 2; -pub const IFLA_INFO_XSTATS: c_ushort = 3; -pub const IFLA_INFO_SLAVE_KIND: c_ushort = 4; -pub const IFLA_INFO_SLAVE_DATA: c_ushort = 5; - // Since Linux 3.1 pub const SEEK_DATA: c_int = 3; pub const SEEK_HOLE: c_int = 4; @@ -2100,60 +1876,6 @@ pub const CTRL_ATTR_MCAST_GRP_UNSPEC: c_int = 0; pub const CTRL_ATTR_MCAST_GRP_NAME: c_int = 1; pub const CTRL_ATTR_MCAST_GRP_ID: c_int = 2; -pub const PACKET_FANOUT: c_int = 18; -pub const PACKET_TX_HAS_OFF: c_int = 19; -pub const PACKET_QDISC_BYPASS: c_int = 20; -pub const PACKET_ROLLOVER_STATS: c_int = 21; -pub const PACKET_FANOUT_DATA: c_int = 22; -pub const PACKET_IGNORE_OUTGOING: c_int = 23; -pub const PACKET_VNET_HDR_SZ: c_int = 24; - -pub const PACKET_FANOUT_HASH: c_uint = 0; -pub const PACKET_FANOUT_LB: c_uint = 1; -pub const PACKET_FANOUT_CPU: c_uint = 2; -pub const PACKET_FANOUT_ROLLOVER: c_uint = 3; -pub const PACKET_FANOUT_RND: c_uint = 4; -pub const PACKET_FANOUT_QM: c_uint = 5; -pub const PACKET_FANOUT_CBPF: c_uint = 6; -pub const PACKET_FANOUT_EBPF: c_uint = 7; -pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000; -pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000; -pub const PACKET_FANOUT_FLAG_IGNORE_OUTGOING: c_uint = 0x4000; -pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000; - -pub const TP_STATUS_KERNEL: __u32 = 0; -pub const TP_STATUS_USER: __u32 = 1 << 0; -pub const TP_STATUS_COPY: __u32 = 1 << 1; -pub const TP_STATUS_LOSING: __u32 = 1 << 2; -pub const TP_STATUS_CSUMNOTREADY: __u32 = 1 << 3; -pub const TP_STATUS_VLAN_VALID: __u32 = 1 << 4; -pub const TP_STATUS_BLK_TMO: __u32 = 1 << 5; -pub const TP_STATUS_VLAN_TPID_VALID: __u32 = 1 << 6; -pub const TP_STATUS_CSUM_VALID: __u32 = 1 << 7; - -pub const TP_STATUS_AVAILABLE: __u32 = 0; -pub const TP_STATUS_SEND_REQUEST: __u32 = 1 << 0; -pub const TP_STATUS_SENDING: __u32 = 1 << 1; -pub const TP_STATUS_WRONG_FORMAT: __u32 = 1 << 2; - -pub const TP_STATUS_TS_SOFTWARE: __u32 = 1 << 29; -pub const TP_STATUS_TS_SYS_HARDWARE: __u32 = 1 << 30; -pub const TP_STATUS_TS_RAW_HARDWARE: __u32 = 1 << 31; - -pub const TP_FT_REQ_FILL_RXHASH: __u32 = 1; - -pub const TPACKET_ALIGNMENT: usize = 16; - -pub const TPACKET_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) - & !(TPACKET_ALIGNMENT - 1)) - + size_of::(); -pub const TPACKET2_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) - & !(TPACKET_ALIGNMENT - 1)) - + size_of::(); -pub const TPACKET3_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) - & !(TPACKET_ALIGNMENT - 1)) - + size_of::(); - // linux/netfilter.h pub const NF_DROP: c_int = 0; pub const NF_ACCEPT: c_int = 1; @@ -3141,10 +2863,6 @@ pub const IN_ALL_EVENTS: u32 = IN_ACCESS pub const IN_CLOEXEC: c_int = O_CLOEXEC; pub const IN_NONBLOCK: c_int = O_NONBLOCK; -// uapi/linux/mount.h -pub const OPEN_TREE_CLONE: c_uint = 0x01; -pub const OPEN_TREE_CLOEXEC: c_uint = O_CLOEXEC as c_uint; - // uapi/linux/netfilter/nf_tables.h pub const NFT_TABLE_MAXNAMELEN: c_int = 256; pub const NFT_CHAIN_MAXNAMELEN: c_int = 256; @@ -3491,6 +3209,16 @@ pub const FUTEX_PRIVATE_FLAG: c_int = 128; pub const FUTEX_CLOCK_REALTIME: c_int = 256; pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); +pub const FUTEX2_SIZE_U8: c_int = 0x00; +pub const FUTEX2_SIZE_U16: c_int = 0x01; +pub const FUTEX2_SIZE_U32: c_int = 0x02; +pub const FUTEX2_SIZE_U64: c_int = 0x03; +pub const FUTEX2_NUMA: c_int = 0x04; +pub const FUTEX2_PRIVATE: c_int = FUTEX_PRIVATE_FLAG; +pub const FUTEX2_SIZE_MASK: c_int = 0x03; +pub const FUTEX_32: c_int = FUTEX2_SIZE_U32; +pub const FUTEX_WAITV_MAX: c_int = 128; + pub const FUTEX_WAITERS: u32 = 0x80000000; pub const FUTEX_OWNER_DIED: u32 = 0x40000000; pub const FUTEX_TID_MASK: u32 = 0x3fffffff; @@ -3670,7 +3398,6 @@ pub const KERN_PROF: c_int = 6; pub const KERN_NODENAME: c_int = 7; pub const KERN_DOMAINNAME: c_int = 8; pub const KERN_PANIC: c_int = 15; -pub const KERN_REALROOTDEV: c_int = 16; pub const KERN_SPARC_REBOOT: c_int = 21; pub const KERN_CTLALTDEL: c_int = 22; pub const KERN_PRINTK: c_int = 23; @@ -3742,7 +3469,6 @@ pub const VM_SWAPPINESS: c_int = 19; pub const VM_LOWMEM_RESERVE_RATIO: c_int = 20; pub const VM_MIN_FREE_KBYTES: c_int = 21; pub const VM_MAX_MAP_COUNT: c_int = 22; -pub const VM_LAPTOP_MODE: c_int = 23; pub const VM_BLOCK_DUMP: c_int = 24; pub const VM_HUGETLB_GROUP: c_int = 25; pub const VM_VFS_CACHE_PRESSURE: c_int = 26; @@ -3902,21 +3628,6 @@ pub const XDP_TX_METADATA: crate::__u32 = 1 << 1; pub const SOL_XDP: c_int = 283; -// linux/mount.h -pub const MOUNT_ATTR_RDONLY: crate::__u64 = 0x00000001; -pub const MOUNT_ATTR_NOSUID: crate::__u64 = 0x00000002; -pub const MOUNT_ATTR_NODEV: crate::__u64 = 0x00000004; -pub const MOUNT_ATTR_NOEXEC: crate::__u64 = 0x00000008; -pub const MOUNT_ATTR__ATIME: crate::__u64 = 0x00000070; -pub const MOUNT_ATTR_RELATIME: crate::__u64 = 0x00000000; -pub const MOUNT_ATTR_NOATIME: crate::__u64 = 0x00000010; -pub const MOUNT_ATTR_STRICTATIME: crate::__u64 = 0x00000020; -pub const MOUNT_ATTR_NODIRATIME: crate::__u64 = 0x00000080; -pub const MOUNT_ATTR_IDMAP: crate::__u64 = 0x00100000; -pub const MOUNT_ATTR_NOSYMFOLLOW: crate::__u64 = 0x00200000; - -pub const MOUNT_ATTR_SIZE_VER0: c_int = 32; - pub const SCHED_FLAG_KEEP_ALL: c_int = SCHED_FLAG_KEEP_POLICY | SCHED_FLAG_KEEP_PARAMS; pub const SCHED_FLAG_UTIL_CLAMP: c_int = SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX; @@ -3953,10 +3664,6 @@ f! { ee.offset(1) as *mut crate::sockaddr } - pub fn TPACKET_ALIGN(x: usize) -> usize { - (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1) - } - pub fn BPF_CLASS(code: __u32) -> __u32 { code & 0x07 } 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 82df29bf43a1..5a1fa8866add 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -373,6 +373,7 @@ pub const SYS_pread64: c_long = 67; pub const SYS_pwrite64: c_long = 68; pub const SYS_preadv: c_long = 69; pub const SYS_pwritev: c_long = 70; +pub const SYS_sendfile: c_long = 71; pub const SYS_pselect6: c_long = 72; pub const SYS_ppoll: c_long = 73; pub const SYS_signalfd4: c_long = 74; @@ -524,6 +525,7 @@ pub const SYS_keyctl: c_long = 219; pub const SYS_clone: c_long = 220; pub const SYS_execve: c_long = 221; pub const SYS_mmap: c_long = 222; +pub const SYS_fadvise64: c_long = 223; pub const SYS_swapon: c_long = 224; pub const SYS_swapoff: c_long = 225; pub const SYS_mprotect: c_long = 226; diff --git a/src/unix/linux_like/linux/musl/lfs64.rs b/src/unix/linux_like/linux/musl/lfs64.rs index 4d595fc42d72..c74fb8460a02 100644 --- a/src/unix/linux_like/linux/musl/lfs64.rs +++ b/src/unix/linux_like/linux/musl/lfs64.rs @@ -18,7 +18,7 @@ pub unsafe extern "C" fn fallocate64( #[inline] pub unsafe extern "C" fn fgetpos64(stream: *mut crate::FILE, pos: *mut crate::fpos64_t) -> c_int { - crate::fgetpos(stream, pos as *mut _) + crate::fgetpos(stream, pos.cast()) } #[inline] @@ -46,12 +46,12 @@ pub unsafe extern "C" fn fseeko64( #[inline] pub unsafe extern "C" fn fsetpos64(stream: *mut crate::FILE, pos: *const crate::fpos64_t) -> c_int { - crate::fsetpos(stream, pos as *mut _) + crate::fsetpos(stream, pos.cast()) } #[inline] pub unsafe extern "C" fn fstat64(fildes: c_int, buf: *mut crate::stat64) -> c_int { - crate::fstat(fildes, buf as *mut _) + crate::fstat(fildes, buf.cast()) } #[inline] @@ -61,17 +61,17 @@ pub unsafe extern "C" fn fstatat64( buf: *mut crate::stat64, flag: c_int, ) -> c_int { - crate::fstatat(fd, path, buf as *mut _, flag) + crate::fstatat(fd, path, buf.cast(), flag) } #[inline] pub unsafe extern "C" fn fstatfs64(fd: c_int, buf: *mut crate::statfs64) -> c_int { - crate::fstatfs(fd, buf as *mut _) + crate::fstatfs(fd, buf.cast()) } #[inline] pub unsafe extern "C" fn fstatvfs64(fd: c_int, buf: *mut crate::statvfs64) -> c_int { - crate::fstatvfs(fd, buf as *mut _) + crate::fstatvfs(fd, buf.cast()) } #[inline] @@ -86,7 +86,7 @@ pub unsafe extern "C" fn ftruncate64(fd: c_int, length: off64_t) -> c_int { #[inline] pub unsafe extern "C" fn getrlimit64(resource: c_int, rlim: *mut crate::rlimit64) -> c_int { - crate::getrlimit(resource, rlim as *mut _) + crate::getrlimit(resource, rlim.cast()) } #[inline] @@ -96,7 +96,7 @@ pub unsafe extern "C" fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> o #[inline] pub unsafe extern "C" fn lstat64(path: *const c_char, buf: *mut crate::stat64) -> c_int { - crate::lstat(path, buf as *mut _) + crate::lstat(path, buf.cast()) } #[inline] @@ -164,7 +164,7 @@ pub unsafe extern "C" fn prlimit64( new_limit: *const crate::rlimit64, old_limit: *mut crate::rlimit64, ) -> c_int { - crate::prlimit(pid, resource, new_limit as *mut _, old_limit as *mut _) + crate::prlimit(pid, resource, new_limit.cast(), old_limit.cast()) } #[inline] @@ -189,7 +189,7 @@ pub unsafe extern "C" fn pwritev64( #[inline] pub unsafe extern "C" fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64 { - crate::readdir(dirp) as *mut _ + crate::readdir(dirp).cast() } #[inline] @@ -198,7 +198,7 @@ pub unsafe extern "C" fn readdir64_r( entry: *mut crate::dirent64, result: *mut *mut crate::dirent64, ) -> c_int { - crate::readdir_r(dirp, entry as *mut _, result as *mut _) + crate::readdir_r(dirp, entry.cast(), result.cast()) } #[inline] @@ -213,22 +213,22 @@ pub unsafe extern "C" fn sendfile64( #[inline] pub unsafe extern "C" fn setrlimit64(resource: c_int, rlim: *const crate::rlimit64) -> c_int { - crate::setrlimit(resource, rlim as *mut _) + crate::setrlimit(resource, rlim.cast()) } #[inline] pub unsafe extern "C" fn stat64(pathname: *const c_char, statbuf: *mut crate::stat64) -> c_int { - crate::stat(pathname, statbuf as *mut _) + crate::stat(pathname, statbuf.cast()) } #[inline] pub unsafe extern "C" fn statfs64(pathname: *const c_char, buf: *mut crate::statfs64) -> c_int { - crate::statfs(pathname, buf as *mut _) + crate::statfs(pathname, buf.cast()) } #[inline] pub unsafe extern "C" fn statvfs64(path: *const c_char, buf: *mut crate::statvfs64) -> c_int { - crate::statvfs(path, buf as *mut _) + crate::statvfs(path, buf.cast()) } #[inline] diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 9d3009cba880..2677462436d4 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -61,7 +61,7 @@ impl siginfo_t { _si_code: c_int, si_addr: *mut c_void, } - (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + (*(self as *const siginfo_t).cast::()).si_addr } pub unsafe fn si_value(&self) -> crate::sigval { @@ -74,7 +74,7 @@ impl siginfo_t { _si_overrun: c_int, si_value: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + (*(self as *const siginfo_t).cast::()).si_value } } @@ -105,7 +105,7 @@ s_no_extra_traits! { impl siginfo_t { unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields + &(*(self as *const siginfo_t).cast::()).sifields } pub unsafe fn si_pid(&self) -> crate::pid_t { @@ -507,8 +507,6 @@ pub const MAP_HUGE_1GB: c_int = 30 << MAP_HUGE_SHIFT; pub const MAP_HUGE_2GB: c_int = 31 << MAP_HUGE_SHIFT; pub const MAP_HUGE_16GB: c_int = 34 << MAP_HUGE_SHIFT; -pub const MS_RMT_MASK: c_ulong = 0x02800051; - // include/utmpx.h pub const EMPTY: c_short = 0; pub const RUN_LVL: c_short = 1; @@ -795,6 +793,13 @@ extern "C" { flags: c_int, ) -> ssize_t; pub fn getauxval(type_: c_ulong) -> c_ulong; + pub fn renameat2( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_uint, + ) -> c_int; // Added in `musl` 1.1.20 pub fn explicit_bzero(s: *mut c_void, len: size_t); diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 26dd49b24465..56e37a113410 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -2,7 +2,6 @@ use crate::off64_t; use crate::prelude::*; pub type wchar_t = c_uint; -pub type time_t = c_long; pub type clock_t = c_long; pub type fsblkcnt_t = c_ulong; @@ -10,7 +9,6 @@ pub type fsfilcnt_t = c_ulong; pub type ino_t = c_ulong; pub type off_t = c_long; pub type pthread_t = c_ulong; -pub type suseconds_t = c_long; pub type nlink_t = c_uint; pub type blksize_t = c_long; 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 93ed7ab21333..92a3d218eb0d 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -2,8 +2,6 @@ use crate::off64_t; use crate::prelude::*; pub type clock_t = i32; -pub type time_t = i32; -pub type suseconds_t = i32; pub type wchar_t = i32; pub type off_t = i32; pub type ino_t = u32; diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index 4495181400d4..a6a63a33a93b 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -8,8 +8,6 @@ pub type fsfilcnt_t = c_ulong; pub type ino_t = u64; pub type nlink_t = u64; pub type off_t = i64; -pub type suseconds_t = i64; -pub type time_t = i64; pub type wchar_t = i32; s! { diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index f70e0c41aeed..6c3d8013f917 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -12,6 +12,17 @@ pub type rlim_t = c_ulong; pub type __rlimit_resource_t = c_ulong; pub type __priority_which_t = c_uint; +cfg_if! { + // Set `--cfg=libc_unstable_uclibc_time64` in RUSTFLAGS if your uClibc has 64-bit `time_t`. + if #[cfg(linux_time_bits64)] { + pub type time_t = i64; + pub type suseconds_t = i64; + } else { + pub type time_t = c_long; + pub type suseconds_t = c_long; + } +} + cfg_if! { if #[cfg(doc)] { // Used in `linux::arch` to define ioctl constants. @@ -87,37 +98,6 @@ s! { pub nr: crate::__s32, } - #[cfg_attr( - any( - target_pointer_width = "32", - target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64" - ), - repr(align(4)) - )] - #[cfg_attr( - not(any( - target_pointer_width = "32", - target_arch = "x86_64", - target_arch = "powerpc64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64" - )), - repr(align(8)) - )] - pub struct pthread_mutexattr_t { - size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[repr(align(4))] - pub struct pthread_condattr_t { - size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], - } - pub struct tcp_info { pub tcpi_state: u8, pub tcpi_ca_state: u8, @@ -164,7 +144,7 @@ impl siginfo_t { _si_code: c_int, si_addr: *mut c_void, } - (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + (*(self as *const siginfo_t).cast::()).si_addr } pub unsafe fn si_value(&self) -> crate::sigval { @@ -177,7 +157,7 @@ impl siginfo_t { _si_overrun: c_int, si_value: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + (*(self as *const siginfo_t).cast::()).si_value } } @@ -208,7 +188,7 @@ s_no_extra_traits! { impl siginfo_t { unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields + &(*(self as *const siginfo_t).cast::()).sifields } pub unsafe fn si_pid(&self) -> crate::pid_t { @@ -288,79 +268,17 @@ pub const LC_MESSAGES: c_int = 5; pub const LC_ALL: c_int = 6; // end different section -// MS_ flags for mount(2) -pub const MS_RMT_MASK: c_ulong = - crate::MS_RDONLY | crate::MS_SYNCHRONOUS | crate::MS_MANDLOCK | crate::MS_I_VERSION; - pub const ENOTSUP: c_int = EOPNOTSUPP; pub const IPV6_JOIN_GROUP: c_int = 20; pub const IPV6_LEAVE_GROUP: c_int = 21; -// These are different from GNU -pub const ABDAY_1: crate::nl_item = 0x300; -pub const ABDAY_2: crate::nl_item = 0x301; -pub const ABDAY_3: crate::nl_item = 0x302; -pub const ABDAY_4: crate::nl_item = 0x303; -pub const ABDAY_5: crate::nl_item = 0x304; -pub const ABDAY_6: crate::nl_item = 0x305; -pub const ABDAY_7: crate::nl_item = 0x306; -pub const DAY_1: crate::nl_item = 0x307; -pub const DAY_2: crate::nl_item = 0x308; -pub const DAY_3: crate::nl_item = 0x309; -pub const DAY_4: crate::nl_item = 0x30A; -pub const DAY_5: crate::nl_item = 0x30B; -pub const DAY_6: crate::nl_item = 0x30C; -pub const DAY_7: crate::nl_item = 0x30D; -pub const ABMON_1: crate::nl_item = 0x30E; -pub const ABMON_2: crate::nl_item = 0x30F; -pub const ABMON_3: crate::nl_item = 0x310; -pub const ABMON_4: crate::nl_item = 0x311; -pub const ABMON_5: crate::nl_item = 0x312; -pub const ABMON_6: crate::nl_item = 0x313; -pub const ABMON_7: crate::nl_item = 0x314; -pub const ABMON_8: crate::nl_item = 0x315; -pub const ABMON_9: crate::nl_item = 0x316; -pub const ABMON_10: crate::nl_item = 0x317; -pub const ABMON_11: crate::nl_item = 0x318; -pub const ABMON_12: crate::nl_item = 0x319; -pub const MON_1: crate::nl_item = 0x31A; -pub const MON_2: crate::nl_item = 0x31B; -pub const MON_3: crate::nl_item = 0x31C; -pub const MON_4: crate::nl_item = 0x31D; -pub const MON_5: crate::nl_item = 0x31E; -pub const MON_6: crate::nl_item = 0x31F; -pub const MON_7: crate::nl_item = 0x320; -pub const MON_8: crate::nl_item = 0x321; -pub const MON_9: crate::nl_item = 0x322; -pub const MON_10: crate::nl_item = 0x323; -pub const MON_11: crate::nl_item = 0x324; -pub const MON_12: crate::nl_item = 0x325; -pub const AM_STR: crate::nl_item = 0x326; -pub const PM_STR: crate::nl_item = 0x327; -pub const D_T_FMT: crate::nl_item = 0x328; -pub const D_FMT: crate::nl_item = 0x329; -pub const T_FMT: crate::nl_item = 0x32A; -pub const T_FMT_AMPM: crate::nl_item = 0x32B; -pub const ERA: crate::nl_item = 0x32C; -pub const ERA_D_FMT: crate::nl_item = 0x32E; -pub const ALT_DIGITS: crate::nl_item = 0x32F; -pub const ERA_D_T_FMT: crate::nl_item = 0x330; -pub const ERA_T_FMT: crate::nl_item = 0x331; -pub const CODESET: crate::nl_item = 10; -pub const CRNCYSTR: crate::nl_item = 0x215; -pub const RADIXCHAR: crate::nl_item = 0x100; -pub const THOUSEP: crate::nl_item = 0x101; -pub const NOEXPR: crate::nl_item = 0x501; -pub const YESSTR: crate::nl_item = 0x502; -pub const NOSTR: crate::nl_item = 0x503; - // Different than Gnu. pub const FILENAME_MAX: c_uint = 4095; -pub const PRIO_PROCESS: c_int = 0; -pub const PRIO_PGRP: c_int = 1; -pub const PRIO_USER: c_int = 2; +pub const PRIO_PROCESS: crate::__priority_which_t = 0; +pub const PRIO_PGRP: crate::__priority_which_t = 1; +pub const PRIO_USER: crate::__priority_which_t = 2; pub const SOMAXCONN: c_int = 128; @@ -418,7 +336,6 @@ pub const SOCK_PACKET: c_int = 10; pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; pub const UDP_GRO: c_int = 104; pub const UDP_SEGMENT: c_int = 103; -pub const YESEXPR: c_int = ((5) << 8) | (0); extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> 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 30e6772388d1..09ffffd2954b 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -14,8 +14,6 @@ pub type nlink_t = c_uint; pub type off_t = c_long; // [uClibc docs] Note stat64 has the same shape as stat for x86-64. pub type stat64 = stat; -pub type suseconds_t = c_long; -pub type time_t = c_int; pub type wchar_t = c_int; pub type pthread_t = c_ulong; diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index cf76b3966ffa..1877f3cadcf3 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -85,13 +85,6 @@ s! { __val: [c_int; 2], } - pub struct packet_mreq { - pub mr_ifindex: c_int, - pub mr_type: c_ushort, - pub mr_alen: c_ushort, - pub mr_address: [c_uchar; 8], - } - pub struct cpu_set_t { #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] bits: [u32; 32], @@ -805,11 +798,9 @@ pub const EM_M32R: u16 = 88; pub const EM_MN10300: u16 = 89; pub const EM_MN10200: u16 = 90; pub const EM_PJ: u16 = 91; -#[cfg(not(target_env = "uclibc"))] pub const EM_OPENRISC: u16 = 92; #[cfg(target_env = "uclibc")] pub const EM_OR1K: u16 = 92; -#[cfg(not(target_env = "uclibc"))] pub const EM_ARC_A5: u16 = 93; pub const EM_XTENSA: u16 = 94; pub const EM_AARCH64: u16 = 183; @@ -884,7 +875,6 @@ pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value // wherever it is defined. pub const AT_SYSINFO_EHDR: c_ulong = 33; -#[cfg(not(target_env = "uclibc"))] pub const AT_MINSIGSTKSZ: c_ulong = 51; pub const GLOB_ERR: c_int = 1 << 0; @@ -939,21 +929,16 @@ pub const PTHREAD_MUTEX_NORMAL: c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; -#[cfg(not(target_env = "uclibc"))] pub const PTHREAD_MUTEX_STALLED: c_int = 0; -#[cfg(not(target_env = "uclibc"))] pub const PTHREAD_MUTEX_ROBUST: c_int = 1; -#[cfg(not(target_env = "uclibc"))] pub const PTHREAD_PRIO_NONE: c_int = 0; -#[cfg(not(target_env = "uclibc"))] pub const PTHREAD_PRIO_INHERIT: c_int = 1; -#[cfg(not(target_env = "uclibc"))] pub const PTHREAD_PRIO_PROTECT: c_int = 2; pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; pub const PTHREAD_PROCESS_SHARED: c_int = 1; pub const PTHREAD_INHERIT_SCHED: c_int = 0; pub const PTHREAD_EXPLICIT_SCHED: c_int = 1; -#[cfg(not(all(target_os = "l4re", target_env = "uclibc")))] +#[cfg(not(target_os = "l4re"))] pub const __SIZEOF_PTHREAD_COND_T: usize = 48; // netinet/in.h @@ -1193,11 +1178,11 @@ pub const IUTF8: crate::tcflag_t = 0x00004000; #[cfg(not(all(target_env = "uclibc", target_arch = "mips")))] pub const CMSPAR: crate::tcflag_t = 0o10000000000; -pub const MFD_CLOEXEC: c_uint = 0x0001; -pub const MFD_ALLOW_SEALING: c_uint = 0x0002; -pub const MFD_HUGETLB: c_uint = 0x0004; cfg_if! { - if #[cfg(not(target_env = "uclibc"))] { + if #[cfg(not(target_os = "l4re"))] { + pub const MFD_CLOEXEC: c_uint = 0x0001; + pub const MFD_ALLOW_SEALING: c_uint = 0x0002; + pub const MFD_HUGETLB: c_uint = 0x0004; pub const MFD_NOEXEC_SEAL: c_uint = 0x0008; pub const MFD_EXEC: c_uint = 0x0010; pub const MFD_HUGE_64KB: c_uint = 0x40000000; @@ -1217,43 +1202,6 @@ cfg_if! { } } -// linux/if_packet.h -pub const PACKET_HOST: c_uchar = 0; -pub const PACKET_BROADCAST: c_uchar = 1; -pub const PACKET_MULTICAST: c_uchar = 2; -pub const PACKET_OTHERHOST: c_uchar = 3; -pub const PACKET_OUTGOING: c_uchar = 4; -pub const PACKET_LOOPBACK: c_uchar = 5; -#[cfg(not(target_os = "l4re"))] -pub const PACKET_USER: c_uchar = 6; -#[cfg(not(target_os = "l4re"))] -pub const PACKET_KERNEL: c_uchar = 7; - -pub const PACKET_ADD_MEMBERSHIP: c_int = 1; -pub const PACKET_DROP_MEMBERSHIP: c_int = 2; -pub const PACKET_RECV_OUTPUT: c_int = 3; -pub const PACKET_RX_RING: c_int = 5; -pub const PACKET_STATISTICS: c_int = 6; -cfg_if! { - if #[cfg(not(target_os = "l4re"))] { - pub const PACKET_COPY_THRESH: c_int = 7; - pub const PACKET_AUXDATA: c_int = 8; - pub const PACKET_ORIGDEV: c_int = 9; - pub const PACKET_VERSION: c_int = 10; - pub const PACKET_HDRLEN: c_int = 11; - pub const PACKET_RESERVE: c_int = 12; - pub const PACKET_TX_RING: c_int = 13; - pub const PACKET_LOSS: c_int = 14; - pub const PACKET_VNET_HDR: c_int = 15; - pub const PACKET_TX_TIMESTAMP: c_int = 16; - pub const PACKET_TIMESTAMP: c_int = 17; - } -} - -pub const PACKET_MR_MULTICAST: c_int = 0; -pub const PACKET_MR_PROMISC: c_int = 1; -pub const PACKET_MR_ALLMULTI: c_int = 2; - pub const SIOCADDRT: c_ulong = 0x0000890B; pub const SIOCDELRT: c_ulong = 0x0000890C; pub const SIOCGIFNAME: c_ulong = 0x00008910; @@ -1485,7 +1433,7 @@ f! { cmsg: *const crate::cmsghdr, ) -> *mut crate::cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::() { - return core::ptr::null_mut::(); + return ptr::null_mut(); } // FIXME(msrv): `.wrapping_byte_add()` stabilized in 1.75 @@ -1497,7 +1445,7 @@ f! { // In case the addition wrapped. `next_addr > max_addr` // would otherwise not work as intended. if (next_cmsg as usize) < (cmsg as usize) { - return core::ptr::null_mut(); + return ptr::null_mut(); } let mut max_addr = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; @@ -1510,7 +1458,7 @@ f! { } if next_cmsg as usize + size_of::() > max_addr { - core::ptr::null_mut::() + ptr::null_mut() } else { next_cmsg as *mut crate::cmsghdr } @@ -1523,9 +1471,7 @@ f! { } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in &mut cpuset.bits { - *slot = 0; - } + cpuset.bits.fill(0); } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 59e16a0f3c4b..3d6a86ea9c75 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -250,6 +250,14 @@ cfg_if! { pub len: c_ushort, pub filter: *mut sock_filter, } + + // linux/futex.h + pub struct futex_waitv { + pub val: crate::__u64, + pub uaddr: crate::__u64, + pub flags: crate::__u32, + __reserved: Padding, + } } } } @@ -545,6 +553,7 @@ pub const MS_NODIRATIME: c_ulong = 0x0800; pub const MS_BIND: c_ulong = 0x1000; pub const MS_MOVE: c_ulong = 0x2000; pub const MS_REC: c_ulong = 0x4000; +// MS_VERBOSE is deprecated pub const MS_SILENT: c_ulong = 0x8000; pub const MS_POSIXACL: c_ulong = 0x010000; pub const MS_UNBINDABLE: c_ulong = 0x020000; @@ -760,11 +769,8 @@ pub const IP_TRANSPARENT: c_int = 19; pub const IP_ORIGDSTADDR: c_int = 20; pub const IP_RECVORIGDSTADDR: c_int = IP_ORIGDSTADDR; pub const IP_MINTTL: c_int = 21; -#[cfg(not(target_env = "uclibc"))] pub const IP_NODEFRAG: c_int = 22; -#[cfg(not(target_env = "uclibc"))] pub const IP_CHECKSUM: c_int = 23; -#[cfg(not(target_env = "uclibc"))] pub const IP_BIND_ADDRESS_NO_PORT: c_int = 24; pub const IP_MULTICAST_IF: c_int = 32; pub const IP_MULTICAST_TTL: c_int = 33; @@ -786,9 +792,7 @@ pub const IP_PMTUDISC_DONT: c_int = 0; pub const IP_PMTUDISC_WANT: c_int = 1; pub const IP_PMTUDISC_DO: c_int = 2; pub const IP_PMTUDISC_PROBE: c_int = 3; -#[cfg(not(target_env = "uclibc"))] pub const IP_PMTUDISC_INTERFACE: c_int = 4; -#[cfg(not(target_env = "uclibc"))] pub const IP_PMTUDISC_OMIT: c_int = 5; // IPPROTO_IP defined in src/unix/mod.rs @@ -898,32 +902,25 @@ pub const IPV6_RECVRTHDR: c_int = 56; pub const IPV6_RTHDR: c_int = 57; pub const IPV6_RECVDSTOPTS: c_int = 58; pub const IPV6_DSTOPTS: c_int = 59; -#[cfg(not(target_env = "uclibc"))] pub const IPV6_RECVPATHMTU: c_int = 60; -#[cfg(not(target_env = "uclibc"))] pub const IPV6_PATHMTU: c_int = 61; -#[cfg(not(target_env = "uclibc"))] pub const IPV6_DONTFRAG: c_int = 62; pub const IPV6_RECVTCLASS: c_int = 66; pub const IPV6_TCLASS: c_int = 67; -cfg_if! { - if #[cfg(not(target_env = "uclibc"))] { - pub const IPV6_AUTOFLOWLABEL: c_int = 70; - pub const IPV6_ADDR_PREFERENCES: c_int = 72; - pub const IPV6_MINHOPCOUNT: c_int = 73; - pub const IPV6_ORIGDSTADDR: c_int = 74; - pub const IPV6_RECVORIGDSTADDR: c_int = IPV6_ORIGDSTADDR; - pub const IPV6_TRANSPARENT: c_int = 75; - pub const IPV6_UNICAST_IF: c_int = 76; - pub const IPV6_PREFER_SRC_TMP: c_int = 0x0001; - pub const IPV6_PREFER_SRC_PUBLIC: c_int = 0x0002; - pub const IPV6_PREFER_SRC_PUBTMP_DEFAULT: c_int = 0x0100; - pub const IPV6_PREFER_SRC_COA: c_int = 0x0004; - pub const IPV6_PREFER_SRC_HOME: c_int = 0x0400; - pub const IPV6_PREFER_SRC_CGA: c_int = 0x0008; - pub const IPV6_PREFER_SRC_NONCGA: c_int = 0x0800; - } -} +pub const IPV6_AUTOFLOWLABEL: c_int = 70; +pub const IPV6_ADDR_PREFERENCES: c_int = 72; +pub const IPV6_MINHOPCOUNT: c_int = 73; +pub const IPV6_ORIGDSTADDR: c_int = 74; +pub const IPV6_RECVORIGDSTADDR: c_int = IPV6_ORIGDSTADDR; +pub const IPV6_TRANSPARENT: c_int = 75; +pub const IPV6_UNICAST_IF: c_int = 76; +pub const IPV6_PREFER_SRC_TMP: c_int = 0x0001; +pub const IPV6_PREFER_SRC_PUBLIC: c_int = 0x0002; +pub const IPV6_PREFER_SRC_PUBTMP_DEFAULT: c_int = 0x0100; +pub const IPV6_PREFER_SRC_COA: c_int = 0x0004; +pub const IPV6_PREFER_SRC_HOME: c_int = 0x0400; +pub const IPV6_PREFER_SRC_CGA: c_int = 0x0008; +pub const IPV6_PREFER_SRC_NONCGA: c_int = 0x0800; pub const IPV6_PMTUDISC_DONT: c_int = 0; pub const IPV6_PMTUDISC_WANT: c_int = 1; @@ -1170,14 +1167,10 @@ pub const __WNOTHREAD: c_int = 0x20000000; pub const __WALL: c_int = 0x40000000; pub const __WCLONE: c_int = 0x80000000; -cfg_if! { - if #[cfg(not(target_env = "uclibc"))] { - pub const SPLICE_F_MOVE: c_uint = 0x01; - pub const SPLICE_F_NONBLOCK: c_uint = 0x02; - pub const SPLICE_F_MORE: c_uint = 0x04; - pub const SPLICE_F_GIFT: c_uint = 0x08; - } -} +pub const SPLICE_F_MOVE: c_uint = 0x01; +pub const SPLICE_F_NONBLOCK: c_uint = 0x02; +pub const SPLICE_F_MORE: c_uint = 0x04; +pub const SPLICE_F_GIFT: c_uint = 0x08; pub const RTLD_LOCAL: c_int = 0; pub const RTLD_LAZY: c_int = 1; @@ -1740,9 +1733,9 @@ const fn CMSG_ALIGN(len: usize) -> usize { f! { pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut crate::cmsghdr { if (*mhdr).msg_controllen as usize >= size_of::() { - (*mhdr).msg_control.cast::() + (*mhdr).msg_control.cast() } else { - core::ptr::null_mut::() + ptr::null_mut() } } @@ -1779,9 +1772,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in &mut (*set).fds_bits { - *slot = 0; - } + (*set).fds_bits.fill(0); } } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 207c36b82d55..3f5451c2b643 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -957,6 +957,15 @@ extern "C" { )] #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")] pub fn opendir(dirname: *const c_char) -> *mut crate::DIR; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "fdopendir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fdopendir$INODE64$UNIX2003" + )] + pub fn fdopendir(fd: c_int) -> *mut crate::DIR; #[cfg_attr( all(target_os = "macos", not(target_arch = "aarch64")), @@ -994,6 +1003,8 @@ extern "C" { group: crate::gid_t, flags: c_int, ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")] + pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; #[cfg_attr( all(target_os = "macos", not(target_arch = "aarch64")), link_name = "fstatat$INODE64" @@ -1019,6 +1030,8 @@ extern "C" { flags: c_int, ) -> c_int; #[cfg(not(target_os = "l4re"))] + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + #[cfg(not(target_os = "l4re"))] pub fn renameat( olddirfd: c_int, oldpath: *const c_char, @@ -2201,22 +2214,6 @@ cfg_if! { link_name = "pause$UNIX2003" )] pub fn pause() -> c_int; - - #[cfg(not(target_os = "l4re"))] - pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; - #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")] - pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; - - #[cfg_attr( - all(target_os = "macos", target_arch = "x86_64"), - link_name = "fdopendir$INODE64" - )] - #[cfg_attr( - all(target_os = "macos", target_arch = "x86"), - link_name = "fdopendir$INODE64$UNIX2003" - )] - pub fn fdopendir(fd: c_int) -> *mut crate::DIR; - #[cfg_attr( all(target_os = "macos", not(target_arch = "aarch64")), link_name = "readdir_r$INODE64" diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 9e7df163e62e..5783e66b5472 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -837,9 +837,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 022fb0be1f78..551d034b660a 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2428,9 +2428,9 @@ const fn _ALIGN(p: usize, b: usize) -> usize { f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { if (*mhdr).msg_controllen as usize >= size_of::() { - (*mhdr).msg_control as *mut cmsghdr + (*mhdr).msg_control.cast() } else { - core::ptr::null_mut::() + ptr::null_mut() } } @@ -2438,7 +2438,7 @@ f! { let msg = _CMSG_ALIGN((*cmsg).cmsg_len as usize); let next = cmsg as usize + msg + _CMSG_ALIGN(size_of::()); if next > (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize { - core::ptr::null_mut::() + ptr::null_mut() } else { (cmsg as usize + msg) as *mut cmsghdr } @@ -2477,9 +2477,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } pub fn _DEXTRA_FIRST(_d: *const dirent) -> *mut crate::dirent_extra { @@ -3150,7 +3148,7 @@ pub unsafe fn atexit(cb: extern "C" fn()) -> c_int { static __dso_handle: *mut c_void; pub fn __cxa_atexit(cb: extern "C" fn(), __arg: *mut c_void, __dso: *mut c_void) -> c_int; } - __cxa_atexit(cb, 0 as *mut c_void, __dso_handle) + __cxa_atexit(cb, ptr::null_mut(), __dso_handle) } impl siginfo_t { @@ -3160,7 +3158,7 @@ impl siginfo_t { _pad: Padding<[u8; 32]>, si_addr: *mut c_void, } - (*(self as *const siginfo_t as *const siginfo_si_addr)).si_addr + (*(self as *const siginfo_t).cast::()).si_addr } pub unsafe fn si_value(&self) -> crate::sigval { @@ -3169,7 +3167,7 @@ impl siginfo_t { _pad: Padding<[u8; 32]>, si_value: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + (*(self as *const siginfo_t).cast::()).si_value } pub unsafe fn si_pid(&self) -> crate::pid_t { @@ -3178,7 +3176,7 @@ impl siginfo_t { _pad: Padding<[u8; 16]>, si_pid: crate::pid_t, } - (*(self as *const siginfo_t as *const siginfo_si_pid)).si_pid + (*(self as *const siginfo_t).cast::()).si_pid } pub unsafe fn si_uid(&self) -> crate::uid_t { @@ -3187,7 +3185,7 @@ impl siginfo_t { _pad: Padding<[u8; 24]>, si_uid: crate::uid_t, } - (*(self as *const siginfo_t as *const siginfo_si_uid)).si_uid + (*(self as *const siginfo_t).cast::()).si_uid } pub unsafe fn si_status(&self) -> c_int { @@ -3196,7 +3194,7 @@ impl siginfo_t { _pad: Padding<[u8; 28]>, si_status: c_int, } - (*(self as *const siginfo_t as *const siginfo_si_status)).si_status + (*(self as *const siginfo_t).cast::()).si_status } } diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 150dc43557d2..0f65225fe48f 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -501,9 +501,13 @@ pub const SO_LINGER: i32 = 6; pub const SO_RCVTIMEO: i32 = 0xa; pub const SO_SNDTIMEO: i32 = 0xe; pub const SO_BROADCAST: i32 = 1; +pub const SO_KEEPALIVE: i32 = 5; // netinet/tcp.h pub const TCP_NODELAY: i32 = 0x10; +pub const TCP_KEEPIDLE: i32 = 0x11; +pub const TCP_KEEPINTVL: i32 = 0x12; +pub const TCP_KEEPCNT: i32 = 0x13; // nuttx/fs/ioctl.h pub const FIONBIO: i32 = 0x30a; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 691fe5c5fced..bd39b872c383 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -345,6 +345,11 @@ pub const F_TLOCK: c_int = 2; pub const F_TEST: c_int = 3; pub const AT_FDCWD: c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x200; +pub const AT_REMOVEDIR: c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: c_int = 0x2000; +pub const AT_EMPTY_PATH: c_int = 0x4000; +pub const AT_EACCESS: c_int = 0x400; // FIXME(redox): relibc { pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); @@ -516,6 +521,7 @@ pub const O_SHLOCK: c_int = 0x0010_0000; pub const O_EXLOCK: c_int = 0x0020_0000; pub const O_ASYNC: c_int = 0x0040_0000; pub const O_FSYNC: c_int = 0x0080_0000; +pub const O_SYNC: c_int = O_FSYNC; pub const O_CLOEXEC: c_int = 0x0100_0000; pub const O_CREAT: c_int = 0x0200_0000; pub const O_TRUNC: c_int = 0x0400_0000; @@ -725,6 +731,8 @@ pub const S_IRWXO: c_int = 0o0007; pub const S_IROTH: c_int = 0o0004; pub const S_IWOTH: c_int = 0o0002; pub const S_IXOTH: c_int = 0o0001; +pub const UTIME_NOW: c_long = 0xffffffff; +pub const UTIME_OMIT: c_long = 0xfffffffe; // stdlib.h pub const EXIT_SUCCESS: c_int = 0; @@ -1134,9 +1142,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } } @@ -1206,8 +1212,10 @@ extern "C" { // dirent.h pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); // unistd.h + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; pub fn getdtablesize() -> c_int; pub fn getresgid( @@ -1408,6 +1416,13 @@ extern "C" { // sys/stat.h pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; // sys/uio.h pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; @@ -1420,6 +1435,7 @@ extern "C" { // time.h pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn strftime( s: *mut c_char, diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index 50e6302e7c9e..b31c31bd1f6c 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -207,6 +207,10 @@ pub const B4000000: crate::speed_t = 31; // sys/systeminfo.h pub const SI_ADDRESS_WIDTH: c_int = 520; +// netinet/in.h +pub const IP_MINTTL: c_int = 0x1c; +pub const IPV6_MINHOPCOUNT: c_int = 0x2f; + // sys/timerfd.h pub const TFD_CLOEXEC: i32 = 0o2000000; pub const TFD_NONBLOCK: i32 = 0o4000; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 494ecdb7d95c..5ef4a301c927 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -882,6 +882,7 @@ pub const IPV6_MULTICAST_IF: c_int = 0x6; pub const IPV6_MULTICAST_HOPS: c_int = 0x7; pub const IPV6_MULTICAST_LOOP: c_int = 0x8; pub const IPV6_PKTINFO: c_int = 0xb; +pub const IPV6_HOPLIMIT: c_int = 0xc; pub const IPV6_RECVPKTINFO: c_int = 0x12; pub const IPV6_RECVTCLASS: c_int = 0x19; pub const IPV6_DONTFRAG: c_int = 0x21; @@ -1234,6 +1235,8 @@ pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; pub const EAI_OVERFLOW: c_int = 12; +pub const AI_CANONNAME: c_int = 0x0010; + pub const NI_NOFQDN: c_uint = 0x0001; pub const NI_NUMERICHOST: c_uint = 0x0002; pub const NI_NAMEREQD: c_uint = 0x0004; @@ -2218,9 +2221,9 @@ f! { pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { if ((*mhdr).msg_controllen as usize) < size_of::() { - core::ptr::null_mut::() + ptr::null_mut() } else { - (*mhdr).msg_control as *mut cmsghdr + (*mhdr).msg_control.cast::() } } @@ -2232,7 +2235,7 @@ f! { _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize + size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - core::ptr::null_mut::() + ptr::null_mut() } else { _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr } @@ -2263,9 +2266,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { - *slot = 0; - } + (*set).fds_bits.fill(0); } } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index bc4d53689647..58bf10838d59 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1,7 +1,5 @@ //! Interface to VxWorks C library -use core::ptr::null_mut; - use crate::prelude::*; extern_ty! { @@ -1333,7 +1331,7 @@ const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t = pthread_mutexattr_t { mutexAttrPshared: 1, }; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - mutexSemId: null_mut(), + mutexSemId: ptr::null_mut(), mutexValid: PTHREAD_VALID_OBJ, mutexInitted: PTHREAD_UNUSED_YET_OBJ, mutexCondRefCount: 0, @@ -1348,11 +1346,11 @@ const PTHREAD_CONDATTR_INITIALIZER: pthread_condattr_t = pthread_condattr_t { condAttrClockId: CLOCK_REALTIME, }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - condSemId: null_mut(), + condSemId: ptr::null_mut(), condValid: PTHREAD_VALID_OBJ, condInitted: PTHREAD_UNUSED_YET_OBJ, condRefCount: 0, - condMutex: null_mut(), + condMutex: ptr::null_mut(), condAttr: PTHREAD_CONDATTR_INITIALIZER, condSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX], }; @@ -1364,7 +1362,7 @@ const PTHREAD_RWLOCKATTR_INITIALIZER: pthread_rwlockattr_t = pthread_rwlockattr_ rwlockAttrConformOpt: 1, }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - rwlockSemId: null_mut(), + rwlockSemId: ptr::null_mut(), rwlockReadersRefCount: 0, rwlockValid: PTHREAD_VALID_OBJ, rwlockInitted: PTHREAD_UNUSED_YET_OBJ, @@ -1452,15 +1450,15 @@ f! { if next <= max { (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } else { - core::ptr::null_mut::() + ptr::null_mut() } } pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { if (*mhdr).msg_controllen as usize > 0 { - (*mhdr).msg_control as *mut cmsghdr + (*mhdr).msg_control.cast() } else { - core::ptr::null_mut::() + ptr::null_mut() } } diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index e580df52ad22..77c6368caef4 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -14,7 +14,7 @@ pub type ssize_t = isize; pub type ptrdiff_t = isize; pub type intptr_t = isize; pub type uintptr_t = usize; -pub type off_t = i64; +pub type off_t = c_longlong; pub type pid_t = i32; pub type clock_t = c_longlong; pub type time_t = c_longlong; diff --git a/triagebot.toml b/triagebot.toml index 91bc102738b5..0e34f9edbd58 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -4,6 +4,7 @@ allow-unauthenticated = [ "O-*", "S-*", "ctest", + "has-merge-commits", "stable-nominated", ] @@ -113,6 +114,10 @@ remove_labels = ["S-waiting-on-author"] # Those labels are added when PR author requests a review from an assignee add_labels = ["S-waiting-on-review"] +[no-merges] +exclude_titles = ["[0.2]"] +labels = ["has-merge-commits", "S-waiting-on-author"] + [shortcut] [mentions."*openbsd*"]