diff --git a/.cirrus.yml b/.cirrus.yml index 8caefcbb28a12..11556721e9b06 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -7,15 +7,16 @@ task: # https://github.com/rust-lang/rust/issues/132185 RUST_BACKTRACE: "0" matrix: - - name: nightly freebsd-13 i686 - # Test i686 FreeBSD in 32-bit emulation on a 64-bit host. - env: - TARGET: i686-unknown-freebsd - freebsd_instance: - image_family: freebsd-13-4 - - name: nightly freebsd-13 x86_64 - freebsd_instance: - image_family: freebsd-13-4 + # FIXME(#4740): FreeBSD 13 tests are extremely flaky and fail most of the time + # - name: nightly freebsd-13 i686 + # # Test i686 FreeBSD in 32-bit emulation on a 64-bit host. + # env: + # TARGET: i686-unknown-freebsd + # freebsd_instance: + # image_family: freebsd-13-4 + # - name: nightly freebsd-13 x86_64 + # freebsd_instance: + # image_family: freebsd-13-4 - name: nightly freebsd-14 x86_64 freebsd_instance: image: freebsd-14-3-release-amd64-ufs diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e074cbce02d9..6914a53d8e57a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,6 +13,7 @@ env: RUSTDOCFLAGS: -Dwarnings RUSTFLAGS: -Dwarnings RUST_BACKTRACE: full + TARGET_REF: ${{ github.base_ref || github.event.merge_group.base_ref }} defaults: run: @@ -24,21 +25,21 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Rust toolchain run: ./ci/install-rust.sh && rustup component add rustfmt - name: Check style - run: ./ci/style.sh + run: ./ci/style.py clippy: name: Clippy on ${{ matrix.os }} strategy: matrix: - os: [ubuntu-24.04, macos-15, windows-2022] + os: [ubuntu-24.04, macos-15, windows-2025] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - run: rustup update stable --no-self-update - uses: Swatinem/rust-cache@v2 # Here we use the latest stable Rust toolchain already installed by GitHub @@ -51,17 +52,23 @@ jobs: name: Verify build strategy: matrix: - toolchain: [stable, nightly, 1.63.0] - os: [ubuntu-24.04, macos-15, windows-2022] + toolchain: [stable, 1.63.0] include: + # Nightly has a lot of targets, so split it in half + - toolchain: nightly + half: 1 + - toolchain: nightly + half: 2 - toolchain: beta - os: ubuntu-24.04 - runs-on: ${{ matrix.os }} + only: '(aarch64|x86_64)' # just a spot check for beta + - toolchain: stable + - toolchain: 1.63.0 # msrv + runs-on: ubuntu-24.04 timeout-minutes: 25 env: TOOLCHAIN: ${{ matrix.toolchain }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Rust toolchain run: ./ci/install-rust.sh @@ -69,6 +76,10 @@ jobs: uses: taiki-e/install-action@cargo-semver-checks if: matrix.toolchain == 'stable' + - name: Retrieve semver baseline + if: matrix.toolchain == 'stable' + run: ./ci/prep-semver-baseline.sh + # FIXME(ci): These `du` statements are temporary for debugging cache - name: Target size before restoring cache run: du -sh target | sort -k 2 || true @@ -78,12 +89,16 @@ jobs: - name: Target size after restoring cache run: du -sh target | sort -k 2 || true - - name: Execute build.sh + - name: Execute build check run: | set -eux # Remove `-Dwarnings` at the MSRV since lints may be different [ "${{ matrix.toolchain }}" = "1.63.0" ] && export RUSTFLAGS="" - ./ci/verify-build.sh + python3 ci/verify-build.py \ + --toolchain "$TOOLCHAIN" \ + ${BASELINE_CRATE_DIR:+"--baseline-crate-dir" "$BASELINE_CRATE_DIR"} \ + ${{ matrix.only && format('--only "{0}"', matrix.only) }} \ + ${{ matrix.half && format('--half "{0}"', matrix.half) }} - name: Target size after job completion run: du -sh target | sort -k 2 @@ -92,46 +107,30 @@ jobs: strategy: matrix: include: - - target: i686-unknown-linux-gnu - docker: true - os: ubuntu-24.04 - - target: i686-unknown-linux-gnu - docker: true - os: ubuntu-24.04 - artifact-tag: offset-bits64 - env: - RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 - - target: i686-unknown-linux-gnu - docker: true - os: ubuntu-24.04 - artifact-tag: time-bits64 - env: - RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 - - target: x86_64-unknown-linux-gnu - docker: true - os: ubuntu-24.04 - target: aarch64-apple-darwin os: macos-15 - - target: x86_64-pc-windows-gnu - os: windows-2022 - env: - ARCH_BITS: 64 - ARCH: x86_64 - - target: x86_64-pc-windows-msvc - os: windows-2022 + - target: aarch64-pc-windows-msvc + os: windows-11-arm + - target: aarch64-unknown-linux-gnu + os: ubuntu-24.04-arm # FIXME: It currently causes segfaults. #- target: i686-pc-windows-gnu - # env: - # ARCH_BITS: 32 - # ARCH: i686 + # env: { ARCH_BITS: 32, ARCH: i686 } - target: i686-pc-windows-msvc - os: windows-2022 - runs-on: ${{ matrix.os }} + os: windows-2025 + - target: i686-unknown-linux-gnu + - target: x86_64-pc-windows-gnu + os: windows-2025 + env: { ARCH_BITS: 64, ARCH: x86_64 } + - target: x86_64-pc-windows-msvc + os: windows-2025 + - target: x86_64-unknown-linux-gnu + runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} timeout-minutes: 25 env: TARGET: ${{ matrix.target }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Rust toolchain run: ./ci/install-rust.sh - uses: Swatinem/rust-cache@v2 @@ -146,17 +145,17 @@ jobs: shell: bash - name: Run natively - if: "!matrix.docker" + if: runner.os != 'Linux' run: ./ci/run.sh ${{ matrix.target }} - name: Run in Docker - if: "matrix.docker" + if: runner.os == 'Linux' run: ./ci/run-docker.sh ${{ matrix.target }} - name: Create CI artifacts id: create_artifacts if: always() - run: ./ci/create-artifacts.py - - uses: actions/upload-artifact@v4 + run: python3 ci/create-artifacts.py + - uses: actions/upload-artifact@v5 if: always() && steps.create_artifacts.outcome == 'success' with: name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} @@ -166,81 +165,69 @@ jobs: # Unlike `main` this job doesn't have `needs`, in order to speed up backports a bit test_tier2: name: Test tier2 - runs-on: ubuntu-24.04 + needs: [test_tier1, style_check] strategy: fail-fast: true - max-parallel: 12 + max-parallel: 16 matrix: - target: + include: # FIXME(sparc): this takes much longer to run than any other job, put # it first to make sure it gets a head start. - - sparc64-unknown-linux-gnu - - aarch64-linux-android - - aarch64-unknown-linux-gnu - - aarch64-unknown-linux-musl - - arm-linux-androideabi - - arm-unknown-linux-musleabihf - # FIXME(#4297): Disabled due to spurious failueSome android jobs are disabled because of high rates of - # - i686-linux-android - - i686-unknown-linux-musl - - loongarch64-unknown-linux-gnu - - loongarch64-unknown-linux-musl - - powerpc64-unknown-linux-gnu - - powerpc64le-unknown-linux-gnu - - powerpc64le-unknown-linux-musl - - riscv64gc-unknown-linux-gnu - - s390x-unknown-linux-gnu - - wasm32-unknown-emscripten - - wasm32-wasip1 - - wasm32-wasip2 - - x86_64-linux-android - # FIXME: Exec format error (os error 8) - # - x86_64-unknown-linux-gnux32 - - x86_64-unknown-linux-musl - # FIXME: It seems some items in `src/unix/mod.rs` - # aren't defined on redox actually. - # - x86_64-unknown-redox - include: - - target: arm-unknown-linux-gnueabihf - - target: arm-unknown-linux-gnueabihf - env: - RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 - artifact-tag: offset-bits64 - - target: arm-unknown-linux-gnueabihf - env: - RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 - artifact-tag: time-bits64 + - target: sparc64-unknown-linux-gnu + - target: aarch64-linux-android - target: aarch64-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: aarch64-unknown-linux-musl + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + - target: arm-linux-androideabi + - target: arm-unknown-linux-gnueabihf + - target: arm-unknown-linux-musleabihf - target: arm-unknown-linux-musleabihf - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + # FIXME(#4297): Disabled due to spurious failue + # - target: i686-linux-android - target: i686-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: i686-unknown-linux-musl + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + - target: loongarch64-unknown-linux-gnu + - target: loongarch64-unknown-linux-musl - target: loongarch64-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + - target: powerpc64-unknown-linux-gnu + - target: powerpc64le-unknown-linux-gnu - target: powerpc64le-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: powerpc64le-unknown-linux-musl + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + - target: riscv64gc-unknown-linux-gnu + - target: s390x-unknown-linux-gnu + - target: wasm32-unknown-emscripten + - target: wasm32-wasip1 + - target: wasm32-wasip2 + - target: x86_64-apple-darwin + os: macos-15-intel + - target: x86_64-linux-android + # FIXME: Exec format error (os error 8) + # - target: x86_64-unknown-linux-gnux32 + - target: x86_64-unknown-linux-musl + - target: x86_64-unknown-linux-musl + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + # FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually. + # - target: x86_64-unknown-redox + # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu - # - target: powerpc-unknown-linux-gnu - # env: - # RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 - # artifact-tag: offset-bits64 - # - target: powerpc-unknown-linux-gnu - # env: - # RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 - # artifact-tag: time-bits64 + runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} timeout-minutes: 25 env: TARGET: ${{ matrix.target }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Rust toolchain run: ./ci/install-rust.sh - uses: Swatinem/rust-cache@v2 @@ -254,14 +241,18 @@ jobs: jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV shell: bash - - name: Execute run-docker.sh + - name: Run natively + if: runner.os != 'Linux' + run: ./ci/run.sh ${{ matrix.target }} + - name: Run in Docker + if: runner.os == 'Linux' run: ./ci/run-docker.sh ${{ matrix.target }} - name: Create CI artifacts id: create_artifacts if: always() run: ./ci/create-artifacts.py - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 if: always() && steps.create_artifacts.outcome == 'success' with: name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} @@ -274,13 +265,15 @@ jobs: strategy: fail-fast: true matrix: - target: - - x86_64-pc-solaris + include: + - target: x86_64-pc-solaris + - target: x86_64-unknown-netbsd timeout-minutes: 25 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: test on Solaris - uses: vmactions/solaris-vm@v1.1.5 + uses: vmactions/solaris-vm@v1.1.6 + if: contains(matrix.target, 'solaris') with: release: "11.4-gcc" usesh: true @@ -295,6 +288,37 @@ jobs: export PATH=$HOME/.rust_solaris/bin:$PATH ./ci/run.sh ${{ matrix.target }} + - name: Test on NetBSD + uses: vmactions/netbsd-vm@v1 + if: contains(matrix.target, 'netbsd') + with: + release: "10.1" + usesh: true + mem: 4096 + copyback: false + prepare: | + set -x + /usr/sbin/pkg_add curl + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ + --profile minimal --default-toolchain nightly -y + run: | + set -x + . "$HOME/.cargo/env" + which rustc + rustc -Vv + ./ci/run.sh ${{ matrix.target }} + + docs: + name: Ensure docs build + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@master + - name: Install Rust + run: rustup update nightly --no-self-update && rustup default nightly + - uses: Swatinem/rust-cache@v2 + - run: cargo doc --workspace --no-deps + # 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: @@ -306,8 +330,9 @@ jobs: - test_tier2 - test_tier2_vm - verify_build + - docs - clippy - # GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency + # 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" diff --git a/.github/workflows/publish_0.2.yml b/.github/workflows/publish_0.2.yml index 00d5a7792a548..9327c50d88899 100644 --- a/.github/workflows/publish_0.2.yml +++ b/.github/workflows/publish_0.2.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 - name: Install Rust (rustup) diff --git a/rustfmt.toml b/.rustfmt.toml similarity index 51% rename from rustfmt.toml rename to .rustfmt.toml index de0fc5ecc0166..42e6cff32e740 100644 --- a/rustfmt.toml +++ b/.rustfmt.toml @@ -2,3 +2,5 @@ edition = "2021" error_on_line_overflow = true group_imports = "StdExternalCrate" imports_granularity = "Module" +# This crate gets large lists of reexports. Use vertical to reduce conflicts. +imports_layout = "Vertical" diff --git a/CHANGELOG.md b/CHANGELOG.md index e9b726cf19790..a41b5d5d496a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,89 @@ # Changelog +## [0.2.178](https://github.com/rust-lang/libc/compare/0.2.177...0.2.178) - 2025-12-01 + +### Added + +- BSD: Add `issetugid` ([#4744](https://github.com/rust-lang/libc/pull/4744)) +- Cygwin: Add missing utmp/x.h, grp.h, and stdio.h interfaces ([#4827](https://github.com/rust-lang/libc/pull/4827)) +- Linux s390x musl: Add `__psw_t`/`fprefset_t`/`*context_t` ([#4726](https://github.com/rust-lang/libc/pull/4726)) +- Linux, Android: Add definition for IUCLC ([#4846](https://github.com/rust-lang/libc/pull/4846)) +- Linux, FreeBSD: Add `AT_HWCAP{3,4}` ([#4734](https://github.com/rust-lang/libc/pull/4734)) +- Linux: Add definitions from linux/can/bcm.h ([#4683](https://github.com/rust-lang/libc/pull/4683)) +- Linux: Add syscalls 451-469 for m68k ([#4850](https://github.com/rust-lang/libc/pull/4850)) +- Linux: PowerPC: Add 'ucontext.h' definitions ([#4696](https://github.com/rust-lang/libc/pull/4696)) +- NetBSD: Define `eventfd` ([#4830](https://github.com/rust-lang/libc/pull/4830)) +- Newlib: Add missing constants from `unistd.h` ([#4811](https://github.com/rust-lang/libc/pull/4811)) +- QNX NTO: Add `cfmakeraw` ([#4704](https://github.com/rust-lang/libc/pull/4704)) +- QNX NTO: Add `cfsetspeed` ([#4704](https://github.com/rust-lang/libc/pull/4704)) +- Redox: Add `getresgid` and `getresuid` ([#4752](https://github.com/rust-lang/libc/pull/4752)) +- Redox: Add `setresgid` and `setresuid` ([#4752](https://github.com/rust-lang/libc/pull/4752)) +- VxWorks: Add definitions from `select.h`, `stat.h`, `poll.h`, `ttycom.h`, `utsname.h`, `resource.h`, `mman.h`, `udp.h`, `in.h`, `in6.h`, `if.h`, `fnmatch.h`, and `sioLibCommon.h` ([#4781](https://github.com/rust-lang/libc/pull/4781)) +- VxWorks: Add missing defines/functions needed by rust stdlib ([#4779](https://github.com/rust-lang/libc/pull/4779)) +- WASI: Add more definitions for libstd ([#4747](https://github.com/rust-lang/libc/pull/4747)) + +### Deprecated: + +- Apple: Deprecate `TIOCREMOTE` ([#4764](https://github.com/rust-lang/libc/pull/4764)) + +### Fixed: + +Note that there were a large number of fixes on NetBSD for this `libc` release, some of which include minor breakage. + +- AIX: Change errno `EWOULDBLOCK` to make it an alias of `EAGAIN` ([#4790](https://github.com/rust-lang/libc/pull/4790)) +- AIX: Resolve function comparison and `unnecessary_transmutes` warnings ([#4780](https://github.com/rust-lang/libc/pull/4780)) +- Apple: Correct the value of `SF_SETTABLE` ([#4764](https://github.com/rust-lang/libc/pull/4764)) +- DragonflyBSD: Fix the type of `mcontext_t.mc_fpregs` ([#]()) +- EspIDF: Fix the duplicate definition of `gethostname` ([#4773](https://github.com/rust-lang/libc/pull/4773)) +- L4Re: Update available pthread API ([#4836](https://github.com/rust-lang/libc/pull/4836)) +- Linux: Correct the value of `NFT_MSG_MAX` ([#4761](https://github.com/rust-lang/libc/pull/4761)) +- Linux: Remove incorrect `repr(align(8))` for `canxl_frame` ([#4760](https://github.com/rust-lang/libc/pull/4760)) +- Make `eventfd` argument names match OS docs/headers ([#4830](https://github.com/rust-lang/libc/pull/4830)) +- NetBSD: Account for upstream changes to ptrace with LWP ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Correct `ipc_perm`, split from OpenBSD as `ipc.rs` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Correct a number of symbol link names ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Correct the type of `kinfo_vmentry.kve_path` ([#]()) +- NetBSD: Fix `uucred.cr_ngroups` from `int` to `short` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Fix the type of `kevent.udata` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Fix the type of `mcontext_t.__fpregs` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Fix the value of `PT_SUSPEND` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Fix the values of FNM_* constants ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Increase the size of `sockaddr_dl.sdl_data` from 12 to 24 ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `if_.rs`, fix the definition of `ifreq` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `time.rs`, fix the values of `CLOCK_*_CPUTIME_ID` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `timex.rs` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `types.rs`, correct the definition of `lwpid_t` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `utmp_.rs`, correct the definition of `lastlog` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `utmpx_.rs`, correct utmpx definitions ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Make `_cpuset` an extern type ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: RISC-V 64: Fix the `mcontext` types ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- Nuttx: Resolve warnings ([#4773](https://github.com/rust-lang/libc/pull/4773)) +- OHOS: Don't emit duplicate lfs64 definitions ([#4804](https://github.com/rust-lang/libc/pull/4804)) +- Redox: Fix the type of `pid_t` ([#4825](https://github.com/rust-lang/libc/pull/4825)) +- WASI: Gate `__wasilibc_register_preopened_fd` ([#4837](https://github.com/rust-lang/libc/pull/4837)) +- Wali: Fix unknown config ([#4773](https://github.com/rust-lang/libc/pull/4773)) + +### Changed + +- AIX: Declare field 'tv_nsec' of structure 'timespec' as 'i32' in both 32-bit and 64-bit modes ([#4750](https://github.com/rust-lang/libc/pull/4750)) +- DragonFly: Avoid usage of `thread_local` ([#3653](https://github.com/rust-lang/libc/pull/3653)) +- Linux: Update the definition for `ucontext_t` and unskip its tests ([#4760](https://github.com/rust-lang/libc/pull/4760)) +- MinGW: Set `L_tmpnam` and `TMP_MAX` to the UCRT value ([#4566](https://github.com/rust-lang/libc/pull/4566)) +- WASI: More closely align pthread type reprs ([#4747](https://github.com/rust-lang/libc/pull/4747)) +- Simplify rustc-check-cfg emission in build.rs ([#4724](https://github.com/rust-lang/libc/pull/4724)) +- Transition a number of definitions to the new source structure (internal change) + +### Removed + +- MIPS Musl: Remove rogue definition of `SIGSTKFLT` ([#4749](https://github.com/rust-lang/libc/pull/4749)) +- NetBSD: Make `statvfs.f_spare` non-public ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Remove BPF constants ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Remove `*_MAXID` constants and `AT_SUN_LDPGSIZE` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Remove `IFF_NOTRAILERS` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Remove `vm_size_t` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Replace REG_ENOSYS with REG_ILLSEQ ([#4782](https://github.com/rust-lang/libc/pull/4782)) + + ## [0.2.177](https://github.com/rust-lang/libc/compare/0.2.176...0.2.177) - 2025-10-09 ### Added diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0cdfaeadf9059..f43cda673d37b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -93,7 +93,7 @@ We have two automated tests running on - `cd libc-test && cargo test` - Use the `skip_*()` functions in `build.rs` if you really need a workaround. 2. Style checker - - [`./ci/style.sh`](https://github.com/rust-lang/libc/blob/main/ci/style.sh) + - [`./ci/style.py`](https://github.com/rust-lang/libc/blob/main/ci/style.py) ## Breaking change policy diff --git a/Cargo.lock b/Cargo.lock index 46bd7a6704f01..a1dc49a011a64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] @@ -23,9 +23,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "askama" @@ -80,18 +80,19 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.32" +version = "1.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e" +checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "ctest" @@ -99,9 +100,9 @@ version = "0.1.0" [[package]] name = "ctest" -version = "0.5.0-beta.0" +version = "0.5.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af3dc06650f831a3845f2493213c01ebe1dc1cd7bea271d26766a38dc6e72a3f" +checksum = "2011d1b0af8c72339aab2847f4650561f4a2807ea3797c8abb7525dcbb1fbaf7" dependencies = [ "askama", "cc", @@ -111,11 +112,17 @@ dependencies = [ "thiserror", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" + [[package]] name = "glob" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "itoa" @@ -125,7 +132,7 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "libc" -version = "0.2.177" +version = "0.2.178" dependencies = [ "rustc-std-workspace-core", ] @@ -137,7 +144,7 @@ dependencies = [ "annotate-snippets", "cc", "cfg-if", - "ctest 0.5.0-beta.0", + "ctest 0.5.0-beta.2", "glob", "libc", "proc-macro2", @@ -147,9 +154,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "percent-encoding" @@ -159,27 +166,27 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] [[package]] name = "regex" -version = "1.11.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -189,9 +196,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -200,9 +207,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "rustc-hash" @@ -224,18 +231,27 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -244,14 +260,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.142" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] @@ -262,9 +279,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" dependencies = [ "proc-macro2", "quote", @@ -273,18 +290,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", @@ -293,15 +310,15 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-width" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "winnow" diff --git a/Cargo.toml b/Cargo.toml index 74241d2ee390a..96d85e4b0d63c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "libc" -version = "0.2.177" +version = "0.2.178" keywords = ["libc", "ffi", "bindings", "operating", "system"] categories = ["external-ffi-bindings", "no-std", "os"] -exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"] +exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml", "cherry-pick-stable.sh"] description = "Raw FFI bindings to platform libraries like libc." authors = ["The Rust Project Developers"] edition = "2021" @@ -178,3 +178,9 @@ expl_impl_clone_on_copy = "allow" uninlined_format_args = "allow" unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets used_underscore_binding = "allow" + +[package.metadata.cargo-semver-checks.lints] +# Alignment is an internal detail that users must not rely upon +repr_align_removed = "warn" +# We deprecate things all the time +global_value_marked_deprecated = "warn" diff --git a/README.md b/README.md index c616d8b29f52b..607bf308d01eb 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ but this is not guaranteed. You can see the platform(target)-specific docs on [docs.rs], select a platform you want to see. -See [`ci/verify-build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.sh) for +See [`ci/verify-build.py`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.py) for the platforms on which `libc` is guaranteed to build for each Rust toolchain. The test-matrix at [GitHub Actions] and [Cirrus CI] show the platforms in which `libc` tests are run. diff --git a/build.rs b/build.rs index 802ea7a37def0..9e1dd66b59923 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,11 @@ -use std::process::{Command, Output}; -use std::{env, str}; +use std::process::{ + Command, + Output, +}; +use std::{ + env, + str, +}; // List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we // need to know all the possible cfgs that this script will set. If you need to set another cfg @@ -18,10 +24,10 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `_TIME_BITS=64` in glibc "gnu_time_bits64", "libc_deny_warnings", - "libc_thread_local", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", + "vxworks_lt_25_09", ]; // Extra values to allow for check-cfg. @@ -47,7 +53,6 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); - let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); @@ -87,6 +92,12 @@ fn main() { _ => (), } + match vxworks_version_code() { + Some(v) if (v < (25, 9)) => set_cfg("vxworks_lt_25_09"), + // VxWorks version >= 25.09 + _ => (), + } + let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); // loongarch64 and ohos have already updated @@ -143,28 +154,15 @@ fn main() { set_cfg("libc_deny_warnings"); } - // #[thread_local] is currently unstable - if rustc_dep_of_std { - set_cfg("libc_thread_local"); - } - // Since Rust 1.80, configuration that isn't recognized by default needs to be provided to // avoid warnings. if rustc_minor_ver >= 80 { for cfg in ALLOWED_CFGS { - if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({cfg})"); - } else { - println!("cargo:rustc-check-cfg=values({cfg})"); - } + println!("cargo:rustc-check-cfg=cfg({cfg})"); } for &(name, values) in CHECK_CFG_EXTRA { let values = values.join("\",\""); - if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); - } else { - println!("cargo:rustc-check-cfg=values({name},\"{values}\")"); - } + println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); } } } @@ -289,6 +287,20 @@ fn emcc_version_code() -> Option { Some(major * 10000 + minor * 100 + patch) } +/// Retrieve the VxWorks release version from the environment variable set by the VxWorks build +/// environment, in `(minor, patch)` form. Currently the only major version supported by Rust +/// is 7. +fn vxworks_version_code() -> Option<(u32, u32)> { + let version = env::var("WIND_RELEASE_ID").ok()?; + + let mut pieces = version.trim().split(['.']); + + let major: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + let minor: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + + Some((major, minor)) +} + fn set_cfg(cfg: &str) { assert!( ALLOWED_CFGS.contains(&cfg), diff --git a/ci/create-artifacts.py b/ci/create-artifacts.py index 2854daa563154..bd5656fd040b2 100755 --- a/ci/create-artifacts.py +++ b/ci/create-artifacts.py @@ -30,7 +30,11 @@ def main(): archive_name = f"archive-{now}" archive_path = f"{archive_name}.tar.gz" - sp.run(["tar", "czvf", archive_path, "-C", build_dir, "-T-"], input=file_list) + sp.run( + ["tar", "czvf", archive_path, "-C", build_dir, "-T-"], + input=file_list, + check=True, + ) # If we are in GHA, set these env vars for future use gh_env = os.getenv("GITHUB_ENV") @@ -42,6 +46,7 @@ def main(): if __name__ == "__main__": + print("Starting script...") # For debugging CI failures # FIXME(ci): remove after the bump to windoes-2025 GHA images # Python <= 3.9 does not support the very helpful `root_dir` argument, # and that is the version used by the Windows GHA images. Rather than @@ -55,10 +60,12 @@ def main(): sys.exit(1) # Find the next 3.1x Python version - dirs = sorted(list(Path(r"C:\hostedtoolcache\windows\Python").iterdir())) + dirs = sorted(Path(r"C:\hostedtoolcache\windows\Python").iterdir()) usepy = next(x for x in dirs if r"\3.1" in str(x)) py = usepy.joinpath(r"x64\python.exe") print(f"relaunching with {py}") os.execvp(py, [__file__] + sys.argv) main() +else: + print("not invoked as main, exiting") # For debugging CI failures diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index 8ed15a5234d1e..0e5baf0854238 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -1,18 +1,18 @@ FROM ubuntu:25.04 RUN dpkg --add-architecture i386 -RUN apt-get update -RUN apt-get install -y --no-install-recommends libc6-dev gcc -RUN apt-get install -y --no-install-recommends \ - file \ - wget \ - ca-certificates \ - python3 \ - unzip \ - expect \ - openjdk-8-jre \ - libstdc++6:i386 \ - libpulse0 +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + expect \ + file \ + gcc \ + libc6-dev \ + libpulse0 \ + libstdc++6:i386 \ + openjdk-8-jre \ + python3 \ + unzip \ + wget WORKDIR /android/ COPY android* /android/ @@ -35,12 +35,12 @@ ENV PATH=$PATH:/rust/bin \ ADD runtest-android.rs /tmp/runtest.rs ENTRYPOINT [ \ - "bash", \ - "-c", \ - # set SHELL so android can detect a 64bits system, see - # http://stackoverflow.com/a/41789144 - "SHELL=/bin/dash /android/sdk/emulator/emulator @aarch64 -no-window & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ - exec \"$@\"", \ - "--" \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash /android/sdk/emulator/emulator @aarch64 -no-window & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ ] diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index a4faeb4a8b96b..e6b1798b1cfbf 100644 --- a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -1,8 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates \ - gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user + ca-certificates \ + gcc \ + gcc-aarch64-linux-gnu \ + libc6-dev \ + libc6-dev-arm64-cross \ + qemu-user + ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \ PATH=$PATH:/rust/bin diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index f57c5fa6055c2..3bbf58aa3b8b6 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -1,8 +1,17 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates \ - gcc-aarch64-linux-gnu qemu-user xz-utils patch rsync + ca-certificates \ + curl \ + gcc \ + gcc-aarch64-linux-gnu \ + git \ + libc6-dev \ + make \ + patch \ + qemu-user \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh aarch64 diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index e81623f7bf0e7..23afe49970e71 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -1,18 +1,18 @@ FROM ubuntu:25.04 RUN dpkg --add-architecture i386 -RUN apt-get update -RUN apt-get install -y --no-install-recommends libc6-dev gcc -RUN apt-get install -y --no-install-recommends \ - file \ - wget \ - ca-certificates \ - python3 \ - unzip \ - expect \ - openjdk-8-jre \ - libstdc++6:i386 \ - libpulse0 +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + expect \ + file \ + gcc \ + libc6-dev \ + libpulse0 \ + libstdc++6:i386 \ + openjdk-8-jre \ + python3 \ + unzip \ + wget WORKDIR /android/ COPY android* /android/ @@ -35,12 +35,12 @@ ENV PATH=$PATH:/rust/bin \ ADD runtest-android.rs /tmp/runtest.rs ENTRYPOINT [ \ - "bash", \ - "-c", \ - # set SHELL so android can detect a 64bits system, see - # http://stackoverflow.com/a/41789144 - "SHELL=/bin/dash /android/sdk/emulator/emulator @arm -no-window & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ - exec \"$@\"", \ - "--" \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash /android/sdk/emulator/emulator @arm -no-window & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ ] diff --git a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile index 8f2d3ea80d065..e6cdf778d78c0 100644 --- a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@ -4,8 +4,13 @@ FROM ubuntu:23.10 RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates \ - gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user + ca-certificates \ + gcc \ + gcc-arm-linux-gnueabihf \ + libc6-dev \ + libc6-dev-armhf-cross \ + qemu-user + ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" \ PATH=$PATH:/rust/bin diff --git a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index c6bd116b6f1cb..e4628e8befbd0 100644 --- a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -4,8 +4,17 @@ FROM ubuntu:23.10 RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates \ - gcc-arm-linux-gnueabihf qemu-user xz-utils patch rsync + ca-certificates \ + curl \ + gcc \ + gcc-arm-linux-gnueabihf \ + git \ + libc6-dev \ + make \ + patch \ + qemu-user \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh arm diff --git a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile index 330493f54a1d1..284389360ac2c 100644 --- a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile +++ b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile @@ -4,8 +4,15 @@ FROM ubuntu:23.10 RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates qemu-system-arm curl \ - xz-utils patch file + ca-certificates \ + curl \ + file \ + gcc \ + libc6-dev \ + patch \ + qemu-system-arm \ + qemu-user \ + xz-utils RUN mkdir /toolchain diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile index c8fb40cc3d3c0..312eca1146dba 100644 --- a/ci/docker/asmjs-unknown-emscripten/Dockerfile +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -4,9 +4,8 @@ FROM ubuntu:25.04 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -RUN apt-get update -RUN apt-get install -y --no-install-recommends tzdata -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ + bzip2 \ ca-certificates \ curl \ gcc \ @@ -14,8 +13,8 @@ RUN apt-get install -y --no-install-recommends \ libc6-dev \ libxml2 \ python3 \ - xz-utils \ - bzip2 + tzdata \ + xz-utils COPY emscripten.sh / RUN /emscripten.sh diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index 24d15872efd07..96507d7fc2275 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -1,18 +1,18 @@ FROM ubuntu:25.04 RUN dpkg --add-architecture i386 -RUN apt-get update -RUN apt-get install -y --no-install-recommends libc6-dev gcc -RUN apt-get install -y --no-install-recommends \ - file \ - wget \ - ca-certificates \ - python3 \ - unzip \ - expect \ - openjdk-8-jre \ - libstdc++6:i386 \ - libpulse0 +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + expect \ + gcc \ + libc6-dev \ + libpulse0 \ + libstdc++6:i386 \ + openjdk-8-jre \ + python3 \ + unzip \ + wget \ + file WORKDIR /android/ COPY android* /android/ @@ -35,12 +35,12 @@ ENV PATH=$PATH:/rust/bin \ ADD runtest-android.rs /tmp/runtest.rs ENTRYPOINT [ \ - "bash", \ - "-c", \ - # set SHELL so android can detect a 64bits system, see - # http://stackoverflow.com/a/41789144 - "SHELL=/bin/dash /android/sdk/emulator/emulator @i686 -no-window -no-accel & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ - exec \"$@\"", \ - "--" \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash /android/sdk/emulator/emulator @i686 -no-window -no-accel & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ ] diff --git a/ci/docker/i686-unknown-linux-gnu/Dockerfile b/ci/docker/i686-unknown-linux-gnu/Dockerfile index fae0b566d33fc..5a2f4c9dd43ec 100644 --- a/ci/docker/i686-unknown-linux-gnu/Dockerfile +++ b/ci/docker/i686-unknown-linux-gnu/Dockerfile @@ -1,10 +1,11 @@ FROM ubuntu:23.10 - # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc-multilib libc6-dev ca-certificates + ca-certificates \ + gcc-multilib \ + libc6-dev ENV PATH=$PATH:/rust/bin diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index 287f325e9151f..82f2b786eda20 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -5,8 +5,16 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ dpkg --add-architecture i386 && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc-multilib make libc6-dev git curl ca-certificates libc6-i386 \ - xz-utils patch rsync + ca-certificates \ + curl \ + gcc-multilib \ + git \ + libc6-dev \ + libc6-i386 \ + make \ + patch \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh i686 diff --git a/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile b/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile index 138b9a195adb8..ab13f33f1187d 100644 --- a/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile @@ -1,9 +1,12 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-14-loongarch64-linux-gnu libc6-dev-loong64-cross \ - linux-headers-generic + ca-certificates \ + gcc \ + gcc-14-loongarch64-linux-gnu \ + libc6-dev \ + libc6-dev-loong64-cross \ + qemu-user ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_LINKER=loongarch64-linux-gnu-gcc-14 \ CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-loongarch64 -L /usr/loongarch64-linux-gnu" \ diff --git a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile index ec632c33f7af3..dcf75b428a290 100644 --- a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile @@ -1,8 +1,17 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates curl gcc gcc-14-loongarch64-linux-gnu git libc6-dev \ - make qemu-user xz-utils patch rsync + ca-certificates \ + curl \ + gcc \ + gcc-14-loongarch64-linux-gnu \ + git \ + libc6-dev \ + make \ + patch \ + qemu-user \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh loongarch64 diff --git a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile index 535202951d2ce..99c5f13892095 100644 --- a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -4,9 +4,13 @@ FROM ubuntu:23.10 RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-powerpc-linux-gnu libc6-dev-powerpc-cross \ - qemu-system-ppc + ca-certificates \ + gcc \ + gcc-powerpc-linux-gnu \ + libc6-dev \ + libc6-dev-powerpc-cross \ + qemu-system-ppc \ + qemu-user ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" \ diff --git a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile index a8a9dd8c92263..f7907a32347ac 100644 --- a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -1,9 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \ - qemu-system-ppc + ca-certificates \ + gcc \ + gcc-powerpc64-linux-gnu \ + libc6-dev \ + libc6-dev-ppc64-cross \ + qemu-system-ppc \ + qemu-user ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" \ diff --git a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile index 0d6110f39149f..f2f0a6e20c7b2 100644 --- a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -1,9 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \ - qemu-system-ppc + ca-certificates \ + gcc \ + gcc-powerpc64le-linux-gnu \ + libc6-dev \ + libc6-dev-ppc64el-cross \ + qemu-system-ppc \ + qemu-user ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64le -L /usr/powerpc64le-linux-gnu" \ diff --git a/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile b/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile index 40a661149f7d8..c21ce6a3d5097 100644 --- a/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile @@ -1,8 +1,17 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates \ - gcc-powerpc64le-linux-gnu qemu-user xz-utils patch rsync + ca-certificates \ + curl \ + gcc \ + gcc-powerpc64le-linux-gnu \ + git \ + libc6-dev \ + make \ + patch \ + qemu-user \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh powerpc64le diff --git a/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile b/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile index 43138af5da234..10395b72406b0 100644 --- a/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile @@ -1,9 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-riscv64-linux-gnu libc6-dev-riscv64-cross \ - qemu-system-riscv64 linux-headers-generic + ca-certificates \ + gcc \ + gcc-riscv64-linux-gnu \ + libc6-dev \ + libc6-dev-riscv64-cross \ + qemu-system-riscv64 \ + qemu-user ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc \ CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_RUNNER="qemu-riscv64 -L /usr/riscv64-linux-gnu" \ diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index aa3490228c4db..4e0e3e7d514f9 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -1,11 +1,14 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - curl ca-certificates \ - gcc libc6-dev \ - gcc-s390x-linux-gnu libc6-dev-s390x-cross \ - qemu-system-s390x \ - cpio + ca-certificates \ + cpio \ + curl \ + gcc \ + gcc-s390x-linux-gnu \ + libc6-dev \ + libc6-dev-s390x-cross \ + qemu-system-s390x COPY linux-s390x.sh / RUN /linux-s390x.sh diff --git a/ci/docker/s390x-unknown-linux-musl/Dockerfile b/ci/docker/s390x-unknown-linux-musl/Dockerfile index 0dfad20fb7a1d..58133e216c840 100644 --- a/ci/docker/s390x-unknown-linux-musl/Dockerfile +++ b/ci/docker/s390x-unknown-linux-musl/Dockerfile @@ -1,11 +1,14 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - curl ca-certificates \ - gcc \ - gcc-s390x-linux-gnu \ - qemu-user \ - xz-utils patch rsync + curl \ + ca-certificates \ + gcc \ + gcc-s390x-linux-gnu \ + qemu-user \ + xz-utils \ + patch \ + rsync COPY install-musl.sh / RUN /install-musl.sh s390x diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index a91ec3dd25f27..728586f119545 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -1,14 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - curl ca-certificates \ - gcc libc6-dev \ - gcc-sparc64-linux-gnu libc6-dev-sparc64-cross \ - qemu-system-sparc64 openbios-sparc seabios ipxe-qemu \ - p7zip-full cpio linux-libc-dev-sparc64-cross qemu-user - -COPY linux-sparc64.sh / -RUN /linux-sparc64.sh + ca-certificates \ + gcc \ + gcc-sparc64-linux-gnu \ + libc6-dev \ + libc6-dev-sparc64-cross \ + qemu-system-sparc64 \ + qemu-user ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-sparc64 -L /usr/sparc64-linux-gnu" \ diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile index 969a0ffca0be3..e068ad59f94c2 100644 --- a/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -4,24 +4,23 @@ FROM ubuntu:25.04 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -RUN apt-get update -RUN apt-get install -y --no-install-recommends tzdata -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ + bzip2 \ ca-certificates \ - g++ \ - make \ - file \ + cmake \ curl \ + file \ + g++ \ gcc \ + gdb \ git \ libc6-dev \ libxml2 \ + make \ python3 \ - cmake \ + tzdata \ sudo \ - gdb \ - xz-utils \ - bzip2 + xz-utils RUN ln -s /usr/bin/python3 /usr/bin/python & \ ln -s /usr/bin/pip3 /usr/bin/pip diff --git a/ci/docker/wasm32-wasip1/Dockerfile b/ci/docker/wasm32-wasip1/Dockerfile index 419159a0b1380..93258ac7e4422 100644 --- a/ci/docker/wasm32-wasip1/Dockerfile +++ b/ci/docker/wasm32-wasip1/Dockerfile @@ -10,7 +10,7 @@ RUN /wasi.sh # library. ENV CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime \ CARGO_TARGET_WASM32_WASIP1_LINKER=/opt/wasi-sdk/bin/clang \ - CARGO_TARGET_WASM32_WASIP1_RUSTFLAGS="-lwasi-emulated-process-clocks -Ctarget-feature=-crt-static" \ + CARGO_TARGET_WASM32_WASIP1_RUSTFLAGS="-Clink-self-contained=n -lwasi-emulated-process-clocks" \ CC_wasm32_wasip1=/opt/wasi-sdk/bin/clang \ CFLAGS_wasm32_wasip1=-D_WASI_EMULATED_PROCESS_CLOCKS \ PATH=$PATH:/rust/bin:/wasmtime diff --git a/ci/docker/wasm32-wasip2/Dockerfile b/ci/docker/wasm32-wasip2/Dockerfile index 8d819b36e5c15..a8da1e212333e 100644 --- a/ci/docker/wasm32-wasip2/Dockerfile +++ b/ci/docker/wasm32-wasip2/Dockerfile @@ -9,7 +9,7 @@ RUN /wasi.sh # itself, this should be fixed upstream. ENV CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtime \ CARGO_TARGET_WASM32_WASIP2_LINKER=/opt/wasi-sdk/bin/clang \ - CARGO_TARGET_WASM32_WASIP2_RUSTFLAGS="-lwasi-emulated-process-clocks -Ctarget-feature=-crt-static -Clink-arg=-Wl,--export,cabi_realloc" \ + CARGO_TARGET_WASM32_WASIP2_RUSTFLAGS="-Clink-self-contained=n -lwasi-emulated-process-clocks -Clink-arg=-Wl,--export,cabi_realloc" \ CC_wasm32_wasip2=/opt/wasi-sdk/bin/clang \ CFLAGS_wasm32_wasip2=-D_WASI_EMULATED_PROCESS_CLOCKS \ PATH=$PATH:/rust/bin:/wasmtime diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index 950c2a9fdc612..76b80a894b2bb 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -1,13 +1,12 @@ FROM ubuntu:25.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - wget \ - gcc \ - libc-dev \ - python3 \ - unzip +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + gcc \ + libc-dev \ + python3 \ + unzip \ + wget WORKDIR /android/ ENV ANDROID_ARCH=x86_64 diff --git a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index 3e94948095024..ed9734ca2b6f8 100644 --- a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -1,8 +1,9 @@ FROM ubuntu:25.04 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates linux-headers-generic +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + gcc \ + libc6-dev RUN apt search linux-headers RUN ls /usr/src diff --git a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile index 92a92b1dfe98d..0d5cdd7daafb0 100644 --- a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile @@ -1,6 +1,8 @@ FROM ubuntu:25.04 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc-multilib libc6-dev ca-certificates +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + gcc-multilib \ + libc6-dev + ENV PATH=$PATH:/rust/bin diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index 194a6e7847f55..5b524c31eff79 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -1,9 +1,15 @@ FROM ubuntu:25.04 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates \ - xz-utils patch rsync +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + gcc \ + git \ + libc6-dev \ + make \ + patch \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh x86_64 diff --git a/ci/install-musl.sh b/ci/install-musl.sh index f5516553707d2..2335eea3fbbda 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -5,20 +5,25 @@ set -eux +old_musl=1.1.24 +new_musl=1.2.5 + case ${1} in - loongarch64) - musl_version=1.2.5 - ;; + loongarch64) musl_version="$new_musl" ;; *) - [ -n "${RUST_LIBC_UNSTABLE_MUSL_V1_2_3:-}" ] && musl_version=1.2.3 || musl_version=1.1.24 + [ -n "${RUST_LIBC_UNSTABLE_MUSL_V1_2_3:-}" ] && + musl_version="$new_musl" || + musl_version="$old_musl" ;; esac musl="musl-${musl_version}" -# Download, configure, build, and install musl: -curl --retry 5 "https://www.musl-libc.org/releases/${musl}.tar.gz" | tar xzf - +# Note that if a new version of musl is needed, it needs to be added to the mirror +# first. See https://github.com/rust-lang/ci-mirrors/blob/main/files/libc.toml. +curl --retry 5 "https://ci-mirrors.rust-lang.org/libc/${musl}.tar.gz" | tar xzf - +# Configure, build, and install musl: cd "$musl" case ${1} in aarch64) diff --git a/ci/ios/deploy_and_run_on_ios_simulator.rs b/ci/ios/deploy_and_run_on_ios_simulator.rs index 0398a9d3f888d..5c2d2fbad328d 100644 --- a/ci/ios/deploy_and_run_on_ios_simulator.rs +++ b/ci/ios/deploy_and_run_on_ios_simulator.rs @@ -6,11 +6,17 @@ // (https://github.com/snipsco/dinghy): cargo dinghy install, then cargo dinghy // test. -use std::fs::{self, File}; +use std::fs::{ + self, + File, +}; use std::io::Write; use std::path::Path; use std::process::Command; -use std::{env, process}; +use std::{ + env, + process, +}; macro_rules! t { ($e:expr) => { diff --git a/ci/linux-sparc64.sh b/ci/linux-sparc64.sh deleted file mode 100755 index b272c42edd9aa..0000000000000 --- a/ci/linux-sparc64.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env sh - -set -eux - -mkdir -m 777 /qemu -cd /qemu - -curl --retry 5 -LO https://cdimage.debian.org/cdimage/ports/snapshots/2024-12-24/debian-12.0.0-sparc64-NETINST-1.iso -7z e debian-12.0.0-sparc64-NETINST-1.iso install/initrd.gz -7z e debian-12.0.0-sparc64-NETINST-1.iso install/vmlinux -mv vmlinux kernel -rm debian-12.0.0-sparc64-NETINST-1.iso - -mkdir init -cd init -gunzip -c ../initrd.gz | cpio -id -rm ../initrd.gz -cp /usr/sparc64-linux-gnu/lib/libgcc_s.so.1 usr/lib/ -chmod a+w . diff --git a/ci/prep-semver-baseline.sh b/ci/prep-semver-baseline.sh new file mode 100755 index 0000000000000..7d7a3333fd3b6 --- /dev/null +++ b/ci/prep-semver-baseline.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Download a baseline crate to run semver checks against + +set -euxo pipefail + +# Retrieve the index for libc +index=$(curl -L https://index.crates.io/li/bc/libc) + +# Regex for versions matching what we want to check against. Note we check only +# a suffix since in the merge queue `base_ref` is set to something like +# `refs/heads/main` rather than only the branch name. +if [[ "${TARGET_REF:-}" = *"libc-0.2" ]]; then + pat="^0.2" +elif [[ "${TARGET_REF:-}" = *"main" ]]; then + pat="^1.0" +else + echo "TARGET_REF must be set and end with either 'libc-0.2' or 'main'" + exit 1 +fi + +# Find the most recent version matching a pattern. +version=$( + echo "$index" | + jq -er --slurp --arg pat "$pat" ' + map(select(.vers | test($pat))) + | last + | debug("version:", .) + | .vers + ' +) + +libc_cache="${XDG_CACHE_DIR:-$HOME/.cache}/libc-ci/" +mkdir -p "$libc_cache" + +curl -L "https://static.crates.io/crates/libc/libc-$version.crate" | tar xzf - -C "$libc_cache" +crate_dir="$libc_cache/libc-$version" + +echo "BASELINE_CRATE_DIR=$crate_dir" >> "$GITHUB_ENV" diff --git a/ci/run-docker.sh b/ci/run-docker.sh index db10c3b061ba8..c34bcff6ed786 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -45,6 +45,7 @@ run() { --env LIBC_CI_ZBUILD_STD \ --env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \ --env RUST_LIBC_UNSTABLE_GNU_TIME_BITS \ + --env RUST_LIBC_UNSTABLE_MUSL_V1_2_3 \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --volume "$CARGO_HOME":/cargo \ diff --git a/ci/run.sh b/ci/run.sh index 7b4525143d05a..8a7abf2e20f77 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -9,6 +9,9 @@ target="$1" export RUST_BACKTRACE="${RUST_BACKTRACE:-1}" +# For logging +uname -a + cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}" test_flags="--skip check_style" @@ -22,39 +25,21 @@ case "$target" in *) cmd="$cmd --workspace" ;; esac -if [ "$target" = "s390x-unknown-linux-gnu" ]; then - # FIXME: s390x-unknown-linux-gnu often fails to test due to timeout, - # so we retry this N times. - N=5 - n=0 - passed=0 - until [ $n -ge $N ]; do - if [ "$passed" = "0" ]; then - # shellcheck disable=SC2086 - if $cmd --no-default-features -- $test_flags; then - passed=$((passed + 1)) - continue - fi - elif [ "$passed" = "1" ]; then - # shellcheck disable=SC2086 - if $cmd -- $test_flags; then - passed=$((passed + 1)) - continue - fi - elif [ "$passed" = "2" ]; then - # shellcheck disable=SC2086 - if $cmd --features extra_traits -- $test_flags; then - break - fi - fi - n=$((n + 1)) - sleep 1 - done -else - # shellcheck disable=SC2086 - $cmd --no-default-features -- $test_flags +env="$(rustc --print cfg --target "$target" | sed -n 's/target_env="\(.*\)"/\1/p')" +bits="$(rustc --print cfg --target "$target" | sed -n 's/target_pointer_width="\(.*\)"/\1/p')" + +# shellcheck disable=SC2086 +$cmd --no-default-features -- $test_flags +# shellcheck disable=SC2086 +$cmd -- $test_flags +# shellcheck disable=SC2086 +$cmd --features extra_traits -- $test_flags + +# On relevant platforms, also test with our optional settings + +if [ "$env" = "gnu" ] && [ "$bits" = "32" ]; then # shellcheck disable=SC2086 - $cmd -- $test_flags + RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd -- $test_flags # shellcheck disable=SC2086 - $cmd --features extra_traits -- $test_flags + RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd -- $test_flags fi diff --git a/ci/runtest-android.rs b/ci/runtest-android.rs index 29b1a82f675c7..b88cd9c1b9140 100644 --- a/ci/runtest-android.rs +++ b/ci/runtest-android.rs @@ -1,5 +1,8 @@ use std::env; -use std::path::{Path, PathBuf}; +use std::path::{ + Path, + PathBuf, +}; use std::process::Command; fn main() { diff --git a/ci/style.py b/ci/style.py new file mode 100755 index 0000000000000..fcbee07dac17c --- /dev/null +++ b/ci/style.py @@ -0,0 +1,182 @@ +#!/usr/bin/env python3 + +import os +import re +import subprocess as sp +import sys + +from difflib import unified_diff +from glob import iglob +from pathlib import Path + + +FMT_DIRS = ["src", "ci"] +IGNORE_FILES = [ + # Too much special syntax that we don't want to format + "src/macros.rs" +] + + +def main(): + # if `CI` is set, do a check rather than overwriting + check_only = os.getenv("CI") is not None + run(["rustfmt", "-V"]) + + fmt_files = [] + for dir in FMT_DIRS: + fmt_files.extend(iglob(f"{dir}/**/*.rs", recursive=True)) + + for file in fmt_files: + if file in IGNORE_FILES: + continue + fmt_one(Path(file), check_only) + + # Run once from workspace root to get everything that wasn't handled as an + # individual file. + if check_only: + run(["cargo", "fmt", "--check"]) + else: + run(["cargo", "fmt"]) + + for file in iglob("libc-test/semver/*.txt"): + check_semver_file(Path(file)) + + # Style tests + run( + [ + "cargo", + "test", + "--manifest-path=libc-test/Cargo.toml", + "--test=style", + "--", + "--nocapture", + ] + ) + + try: + run(["shellcheck", "--version"]) + except sp.CalledProcessError: + eprint("ERROR: shellcheck not found") + exit(1) + + for file in iglob("**/*.sh", recursive=True): + run(["shellcheck", file]) + + +def fmt_one(fpath: Path, check_only: bool): + eprint(f"Formatting {fpath}") + text = fpath.read_text() + + # Rustfmt doesn't format the bodies of `{ ... }` macros, which is most of `libc`. To + # make things usable, we do some hacks to replace macros with some kind of + # alternative syntax that gets formatted about how we want, then reset the changes + # after formatting. + + # Turn all braced macro `foo! { /* ... */ }` invocations into + # `fn foo_fmt_tmp() { /* ... */ }`, since our macro bodies are usually valid in + # a function context. + text = re.sub(r"(?!macro_rules)\b(\w+)!\s*\{", r"fn \1_fmt_tmp() {", text) + + # Replace `if #[cfg(...)]` within `cfg_if` with `if cfg_tmp!([...])` which + # `rustfmt` will format. We put brackets within the parens so it is easy to + # match (trying to match parentheses would catch the first closing `)` which + # wouldn't be correct for something like `all(any(...), ...)`). + text = re.sub(r"if #\[cfg\((.*?)\)\]", r"if cfg_tmp!([\1])", text, flags=re.DOTALL) + + # The `c_enum!` macro allows anonymous enums without names, which isn't valid + # syntax. Replace it with a dummy name. + text = re.sub(r"enum #anon\b", r"enum _fmt_anon", text) + + # If enum variants are annotated with `pub`, rustfmt erases the visibility. To get + # around this we first match on all enums to extract their bodies, then look for `pub` + # visibility indicators. If found, these get stashed in a comment on the preceding + # line. + def enum_sub(m: re.Match) -> str: + enum_body = m.group(0) + rep = re.sub( + r"^(.*)\b(pub\s*?(\(.*?\))?)\s*", + r"\1/* FMT-VIS \2 END-FMT-VIS */\n\1", + enum_body, + flags=re.MULTILINE, + ) + return rep + + text = re.sub(r"\benum.*\{\n?(?:\s*[^}]*\n)+\s*\}", enum_sub, text) + + # Invoke rustfmt passing via stdin/stdout so we don't need to write the file. Exits + # on failure. + cmd = ["rustfmt", "--config-path=.rustfmt.toml"] + if check_only: + res = check_output(cmd + ["--check"], input=text) + + # Unfortunately rustfmt on stdin always completes with 0 exit code even if + # there are errors, so we need to pick between writing the file to disk or + # relying on empty stdout to indicate success. + # . + if len(res) == 0: + return + eprint(f"ERROR: File {fpath} is not properly formatted") + print(res) + exit(1) + else: + text = check_output(cmd, input=text) + + # Restore all changes in the formatted text + text = re.sub(r"fn (\w+)_fmt_tmp\(\)", r"\1!", text) + text = re.sub(r"cfg_tmp!\(\[(.*?)\]\)", r"#[cfg(\1)]", text, flags=re.DOTALL) + text = re.sub(r"enum _fmt_anon", r"enum #anon", text) + text = re.sub(r"/\* FMT-VIS (.*) END-FMT-VIS \*/\n\s*", r"\1 ", text) + + # And write the formatted file back + fpath.write_text(text) + + +def check_semver_file(fpath: Path): + if "TODO" in str(fpath): + eprint(f"Skipping semver file {fpath}") + return + + eprint(f"Checking semver file {fpath}") + + text = fpath.read_text() + lines = text.splitlines() + sort = sorted(lines) + if lines != sort: + eprint(f"ERROR: Unsorted semver file {fpath}") + eprint("\n".join(unified_diff(lines, sort, lineterm=""))) + exit(1) + + duplicates = [] + seen = set() + for line in lines: + if line in seen: + duplicates.append(line) + seen.add(line) + + if len(duplicates) > 0: + eprint(f"ERROR: Duplicates in semver file {fpath}") + eprint(duplicates) + exit(1) + + +def check_output(args: list[str], **kw) -> str: + xtrace(args) + return sp.check_output(args, encoding="utf8", text=True, **kw) + + +def run(args: list[str], **kw) -> sp.CompletedProcess: + xtrace(args) + return sp.run(args, check=True, text=True, **kw) + + +def xtrace(args: list[str]): + astr = " ".join(args) + eprint(f"+ {astr}") + + +def eprint(*args, **kw): + print(*args, file=sys.stderr, **kw) + + +if __name__ == "__main__": + main() diff --git a/ci/style.sh b/ci/style.sh deleted file mode 100755 index 200cc15cfa16a..0000000000000 --- a/ci/style.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -set -eux - -[ -n "${CI:-}" ] && check="--check" - -cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture - -command -v rustfmt -rustfmt -V - -# Save a list of all source files -tmpfile="file-list~" # trailing tilde for gitignore -find src ci -name '*.rs' > "$tmpfile" - -# Before formatting, replace all macro identifiers with a function signature. -# This allows `rustfmt` to format it. -while IFS= read -r file; do - if [ "$file" = "src/macros.rs" ]; then - # Too much special syntax in `macros.rs` that we don't want to format - continue - fi - - # Turn all braced macro `foo! { /* ... */ }` invocations into - # `fn foo_fmt_tmp() { /* ... */ }`. - perl -pi -e 's/(?!macro_rules)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file" - - # Replace `if #[cfg(...)]` within `cfg_if` with `if cfg_tmp!([...])` which - # `rustfmt` will format. We put brackets within the parens so it is easy to - # match (trying to match parentheses would catch the first closing `)` which - # wouldn't be correct for something like `all(any(...), ...)`). - perl -pi -0777 -e 's/if #\[cfg\((.*?)\)\]/if cfg_tmp!([$1])/gms' "$file" - - # Format the file. We need to invoke `rustfmt` directly since `cargo fmt` - # can't figure out the module tree with the hacks in place. - failed=false - rustfmt --config-path rustfmt.toml "$file" ${check:+"$check"} || failed=true - - # Restore all changes to the files. - perl -pi -e 's/fn (\w+)_fmt_tmp\(\)/$1!/g' "$file" - perl -pi -0777 -e 's/cfg_tmp!\(\[(.*?)\]\)/#[cfg($1)]/gms' "$file" - - # Defer emitting the failure until after the files get reset - if [ "$failed" != "false" ]; then - echo "Formatting failed" - exit 1 - fi -done < "$tmpfile" - -rm "$tmpfile" - -# Run once from workspace root to get everything that wasn't handled as an -# individual file. -cargo fmt ${check:+"$check"} - -# Ensure that `sort` output is not locale-dependent -export LC_ALL=C - -for file in libc-test/semver/*.txt; do - case "$file" in - *TODO*) continue ;; - esac - - if ! sort -C "$file"; then - echo "Unsorted semver file $file" - exit 1 - fi - - duplicates=$(uniq -d "$file") - if [ -n "$duplicates" ]; then - echo "Semver file $file contains duplicates:" - echo "$duplicates" - - exit 1 - fi -done - -if shellcheck --version; then - find . -name '*.sh' -print0 | xargs -0 shellcheck -else - echo "shellcheck not found" - exit 1 -fi diff --git a/ci/verify-build.py b/ci/verify-build.py new file mode 100755 index 0000000000000..40552e2689ee1 --- /dev/null +++ b/ci/verify-build.py @@ -0,0 +1,516 @@ +#!/usr/bin/env python3 + +import argparse +import os +import platform +import re +import subprocess as sp +import sys +import time +from dataclasses import dataclass, field +from enum import Enum, IntEnum +from pathlib import Path +from typing import Optional, Sequence + + +ESC_YELLOW = "\033[1;33m" +ESC_CYAN = "\033[1;36m" +ESC_END = "\033[0m" + + +class Os(Enum): + LINUX = "Linux" + WINDOWS = "Windows" + DARWIN = "Darwin" + + +class Toolchain(IntEnum): + OTHER = 0 # msrv + STABLE = 1 + BETA = 2 + NIGHTLY = 3 + + +@dataclass +class Cfg: + toolchain_name: str + toolchain: Toolchain = field(init=False) + host_target: str = field(init=False) + os_: Os = field(init=False) + baseline_crate_dir: Optional[Path] + skip_semver: bool + + def __post_init__(self): + rustc_output = check_output(["rustc", f"+{self.toolchain_name}", "-vV"]) + self.host_target = re.findall(r"host: (.*)", rustc_output)[0] + if "nightly" in self.toolchain_name: + self.toolchain = Toolchain.NIGHTLY + elif "beta" in self.toolchain_name: + self.toolchain = Toolchain.BETA + elif "stable" in self.toolchain_name: + self.toolchain = Toolchain.STABLE + else: + self.toolchain = Toolchain.OTHER + self.os_ = Os(platform.system()) + eprint(f"Testing Rust {self.toolchain_name} on {self.os_}") + + def nightly(self) -> bool: + return self.toolchain == Toolchain.NIGHTLY + + +@dataclass +class Target: + name: str + dist: bool = True + min_toolchain: Toolchain = Toolchain.OTHER + + def __post_init__(self): + if not self.dist: + # We will need to use build-std + self.min_toolchain = Toolchain.NIGHTLY + + +@dataclass +class TargetResult: + """Not all checks exit immediately, so failures are reported here.""" + + target: Target + semver_ok: bool + + +FREEBSD_VERSIONS = [11, 12, 13, 14, 15] + +TARGETS = [ + # Tier 1 + Target("aarch64-apple-darwin"), + Target("aarch64-pc-windows-msvc"), + Target("aarch64-unknown-linux-gnu"), + Target("i686-pc-windows-msvc"), + Target("i686-unknown-linux-gnu"), + Target("x86_64-pc-windows-gnu"), + Target("x86_64-pc-windows-msvc"), + Target("x86_64-unknown-linux-gnu"), + # + # Tier 2 with host tools + Target("aarch64-pc-windows-gnullvm", min_toolchain=Toolchain.STABLE), + Target("aarch64-unknown-linux-musl"), + Target("aarch64-unknown-linux-ohos", min_toolchain=Toolchain.STABLE), + Target("arm-unknown-linux-gnueabi"), + Target("arm-unknown-linux-gnueabihf"), + Target("armv7-unknown-linux-gnueabihf"), + Target("armv7-unknown-linux-ohos", min_toolchain=Toolchain.STABLE), + Target("i686-pc-windows-gnu"), + Target("loongarch64-unknown-linux-gnu", min_toolchain=Toolchain.STABLE), + Target("loongarch64-unknown-linux-musl", min_toolchain=Toolchain.STABLE), + Target("powerpc-unknown-linux-gnu"), + Target("powerpc64-unknown-linux-gnu"), + Target("powerpc64le-unknown-linux-gnu"), + Target("powerpc64le-unknown-linux-musl", min_toolchain=Toolchain.STABLE), + Target("riscv64gc-unknown-linux-gnu"), + Target("s390x-unknown-linux-gnu"), + Target("sparcv9-sun-solaris"), + Target("x86_64-apple-darwin"), + Target("x86_64-pc-solaris"), + Target("x86_64-pc-windows-gnullvm", min_toolchain=Toolchain.STABLE), + Target("x86_64-unknown-freebsd"), + Target("x86_64-unknown-illumos"), + Target("x86_64-unknown-linux-musl"), + Target("x86_64-unknown-linux-ohos", min_toolchain=Toolchain.STABLE), + Target("x86_64-unknown-netbsd"), + # + # Tier 2 without host tools + Target("aarch64-apple-ios"), + Target("aarch64-linux-android"), + Target("aarch64-unknown-fuchsia", min_toolchain=Toolchain.STABLE), + Target("arm-linux-androideabi"), + Target("arm-unknown-linux-musleabi"), + Target("arm-unknown-linux-musleabihf"), + Target("armv5te-unknown-linux-gnueabi"), + Target("armv5te-unknown-linux-musleabi"), + Target("armv7-linux-androideabi"), + Target("armv7-unknown-linux-musleabihf"), + Target("i586-unknown-linux-gnu"), + Target("i586-unknown-linux-musl"), + Target("i686-linux-android"), + Target("i686-unknown-freebsd"), + Target("i686-unknown-linux-musl"), + Target("sparc64-unknown-linux-gnu"), + Target("wasm32-unknown-emscripten"), + Target("wasm32-unknown-unknown"), + Target("wasm32-wasip1", min_toolchain=Toolchain.STABLE), + Target("wasm32-wasip2", min_toolchain=Toolchain.STABLE), + Target("x86_64-fortanix-unknown-sgx"), + Target("x86_64-linux-android"), + Target("x86_64-unknown-fuchsia", min_toolchain=Toolchain.STABLE), + Target("x86_64-unknown-linux-gnux32"), + Target("x86_64-unknown-redox"), + # + # Libc has historically checked that a number of tier 3 targets build. Technically + # there is no need to do this given the target tier policy, but the cost is small + # and the saved churn from accidental breakage is significant, so we keep it around. + Target("aarch64-unknown-freebsd", dist=False), + Target("aarch64-unknown-hermit", dist=False), + Target("aarch64-unknown-illumos", dist=False), + Target("aarch64-unknown-netbsd", dist=False), + Target("aarch64-unknown-openbsd", dist=False), + Target("aarch64-wrs-vxworks", dist=False), + Target("armebv7r-none-eabihf", dist=False), + Target("armv7-wrs-vxworks-eabihf", dist=False), + Target("armv7r-none-eabihf", dist=False), + Target("armv7s-apple-ios", dist=False), + # FIXME(hexagon): hits "error: symbol 'fma' is already defined" error + # Target("hexagon-unknown-linux-musl", dist=False), + Target("i386-apple-ios", dist=False), + Target("i686-apple-darwin", dist=False), + Target("i686-unknown-haiku", dist=False), + Target("i686-unknown-hurd-gnu", dist=False), + Target("i686-unknown-netbsd", dist=False), + Target("i686-unknown-openbsd", dist=False), + Target("i686-wrs-vxworks", dist=False), + Target("mips-unknown-linux-gnu", dist=False), + Target("mips-unknown-linux-musl", dist=False), + Target("mips64-unknown-linux-gnuabi64", dist=False), + Target("mips64-unknown-linux-muslabi64", dist=False), + Target("mips64el-unknown-linux-gnuabi64", dist=False), + Target("mips64el-unknown-linux-muslabi64", dist=False), + Target("mipsel-unknown-linux-gnu", dist=False), + Target("mipsel-unknown-linux-musl", dist=False), + Target("nvptx64-nvidia-cuda", dist=False), + Target("powerpc-unknown-linux-gnuspe", dist=False), + Target("powerpc-unknown-netbsd", dist=False), + Target("powerpc-wrs-vxworks", dist=False), + Target("powerpc-wrs-vxworks-spe", dist=False), + Target("powerpc64-ibm-aix", dist=False), + Target("powerpc64-unknown-freebsd", dist=False), + Target("powerpc64-wrs-vxworks", dist=False), + Target("riscv32-wrs-vxworks", dist=False), + Target("riscv32gc-unknown-linux-gnu", dist=False), + Target("riscv32i-unknown-none-elf", dist=False), + Target("riscv32imac-unknown-none-elf", dist=False), + Target("riscv32imc-unknown-none-elf", dist=False), + Target("riscv64-wrs-vxworks", dist=False), + Target("riscv64a23-unknown-linux-gnu", dist=False), + Target("riscv64gc-unknown-freebsd", dist=False), + Target("riscv64gc-unknown-hermit", dist=False), + Target("riscv64gc-unknown-linux-musl", dist=False), + Target("riscv64gc-unknown-none-elf", dist=False), + Target("riscv64imac-unknown-none-elf", dist=False), + Target("s390x-unknown-linux-musl", dist=False), + Target("sparc-unknown-linux-gnu", dist=False), + Target("sparc64-unknown-netbsd", dist=False), + Target("thumbv7em-none-eabihf", dist=False), + Target("thumbv7m-none-eabi", dist=False), + Target("thumbv7neon-linux-androideabi", dist=False), + Target("thumbv7neon-unknown-linux-gnueabihf", dist=False), + Target("thumbv8m.main-none-eabi", dist=False), + Target("x86_64-unknown-dragonfly", dist=False), + Target("x86_64-unknown-haiku", dist=False), + Target("x86_64-unknown-hermit", dist=False), + Target("x86_64-unknown-l4re-uclibc", dist=False), + Target("x86_64-unknown-openbsd", dist=False), + Target("x86_64-wrs-vxworks", dist=False), +] + + +def eprint(*args, **kw) -> None: + print(*args, file=sys.stderr, **kw) + + +def xtrace(args: Sequence[str | Path], *, env: Optional[dict[str, str]]) -> None: + """Print commands before running them.""" + astr = " ".join(str(arg) for arg in args) + if env is None: + eprint(f"+ {astr}") + else: + envdiff = set(env.items()) - set(os.environ.items()) + estr = " ".join(f"{k}='{v}'" for (k, v) in envdiff) + eprint(f"+ {estr} {astr}") + + +def check_output( + args: Sequence[str | Path], *, env: Optional[dict[str, str]] = None +) -> str: + xtrace(args, env=env) + return sp.check_output(args, env=env, encoding="utf8") + + +def run( + args: Sequence[str | Path], + *, + env: Optional[dict[str, str]] = None, + check: bool = True, +) -> sp.CompletedProcess: + xtrace(args, env=env) + return sp.run(args, env=env, check=check) + + +def check_dup_targets() -> None: + """Ensure there are no duplicate targets in the list.""" + all = set() + duplicates = set() + for target in TARGETS: + if target.name in all: + duplicates.add(target.name) + all.add(target.name) + assert len(duplicates) == 0, f"duplicate targets: {duplicates}" + + +def do_semver_checks(cfg: Cfg, target: Target) -> bool: + """Run cargo semver-checks for a target.""" + tname = target.name + if cfg.toolchain != Toolchain.STABLE: + eprint("Skipping semver checks (only supported on stable)") + return True + + if not target.dist: + eprint("Skipping semver checks on non-dist target") + return True + + if tname == cfg.host_target: + # FIXME(semver): This is what we actually want to be doing on all targets, but + # `--target` doesn't work right with semver-checks. + eprint("Running semver checks on host") + # NOTE: this is the only check which actually fails CI if it doesn't succeed, + # since it is the only check we can control lints for (via the + # package.metadata table). + # + # We may need to play around with this a bit. + run( + [ + "cargo", + "semver-checks", + "--only-explicit-features", + "--features=std,extra_traits", + "--release-type=patch", + ], + check=True, + ) + # Don't return here so we still get the same rustdoc-json-base tests even while + # running on the host. + + if cfg.baseline_crate_dir is None: + eprint( + "Non-host target: --baseline-crate-dir must be specified to \ + run semver-checks" + ) + sys.exit(1) + + # Since semver-checks doesn't work with `--target`, we build the json ourself and + # hand it over. + eprint("Running semver checks with cross compilation") + + # Set the bootstrap hack (for rustdoc json), allow warnings, and get rid of LIBC_CI + # (which sets `deny(warnings)`). + env = os.environ.copy() + env.setdefault("RUSTFLAGS", "") + env["RUSTFLAGS"] += " -Awarnings" + env["RUSTC_BOOTSTRAP"] = "1" + env.pop("LIBC_CI", None) + + cmd = ["cargo", "rustdoc", "--target", tname] + # Take the flags from: + # https://github.com/obi1kenobi/cargo-semver-checks/blob/030af2032e93a64a6a40c4deaa0f57f262042426/src/data_generation/generate.rs#L241-L297 + rustdoc_args = [ + "--", + "-Zunstable-options", + "--document-private-items", + "--document-hidden-items", + "--output-format=json", + "--cap-lints=allow", + ] + + # Build the current crate and the baseline crate, which CI should have downloaded + run([*cmd, *rustdoc_args], env=env) + run( + [*cmd, "--manifest-path", cfg.baseline_crate_dir / "Cargo.toml", *rustdoc_args], + env=env, + ) + + baseline = cfg.baseline_crate_dir / "target" / tname / "doc" / "libc.json" + current = Path("target") / tname / "doc" / "libc.json" + + # NOTE: We can't configure lints when using the rustoc input :(. For this reason, + # we don't check for failure output status since there is no way to override false + # positives. + # + # See: https://github.com/obi1kenobi/cargo-semver-checks/issues/827 + res = run( + [ + "cargo", + "semver-checks", + "--baseline-rustdoc", + baseline, + "--current-rustdoc", + current, + # For now, everything is a patch + "--release-type=patch", + ], + check=False, + ) + + # If this job failed, we can't fail CI because it may have been a false positive. + # But at least we can make an explicit note of it. + return res.returncode == 0 + + +def test_target(cfg: Cfg, target: Target) -> TargetResult: + """Run tests for a single target.""" + start = time.time() + env = os.environ.copy() + env.setdefault("RUSTFLAGS", "") + + tname = target.name + target_cfg = check_output(["rustc", "--print=cfg", "--target", tname]) + target_env = re.findall(r'target_env="(.*)"', target_cfg) + target_os = re.findall(r'target_os="(.*)"', target_cfg) + target_bits = re.findall(r'target_pointer_width="(.*)"', target_cfg)[0] + assert target_bits in ["32", "64"] + eprint(f"env {target_env}, os {target_os}, bits {target_bits}") + + # Usually we do a full build to make sure we don't run into any crashes or link + # problems. If we need to use build-std, though, only do a check to speed + # things up. + if target.dist: + action = "build" + else: + action = "check" + + cmd = ["cargo", f"+{cfg.toolchain_name}", action, "--target", tname] + + if not target.dist: + # If we can't download a `core`, we need to build it + cmd += ["-Zbuild-std=core"] + # FIXME: With `the build-std` feature, `compiler_builtins` emits a lot of + # lint warnings. + env["RUSTFLAGS"] += " -Aimproper_ctypes_definitions" + else: + run(["rustup", "target", "add", tname, "--toolchain", cfg.toolchain_name]) + + # Test with expected combinations of features + run(cmd, env=env) + run([*cmd, "--features=extra_traits"], env=env) + + # Check with different env for 64-bit time_t + if target_os == "linux" and target_bits == "32": + # Equivalent of __USE_TIME_BITS64 + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64": "1"}) + + if "gnu" in target_env and target_bits == "32": + # Equivalent of _FILE_OFFSET_BITS=64 + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS": "64"}) + # Equivalent of _TIME_BITS=64 + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_TIME_BITS": "64"}) + + if "musl" in target_env: + # Check with breaking changes from musl, including 64-bit time_t on 32-bit + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_MUSL_V1_2_3": "1"}) + + # Test again without default features, i.e. without `std` + run([*cmd, "--no-default-features"]) + run([*cmd, "--no-default-features", "--features=extra_traits"]) + + # Ensure the crate will build when used as a dependency of `std` + if cfg.nightly(): + run([*cmd, "--no-default-features", "--features=rustc-dep-of-std"]) + + # For freebsd targets, check with the different versions we support + # if on nightly or stable + if "freebsd" in tname and cfg.toolchain >= Toolchain.STABLE: + for version in FREEBSD_VERSIONS: + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_FREEBSD_VERSION": str(version)}) + run( + [*cmd, "--no-default-features"], + env=env | {"RUST_LIBC_UNSTABLE_FREEBSD_VERSION": str(version)}, + ) + + if cfg.skip_semver: + eprint("Skipping semver checks") + semver_ok = True + else: + semver_ok = do_semver_checks(cfg, target) + + elapsed = round(time.time() - start, 2) + eprint(f"Finished checking target {tname} in {elapsed} seconds") + return TargetResult(target=target, semver_ok=semver_ok) + + +def main() -> None: + p = argparse.ArgumentParser() + p.add_argument("--toolchain", required=True, help="Rust toolchain") + p.add_argument("--only", help="only targets matching this regex") + p.add_argument("--skip", help="skip targets matching this regex") + p.add_argument("--skip-semver", help="don't run semver checks") + p.add_argument( + "--baseline-crate-dir", + help="specify the directory of the crate to run semver checks against", + ) + p.add_argument( + "--half", + type=int, + choices=[1, 2], + help="specify 1 or 2 to run half of the targets", + ) + args = p.parse_args() + + cfg = Cfg( + toolchain_name=args.toolchain, + baseline_crate_dir=args.baseline_crate_dir and Path(args.baseline_crate_dir), + skip_semver=args.skip_semver, + ) + eprint(f"Config: {cfg}") + eprint("Python version: ", sys.version) + check_dup_targets() + start = time.time() + + if cfg.nightly(): + # Needed for build-std + run(["rustup", "component", "add", "rust-src"]) + + targets = TARGETS + eprint(f"Total checked targets across platforms: {len(targets)}") + + if not cfg.nightly(): + # Non-dist targets need nightly for build-std + targets = [t for t in targets if t.dist] + + # Filter to targets supported on the current toolchain + targets = [t for t in targets if cfg.toolchain >= t.min_toolchain] + eprint(f"Targets checkable with this toolchain: {len(targets)}") + + # Apply filtering + if args.only: + targets = [t for t in targets if re.match(args.only, t.name)] + if args.skip: + targets = [t for t in targets if not re.match(args.skip, t.name)] + + # Allow splitting the targets in half for time improvements + if args.half == 1: + targets = targets[0::2] + elif args.half == 2: + targets = targets[1::2] + + total = len(targets) + eprint(f"Targets to run: {total}") + assert total > 0, "some tests should be run" + target_results: list[TargetResult] = [] + + for i, target in enumerate(targets): + at = i + 1 + eprint(f"::group::Target: {target.name} ({at}/{total})") + eprint(f"{ESC_CYAN}Checking target {target} ({at}/{total}){ESC_END}") + res = test_target(cfg, target) + target_results.append(res) + eprint("::endgroup::") + + elapsed = round(time.time() - start, 2) + + semver_failures = [t.target.name for t in target_results if not t.semver_ok] + if len(semver_failures) != 0: + eprint(f"\n{ESC_YELLOW}Some targets had semver failures:{ESC_END}") + for t in semver_failures: + eprint(f"* {t}") + + eprint(f"\nChecked {total} targets in {elapsed} seconds") + + +main() diff --git a/ci/verify-build.sh b/ci/verify-build.sh deleted file mode 100755 index e833de2e04c5b..0000000000000 --- a/ci/verify-build.sh +++ /dev/null @@ -1,344 +0,0 @@ -#!/usr/bin/env sh - -# Checks that libc builds properly for all supported targets on a particular -# Rust version: -# The FILTER environment variable can be used to select which target(s) to build. -# For example: set FILTER to vxworks to select the targets that has vxworks in name - -set -eux - -: "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}" - -rust="$TOOLCHAIN" -filter="${FILTER:-}" -host_target=$(rustc -vV | awk '/^host/ { print $2 }') - -case "$(uname -s)" in - Linux*) os=linux ;; - Darwin*) os=macos ;; - MINGW*) os=windows ;; - *) - echo "Unknown system $(uname -s)" - exit 1 - ;; -esac - -echo "Testing Rust $rust on $os" - -if [ "$TOOLCHAIN" = "nightly" ]; then - # For build-std - rustup component add rust-src -fi - -# Print GHA workflow commands -echo_if_ci() { - # Discard stderr so the "set -x" trace doesn't show up - { [ -n "${CI:-}" ] && echo "$1"; } 2> /dev/null -} - -# Run the tests for a specific target -test_target() { - target="$1" - no_dist="$2" - - RUSTFLAGS="${RUSTFLAGS:-}" - - # The basic command that is run each time - cmd="cargo +$rust build --target $target" - - if [ "${no_dist}" != "0" ]; then - # If we can't download a `core`, we need to build it - cmd="$cmd -Zbuild-std=core" - - # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. - RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" - export RUSTFLAGS - else - # Otherwise it is available for download; fetch it: - - # FIXME: rustup often fails to download some artifacts due to network - # issues, so we retry this N times. - N=5 - n=0 - until [ $n -ge $N ]; do - if rustup target add "$target" --toolchain "$rust"; then - break - fi - n=$((n + 1)) - sleep 1 - done - fi - - # Test with expected combinations of features - $cmd - $cmd --features extra_traits - - if [ "$os" = "linux" ]; then - # Test with the equivalent of __USE_TIME_BITS64 - RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd - case "$target" in - arm*-gnu* | i*86*-gnu | powerpc-*-gnu* | mips*-gnu | sparc-*-gnu | thumb-*gnu*) - # Test with the equivalent of _FILE_OFFSET_BITS=64 - RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd - # Test with the equivalent of _TIME_BITS=64 - RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd - ;; - esac - fi - - # Test again without default features, i.e. without "std" - $cmd --no-default-features - $cmd --no-default-features --features extra_traits - - # Ensure the crate will build when used with `std` - if [ "$rust" = "nightly" ]; then - $cmd --no-default-features --features rustc-dep-of-std - fi - - # For tier 2 freebsd targets, check with the different versions we support - # if on nightly or stable - case "$rust-$target" in - stable-x86_64-*freebsd*) do_freebsd_checks=1 ;; - nightly-i686*freebsd*) do_freebsd_checks=1 ;; - esac - - if [ -n "${do_freebsd_checks:-}" ]; then - for version in $freebsd_versions; do - export RUST_LIBC_UNSTABLE_FREEBSD_VERSION="$version" - $cmd - $cmd --no-default-features - done - fi - - # FIXME(semver): can't pass `--target` to `cargo-semver-checks` - if [ "$rust" = "stable" ] && [ "$target" = "$host_target" ]; then - # Run semver checks on the stable channel - cargo semver-checks --only-explicit-features \ - --features std,extra_traits - fi -} - -freebsd_versions="\ -11 \ -12 \ -13 \ -14 \ -15 \ -" - -rust_linux_targets="\ -aarch64-linux-android \ -aarch64-unknown-linux-gnu \ -aarch64-unknown-linux-musl \ -arm-linux-androideabi \ -arm-unknown-linux-gnueabi \ -arm-unknown-linux-gnueabihf \ -arm-unknown-linux-musleabi \ -arm-unknown-linux-musleabihf \ -armv7-linux-androideabi \ -armv7-unknown-linux-gnueabihf \ -armv7-unknown-linux-musleabihf \ -i586-unknown-linux-gnu \ -i586-unknown-linux-musl \ -i686-linux-android \ -i686-unknown-freebsd \ -i686-unknown-linux-gnu \ -i686-unknown-linux-musl \ -powerpc-unknown-linux-gnu \ -powerpc64-unknown-linux-gnu \ -powerpc64le-unknown-linux-gnu \ -s390x-unknown-linux-gnu \ -sparc64-unknown-linux-gnu \ -sparcv9-sun-solaris \ -wasm32-unknown-emscripten \ -wasm32-unknown-unknown \ -wasm32-wasip1 \ -wasm32-wasip2 \ -x86_64-linux-android \ -x86_64-unknown-freebsd \ -x86_64-unknown-linux-gnu \ -x86_64-unknown-linux-musl \ -x86_64-unknown-netbsd \ -" - -# FIXME(powerpc64le): powerpc64le-unknown-linux-musl is tier 2 since 1.85 and -# can be moved to rust_linux_targets once MSRV is increased -rust_nightly_linux_targets="\ -aarch64-unknown-fuchsia \ -armv5te-unknown-linux-gnueabi \ -armv5te-unknown-linux-musleabi \ -i686-pc-windows-gnu \ -powerpc64le-unknown-linux-musl \ -riscv64gc-unknown-linux-gnu \ -x86_64-fortanix-unknown-sgx \ -x86_64-pc-solaris \ -x86_64-pc-windows-gnu \ -x86_64-unknown-fuchsia \ -x86_64-unknown-illumos \ -x86_64-unknown-linux-gnux32 \ -x86_64-unknown-redox \ -" - -rust_apple_targets="\ -aarch64-apple-darwin \ -aarch64-apple-ios \ -x86_64-apple-darwin \ -x86_64-apple-ios \ -" - -rust_nightly_apple_targets="\ -" - -# Must start with `x86_64-pc-windows-msvc` first. -rust_nightly_windows_targets="\ -x86_64-pc-windows-msvc \ -x86_64-pc-windows-gnu \ -i686-pc-windows-msvc \ -" - -# Targets which are not available via rustup and must be built with -Zbuild-std -# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has -# duplicate symbol errors from `compiler_builtins`. -rust_linux_no_dist_targets="\ -aarch64-pc-windows-msvc \ -aarch64-unknown-freebsd \ -aarch64-unknown-hermit \ -aarch64-unknown-netbsd \ -aarch64-unknown-openbsd \ -aarch64-wrs-vxworks \ -armebv7r-none-eabi \ -armebv7r-none-eabihf \ -armv7-wrs-vxworks-eabihf \ -armv7r-none-eabi \ -armv7r-none-eabihf \ -i686-pc-windows-msvc \ -i686-unknown-haiku \ -i686-unknown-netbsd \ -i686-unknown-openbsd \ -i686-wrs-vxworks \ -mips-unknown-linux-gnu \ -mips-unknown-linux-musl \ -mips64-unknown-linux-gnuabi64 \ -mips64-unknown-linux-muslabi64 \ -mips64el-unknown-linux-gnuabi64 \ -mips64el-unknown-linux-muslabi64 \ -mipsel-unknown-linux-gnu \ -mipsel-unknown-linux-musl \ -mipsel-sony-psp \ -nvptx64-nvidia-cuda \ -powerpc-unknown-linux-gnuspe \ -powerpc-unknown-netbsd \ -powerpc-wrs-vxworks \ -powerpc-wrs-vxworks-spe \ -powerpc64-unknown-freebsd \ -powerpc64-wrs-vxworks \ -riscv32i-unknown-none-elf \ -riscv32imac-unknown-none-elf \ -riscv32imc-unknown-none-elf \ -riscv32gc-unknown-linux-gnu \ -riscv32-wrs-vxworks \ -riscv64gc-unknown-freebsd \ -riscv64gc-unknown-hermit \ -riscv64gc-unknown-linux-musl \ -riscv64gc-unknown-none-elf \ -riscv64imac-unknown-none-elf \ -riscv64-wrs-vxworks \ -s390x-unknown-linux-musl \ -sparc-unknown-linux-gnu \ -sparc64-unknown-netbsd \ - -thumbv6m-none-eabi \ -thumbv7em-none-eabi \ -thumbv7em-none-eabihf \ -thumbv7m-none-eabi \ -thumbv7neon-linux-androideabi \ -thumbv7neon-unknown-linux-gnueabihf \ -thumbv8m.main-none-eabi \ -x86_64-pc-windows-msvc \ -x86_64-unknown-dragonfly \ -x86_64-unknown-haiku \ -x86_64-unknown-hermit \ -x86_64-unknown-l4re-uclibc \ -x86_64-unknown-openbsd \ -x86_64-wrs-vxworks \ -" - -rust_apple_no_dist_targets="\ -armv7s-apple-ios \ -i686-apple-darwin \ -i386-apple-ios \ -" - -# The targets are listed here alphabetically -if [ "$os" = "linux" ]; then - targets="$rust_linux_targets" - nightly_targets="$rust_nightly_linux_targets" - no_dist_targets="$rust_linux_no_dist_targets" -elif [ "$os" = "macos" ]; then - targets="$rust_apple_targets" - nightly_targets="$rust_nightly_apple_targets" - no_dist_targets="$rust_apple_no_dist_targets" -elif [ "$os" = "windows" ]; then - targets=${rust_nightly_windows_targets} -else - exit 1 -fi - -if [ "$rust" = "nightly" ]; then - targets="$targets ${nightly_targets:-}" -else - # build-std requires nightly - no_dist_targets="" -fi - -case "$rust" in - "stable") supports_wasi_pn=1 ;; - "beta") supports_wasi_pn=1 ;; - "nightly") supports_wasi_pn=1 ;; - *) supports_wasi_pn=0 ;; -esac - -some_tests_run=0 - -# Apply the `FILTER` variable, do OS-specific tasks, and run a target -filter_and_run() { - target="$1" - no_dist="${2:-0}" - - if echo "$target" | grep -q "$filter"; then - if [ "$os" = "windows" ]; then - TARGET="$target" ./ci/install-rust.sh - fi - - # `wasm32-wasip1` was renamed from `wasm32-wasi` - if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then - target="wasm32-wasi" - fi - - # `wasm32-wasip2` only exists in recent versions of Rust - if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then - return - fi - - test_target "$target" "$no_dist" - some_tests_run=1 - fi -} - -for target in $targets; do - echo_if_ci "::group::Target: $target" - filter_and_run "$target" - echo_if_ci "::endgroup::" -done - -for target in ${no_dist_targets:-}; do - echo_if_ci "::group::Target: $target" - filter_and_run "$target" 1 - echo_if_ci "::endgroup::" -done - -# Make sure we didn't accidentally filter everything -if [ "$some_tests_run" != 1 ]; then - echo "No tests were run" - exit 1 -fi diff --git a/ci/wasi.sh b/ci/wasi.sh index 4928681b0a270..2648aa38207d7 100755 --- a/ci/wasi.sh +++ b/ci/wasi.sh @@ -11,8 +11,8 @@ apt-get install -y --no-install-recommends \ # Wasmtime is used to execute tests and wasi-sdk is used to compile tests. # Download appropriate versions here and configure various flags below. -wasmtime=35.0.0 -wasi_sdk=25 +wasmtime=38.0.2 +wasi_sdk=29 curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | tar xJf - diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 4ae4a3cd2056f..2f83b9659fae3 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -9,20 +9,20 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" [dependencies] -cfg-if = "1.0.1" -libc = { path = "..", version = "0.2.171", default-features = false } +cfg-if = "1.0.4" +libc = { path = "..", version = "0.2.177", default-features = false } [dev-dependencies] -syn = { version = "2.0.104", features = ["full", "visit"] } -proc-macro2 = { version = "1.0.95", features = ["span-locations"] } -glob = "0.3.2" +syn = { version = "2.0.108", features = ["full", "visit"] } +proc-macro2 = { version = "1.0.103", features = ["span-locations"] } +glob = "0.3.3" annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } [build-dependencies] -cc = "1.2.29" +cc = "1.2.43" # Use the in-tree `ctest` from the `main` branch via crates.io -ctest = "0.5.0-beta.0" -regex = "1.11.1" +ctest = "0.5.0-beta.2" +regex = "1.12.2" [features] default = ["std"] @@ -32,54 +32,36 @@ extra_traits = ["libc/extra_traits"] [[test]] name = "ctest" -path = "test/ctest.rs" harness = false [[test]] -name = "linux-fcntl" -path = "test/linux_fcntl.rs" +name = "linux_fcntl" harness = false [[test]] -name = "linux-if-arp" -path = "test/linux_if_arp.rs" +name = "linux_if_arp" harness = false [[test]] -name = "linux-ipv6" -path = "test/linux_ipv6.rs" +name = "linux_ipv6" harness = false [[test]] -name = "linux-elf" -path = "test/linux_elf.rs" +name = "linux_elf" harness = false [[test]] -name = "linux-strerror_r" -path = "test/linux_strerror_r.rs" +name = "linux_strerror_r" harness = false [[test]] -name = "linux-termios" -path = "test/linux_termios.rs" +name = "linux_termios" harness = false [[test]] name = "semver" -path = "test/semver.rs" harness = false -[[test]] -name = "style" -path = "test/check_style.rs" -harness = true - -[[test]] -name = "style_tests" -path = "test/style_tests.rs" -harness = true - # FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]` # once MSRV is above 1.64 and replaced with `[lints] workspace=true` diff --git a/libc-test/build.rs b/libc-test/build.rs index ebc8f775c584d..71448bedc09e2 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2,9 +2,20 @@ #![allow(clippy::match_like_matches_macro)] use std::fs::File; -use std::io::{BufRead, BufReader, BufWriter, Write}; -use std::path::{Path, PathBuf}; -use std::{env, io}; +use std::io::{ + BufRead, + BufReader, + BufWriter, + Write, +}; +use std::path::{ + Path, + PathBuf, +}; +use std::{ + env, + io, +}; fn do_cc() { let target = env::var("TARGET").unwrap(); @@ -72,10 +83,16 @@ fn do_ctest() { fn ctest_cfg() -> ctest::TestGenerator { let mut cfg = ctest::TestGenerator::new(); cfg.skip_private(true); - let libc_cfgs = ["libc_thread_local"]; - for f in &libc_cfgs { - cfg.cfg(f, None); - } + + // Skip anonymous unions/structs. + cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); + cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); + cfg.skip_alias(|ty| ty.ident().starts_with("__c_anonymous_")); + + // __uint128 is not declared in C, but is an alias we export. + // FIXME(1.0): These aliases will eventually be removed. + cfg.skip_alias(|ty| ty.ident() == "__uint128"); + cfg } @@ -100,7 +117,7 @@ fn do_semver() { // maintain a file for Android. // NOTE: AIX doesn't include the unix file because there are definitions // missing on AIX. It is easier to maintain a file for AIX. - if family != os && !matches!(os.as_str(), "android" | "aix") { + if family != os && !matches!(os.as_str(), "android" | "aix") && os != "vxworks" { process_semver_file(&mut output, &mut semver_root, &family); } // We don't do semver for unknown targets. @@ -163,22 +180,24 @@ fn main() { } macro_rules! headers { - ($cfg:ident: [$m:expr]: $header:literal) => { - if $m { - $cfg.header($header); - } - }; - ($cfg:ident: $header:literal) => { - $cfg.header($header); - }; - ($($cfg:ident: $([$c:expr]:)* $header:literal,)*) => { - $(headers!($cfg: $([$c]:)* $header);)* - }; - ($cfg:ident: $( $([$c:expr]:)* $header:literal,)*) => { - headers!($($cfg: $([$c]:)* $header,)*); - }; - ($cfg:ident: $( $([$c:expr]:)* $header:literal),*) => { - headers!($($cfg: $([$c]:)* $header,)*); + ( + $cfg:ident, + $( + // Allow a simple header + $($header:literal)? + // As well as a style that is conditionally applied. + $(($pred:expr, $pred_header:literal))? + , + )+ + ) => { + $( + $( $cfg.header($header); )? + $( + if $pred { + $cfg.header($pred_header); + } + )? + )+ }; } @@ -192,7 +211,8 @@ fn test_apple(target: &str) { cfg.flag("-Wno-deprecated-declarations"); cfg.define("__APPLE_USE_RFC_3542", None); - headers! { cfg: + headers!( + cfg, "aio.h", "CommonCrypto/CommonCrypto.h", "CommonCrypto/CommonRandom.h", @@ -244,8 +264,7 @@ fn test_apple(target: &str) { "os/clock.h", "os/lock.h", "os/signpost.h", - // FIXME(macos): Requires the macOS 14.4 SDK. - //"os/os_sync_wait_on_address.h", + "os/os_sync_wait_on_address.h", "poll.h", "pthread.h", "pthread_spis.h", @@ -306,14 +325,10 @@ fn test_apple(target: &str) { "utmpx.h", "wchar.h", "xlocale.h", - [x86_64]: "crt_externs.h", - } - - // Skip anonymous unions/structs. - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); + (x86_64, "crt_externs.h"), + ); - cfg.skip_struct(|s| { + cfg.skip_struct(move |s| { match s.ident() { // FIXME(union): actually a union "sigval" => true, @@ -322,21 +337,9 @@ fn test_apple(target: &str) { // it is a moving target, changing through versions // also contains bitfields members "tcp_connection_info" => true, - // FIXME(macos): The size is changed in recent macOSes. - "malloc_introspection_t" => true, - _ => false, - } - }); - - cfg.skip_alias(|ty| ty.ident().starts_with("__c_anonymous_")); - cfg.skip_alias(|ty| { - match ty.ident() { - // FIXME(macos): Requires the macOS 14.4 SDK. - "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true, - - // FIXME(macos): "'__uint128' undeclared" in C - "__uint128" => true, + // FIXME(macos): The size is changed in recent macOSes. + "malloc_introspection_t" if x86_64 => true, _ => false, } }); @@ -345,21 +348,14 @@ fn test_apple(target: &str) { match constant.ident() { // They're declared via `deprecated_mach` and we don't support it anymore. x if x.starts_with("VM_FLAGS_") => true, - // These OSX constants are removed in Sierra. + // FIXME(deprecated): These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, - // FIXME(macos): the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). - "SF_SETTABLE" => true, - // FIXME(macos): XCode 13.1 doesn't have it. + // FIXME(deprecated): Removed since 12.0.1 / xnu-8019.41.5. See `ttycom.h` at + // https://github.com/apple-oss-distributions/xnu/commit/e6231be02a03711ca404e5121a151b24afbff733 "TIOCREMOTE" => true, - // FIXME(macos): Requires the macOS 14.4 SDK. - "OS_SYNC_WAKE_BY_ADDRESS_NONE" - | "OS_SYNC_WAKE_BY_ADDRESS_SHARED" - | "OS_SYNC_WAIT_ON_ADDRESS_NONE" - | "OS_SYNC_WAIT_ON_ADDRESS_SHARED" => true, - _ => false, } }); @@ -369,41 +365,19 @@ fn test_apple(target: &str) { match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, - // close calls the close_nocancel system call - "close" => true, - + // close calls the close_nocancel system call on x86 + "close" if x86_64 => true, // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 "res_init" => true, - - // FIXME(macos): remove once the target in CI is updated - "pthread_jit_write_freeze_callbacks_np" => true, - - // FIXME(macos): ABI has been changed on recent macOSes. - "os_unfair_lock_assert_owner" | "os_unfair_lock_assert_not_owner" => true, - - // FIXME(macos): Once the SDK get updated to Ventura's level - "freadlink" | "mknodat" | "mkfifoat" => true, - - // FIXME(macos): Requires the macOS 14.4 SDK. - "os_sync_wake_by_address_any" - | "os_sync_wake_by_address_all" - | "os_sync_wake_by_address_flags_t" - | "os_sync_wait_on_address" - | "os_sync_wait_on_address_flags_t" - | "os_sync_wait_on_address_with_deadline" - | "os_sync_wait_on_address_with_timeout" => true, - _ => false, } }); cfg.skip_struct_field(move |struct_, field| { match (struct_.ident(), field.ident()) { - // FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]). - ("statfs", "f_reserved") => true, - ("__darwin_arm_neon_state64", "__v") => true, // MAXPATHLEN is too big for auto-derive traits on arrays. ("vnode_info_path", "vip_path") => true, + // Anonymous ADT fields ("ifreq", "ifr_ifru") => true, ("in6_ifreq", "ifr_ifru") => true, ("ifkpi", "ifk_data") => true, @@ -454,8 +428,6 @@ fn test_apple(target: &str) { cfg.skip_roundtrip(move |s| match s { // FIXME(macos): this type has the wrong ABI "max_align_t" if i686 => true, - // Can't return an array from a C function. - "uuid_t" | "vol_capabilities_set_t" => true, _ => false, }); @@ -470,7 +442,8 @@ fn test_openbsd(target: &str) { let x86_64 = target.contains("x86_64"); - headers! { cfg: + headers!( + cfg, "elf.h", "errno.h", "execinfo.h", @@ -492,7 +465,7 @@ fn test_openbsd(target: &str) { "ctype.h", "dirent.h", "sys/socket.h", - [x86_64]:"machine/fpu.h", + (x86_64, "machine/fpu.h"), "net/if.h", "net/route.h", "net/if_arp.h", @@ -554,7 +527,7 @@ fn test_openbsd(target: &str) { "sys/shm.h", "sys/param.h", "sys/auxv.h", - } + ); cfg.rename_type(|ty| match ty { // FIXME(openbsd): https://github.com/rust-lang/libc/issues/1273 @@ -630,9 +603,6 @@ fn test_openbsd(target: &str) { } }); - // Skip anonymous unions/structs. - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |ty| { match ty.ident() { // FIXME(union): actually a union @@ -670,7 +640,8 @@ fn test_cygwin(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -696,6 +667,7 @@ fn test_cygwin(target: &str) { "spawn.h", "stddef.h", "stdlib.h", + "stdio.h", "string.h", "sys/cpuset.h", "sys/ioctl.h", @@ -718,9 +690,10 @@ fn test_cygwin(target: &str) { "termios.h", "unistd.h", "utime.h", + "utmpx.h", "wait.h", "wchar.h", - } + ); cfg.rename_type(|ty| match ty { "Ioctl" => Some("int".to_string()), @@ -768,14 +741,6 @@ fn test_cygwin(target: &str) { _ => false, }); - cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } - - false - }); - cfg.rename_struct_field(move |struct_, field| { match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part @@ -846,7 +811,8 @@ fn test_windows(target: &str) { } cfg.define("_WIN32_WINNT", Some("0x8000")); - headers! { cfg: + headers!( + cfg, "direct.h", "errno.h", "fcntl.h", @@ -864,9 +830,9 @@ fn test_windows(target: &str) { "sys/utime.h", "time.h", "wchar.h", - [gnu]: "ws2tcpip.h", - [!gnu]: "Winsock2.h", - } + (gnu, "ws2tcpip.h"), + (!gnu, "Winsock2.h"), + ); cfg.rename_struct_ty(|ty| { match ty { @@ -907,17 +873,12 @@ fn test_windows(target: &str) { }); cfg.skip_struct(move |struct_| { - let ty = struct_.ident(); - if ty.starts_with("__c_anonymous_") { - return true; - } - match ty { + match struct_.ident() { // FIXME(windows): The size and alignment of this struct are incorrect "timespec" if gnu && i686 => true, _ => false, } }); - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); cfg.skip_const(move |constant| { match constant.ident() { @@ -965,8 +926,8 @@ fn test_redox(target: &str) { let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); - headers! { - cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -1004,7 +965,7 @@ fn test_redox(target: &str) { "unistd.h", "utime.h", "wchar.h", - } + ); ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } @@ -1030,8 +991,8 @@ fn test_solarish(target: &str) { cfg.define("SIGINFO", Some("41")); } - headers! { - cfg: + headers!( + cfg, "aio.h", "ctype.h", "dirent.h", @@ -1110,19 +1071,14 @@ fn test_solarish(target: &str) { "utime.h", "utmpx.h", "wchar.h", - } + ); if is_illumos { - headers! { cfg: - "sys/epoll.h", - "sys/eventfd.h", - } + headers!(cfg, "sys/epoll.h", "sys/eventfd.h",); } if is_solaris { - headers! { cfg: - "sys/lgrp_user_impl.h", - } + headers!(cfg, "sys/lgrp_user_impl.h",); } cfg.skip_alias(move |ty| match ty.ident() { @@ -1184,15 +1140,12 @@ fn test_solarish(target: &str) { cfg.skip_union(|union_| { // the union handling is a mess - if union_.ident().starts_with("__c_anonymous_") || union_.ident().contains("door_desc_t_") { + if union_.ident().contains("door_desc_t_") { return true; } false }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } // the union handling is a mess if struct_.ident().contains("door_desc_t_") { return true; @@ -1314,11 +1267,17 @@ fn test_netbsd(target: &str) { assert!(target.contains("netbsd")); let mut cfg = ctest_cfg(); + // Assume netbsd10 but check for netbsd9 for test config. + let netbsd9 = match try_command_output("uname", &["-sr"]) { + Some(s) if s.starts_with("NetBSD 9.") => true, + _ => false, + }; + cfg.flag("-Wno-deprecated-declarations"); cfg.define("_NETBSD_SOURCE", Some("1")); - headers! { - cfg: + headers!( + cfg, "elf.h", "errno.h", "fcntl.h", @@ -1340,10 +1299,12 @@ fn test_netbsd(target: &str) { "ctype.h", "dirent.h", "dlfcn.h", + "execinfo.h", "glob.h", "grp.h", "ifaddrs.h", "langinfo.h", + "lwp.h", "net/bpf.h", "net/if.h", "net/if_arp.h", @@ -1362,12 +1323,14 @@ fn test_netbsd(target: &str) { "sched.h", "semaphore.h", "signal.h", + "spawn.h", "string.h", "sys/endian.h", "sys/exec_elf.h", "sys/xattr.h", "sys/extattr.h", "sys/file.h", + (!netbsd9, "sys/futex.h"), "sys/ioctl.h", "sys/ioctl_compat.h", "sys/ipc.h", @@ -1375,12 +1338,15 @@ fn test_netbsd(target: &str) { "sys/mman.h", "sys/mount.h", "sys/ptrace.h", + (!netbsd9, "sys/random.h"), "sys/resource.h", + "sys/sched.h", "sys/shm.h", "sys/socket.h", "sys/statvfs.h", "sys/sysctl.h", "sys/time.h", + (!netbsd9, "sys/timerfd.h"), "sys/times.h", "sys/timex.h", "sys/ucontext.h", @@ -1399,11 +1365,14 @@ fn test_netbsd(target: &str) { "mqueue.h", "netinet/dccp.h", "sys/event.h", + (!netbsd9, "sys/eventfd.h"), "sys/quota.h", "sys/reboot.h", "sys/shm.h", "iconv.h", - } + "utmp.h", + "utmpx.h", + ); cfg.rename_type(move |ty| { match ty { @@ -1435,16 +1404,15 @@ fn test_netbsd(target: &str) { } }); - cfg.skip_struct(|ty| ty.ident().starts_with("__c_anonymous_")); - cfg.skip_union(|ty| ty.ident().starts_with("__c_anonymous_")); + cfg.alias_is_c_enum(|ty| ty == "fae_action"); cfg.skip_alias(move |ty| { - if ty.ident().starts_with("__c_anonymous_") { - return true; - } match ty.ident() { // FIXME(netbsd): sighandler_t is crazy across platforms "sighandler_t" => true, + // Incomplete type in C + "cpuset_t" => true, + "eventfd_t" if netbsd9 => true, _ => false, } }); @@ -1456,6 +1424,14 @@ fn test_netbsd(target: &str) { // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. "termios2" => true, + // Anon struct + "__exit_status" => true, + // FIXME(netbsd): Should be importable but aren't for some reason. + "Aux32Info" | "Aux64Info" => true, + // deprecated, obsolete upstream + "ptrace_lwpinfo" => true, + // ABI change in NetBSD10, with symbol versioning. + "statvfs" if !netbsd9 => true, _ => false, } }); @@ -1475,12 +1451,19 @@ fn test_netbsd(target: &str) { "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness "SIGUNUSED" => true, // removed in glibc 2.26 + // deprecated, obsolete upstream + "PT_LWPINFO" | "PL_EVENT_NONE" | "PL_EVENT_SIGNAL" | "PL_EVENT_SUSPENDED" => true, + // weird signed extension or something like that? "MS_NOUSER" => true, "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 "BOTHER" => true, "GRND_RANDOM" | "GRND_INSECURE" | "GRND_NONBLOCK" => true, // netbsd 10 minimum + // Due to the NetBSD `__BIT` macro this turns out to be an `unsigned long`, but + // the futex syscall takes `int` ops. + "FUTEX_CMD_MASK" => true, + _ => false, } }); @@ -1488,15 +1471,22 @@ fn test_netbsd(target: &str) { cfg.skip_fn(move |func| { #[expect(clippy::wildcard_in_or_patterns)] match func.ident() { - // FIXME(netbsd): netbsd 10 minimum // FIXME(netbsd): https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, - "getentropy" | "getrandom" => true, + // FIXME(netbsd): Look into setting `_POSIX_C_SOURCE` to enable this + "qsort_r" => true, - "getrlimit" | "getrlimit64" | // non-int in 1st arg - "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg + "eventfd" | "eventfd_read" | "eventfd_write" if netbsd9 => true, + + _ => false, + } + }); + cfg.skip_fn_ptrcheck(move |func| { + match func { + // New symbol version present in NetBSD10, but we keep the old versions for NetBSD9 + // compatibility. + "getmntinfo" | "statvfs" | "fstatvfs" | "getvfsstat" | "sigaction" => true, _ => false, } }); @@ -1519,10 +1509,65 @@ fn test_netbsd(target: &str) { ("Elf64_Phdr", "p_type") => true, // pthread_spin_t is a volatile uchar ("pthread_spinlock_t", "pts_spin") => true, + + // `tcp_snd_wscale` and `tcp_rcv_wscale` are bitfields + ("tcp_info", "tcp_snd_wscale") => true, + ("tcp_info", "tcp_rcv_wscale") => true, + + // Anonymous unions + ("ifconf", "ifc_ifcu") => true, + ("ifreq", "ifr_ifru") => true, + ("utmpx", "ut_exit") => true, + ("posix_spawn_file_actions_entry_t", "fae_data") => true, + _ => false, } }); + // Unless otherwise noted, everything in this block was an addition in NetBS 10. + if netbsd9 { + cfg.skip_const(move |constant| match constant.ident() { + "EOWNERDEAD" + | "ENOTRECOVERABLE" + | "F_GETPATH" + | "MNT_NFS4ACLS" + | "MNT_POSIX1EACLS" + | "MNT_ACLS" + | "EVFILT_USER" + | "EVFILT_EMPTY" + | "REG_ILLSEQ" + | "PT_SET_SIGPASS" + | "PT_GET_SIGPASS" + | "EXTATTR_NAMESPACE_EMPTY" => true, + x if x.starts_with("FUTEX") => true, + x if x.starts_with("NOTE_") => true, + x if x.starts_with("PT_LWP") => true, + x if x.starts_with("TFD_") => true, + "ELAST" => true, // not version-stable + _ => false, + }); + + cfg.skip_struct(move |struct_| match struct_.ident() { + "sockaddr_dl" if !netbsd9 => true, // Last field increased size in 10 + x if x.starts_with("ptrace_lwp") => true, + // These were packed before NetBSD 10 + "arphdr" | "in_addr" | "ip_mreq" | "sockaddr_in" => true, + _ => false, + }); + + cfg.skip_fn(move |func| match func.ident() { + "reallocarray" | "getentropy" | "ppoll" | "getrandom" => true, + x if x.starts_with("timerfd_") => true, + _ => false, + }); + + cfg.skip_struct_field(|struct_, field| match (struct_.ident(), field.ident()) { + ("statvfs", "f_mntfromlabel") => true, // added field + ("kevent", "udata") => true, // changed type (ABI-compatible) + _ => false, + }); + } + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } @@ -1531,8 +1576,8 @@ fn test_dragonflybsd(target: &str) { let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); - headers! { - cfg: + headers!( + cfg, "aio.h", "ctype.h", "dirent.h", @@ -1620,7 +1665,7 @@ fn test_dragonflybsd(target: &str) { "vm/vm_map.h", "wchar.h", "iconv.h", - } + ); cfg.rename_struct_ty(move |ty| { match ty { @@ -1670,9 +1715,6 @@ fn test_dragonflybsd(target: &str) { }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // FIXME(dragonflybsd): These are tested as part of the linux_fcntl tests since // there are header conflicts when including them with all the other @@ -1757,7 +1799,8 @@ fn test_wasi(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "errno.h", @@ -1767,10 +1810,11 @@ fn test_wasi(target: &str) { "limits.h", "locale.h", "malloc.h", - [p2]: "netdb.h", - [p2]: "netinet/in.h", - [p2]: "netinet/tcp.h", + (p2, "netdb.h"), + (p2, "netinet/in.h"), + (p2, "netinet/tcp.h"), "poll.h", + "pthread.h", "sched.h", "stdbool.h", "stddef.h", @@ -1794,7 +1838,7 @@ fn test_wasi(target: &str) { "wasi/libc-nocwd.h", "wasi/libc.h", "wchar.h", - } + ); cfg.rename_struct_ty(move |ty| match ty { "FILE" | "fd_set" | "DIR" => Some(ty.to_string()), @@ -1855,151 +1899,150 @@ fn test_android(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: - "arpa/inet.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "errno.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "grp.h", - "ifaddrs.h", - "libgen.h", - "limits.h", - "link.h", - "linux/sysctl.h", - "locale.h", - "malloc.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "netpacket/packet.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/auxv.h", - "sys/epoll.h", - "sys/eventfd.h", - "sys/file.h", - "sys/fsuid.h", - "sys/inotify.h", - "sys/ioctl.h", - "sys/klog.h", - "sys/mman.h", - "sys/mount.h", - "sys/personality.h", - "sys/prctl.h", - "sys/ptrace.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/sendfile.h", - "sys/signalfd.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/swap.h", - "sys/syscall.h", - "sys/sysinfo.h", - "sys/system_properties.h", - "sys/time.h", - "sys/timerfd.h", - "sys/times.h", - "sys/types.h", - "sys/ucontext.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/xattr.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "unistd.h", - "utime.h", - "utmp.h", - "wchar.h", - "xlocale.h", - // time64_t is not defined for 64-bit targets If included it will - // generate the error 'Your time_t is already 64-bit' - [target_pointer_width == 32]: "time64.h", - [x86]: "sys/reg.h", - } + headers!( + cfg, + "arpa/inet.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "grp.h", + "ifaddrs.h", + "libgen.h", + "limits.h", + "link.h", + "linux/sysctl.h", + "locale.h", + "malloc.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/auxv.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/klog.h", + "sys/mman.h", + "sys/mount.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sendfile.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/sysinfo.h", + "sys/system_properties.h", + "sys/time.h", + "sys/timerfd.h", + "sys/times.h", + "sys/types.h", + "sys/ucontext.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/xattr.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "unistd.h", + "utime.h", + "utmp.h", + "wchar.h", + "xlocale.h", + // time64_t is not defined for 64-bit targets If included it will + // generate the error 'Your time_t is already 64-bit' + (target_pointer_width == 32, "time64.h"), + (x86, "sys/reg.h"), + ); // Include linux headers at the end: - headers! { cfg: - "asm/mman.h", - "linux/auxvec.h", - "linux/dccp.h", - "linux/elf.h", - "linux/errqueue.h", - "linux/falloc.h", - "linux/filter.h", - "linux/futex.h", - "linux/fs.h", - "linux/genetlink.h", - "linux/if_alg.h", - "linux/if_addr.h", - "linux/if_ether.h", - "linux/if_link.h", - "linux/rtnetlink.h", - "linux/if_tun.h", - "linux/kexec.h", - "linux/magic.h", - "linux/membarrier.h", - "linux/memfd.h", - "linux/mempolicy.h", - "linux/module.h", - "linux/mount.h", - "linux/net_tstamp.h", - "linux/netfilter/nfnetlink.h", - "linux/netfilter/nfnetlink_log.h", - "linux/netfilter/nfnetlink_queue.h", - "linux/netfilter/nf_tables.h", - "linux/netfilter_arp.h", - "linux/netfilter_bridge.h", - "linux/netfilter_ipv4.h", - "linux/netfilter_ipv6.h", - "linux/netfilter_ipv6/ip6_tables.h", - "linux/netlink.h", - "linux/quota.h", - "linux/reboot.h", - "linux/seccomp.h", - "linux/sched.h", - "linux/sockios.h", - "linux/uinput.h", - "linux/vm_sockets.h", - "linux/wait.h", - - } + headers!( + cfg, + "asm/mman.h", + "linux/auxvec.h", + "linux/dccp.h", + "linux/elf.h", + "linux/errqueue.h", + "linux/falloc.h", + "linux/filter.h", + "linux/futex.h", + "linux/fs.h", + "linux/genetlink.h", + "linux/if_alg.h", + "linux/if_addr.h", + "linux/if_ether.h", + "linux/if_link.h", + "linux/rtnetlink.h", + "linux/if_tun.h", + "linux/kexec.h", + "linux/magic.h", + "linux/membarrier.h", + "linux/memfd.h", + "linux/mempolicy.h", + "linux/module.h", + "linux/mount.h", + "linux/net_tstamp.h", + "linux/netfilter/nfnetlink.h", + "linux/netfilter/nfnetlink_log.h", + "linux/netfilter/nfnetlink_queue.h", + "linux/netfilter/nf_tables.h", + "linux/netfilter_arp.h", + "linux/netfilter_bridge.h", + "linux/netfilter_ipv4.h", + "linux/netfilter_ipv6.h", + "linux/netfilter_ipv6/ip6_tables.h", + "linux/netlink.h", + "linux/quota.h", + "linux/reboot.h", + "linux/seccomp.h", + "linux/sched.h", + "linux/sockios.h", + "linux/uinput.h", + "linux/vm_sockets.h", + "linux/wait.h", + ); // Include Android-specific headers: - headers! { cfg: - "android/set_abort_message.h" - } + headers!(cfg, "android/set_abort_message.h",); cfg.rename_type(move |ty| match ty { "Ioctl" => Some("int".to_string()), @@ -2049,8 +2092,6 @@ fn test_android(target: &str) { "posix_spawn_file_actions_t" => true, "posix_spawnattr_t" => true, - // FIXME(android): "'__uint128' undeclared" in C - "__uint128" => true, // Added in API level 24 "if_nameindex" => true, @@ -2058,12 +2099,7 @@ fn test_android(target: &str) { } }); - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. @@ -2235,6 +2271,9 @@ fn test_android(target: &str) { // FIXME(android): Requires >= 6.12 kernel headers. "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, + // FIXME(android): Requires >= 6.9 kernel headers. + "AT_HWCAP3" | "AT_HWCAP4" => true, + _ => false, } }); @@ -2358,7 +2397,21 @@ fn test_freebsd(target: &str) { assert!(target.contains("freebsd")); let mut cfg = ctest_cfg(); - let freebsd_ver = which_freebsd(); + let freebsd_ver = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { + let vers = version.parse().unwrap(); + println!("cargo:warning=setting FreeBSD version to {vers}"); + Some(vers) + } else { + match &try_command_output("freebsd-version", &[]) { + Some(s) if s.starts_with("10") => Some(10), + Some(s) if s.starts_with("11") => Some(11), + Some(s) if s.starts_with("12") => Some(12), + Some(s) if s.starts_with("13") => Some(13), + Some(s) if s.starts_with("14") => Some(14), + Some(s) if s.starts_with("15") => Some(15), + Some(_) | None => None, + } + }; match freebsd_ver { Some(12) => cfg.cfg("freebsd12", None), @@ -2379,175 +2432,176 @@ fn test_freebsd(target: &str) { let freebsd14 = matches!(freebsd_ver, Some(n) if n >= 14); let freebsd15 = matches!(freebsd_ver, Some(n) if n >= 15); - headers! { cfg: - "aio.h", - "arpa/inet.h", - "bsm/audit.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "errno.h", - "execinfo.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "glob.h", - "grp.h", - "iconv.h", - "ifaddrs.h", - "kenv.h", - "langinfo.h", - "libgen.h", - "libutil.h", - "limits.h", - "link.h", - "locale.h", - "machine/elf.h", - "machine/reg.h", - "malloc_np.h", - "memstat.h", - "mqueue.h", - "net/bpf.h", - "net/if.h", - "net/if_arp.h", - "net/if_dl.h", - "net/if_mib.h", - "net/route.h", - "netdb.h", - "netinet/ip.h", - "netinet/in.h", - "netinet/sctp.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pthread_np.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/capsicum.h", - "sys/auxv.h", - "sys/cpuset.h", - "sys/domainset.h", - "sys/eui64.h", - "sys/event.h", - [freebsd13]:"sys/eventfd.h", - "sys/extattr.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/jail.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/procctl.h", - "sys/procdesc.h", - "sys/ptrace.h", - "sys/queue.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/rtprio.h", - "sys/sem.h", - "sys/shm.h", - "sys/socket.h", - "sys/socketvar.h", - [freebsd15]:"sys/ktls.h", - "netinet/in_pcb.h", // must be after sys/socketvar.h, sys/ktls.h - "sys/stat.h", - "sys/statvfs.h", - "sys/sysctl.h", - "sys/thr.h", - "sys/time.h", - [freebsd14 || freebsd15]:"sys/timerfd.h", - [freebsd13 || freebsd14 || freebsd15]:"dev/evdev/input.h", - "sys/times.h", - "sys/timex.h", - "sys/types.h", - "sys/proc.h", - "kvm.h", // must be after "sys/types.h" - "sys/ucontext.h", - "sys/uio.h", - "sys/ktrace.h", - "sys/umtx.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/uuid.h", - "sys/vmmeter.h", - "sys/wait.h", - "libprocstat.h", - "devstat.h", - "syslog.h", - "termios.h", - "time.h", - "ufs/ufs/quota.h", - "unistd.h", - "utime.h", - "utmpx.h", - "wchar.h", - } - - cfg.rename_type(|ty| match ty { - // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 - "sighandler_t" => Some("sig_t".to_string()), - _ => None, - }); - - cfg.rename_struct_ty(|ty| { - match ty { - // Just pass all these through, no need for a "struct" prefix - "FILE" - | "fd_set" - | "Dl_info" - | "DIR" - | "Elf32_Phdr" - | "Elf64_Phdr" - | "Elf32_Auxinfo" - | "Elf64_Auxinfo" - | "devstat_select_mode" - | "devstat_support_flags" - | "devstat_type_flags" - | "devstat_match_flags" - | "devstat_priority" => Some(ty.to_string()), - - // sigval is a struct in Rust, but a union in C: - "sigval" => Some("union sigval".to_string()), - - t if t.ends_with("_t") => Some(t.to_string()), - - _ => None, - } - }); - - cfg.rename_struct_field(|struct_, field_| { - let struct_ = struct_.ident(); - let replacement = match field_.ident() { - // Our stat *_nsec fields normally don't actually exist but are part - // of a timeval struct - s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", ".tv_nsec") - } - // Field is named `type` in C but that is a Rust keyword, - // so these fields are translated to `type_` in the bindings. - "type_" if struct_ == "rtprio" => "type".to_string(), - "type_" if struct_ == "sockstat" => "type".to_string(), - "type_" if struct_ == "devstat_match_table" => "type".to_string(), - "type_" if struct_ == "input_event" => "type".to_string(), - // Field is named `gennum` in Rust because `gen` is a keyword - "gennum" if struct_ == "xktls_session_onedir" => "gen".to_string(), - _ => return None, - }; + headers!( + cfg, + "aio.h", + "arpa/inet.h", + "bsm/audit.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "errno.h", + "execinfo.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "glob.h", + "grp.h", + "iconv.h", + "ifaddrs.h", + "kenv.h", + "langinfo.h", + "libgen.h", + "libutil.h", + "limits.h", + "link.h", + "locale.h", + "machine/elf.h", + "machine/reg.h", + "malloc_np.h", + "memstat.h", + "mqueue.h", + "net/bpf.h", + "net/if.h", + "net/if_arp.h", + "net/if_dl.h", + "net/if_mib.h", + "net/route.h", + "netdb.h", + "netinet/ip.h", + "netinet/in.h", + "netinet/sctp.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pthread_np.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/capsicum.h", + "sys/auxv.h", + "sys/cpuset.h", + "sys/domainset.h", + "sys/eui64.h", + "sys/event.h", + (freebsd13, "sys/eventfd.h"), + "sys/extattr.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/jail.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/procctl.h", + "sys/procdesc.h", + "sys/ptrace.h", + "sys/queue.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/rtprio.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/socketvar.h", + (freebsd15, "sys/ktls.h"), + "netinet/in_pcb.h", // must be after sys/socketvar.h, sys/ktls.h + "sys/stat.h", + "sys/statvfs.h", + "sys/sysctl.h", + "sys/thr.h", + "sys/time.h", + (freebsd14 || freebsd15, "sys/timerfd.h"), + (freebsd13 || freebsd14 || freebsd15, "dev/evdev/input.h"), + "sys/times.h", + "sys/timex.h", + "sys/types.h", + "sys/proc.h", + "kvm.h", // must be after "sys/types.h" + "sys/ucontext.h", + "sys/uio.h", + "sys/ktrace.h", + "sys/umtx.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/uuid.h", + "sys/vmmeter.h", + "sys/wait.h", + "libprocstat.h", + "devstat.h", + "syslog.h", + "termios.h", + "time.h", + "ufs/ufs/quota.h", + "unistd.h", + "utime.h", + "utmpx.h", + "wchar.h", + ); + + cfg.rename_type(|ty| match ty { + // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 + "sighandler_t" => Some("sig_t".to_string()), + _ => None, + }); + + cfg.rename_struct_ty(|ty| { + match ty { + // Just pass all these through, no need for a "struct" prefix + "FILE" + | "fd_set" + | "Dl_info" + | "DIR" + | "Elf32_Phdr" + | "Elf64_Phdr" + | "Elf32_Auxinfo" + | "Elf64_Auxinfo" + | "devstat_select_mode" + | "devstat_support_flags" + | "devstat_type_flags" + | "devstat_match_flags" + | "devstat_priority" => Some(ty.to_string()), + + // sigval is a struct in Rust, but a union in C: + "sigval" => Some("union sigval".to_string()), + + t if t.ends_with("_t") => Some(t.to_string()), + + _ => None, + } + }); + + cfg.rename_struct_field(|struct_, field_| { + let struct_ = struct_.ident(); + let replacement = match field_.ident() { + // Our stat *_nsec fields normally don't actually exist but are part + // of a timeval struct + s if s.ends_with("_nsec") && struct_.starts_with("stat") => { + s.replace("e_nsec", ".tv_nsec") + } + // Field is named `type` in C but that is a Rust keyword, + // so these fields are translated to `type_` in the bindings. + "type_" if struct_ == "rtprio" => "type".to_string(), + "type_" if struct_ == "sockstat" => "type".to_string(), + "type_" if struct_ == "devstat_match_table" => "type".to_string(), + "type_" if struct_ == "input_event" => "type".to_string(), + // Field is named `gennum` in Rust because `gen` is a keyword + "gennum" if struct_ == "xktls_session_onedir" => "gen".to_string(), + _ => return None, + }; Some(replacement) }); @@ -2831,6 +2885,9 @@ fn test_freebsd(target: &str) { // FIXME(deprecated): deprecated in 0.2, removed in main "TIOCMGDTRWAIT" | "TIOCMSDTRWAIT" => true, + // Added in FreeBSD 15 + "AT_HWCAP3" | "AT_HWCAP4" if Some(15) > freebsd_ver => true, + _ => false, } }); @@ -2847,13 +2904,8 @@ fn test_freebsd(target: &str) { } }); - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |struct_| { - let ty = struct_.ident(); - if ty.starts_with("__c_anonymous_") { - return true; - } - match ty { + match struct_.ident() { // `procstat` is a private struct "procstat" => true, @@ -3049,81 +3101,82 @@ fn test_emscripten(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); // FIXME(emscripten): ?? - headers! { cfg: - "ctype.h", - "dirent.h", - "dlfcn.h", - "errno.h", - "fcntl.h", - "fnmatch.h", - "glob.h", - "grp.h", - "ifaddrs.h", - "langinfo.h", - "limits.h", - "locale.h", - "malloc.h", - "mntent.h", - "mqueue.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "netpacket/packet.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "resolv.h", - "sched.h", - "sched.h", - "semaphore.h", - "shadow.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/resource.h", - "sys/sem.h", - "sys/shm.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/syscall.h", - "sys/sysinfo.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/wait.h", - "sys/xattr.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "utmp.h", - "utmpx.h", - "wchar.h", - } + headers!( + cfg, + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "resolv.h", + "sched.h", + "sched.h", + "semaphore.h", + "shadow.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/resource.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/syscall.h", + "sys/sysinfo.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "sys/xattr.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + ); cfg.rename_struct_ty(move |ty| { match ty { @@ -3166,10 +3219,6 @@ fn test_emscripten(target: &str) { }); cfg.skip_union(|union_| { - if union_.ident().starts_with("__c_anonymous_") { - return true; - } - match union_.ident() { // No epoll support // https://github.com/emscripten-core/emscripten/issues/5033 @@ -3188,9 +3237,6 @@ fn test_emscripten(target: &str) { }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // This is actually a union, not a struct "sigval" => true, @@ -3306,17 +3352,19 @@ fn test_neutrino(target: &str) { .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); cfg.include(qnx_target_val + "/usr/include/io-sock"); - headers! { cfg: + headers!( + cfg, "io-sock.h", "sys/types.h", "sys/socket.h", "sys/sysctl.h", "net/if.h", - "net/if_arp.h" - } + "net/if_arp.h", + ); } - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -3399,12 +3447,11 @@ fn test_neutrino(target: &str) { "net/bpf.h", "net/if_dl.h", "sys/syspage.h", - // TODO: The following header file doesn't appear as part of the default headers // found in a standard installation of Neutrino 7.1 SDP. The structures/ // functions dependent on it are currently commented out. //"sys/asyncmsg.h", - } + ); // Create and include a header file containing // items which are not included in any official @@ -3463,17 +3510,11 @@ fn test_neutrino(target: &str) { // Does not exist in Neutrino "locale_t" => true, - // FIXME: "'__uint128' undeclared" in C - "__uint128" => true, - _ => false, } }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { "Elf64_Phdr" | "Elf32_Phdr" => true, @@ -3561,75 +3602,110 @@ fn test_neutrino(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } +fn which_vxworks() -> Option<(u32, u32)> { + let version = env::var("WIND_RELEASE_ID").ok()?; // When in VxWorks setup, WIND_RELEASE_ID is + // always set as the version of the release. + + let mut pieces = version.trim().split(['.']); + + let major: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + let minor: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + + Some((major, minor)) +} + fn test_vxworks(target: &str) { assert!(target.contains("vxworks")); let mut cfg = ctest_cfg(); - headers! { cfg: - "vxWorks.h", - "yvals.h", - "nfs/nfsCommon.h", - "rtpLibCommon.h", - "randomNumGen.h", - "taskLib.h", - "sysLib.h", - "ioLib.h", - "inetLib.h", - "socket.h", - "errnoLib.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "fcntl.h", - "grp.h", - "sys/poll.h", - "ifaddrs.h", - "langinfo.h", - "limits.h", - "link.h", - "locale.h", - "sys/stat.h", - "netdb.h", - "pthread.h", - "pwd.h", - "sched.h", - "semaphore.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/file.h", - "sys/ioctl.h", - "sys/socket.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "netinet/tcp.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "wchar.h", - "errno.h", - "sys/mman.h", - "pathLib.h", - "mqueue.h", + + let vxworks_ver = which_vxworks(); + + if vxworks_ver < Some((25, 9)) { + cfg.cfg("vxworks_lt_25_09", None); } + + headers!( + cfg, + "vxWorks.h", + "semLibCommon.h", + "yvals.h", + "nfs/nfsCommon.h", + "rtpLibCommon.h", + "randomNumGen.h", + "taskLib.h", + "sysLib.h", + "ioLib.h", + "inetLib.h", + "socket.h", + "errnoLib.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "fcntl.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "link.h", + "locale.h", + "netdb.h", + "pthread.h", + "pwd.h", + "sched.h", + "semaphore.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/select.h", + "sys/stat.h", + "sys/poll.h", + "sys/file.h", + "sys/ioctl.h", + "sys/socket.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "sys/ttycom.h", + "sys/utsname.h", + "sys/resource.h", + "sys/mman.h", + "netinet/tcp.h", + "netinet/udp.h", + "netinet/in.h", + "netinet6/in6.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "wchar.h", + "errno.h", + "pathLib.h", + "mqueue.h", + "fnmatch.h", + "sioLibCommon.h", + "net/if.h", + ); // FIXME(vxworks) cfg.skip_const(move |constant| match constant.ident() { // sighandler_t weirdness "SIG_DFL" | "SIG_ERR" | "SIG_IGN" - // This is not defined in vxWorks - | "RTLD_DEFAULT" => true, + // These are not defined in VxWorks + | "RTLD_DEFAULT" | "PRIO_PROCESS" + // Sticky bits not supported + | "S_ISVTX" + // The following are obsolete for VxWorks + | "SIGIO" | "SIGWINCH" | "SIGLOST" => true, _ => false, }); // FIXME(vxworks) @@ -3640,7 +3716,12 @@ fn test_vxworks(target: &str) { cfg.skip_struct_field_type( move |struct_, field| match (struct_.ident(), field.ident()) { - ("siginfo_t", "si_value") | ("stat", "st_size") | ("sigaction", "sa_u") => true, + ("siginfo_t", "si_value") + | ("stat", "st_size") + // sighandler_t type is super weird + | ("sigaction", "sa_sigaction") + // sa_u_t type is not defined in vxworks + | ("sigaction", "sa_u") => true, _ => false, }, ); @@ -3659,11 +3740,16 @@ fn test_vxworks(target: &str) { "sigqueue" | "_sigqueue" // sighandler_t | "signal" + // This is used a realpath and not _realpath + | "_realpath" // not used in static linking by default | "dlerror" => true, _ => false, }); + // Not defined in vxworks. Just a crate specific union type. + cfg.skip_union(move |u| u.ident() == "sa_u_t"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } @@ -3740,6 +3826,7 @@ fn test_linux(target: &str) { let loongarch64 = target.contains("loongarch64"); let wasm32 = target.contains("wasm32"); let uclibc = target.contains("uclibc"); + let mips = target.contains("mips"); let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); let old_musl = musl && !musl_v1_2_3; @@ -3756,128 +3843,127 @@ fn test_linux(target: &str) { config_gnu_bits(target, &mut cfg); - headers! { cfg: - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "glob.h", - [gnu]: "gnu/libc-version.h", - "grp.h", - "iconv.h", - "ifaddrs.h", - "langinfo.h", - "libgen.h", - "limits.h", - "link.h", - "linux/sysctl.h", - "locale.h", - "malloc.h", - "mntent.h", - "mqueue.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "shadow.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/epoll.h", - "sys/eventfd.h", - "sys/file.h", - "sys/fsuid.h", - "sys/klog.h", - "sys/inotify.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/personality.h", - "sys/prctl.h", - "sys/ptrace.h", - "sys/quota.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/sem.h", - "sys/sendfile.h", - "sys/shm.h", - "sys/signalfd.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/swap.h", - "sys/syscall.h", - "sys/time.h", - "sys/timerfd.h", - "sys/times.h", - "sys/timex.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "utmp.h", - "utmpx.h", - "wchar.h", - "errno.h", - // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit - // ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162 - // Also unavailable on gnueabihf with glibc 2.30. - // https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1 - [(x86_64 || x86_32 || arm) && !gnueabihf]: "sys/io.h", - // `sys/reg.h` is only available on x86 and x86_64 - [x86_64 || x86_32]: "sys/reg.h", - // sysctl system call is deprecated and not available on musl - // It is also unsupported in x32, deprecated since glibc 2.30: - [!(x32 || musl || gnu)]: "sys/sysctl.h", - // is not supported by musl: - // https://www.openwall.com/lists/musl/2015/04/09/3 - // is not present on uclibc. - [!(musl || uclibc)]: "execinfo.h", - } + headers!( + cfg, + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "glob.h", + (gnu, "gnu/libc-version.h"), + "grp.h", + "iconv.h", + "ifaddrs.h", + "langinfo.h", + "libgen.h", + "limits.h", + "link.h", + "linux/sysctl.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "shadow.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/klog.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/quota.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sem.h", + "sys/sendfile.h", + "sys/shm.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/time.h", + "sys/timerfd.h", + "sys/times.h", + "sys/timex.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + "errno.h", + // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit + // ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162 + // Also unavailable on gnueabihf with glibc 2.30. + // https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1 + ((x86_64 || x86_32 || arm) && !gnueabihf, "sys/io.h"), + // `sys/reg.h` is only available on x86 and x86_64 + (x86_64 || x86_32, "sys/reg.h"), + // sysctl system call is deprecated and not available on musl + // It is also unsupported in x32, deprecated since glibc 2.30: + (!(x32 || musl || gnu), "sys/sysctl.h"), + // is not supported by musl: + // https://www.openwall.com/lists/musl/2015/04/09/3 + // is not present on uclibc. + (!(musl || uclibc), "execinfo.h"), + ); // Include linux headers at the end: - headers! { - cfg: - [loongarch64 || riscv64]: "asm/hwcap.h", - "asm/mman.h", - } + headers!(cfg, (loongarch64 || riscv64, "asm/hwcap.h"), "asm/mman.h",); if !wasm32 { - headers! { cfg: - [gnu]: "linux/aio_abi.h", + headers!( + cfg, + (gnu, "linux/aio_abi.h"), "linux/can.h", + "linux/can/bcm.h", "linux/can/raw.h", "linux/can/j1939.h", "linux/cn_proc.h", @@ -3940,19 +4026,19 @@ fn test_linux(target: &str) { "linux/wireless.h", "sys/fanotify.h", // is not present on uclibc - [!uclibc]: "sys/auxv.h", - [gnu || musl]: "linux/close_range.h", - } + (!uclibc, "sys/auxv.h"), + (gnu || musl, "linux/close_range.h"), + ); } // note: aio.h must be included before sys/mount.h - headers! { - cfg: + headers!( + cfg, "sys/xattr.h", "sys/sysinfo.h", // AIO is not supported by uclibc: - [!uclibc]: "aio.h", - } + (!uclibc, "aio.h"), + ); // Just pass all these through, no need for a "struct" prefix let typedef_structs = [ @@ -3986,7 +4072,7 @@ fn test_linux(target: &str) { } }); - cfg.rename_struct_field(|struct_, field| { + cfg.rename_struct_field(move |struct_, field| { let struct_ = struct_.ident(); match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part @@ -4009,6 +4095,9 @@ fn test_linux(target: &str) { Some("type".to_string()) } + // FIXME(1.0): field has a different name on loongarch + "uc_flags" if loongarch64 && struct_ == "ucontext_t" => Some("__uc_flags".to_string()), + _ => None, } }); @@ -4043,9 +4132,6 @@ fn test_linux(target: &str) { // specific type. "Ioctl" => true, - // FIXME: "'__uint128' undeclared" in C - "__uint128" => true, - t => { if musl { // LFS64 types have been removed in musl 1.2.4+ @@ -4057,10 +4143,6 @@ fn test_linux(target: &str) { } }); - // Skip structs and enums that are unnamed in C. - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| struct_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| { let ty = struct_.ident(); @@ -4079,11 +4161,6 @@ fn test_linux(target: &str) { return true; } - // FIXME(#1558): passing by value corrupts the value for reasons not understood. - if (gnu && sparc64) && (ty == "ip_mreqn" || ty == "hwtstamp_config") { - return true; - } - // FIXME(rust-lang/rust#43894): pass by value for structs that are not an even 32/64 bits // on big-endian systems corrupts the value for unknown reasons. if (sparc64 || ppc || ppc64 || s390x) @@ -4123,28 +4200,14 @@ fn test_linux(target: &str) { // structs. "termios2" => true, - // FIXME(linux): remove once we set minimum supported glibc version. - // ucontext_t added a new field as of glibc 2.28; our struct definition is - // conservative and omits the field, but that means the size doesn't match for newer - // glibcs (see https://github.com/rust-lang/libc/issues/1410) - "ucontext_t" if gnu => true, - - // FIXME(linux): Somehow we cannot include headers correctly in glibc 2.30. - // So let's ignore for now and re-visit later. - // Probably related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91085 - "statx" => true, - "statx_timestamp" => true, - // On Linux, the type of `ut_exit` field of struct `utmpx` // can be an anonymous struct, so an extra struct, // which is absent in musl, has to be defined. "__exit_status" if musl => true, - // clone_args might differ b/w libc versions - "clone_args" => true, - - // Might differ between kernel versions - "open_how" => true, + // FIXME(ppc): tests fail due to a field type mismatch (`long long unsigned` vs + // `long unsigned`). + "clone_args" if ppc64 => true, // Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15) // Might differ between kernel versions @@ -4153,37 +4216,6 @@ fn test_linux(target: &str) { "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, - // FIXME(linux): requires >= 6.1 kernel headers - "canxl_frame" => true, - - // FIXME(linux): The size of `iv` has been changed since Linux v6.0 - // https://github.com/torvalds/linux/commit/94dfc73e7cf4a31da66b8843f0b9283ddd6b8381 - "af_alg_iv" => true, - - // FIXME(linux): Requires >= 5.1 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "tls12_crypto_info_aes_gcm_256" - if (aarch64 || arm || i686 || s390x || x86_64) && musl => - { - true - } - - // FIXME(linux): Requires >= 5.11 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "tls12_crypto_info_chacha20_poly1305" - if (aarch64 || arm || i686 || s390x || x86_64) && musl => - { - true - } - - // FIXME(linux): Requires >= 5.3 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_options" if musl => true, - - // FIXME(linux): Requires >= 5.4 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_ring_offset" | "xdp_mmap_offsets" if musl => true, - // FIXME(linux): Requires >= 6.8 kernel headers. // A field was added in 6.8. // https://github.com/torvalds/linux/commit/341ac980eab90ac1f6c22ee9f9da83ed9604d899 @@ -4191,15 +4223,8 @@ fn test_linux(target: &str) { // https://github.com/torvalds/linux/commit/32654bbd6313b4cfc82297e6634fa9725c3c900f "xdp_umem_reg" => true, - // FIXME(linux): Requires >= 5.9 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_statistics" if musl => true, - // FIXME(linux): Requires >= 6.8 kernel headers. - "xsk_tx_metadata" - | "__c_anonymous_xsk_tx_metadata_union" - | "xsk_tx_metadata_request" - | "xsk_tx_metadata_completion" => true, + "xsk_tx_metadata" | "xsk_tx_metadata_request" | "xsk_tx_metadata_completion" => true, // A new field was added in kernel 5.4, this is the old version for backwards compatibility. // https://github.com/torvalds/linux/commit/77cd0d7b3f257fd0e3096b4fdcff1a7d38e99e10 @@ -4228,11 +4253,14 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.12 kernel headers. "mnt_ns_info" => true, - // FIXME(linux): Requires >= 6.4 kernel headers. - "ptrace_sud_config" => true, + // FIXME(musl): Struct has changed for new musl versions + "tcp_info" if musl => true, + + // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. + "statx" | "statx_timestamp" if musl => true, - // Struct has changed for new musl versions - "tcp_info" if old_musl => true, + // FIXME(musl): New fields in newer versions + "utmpx" if !old_musl => true, _ => false, } @@ -4278,116 +4306,91 @@ fn test_linux(target: &str) { } } if musl { - // FIXME(linux): Requires >= 5.0 kernel headers - if name == "SECCOMP_GET_NOTIF_SIZES" - || name == "SECCOMP_FILTER_FLAG_NEW_LISTENER" - || name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH" - || name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5 - || name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9 - || name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9 - || name == "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" // requires >= 5.19 - { - return true; - } - // FIXME(linux): Requires >= 4.20 kernel headers - if name == "PTP_SYS_OFFSET_EXTENDED" { - return true; - } - // FIXME(linux): Requires >= 5.4 kernel headers - if name == "PTP_CLOCK_GETCAPS2" - || name == "PTP_ENABLE_PPS2" - || name == "PTP_EXTTS_REQUEST2" - || name == "PTP_PEROUT_REQUEST2" - || name == "PTP_PIN_GETFUNC2" - || name == "PTP_PIN_SETFUNC2" - || name == "PTP_SYS_OFFSET2" - || name == "PTP_SYS_OFFSET_PRECISE2" - || name == "PTP_SYS_OFFSET_EXTENDED2" - { - return true; - } - // FIXME(linux): Requires >= 5.4.1 kernel headers - if name.starts_with("J1939") - || name.starts_with("RTEXT_FILTER_") - || name.starts_with("SO_J1939") - || name.starts_with("SCM_J1939") - { - return true; - } - // FIXME(linux): Requires >= 5.10 kernel headers - if name.starts_with("MEMBARRIER_CMD_REGISTER") - || name.starts_with("MEMBARRIER_CMD_PRIVATE") - { - return true; - } // LFS64 types have been removed in musl 1.2.4+ if name.starts_with("RLIM64") { return true; } - // CI fails because musl targets use Linux v4 kernel - if name.starts_with("NI_IDN") { - return true; - } - // FIXME: Requires >= 6.3 kernel headers - if loongarch64 && (name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC") { - return true; - } - // FIXME: Requires >= 6.3 (6.6) kernel headers - if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" { - return true; - } - // Requires musl >= 1.2 - if old_musl && (name == "SO_PREFER_BUSY_POLL" - || name == "SO_BUSY_POLL_BUDGET") - { - return true; - } - // FIXME(musl): Not in musl yet - if name == "SO_NETNS_COOKIE" - || name == "SO_BUF_LOCK" - || name == "SO_RESERVE_MEM" - || name == "SO_TXREHASH" - || name == "SO_RCVMARK" - || name == "SO_PASSPIDFD" - || name == "SO_PEERPIDFD" - || name == "SO_DEVMEM_LINEAR" - || name == "SO_DEVMEM_DMABUF" - || name == "SO_DEVMEM_DONTNEED" - { - return true; - } - // FIXME(musl): Not in musl yet - if name == "SCM_DEVMEM_LINEAR" - || name == "SCM_DEVMEM_DMABUF" - { - return true; - } - // Values changed in newer musl versions on these arches - if old_musl && (riscv64 || x86_64) && name == "O_LARGEFILE" { - return true; - } - // Values changed in newer musl versions - if old_musl && name == "RLIM_NLIMITS" { + // CI fails because musl targets use Linux v4 kernel + if name.starts_with("NI_IDN") { return true; } - // FIXME: Does not exist on non-x86 architectures, slated for removal - // in libc in 1.0 - if ppc64 && name == "MAP_32BIT" { - return true; + + match name { + // FIXME: Does not exist on non-x86 architectures, slated for removal + // in libc in 1.0 + "MAP_32BIT" if ppc64 => return true, + + // FIXME(musl): None of these are actually defined in musl, they should be removed. + "SO_NETNS_COOKIE" + | "SO_BUF_LOCK" + | "SO_RESERVE_MEM" + | "SO_TXREHASH" + | "SO_RCVMARK" + | "SO_PASSPIDFD" + | "SO_PEERPIDFD" + | "SO_DEVMEM_LINEAR" + | "SO_DEVMEM_DMABUF" + | "SO_DEVMEM_DONTNEED" + | "SCM_DEVMEM_LINEAR" + | "SCM_DEVMEM_DMABUF" + | "FAN_EVENT_INFO_TYPE_ERROR" + | "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" + | "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" + | "FAN_FS_ERROR" + | "FAN_INFO" + | "FAN_MARK_EVICTABLE" + | "FAN_MARK_IGNORE" + | "FAN_MARK_IGNORE_SURV" + | "FAN_RENAME" + | "FAN_REPORT_DFID_NAME_TARGET" + | "FAN_REPORT_TARGET_FID" + | "FAN_RESPONSE_INFO_AUDIT_RULE" + | "FAN_RESPONSE_INFO_NONE" + | "PR_GET_MDWE" + | "PR_MDWE_NO_INHERIT" + | "PR_MDWE_REFUSE_EXEC_GAIN" + | "PR_SET_MDWE" + | "IPPROTO_ETHERNET" + | "IPPROTO_MPTCP" + | "SI_DETHREAD" + | "PR_SET_VMA" + | "PR_SET_VMA_ANON_NAME" + | "PR_SCHED_CORE" + | "PR_SCHED_CORE_CREATE" + | "PR_SCHED_CORE_GET" + | "PR_SCHED_CORE_MAX" + | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" + | "PR_SCHED_CORE_SCOPE_THREAD" + | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" + | "PR_SCHED_CORE_SHARE_FROM" + | "PR_SCHED_CORE_SHARE_TO" => return true, + + /* Added in versions more recent than what we test */ + // Since 1.2.3 + "SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" => return true, + + // FIXME(musl): value was updated in new musl + "RLIM_NLIMITS" => return true, + + // FIXME(musl): Values changed in newer musl versions on these arches + "O_LARGEFILE" if riscv64 || x86_64 => return true, + + _ => (), } } + match name { // These constants are not available if gnu headers have been included // and can therefore not be tested here // // The IPV6 constants are tested in the `linux_ipv6.rs` tests: - | "IPV6_FLOWINFO" + "IPV6_FLOWINFO" | "IPV6_FLOWLABEL_MGR" | "IPV6_FLOWINFO_SEND" | "IPV6_FLOWINFO_FLOWLABEL" - | "IPV6_FLOWINFO_PRIORITY" + | "IPV6_FLOWINFO_PRIORITY" => true, // The F_ fnctl constants are tested in the `linux_fnctl.rs` tests: - | "F_CANCELLK" + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" @@ -4410,12 +4413,7 @@ fn test_linux(target: &str) { // FIXME(linux): conflicts with glibc headers and is tested in // `linux_termios.rs` below: - | "BOTHER" - | "IBSHIFT" - | "TCGETS2" - | "TCSETS2" - | "TCSETSW2" - | "TCSETSF2" => true, + "BOTHER" | "IBSHIFT" | "TCGETS2" | "TCSETS2" | "TCSETSW2" | "TCSETSF2" => true, // FIXME(musl): on musl the pthread types are defined a little differently // - these constants are used by the glibc implementation. @@ -4428,46 +4426,24 @@ fn test_linux(target: &str) { // deprecated: not available from Linux kernel 5.6: "VMADDR_CID_RESERVED" => true, - // IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP: - | "IPPROTO_MAX" - | "IPPROTO_ETHERNET" - | "IPPROTO_MPTCP" => true, + // FIXME(value): IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP: + "IPPROTO_MAX" => true, // FIXME(linux): Not yet implemented on sparc64 "SYS_clone3" if sparc64 => true, - // FIXME(linux): Not defined on ARM, gnueabihf, musl, PowerPC, riscv64, s390x, and sparc64. - "SYS_memfd_secret" if arm | gnueabihf | musl | ppc | riscv64 | s390x | sparc64 => true, - - // FIXME(linux): Added in Linux 5.16 - // https://github.com/torvalds/linux/commit/039c0ec9bb77446d7ada7f55f90af9299b28ca49 - "SYS_futex_waitv" => true, - - // FIXME(linux): Added in Linux 5.17 - // https://github.com/torvalds/linux/commit/c6018b4b254971863bd0ad36bb5e7d0fa0f0ddb0 - "SYS_set_mempolicy_home_node" => true, - - // FIXME(linux): Added in Linux 5.18 - // https://github.com/torvalds/linux/commit/8b5413647262dda8d8d0e07e14ea1de9ac7cf0b2 - "NFQA_PRIORITY" => true, - - // FIXME(linux): requires more recent kernel headers on CI - | "UINPUT_VERSION" - | "SW_MAX" - | "SW_CNT" - if ppc64 || riscv64 => true, - - // FIXME(linux): requires more recent kernel headers on CI - "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" if sparc64 => true, - - // FIXME(linux): Not currently available in headers on ARM and musl. - "NETLINK_GET_STRICT_CHK" if arm => 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 => + { + true + } // Skip as this signal codes and trap reasons need newer headers - "SI_DETHREAD" | "TRAP_PERF" => true, + "TRAP_PERF" => true, // kernel constants not available in uclibc 1.0.34 - | "EXTPROC" + "EXTPROC" | "IPPROTO_BEETPH" | "IPPROTO_MPLS" | "IPV6_HDRINCL" @@ -4480,7 +4456,10 @@ fn test_linux(target: &str) { | "SHM_EXEC" | "UDP_GRO" | "UDP_SEGMENT" - if uclibc => true, + if uclibc => + { + true + } // headers conflicts with linux/pidfd.h "PIDFD_NONBLOCK" => true, @@ -4512,69 +4491,19 @@ fn test_linux(target: &str) { // is a private value for kernel usage normally "FUSE_SUPER_MAGIC" => true, - // linux 5.17 min - "PR_SET_VMA" | "PR_SET_VMA_ANON_NAME" => true, - - // present in recent kernels only - "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, - - // present in recent kernels only >= 5.13 - "PR_PAC_SET_ENABLED_KEYS" | "PR_PAC_GET_ENABLED_KEYS" => true, - // present in recent kernels only >= 5.19 - "PR_SME_SET_VL" | "PR_SME_GET_VL" | "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" => true, - - // Added in Linux 5.14 - "FUTEX_LOCK_PI2" => true, - - // Added in linux 6.1 - "STATX_DIOALIGN" - | "CAN_RAW_XL_FRAMES" - | "CANXL_HDR_SIZE" - | "CANXL_MAX_DLC" - | "CANXL_MAX_DLC_MASK" - | "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" - => true, - - // FIXME(linux): Parts of netfilter/nfnetlink*.h require more recent kernel headers: - | "RTNLGRP_MCTP_IFADDR" // linux v5.17+ - | "RTNLGRP_TUNNEL" // linux v5.18+ - | "RTNLGRP_STATS" // linux v5.18+ - => true, + // Not present in glibc + "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" if gnu => true, // FIXME(linux): The below is no longer const in glibc 2.34: // https://github.com/bminor/glibc/commit/5d98a7dae955bafa6740c26eaba9c86060ae0344 - | "PTHREAD_STACK_MIN" - | "SIGSTKSZ" - | "MINSIGSTKSZ" - if gnu => true, - - // FIXME(linux): Linux >= 5.16: - // https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96 - "NF_NETDEV_EGRESS" if sparc64 => true, + "PTHREAD_STACK_MIN" | "SIGSTKSZ" | "MINSIGSTKSZ" if gnu => true, + // value changed "NF_NETDEV_NUMHOOKS" if sparc64 => true, - // FIXME(linux): requires Linux >= v5.8 - "IF_LINK_MODE_TESTING" if sparc64 => true, - // DIFF(main): fixed in 1.0 with e9abac9ac2 "CLONE_CLEAR_SIGHAND" | "CLONE_INTO_CGROUP" => true, - // kernel 6.1 minimum - "MADV_COLLAPSE" => true, - - // kernel 6.2 minimum - "TUN_F_USO4" | "TUN_F_USO6" | "IFF_NO_CARRIER" => true, - // kernel 6.9 minimum "RWF_NOAPPEND" => true, @@ -4584,38 +4513,6 @@ fn test_linux(target: &str) { // kernel 6.14 minimum "RWF_DONTCACHE" => true, - // FIXME(linux): Requires more recent kernel headers - | "IFLA_PARENT_DEV_NAME" // linux v5.13+ - | "IFLA_PARENT_DEV_BUS_NAME" // linux v5.13+ - | "IFLA_GRO_MAX_SIZE" // linux v5.16+ - | "IFLA_TSO_MAX_SIZE" // linux v5.18+ - | "IFLA_TSO_MAX_SEGS" // linux v5.18+ - | "IFLA_ALLMULTI" // linux v6.0+ - | "MADV_DONTNEED_LOCKED" // linux v5.18+ - => true, - "SCTP_FUTURE_ASSOC" | "SCTP_CURRENT_ASSOC" | "SCTP_ALL_ASSOC" | "SCTP_PEER_ADDR_THLDS_V2" => true, // linux 5.5+ - - // kernel 6.5 minimum - "MOVE_MOUNT_BENEATH" => true, - // FIXME(linux): Requires linux 6.1 - "ALG_SET_KEY_BY_KEY_SERIAL" | "ALG_SET_DRBG_ENTROPY" => true, - - // FIXME(linux): Requires more recent kernel headers - | "FAN_FS_ERROR" // linux v5.16+ - | "FAN_RENAME" // linux v5.17+ - | "FAN_REPORT_TARGET_FID" // linux v5.17+ - | "FAN_REPORT_DFID_NAME_TARGET" // linux v5.17+ - | "FAN_MARK_EVICTABLE" // linux v5.19+ - | "FAN_MARK_IGNORE" // linux v6.0+ - | "FAN_MARK_IGNORE_SURV" // linux v6.0+ - | "FAN_EVENT_INFO_TYPE_ERROR" // linux v5.16+ - | "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" // linux v5.17+ - | "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" // linux v5.17+ - | "FAN_RESPONSE_INFO_NONE" // linux v5.16+ - | "FAN_RESPONSE_INFO_AUDIT_RULE" // linux v5.16+ - | "FAN_INFO" // linux v5.16+ - => true, - // musl doesn't use in "FAN_REPORT_PIDFD" | "FAN_REPORT_DIR_FID" @@ -4626,43 +4523,36 @@ fn test_linux(target: &str) { | "FAN_EVENT_INFO_TYPE_PIDFD" | "FAN_NOPIDFD" | "FAN_EPIDFD" - if musl => true, - - // FIXME(linux): Requires linux 6.5 - "NFT_MSG_MAX" => true, - - // FIXME(linux): Requires >= 6.6 kernel headers. - "XDP_USE_SG" - | "XDP_PKT_CONTD" - => + if musl => { true } // FIXME(linux): Requires >= 6.6 kernel headers. - "PR_MDWE_NO_INHERIT" => true, + "XDP_USE_SG" | "XDP_PKT_CONTD" => true, + + // FIXME(linux): Missing only on this platform for some reason + "PR_MDWE_NO_INHERIT" if gnueabihf => true, // FIXME(linux): Requires >= 6.8 kernel headers. "XDP_UMEM_TX_SW_CSUM" | "XDP_TXMD_FLAGS_TIMESTAMP" | "XDP_TXMD_FLAGS_CHECKSUM" - | "XDP_TX_METADATA" - => - { - true - } + | "XDP_TX_METADATA" => true, // FIXME(linux): Requires >= 6.11 kernel headers. - "XDP_UMEM_TX_METADATA_LEN" - => - { - true - } + "XDP_UMEM_TX_METADATA_LEN" => true, // FIXME(linux): Requires >= 6.11 kernel headers. - "NS_GET_MNTNS_ID" | "NS_GET_PID_FROM_PIDNS" | "NS_GET_TGID_FROM_PIDNS" | "NS_GET_PID_IN_PIDNS" | "NS_GET_TGID_IN_PIDNS" => true, + "NS_GET_MNTNS_ID" + | "NS_GET_PID_FROM_PIDNS" + | "NS_GET_TGID_FROM_PIDNS" + | "NS_GET_PID_IN_PIDNS" + | "NS_GET_TGID_IN_PIDNS" => true, // FIXME(linux): Requires >= 6.12 kernel headers. - "MNT_NS_INFO_SIZE_VER0" | "NS_MNT_GET_INFO" | "NS_MNT_GET_NEXT" | "NS_MNT_GET_PREV" => true, + "MNT_NS_INFO_SIZE_VER0" | "NS_MNT_GET_INFO" | "NS_MNT_GET_NEXT" | "NS_MNT_GET_PREV" => { + true + } // FIXME(linux): Requires >= 6.6 kernel headers. "SYS_fchmodat2" => true, @@ -4671,58 +4561,30 @@ fn test_linux(target: &str) { "SYS_mseal" => true, // FIXME(linux): seems to not be available all the time (from : - "PF_VCPU" - | "PF_IDLE" - | "PF_EXITING" - | "PF_POSTCOREDUMP" - | "PF_IO_WORKER" - | "PF_WQ_WORKER" - | "PF_FORKNOEXEC" - | "PF_MCE_PROCESS" - | "PF_SUPERPRIV" - | "PF_DUMPCORE" - | "PF_SIGNALED" - | "PF_MEMALLOC" - | "PF_NPROC_EXCEEDED" - | "PF_USED_MATH" - | "PF_USER_WORKER" - | "PF_NOFREEZE" - | "PF_KSWAPD" - | "PF_MEMALLOC_NOFS" - | "PF_MEMALLOC_NOIO" - | "PF_LOCAL_THROTTLE" - | "PF_KTHREAD" - | "PF_RANDOMIZE" - | "PF_NO_SETAFFINITY" - | "PF_MCE_EARLY" - | "PF_MEMALLOC_PIN" - | "PF_BLOCK_TS" - | "PF_SUSPEND_TASK" => true, + "PF_VCPU" | "PF_IDLE" | "PF_EXITING" | "PF_POSTCOREDUMP" | "PF_IO_WORKER" + | "PF_WQ_WORKER" | "PF_FORKNOEXEC" | "PF_MCE_PROCESS" | "PF_SUPERPRIV" + | "PF_DUMPCORE" | "PF_SIGNALED" | "PF_MEMALLOC" | "PF_NPROC_EXCEEDED" + | "PF_USED_MATH" | "PF_USER_WORKER" | "PF_NOFREEZE" | "PF_KSWAPD" + | "PF_MEMALLOC_NOFS" | "PF_MEMALLOC_NOIO" | "PF_LOCAL_THROTTLE" | "PF_KTHREAD" + | "PF_RANDOMIZE" | "PF_NO_SETAFFINITY" | "PF_MCE_EARLY" | "PF_MEMALLOC_PIN" + | "PF_BLOCK_TS" | "PF_SUSPEND_TASK" => true, // FIXME(linux): Requires >= 6.9 kernel headers. - "EPIOCSPARAMS" - | "EPIOCGPARAMS" => true, + "EPIOCSPARAMS" | "EPIOCGPARAMS" => true, // FIXME(linux): Requires >= 6.11 kernel headers. "MAP_DROPPABLE" => true, - // FIXME(linux): Requires >= 6.2 kernel headers. - "SOF_TIMESTAMPING_OPT_ID_TCP" => true, - // FIXME(linux): Requires >= 6.12 kernel headers. "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, // FIXME(linux): Requires >= 6.12 kernel headers. - "SO_DEVMEM_LINEAR" - | "SO_DEVMEM_DMABUF" - | "SO_DEVMEM_DONTNEED" - | "SCM_DEVMEM_LINEAR" - | "SCM_DEVMEM_DMABUF" => true, - // FIXME(linux): Requires >= 6.4 kernel headers. - "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, + "SO_DEVMEM_LINEAR" | "SO_DEVMEM_DMABUF" | "SO_DEVMEM_DONTNEED" + | "SCM_DEVMEM_LINEAR" | "SCM_DEVMEM_DMABUF" => true, - // FIXME(linux): Requires >= 6.6 kernel headers. - "PROC_EVENT_NONZERO_EXIT" => true, + // FIXME(linux): Requires >= 6.4 kernel headers. + "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" + | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, // FIXME(linux): Requires >= 6.14 kernel headers. "SECBIT_EXEC_DENY_INTERACTIVE" @@ -4734,6 +4596,9 @@ fn test_linux(target: &str) { // FIXME(linux): Value changed in 6.14 "SECURE_ALL_BITS" | "SECURE_ALL_LOCKS" => true, + // FIXME(linux): Requires >= 6.9 kernel headers. + "AT_HWCAP3" | "AT_HWCAP4" => true, + _ => false, } }); @@ -4816,20 +4681,22 @@ fn test_linux(target: &str) { // assume it's a int instead. "getnameinfo" if uclibc => true, - // FIXME(musl): This needs musl 1.2.2 or later. - "gettid" if old_musl => true, + // FIXME(musl): This needs musl 1.2.2 or later, which is newer than what we test with + // on CI. + "gettid" | "reallocarray" if musl => true, + // Needs musl 1.2.3 or later. + "pthread_getname_np" if musl => true, + // Added in musl 1.2.5 + "preadv2" | "pwritev2" if musl => true, + // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. + "statx" if musl => true, // Needs glibc 2.33 or later. "mallinfo2" => true, - "reallocarray" if old_musl => true, - // Not defined in uclibc as of 1.0.34 "gettid" if uclibc => true, - // Needs musl 1.2.3 or later. - "pthread_getname_np" if old_musl => true, - // pthread_sigqueue uses sigval, which was initially declared // as a struct but should be defined as a union. However due // to the issues described here: https://github.com/rust-lang/libc/issues/2816 @@ -4855,9 +4722,6 @@ fn test_linux(target: &str) { // FIXME(linux): function pointers changed since Ubuntu 23.10 "strtol" | "strtoll" | "strtoul" | "strtoull" | "fscanf" | "scanf" | "sscanf" => true, - // Added in musl 1.2.5 - "preadv2" | "pwritev2" if musl => true, - _ => false, } }); @@ -4949,7 +4813,7 @@ fn test_linux(target: &str) { (musl && struct_ == "tcp_info" && field == "tcpi_delivery_fastopen_bitfields") || // either fsid_t or int[2] type (struct_ == "fanotify_event_info_fid" && field == "fsid") || - // `handle` is a VLA + // `handle` is a flexible array member (struct_ == "fanotify_event_info_fid" && field == "handle") || // `anonymous_1` is an anonymous union (struct_ == "ptp_perout_request" && field == "anonymous_1") || @@ -4967,7 +4831,11 @@ fn test_linux(target: &str) { // the `xsk_tx_metadata_union` field is an anonymous union (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") || // After musl 1.2.0, the type becomes `int` instead of `long`. - (old_musl && struct_ == "utmpx" && field == "ut_session") + (musl && struct_ == "utmpx" && field == "ut_session") || + // `frames` is a flexible array member + (struct_ == "bcm_msg_head" && field == "frames") || + // FAM + (struct_ == "af_alg_iv" && field == "iv") }); cfg.skip_roundtrip(move |s| match s { @@ -5006,6 +4874,7 @@ fn test_linux(target: &str) { "inotify_event" => true, "fanotify_event_info_fid" => true, "cmsghdr" => true, + "bcm_msg_head" => true, // FIXME(linux): the call ABI of max_align_t is incorrect on these platforms: "max_align_t" if i686 || ppc64 => true, @@ -5033,9 +4902,9 @@ fn test_linux_like_apis(target: &str) { if linux || android || emscripten { // test strerror_r from the `string.h` header config_gnu_bits(target, &mut cfg); - headers! { cfg: "string.h" } - cfg.skip_alias(|_| true) + cfg.header("string.h") + .skip_alias(|_| true) .skip_static(|_| true) .skip_const(|_| true) .skip_struct(|_| true) @@ -5118,10 +4987,7 @@ fn test_linux_like_apis(target: &str) { .skip_const(move |constant| !ipv6_constants.contains(&constant.ident())); config_gnu_bits(target, &mut cfg); - headers! { - cfg: - "linux/in6.h" - } + headers!(cfg, "linux/in6.h",); ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_ipv6.rs").unwrap(); } @@ -5164,34 +5030,6 @@ fn test_linux_like_apis(target: &str) { } } -fn which_freebsd() -> Option { - if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { - let vers = version.parse().unwrap(); - println!("cargo:warning=setting FreeBSD version to {vers}"); - return Some(vers); - } - - let output = std::process::Command::new("freebsd-version") - .output() - .ok()?; - - if !output.status.success() { - return None; - } - - let stdout = String::from_utf8(output.stdout).ok()?; - - match &stdout { - s if s.starts_with("10") => Some(10), - s if s.starts_with("11") => Some(11), - s if s.starts_with("12") => Some(12), - s if s.starts_with("13") => Some(13), - s if s.starts_with("14") => Some(14), - s if s.starts_with("15") => Some(15), - _ => None, - } -} - fn test_haiku(target: &str) { assert!(target.contains("haiku")); @@ -5202,143 +5040,142 @@ fn test_haiku(target: &str) { cfg.language(ctest::Language::CXX); // POSIX API - headers! { cfg: - "alloca.h", - "arpa/inet.h", - "arpa/nameser.h", - "arpa/nameser_compat.h", - "assert.h", - "complex.h", - "ctype.h", - "dirent.h", - "div_t.h", - "dlfcn.h", - "endian.h", - "errno.h", - "fcntl.h", - "fenv.h", - "fnmatch.h", - "fts.h", - "ftw.h", - "getopt.h", - "glob.h", - "grp.h", - "inttypes.h", - "iovec.h", - "langinfo.h", - "libgen.h", - "libio.h", - "limits.h", - "locale.h", - "malloc.h", - "malloc_debug.h", - "math.h", - "memory.h", - "monetary.h", - "net/if.h", - "net/if_dl.h", - "net/if_media.h", - "net/if_tun.h", - "net/if_types.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/ip6.h", - "netinet/ip_icmp.h", - "netinet/ip_var.h", - "netinet/tcp.h", - "netinet/udp.h", - "netinet6/in6.h", - "nl_types.h", - "null.h", - "poll.h", - "pthread.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "search.h", - "semaphore.h", - "setjmp.h", - "shadow.h", - "signal.h", - "size_t.h", - "spawn.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "strings.h", - "sys/cdefs.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/msg.h", - "sys/param.h", - "sys/poll.h", - "sys/resource.h", - "sys/select.h", - "sys/sem.h", - "sys/socket.h", - "sys/sockio.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/time.h", - "sys/timeb.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "syslog.h", - "tar.h", - "termios.h", - "time.h", - "uchar.h", - "unistd.h", - "utime.h", - "utmpx.h", - "wchar.h", - "wchar_t.h", - "wctype.h" - } + headers!( + cfg, + "alloca.h", + "arpa/inet.h", + "arpa/nameser.h", + "arpa/nameser_compat.h", + "assert.h", + "complex.h", + "ctype.h", + "dirent.h", + "div_t.h", + "dlfcn.h", + "endian.h", + "errno.h", + "fcntl.h", + "fenv.h", + "fnmatch.h", + "fts.h", + "ftw.h", + "getopt.h", + "glob.h", + "grp.h", + "inttypes.h", + "iovec.h", + "langinfo.h", + "libgen.h", + "libio.h", + "limits.h", + "locale.h", + "malloc.h", + "malloc_debug.h", + "math.h", + "memory.h", + "monetary.h", + "net/if.h", + "net/if_dl.h", + "net/if_media.h", + "net/if_tun.h", + "net/if_types.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/ip6.h", + "netinet/ip_icmp.h", + "netinet/ip_var.h", + "netinet/tcp.h", + "netinet/udp.h", + "netinet6/in6.h", + "nl_types.h", + "null.h", + "poll.h", + "pthread.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "search.h", + "semaphore.h", + "setjmp.h", + "shadow.h", + "signal.h", + "size_t.h", + "spawn.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "strings.h", + "sys/cdefs.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/msg.h", + "sys/param.h", + "sys/poll.h", + "sys/resource.h", + "sys/select.h", + "sys/sem.h", + "sys/socket.h", + "sys/sockio.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/time.h", + "sys/timeb.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "syslog.h", + "tar.h", + "termios.h", + "time.h", + "uchar.h", + "unistd.h", + "utime.h", + "utmpx.h", + "wchar.h", + "wchar_t.h", + "wctype.h", + ); // BSD Extensions - headers! { cfg: - "ifaddrs.h", - "libutil.h", - "link.h", - "pty.h", - "stdlib.h", - "stringlist.h", - "sys/link_elf.h", - } + headers!( + cfg, + "ifaddrs.h", + "libutil.h", + "link.h", + "pty.h", + "stdlib.h", + "stringlist.h", + "sys/link_elf.h", + ); // Native API - headers! { cfg: - "kernel/OS.h", - "kernel/fs_attr.h", - "kernel/fs_index.h", - "kernel/fs_info.h", - "kernel/fs_query.h", - "kernel/fs_volume.h", - "kernel/image.h", - "kernel/scheduler.h", - "storage/FindDirectory.h", - "storage/StorageDefs.h", - "support/Errors.h", - "support/SupportDefs.h", - "support/TypeConstants.h" - } + headers!( + cfg, + "kernel/OS.h", + "kernel/fs_attr.h", + "kernel/fs_index.h", + "kernel/fs_info.h", + "kernel/fs_query.h", + "kernel/fs_volume.h", + "kernel/image.h", + "kernel/scheduler.h", + "storage/FindDirectory.h", + "storage/StorageDefs.h", + "support/Errors.h", + "support/SupportDefs.h", + "support/TypeConstants.h", + ); - cfg.skip_union(|union_| union_.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // FIXME(union): actually a union "sigval" => true, @@ -5544,92 +5381,93 @@ fn test_aix(target: &str) { // 'IN6ADDR_LOOPBACK_INIT' in netinent/in.h. cfg.flag("-Wno-missing-braces"); - headers! { cfg: - "aio.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "errno.h", - "fcntl.h", - "fnmatch.h", - "glob.h", - "grp.h", - "iconv.h", - "langinfo.h", - "libgen.h", - "limits.h", - "locale.h", - "malloc.h", - "mntent.h", - "mqueue.h", - "netinet/in.h", // this needs be before net/if.h - "poll.h", // this needs be before net/if.h - "sys/pollset.h", // this needs to be before net/if.h - "net/if.h", - "net/bpf.h", // this needs to be after net/if.h - "net/if_dl.h", - "netdb.h", - "netinet/tcp.h", - "netinet/sctp.h", - "pthread.h", - "pwd.h", - "rpcsvc/mount.h", - "rpcsvc/rstat.h", - "regex.h", - "resolv.h", - "sched.h", - "search.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "strings.h", - "sys/aacct.h", - "sys/acct.h", - "sys/dr.h", - "sys/file.h", - "sys/io.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/ldr.h", - "sys/mman.h", - "sys/msg.h", - "sys/reg.h", - "sys/resource.h", - "sys/sem.h", - "sys/shm.h", - "sys/socket.h", - "sys/stat.h", - "sys/statfs.h", - "sys/statvfs.h", - "sys/stropts.h", - "sys/termio.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vattr.h", - "sys/vminfo.h", - "sys/wait.h", - "sys/xti.h", - "syslog.h", - "termios.h", - "thread.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "utmp.h", - "utmpx.h", - "wchar.h", - } + headers!( + cfg, + "aio.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "glob.h", + "grp.h", + "iconv.h", + "langinfo.h", + "libgen.h", + "limits.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "netinet/in.h", // this needs be before net/if.h + "poll.h", // this needs be before net/if.h + "sys/pollset.h", // this needs to be before net/if.h + "net/if.h", + "net/bpf.h", // this needs to be after net/if.h + "net/if_dl.h", + "netdb.h", + "netinet/tcp.h", + "netinet/sctp.h", + "pthread.h", + "pwd.h", + "rpcsvc/mount.h", + "rpcsvc/rstat.h", + "regex.h", + "resolv.h", + "sched.h", + "search.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "strings.h", + "sys/aacct.h", + "sys/acct.h", + "sys/dr.h", + "sys/file.h", + "sys/io.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/ldr.h", + "sys/mman.h", + "sys/msg.h", + "sys/reg.h", + "sys/resource.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statfs.h", + "sys/statvfs.h", + "sys/stropts.h", + "sys/termio.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vattr.h", + "sys/vminfo.h", + "sys/wait.h", + "sys/xti.h", + "syslog.h", + "termios.h", + "thread.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + ); cfg.skip_alias(move |ty| match ty.ident() { // AIX does not define type 'sighandler_t'. @@ -5657,11 +5495,9 @@ fn test_aix(target: &str) { // Skip 'sighandler_t' assignments. "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, - // _ALL_SOURCE defines these errno values as aliases of other errno - // values, but POSIX requires each errno to be unique. Skip these - // values because non-unique values are being used which will - // fail the test when _ALL_SOURCE is defined. - "EWOULDBLOCK" | "ENOTEMPTY" => true, + // _ALL_SOURCE defines ENOTEMPTY as an alias of EEXIST, but POSIX + // requires its value to be unique. Skip. + "ENOTEMPTY" => true, // FIXME(ctest): These constants are intended for use as the 'int request' argument // to 'ioctl()'. However, the AIX headers do not explicitly define their types. If a @@ -5750,6 +5586,12 @@ fn test_aix(target: &str) { // The field 'data' is actually a unnamed union in the AIX header. "pollfd_ext" if field.ident() == "data" => true, + // On AIX, declares 'tv_nsec' as 'long', but the + // underlying system calls return a 32-bit value in both 32-bit + // and 64-bit modes. In the 'libc' crate it is declared as 'i32' + // to match the system call. Skip this field. + "timespec" if field.ident() == "tv_nsec" => true, + _ => false, } }); @@ -5828,3 +5670,17 @@ fn test_aix(target: &str) { 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 { + let output = std::process::Command::new(cmd).args(args).output().ok()?; + + if !output.status.success() { + return None; + } + + let res = String::from_utf8(output.stdout) + .unwrap_or_else(|e| panic!("command {cmd} returned non-UTF-8 output: {e}")); + Some(res) +} diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 53ab742cf2a6a..47b4d7693448a 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -150,6 +150,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_IGNORE AT_MINSIGSTKSZ AT_NOTELF @@ -1086,6 +1088,7 @@ IP_XFRM_POLICY ISIG ISOFS_SUPER_MAGIC ISTRIP +IUCLC IUTF8 IXANY IXOFF diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 1d340bd54929d..09934484f379e 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -2033,6 +2033,7 @@ initgroups integer_t ip_mreqn ipc_perm +issetugid kern_return_t kevent kevent64 @@ -2190,12 +2191,14 @@ pseudo_AF_PIP pseudo_AF_RTIP pseudo_AF_XTP pthread_atfork +pthread_attr_get_qos_class_np pthread_attr_getdetachstate pthread_attr_getinheritsched pthread_attr_getschedparam pthread_attr_getschedpolicy pthread_attr_getscope pthread_attr_getstackaddr +pthread_attr_set_qos_class_np pthread_attr_setinheritsched pthread_attr_setschedparam pthread_attr_setschedpolicy @@ -2208,6 +2211,7 @@ pthread_condattr_setpshared pthread_cpu_number_np pthread_create_from_mach_thread pthread_from_mach_thread_np +pthread_get_qos_class_np pthread_get_stackaddr_np pthread_get_stacksize_np pthread_getname_np @@ -2229,6 +2233,7 @@ pthread_once pthread_once_t pthread_rwlockattr_getpshared pthread_rwlockattr_setpshared +pthread_set_qos_class_self_np pthread_setname_np pthread_setschedparam pthread_stack_frame_decode_np diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 6c2a3a0d2e4e0..6d41c8c6cabd9 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1403,6 +1403,7 @@ if_nameindex ifaddrs in6_pktinfo initgroups +issetugid jrand48 kevent killpg diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index cebe46464eebf..baf07600f5b12 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -96,6 +96,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_NCPUS AT_NOTELF AT_NULL @@ -2052,6 +2054,7 @@ input_absinfo input_event ip_mreqn ipc_perm +issetugid jail jail_attach jail_get diff --git a/libc-test/semver/linux-gnu-powerpc64.txt b/libc-test/semver/linux-gnu-powerpc64.txt index 148688c5ff20d..46aa2db2cfdd3 100644 --- a/libc-test/semver/linux-gnu-powerpc64.txt +++ b/libc-test/semver/linux-gnu-powerpc64.txt @@ -10,5 +10,20 @@ KEYCTL_CAPS0_RESTRICT_KEYRING KEYCTL_CAPS1_NS_KEYRING_NAME KEYCTL_CAPS1_NS_KEY_TAG KEYCTL_MOVE +__NFPREG +__NGREG +__NVRREG +clone_args +fpregset_t +getcontext +gregset_t +makecontext max_align_t +mcontext_t +pt_regs +setcontext +swapcontext sysctl +ucontext_t +vrregset_t +vscr_t diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 318cca51b482e..151d21cbd02c6 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -168,6 +168,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_IGNORE AT_MINSIGSTKSZ AT_NOTELF @@ -232,6 +234,7 @@ CAN_EFF_ID_BITS CAN_EFF_MASK CAN_ERR_FLAG CAN_ERR_MASK +CAN_FD_FRAME CAN_INV_FILTER CAN_ISOTP CAN_J1939 @@ -1299,6 +1302,7 @@ IP_XFRM_POLICY ITIMER_PROF ITIMER_REAL ITIMER_VIRTUAL +IUCLC IUTF8 IWEVASSOCREQIE IWEVASSOCRESPIE @@ -2709,6 +2713,17 @@ RT_TOS RUSAGE_CHILDREN RUSAGE_SELF RUSAGE_THREAD +RX_ANNOUNCE_RESUME +RX_CHANGED +RX_CHECK_DLC +RX_DELETE +RX_FILTER_ID +RX_NO_AUTOTIMER +RX_READ +RX_RTR_FRAME +RX_SETUP +RX_STATUS +RX_TIMEOUT SCHED_BATCH SCHED_FIFO SCHED_IDLE @@ -2842,6 +2857,7 @@ SEM_STAT SEM_STAT_ANY SEM_UNDO SETALL +SETTIMER SETVAL SFD_CLOEXEC SFD_NONBLOCK @@ -3086,6 +3102,7 @@ SPLICE_F_MOVE SPLICE_F_NONBLOCK SS_DISABLE SS_ONSTACK +STARTTIMER STICKY_TIMEOUTS ST_APPEND ST_IMMUTABLE @@ -3574,6 +3591,16 @@ TUN_TAP_DEV TUN_TUN_DEV TUN_TX_TIMESTAMP TUN_TYPE_MASK +TX_ANNOUNCE +TX_COUNTEVT +TX_CP_CAN_ID +TX_DELETE +TX_EXPIRED +TX_READ +TX_RESET_MULTI_IDX +TX_SEND +TX_SETUP +TX_STATUS T_FMT T_FMT_AMPM UDP_CORK @@ -3857,6 +3884,8 @@ arpd_request arphdr arpreq arpreq_old +bcm_msg_head +bcm_timeval blkcnt64_t brk bsearch diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 5821466cc8ddf..982f610a4f3aa 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -93,7 +93,6 @@ AT_SUN_IFLUSH AT_SUN_LDELF AT_SUN_LDNAME AT_SUN_LDSHDR -AT_SUN_LPGSIZE AT_SUN_PLATFORM AT_SYMLINK_FOLLOW AT_SYMLINK_NOFOLLOW @@ -104,23 +103,6 @@ B460800 B7200 B76800 B921600 -BIOCFLUSH -BIOCGBLEN -BIOCGDLT -BIOCGETIF -BIOCGHDRCMPLT -BIOCGRSIG -BIOCGSEESENT -BIOCGSTATS -BIOCIMMEDIATE -BIOCPROMISC -BIOCSBLEN -BIOCSDLT -BIOCSETIF -BIOCSHDRCMPLT -BIOCSRSIG -BIOCSSEESENT -BIOCVERSION BOOT_TIME BUFSIZ BUS_ADRALN @@ -180,7 +162,6 @@ CTL_HW CTL_IPPROTO_IPSEC CTL_KERN CTL_MACHDEP -CTL_MAXID CTL_MAXNAME CTL_MMAP CTL_NET @@ -417,7 +398,6 @@ IFF_LINK2 IFF_LOOPBACK IFF_MULTICAST IFF_NOARP -IFF_NOTRAILERS IFF_OACTIVE IFF_POINTOPOINT IFF_PROMISC @@ -534,7 +514,6 @@ KERN_LOGSIGEXIT KERN_LWP KERN_MAPPED_FILES KERN_MAXFILES -KERN_MAXID KERN_MAXPARTITIONS KERN_MAXPHYS KERN_MAXPROC @@ -728,13 +707,11 @@ NANOSECOND NET_RT_DUMP NET_RT_FLAGS NET_RT_IFLIST -NET_RT_MAXID NET_RT_OIFLIST NET_RT_OOIFLIST NET_RT_OOOIFLIST NEW_TIME NI_DGRAM -NI_MAXHOST NI_MAXSERV NI_NAMEREQD NI_NOFQDN @@ -845,7 +822,6 @@ POSIX_SPAWN_RETURNERROR POSIX_SPAWN_SETPGROUP POSIX_SPAWN_SETSCHEDPARAM POSIX_SPAWN_SETSCHEDULER -POSIX_SPAWN_SETSIGDEP POSIX_SPAWN_SETSIGMASK PROT_MPROTECT PTHREAD_CREATE_DETACHED @@ -908,7 +884,6 @@ REG_ECOLLATE REG_ECTYPE REG_EESCAPE REG_EMPTY -REG_ENOSYS REG_EPAREN REG_ERANGE REG_ESPACE @@ -997,7 +972,6 @@ SIGINFO SIGIO SIGNATURE SIGSTKSZ -SIOCGIFADDR SOCKCREDSIZE SOCK_CLOEXEC SOCK_CONN_DGRAM @@ -1342,7 +1316,6 @@ futimes getbootfile getbyteorder getdiskrawname -getdistcookedname getdomainname getdtablesize getentropy @@ -1402,6 +1375,7 @@ in6_pktinfo in_pktinfo initgroups ipc_perm +issetugid itimerspec jrand48 kevent @@ -1421,7 +1395,6 @@ lcong48 lgetxattr lio_listio listxattr -llistxaatr localeconv_l lockf login @@ -1650,11 +1623,10 @@ updwtmpx useconds_t utimensat utmp +utmpname utmpx utmpxname -utpname utrace uucred -vm_size_t wait4 waitid diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index cfb234fdfa3d1..412ba5a4bd481 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1173,6 +1173,7 @@ initgroups ip_mreqn ipc_perm iso_args +issetugid jrand48 kevent key_t diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index b7aaa5706d626..e993475f20b4b 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -302,6 +302,8 @@ getgrouplist getline getpwent getpwnam_r +getresgid +getresuid getrlimit getrusage getservbyport @@ -324,6 +326,8 @@ reallocarray rlim_t setgrent setpwent +setresgid +setresuid setrlimit setservent sigqueue diff --git a/libc-test/semver/vxworks.txt b/libc-test/semver/vxworks.txt new file mode 100644 index 0000000000000..bb5f32ccc608f --- /dev/null +++ b/libc-test/semver/vxworks.txt @@ -0,0 +1,817 @@ +AF_INET +AF_INET6 +AF_UNIX +AF_UNSPEC +AT_FDCWD +AT_REMOVEDIR +AT_SYMLINK_FOLLOW +AT_SYMLINK_NOFOLLOW +B0 +B110 +B115200 +B1200 +B134 +B150 +B1800 +B19200 +B200 +B230400 +B2400 +B300 +B38400 +B4800 +B50 +B57600 +B600 +B75 +B9600 +BRKINT +CLOCAL +CLOCK_MONOTONIC +CLOCK_REALTIME +CREAD +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTOPB +DIR +DT_BLK +DT_CHR +DT_DIR +DT_FIFO +DT_LNK +DT_REG +DT_SOCK +Dl_info +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EAFNOSUPPORT +EAGAIN +EAI_SYSTEM +EALREADY +EBADF +EBADMSG +EBUSY +ECANCELED +ECHILD +ECHO +ECHOE +ECHOK +ECHONL +ECONNABORTED +ECONNREFUSED +ECONNRESET +EDEADLK +EDESTADDRREQ +EDOM +EDQUOT +EEXIST +EFAULT +EFBIG +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +ELOOP +EMFILE +EMLINK +EMSGSIZE +ENAMETOOLONG +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOBUFS +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOMEM +ENOMSG +ENOPROTOOPT +ENOSPC +ENOSYS +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTSOCK +ENOTTY +ENXIO +EOPNOTSUPP +EOVERFLOW +EPERM +EPFNOSUPPORT +EPIPE +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERANGE +EROFS +ESHUTDOWN +ESPIPE +ESRCH +ESTALE +ETIMEDOUT +ETXTBSY +EWOULDBLOCK +EXDEV +EXIT_FAILURE +EXIT_SUCCESS +FD_CLOEXEC +FILE +FIONBIO +FNM_CASEFOLD +FNM_NOESCAPE +FNM_NOMATCH +FNM_PATHNAME +FNM_PERIOD +F_DUPFD +F_DUPFD_CLOEXEC +F_GETFD +F_GETFL +F_GETLK +F_OK +F_SETFD +F_SETFL +F_SETLK +F_SETLKW +HUPCL +ICANON +ICRNL +IEXTEN +IFNAMSIZ +IF_NAMESIZE +IGNBRK +IGNCR +IGNPAR +IN6ADDR_ANY_INIT +IN6ADDR_LOOPBACK_INIT +INADDR_ANY +INADDR_BROADCAST +INADDR_LOOPBACK +INADDR_NONE +INLCR +INPCK +INT_MAX +INT_MIN +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IP +IPPROTO_IPV6 +IPPROTO_TCP +IPPROTO_UDP +IPV6_MULTICAST_HOPS +IPV6_MULTICAST_IF +IPV6_MULTICAST_LOOP +IPV6_UNICAST_HOPS +IPV6_V6ONLY +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MULTICAST_IF +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_TTL +ISIG +ISTRIP +IXOFF +IXON +LOG_ALERT +LOG_AUTH +LOG_CONS +LOG_CRIT +LOG_DAEMON +LOG_DEBUG +LOG_EMERG +LOG_ERR +LOG_FACMASK +LOG_INFO +LOG_KERN +LOG_LOCAL0 +LOG_LOCAL1 +LOG_LOCAL2 +LOG_LOCAL3 +LOG_LOCAL4 +LOG_LOCAL5 +LOG_LOCAL6 +LOG_LOCAL7 +LOG_LPR +LOG_MAIL +LOG_NDELAY +LOG_NEWS +LOG_NOTICE +LOG_NOWAIT +LOG_ODELAY +LOG_PID +LOG_PRIMASK +LOG_SYSLOG +LOG_USER +LOG_UUCP +LOG_WARNING +MAP_ANON +MAP_ANONYMOUS +MAP_FAILED +MAP_FIXED +MAP_PRIVATE +MAP_SHARED +MSG_CTRUNC +MSG_DONTROUTE +MSG_EOR +MSG_OOB +MSG_PEEK +MSG_TRUNC +MSG_WAITALL +MS_ASYNC +MS_INVALIDATE +MS_SYNC +NCCS +NI_MAXHOST +NOFLSH +OCRNL +ONLCR +OPOST +O_ACCMODE +O_APPEND +O_CLOEXEC +O_CREAT +O_EXCL +O_NONBLOCK +O_RDONLY +O_RDWR +O_TRUNC +O_WRONLY +PARENB +PARMRK +PARODD +PATH_MAX +PF_INET +PF_INET6 +PF_UNIX +PF_UNSPEC +POLLERR +POLLHUP +POLLIN +POLLNVAL +POLLOUT +POLLPRI +PROT_EXEC +PROT_NONE +PROT_READ +PROT_WRITE +PTHREAD_COND_INITIALIZER +PTHREAD_MUTEX_INITIALIZER +PTHREAD_MUTEX_NORMAL +PTHREAD_MUTEX_RECURSIVE +PTHREAD_RWLOCK_INITIALIZER +RTLD_DEFAULT +RTLD_GLOBAL +RTLD_LAZY +RTLD_LOCAL +RTLD_NOW +R_OK +SA_NOCLDSTOP +SA_NOCLDWAIT +SA_NODEFER +SA_ONSTACK +SA_RESETHAND +SA_RESTART +SA_SIGINFO +SEEK_CUR +SEEK_END +SEEK_SET +SHUT_RD +SHUT_RDWR +SHUT_WR +SIGABRT +SIGALRM +SIGBUS +SIGCHLD +SIGCONT +SIGFPE +SIGHUP +SIGILL +SIGINT +SIGKILL +SIGPIPE +SIGPROF +SIGQUIT +SIGSEGV +SIGSTOP +SIGSYS +SIGTERM +SIGTRAP +SIGTSTP +SIGTTIN +SIGTTOU +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ +SIG_BLOCK +SIG_DFL +SIG_ERR +SIG_IGN +SIG_SETMASK +SIG_UNBLOCK +SOCK_DGRAM +SOCK_SEQPACKET +SOCK_STREAM +SOL_SOCKET +SO_ACCEPTCONN +SO_BROADCAST +SO_DEBUG +SO_DONTROUTE +SO_ERROR +SO_KEEPALIVE +SO_LINGER +SO_OOBINLINE +SO_RCVBUF +SO_RCVLOWAT +SO_RCVTIMEO +SO_REUSEADDR +SO_SNDBUF +SO_SNDLOWAT +SO_SNDTIMEO +SO_TYPE +STDERR_FILENO +STDIN_FILENO +STDOUT_FILENO +S_IFBLK +S_IFCHR +S_IFDIR +S_IFIFO +S_IFLNK +S_IFMT +S_IFREG +S_IFSOCK +S_IRGRP +S_IROTH +S_IRUSR +S_IRWXG +S_IRWXO +S_IRWXU +S_ISGID +S_ISUID +S_ISVTX +S_IWGRP +S_IWOTH +S_IWUSR +S_IXGRP +S_IXOTH +S_IXUSR +TCIFLUSH +TCP_NODELAY +TCSADRAIN +TCSAFLUSH +TCSANOW +TIOCGWINSZ +TIOCSWINSZ +VEOF +VERASE +VINTR +VKILL +VMIN +VQUIT +VTIME +WCONTINUED +WEXITSTATUS +WIFCONTINUED +WIFEXITED +WIFSIGNALED +WIFSTOPPED +WNOHANG +WSTOPSIG +WTERMSIG +WUNTRACED +W_OK +X_OK +_PC_CHOWN_RESTRICTED +_PC_LINK_MAX +_PC_MAX_CANON +_PC_MAX_INPUT +_PC_NAME_MAX +_PC_NO_TRUNC +_PC_PATH_MAX +_PC_PIPE_BUF +_PC_VDISABLE +_SC_ARG_MAX +_SC_CHILD_MAX +_SC_CLK_TCK +_SC_HOST_NAME_MAX +_SC_NGROUPS_MAX +_SC_OPEN_MAX +_SC_PAGESIZE +_SC_PAGE_SIZE +_SC_STREAM_MAX +_SC_SYMLOOP_MAX +_SC_TTY_NAME_MAX +_SC_TZNAME_MAX +_SC_VERSION +_exit +abort +accept +access +addrinfo +alarm +aligned_alloc +atexit +atof +atoi +atol +atoll +bind +blkcnt_t +blksize_t +c_char +c_double +c_float +c_int +c_long +c_longlong +c_schar +c_short +c_uchar +c_uint +c_ulong +c_ulonglong +c_ushort +c_void +calloc +cc_t +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +chdir +chmod +chown +clock_gettime +clock_t +clockid_t +close +closedir +closelog +confstr +connect +creat +dev_t +dirent +dladdr +dlclose +dlerror +dlopen +dlsym +dup +dup2 +exit +fchmod +fchmodat +fchown +fchownat +fclose +fcntl +fdopen +feof +ferror +fflush +fgetc +fgetpos +fgets +fileno +flock +fnmatch +fopen +fpathconf +fpos_t +fprintf +fputc +fputs +fread +free +freeaddrinfo +freopen +fscanf +fseek +fseeko +fsetpos +fstat +fsync +ftell +ftello +ftruncate +futimens +fwrite +gai_strerror +getaddrinfo +getchar +getchar_unlocked +getcwd +getegid +getenv +geteuid +getgid +getgroups +gethostname +getlogin +getopt +getpeername +getpid +getppid +getprotobyname +getprotobynumber +getservbyname +getsockname +getsockopt +gettimeofday +getuid +gid_t +gmtime +gmtime_r +group +hostent +in6_addr +in_addr +in_addr_t +ino_t +int16_t +int32_t +int64_t +int8_t +intmax_t +intptr_t +ioctl +iovec +ip_mreq +ipv6_mreq +isalnum +isalpha +isatty +isblank +iscntrl +isdigit +isgraph +islower +isprint +ispunct +isspace +isupper +isxdigit +kill +lconv +linger +link +linkat +listen +localtime +localtime_r +lseek +lstat +malloc +memccpy +memchr +memcmp +memcpy +memmove +memset +mkdir +mkdtemp +mkfifo +mkstemp +mktime +mlock +mlockall +mmap +mode_t +mprotect +msync +munlock +munlockall +munmap +nanosleep +nfds_t +nlink_t +off_t +open +opendir +openlog +pathconf +pclose +perror +pid_t +pipe +poll +pollfd +posix_memalign +pread +printf +protoent +pthread_attr_destroy +pthread_attr_getstacksize +pthread_attr_init +pthread_attr_setdetachstate +pthread_attr_setstacksize +pthread_attr_t +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_t +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_init +pthread_condattr_t +pthread_create +pthread_detach +pthread_equal +pthread_exit +pthread_getspecific +pthread_join +pthread_key_create +pthread_key_delete +pthread_key_t +pthread_mutex_destroy +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_t +pthread_mutex_trylock +pthread_mutex_unlock +pthread_mutexattr_destroy +pthread_mutexattr_init +pthread_mutexattr_settype +pthread_mutexattr_t +pthread_rwlock_destroy +pthread_rwlock_init +pthread_rwlock_rdlock +pthread_rwlock_t +pthread_rwlock_tryrdlock +pthread_rwlock_trywrlock +pthread_rwlock_unlock +pthread_rwlock_wrlock +pthread_rwlockattr_destroy +pthread_rwlockattr_init +pthread_rwlockattr_t +pthread_self +pthread_setspecific +pthread_t +ptrdiff_t +putchar +putchar_unlocked +putenv +puts +pwrite +raise +read +readdir +readlink +readv +realloc +realpath +recv +recvfrom +remove +rename +rewind +rewinddir +rlim_t +rlimit +rmdir +rusage +sa_family_t +scanf +sched_yield +send +sendto +servent +setbuf +setegid +setenv +seteuid +setgid +setlocale +setlogmask +setpgid +setsockopt +setuid +setvbuf +shm_open +shm_unlink +shutdown +sigaction +sigaddset +sigdelset +sigemptyset +sigfillset +sighandler_t +sigismember +signal +sigpending +sigprocmask +sigset_t +sigval +size_t +sleep +snprintf +sockaddr +sockaddr_in +sockaddr_in6 +sockaddr_storage +sockaddr_un +socket +socklen_t +speed_t +sprintf +sscanf +ssize_t +stat +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strerror_r +strlen +strncat +strncmp +strncpy +strnlen +strpbrk +strrchr +strspn +strstr +strtod +strtof +strtok +strtol +strtoll +strtoul +strtoull +strxfrm +suseconds_t +symlink +symlinkat +sysconf +syslog +system +tcflag_t +tcflush +tcgetattr +tcsendbreak +tcsetattr +termios +time +time_t +timegm +times +timespec +timeval +tm +tmpfile +tmpnam +tms +tolower +toupper +ttyname +uid_t +uint16_t +uint32_t +uint64_t +uint8_t +uintmax_t +uintptr_t +umask +uname +ungetc +unlink +unlinkat +unsetenv +usleep +utimbuf +utime +utimensat +utimes +utsname +wait +waitpid +wchar_t +wcslen +wcstombs +winsize +wmemchr +write +writev diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index bba658c498aa9..80d4af53938e8 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -6,7 +6,14 @@ mod t { use std::mem; - use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr}; + use libc::{ + self, + c_uchar, + c_uint, + c_void, + cmsghdr, + msghdr, + }; extern "C" { pub fn cmsg_firsthdr(msgh: *const msghdr) -> *mut cmsghdr; @@ -29,14 +36,16 @@ mod t { } #[test] + #[allow(unused_assignments)] // false-positive: https://github.com/rust-lang/rust/issues/147648 fn test_cmsg_firsthdr() { + let mut buf = [0u8; 256]; let mut mhdr: msghdr = unsafe { mem::zeroed() }; - mhdr.msg_control = 0xdeadbeef as *mut c_void; - let pmhdr = &mhdr as *const msghdr; + mhdr.msg_control = buf.as_mut_ptr().cast::(); + for l in 0..128 { - mhdr.msg_controllen = l; + mhdr.msg_controllen = l as _; unsafe { - assert_eq!(libc::CMSG_FIRSTHDR(pmhdr), cmsg_firsthdr(pmhdr)); + assert_eq!(libc::CMSG_FIRSTHDR(&mhdr), cmsg_firsthdr(&mhdr)); } } } diff --git a/libc-test/test/ctest.rs b/libc-test/tests/ctest.rs similarity index 100% rename from libc-test/test/ctest.rs rename to libc-test/tests/ctest.rs diff --git a/libc-test/tests/errqueue.rs b/libc-test/tests/errqueue.rs index a7d1563c5cf39..c3d9c2e69a496 100644 --- a/libc-test/tests/errqueue.rs +++ b/libc-test/tests/errqueue.rs @@ -2,7 +2,11 @@ #[cfg(any(target_os = "linux", target_os = "android"))] mod t { - use libc::{self, sock_extended_err, sockaddr}; + use libc::{ + self, + sock_extended_err, + sockaddr, + }; extern "C" { pub fn so_ee_offender(ee: *const sock_extended_err) -> *mut sockaddr; diff --git a/libc-test/test/linux_elf.rs b/libc-test/tests/linux_elf.rs similarity index 100% rename from libc-test/test/linux_elf.rs rename to libc-test/tests/linux_elf.rs diff --git a/libc-test/test/linux_fcntl.rs b/libc-test/tests/linux_fcntl.rs similarity index 100% rename from libc-test/test/linux_fcntl.rs rename to libc-test/tests/linux_fcntl.rs diff --git a/libc-test/test/linux_if_arp.rs b/libc-test/tests/linux_if_arp.rs similarity index 100% rename from libc-test/test/linux_if_arp.rs rename to libc-test/tests/linux_if_arp.rs diff --git a/libc-test/test/linux_ipv6.rs b/libc-test/tests/linux_ipv6.rs similarity index 100% rename from libc-test/test/linux_ipv6.rs rename to libc-test/tests/linux_ipv6.rs diff --git a/libc-test/test/linux_kernel_version.rs b/libc-test/tests/linux_kernel_version.rs similarity index 100% rename from libc-test/test/linux_kernel_version.rs rename to libc-test/tests/linux_kernel_version.rs diff --git a/libc-test/test/linux_strerror_r.rs b/libc-test/tests/linux_strerror_r.rs similarity index 100% rename from libc-test/test/linux_strerror_r.rs rename to libc-test/tests/linux_strerror_r.rs diff --git a/libc-test/test/linux_termios.rs b/libc-test/tests/linux_termios.rs similarity index 100% rename from libc-test/test/linux_termios.rs rename to libc-test/tests/linux_termios.rs diff --git a/libc-test/tests/makedev.rs b/libc-test/tests/makedev.rs index 1c08776d7260f..a5c1ec2ffc580 100644 --- a/libc-test/tests/makedev.rs +++ b/libc-test/tests/makedev.rs @@ -13,7 +13,11 @@ target_os = "cygwin", ))] -use libc::{self, c_uint, dev_t}; +use libc::{ + self, + c_uint, + dev_t, +}; cfg_if::cfg_if! { if #[cfg(any(target_os = "solaris", target_os = "illumos"))] { diff --git a/libc-test/test/semver.rs b/libc-test/tests/semver.rs similarity index 100% rename from libc-test/test/semver.rs rename to libc-test/tests/semver.rs diff --git a/libc-test/test/check_style.rs b/libc-test/tests/style.rs similarity index 95% rename from libc-test/test/check_style.rs rename to libc-test/tests/style.rs index d1d7fdf4aa150..dcbe43bb59651 100644 --- a/libc-test/test/check_style.rs +++ b/libc-test/tests/style.rs @@ -9,12 +9,15 @@ //! cargo test --test style //! ``` -pub mod style; +pub mod style_lib; use std::env; use std::path::Path; -use style::{Result, StyleChecker}; +use style_lib::{ + Result, + StyleChecker, +}; /// Relative to `src/`. const SKIP_PREFIXES: &[&str] = &[ diff --git a/libc-test/test/style/mod.rs b/libc-test/tests/style_lib/mod.rs similarity index 98% rename from libc-test/test/style/mod.rs rename to libc-test/tests/style_lib/mod.rs index cc953d32c3aed..04eec91df635d 100644 --- a/libc-test/test/style/mod.rs +++ b/libc-test/tests/style_lib/mod.rs @@ -28,13 +28,26 @@ use std::collections::HashMap; use std::fs; use std::ops::Deref; -use std::path::{Path, PathBuf}; - -use annotate_snippets::{Level, Renderer, Snippet}; +use std::path::{ + Path, + PathBuf, +}; + +use annotate_snippets::{ + Level, + Renderer, + Snippet, +}; use proc_macro2::Span; -use syn::parse::{Parse, ParseStream}; +use syn::parse::{ + Parse, + ParseStream, +}; use syn::spanned::Spanned; -use syn::visit::{self, Visit}; +use syn::visit::{ + self, + Visit, +}; use syn::Token; const ALLOWED_REPEATED_MACROS: &[&str] = &["s", "s_no_extra_traits", "s_paren"]; diff --git a/libc-test/test/style_tests.rs b/libc-test/tests/style_tests.rs similarity index 99% rename from libc-test/test/style_tests.rs rename to libc-test/tests/style_tests.rs index be8fddbccf644..e136bb66d26a4 100644 --- a/libc-test/test/style_tests.rs +++ b/libc-test/tests/style_tests.rs @@ -1,8 +1,8 @@ //! Verifies the implementation of the style checker in [style]. -use style::StyleChecker; +use style_lib::StyleChecker; -pub mod style; +pub mod style_lib; #[test] fn check_style_accept_correct_module_layout() { diff --git a/src/fuchsia/aarch64.rs b/src/fuchsia/aarch64.rs index 577f0d99cf24d..93090f7238d7a 100644 --- a/src/fuchsia/aarch64.rs +++ b/src/fuchsia/aarch64.rs @@ -15,10 +15,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad0: c_ulong, + __pad0: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad1: c_int, + __pad1: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -26,7 +26,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_uint; 2], + __unused: Padding<[c_uint; 2]>, } pub struct stat64 { @@ -37,10 +37,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad0: c_ulong, + __pad0: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad1: c_int, + __pad1: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -48,7 +48,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_uint; 2], + __unused: Padding<[c_uint; 2]>, } pub struct ipc_perm { @@ -59,8 +59,8 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __unused1: Padding, + __unused2: Padding, } } diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 31f13b16832d2..4ba381cbb6e3a 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -78,32 +78,10 @@ pub type fsblkcnt_t = c_ulonglong; pub type fsfilcnt_t = c_ulonglong; pub type rlim_t = c_ulonglong; -// FIXME(fuchsia): why are these uninhabited types? that seems... wrong? -// Presumably these should be `()` or an `extern type` (when that stabilizes). -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} -#[derive(Debug)] -pub enum DIR {} -impl Copy for DIR {} -impl Clone for DIR { - fn clone(&self) -> DIR { - *self - } -} - -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } +extern_ty! { + pub enum timezone {} + pub enum DIR {} + pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct } // PUB_STRUCT @@ -143,46 +121,46 @@ s! { pub ru_stime: timeval, pub ru_maxrss: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad1: u32, + __pad1: Padding, pub ru_ixrss: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad2: u32, + __pad2: Padding, pub ru_idrss: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad3: u32, + __pad3: Padding, pub ru_isrss: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad4: u32, + __pad4: Padding, pub ru_minflt: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad5: u32, + __pad5: Padding, pub ru_majflt: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad6: u32, + __pad6: Padding, pub ru_nswap: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad7: u32, + __pad7: Padding, pub ru_inblock: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad8: u32, + __pad8: Padding, pub ru_oublock: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad9: u32, + __pad9: Padding, pub ru_msgsnd: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad10: u32, + __pad10: Padding, pub ru_msgrcv: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad11: u32, + __pad11: Padding, pub ru_nsignals: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad12: u32, + __pad12: Padding, pub ru_nvcsw: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad13: u32, + __pad13: Padding, pub ru_nivcsw: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad14: u32, + __pad14: Padding, } pub struct in_addr { @@ -454,11 +432,11 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct ifaddrs { @@ -543,7 +521,7 @@ s! { pub ssi_stime: u64, pub ssi_addr: u64, pub ssi_addr_lsb: u16, - _pad2: u16, + _pad2: Padding, pub ssi_syscall: i32, pub ssi_call_addr: u64, pub ssi_arch: u32, @@ -800,8 +778,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct msqid_ds { @@ -814,8 +792,8 @@ s! { pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct statfs { @@ -838,10 +816,10 @@ s! { pub msg_namelen: crate::socklen_t, pub msg_iov: *mut crate::iovec, pub msg_iovlen: c_int, - __pad1: c_int, + __pad1: Padding, pub msg_control: *mut c_void, pub msg_controllen: crate::socklen_t, - __pad2: crate::socklen_t, + __pad2: Padding, pub msg_flags: c_int, } @@ -902,9 +880,7 @@ s! { pub struct pthread_condattr_t { size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], } -} -s_no_extra_traits! { pub struct sysinfo { pub uptime: c_ulong, pub loads: [c_ulong; 3], @@ -929,7 +905,7 @@ s_no_extra_traits! { pub struct sockaddr_storage { pub ss_family: sa_family_t, - __ss_pad2: [u8; 128 - 2 - 8], + __ss_pad2: Padding<[u8; 128 - 2 - 8]>, __ss_align: size_t, } @@ -986,11 +962,13 @@ s_no_extra_traits! { pub struct sockaddr_nl { pub nl_family: crate::sa_family_t, - nl_pad: c_ushort, + nl_pad: Padding, pub nl_pid: u32, pub nl_groups: u32, } + // FIXME(msrv): suggested method was added in 1.85 + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigevent { pub sigev_value: crate::sigval, pub sigev_signo: c_int, @@ -1045,269 +1023,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sysinfo { - fn eq(&self, other: &sysinfo) -> bool { - self.uptime == other.uptime - && self.loads == other.loads - && self.totalram == other.totalram - && self.freeram == other.freeram - && self.sharedram == other.sharedram - && self.bufferram == other.bufferram - && self.totalswap == other.totalswap - && self.freeswap == other.freeswap - && self.procs == other.procs - && self.pad == other.pad - && self.totalhigh == other.totalhigh - && self.freehigh == other.freehigh - && self.mem_unit == other.mem_unit - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sysinfo {} - impl hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { - self.uptime.hash(state); - self.loads.hash(state); - self.totalram.hash(state); - self.freeram.hash(state); - self.sharedram.hash(state); - self.bufferram.hash(state); - self.totalswap.hash(state); - self.freeswap.hash(state); - self.procs.hash(state); - self.pad.hash(state); - self.totalhigh.hash(state); - self.freehigh.hash(state); - self.mem_unit.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for utsname {} - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent64 {} - impl hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_flags == other.mq_flags - && self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_curmsgs == other.mq_curmsgs - } - } - impl Eq for mq_attr {} - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_flags.hash(state); - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_curmsgs.hash(state); - } - } - - impl PartialEq for sockaddr_nl { - fn eq(&self, other: &sockaddr_nl) -> bool { - self.nl_family == other.nl_family - && self.nl_pid == other.nl_pid - && self.nl_groups == other.nl_groups - } - } - impl Eq for sockaddr_nl {} - impl hash::Hash for sockaddr_nl { - fn hash(&self, state: &mut H) { - self.nl_family.hash(state); - self.nl_pid.hash(state); - self.nl_groups.hash(state); - } - } - - // FIXME(msrv): suggested method was added in 1.85 - #[allow(unpredictable_function_pointer_comparisons)] - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_value == other.sigev_value - && self.sigev_signo == other.sigev_signo - && self.sigev_notify == other.sigev_notify - && self.sigev_notify_function == other.sigev_notify_function - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_value.hash(state); - self.sigev_signo.hash(state); - self.sigev_notify.hash(state); - self.sigev_notify_function.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - impl Eq for pthread_cond_t {} - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - impl Eq for pthread_mutex_t {} - impl hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - impl Eq for pthread_rwlock_t {} - impl hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - } -} - // PUB_CONST pub const INT_MIN: c_int = -2147483648; @@ -1490,9 +1205,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; pub const SIGQUIT: c_int = 3; @@ -3421,21 +3133,9 @@ fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar { #[link(name = "fdio")] extern "C" {} -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct } extern "C" { @@ -4173,7 +3873,7 @@ extern "C" { len: size_t, flags: c_uint, ) -> ssize_t; - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; diff --git a/src/fuchsia/riscv64.rs b/src/fuchsia/riscv64.rs index c57d52aad1386..bc93cc3bff0a9 100644 --- a/src/fuchsia/riscv64.rs +++ b/src/fuchsia/riscv64.rs @@ -17,7 +17,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -28,7 +28,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } // Not actually used, IPC calls just return ENOSYS @@ -40,7 +40,7 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __unused1: Padding, + __unused2: Padding, } } diff --git a/src/fuchsia/x86_64.rs b/src/fuchsia/x86_64.rs index add60a4564020..fc42cd9810985 100644 --- a/src/fuchsia/x86_64.rs +++ b/src/fuchsia/x86_64.rs @@ -14,7 +14,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -25,7 +25,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct stat64 { @@ -35,7 +35,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -46,7 +46,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __reserved: [c_long; 3], + __reserved: Padding<[c_long; 3]>, } pub struct mcontext_t { @@ -61,12 +61,10 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } -} -s_no_extra_traits! { pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -77,36 +75,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - && self - .__private - .iter() - .zip(other.__private.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - self.__private.hash(state); - } - } - } -} - // offsets in user_regs_structs, from sys/reg.h pub const R15: c_int = 0; pub const R14: c_int = 1; diff --git a/src/hermit.rs b/src/hermit.rs index b96be6b0e2a2f..e8699228b6001 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -87,9 +87,9 @@ s! { pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], + __ss_pad1: Padding<[u8; 6]>, __ss_align: i64, - __ss_pad2: [u8; 112], + __ss_pad2: Padding<[u8; 112]>, } pub struct stat { diff --git a/src/lib.rs b/src/lib.rs index aa919b5ca038e..846c2189b79ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,6 @@ #![cfg_attr(libc_deny_warnings, deny(warnings))] // Attributes needed when building as part of the standard library #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] -#![cfg_attr(libc_thread_local, feature(thread_local))] #![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))] // DIFF(1.0): The thread local references that raise this lint were removed in 1.0 #![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))] diff --git a/src/macros.rs b/src/macros.rs index 6906da6bd70da..019a15a2ec728 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -76,26 +76,60 @@ macro_rules! prelude { #[allow(unused_imports)] pub(crate) use core::default::Default; #[allow(unused_imports)] - pub(crate) use core::marker::{Copy, Send, Sync}; + pub(crate) use core::marker::{ + Copy, + Send, + Sync, + }; #[allow(unused_imports)] pub(crate) use core::option::Option; #[allow(unused_imports)] pub(crate) use core::prelude::v1::derive; #[allow(unused_imports)] - pub(crate) use core::{fmt, hash, iter, mem, ptr}; + pub(crate) use core::{ + cfg, + fmt, + hash, + iter, + mem, + ptr, + }; #[allow(unused_imports)] pub(crate) use fmt::Debug; #[allow(unused_imports)] - pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val}; + pub(crate) use mem::{ + align_of, + align_of_val, + size_of, + size_of_val, + }; #[allow(unused_imports)] - pub(crate) use crate::types::{CEnumRepr, Padding}; + pub(crate) use crate::types::{ + CEnumRepr, + Padding, + }; // Commonly used types defined in this crate #[allow(unused_imports)] pub(crate) use crate::{ - c_char, c_double, c_float, c_int, c_long, c_longlong, c_short, c_uchar, c_uint, - c_ulong, c_ulonglong, c_ushort, c_void, intptr_t, size_t, ssize_t, uintptr_t, + c_char, + c_double, + c_float, + c_int, + c_long, + c_longlong, + c_short, + c_uchar, + c_uint, + c_ulong, + c_ulonglong, + c_ushort, + c_void, + intptr_t, + size_t, + ssize_t, + uintptr_t, }; } }; @@ -109,30 +143,30 @@ macro_rules! prelude { macro_rules! s { ($( $(#[$attr:meta])* - pub $t:ident $i:ident { $($field:tt)* } + $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s!(it: $(#[$attr])* pub $t $i { $($field)* }); + s!(it: $(#[$attr])* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( + (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead"); ); - (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( + (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] - #[cfg_attr( - feature = "extra_traits", - ::core::prelude::v1::derive(Eq, Hash, PartialEq) - )] #[::core::prelude::v1::derive( ::core::clone::Clone, ::core::marker::Copy, ::core::fmt::Debug, )] + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] #[allow(deprecated)] $(#[$attr])* - pub struct $i { $($field)* } + $pub struct $i { $($field)* } } ); } @@ -169,17 +203,17 @@ macro_rules! s_paren { macro_rules! s_no_extra_traits { ($( $(#[$attr:meta])* - pub $t:ident $i:ident { $($field:tt)* } + $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* }); + s_no_extra_traits!(it: $(#[$attr])* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( + (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] $(#[$attr])* - pub union $i { $($field)* } + $pub union $i { $($field)* } } impl ::core::fmt::Debug for $i { @@ -189,7 +223,7 @@ macro_rules! s_no_extra_traits { } ); - (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( + (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] #[::core::prelude::v1::derive( @@ -198,20 +232,30 @@ macro_rules! s_no_extra_traits { ::core::fmt::Debug, )] $(#[$attr])* - pub struct $i { $($field)* } + $pub struct $i { $($field)* } } ); } -/// Specify that an enum should have no traits that aren't specified in the macro -/// invocation, i.e. no `Clone` or `Copy`. -macro_rules! missing { +/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, +/// and `Copy`, but these aren't meaningful for extern types so they should eventually +/// be removed. +/// +/// Really what we want here is something that also can't be named without indirection (in +/// ADTs or function signatures), but this doesn't exist. +macro_rules! extern_ty { ($( $(#[$attr:meta])* pub enum $i:ident {} )*) => ($( $(#[$attr])* - #[allow(missing_copy_implementations)] + // FIXME(1.0): the type is uninhabited so these traits are unreachable and could be + // removed. + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] pub enum $i { } )*); } @@ -246,40 +290,68 @@ macro_rules! e { /// unlisted values, but this is UB in Rust. This enum doesn't implement any traits, its main /// purpose is to calculate the correct enum values. /// +/// Use the magic name `#anon` if the C enum doesn't create a type. +/// /// See for more. macro_rules! c_enum { + // Matcher for multiple enums ($( $(#[repr($repr:ty)])? - pub enum $ty_name:ident { - $($variant:ident $(= $value:expr)?,)+ + pub enum $($ty_name:ident)? $(#$anon:ident)? { + $($vis:vis $variant:ident $(= $value:expr)?,)+ } )+) => { - $(c_enum!(@expand; + $(c_enum!(@single; $(#[repr($repr)])? - pub enum $ty_name { - $($variant $(= $value)?,)+ + pub enum $($ty_name)? $(#$anon)? { + $($vis $variant $(= $value)?,)+ } );)+ }; - (@expand; + // Matcher for a single enum + (@single; $(#[repr($repr:ty)])? pub enum $ty_name:ident { - $($variant:ident $(= $value:expr)?,)+ + $($vis:vis $variant:ident $(= $value:expr)?,)+ } ) => { pub type $ty_name = c_enum!(@ty $($repr)?); - c_enum!(@one; $ty_name; 0; $($variant $(= $value)?,)+); + c_enum! { + @variant; + ty: $ty_name; + default: 0; + variants: [$($vis $variant $(= $value)?,)+] + } }; - // Matcher for a single variant - (@one; $_ty_name:ident; $_idx:expr;) => {}; + // Matcher for a single anonymous enum + (@single; + $(#[repr($repr:ty)])? + pub enum #anon { + $($vis:vis $variant:ident $(= $value:expr)?,)+ + } + ) => { + c_enum! { + @variant; + ty: c_enum!(@ty $($repr)?); + default: 0; + variants: [$($vis $variant $(= $value)?,)+] + } + }; + + // Matcher for variants: eats a single variant then recurses with the rest + (@variant; ty: $_ty_name:ty; default: $_idx:expr; variants: []) => { /* end of the chain */ }; ( - @one; $ty_name:ident; $default_val:expr; - $variant:ident $(= $value:expr)?, - $($tail:tt)* + @variant; + ty: $ty_name:ty; + default: $default_val:expr; + variants: [ + $vis:vis $variant:ident $(= $value:expr)?, + $($tail:tt)* + ] ) => { - pub const $variant: $ty_name = { + $vis const $variant: $ty_name = { #[allow(unused_variables)] let r = $default_val; $(let r = $value;)? @@ -288,7 +360,12 @@ macro_rules! c_enum { // The next value is always one more than the previous value, unless // set explicitly. - c_enum!(@one; $ty_name; $variant + 1; $($tail)*); + c_enum! { + @variant; + ty: $ty_name; + default: $variant + 1; + variants: [$($tail)*] + } }; // Use a specific type if provided, otherwise default to `CEnumRepr` @@ -370,12 +447,31 @@ macro_rules! deprecated_mach { } } +/// Polyfill for std's `offset_of`. +// FIXME(msrv): stabilized in std in 1.77 +macro_rules! offset_of { + ($Ty:path, $field:ident) => {{ + // Taken from bytemuck, avoids accidentally calling on deref + #[allow(clippy::unneeded_field_pattern)] + let $Ty { $field: _, .. }; + let data = core::mem::MaybeUninit::<$Ty>::uninit(); + let ptr = data.as_ptr(); + // SAFETY: computed address is inbounds since we have a stack alloc for T + let fptr = unsafe { core::ptr::addr_of!((*ptr).$field) }; + let off = (fptr as usize).checked_sub(ptr as usize).unwrap(); + assert!(off <= core::mem::size_of::<$Ty>()); + off + }}; +} + #[cfg(test)] mod tests { + use core::any::TypeId; + use crate::types::CEnumRepr; #[test] - fn c_enumbasic() { + fn c_enum_basic() { // By default, variants get sequential values. c_enum! { pub enum e { @@ -383,28 +479,50 @@ mod tests { VAR1, VAR2, } + + // Also check enums that don't create a type. + pub enum #anon { + ANON0, + ANON1, + ANON2, + } } + assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(VAR0, 0 as CEnumRepr); assert_eq!(VAR1, 1 as CEnumRepr); assert_eq!(VAR2, 2 as CEnumRepr); + + assert_eq!(type_id_of_val(&ANON0), TypeId::of::()); + assert_eq!(ANON0, 0 as CEnumRepr); + assert_eq!(ANON1, 1 as CEnumRepr); + assert_eq!(ANON2, 2 as CEnumRepr); } #[test] - fn c_enumrepr() { - // By default, variants get sequential values. + fn c_enum_repr() { + // Check specifying the integer representation c_enum! { #[repr(u16)] pub enum e { VAR0, } + + #[repr(u16)] + pub enum #anon { + ANON0, + } } + assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(VAR0, 0_u16); + + assert_eq!(type_id_of_val(&ANON0), TypeId::of::()); + assert_eq!(ANON0, 0_u16); } #[test] - fn c_enumset_value() { + fn c_enum_set_value() { // Setting an explicit value resets the count. c_enum! { pub enum e { @@ -420,7 +538,7 @@ mod tests { } #[test] - fn c_enummultiple_set_value() { + fn c_enum_multiple_set_value() { // C enums always take one more than the previous value, unless set to a specific // value. Duplicates are allowed. c_enum! { @@ -443,4 +561,100 @@ mod tests { assert_eq!(VAR3_1, 3 as CEnumRepr); assert_eq!(VAR4_1, 4 as CEnumRepr); } + + #[test] + fn c_enum_vis() { + mod priv1 { + c_enum! { + #[repr(u8)] + pub enum e1 { + PRIV_ON_1 = 10, + // Variant should still be usable within its visibility + pub PUB1 = PRIV_ON_1 * 2, + } + } + } + mod priv2 { + c_enum! { + #[repr(u16)] + pub enum e2 { + pub PRIV_ON_1 = 42, + pub PUB2 = PRIV_ON_1 * 2, + } + } + } + + use priv1::*; + use priv2::*; + + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(PUB1, 10u8 * 2); + assert_eq!(PUB2, 42u16 * 2); + // Verify that the default is private. If `PRIV_ON_1` was actually public in `priv1`, this + // would be an ambiguous import and/or type mismatch error. + assert_eq!(PRIV_ON_1, 42u16); + } + + fn type_id_of_val(_: &T) -> TypeId { + TypeId::of::() + } + + #[test] + fn test_offset_of() { + #[repr(C)] + struct Off1 { + a: u8, + b: u32, + c: Off2, + d: u64, + } + + #[repr(C)] + #[repr(align(128))] + struct Off2 {} + + assert_eq!(core::mem::offset_of!(Off1, a), offset_of!(Off1, a)); + assert_eq!(core::mem::offset_of!(Off1, b), offset_of!(Off1, b)); + assert_eq!(core::mem::offset_of!(Off1, c), offset_of!(Off1, c)); + assert_eq!(core::mem::offset_of!(Off1, d), offset_of!(Off1, d)); + } +} + +#[cfg(test)] +#[allow(unused)] +mod macro_checks { + s! { + pub struct S1 { + pub a: u32, + b: u32, + } + + struct S1Priv { + pub a: u32, + b: u32, + } + } + + s_no_extra_traits! { + pub struct S2 { + pub a: u32, + b: u32, + } + + struct S2Priv { + pub a: u32, + b: u32, + } + + pub union U2 { + pub a: u32, + b: f32, + } + + union U2Priv { + pub a: u32, + b: f32, + } + } } diff --git a/src/new/aix/mod.rs b/src/new/aix/mod.rs new file mode 100644 index 0000000000000..c99b206b71688 --- /dev/null +++ b/src/new/aix/mod.rs @@ -0,0 +1,6 @@ +//! IBM AIX libc. +//! +//! * Headers are not public +//! * Manual pages: (under "Technical reference" for that version) + +pub(crate) mod unistd; diff --git a/src/new/aix/unistd.rs b/src/new/aix/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/aix/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/apple/libc/signal.rs b/src/new/apple/libc/signal.rs new file mode 100644 index 0000000000000..b5f8d59b2d7f3 --- /dev/null +++ b/src/new/apple/libc/signal.rs @@ -0,0 +1,5 @@ +//! Header: `signal.h` +//! +//! + +pub use crate::sys::signal::*; diff --git a/src/new/apple/libc/unistd.rs b/src/new/apple/libc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/apple/libc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/apple/libpthread/mod.rs b/src/new/apple/libpthread/mod.rs new file mode 100644 index 0000000000000..66f25e6f7ba48 --- /dev/null +++ b/src/new/apple/libpthread/mod.rs @@ -0,0 +1,20 @@ +//! Source from libpthread + +/// Directory: `pthread/` +/// +/// Note that this module has a trailing underscore to avoid conflicting with its child `pthread` +/// module. +/// +/// +pub(crate) mod pthread_ { + pub(crate) mod introspection; + pub(crate) mod pthread; + pub(crate) mod pthread_impl; + pub(crate) mod pthread_spis; + pub(crate) mod qos; + pub(crate) mod sched; + pub(crate) mod spawn; + pub(crate) mod stack_np; +} + +pub(crate) mod sys; diff --git a/src/new/apple/libpthread/pthread_/introspection.rs b/src/new/apple/libpthread/pthread_/introspection.rs new file mode 100644 index 0000000000000..6509e22be3c08 --- /dev/null +++ b/src/new/apple/libpthread/pthread_/introspection.rs @@ -0,0 +1,36 @@ +//! Header: `pthread/introspection.h` +//! +//! + +use crate::prelude::*; +pub use crate::pthread_::pthread::*; + +c_enum! { + #[repr(c_uint)] + pub enum #anon { + pub PTHREAD_INTROSPECTION_THREAD_CREATE = 1, + pub PTHREAD_INTROSPECTION_THREAD_START, + pub PTHREAD_INTROSPECTION_THREAD_TERMINATE, + pub PTHREAD_INTROSPECTION_THREAD_DESTROY, + } +} + +pub type pthread_introspection_hook_t = + extern "C" fn(event: c_uint, thread: pthread_t, addr: *mut c_void, size: size_t); + +extern "C" { + // Available from Big Sur + pub fn pthread_introspection_hook_install( + hook: pthread_introspection_hook_t, + ) -> pthread_introspection_hook_t; + pub fn pthread_introspection_setspecific_np( + thread: pthread_t, + key: pthread_key_t, + value: *const c_void, + ) -> c_int; + + pub fn pthread_introspection_getspecific_np( + thread: pthread_t, + key: pthread_key_t, + ) -> *mut c_void; +} diff --git a/src/new/apple/libpthread/pthread_/pthread.rs b/src/new/apple/libpthread/pthread_/pthread.rs new file mode 100644 index 0000000000000..a7e56bef8f11b --- /dev/null +++ b/src/new/apple/libpthread/pthread_/pthread.rs @@ -0,0 +1,76 @@ +//! Header: `pthread.h` or `pthread/pthread.h` +//! +//! + +use crate::prelude::*; +pub use crate::pthread_::qos::*; +pub use crate::pthread_::sched::*; +// No need to import from the `_pthread_attr_t` and similar modules since `_pthread_types` has +// everything we need. +pub use crate::sys::_pthread::_pthread_types::*; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 1; +pub const PTHREAD_CREATE_DETACHED: c_int = 2; + +pub const PTHREAD_INHERIT_SCHED: c_int = 1; +pub const PTHREAD_EXPLICIT_SCHED: c_int = 2; + +pub const PTHREAD_CANCEL_ENABLE: c_int = 0x01; +pub const PTHREAD_CANCEL_DISABLE: c_int = 0x00; +pub const PTHREAD_CANCEL_DEFERRED: c_int = 0x02; +pub const PTHREAD_CANCEL_ASYNCHRONOUS: c_int = 0x00; + +pub const PTHREAD_CANCELED: *mut c_void = 1 as *mut c_void; + +pub const PTHREAD_SCOPE_SYSTEM: c_int = 1; +pub const PTHREAD_SCOPE_PROCESS: c_int = 2; + +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 2; + +pub const PTHREAD_PRIO_NONE: c_int = 0; +pub const PTHREAD_PRIO_INHERIT: c_int = 1; +pub const PTHREAD_PRIO_PROTECT: c_int = 2; + +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; + +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __sig: _PTHREAD_RWLOCK_SIG_init, + __opaque: [0; __PTHREAD_RWLOCK_SIZE__], +}; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __sig: _PTHREAD_MUTEX_SIG_init, + __opaque: [0; __PTHREAD_MUTEX_SIZE__], +}; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __sig: _PTHREAD_COND_SIG_init, + __opaque: [0; __PTHREAD_COND_SIZE__], +}; + +pub const PTHREAD_ONCE_INIT: crate::pthread_once_t = crate::pthread_once_t { + __sig: _PTHREAD_ONCE_SIG_INIT, + __opaque: [0; __PTHREAD_ONCE_SIZE__], +}; + +pub use crate::new::common::posix::pthread::{ + pthread_attr_getinheritsched, + pthread_attr_getschedparam, + pthread_attr_getschedpolicy, + pthread_attr_setinheritsched, + pthread_attr_setschedparam, + pthread_attr_setschedpolicy, + pthread_condattr_getpshared, + pthread_condattr_setpshared, + pthread_getschedparam, + pthread_mutexattr_getpshared, + pthread_mutexattr_setpshared, + pthread_once, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, +}; diff --git a/src/new/apple/libpthread/pthread_/pthread_impl.rs b/src/new/apple/libpthread/pthread_/pthread_impl.rs new file mode 100644 index 0000000000000..92c5e2733c44e --- /dev/null +++ b/src/new/apple/libpthread/pthread_/pthread_impl.rs @@ -0,0 +1,12 @@ +use crate::prelude::*; + +// FIXME(apple): these should all be `pub(crate)` +pub const _PTHREAD_MUTEX_SIG_init: c_long = 0x32AAABA7; + +pub const _PTHREAD_COND_SIG_init: c_long = 0x3CB0B1BB; +pub(crate) const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; +pub const _PTHREAD_RWLOCK_SIG_init: c_long = 0x2DA8B3B4; + +pub const SCHED_OTHER: c_int = 1; +pub const SCHED_FIFO: c_int = 4; +pub const SCHED_RR: c_int = 2; diff --git a/src/new/apple/libpthread/pthread_/pthread_spis.rs b/src/new/apple/libpthread/pthread_/pthread_spis.rs new file mode 100644 index 0000000000000..24e3fedc9d307 --- /dev/null +++ b/src/new/apple/libpthread/pthread_/pthread_spis.rs @@ -0,0 +1,14 @@ +//! Header: `pthread/pthread_spis.h` +//! +//! + +use crate::prelude::*; + +extern "C" { + pub fn pthread_create_from_mach_thread( + thread: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; +} diff --git a/src/new/apple/libpthread/pthread_/qos.rs b/src/new/apple/libpthread/pthread_/qos.rs new file mode 100644 index 0000000000000..8b68c78ffb826 --- /dev/null +++ b/src/new/apple/libpthread/pthread_/qos.rs @@ -0,0 +1,25 @@ +//! Header: `pthread/qos.h` +//! +//! + +use crate::prelude::*; +pub use crate::sys::qos::*; + +extern "C" { + pub fn pthread_attr_set_qos_class_np( + attr: *mut crate::pthread_attr_t, + class: qos_class_t, + priority: c_int, + ) -> c_int; + pub fn pthread_attr_get_qos_class_np( + attr: *mut crate::pthread_attr_t, + class: *mut qos_class_t, + priority: *mut c_int, + ) -> c_int; + pub fn pthread_set_qos_class_self_np(class: qos_class_t, priority: c_int) -> c_int; + pub fn pthread_get_qos_class_np( + thread: crate::pthread_t, + class: *mut qos_class_t, + priority: *mut c_int, + ) -> c_int; +} diff --git a/src/new/apple/libpthread/pthread_/sched.rs b/src/new/apple/libpthread/pthread_/sched.rs new file mode 100644 index 0000000000000..d25a6cb082755 --- /dev/null +++ b/src/new/apple/libpthread/pthread_/sched.rs @@ -0,0 +1,9 @@ +pub use crate::new::pthread_::pthread_impl::*; +use crate::prelude::*; + +s! { + pub struct sched_param { + pub sched_priority: c_int, + __opaque: [c_char; 4], + } +} diff --git a/src/new/apple/libpthread/pthread_/spawn.rs b/src/new/apple/libpthread/pthread_/spawn.rs new file mode 100644 index 0000000000000..c5bdb7ababf10 --- /dev/null +++ b/src/new/apple/libpthread/pthread_/spawn.rs @@ -0,0 +1,16 @@ +//! Header: `pthread/spawn.h` +//! +//! + +use crate::prelude::*; + +extern "C" { + pub fn posix_spawnattr_set_qos_class_np( + attr: *mut crate::posix_spawnattr_t, + qos_class: crate::qos_class_t, + ) -> c_int; + pub fn posix_spawnattr_get_qos_class_np( + attr: *const crate::posix_spawnattr_t, + qos_class: *mut crate::qos_class_t, + ) -> c_int; +} diff --git a/src/new/apple/libpthread/pthread_/stack_np.rs b/src/new/apple/libpthread/pthread_/stack_np.rs new file mode 100644 index 0000000000000..0d501cdbb6f0b --- /dev/null +++ b/src/new/apple/libpthread/pthread_/stack_np.rs @@ -0,0 +1,12 @@ +//! Header: `pthread/stack_np.h` +//! +//! + +use crate::prelude::*; + +extern "C" { + pub fn pthread_stack_frame_decode_np( + frame_addr: uintptr_t, + return_addr: *mut uintptr_t, + ) -> uintptr_t; +} diff --git a/src/new/apple/libpthread/sys/_pthread/_pthread_types.rs b/src/new/apple/libpthread/sys/_pthread/_pthread_types.rs new file mode 100644 index 0000000000000..95e181c13f05d --- /dev/null +++ b/src/new/apple/libpthread/sys/_pthread/_pthread_types.rs @@ -0,0 +1,79 @@ +//! Header: `sys/_pthread/_pthread_types.h` +//! +//! +//! +//! Note that the actual header defines `_opaque_pthread_*` structs which are typedefed to +//! `__darwin_pthread*` structs, and typedefed again in separate `_pthread_*.h` files to their final +//! `pthread_` name. This isn't useful for us so we simplify a bit and just define everything here. + +use crate::prelude::*; + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const __PTHREAD_SIZE__: usize = 8176; + pub const __PTHREAD_ATTR_SIZE__: usize = 56; + pub const __PTHREAD_MUTEXATTR_SIZE__: usize = 8; + pub const __PTHREAD_MUTEX_SIZE__: usize = 56; + pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; + pub const __PTHREAD_COND_SIZE__: usize = 40; + pub const __PTHREAD_ONCE_SIZE__: usize = 8; + pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; + pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16; + } else { + pub const __PTHREAD_SIZE__: usize = 4088; + pub const __PTHREAD_ATTR_SIZE__: usize = 36; + pub const __PTHREAD_MUTEXATTR_SIZE__: usize = 8; + pub const __PTHREAD_MUTEX_SIZE__: usize = 40; + pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; + pub const __PTHREAD_COND_SIZE__: usize = 24; + pub const __PTHREAD_ONCE_SIZE__: usize = 4; + pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; + pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12; + } +} + +s! { + pub struct pthread_attr_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [c_char; __PTHREAD_ATTR_SIZE__], + } + + pub struct pthread_cond_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_COND_SIZE__], + } + + pub struct pthread_condattr_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_CONDATTR_SIZE__], + } + + pub struct pthread_mutex_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_MUTEX_SIZE__], + } + + pub struct pthread_mutexattr_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_MUTEXATTR_SIZE__], + } + + pub struct pthread_once_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [c_char; __PTHREAD_ONCE_SIZE__], + } + + pub struct pthread_rwlock_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], + } + + pub struct pthread_rwlockattr_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_RWLOCKATTR_SIZE__], + } +} + +pub type pthread_key_t = c_ulong; + +pub use crate::pthread_t; diff --git a/src/new/apple/libpthread/sys/mod.rs b/src/new/apple/libpthread/sys/mod.rs new file mode 100644 index 0000000000000..da0a229547cb2 --- /dev/null +++ b/src/new/apple/libpthread/sys/mod.rs @@ -0,0 +1,14 @@ +//! Directory: `sys/` +//! +//! + +/// Directory: `sys/_pthread/` +/// +/// +pub(crate) mod _pthread { + // We don't have the `_pthread_attr_t` and similar modules to match `_pthread_attr_t.h`, + // everything is defined in `_pthread_types`. + pub(crate) mod _pthread_types; +} + +pub(crate) mod qos; diff --git a/src/new/apple/libpthread/sys/qos.rs b/src/new/apple/libpthread/sys/qos.rs new file mode 100644 index 0000000000000..9d9a2eb3dfcb9 --- /dev/null +++ b/src/new/apple/libpthread/sys/qos.rs @@ -0,0 +1,22 @@ +//! Header: `sys/qos.h` +//! +//! + +use crate::prelude::*; + +#[derive(Debug)] +#[repr(u32)] +pub enum qos_class_t { + QOS_CLASS_USER_INTERACTIVE = 0x21, + QOS_CLASS_USER_INITIATED = 0x19, + QOS_CLASS_DEFAULT = 0x15, + QOS_CLASS_UTILITY = 0x11, + QOS_CLASS_BACKGROUND = 0x09, + QOS_CLASS_UNSPECIFIED = 0x00, +} +impl Copy for qos_class_t {} +impl Clone for qos_class_t { + fn clone(&self) -> qos_class_t { + *self + } +} diff --git a/src/new/apple/mod.rs b/src/new/apple/mod.rs new file mode 100644 index 0000000000000..beb8caab63c20 --- /dev/null +++ b/src/new/apple/mod.rs @@ -0,0 +1,20 @@ +//! Apple interfaces. +//! +//! The Xcode SDK includes interfaces that are split across a couple of different libraries. Most +//! of these are available at . + +/// Entrypoint for Apple headers, usually found as part of the Xcode SDK. +/// +/// +mod libc { + pub(crate) mod signal; + pub(crate) mod unistd; +} + +mod libpthread; +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/apple/xnu/arm/_mcontext.rs b/src/new/apple/xnu/arm/_mcontext.rs new file mode 100644 index 0000000000000..ae22f7a4ec777 --- /dev/null +++ b/src/new/apple/xnu/arm/_mcontext.rs @@ -0,0 +1,15 @@ +//! Header: `arm/_mcontext.h` +//! +//! + +pub use crate::mach::machine::_structs::*; + +s! { + pub struct __darwin_mcontext64 { + pub __es: __darwin_arm_exception_state64, + pub __ss: __darwin_arm_thread_state64, + pub __ns: __darwin_arm_neon_state64, + } +} + +pub type mcontext_t = *mut __darwin_mcontext64; diff --git a/src/new/apple/xnu/i386/_mcontext.rs b/src/new/apple/xnu/i386/_mcontext.rs new file mode 100644 index 0000000000000..2b07ad1bf6e64 --- /dev/null +++ b/src/new/apple/xnu/i386/_mcontext.rs @@ -0,0 +1,15 @@ +//! Header: `i386/_mcontext.h` +//! +//! + +pub use crate::mach::machine::_structs::*; + +s! { + pub struct __darwin_mcontext64 { + pub __es: __darwin_x86_exception_state64, + pub __ss: __darwin_x86_thread_state64, + pub __fs: __darwin_x86_float_state64, + } +} + +pub type mcontext_t = *mut __darwin_mcontext64; diff --git a/src/new/apple/xnu/mach/arm/_structs.rs b/src/new/apple/xnu/mach/arm/_structs.rs new file mode 100644 index 0000000000000..c0ebce437aedd --- /dev/null +++ b/src/new/apple/xnu/mach/arm/_structs.rs @@ -0,0 +1,37 @@ +//! Header: `arm/_structs.h` +//! +//! + +#[cfg(target_arch = "arm")] +use crate::prelude::*; + +s! { + pub struct __darwin_arm_exception_state64 { + pub __far: u64, + pub __esr: u32, + pub __exception: u32, + } + + pub struct __darwin_arm_thread_state64 { + pub __x: [u64; 29], + pub __fp: u64, + pub __lr: u64, + pub __sp: u64, + pub __pc: u64, + pub __cpsr: u32, + pub __pad: u32, + } + + #[cfg(target_arch = "aarch64")] + pub struct __darwin_arm_neon_state64 { + pub __v: [crate::__uint128_t; 32], + pub __fpsr: u32, + pub __fpcr: u32, + } + + #[cfg(target_arch = "arm")] + #[repr(align(16))] + pub struct __darwin_arm_neon_state64 { + opaque: [c_char; (32 * 16) + (2 * size_of::())], + } +} diff --git a/src/new/apple/xnu/mach/i386/_structs.rs b/src/new/apple/xnu/mach/i386/_structs.rs new file mode 100644 index 0000000000000..15822f7710de8 --- /dev/null +++ b/src/new/apple/xnu/mach/i386/_structs.rs @@ -0,0 +1,92 @@ +//! Header: `i386/_structs.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct __darwin_mmst_reg { + pub __mmst_reg: [c_char; 10], + pub __mmst_rsrv: [c_char; 6], + } + + pub struct __darwin_xmm_reg { + pub __xmm_reg: [c_char; 16], + } + + pub struct __darwin_x86_thread_state64 { + pub __rax: u64, + pub __rbx: u64, + pub __rcx: u64, + pub __rdx: u64, + pub __rdi: u64, + pub __rsi: u64, + pub __rbp: u64, + pub __rsp: u64, + pub __r8: u64, + pub __r9: u64, + pub __r10: u64, + pub __r11: u64, + pub __r12: u64, + pub __r13: u64, + pub __r14: u64, + pub __r15: u64, + pub __rip: u64, + pub __rflags: u64, + pub __cs: u64, + pub __fs: u64, + pub __gs: u64, + } + + pub struct __darwin_x86_exception_state64 { + pub __trapno: u16, + pub __cpu: u16, + pub __err: u32, + pub __faultvaddr: u64, + } + + pub struct __darwin_x86_float_state64 { + pub __fpu_reserved: [c_int; 2], + __fpu_fcw: c_short, + __fpu_fsw: c_short, + pub __fpu_ftw: u8, + pub __fpu_rsrv1: u8, + pub __fpu_fop: u16, + pub __fpu_ip: u32, + pub __fpu_cs: u16, + pub __fpu_rsrv2: u16, + pub __fpu_dp: u32, + pub __fpu_ds: u16, + pub __fpu_rsrv3: u16, + pub __fpu_mxcsr: u32, + pub __fpu_mxcsrmask: u32, + pub __fpu_stmm0: __darwin_mmst_reg, + pub __fpu_stmm1: __darwin_mmst_reg, + pub __fpu_stmm2: __darwin_mmst_reg, + pub __fpu_stmm3: __darwin_mmst_reg, + pub __fpu_stmm4: __darwin_mmst_reg, + pub __fpu_stmm5: __darwin_mmst_reg, + pub __fpu_stmm6: __darwin_mmst_reg, + pub __fpu_stmm7: __darwin_mmst_reg, + pub __fpu_xmm0: __darwin_xmm_reg, + pub __fpu_xmm1: __darwin_xmm_reg, + pub __fpu_xmm2: __darwin_xmm_reg, + pub __fpu_xmm3: __darwin_xmm_reg, + pub __fpu_xmm4: __darwin_xmm_reg, + pub __fpu_xmm5: __darwin_xmm_reg, + pub __fpu_xmm6: __darwin_xmm_reg, + pub __fpu_xmm7: __darwin_xmm_reg, + pub __fpu_xmm8: __darwin_xmm_reg, + pub __fpu_xmm9: __darwin_xmm_reg, + pub __fpu_xmm10: __darwin_xmm_reg, + pub __fpu_xmm11: __darwin_xmm_reg, + pub __fpu_xmm12: __darwin_xmm_reg, + pub __fpu_xmm13: __darwin_xmm_reg, + pub __fpu_xmm14: __darwin_xmm_reg, + pub __fpu_xmm15: __darwin_xmm_reg, + // FIXME(apple): this field is actually [u8; 96], but defining it with a bigger type allows + // us to auto-implement traits for it since the length of the array is less than 32 + __fpu_rsrv4: [u32; 24], + pub __fpu_reserved1: c_int, + } +} diff --git a/src/new/apple/xnu/mach/machine/_structs.rs b/src/new/apple/xnu/mach/machine/_structs.rs new file mode 100644 index 0000000000000..6acae8d9acbd7 --- /dev/null +++ b/src/new/apple/xnu/mach/machine/_structs.rs @@ -0,0 +1,13 @@ +//! Header: `mach/machine/_structs.h` +//! +//! + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub use crate::mach::i386::_structs::*; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub use crate::mach::arm::_structs::*; + } else { + // Unsupported arch + } +} diff --git a/src/new/apple/xnu/mach/mod.rs b/src/new/apple/xnu/mach/mod.rs new file mode 100644 index 0000000000000..90751260a7a7c --- /dev/null +++ b/src/new/apple/xnu/mach/mod.rs @@ -0,0 +1,20 @@ +//! Directory: `mach/` +//! +//! + +/// Directory: `mach/arm` +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +pub(crate) mod arm { + pub(crate) mod _structs; +} + +/// Directory: `mach/i386` +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(crate) mod i386 { + pub(crate) mod _structs; +} + +/// Directory: `mach/machine` +pub(crate) mod machine { + pub(crate) mod _structs; +} diff --git a/src/new/apple/xnu/machine/_mcontext.rs b/src/new/apple/xnu/machine/_mcontext.rs new file mode 100644 index 0000000000000..004b94707e33a --- /dev/null +++ b/src/new/apple/xnu/machine/_mcontext.rs @@ -0,0 +1,11 @@ +//! Header: `machine/_mcontext.h` + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub use crate::i386::_mcontext::*; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub use crate::arm::_mcontext::*; + } else { + // Unsupported arch + } +} diff --git a/src/new/apple/xnu/mod.rs b/src/new/apple/xnu/mod.rs new file mode 100644 index 0000000000000..8b8afb6bc39d3 --- /dev/null +++ b/src/new/apple/xnu/mod.rs @@ -0,0 +1,30 @@ +//! Source from XNU +//! +//! We omit nesting for the `bsd` module since most items of interest are in there. + +/// Directory: `arm/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/arm +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +pub(crate) mod arm { + pub(crate) mod _mcontext; +} + +/// Directory: `i386/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/i386 +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(crate) mod i386 { + pub(crate) mod _mcontext; +} + +pub(crate) mod mach; + +/// Directory: `machine/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/machine +pub(crate) mod machine { + pub(crate) mod _mcontext; +} + +pub(crate) mod sys; diff --git a/src/new/apple/xnu/sys/_types/_ucontext.rs b/src/new/apple/xnu/sys/_types/_ucontext.rs new file mode 100644 index 0000000000000..53bc0f22d6691 --- /dev/null +++ b/src/new/apple/xnu/sys/_types/_ucontext.rs @@ -0,0 +1,17 @@ +//! Header: `sys/_types/_ucontext.h` + +pub use crate::machine::_mcontext::*; +use crate::prelude::*; + +s! { + pub struct __darwin_ucontext { + pub uc_onstack: c_int, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: crate::stack_t, + pub uc_link: *mut ucontext_t, + pub uc_mcsize: usize, + pub uc_mcontext: mcontext_t, + } +} + +pub type ucontext_t = __darwin_ucontext; diff --git a/src/new/apple/xnu/sys/mod.rs b/src/new/apple/xnu/sys/mod.rs new file mode 100644 index 0000000000000..ad4a204898cb8 --- /dev/null +++ b/src/new/apple/xnu/sys/mod.rs @@ -0,0 +1,15 @@ +//! Directory: `sys/` +//! +//! + +pub(crate) mod signal; + +/// Directory: `sys/_types` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys/_types +pub(crate) mod _types { + pub(crate) mod _ucontext; +} + +// Bit of a hack since the directories get merged and we can't have >1 sys module. +pub(crate) use crate::new::apple::libpthread::sys::*; diff --git a/src/new/apple/xnu/sys/signal.rs b/src/new/apple/xnu/sys/signal.rs new file mode 100644 index 0000000000000..844793e119b31 --- /dev/null +++ b/src/new/apple/xnu/sys/signal.rs @@ -0,0 +1,6 @@ +//! Header: `sys/signal.h` +//! +//! + +pub use crate::machine::_mcontext::*; +pub use crate::sys::_types::_ucontext::*; diff --git a/src/new/bionic/mod.rs b/src/new/bionic/mod.rs deleted file mode 100644 index 644a4ab96d90f..0000000000000 --- a/src/new/bionic/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod sys; -pub use sys::*; diff --git a/src/new/bionic/sys/mod.rs b/src/new/bionic/sys/mod.rs deleted file mode 100644 index fd96d0821ac88..0000000000000 --- a/src/new/bionic/sys/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod socket; -pub use socket::*; diff --git a/src/new/bionic_libc/mod.rs b/src/new/bionic_libc/mod.rs new file mode 100644 index 0000000000000..1dd186e4f940f --- /dev/null +++ b/src/new/bionic_libc/mod.rs @@ -0,0 +1,7 @@ +//! This directory maps to `bionic/libc/include` in the Android source. +//! +//! + +pub(crate) mod pthread; +pub(crate) mod sys; +pub(crate) mod unistd; diff --git a/src/new/bionic_libc/pthread.rs b/src/new/bionic_libc/pthread.rs new file mode 100644 index 0000000000000..4997547ff0905 --- /dev/null +++ b/src/new/bionic_libc/pthread.rs @@ -0,0 +1,42 @@ +//! Header: `unistd.h` + +pub use crate::new::common::linux_like::pthread::{ + pthread_getattr_np, + pthread_setname_np, +}; +pub use crate::new::common::posix::pthread::{ + pthread_atfork, + pthread_attr_getguardsize, + pthread_attr_getinheritsched, + pthread_attr_getstack, + pthread_attr_setguardsize, + pthread_attr_setinheritsched, + pthread_attr_setstack, + pthread_barrier_destroy, + pthread_barrier_init, + pthread_barrier_wait, + pthread_barrierattr_destroy, + pthread_barrierattr_getpshared, + pthread_barrierattr_init, + pthread_barrierattr_setpshared, + pthread_condattr_getclock, + pthread_condattr_getpshared, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_getcpuclockid, + pthread_getschedparam, + pthread_kill, + pthread_mutex_timedlock, + pthread_mutexattr_getpshared, + pthread_mutexattr_setpshared, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, + pthread_sigmask, + pthread_spin_destroy, + pthread_spin_init, + pthread_spin_lock, + pthread_spin_trylock, + pthread_spin_unlock, +}; diff --git a/src/new/bionic_libc/sys/mod.rs b/src/new/bionic_libc/sys/mod.rs new file mode 100644 index 0000000000000..a882cbd99fca1 --- /dev/null +++ b/src/new/bionic_libc/sys/mod.rs @@ -0,0 +1,3 @@ +//! Directory: `sys/` + +pub(crate) mod socket; diff --git a/src/new/bionic/sys/socket.rs b/src/new/bionic_libc/sys/socket.rs similarity index 95% rename from src/new/bionic/sys/socket.rs rename to src/new/bionic_libc/sys/socket.rs index 49af36fe93356..c4a4e781275d9 100644 --- a/src/new/bionic/sys/socket.rs +++ b/src/new/bionic_libc/sys/socket.rs @@ -1,4 +1,4 @@ -//! Header: `bionic/libc/include/sys/socket.h` +//! Header: `sys/socket.h` use crate::prelude::*; diff --git a/src/new/bionic_libc/unistd.rs b/src/new/bionic_libc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/bionic_libc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/common/bsd.rs b/src/new/common/bsd.rs new file mode 100644 index 0000000000000..818daf93489c9 --- /dev/null +++ b/src/new/common/bsd.rs @@ -0,0 +1 @@ +//! Interfaces common across the BSD family. diff --git a/src/new/common/freebsd_like.rs b/src/new/common/freebsd_like.rs new file mode 100644 index 0000000000000..f49f2c9c2c06e --- /dev/null +++ b/src/new/common/freebsd_like.rs @@ -0,0 +1 @@ +//! Interfaces common in FreeBSD-derived operating systems. This includes FreeBSD and DragonFlyBSD. diff --git a/src/new/common/linux_like/mod.rs b/src/new/common/linux_like/mod.rs new file mode 100644 index 0000000000000..9c41fe256ceff --- /dev/null +++ b/src/new/common/linux_like/mod.rs @@ -0,0 +1,9 @@ +//! API that primarily comes from Linux but is also used other platforms (e.g. Android). + +#[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux" +))] +pub(crate) mod pthread; diff --git a/src/new/common/linux_like/pthread.rs b/src/new/common/linux_like/pthread.rs new file mode 100644 index 0000000000000..165f3254e79da --- /dev/null +++ b/src/new/common/linux_like/pthread.rs @@ -0,0 +1,25 @@ +use crate::prelude::*; + +extern "C" { + #[cfg(target_os = "linux")] + pub fn pthread_getaffinity_np( + thread: crate::pthread_t, + cpusetsize: size_t, + cpuset: *mut crate::cpu_set_t, + ) -> c_int; + + pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_setaffinity_np( + thread: crate::pthread_t, + cpusetsize: size_t, + cpuset: *const crate::cpu_set_t, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; +} diff --git a/src/new/common/mod.rs b/src/new/common/mod.rs new file mode 100644 index 0000000000000..acb18917c8998 --- /dev/null +++ b/src/new/common/mod.rs @@ -0,0 +1,39 @@ +//! Interfaces that are common across multiple platforms +//! +//! We make these available everywhere but each platform must opt in to reexporting. +//! +//! There shouldn't be any repeated definitions or complex configuration in this module. On +//! platforms that don't use common APIs it is fine to use `#[cfg(not(...))]`, but if a platform +//! needs a custom definition then it should be defined in the platform-specific module. +//! +//! The goal is that platforms need to opt in to the definitions here, so that worst case we have +//! an unused warning on untested platforms (rather than exposing incorrect API). + +#[cfg(any( + target_vendor = "apple", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd", +))] +pub(crate) mod bsd; + +#[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux", +))] +pub(crate) mod linux_like; + +#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] +pub(crate) mod freebsd_like; + +#[cfg(any(target_os = "netbsd", target_os = "openbsd"))] +pub(crate) mod netbsd_like; + +#[cfg(any(target_os = "illumos", target_os = "solaris"))] +pub(crate) mod solarish; + +#[cfg(target_family = "unix")] +pub(crate) mod posix; diff --git a/src/new/common/netbsd_like.rs b/src/new/common/netbsd_like.rs new file mode 100644 index 0000000000000..4267357ac9046 --- /dev/null +++ b/src/new/common/netbsd_like.rs @@ -0,0 +1 @@ +//! Interfaces common in NetBSD-derived operating systems. This includes NetBSD and OpenBSD. diff --git a/src/new/common/posix/mod.rs b/src/new/common/posix/mod.rs new file mode 100644 index 0000000000000..7bd596e37205d --- /dev/null +++ b/src/new/common/posix/mod.rs @@ -0,0 +1,14 @@ +//! POSIX APIs that are used by a number of platforms +//! +//! These can be found at: . + +// FIXME(pthread): eventually all platforms should use this module +#[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", +))] +pub(crate) mod pthread; +pub(crate) mod unistd; diff --git a/src/new/common/posix/pthread.rs b/src/new/common/posix/pthread.rs new file mode 100644 index 0000000000000..8cff48c601fb8 --- /dev/null +++ b/src/new/common/posix/pthread.rs @@ -0,0 +1,331 @@ +//! Header: `pthread.h` +//! +//! + +use crate::prelude::*; + +extern "C" { + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_attr_getinheritsched( + attr: *const crate::pthread_attr_t, + inheritsched: *mut c_int, + ) -> c_int; + + #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] + pub fn pthread_attr_getschedparam( + attr: *const crate::pthread_attr_t, + param: *mut crate::sched_param, + ) -> c_int; + + #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] + pub fn pthread_attr_getschedpolicy( + attr: *const crate::pthread_attr_t, + policy: *mut c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re" + ))] + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple" + ))] + pub fn pthread_attr_setinheritsched( + attr: *mut crate::pthread_attr_t, + inheritsched: c_int, + ) -> c_int; + + #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] + pub fn pthread_attr_setschedparam( + attr: *mut crate::pthread_attr_t, + param: *const crate::sched_param, + ) -> c_int; + + #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] + pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re" + ))] + pub fn pthread_attr_setstack( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrier_destroy(barrier: *mut crate::pthread_barrier_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrier_init( + barrier: *mut crate::pthread_barrier_t, + attr: *const crate::pthread_barrierattr_t, + count: c_uint, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrier_wait(barrier: *mut crate::pthread_barrier_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn pthread_barrierattr_getpshared( + attr: *const crate::pthread_barrierattr_t, + shared: *mut c_int, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrierattr_setpshared( + attr: *mut crate::pthread_barrierattr_t, + shared: c_int, + ) -> c_int; + + #[cfg(any(target_os = "l4re", all(target_os = "linux", not(target_env = "ohos"))))] + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + ))] + pub fn pthread_condattr_getclock( + attr: *const crate::pthread_condattr_t, + clock_id: *mut crate::clockid_t, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_condattr_getpshared( + attr: *const crate::pthread_condattr_t, + pshared: *mut c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + ))] + pub fn pthread_condattr_setclock( + attr: *mut crate::pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + target_vendor = "apple", + ))] + pub fn pthread_condattr_setpshared( + attr: *mut crate::pthread_condattr_t, + pshared: c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux", + ))] + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut crate::sched_param, + ) -> c_int; + + // FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required + // in pthread. + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + + #[cfg(all(target_os = "linux", not(target_env = "ohos")))] + pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + #[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")] + pub fn pthread_mutex_timedlock( + lock: *mut crate::pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_mutexattr_getprotocol( + attr: *const crate::pthread_mutexattr_t, + protocol: *mut c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_mutexattr_getpshared( + attr: *const crate::pthread_mutexattr_t, + pshared: *mut c_int, + ) -> c_int; + + #[cfg(all(target_os = "linux", not(target_env = "ohos")))] + pub fn pthread_mutexattr_getrobust( + attr: *const crate::pthread_mutexattr_t, + robustness: *mut c_int, + ) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_mutexattr_setprotocol( + attr: *mut crate::pthread_mutexattr_t, + protocol: c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + target_vendor = "apple", + ))] + pub fn pthread_mutexattr_setpshared( + attr: *mut crate::pthread_mutexattr_t, + pshared: c_int, + ) -> c_int; + + #[cfg(all(target_os = "linux", not(target_env = "ohos")))] + pub fn pthread_mutexattr_setrobust( + attr: *mut crate::pthread_mutexattr_t, + robustness: c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + target_vendor = "apple", + ))] + pub fn pthread_rwlockattr_getpshared( + attr: *const crate::pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + target_vendor = "apple", + ))] + pub fn pthread_rwlockattr_setpshared( + attr: *mut crate::pthread_rwlockattr_t, + val: c_int, + ) -> c_int; + + // FIXME(1.0): These shoul be combined to the version that takes an optional unsafe function. + #[cfg(any(target_os = "l4re", target_os = "linux"))] + pub fn pthread_once(control: *mut crate::pthread_once_t, routine: extern "C" fn()) -> c_int; + #[cfg(target_vendor = "apple")] + pub fn pthread_once( + once_control: *mut crate::pthread_once_t, + init_routine: Option, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int; + + // FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required + // in pthread. + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_sigmask( + how: c_int, + set: *const crate::sigset_t, + oldset: *mut crate::sigset_t, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int; +} diff --git a/src/new/common/posix/unistd.rs b/src/new/common/posix/unistd.rs new file mode 100644 index 0000000000000..0c02cbaa699f4 --- /dev/null +++ b/src/new/common/posix/unistd.rs @@ -0,0 +1,9 @@ +//! Header: `unistd.h` +//! +//! + +use crate::prelude::*; + +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; diff --git a/src/new/common/solarish.rs b/src/new/common/solarish.rs new file mode 100644 index 0000000000000..f966114e370ae --- /dev/null +++ b/src/new/common/solarish.rs @@ -0,0 +1 @@ +//! Interfaces common in solaris-derived operating systems. This includes Solaris and Illumos. diff --git a/src/new/cygwin/mod.rs b/src/new/cygwin/mod.rs new file mode 100644 index 0000000000000..356ae587653df --- /dev/null +++ b/src/new/cygwin/mod.rs @@ -0,0 +1,5 @@ +//! Cygwin libc. +//! +//! * Headers: + +pub(crate) mod unistd; diff --git a/src/new/cygwin/unistd.rs b/src/new/cygwin/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/cygwin/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/dragonfly/mod.rs b/src/new/dragonfly/mod.rs new file mode 100644 index 0000000000000..4a1b2c4998d07 --- /dev/null +++ b/src/new/dragonfly/mod.rs @@ -0,0 +1,6 @@ +//! DragonFly BSD libc. +//! +//! * Headers: +//! * Manual pages: + +pub(crate) mod unistd; diff --git a/src/new/dragonfly/unistd.rs b/src/new/dragonfly/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/dragonfly/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/emscripten/mod.rs b/src/new/emscripten/mod.rs new file mode 100644 index 0000000000000..f0765d3e06fff --- /dev/null +++ b/src/new/emscripten/mod.rs @@ -0,0 +1,6 @@ +//! Emscripten libc. +//! +//! * Headers: + +pub(crate) mod pthread; +pub(crate) mod unistd; diff --git a/src/new/emscripten/pthread.rs b/src/new/emscripten/pthread.rs new file mode 100644 index 0000000000000..21982b7979d43 --- /dev/null +++ b/src/new/emscripten/pthread.rs @@ -0,0 +1,14 @@ +//! Header: `pthread.h` + +pub use crate::new::common::linux_like::pthread::pthread_getattr_np; +pub use crate::new::common::posix::pthread::{ + pthread_attr_getstack, + pthread_attr_setstack, + pthread_condattr_getclock, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_mutexattr_setpshared, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, +}; diff --git a/src/new/emscripten/unistd.rs b/src/new/emscripten/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/emscripten/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/espidf/mod.rs b/src/new/espidf/mod.rs new file mode 100644 index 0000000000000..061ea6e64614b --- /dev/null +++ b/src/new/espidf/mod.rs @@ -0,0 +1,2 @@ +//! Expressif libc. +// FIXME(espidf): link to headers needed. diff --git a/src/new/freebsd/mod.rs b/src/new/freebsd/mod.rs new file mode 100644 index 0000000000000..87c2e487560be --- /dev/null +++ b/src/new/freebsd/mod.rs @@ -0,0 +1,6 @@ +//! FreeBSD libc. +//! +//! * Headers: +//! * Symbol map: + +pub(crate) mod unistd; diff --git a/src/new/freebsd/unistd.rs b/src/new/freebsd/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/freebsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/fuchsia/mod.rs b/src/new/fuchsia/mod.rs new file mode 100644 index 0000000000000..b3a908349bf3b --- /dev/null +++ b/src/new/fuchsia/mod.rs @@ -0,0 +1,4 @@ +//! Fuschia libc. +// FIXME(fuchsia): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/fuchsia/unistd.rs b/src/new/fuchsia/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/fuchsia/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs new file mode 100644 index 0000000000000..71d979b17ecc4 --- /dev/null +++ b/src/new/glibc/mod.rs @@ -0,0 +1,31 @@ +//! GNU libc. +//! +//! * Headers: (official) +//! * Headers: (mirror) +//! +//! This module structure is modeled after glibc's source tree. Its build system selects headers +//! from different locations based on the platform, which we mimic here with reexports. + +/// Source directory: `posix/` +/// +/// +mod posix { + pub(crate) mod unistd; +} + +/// Source directory: `sysdeps/` +/// +/// +mod sysdeps { + // FIXME(pthread): eventually all platforms should use this module + #[cfg(target_os = "linux")] + pub(crate) mod nptl; + pub(crate) mod unix; +} + +pub(crate) use posix::*; +// FIXME(pthread): eventually all platforms should use this module +#[cfg(target_os = "linux")] +pub(crate) use sysdeps::nptl::*; +#[cfg(target_os = "linux")] +pub(crate) use sysdeps::unix::linux::*; diff --git a/src/new/glibc/posix/unistd.rs b/src/new/glibc/posix/unistd.rs new file mode 100644 index 0000000000000..907066c458df2 --- /dev/null +++ b/src/new/glibc/posix/unistd.rs @@ -0,0 +1,9 @@ +//! Header: `unistd.h` +//! +//! + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/glibc/sysdeps/nptl/mod.rs b/src/new/glibc/sysdeps/nptl/mod.rs new file mode 100644 index 0000000000000..18e82e48b80a7 --- /dev/null +++ b/src/new/glibc/sysdeps/nptl/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `sysdeps/nptl/`o +//! +//! Native POSIX threading library. +//! +//! + +pub(crate) mod pthread; diff --git a/src/new/glibc/sysdeps/nptl/pthread.rs b/src/new/glibc/sysdeps/nptl/pthread.rs new file mode 100644 index 0000000000000..27b17285b53ba --- /dev/null +++ b/src/new/glibc/sysdeps/nptl/pthread.rs @@ -0,0 +1,59 @@ +//! Source header: `sysdeps/nptl/pthread.h` +//! +//! + +pub use crate::new::common::linux_like::pthread::{ + pthread_getaffinity_np, + pthread_getattr_np, + pthread_getname_np, + pthread_setaffinity_np, + pthread_setname_np, +}; +pub use crate::new::common::posix::pthread::{ + pthread_atfork, + pthread_attr_getguardsize, + pthread_attr_getinheritsched, + pthread_attr_getschedparam, + pthread_attr_getschedpolicy, + pthread_attr_getstack, + pthread_attr_setguardsize, + pthread_attr_setinheritsched, + pthread_attr_setschedparam, + pthread_attr_setschedpolicy, + pthread_attr_setstack, + pthread_barrier_destroy, + pthread_barrier_init, + pthread_barrier_wait, + pthread_barrierattr_destroy, + pthread_barrierattr_getpshared, + pthread_barrierattr_init, + pthread_barrierattr_setpshared, + pthread_cancel, + pthread_condattr_getclock, + pthread_condattr_getpshared, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_getcpuclockid, + pthread_getschedparam, + pthread_kill, + pthread_mutex_consistent, + pthread_mutex_timedlock, + pthread_mutexattr_getprotocol, + pthread_mutexattr_getpshared, + pthread_mutexattr_getrobust, + pthread_mutexattr_setprotocol, + pthread_mutexattr_setpshared, + pthread_mutexattr_setrobust, + pthread_once, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, + pthread_setschedprio, + pthread_sigmask, + pthread_spin_destroy, + pthread_spin_init, + pthread_spin_lock, + pthread_spin_trylock, + pthread_spin_unlock, +}; diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs new file mode 100644 index 0000000000000..0ecee596c5b12 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -0,0 +1,10 @@ +//! Source directory: `sysdeps/unix/sysv/linux` (the `sysv` is flattened). +//! +//! + +/// Directory: `net/` +/// +/// Source directory: `sysdeps/unix/sysv/linux/net` +pub(crate) mod net { + pub(crate) mod route; +} diff --git a/src/new/glibc/sysdeps/unix/linux/net/route.rs b/src/new/glibc/sysdeps/unix/linux/net/route.rs new file mode 100644 index 0000000000000..2851451652df0 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/net/route.rs @@ -0,0 +1,30 @@ +//! Header: `net/route.h` +//! +//! Source header: `sysdeps/unix/sysv/linux/net/route.h` +//! + +use crate::prelude::*; + +s! { + pub struct rtentry { + pub rt_pad1: c_ulong, + pub rt_dst: crate::sockaddr, + pub rt_gateway: crate::sockaddr, + pub rt_genmask: crate::sockaddr, + pub rt_flags: c_ushort, + pub rt_pad2: c_short, + pub rt_pad3: c_ulong, + pub rt_tos: c_uchar, + pub rt_class: c_uchar, + // FIXME(1.0): private padding fields + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: c_short, + pub rt_metric: c_short, + pub rt_dev: *mut c_char, + pub rt_mtu: c_ulong, + pub rt_window: c_ulong, + pub rt_irtt: c_ushort, + } +} diff --git a/src/new/glibc/sysdeps/unix/mod.rs b/src/new/glibc/sysdeps/unix/mod.rs new file mode 100644 index 0000000000000..55a895d4d0de2 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/mod.rs @@ -0,0 +1,6 @@ +//! Source directory: `sysdeps/unix/` +//! +//! + +#[cfg(target_os = "linux")] +pub(crate) mod linux; diff --git a/src/new/haiku/mod.rs b/src/new/haiku/mod.rs new file mode 100644 index 0000000000000..a565afe10d9ce --- /dev/null +++ b/src/new/haiku/mod.rs @@ -0,0 +1,4 @@ +//! Haiku OS libc. +// FIXME(haiku): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/haiku/unistd.rs b/src/new/haiku/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/haiku/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/hermit_abi/mod.rs b/src/new/hermit_abi/mod.rs new file mode 100644 index 0000000000000..65f59fe12d691 --- /dev/null +++ b/src/new/hermit_abi/mod.rs @@ -0,0 +1,3 @@ +//! Hermit kernel libc. +//! +//! * Headers: diff --git a/src/new/horizon/mod.rs b/src/new/horizon/mod.rs new file mode 100644 index 0000000000000..338e9f0a4d840 --- /dev/null +++ b/src/new/horizon/mod.rs @@ -0,0 +1,2 @@ +//! Switch libc. +// FIXME(horizon): link to headers or manpages needed. diff --git a/src/new/hurd/mod.rs b/src/new/hurd/mod.rs new file mode 100644 index 0000000000000..12198d58bd582 --- /dev/null +++ b/src/new/hurd/mod.rs @@ -0,0 +1,2 @@ +//! GNU Hurd libc. +// FIXME(hurd): link to headers needed. diff --git a/src/new/illumos/mod.rs b/src/new/illumos/mod.rs new file mode 100644 index 0000000000000..83d15da8801f2 --- /dev/null +++ b/src/new/illumos/mod.rs @@ -0,0 +1,4 @@ +//! Illumos libc. +// FIXME(illumos): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/illumos/unistd.rs b/src/new/illumos/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/illumos/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/l4re/mod.rs b/src/new/l4re/mod.rs new file mode 100644 index 0000000000000..cbf725f406b6b --- /dev/null +++ b/src/new/l4re/mod.rs @@ -0,0 +1,3 @@ +//! L4re. +//! +//! * Headers: diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index b9479a63bacea..8019124749c1e 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -1,11 +1,9 @@ //! Header: `uapi/linux/can.h` +pub(crate) mod bcm; pub(crate) mod j1939; pub(crate) mod raw; -pub use j1939::*; -pub use raw::*; - use crate::prelude::*; pub const CAN_EFF_FLAG: canid_t = 0x80000000; @@ -43,7 +41,7 @@ s! { pub can_id: canid_t, // FIXME(1.0): this field was renamed to `len` in Linux 5.11 pub can_dlc: u8, - __pad: u8, + __pad: Padding, __res0: u8, pub len8_dlc: u8, pub data: [u8; CAN_MAX_DLEN], @@ -70,7 +68,6 @@ pub const CANXL_XLF: c_int = 0x80; pub const CANXL_SEC: c_int = 0x01; s! { - #[repr(align(8))] pub struct canxl_frame { pub prio: canid_t, pub flags: u8, diff --git a/src/new/linux_uapi/linux/can/bcm.rs b/src/new/linux_uapi/linux/can/bcm.rs new file mode 100644 index 0000000000000..853f85f040880 --- /dev/null +++ b/src/new/linux_uapi/linux/can/bcm.rs @@ -0,0 +1,52 @@ +//! Header: `linux/can/bcm.h` + +pub use crate::linux::can::*; + +s! { + pub struct bcm_timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + pub struct bcm_msg_head { + pub opcode: u32, + pub flags: u32, + pub count: u32, + pub ival1: bcm_timeval, + pub ival2: bcm_timeval, + pub can_id: canid_t, + pub nframes: u32, + pub frames: [can_frame; 0], + } +} + +c_enum! { + #[repr(u32)] + pub enum #anon { + pub TX_SETUP = 1, + pub TX_DELETE, + pub TX_READ, + pub TX_SEND, + pub RX_SETUP, + pub RX_DELETE, + pub RX_READ, + pub TX_STATUS, + pub TX_EXPIRED, + pub RX_STATUS, + pub RX_TIMEOUT, + pub RX_CHANGED, + } +} + +pub const SETTIMER: u32 = 0x0001; +pub const STARTTIMER: u32 = 0x0002; +pub const TX_COUNTEVT: u32 = 0x0004; +pub const TX_ANNOUNCE: u32 = 0x0008; +pub const TX_CP_CAN_ID: u32 = 0x0010; +pub const RX_FILTER_ID: u32 = 0x0020; +pub const RX_CHECK_DLC: u32 = 0x0040; +pub const RX_NO_AUTOTIMER: u32 = 0x0080; +pub const RX_ANNOUNCE_RESUME: u32 = 0x0100; +pub const TX_RESET_MULTI_IDX: u32 = 0x0200; +pub const RX_RTR_FRAME: u32 = 0x0400; +pub const CAN_FD_FRAME: u32 = 0x0800; diff --git a/src/new/linux_uapi/linux/can/raw.rs b/src/new/linux_uapi/linux/can/raw.rs index 1f92a13edbba6..470334bd5d147 100644 --- a/src/new/linux_uapi/linux/can/raw.rs +++ b/src/new/linux_uapi/linux/can/raw.rs @@ -1,4 +1,4 @@ -//! `linux/can/raw.h` +//! Header: `linux/can/raw.h` pub use crate::linux::can::*; diff --git a/src/new/linux_uapi/linux/keyctl.rs b/src/new/linux_uapi/linux/keyctl.rs new file mode 100644 index 0000000000000..cc6527a8a5113 --- /dev/null +++ b/src/new/linux_uapi/linux/keyctl.rs @@ -0,0 +1,69 @@ +//! Header: `linux/keyctl.h` + +pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; +pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; +pub const KEY_SPEC_SESSION_KEYRING: i32 = -3; +pub const KEY_SPEC_USER_KEYRING: i32 = -4; +pub const KEY_SPEC_USER_SESSION_KEYRING: i32 = -5; +pub const KEY_SPEC_GROUP_KEYRING: i32 = -6; +pub const KEY_SPEC_REQKEY_AUTH_KEY: i32 = -7; +pub const KEY_SPEC_REQUESTOR_KEYRING: i32 = -8; + +pub const KEY_REQKEY_DEFL_NO_CHANGE: i32 = -1; +pub const KEY_REQKEY_DEFL_DEFAULT: i32 = 0; +pub const KEY_REQKEY_DEFL_THREAD_KEYRING: i32 = 1; +pub const KEY_REQKEY_DEFL_PROCESS_KEYRING: i32 = 2; +pub const KEY_REQKEY_DEFL_SESSION_KEYRING: i32 = 3; +pub const KEY_REQKEY_DEFL_USER_KEYRING: i32 = 4; +pub const KEY_REQKEY_DEFL_USER_SESSION_KEYRING: i32 = 5; +pub const KEY_REQKEY_DEFL_GROUP_KEYRING: i32 = 6; +pub const KEY_REQKEY_DEFL_REQUESTOR_KEYRING: i32 = 7; + +pub const KEYCTL_GET_KEYRING_ID: u32 = 0; +pub const KEYCTL_JOIN_SESSION_KEYRING: u32 = 1; +pub const KEYCTL_UPDATE: u32 = 2; +pub const KEYCTL_REVOKE: u32 = 3; +pub const KEYCTL_CHOWN: u32 = 4; +pub const KEYCTL_SETPERM: u32 = 5; +pub const KEYCTL_DESCRIBE: u32 = 6; +pub const KEYCTL_CLEAR: u32 = 7; +pub const KEYCTL_LINK: u32 = 8; +pub const KEYCTL_UNLINK: u32 = 9; +pub const KEYCTL_SEARCH: u32 = 10; +pub const KEYCTL_READ: u32 = 11; +pub const KEYCTL_INSTANTIATE: u32 = 12; +pub const KEYCTL_NEGATE: u32 = 13; +pub const KEYCTL_SET_REQKEY_KEYRING: u32 = 14; +pub const KEYCTL_SET_TIMEOUT: u32 = 15; +pub const KEYCTL_ASSUME_AUTHORITY: u32 = 16; +pub const KEYCTL_GET_SECURITY: u32 = 17; +pub const KEYCTL_SESSION_TO_PARENT: u32 = 18; +pub const KEYCTL_REJECT: u32 = 19; +pub const KEYCTL_INSTANTIATE_IOV: u32 = 20; +pub const KEYCTL_INVALIDATE: u32 = 21; +pub const KEYCTL_GET_PERSISTENT: u32 = 22; +pub const KEYCTL_DH_COMPUTE: u32 = 23; +pub const KEYCTL_PKEY_QUERY: u32 = 24; +pub const KEYCTL_PKEY_ENCRYPT: u32 = 25; +pub const KEYCTL_PKEY_DECRYPT: u32 = 26; +pub const KEYCTL_PKEY_SIGN: u32 = 27; +pub const KEYCTL_PKEY_VERIFY: u32 = 28; +pub const KEYCTL_RESTRICT_KEYRING: u32 = 29; +pub const KEYCTL_MOVE: u32 = 30; +pub const KEYCTL_CAPABILITIES: u32 = 31; + +pub const KEYCTL_SUPPORTS_ENCRYPT: u32 = 0x01; +pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02; +pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04; +pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08; + +pub const KEYCTL_CAPS0_CAPABILITIES: u32 = 0x01; +pub const KEYCTL_CAPS0_PERSISTENT_KEYRINGS: u32 = 0x02; +pub const KEYCTL_CAPS0_DIFFIE_HELLMAN: u32 = 0x04; +pub const KEYCTL_CAPS0_PUBLIC_KEY: u32 = 0x08; +pub const KEYCTL_CAPS0_BIG_KEY: u32 = 0x10; +pub const KEYCTL_CAPS0_INVALIDATE: u32 = 0x20; +pub const KEYCTL_CAPS0_RESTRICT_KEYRING: u32 = 0x40; +pub const KEYCTL_CAPS0_MOVE: u32 = 0x80; +pub const KEYCTL_CAPS1_NS_KEYRING_NAME: u32 = 0x01; +pub const KEYCTL_CAPS1_NS_KEY_TAG: u32 = 0x02; diff --git a/src/new/linux_uapi/linux/mod.rs b/src/new/linux_uapi/linux/mod.rs index 4a9c04d6396b1..993394e4370ca 100644 --- a/src/new/linux_uapi/linux/mod.rs +++ b/src/new/linux_uapi/linux/mod.rs @@ -1,4 +1,6 @@ -//! The `linux` directory within `include/uapi` in the Linux source tree. +//! Directory: `linux/` +//! +//! pub(crate) mod can; -pub use can::*; +pub(crate) mod keyctl; diff --git a/src/new/linux_uapi/mod.rs b/src/new/linux_uapi/mod.rs index e0d4e094c435f..8ac3022d16578 100644 --- a/src/new/linux_uapi/mod.rs +++ b/src/new/linux_uapi/mod.rs @@ -1,4 +1,3 @@ //! This directory maps to `include/uapi` in the Linux source tree. pub(crate) mod linux; -pub use linux::*; diff --git a/src/new/mod.rs b/src/new/mod.rs index 0a2a55b0f469b..dd451bb5286bd 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -3,13 +3,220 @@ //! //! Eventually everything should be moved over, and we will move this directory to the top //! level in `src`. +//! +//! # Basic structure +//! +//! Each child module here represents a library or group of libraries that we are binding. Each of +//! these has several submodules, representing either a directory or a header file in that library. +//! +//! `#include`s turn into `pub use ...*;` statements. Then at the root level (here), we choose +//! which top-level headers we want to reexport the definitions for. +//! +//! All modules are only crate-public since we don't reexport this structure. + +mod common; + +/* The `pub(crate) use ...` statements are commented while the modules are empty */ +// Platform libraries and combined platform+libc +// +// Not supported or not needed: +// * amdhsa +// * cuda +// * lynxos178 +// * managarm +// * motor +// * none +// * psp +// * psx +// * uefi +// * unknown +// * vexos +// * zkvm +// +// Combined to target_vendor = "apple" +// * ios +// * macos +// * tvos +// * visionos +// * watchos cfg_if! { - if #[cfg(target_os = "linux")] { - mod linux_uapi; - pub use linux_uapi::*; + if #[cfg(target_os = "aix")] { + mod aix; + pub(crate) use aix::*; } else if #[cfg(target_os = "android")] { - mod bionic; - pub use bionic::*; + mod bionic_libc; + pub(crate) use bionic_libc::*; + } else if #[cfg(target_vendor = "apple")] { + mod apple; + pub(crate) use apple::*; + } else if #[cfg(target_os = "cygwin")] { + mod cygwin; + pub(crate) use cygwin::*; + } else if #[cfg(target_os = "dragonfly")] { + mod dragonfly; + pub(crate) use dragonfly::*; + } else if #[cfg(target_os = "emscripten")] { + mod emscripten; + pub(crate) use emscripten::*; + } else if #[cfg(target_os = "espidf")] { + mod espidf; + // pub(crate) use espidf::*; + } else if #[cfg(target_os = "freebsd")] { + mod freebsd; + pub(crate) use freebsd::*; + } else if #[cfg(target_os = "fuchsia")] { + mod fuchsia; + pub(crate) use fuchsia::*; + } else if #[cfg(target_os = "haiku")] { + mod haiku; + pub(crate) use haiku::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit_abi; + // pub(crate) use hermit_abi::*; + } else if #[cfg(target_os = "horizon")] { + mod horizon; + // pub(crate) use horizon::*; + } else if #[cfg(target_os = "hurd")] { + mod hurd; + // pub(crate) use hurd::*; + } else if #[cfg(target_os = "illumos")] { + mod illumos; + pub(crate) use illumos::*; + } else if #[cfg(target_os = "l4re")] { + mod l4re; + // pub(crate) use l4re::*; + } else if #[cfg(target_os = "linux")] { + mod linux_uapi; + pub(crate) use linux_uapi::*; + } else if #[cfg(target_os = "netbsd")] { + mod netbsd; + pub(crate) use netbsd::*; + } else if #[cfg(target_os = "nto")] { + mod nto; + pub(crate) use nto::*; + } else if #[cfg(target_os = "nuttx")] { + mod nuttx; + pub(crate) use nuttx::*; + } else if #[cfg(target_os = "openbsd")] { + mod openbsd; + pub(crate) use openbsd::*; + } else if #[cfg(target_os = "redox")] { + mod redox; + // pub(crate) use redox::*; + } else if #[cfg(target_os = "rtems")] { + mod rtems; + pub(crate) use rtems::*; + } else if #[cfg(target_os = "solaris")] { + mod solaris; + pub(crate) use solaris::*; + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + // pub(crate) use solid::*; + } else if #[cfg(target_os = "teeos")] { + mod teeos; + // pub(crate) use teeos::*; + } else if #[cfg(target_os = "trusty")] { + mod trusty; + // pub(crate) use trusty::*; + } else if #[cfg(target_os = "vita")] { + mod vita; + // pub(crate) use vita::*; + } else if #[cfg(target_os = "vxworks")] { + mod vxworks; + pub(crate) use vxworks::*; + } else if #[cfg(target_os = "wasi")] { + mod wasi; + // pub(crate) use wasi::*; + } else if #[cfg(target_os = "windows")] { + mod ucrt; + // pub(crate) use ucrt::*; + } else if #[cfg(target_os = "xous")] { + mod xous; + // pub(crate) use xous::*; + } +} + +// Multi-platform libc +cfg_if! { + // FIXME(vxworks): vxworks sets `target_env = "gnu"` but maybe shouldn't. + if #[cfg(all( + target_family = "unix", + target_env = "gnu", + not(target_os = "vxworks") + ))] { + mod glibc; + pub(crate) use glibc::*; + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + // OhOS also uses the musl libc + mod musl; + pub(crate) use musl::*; + } else if #[cfg(target_env = "newlib")] { + mod newlib; + pub(crate) use newlib::*; + } else if #[cfg(target_env = "relibc")] { + mod relibc; + pub(crate) use relibc::*; + } else if #[cfg(target_env = "sgx")] { + mod sgx; + // pub(crate) use sgx::*; + } else if #[cfg(target_env = "uclibc")] { + mod uclibc; + pub(crate) use uclibc::*; + } +} + +// Per-OS headers we export +cfg_if! { + if #[cfg(target_os = "android")] { + pub use sys::socket::*; + } else if #[cfg(target_os = "linux")] { + pub use linux::can::bcm::*; + pub use linux::can::j1939::*; + pub use linux::can::raw::*; + pub use linux::can::*; + pub use linux::keyctl::*; + #[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 = "netbsd")] { + pub use net::if_::*; + pub use sys::ipc::*; + pub use sys::statvfs::*; + pub use sys::time::*; + pub use sys::timex::*; + pub use sys::types::*; + pub use utmp_::*; + pub use utmpx_::*; + } else if #[cfg(target_os = "openbsd")] { + pub use sys::ipc::*; + } +} + +// Per-env headers we export +cfg_if! { + if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + pub use sys::socket::*; + } +} + +// Per-family headers we export +cfg_if! { + if #[cfg(target_family = "unix")] { + // FIXME(pthread): eventually all platforms should use this module + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux" + ))] + pub use pthread::*; + pub use unistd::*; } } diff --git a/src/new/musl/arch/generic/mod.rs b/src/new/musl/arch/generic/mod.rs new file mode 100644 index 0000000000000..ac02505c882bf --- /dev/null +++ b/src/new/musl/arch/generic/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/generic/` +//! +//! + +pub(crate) mod bits { + // Currently unused +} diff --git a/src/new/musl/arch/mips/bits/socket.rs b/src/new/musl/arch/mips/bits/socket.rs new file mode 100644 index 0000000000000..77b53e489c3d8 --- /dev/null +++ b/src/new/musl/arch/mips/bits/socket.rs @@ -0,0 +1,4 @@ +use crate::prelude::*; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; diff --git a/src/new/musl/arch/mips/mod.rs b/src/new/musl/arch/mips/mod.rs new file mode 100644 index 0000000000000..2f02036d254ce --- /dev/null +++ b/src/new/musl/arch/mips/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/mips/` +//! +//! + +pub(crate) mod bits { + pub(crate) mod socket; +} diff --git a/src/new/musl/arch/mips64/bits/socket.rs b/src/new/musl/arch/mips64/bits/socket.rs new file mode 100644 index 0000000000000..77b53e489c3d8 --- /dev/null +++ b/src/new/musl/arch/mips64/bits/socket.rs @@ -0,0 +1,4 @@ +use crate::prelude::*; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; diff --git a/src/new/musl/arch/mips64/mod.rs b/src/new/musl/arch/mips64/mod.rs new file mode 100644 index 0000000000000..6a45b067b998e --- /dev/null +++ b/src/new/musl/arch/mips64/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/mips64/` +//! +//! + +pub(crate) mod bits { + pub(crate) mod socket; +} diff --git a/src/new/musl/arch/mod.rs b/src/new/musl/arch/mod.rs new file mode 100644 index 0000000000000..514d7b4bdfea7 --- /dev/null +++ b/src/new/musl/arch/mod.rs @@ -0,0 +1,10 @@ +//! Source directory: `arch/` +//! +//! + +pub(crate) mod generic; + +#[cfg(target_arch = "mips")] +pub(crate) mod mips; +#[cfg(target_arch = "mips64")] +pub(crate) mod mips64; diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs new file mode 100644 index 0000000000000..9fd4d8e96100d --- /dev/null +++ b/src/new/musl/mod.rs @@ -0,0 +1,32 @@ +//! Musl libc. +//! +//! * Headers: (official) +//! * Headers: (mirror) + +// The musl build system includes `arch/$(ARCH)` (preferred if it exists) and `arch/generic` (used +// as the fallback). We can't exactly mirror this with glob exports, so instead we selectively +// reexport in a new module. +mod arch; + +pub(crate) mod bits { + cfg_if! { + if #[cfg(target_arch = "mips")] { + pub(crate) use super::arch::mips::bits::socket; + } else if #[cfg(target_arch = "mips64")] { + pub(crate) use super::arch::mips64::bits::socket; + } else { + // Reexports from generic will live here once we need them. + } + } +} + +pub(crate) mod pthread; + +/// Directory: `sys/` +/// +/// +pub(crate) mod sys { + pub(crate) mod socket; +} + +pub(crate) mod unistd; diff --git a/src/new/musl/pthread.rs b/src/new/musl/pthread.rs new file mode 100644 index 0000000000000..0d578bc9665dc --- /dev/null +++ b/src/new/musl/pthread.rs @@ -0,0 +1,62 @@ +//! Header: `pthread.h` +//! +//! + +pub use crate::new::common::linux_like::pthread::{ + pthread_getaffinity_np, + pthread_getattr_np, + pthread_getname_np, + pthread_setaffinity_np, + pthread_setname_np, +}; +pub use crate::new::common::posix::pthread::{ + pthread_atfork, + pthread_attr_getguardsize, + pthread_attr_getinheritsched, + pthread_attr_getschedparam, + pthread_attr_getschedpolicy, + pthread_attr_getstack, + pthread_attr_setguardsize, + pthread_attr_setinheritsched, + pthread_attr_setschedparam, + pthread_attr_setschedpolicy, + pthread_attr_setstack, + pthread_barrier_destroy, + pthread_barrier_init, + pthread_barrier_wait, + pthread_barrierattr_destroy, + pthread_barrierattr_getpshared, + pthread_barrierattr_init, + pthread_barrierattr_setpshared, + pthread_condattr_getclock, + pthread_condattr_getpshared, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_getcpuclockid, + pthread_getschedparam, + pthread_kill, + pthread_mutex_timedlock, + pthread_mutexattr_getprotocol, + pthread_mutexattr_getpshared, + pthread_mutexattr_setprotocol, + pthread_mutexattr_setpshared, + pthread_once, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, + pthread_setschedprio, + pthread_sigmask, + pthread_spin_destroy, + pthread_spin_init, + pthread_spin_lock, + pthread_spin_trylock, + pthread_spin_unlock, +}; +#[cfg(not(target_env = "ohos"))] +pub use crate::new::common::posix::pthread::{ + pthread_cancel, + pthread_mutex_consistent, + pthread_mutexattr_getrobust, + pthread_mutexattr_setrobust, +}; diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs new file mode 100644 index 0000000000000..f7105c9bbca16 --- /dev/null +++ b/src/new/musl/sys/socket.rs @@ -0,0 +1,63 @@ +//! Header: `sys/socket.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + __pad1: c_int, + pub msg_iovlen: c_int, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + __pad1: c_int, + pub msg_control: *mut c_void, + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + __pad2: c_int, + pub msg_controllen: crate::socklen_t, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + __pad2: c_int, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + pub __pad1: c_int, + pub cmsg_len: crate::socklen_t, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + pub __pad1: c_int, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } +} + +extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + ) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + timeout: *mut crate::timespec, + ) -> c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { + pub use crate::bits::socket::{ + SOCK_DGRAM, + SOCK_STREAM, + }; + } else { + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + } +} diff --git a/src/new/musl/unistd.rs b/src/new/musl/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/musl/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs new file mode 100644 index 0000000000000..5db71760c4de9 --- /dev/null +++ b/src/new/netbsd/mod.rs @@ -0,0 +1,14 @@ +//! NetBSD libc. +//! +//! * Headers: +//! * Sys headers: +//! * Manual pages: + +pub(crate) mod net { + pub(crate) mod if_; +} + +pub(crate) mod sys; +pub(crate) mod unistd; +pub(crate) mod utmp_; +pub(crate) mod utmpx_; diff --git a/src/new/netbsd/net/if_.rs b/src/new/netbsd/net/if_.rs new file mode 100644 index 0000000000000..7cceadfc2b3d6 --- /dev/null +++ b/src/new/netbsd/net/if_.rs @@ -0,0 +1,96 @@ +//! Header: `net/if.h` +//! +//! + +use crate::prelude::*; +use crate::IFNAMSIZ; + +s! { + pub struct if_data { + pub ifi_type: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_link_state: c_int, + pub ifi_mtu: u64, + pub ifi_metric: u64, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_noproto: u64, + pub ifi_lastchange: crate::timespec, + } +} + +pub const IFF_UP: c_int = 0x0001; // interface is up +pub const IFF_BROADCAST: c_int = 0x0002; // broadcast address valid +pub const IFF_DEBUG: c_int = 0x0004; // turn on debugging +pub const IFF_LOOPBACK: c_int = 0x0008; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x0010; // interface is point-to-point link +pub const IFF_RUNNING: c_int = 0x0040; // resources allocated +pub const IFF_NOARP: c_int = 0x0080; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x0100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets +pub const IFF_OACTIVE: c_int = 0x0400; // transmission in progress +pub const IFF_SIMPLEX: c_int = 0x0800; // can't hear own transmissions +pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + +s! { + pub struct if_msghdr { + pub ifm_msglen: c_ushort, + pub ifm_version: c_uchar, + pub ifm_type: c_uchar, + pub ifm_addrs: c_int, + pub ifm_flags: c_int, + pub ifm_index: c_ushort, + pub ifm_data: if_data, + } +} + +s_no_extra_traits! { + pub struct ifreq { + pub ifr_name: [c_char; IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub space: crate::sockaddr_storage, + pub ifru_flags: c_short, + pub ifru_addrflags: c_int, + pub ifru_metrics: c_int, + pub ifru_mtu: c_int, + pub ifru_dlt: c_int, + pub ifru_value: c_uint, + pub ifru_data: *mut c_void, + // buf and buflen are deprecated but they contribute to union size + ifru_b: __c_anonymous_ifr_ifru_ifru_b, + } + + struct __c_anonymous_ifr_ifru_ifru_b { + b_buflen: u32, + b_buf: *mut c_void, + } + + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_void, + pub ifcu_req: *mut ifreq, + } +} diff --git a/src/new/netbsd/sys/ipc.rs b/src/new/netbsd/sys/ipc.rs new file mode 100644 index 0000000000000..49a1c84d74296 --- /dev/null +++ b/src/new/netbsd/sys/ipc.rs @@ -0,0 +1,17 @@ +//! Header: `sys/ipc.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct ipc_perm { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub _seq: c_ushort, + pub _key: crate::key_t, + } +} diff --git a/src/new/netbsd/sys/mod.rs b/src/new/netbsd/sys/mod.rs new file mode 100644 index 0000000000000..185c1f1c2cba1 --- /dev/null +++ b/src/new/netbsd/sys/mod.rs @@ -0,0 +1,9 @@ +//! Directory: `sys/` +//! +//! https://github.com/NetBSD/src/tree/trunk/sys/sys + +pub(crate) mod ipc; +pub(crate) mod statvfs; +pub(crate) mod time; +pub(crate) mod timex; +pub(crate) mod types; diff --git a/src/new/netbsd/sys/statvfs.rs b/src/new/netbsd/sys/statvfs.rs new file mode 100644 index 0000000000000..eee3766300ce6 --- /dev/null +++ b/src/new/netbsd/sys/statvfs.rs @@ -0,0 +1,47 @@ +//! Header: `sys/statvfs.h` +//! +//! + +use crate::prelude::*; + +const _VFS_NAMELEN: usize = 32; +const _VFS_MNAMELEN: usize = 1024; + +s! { + pub struct statvfs { + pub f_flag: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_iosize: c_ulong, + + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_bresvd: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fresvd: crate::fsfilcnt_t, + + pub f_syncreads: u64, + pub f_syncwrites: u64, + + pub f_asyncreads: u64, + pub f_asyncwrites: u64, + + pub f_fsidx: crate::fsid_t, + pub f_fsid: c_ulong, + pub f_namemax: c_ulong, + pub f_owner: crate::uid_t, + + // This type is updated in a future version + f_spare: [u32; 4], + + pub f_fstypename: [c_char; _VFS_NAMELEN], + pub f_mntonname: [c_char; _VFS_MNAMELEN], + pub f_mntfromname: [c_char; _VFS_MNAMELEN], + // Added in NetBSD10 + // pub f_mntfromlabel: [c_char; _VFS_MNAMELEN], + } +} diff --git a/src/new/netbsd/sys/time.rs b/src/new/netbsd/sys/time.rs new file mode 100644 index 0000000000000..5f2d39d347e69 --- /dev/null +++ b/src/new/netbsd/sys/time.rs @@ -0,0 +1,13 @@ +//! Header: `sys/time.h` +//! +//! + +s! { + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } +} + +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 0x20000000; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 0x40000000; diff --git a/src/new/netbsd/sys/timex.rs b/src/new/netbsd/sys/timex.rs new file mode 100644 index 0000000000000..82844bf0e732d --- /dev/null +++ b/src/new/netbsd/sys/timex.rs @@ -0,0 +1,95 @@ +//! Header: `sys/timex.h` +//! +//! + +use crate::prelude::*; + +pub const MAXPHASE: c_long = 500000000; +pub const MAXFREQ: c_long = 500000; +pub const MINSEC: c_int = 256; +pub const MAXSEC: c_int = 2048; +pub const NANOSECOND: c_long = 1000000000; +pub const SCALE_PPM: c_int = 65; +pub const MAXTC: c_int = 10; + +pub const MOD_OFFSET: c_uint = 0x0001; +pub const MOD_FREQUENCY: c_uint = 0x0002; +pub const MOD_MAXERROR: c_uint = 0x0004; +pub const MOD_ESTERROR: c_uint = 0x0008; +pub const MOD_STATUS: c_uint = 0x0010; +pub const MOD_TIMECONST: c_uint = 0x0020; +pub const MOD_PPSMAX: c_uint = 0x0040; +pub const MOD_TAI: c_uint = 0x0080; +pub const MOD_MICRO: c_uint = 0x1000; +pub const MOD_NANO: c_uint = 0x2000; +pub const MOD_CLKB: c_uint = 0x4000; +pub const MOD_CLKA: c_uint = 0x8000; + +pub const STA_PLL: c_int = 0x0001; +pub const STA_PPSFREQ: c_int = 0x0002; +pub const STA_PPSTIME: c_int = 0x0004; +pub const STA_FLL: c_int = 0x0008; +pub const STA_INS: c_int = 0x0010; +pub const STA_DEL: c_int = 0x0020; +pub const STA_UNSYNC: c_int = 0x0040; +pub const STA_FREQHOLD: c_int = 0x0080; +pub const STA_PPSSIGNAL: c_int = 0x0100; +pub const STA_PPSJITTER: c_int = 0x0200; +pub const STA_PPSWANDER: c_int = 0x0400; +pub const STA_PPSERROR: c_int = 0x0800; +pub const STA_CLOCKERR: c_int = 0x1000; +pub const STA_NANO: c_int = 0x2000; +pub const STA_MODE: c_int = 0x4000; +pub const STA_CLK: c_int = 0x8000; + +pub const STA_RONLY: c_int = STA_PPSSIGNAL + | STA_PPSJITTER + | STA_PPSWANDER + | STA_PPSERROR + | STA_CLOCKERR + | STA_NANO + | STA_MODE + | STA_CLK; + +pub const TIME_OK: c_int = 0; +pub const TIME_INS: c_int = 1; +pub const TIME_DEL: c_int = 2; +pub const TIME_OOP: c_int = 3; +pub const TIME_WAIT: c_int = 4; +pub const TIME_ERROR: c_int = 5; + +s! { + pub struct ntptimeval { + pub time: crate::timespec, + pub maxerror: c_long, + pub esterror: c_long, + pub tai: c_long, + pub time_state: c_int, + } + + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + } +} + +extern "C" { + #[link_name = "__ntp_gettime50"] + pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + pub fn ntp_adjtime(buf: *mut timex) -> c_int; +} diff --git a/src/new/netbsd/sys/types.rs b/src/new/netbsd/sys/types.rs new file mode 100644 index 0000000000000..8dfc049426170 --- /dev/null +++ b/src/new/netbsd/sys/types.rs @@ -0,0 +1,16 @@ +//! Header: `sys/types.h` +//! +//! + +use crate::prelude::*; + +pub type dev_t = u64; + +pub type lwpid_t = i32; + +pub type mqd_t = c_int; +pub type cpuid_t = c_ulong; + +pub type clock_t = c_uint; +pub type timer_t = c_int; +pub type suseconds_t = c_int; diff --git a/src/new/netbsd/unistd.rs b/src/new/netbsd/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/netbsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/netbsd/utmp_.rs b/src/new/netbsd/utmp_.rs new file mode 100644 index 0000000000000..2047449053ce8 --- /dev/null +++ b/src/new/netbsd/utmp_.rs @@ -0,0 +1,33 @@ +//! Header: `utmp.h` +//! +//! + +use crate::prelude::*; + +pub const UT_NAMESIZE: usize = 8; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; + +s! { + pub struct lastlog { + pub ll_time: crate::time_t, + pub ll_line: [c_char; UT_LINESIZE], + pub ll_host: [c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_line: [c_char; UT_LINESIZE], + pub ut_name: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_time: crate::time_t, + } +} + +#[link(name = "util")] +extern "C" { + pub fn utmpname(file: *const c_char) -> c_int; + pub fn setutent(); + #[link_name = "__getutent50"] + pub fn getutent() -> *mut utmp; + pub fn endutent(); +} diff --git a/src/new/netbsd/utmpx_.rs b/src/new/netbsd/utmpx_.rs new file mode 100644 index 0000000000000..813c8fb69712e --- /dev/null +++ b/src/new/netbsd/utmpx_.rs @@ -0,0 +1,92 @@ +//! Header: `utmpx.h` +//! +//! + +use crate::prelude::*; + +// pub const _PATH_UTMPX: &[c_char; 14] = b"/var/run/utmpx"; +// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx"; +// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx"; +// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update"; + +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; + +pub const EMPTY: u16 = 0; +pub const RUN_LVL: u16 = 1; +pub const BOOT_TIME: u16 = 2; +pub const OLD_TIME: u16 = 3; +pub const NEW_TIME: u16 = 4; +pub const INIT_PROCESS: u16 = 5; +pub const LOGIN_PROCESS: u16 = 6; +pub const USER_PROCESS: u16 = 7; +pub const DEAD_PROCESS: u16 = 8; +pub const ACCOUNTING: u16 = 9; +pub const SIGNATURE: u16 = 10; +pub const DOWN_TIME: u16 = 11; + +// Expression based on the comment in NetBSD source. +pub const _UTX_PADSIZE: usize = if cfg!(target_pointer_width = "64") { + 36 +} else { + 40 +}; + +s! { + pub struct utmpx { + pub ut_name: [c_char; _UTX_USERSIZE], + pub ut_id: [c_char; _UTX_IDSIZE], + pub ut_line: [c_char; _UTX_LINESIZE], + pub ut_host: [c_char; _UTX_HOSTSIZE], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: crate::pid_t, + pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported + pub ut_ss: crate::sockaddr_storage, + pub ut_tv: crate::timeval, + ut_pad: [u8; _UTX_PADSIZE], + } + + pub struct __exit_status { + pub e_termination: u16, + pub e_exit: u16, + } + + pub struct lastlogx { + pub ll_tv: crate::timeval, + pub ll_line: [c_char; _UTX_LINESIZE], + pub ll_host: [c_char; _UTX_HOSTSIZE], + pub ll_ss: crate::sockaddr_storage, + } +} + +#[link(name = "util")] +extern "C" { + pub fn setutxent(); + pub fn endutxent(); + + #[link_name = "__getutxent50"] + pub fn getutxent() -> *mut utmpx; + #[link_name = "__getutxid50"] + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__getutxline50"] + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__pututxline50"] + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + + #[link_name = "__updwtmpx50"] + pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; + #[link_name = "__getlastlogx50"] + pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) + -> *mut lastlogx; + + #[link_name = "__updlastlogx50"] + pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; + #[link_name = "__getutmp50"] + pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp); + #[link_name = "__getutmpx50"] + pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx); + pub fn utmpxname(file: *const c_char) -> c_int; +} diff --git a/src/new/newlib/mod.rs b/src/new/newlib/mod.rs new file mode 100644 index 0000000000000..b5c7e3dc73a0a --- /dev/null +++ b/src/new/newlib/mod.rs @@ -0,0 +1,4 @@ +//! Newlib libc. +// FIXME(newlib): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/newlib/unistd.rs b/src/new/newlib/unistd.rs new file mode 100644 index 0000000000000..6b240be9b7698 --- /dev/null +++ b/src/new/newlib/unistd.rs @@ -0,0 +1,159 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; +use crate::prelude::*; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_JOB_CONTROL: c_int = 5; +pub const _SC_SAVED_IDS: c_int = 6; +pub const _SC_VERSION: c_int = 7; +pub const _SC_PAGESIZE: c_int = 8; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_NPROCESSORS_CONF: c_int = 9; +pub const _SC_NPROCESSORS_ONLN: c_int = 10; +pub const _SC_PHYS_PAGES: c_int = 11; +pub const _SC_AVPHYS_PAGES: c_int = 12; +pub const _SC_MQ_OPEN_MAX: c_int = 13; +pub const _SC_MQ_PRIO_MAX: c_int = 14; +pub const _SC_RTSIG_MAX: c_int = 15; +pub const _SC_SEM_NSEMS_MAX: c_int = 16; +pub const _SC_SEM_VALUE_MAX: c_int = 17; +pub const _SC_SIGQUEUE_MAX: c_int = 18; +pub const _SC_TIMER_MAX: c_int = 19; +pub const _SC_TZNAME_MAX: c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: c_int = 21; +pub const _SC_FSYNC: c_int = 22; +pub const _SC_MAPPED_FILES: c_int = 23; +pub const _SC_MEMLOCK: c_int = 24; +pub const _SC_MEMLOCK_RANGE: c_int = 25; +pub const _SC_MEMORY_PROTECTION: c_int = 26; +pub const _SC_MESSAGE_PASSING: c_int = 27; +pub const _SC_PRIORITIZED_IO: c_int = 28; +pub const _SC_REALTIME_SIGNALS: c_int = 29; +pub const _SC_SEMAPHORES: c_int = 30; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 31; +pub const _SC_SYNCHRONIZED_IO: c_int = 32; +pub const _SC_TIMERS: c_int = 33; +pub const _SC_AIO_LISTIO_MAX: c_int = 34; +pub const _SC_AIO_MAX: c_int = 35; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 36; +pub const _SC_DELAYTIMER_MAX: c_int = 37; +pub const _SC_THREAD_KEYS_MAX: c_int = 38; +pub const _SC_THREAD_STACK_MIN: c_int = 39; +pub const _SC_THREAD_THREADS_MAX: c_int = 40; +pub const _SC_TTY_NAME_MAX: c_int = 41; +pub const _SC_THREADS: c_int = 42; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 43; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 44; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 45; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 46; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 47; +pub const _SC_THREAD_PRIO_CEILING: c_int = _SC_THREAD_PRIO_PROTECT; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 48; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 49; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 50; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 51; +pub const _SC_LOGIN_NAME_MAX: c_int = 52; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 53; +pub const _SC_ADVISORY_INFO: c_int = 54; +pub const _SC_ATEXIT_MAX: c_int = 55; +pub const _SC_BARRIERS: c_int = 56; +pub const _SC_BC_BASE_MAX: c_int = 57; +pub const _SC_BC_DIM_MAX: c_int = 58; +pub const _SC_BC_SCALE_MAX: c_int = 59; +pub const _SC_BC_STRING_MAX: c_int = 60; +pub const _SC_CLOCK_SELECTION: c_int = 61; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 62; +pub const _SC_CPUTIME: c_int = 63; +pub const _SC_EXPR_NEST_MAX: c_int = 64; +pub const _SC_HOST_NAME_MAX: c_int = 65; +pub const _SC_IOV_MAX: c_int = 66; +pub const _SC_IPV6: c_int = 67; +pub const _SC_LINE_MAX: c_int = 68; +pub const _SC_MONOTONIC_CLOCK: c_int = 69; +pub const _SC_RAW_SOCKETS: c_int = 70; +pub const _SC_READER_WRITER_LOCKS: c_int = 71; +pub const _SC_REGEXP: c_int = 72; +pub const _SC_RE_DUP_MAX: c_int = 73; +pub const _SC_SHELL: c_int = 74; +pub const _SC_SPAWN: c_int = 75; +pub const _SC_SPIN_LOCKS: c_int = 76; +pub const _SC_SPORADIC_SERVER: c_int = 77; +pub const _SC_SS_REPL_MAX: c_int = 78; +pub const _SC_SYMLOOP_MAX: c_int = 79; +pub const _SC_THREAD_CPUTIME: c_int = 80; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 81; +pub const _SC_TIMEOUTS: c_int = 82; +pub const _SC_TRACE: c_int = 83; +pub const _SC_TRACE_EVENT_FILTER: c_int = 84; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 85; +pub const _SC_TRACE_INHERIT: c_int = 86; +pub const _SC_TRACE_LOG: c_int = 87; +pub const _SC_TRACE_NAME_MAX: c_int = 88; +pub const _SC_TRACE_SYS_MAX: c_int = 89; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 90; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 91; +pub const _SC_V7_ILP32_OFF32: c_int = 92; +pub const _SC_V6_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_XBS5_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_V7_ILP32_OFFBIG: c_int = 93; +pub const _SC_V6_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_V7_LP64_OFF64: c_int = 94; +pub const _SC_V6_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_XBS5_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 95; +pub const _SC_V6_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XOPEN_CRYPT: c_int = 96; +pub const _SC_XOPEN_ENH_I18N: c_int = 97; +pub const _SC_XOPEN_LEGACY: c_int = 98; +pub const _SC_XOPEN_REALTIME: c_int = 99; +pub const _SC_STREAM_MAX: c_int = 100; +pub const _SC_PRIORITY_SCHEDULING: c_int = 101; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 102; +pub const _SC_XOPEN_SHM: c_int = 103; +pub const _SC_XOPEN_STREAMS: c_int = 104; +pub const _SC_XOPEN_UNIX: c_int = 105; +pub const _SC_XOPEN_VERSION: c_int = 106; +pub const _SC_2_CHAR_TERM: c_int = 107; +pub const _SC_2_C_BIND: c_int = 108; +pub const _SC_2_C_DEV: c_int = 109; +pub const _SC_2_FORT_DEV: c_int = 110; +pub const _SC_2_FORT_RUN: c_int = 111; +pub const _SC_2_LOCALEDEF: c_int = 112; +pub const _SC_2_PBS: c_int = 113; +pub const _SC_2_PBS_ACCOUNTING: c_int = 114; +pub const _SC_2_PBS_CHECKPOINT: c_int = 115; +pub const _SC_2_PBS_LOCATE: c_int = 116; +pub const _SC_2_PBS_MESSAGE: c_int = 117; +pub const _SC_2_PBS_TRACK: c_int = 118; +pub const _SC_2_SW_DEV: c_int = 119; +pub const _SC_2_UPE: c_int = 120; +pub const _SC_2_VERSION: c_int = 121; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 122; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 123; +pub const _SC_XOPEN_UUCP: c_int = 124; +pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 125; +pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 126; +pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 127; +pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 128; +pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 129; +pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 130; +pub const _SC_LEVEL2_CACHE_SIZE: c_int = 131; +pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 132; +pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 133; +pub const _SC_LEVEL3_CACHE_SIZE: c_int = 134; +pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 135; +pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 136; +pub const _SC_LEVEL4_CACHE_SIZE: c_int = 137; +pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 138; +pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 139; diff --git a/src/new/nto/mod.rs b/src/new/nto/mod.rs new file mode 100644 index 0000000000000..df8ec183bd789 --- /dev/null +++ b/src/new/nto/mod.rs @@ -0,0 +1,4 @@ +//! QNX Neutrino libc. +// FIXME(nto): link to manpages needed. + +pub(crate) mod unistd; diff --git a/src/new/nto/unistd.rs b/src/new/nto/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/nto/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/nuttx/mod.rs b/src/new/nuttx/mod.rs new file mode 100644 index 0000000000000..513c945dbfd9b --- /dev/null +++ b/src/new/nuttx/mod.rs @@ -0,0 +1,4 @@ +//! RTEMS libc. +// FIXME(nuttx): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/nuttx/unistd.rs b/src/new/nuttx/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/nuttx/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/openbsd/mod.rs b/src/new/openbsd/mod.rs new file mode 100644 index 0000000000000..25fa784b2b004 --- /dev/null +++ b/src/new/openbsd/mod.rs @@ -0,0 +1,7 @@ +//! OpenBSD libc. +//! +//! * Headers: +//! * Manual pages: + +pub(crate) mod sys; +pub(crate) mod unistd; diff --git a/src/new/openbsd/sys/ipc.rs b/src/new/openbsd/sys/ipc.rs new file mode 100644 index 0000000000000..59774405bcdd0 --- /dev/null +++ b/src/new/openbsd/sys/ipc.rs @@ -0,0 +1,17 @@ +//! Header: `sys/ipc.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct ipc_perm { + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub mode: crate::mode_t, + pub seq: c_ushort, + pub key: crate::key_t, + } +} diff --git a/src/new/openbsd/sys/mod.rs b/src/new/openbsd/sys/mod.rs new file mode 100644 index 0000000000000..7ba77c537356e --- /dev/null +++ b/src/new/openbsd/sys/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `sys/` +//! +//! https://github.com/openbsd/src/tree/trunk/sys/sys + +pub(crate) mod ipc; diff --git a/src/new/openbsd/unistd.rs b/src/new/openbsd/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/openbsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/redox/mod.rs b/src/new/redox/mod.rs new file mode 100644 index 0000000000000..cf7806a2437ad --- /dev/null +++ b/src/new/redox/mod.rs @@ -0,0 +1,3 @@ +//! Redox libc. +//! +//! * Headers: diff --git a/src/new/relibc/mod.rs b/src/new/relibc/mod.rs new file mode 100644 index 0000000000000..d2449123218a1 --- /dev/null +++ b/src/new/relibc/mod.rs @@ -0,0 +1,5 @@ +//! Redox OS libc. +//! +//! * Headers: + +pub(crate) mod unistd; diff --git a/src/new/relibc/unistd.rs b/src/new/relibc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/relibc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/rtems/mod.rs b/src/new/rtems/mod.rs new file mode 100644 index 0000000000000..bd3dc3954c71e --- /dev/null +++ b/src/new/rtems/mod.rs @@ -0,0 +1,2 @@ +//! RTEMS libc. +// FIXME(rtems): link to headers needed. diff --git a/src/new/sgx/mod.rs b/src/new/sgx/mod.rs new file mode 100644 index 0000000000000..8c15dadb4a0b8 --- /dev/null +++ b/src/new/sgx/mod.rs @@ -0,0 +1 @@ +//! Fortanix SGX. diff --git a/src/new/sgx/unistd.rs b/src/new/sgx/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/sgx/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/solaris/mod.rs b/src/new/solaris/mod.rs new file mode 100644 index 0000000000000..97ae47333deb4 --- /dev/null +++ b/src/new/solaris/mod.rs @@ -0,0 +1,5 @@ +//! Solaris libc. +//! +//! * Manual pages: (under "Reference Manuals") + +pub(crate) mod unistd; diff --git a/src/new/solaris/unistd.rs b/src/new/solaris/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/solaris/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/solid/mod.rs b/src/new/solid/mod.rs new file mode 100644 index 0000000000000..4a197cfb62c5a --- /dev/null +++ b/src/new/solid/mod.rs @@ -0,0 +1,2 @@ +//! Kyoto Microcomputer SOLID. +// FIXME(solid): link to headers needed. diff --git a/src/new/teeos/mod.rs b/src/new/teeos/mod.rs new file mode 100644 index 0000000000000..96f44d3d39361 --- /dev/null +++ b/src/new/teeos/mod.rs @@ -0,0 +1,2 @@ +//! Per the target docs, TEEOS uses part of musl as its libc. +// FIXME(teeos): link to headers needed. diff --git a/src/new/trusty/mod.rs b/src/new/trusty/mod.rs new file mode 100644 index 0000000000000..261ecb09e46de --- /dev/null +++ b/src/new/trusty/mod.rs @@ -0,0 +1,2 @@ +//! Trusty libc. +// FIXME(trusty): link to headers needed. diff --git a/src/new/uclibc/mod.rs b/src/new/uclibc/mod.rs new file mode 100644 index 0000000000000..6bf83ef2e1d38 --- /dev/null +++ b/src/new/uclibc/mod.rs @@ -0,0 +1,7 @@ +//! uClibc. +//! +//! * About: +//! * Headers: (mirror) + +pub(crate) mod pthread; +pub(crate) mod unistd; diff --git a/src/new/uclibc/pthread.rs b/src/new/uclibc/pthread.rs new file mode 100644 index 0000000000000..bd7075d1ce2ef --- /dev/null +++ b/src/new/uclibc/pthread.rs @@ -0,0 +1,64 @@ +//! Header: `pthread.h` +//! +//! Note that The l4re port of uclibc doesn't yet support all `pthread_*` API that is +//! available upstream. + +pub use crate::new::common::linux_like::pthread::pthread_getattr_np; +#[cfg(not(target_os = "l4re"))] +pub use crate::new::common::linux_like::pthread::{ + pthread_getaffinity_np, + pthread_getname_np, + pthread_setaffinity_np, + pthread_setname_np, +}; +#[cfg(not(target_os = "l4re"))] +pub use crate::new::common::posix::pthread::{ + pthread_atfork, + pthread_barrierattr_getpshared, + pthread_getcpuclockid, + pthread_mutex_consistent, + pthread_mutexattr_getprotocol, + pthread_mutexattr_getrobust, + pthread_mutexattr_setprotocol, + pthread_mutexattr_setrobust, + pthread_setschedprio, +}; +pub use crate::new::common::posix::pthread::{ + pthread_attr_getguardsize, + pthread_attr_getinheritsched, + pthread_attr_getschedparam, + pthread_attr_getschedpolicy, + pthread_attr_getstack, + pthread_attr_setguardsize, + pthread_attr_setinheritsched, + pthread_attr_setschedparam, + pthread_attr_setschedpolicy, + pthread_attr_setstack, + pthread_barrier_destroy, + pthread_barrier_init, + pthread_barrier_wait, + pthread_barrierattr_destroy, + pthread_barrierattr_init, + pthread_barrierattr_setpshared, + pthread_cancel, + pthread_condattr_getclock, + pthread_condattr_getpshared, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_getschedparam, + pthread_kill, + pthread_mutex_timedlock, + pthread_mutexattr_getpshared, + pthread_mutexattr_setpshared, + pthread_once, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, + pthread_sigmask, + pthread_spin_destroy, + pthread_spin_init, + pthread_spin_lock, + pthread_spin_trylock, + pthread_spin_unlock, +}; diff --git a/src/new/uclibc/unistd.rs b/src/new/uclibc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/uclibc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/ucrt/mod.rs b/src/new/ucrt/mod.rs new file mode 100644 index 0000000000000..f6b5f5d1ef8fc --- /dev/null +++ b/src/new/ucrt/mod.rs @@ -0,0 +1,4 @@ +//! Windows Universal C Runtime. +//! +//! * Manual pages: +//! * UCRT information: diff --git a/src/new/vita/mod.rs b/src/new/vita/mod.rs new file mode 100644 index 0000000000000..38783a3f19fbc --- /dev/null +++ b/src/new/vita/mod.rs @@ -0,0 +1,4 @@ +//! VITASDK system library. +// FIXME(vita): link to headers or manpages needed. + +pub(crate) mod unistd; diff --git a/src/new/vita/unistd.rs b/src/new/vita/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/vita/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/vxworks/mod.rs b/src/new/vxworks/mod.rs new file mode 100644 index 0000000000000..65630565e53e0 --- /dev/null +++ b/src/new/vxworks/mod.rs @@ -0,0 +1,4 @@ +//! VxWorks libc. +// FIXME(vxworks): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/vxworks/unistd.rs b/src/new/vxworks/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/vxworks/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/wasi/mod.rs b/src/new/wasi/mod.rs new file mode 100644 index 0000000000000..341e6d5d16499 --- /dev/null +++ b/src/new/wasi/mod.rs @@ -0,0 +1,3 @@ +//! WASI libc. +//! +//! * Headers: diff --git a/src/new/xous/mod.rs b/src/new/xous/mod.rs new file mode 100644 index 0000000000000..8a9a28586c448 --- /dev/null +++ b/src/new/xous/mod.rs @@ -0,0 +1,2 @@ +//! Xous libc. +// FIXME(xous): link to headers needed. diff --git a/src/solid/mod.rs b/src/solid/mod.rs index 40d6a9d348586..37c7fe5f0a342 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -395,21 +395,9 @@ pub const SIGUSR1: c_int = 30; pub const SIGUSR2: c_int = 31; pub const SIGPWR: c_int = 32; -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} } extern "C" { diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index fd9c0b168aba4..f9f8569360f97 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -61,89 +61,81 @@ pub type wctype_t = c_ulong; pub type cmpfunc = extern "C" fn(x: *const c_void, y: *const c_void) -> c_int; -#[repr(align(16))] -pub struct _CLongDouble(pub u128); - -#[repr(align(8))] -#[repr(C)] -pub struct pthread_cond_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_COND_T], +s_paren! { + #[repr(align(16))] + pub struct _CLongDouble(pub u128); } -#[repr(align(8))] -#[repr(C)] -pub struct pthread_mutex_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], -} +s! { + #[repr(align(8))] + pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_COND_T], + } -#[repr(align(4))] -#[repr(C)] -pub struct pthread_mutexattr_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], -} + #[repr(align(8))] + pub struct pthread_mutex_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } -#[repr(align(4))] -#[repr(C)] -pub struct pthread_condattr_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], -} + #[repr(align(4))] + pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } -#[repr(C)] -pub struct pthread_attr_t { - __size: [u64; 7], -} + #[repr(align(4))] + pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } -#[repr(C)] -pub struct cpu_set_t { - bits: [c_ulong; 128 / size_of::()], -} + pub struct pthread_attr_t { + __size: [u64; 7], + } -#[repr(C)] -pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, -} + pub struct cpu_set_t { + bits: [c_ulong; 128 / size_of::()], + } -#[repr(C)] -pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, -} + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } -#[repr(C)] -pub struct tm { - pub tm_sec: c_int, - pub tm_min: c_int, - pub tm_hour: c_int, - pub tm_mday: c_int, - pub tm_mon: c_int, - pub tm_year: c_int, - pub tm_wday: c_int, - pub tm_yday: c_int, - pub tm_isdst: c_int, - pub __tm_gmtoff: c_long, - pub __tm_zone: *const c_char, -} + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } -#[repr(C)] -pub struct mbstate_t { - pub __opaque1: c_uint, - pub __opaque2: c_uint, -} + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub __tm_gmtoff: c_long, + pub __tm_zone: *const c_char, + } -#[repr(C)] -pub struct sem_t { - pub __val: [c_int; 4 * size_of::() / size_of::()], -} + pub struct mbstate_t { + pub __opaque1: c_uint, + pub __opaque2: c_uint, + } -#[repr(C)] -pub struct div_t { - pub quot: c_int, - pub rem: c_int, + pub struct sem_t { + pub __val: [c_int; 4 * size_of::() / size_of::()], + } + + pub struct div_t { + pub quot: c_int, + pub rem: c_int, + } } // fcntl diff --git a/src/types.rs b/src/types.rs index 7d49a425d59ea..4a7514564b22b 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,7 @@ //! Platform-agnostic support types. +#[cfg(feature = "extra_traits")] +use core::hash::Hash; use core::mem::MaybeUninit; use crate::prelude::*; @@ -30,6 +32,24 @@ impl fmt::Debug for Padding { } } +/// Do nothing when hashing to ignore the existence of padding fields. +#[cfg(feature = "extra_traits")] +impl Hash for Padding { + fn hash(&self, _state: &mut H) {} +} + +/// Padding fields are all equal, regardless of what is inside them, so they do not affect anything. +#[cfg(feature = "extra_traits")] +impl PartialEq for Padding { + fn eq(&self, _other: &Self) -> bool { + true + } +} + +/// Mark that `Padding` implements `Eq` so that it can be used in types that implement it. +#[cfg(feature = "extra_traits")] +impl Eq for Padding {} + /// The default repr type used for C style enums in Rust. #[cfg(target_env = "msvc")] #[allow(unused)] diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index b6d1af52d133c..356d2a0c402da 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{in_addr_t, in_port_t}; +use crate::{ + in_addr_t, + in_port_t, +}; pub type caddr_t = *mut c_char; pub type clockid_t = c_longlong; @@ -247,9 +250,9 @@ s! { pub struct sockaddr_storage { pub __ss_len: c_uchar, pub ss_family: sa_family_t, - __ss_pad1: [c_char; 6], + __ss_pad1: Padding<[c_char; 6]>, __ss_align: crate::int64_t, - __ss_pad2: [c_char; 1265], + __ss_pad2: Padding<[c_char; 1265]>, } pub struct sockaddr_un { @@ -263,6 +266,15 @@ s! { pub tv_nsec: c_int, } + // On AIX, declares 'tv_nsec' as 'long', but the underlying + // system calls return a 4-byte value in both 32-bit and 64-bit modes. + // It is declared as 'c_int' here to avoid using the other undefined 4 + // bytes in the 64-bit mode. + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_int, + } + pub struct statfs64 { pub f_version: c_int, pub f_type: c_int, @@ -314,6 +326,8 @@ s! { pub cmsg_type: c_int, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigevent { pub sigev_value: crate::sigval, pub sigev_signo: c_int, @@ -530,14 +544,6 @@ s! { pub sa_mask: sigset_t, pub sa_flags: c_int, } -} - -s_no_extra_traits! { - pub union __poll_ctl_ext_u { - pub addr: *mut c_void, - pub data32: u32, - pub data: u64, - } pub struct poll_ctl_ext { pub version: u8, @@ -549,6 +555,14 @@ s_no_extra_traits! { } } +s_no_extra_traits! { + pub union __poll_ctl_ext_u { + pub addr: *mut c_void, + pub data32: u32, + pub data: u64, + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for __poll_ctl_ext_u { @@ -570,28 +584,6 @@ cfg_if! { } } } - - impl PartialEq for poll_ctl_ext { - fn eq(&self, other: &poll_ctl_ext) -> bool { - self.version == other.version - && self.command == other.command - && self.events == other.events - && self.fd == other.fd - && self.reserved64 == other.reserved64 - && self.u == other.u - } - } - impl Eq for poll_ctl_ext {} - impl hash::Hash for poll_ctl_ext { - fn hash(&self, state: &mut H) { - self.version.hash(state); - self.command.hash(state); - self.events.hash(state); - self.fd.hash(state); - self.u.hash(state); - self.reserved64.hash(state); - } - } } } @@ -1261,7 +1253,8 @@ pub const ENOLCK: c_int = 49; pub const ENOCONNECT: c_int = 50; pub const ESTALE: c_int = 52; pub const EDIST: c_int = 53; -pub const EWOULDBLOCK: c_int = 54; +// POSIX allows EWOULDBLOCK to be the same value as EAGAIN. +pub const EWOULDBLOCK: c_int = EAGAIN; pub const EINPROGRESS: c_int = 55; pub const EALREADY: c_int = 56; pub const ENOTSOCK: c_int = 57; @@ -2260,9 +2253,6 @@ pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 11; pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 12; // unistd.h -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const _POSIX_VDISABLE: c_int = 0xff; pub const _PC_LINK_MAX: c_int = 11; pub const _PC_MAX_CANON: c_int = 12; diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index ba4ddc057c40b..a936ddb7e2f99 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -2,8 +2,7 @@ use crate::off_t; use crate::prelude::*; // Define lock_data_instrumented as an empty enum -missing! { - #[derive(Debug)] +extern_ty! { pub enum lock_data_instrumented {} } @@ -245,9 +244,7 @@ s! { pub msg_wwait: c_int, pub msg_reqevents: c_ushort, } -} -s_no_extra_traits! { pub struct siginfo_t { pub si_signo: c_int, pub si_errno: c_int, @@ -262,6 +259,15 @@ s_no_extra_traits! { pub __pad: [c_int; 3], } + pub struct pollfd_ext { + pub fd: c_int, + pub events: c_short, + pub revents: c_short, + pub data: __pollfd_ext_u, + } +} + +s_no_extra_traits! { pub union _kernel_simple_lock { pub _slock: c_long, pub _slockp: *mut lock_data_instrumented, @@ -336,13 +342,6 @@ s_no_extra_traits! { pub data: u64, } - pub struct pollfd_ext { - pub fd: c_int, - pub events: c_short, - pub revents: c_short, - pub data: __pollfd_ext_u, - } - pub struct fpreg_t { pub d: c_double, } @@ -372,36 +371,6 @@ impl siginfo_t { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_errno == other.si_errno - && self.si_code == other.si_code - && self.si_pid == other.si_pid - && self.si_uid == other.si_uid - && self.si_status == other.si_status - && self.si_addr == other.si_addr - && self.si_band == other.si_band - && self.__si_flags == other.__si_flags - && self.si_value == other.si_value - } - } - impl Eq for siginfo_t {} - impl hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_errno.hash(state); - self.si_code.hash(state); - self.si_pid.hash(state); - self.si_uid.hash(state); - self.si_status.hash(state); - self.si_addr.hash(state); - self.si_band.hash(state); - self.si_value.hash(state); - self.__si_flags.hash(state); - } - } - impl PartialEq for __pollfd_ext_u { fn eq(&self, other: &__pollfd_ext_u) -> bool { unsafe { @@ -422,34 +391,15 @@ cfg_if! { } } - impl PartialEq for pollfd_ext { - fn eq(&self, other: &pollfd_ext) -> bool { - self.fd == other.fd - && self.events == other.events - && self.revents == other.revents - && self.data == other.data - } - } - impl Eq for pollfd_ext {} - impl hash::Hash for pollfd_ext { - fn hash(&self, state: &mut H) { - self.fd.hash(state); - self.events.hash(state); - self.revents.hash(state); - self.data.hash(state); - } - } impl PartialEq for fpreg_t { fn eq(&self, other: &fpreg_t) -> bool { self.d == other.d } } - impl Eq for fpreg_t {} - impl hash::Hash for fpreg_t { fn hash(&self, state: &mut H) { - let d: u64 = unsafe { mem::transmute(self.d) }; + let d: u64 = self.d.to_bits(); d.hash(state); } } diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index bd6762558f508..ab0c94ef4c2c2 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -50,72 +50,16 @@ s! { } s_no_extra_traits! { - pub struct pthread_attr_t { - __sig: c_long, - __opaque: [c_char; 36], - } - - pub struct pthread_once_t { - __sig: c_long, - __opaque: [c_char; crate::__PTHREAD_ONCE_SIZE__], - } - #[repr(align(16))] pub struct max_align_t { priv_: [f64; 2], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for pthread_attr_t { - fn eq(&self, other: &pthread_attr_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for pthread_attr_t {} - impl hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - impl PartialEq for pthread_once_t { - fn eq(&self, other: &pthread_once_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for pthread_once_t {} - impl hash::Hash for pthread_once_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - } -} - #[doc(hidden)] #[deprecated(since = "0.2.55")] pub const NET_RT_MAXID: c_int = 10; -pub const __PTHREAD_MUTEX_SIZE__: usize = 40; -pub const __PTHREAD_COND_SIZE__: usize = 24; -pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; -pub const __PTHREAD_ONCE_SIZE__: usize = 4; -pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; -pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12; - pub const TIOCTIMESTAMP: c_ulong = 0x40087459; pub const TIOCDCDTIMESTAMP: c_ulong = 0x40087458; @@ -124,12 +68,6 @@ pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; pub const BIOCSETFNR: c_ulong = 0x8008427e; -const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; -pub const PTHREAD_ONCE_INIT: crate::pthread_once_t = crate::pthread_once_t { - __sig: _PTHREAD_ONCE_SIG_INIT, - __opaque: [0; 4], -}; - extern "C" { pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_ulong) -> c_int; } diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index a13013c09b03b..b5cbe8ff5175f 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -1,49 +1,11 @@ use crate::prelude::*; pub type boolean_t = c_int; -pub type mcontext_t = *mut __darwin_mcontext64; s! { pub struct malloc_zone_t { __private: [crate::uintptr_t; 18], // FIXME(macos): needs arm64 auth pointers support } - - pub struct ucontext_t { - pub uc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub uc_stack: crate::stack_t, - pub uc_link: *mut crate::ucontext_t, - pub uc_mcsize: usize, - pub uc_mcontext: mcontext_t, - } - - pub struct __darwin_mcontext64 { - pub __es: __darwin_arm_exception_state64, - pub __ss: __darwin_arm_thread_state64, - pub __ns: __darwin_arm_neon_state64, - } - - pub struct __darwin_arm_exception_state64 { - pub __far: u64, - pub __esr: u32, - pub __exception: u32, - } - - pub struct __darwin_arm_thread_state64 { - pub __x: [u64; 29], - pub __fp: u64, - pub __lr: u64, - pub __sp: u64, - pub __pc: u64, - pub __cpsr: u32, - pub __pad: u32, - } - - pub struct __darwin_arm_neon_state64 { - pub __v: [crate::__uint128_t; 32], - pub __fpsr: u32, - pub __fpcr: u32, - } } s_no_extra_traits! { diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index 34743464a44e7..4ef2799e8c5fb 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -48,68 +48,10 @@ s! { } } -s_no_extra_traits! { - pub struct pthread_attr_t { - __sig: c_long, - __opaque: [c_char; 56], - } - - pub struct pthread_once_t { - __sig: c_long, - __opaque: [c_char; __PTHREAD_ONCE_SIZE__], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for pthread_attr_t { - fn eq(&self, other: &pthread_attr_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for pthread_attr_t {} - impl hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - impl PartialEq for pthread_once_t { - fn eq(&self, other: &pthread_once_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for pthread_once_t {} - impl hash::Hash for pthread_once_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - } -} - #[doc(hidden)] #[deprecated(since = "0.2.55")] pub const NET_RT_MAXID: c_int = 11; -pub const __PTHREAD_MUTEX_SIZE__: usize = 56; -pub const __PTHREAD_COND_SIZE__: usize = 40; -pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; -pub const __PTHREAD_ONCE_SIZE__: usize = 8; -pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; -pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16; - pub const TIOCTIMESTAMP: c_ulong = 0x40107459; pub const TIOCDCDTIMESTAMP: c_ulong = 0x40107458; @@ -118,12 +60,6 @@ pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; pub const BIOCSETFNR: c_ulong = 0x8010427e; -const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; -pub const PTHREAD_ONCE_INIT: crate::pthread_once_t = crate::pthread_once_t { - __sig: _PTHREAD_ONCE_SIG_INIT, - __opaque: [0; 8], -}; - extern "C" { pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_uint) -> c_int; } diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index 5365becf66c3e..2b22f489b9c6b 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -1,110 +1,8 @@ use crate::prelude::*; pub type boolean_t = c_uint; -pub type mcontext_t = *mut __darwin_mcontext64; s! { - pub struct ucontext_t { - pub uc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub uc_stack: crate::stack_t, - pub uc_link: *mut crate::ucontext_t, - pub uc_mcsize: usize, - pub uc_mcontext: mcontext_t, - } - - pub struct __darwin_mcontext64 { - pub __es: __darwin_x86_exception_state64, - pub __ss: __darwin_x86_thread_state64, - pub __fs: __darwin_x86_float_state64, - } - - pub struct __darwin_x86_exception_state64 { - pub __trapno: u16, - pub __cpu: u16, - pub __err: u32, - pub __faultvaddr: u64, - } - - pub struct __darwin_x86_thread_state64 { - pub __rax: u64, - pub __rbx: u64, - pub __rcx: u64, - pub __rdx: u64, - pub __rdi: u64, - pub __rsi: u64, - pub __rbp: u64, - pub __rsp: u64, - pub __r8: u64, - pub __r9: u64, - pub __r10: u64, - pub __r11: u64, - pub __r12: u64, - pub __r13: u64, - pub __r14: u64, - pub __r15: u64, - pub __rip: u64, - pub __rflags: u64, - pub __cs: u64, - pub __fs: u64, - pub __gs: u64, - } - - pub struct __darwin_x86_float_state64 { - pub __fpu_reserved: [c_int; 2], - __fpu_fcw: c_short, - __fpu_fsw: c_short, - pub __fpu_ftw: u8, - pub __fpu_rsrv1: u8, - pub __fpu_fop: u16, - pub __fpu_ip: u32, - pub __fpu_cs: u16, - pub __fpu_rsrv2: u16, - pub __fpu_dp: u32, - pub __fpu_ds: u16, - pub __fpu_rsrv3: u16, - pub __fpu_mxcsr: u32, - pub __fpu_mxcsrmask: u32, - pub __fpu_stmm0: __darwin_mmst_reg, - pub __fpu_stmm1: __darwin_mmst_reg, - pub __fpu_stmm2: __darwin_mmst_reg, - pub __fpu_stmm3: __darwin_mmst_reg, - pub __fpu_stmm4: __darwin_mmst_reg, - pub __fpu_stmm5: __darwin_mmst_reg, - pub __fpu_stmm6: __darwin_mmst_reg, - pub __fpu_stmm7: __darwin_mmst_reg, - pub __fpu_xmm0: __darwin_xmm_reg, - pub __fpu_xmm1: __darwin_xmm_reg, - pub __fpu_xmm2: __darwin_xmm_reg, - pub __fpu_xmm3: __darwin_xmm_reg, - pub __fpu_xmm4: __darwin_xmm_reg, - pub __fpu_xmm5: __darwin_xmm_reg, - pub __fpu_xmm6: __darwin_xmm_reg, - pub __fpu_xmm7: __darwin_xmm_reg, - pub __fpu_xmm8: __darwin_xmm_reg, - pub __fpu_xmm9: __darwin_xmm_reg, - pub __fpu_xmm10: __darwin_xmm_reg, - pub __fpu_xmm11: __darwin_xmm_reg, - pub __fpu_xmm12: __darwin_xmm_reg, - pub __fpu_xmm13: __darwin_xmm_reg, - pub __fpu_xmm14: __darwin_xmm_reg, - pub __fpu_xmm15: __darwin_xmm_reg, - // this field is actually [u8; 96], but defining it with a bigger type - // allows us to auto-implement traits for it since the length of the - // array is less than 32 - __fpu_rsrv4: [u32; 24], - pub __fpu_reserved1: c_int, - } - - pub struct __darwin_mmst_reg { - pub __mmst_reg: [c_char; 10], - pub __mmst_rsrv: [c_char; 6], - } - - pub struct __darwin_xmm_reg { - pub __xmm_reg: [c_char; 16], - } - pub struct malloc_introspection_t { _private: [crate::uintptr_t; 16], // FIXME(macos): keeping private for now } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 857508f794ad1..00c7e5f1754dc 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3,7 +3,10 @@ //! This covers *-apple-* triples currently use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type wchar_t = i32; pub type clock_t = c_ulong; @@ -15,7 +18,6 @@ pub type mode_t = u16; pub type nlink_t = u16; pub type blksize_t = i32; pub type rlim_t = u64; -pub type pthread_key_t = c_ulong; pub type sigset_t = u32; pub type clockid_t = c_uint; pub type fsblkcnt_t = c_uint; @@ -128,8 +130,6 @@ pub type thread_latency_qos_policy_t = *mut thread_latency_qos_policy; pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy; pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy; -pub type pthread_introspection_hook_t = - extern "C" fn(event: c_uint, thread: crate::pthread_t, addr: *mut c_void, size: size_t); pub type pthread_jit_write_callback_t = Option c_int>; pub type os_clockid_t = u32; @@ -179,30 +179,8 @@ deprecated_mach! { pub type mach_timebase_info_data_t = mach_timebase_info; } -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} - -#[derive(Debug)] -#[repr(u32)] -pub enum qos_class_t { - QOS_CLASS_USER_INTERACTIVE = 0x21, - QOS_CLASS_USER_INITIATED = 0x19, - QOS_CLASS_DEFAULT = 0x15, - QOS_CLASS_UTILITY = 0x11, - QOS_CLASS_BACKGROUND = 0x09, - QOS_CLASS_UNSPECIFIED = 0x00, -} -impl Copy for qos_class_t {} -impl Clone for qos_class_t { - fn clone(&self) -> qos_class_t { - *self - } +extern_ty! { + pub enum timezone {} } #[derive(Debug)] @@ -286,18 +264,18 @@ s! { pub struct glob_t { pub gl_pathc: size_t, - __unused1: c_int, + __unused1: Padding, pub gl_offs: size_t, - __unused2: c_int, + __unused2: Padding, pub gl_pathv: *mut *mut c_char, - __unused3: *mut c_void, + __unused3: Padding<*mut c_void>, - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + __unused8: Padding<*mut c_void>, } pub struct addrinfo { @@ -342,21 +320,6 @@ s! { pub st_qspare: [i64; 2], } - pub struct pthread_mutexattr_t { - __sig: c_long, - __opaque: [u8; 8], - } - - pub struct pthread_condattr_t { - __sig: c_long, - __opaque: [u8; __PTHREAD_CONDATTR_SIZE__], - } - - pub struct pthread_rwlockattr_t { - __sig: c_long, - __opaque: [u8; __PTHREAD_RWLOCKATTR_SIZE__], - } - pub struct siginfo_t { pub si_signo: c_int, pub si_errno: c_int, @@ -367,7 +330,7 @@ s! { pub si_addr: *mut c_void, //Requires it to be union for tests //pub si_value: crate::sigval, - _pad: [usize; 9], + _pad: Padding<[usize; 9]>, } pub struct sigaction { @@ -903,12 +866,6 @@ s! { pub size: crate::vm_size_t, } - // sched.h - pub struct sched_param { - pub sched_priority: c_int, - __opaque: [c_char; 4], - } - pub struct vinfo_stat { pub vst_dev: u32, pub vst_mode: u16, @@ -1144,7 +1101,7 @@ s! { pub tcpi_state: u8, pub tcpi_snd_wscale: u8, pub tcpi_rcv_wscale: u8, - __pad1: u8, + __pad1: Padding, pub tcpi_options: u32, pub tcpi_flags: u32, pub tcpi_rto: u32, @@ -1172,7 +1129,7 @@ s! { pub tcpi_tfo_send_blackhole: u32, pub tcpi_tfo_recv_blackhole: u32, pub tcpi_tfo_onebyte_proxy: u32, - __pad2: u32, + __pad2: Padding, pub tcpi_txpackets: u64, pub tcpi_txbytes: u64, pub tcpi_txretransmitbytes: u64, @@ -1309,14 +1266,6 @@ s! { pub proc_fd: i32, pub proc_fdtype: u32, } -} - -s_no_extra_traits! { - #[repr(packed(4))] - pub struct ifconf { - pub ifc_len: c_int, - pub ifc_ifcu: __c_anonymous_ifc_ifcu, - } #[repr(packed(4))] pub struct kevent { @@ -1398,27 +1347,12 @@ s_no_extra_traits! { pub d_name: [c_char; 1024], } - pub struct pthread_rwlock_t { - __sig: c_long, - __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], - } - - pub struct pthread_mutex_t { - __sig: c_long, - __opaque: [u8; __PTHREAD_MUTEX_SIZE__], - } - - pub struct pthread_cond_t { - __sig: c_long, - __opaque: [u8; __PTHREAD_COND_SIZE__], - } - pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: crate::sa_family_t, - __ss_pad1: [u8; 6], + __ss_pad1: Padding<[u8; 6]>, __ss_align: i64, - __ss_pad2: [u8; 112], + __ss_pad2: Padding<[u8; 112]>, } pub struct utmpx { @@ -1436,7 +1370,7 @@ s_no_extra_traits! { pub sigev_notify: c_int, pub sigev_signo: c_int, pub sigev_value: crate::sigval, - __unused1: *mut c_void, //actually a function pointer + __unused1: Padding<*mut c_void>, //actually a function pointer pub sigev_notify_attributes: *mut crate::pthread_attr_t, } @@ -1612,11 +1546,6 @@ s_no_extra_traits! { pub ifdm_max: c_int, } - pub union __c_anonymous_ifk_data { - pub ifk_ptr: *mut c_void, - pub ifk_value: c_int, - } - #[repr(packed(4))] pub struct ifkpi { pub ifk_module_id: c_uint, @@ -1624,6 +1553,28 @@ s_no_extra_traits! { pub ifk_data: __c_anonymous_ifk_data, } + pub struct ifreq { + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub struct in6_ifreq { + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru6, + } +} + +s_no_extra_traits! { + #[repr(packed(4))] + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + pub union __c_anonymous_ifk_data { + pub ifk_ptr: *mut c_void, + pub ifk_value: c_int, + } + pub union __c_anonymous_ifr_ifru { pub ifru_addr: crate::sockaddr, pub ifru_dstaddr: crate::sockaddr, @@ -1643,11 +1594,6 @@ s_no_extra_traits! { pub ifru_functional_type: u32, } - pub struct ifreq { - pub ifr_name: [c_char; crate::IFNAMSIZ], - pub ifr_ifru: __c_anonymous_ifr_ifru, - } - pub union __c_anonymous_ifc_ifcu { pub ifcu_buf: *mut c_char, pub ifcu_req: *mut ifreq, @@ -1666,11 +1612,6 @@ s_no_extra_traits! { pub ifru_icmp6stat: icmp6_ifstat, pub ifru_scope_id: [u32; SCOPE6_ID_MAX], } - - pub struct in6_ifreq { - pub ifr_name: [c_char; crate::IFNAMSIZ], - pub ifr_ifru: __c_anonymous_ifr_ifru6, - } } impl siginfo_t { @@ -1754,838 +1695,6 @@ cfg_if! { } impl Eq for ifconf {} - impl PartialEq for kevent { - fn eq(&self, other: &kevent) -> bool { - self.ident == other.ident - && self.filter == other.filter - && self.flags == other.flags - && self.fflags == other.fflags - && self.data == other.data - && self.udata == other.udata - } - } - impl Eq for kevent {} - impl hash::Hash for kevent { - fn hash(&self, state: &mut H) { - let ident = self.ident; - let filter = self.filter; - let flags = self.flags; - let fflags = self.fflags; - let data = self.data; - let udata = self.udata; - ident.hash(state); - filter.hash(state); - flags.hash(state); - fflags.hash(state); - data.hash(state); - udata.hash(state); - } - } - - impl PartialEq for semid_ds { - fn eq(&self, other: &semid_ds) -> bool { - let sem_perm = self.sem_perm; - let sem_pad3 = self.sem_pad3; - let other_sem_perm = other.sem_perm; - let other_sem_pad3 = other.sem_pad3; - sem_perm == other_sem_perm - && self.sem_base == other.sem_base - && self.sem_nsems == other.sem_nsems - && self.sem_otime == other.sem_otime - && self.sem_pad1 == other.sem_pad1 - && self.sem_ctime == other.sem_ctime - && self.sem_pad2 == other.sem_pad2 - && sem_pad3 == other_sem_pad3 - } - } - impl Eq for semid_ds {} - impl hash::Hash for semid_ds { - fn hash(&self, state: &mut H) { - let sem_perm = self.sem_perm; - let sem_base = self.sem_base; - let sem_nsems = self.sem_nsems; - let sem_otime = self.sem_otime; - let sem_pad1 = self.sem_pad1; - let sem_ctime = self.sem_ctime; - let sem_pad2 = self.sem_pad2; - let sem_pad3 = self.sem_pad3; - sem_perm.hash(state); - sem_base.hash(state); - sem_nsems.hash(state); - sem_otime.hash(state); - sem_pad1.hash(state); - sem_ctime.hash(state); - sem_pad2.hash(state); - sem_pad3.hash(state); - } - } - - impl PartialEq for shmid_ds { - fn eq(&self, other: &shmid_ds) -> bool { - let shm_perm = self.shm_perm; - let other_shm_perm = other.shm_perm; - shm_perm == other_shm_perm - && self.shm_segsz == other.shm_segsz - && self.shm_lpid == other.shm_lpid - && self.shm_cpid == other.shm_cpid - && self.shm_nattch == other.shm_nattch - && self.shm_atime == other.shm_atime - && self.shm_dtime == other.shm_dtime - && self.shm_ctime == other.shm_ctime - && self.shm_internal == other.shm_internal - } - } - impl Eq for shmid_ds {} - impl hash::Hash for shmid_ds { - fn hash(&self, state: &mut H) { - let shm_perm = self.shm_perm; - let shm_segsz = self.shm_segsz; - let shm_lpid = self.shm_lpid; - let shm_cpid = self.shm_cpid; - let shm_nattch = self.shm_nattch; - let shm_atime = self.shm_atime; - let shm_dtime = self.shm_dtime; - let shm_ctime = self.shm_ctime; - let shm_internal = self.shm_internal; - shm_perm.hash(state); - shm_segsz.hash(state); - shm_lpid.hash(state); - shm_cpid.hash(state); - shm_nattch.hash(state); - shm_atime.hash(state); - shm_dtime.hash(state); - shm_ctime.hash(state); - shm_internal.hash(state); - } - } - - impl PartialEq for proc_threadinfo { - fn eq(&self, other: &proc_threadinfo) -> bool { - self.pth_user_time == other.pth_user_time - && self.pth_system_time == other.pth_system_time - && self.pth_cpu_usage == other.pth_cpu_usage - && self.pth_policy == other.pth_policy - && self.pth_run_state == other.pth_run_state - && self.pth_flags == other.pth_flags - && self.pth_sleep_time == other.pth_sleep_time - && self.pth_curpri == other.pth_curpri - && self.pth_priority == other.pth_priority - && self.pth_maxpriority == other.pth_maxpriority - && self - .pth_name - .iter() - .zip(other.pth_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for proc_threadinfo {} - impl hash::Hash for proc_threadinfo { - fn hash(&self, state: &mut H) { - self.pth_user_time.hash(state); - self.pth_system_time.hash(state); - self.pth_cpu_usage.hash(state); - self.pth_policy.hash(state); - self.pth_run_state.hash(state); - self.pth_flags.hash(state); - self.pth_sleep_time.hash(state); - self.pth_curpri.hash(state); - self.pth_priority.hash(state); - self.pth_maxpriority.hash(state); - self.pth_name.hash(state); - } - } - - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_fsid == other.f_fsid - && self.f_owner == other.f_owner - && self.f_flags == other.f_flags - && self.f_fssubtype == other.f_fssubtype - && self.f_fstypename == other.f_fstypename - && self.f_type == other.f_type - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self.f_reserved == other.f_reserved - } - } - - impl Eq for statfs {} - - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_fsid.hash(state); - self.f_owner.hash(state); - self.f_flags.hash(state); - self.f_fssubtype.hash(state); - self.f_fstypename.hash(state); - self.f_type.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - self.f_reserved.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_seekoff == other.d_seekoff - && self.d_reclen == other.d_reclen - && self.d_namlen == other.d_namlen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_seekoff.hash(state); - self.d_reclen.hash(state); - self.d_namlen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for pthread_rwlock_t {} - impl hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_mutex_t {} - - impl hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_cond_t {} - - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self - .__ss_pad1 - .iter() - .zip(other.__ss_pad1.iter()) - .all(|(a, b)| a == b) - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_user - .iter() - .zip(other.ut_user.iter()) - .all(|(a, b)| a == b) - && self.ut_id == other.ut_id - && self.ut_line == other.ut_line - && self.ut_pid == other.ut_pid - && self.ut_type == other.ut_type - && self.ut_tv == other.ut_tv - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_pad == other.ut_pad - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_user.hash(state); - self.ut_id.hash(state); - self.ut_line.hash(state); - self.ut_pid.hash(state); - self.ut_type.hash(state); - self.ut_tv.hash(state); - self.ut_host.hash(state); - self.ut_pad.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - - impl Eq for sigevent {} - - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - - impl PartialEq for processor_cpu_load_info { - fn eq(&self, other: &processor_cpu_load_info) -> bool { - self.cpu_ticks == other.cpu_ticks - } - } - impl Eq for processor_cpu_load_info {} - impl hash::Hash for processor_cpu_load_info { - fn hash(&self, state: &mut H) { - self.cpu_ticks.hash(state); - } - } - - impl PartialEq for processor_basic_info { - fn eq(&self, other: &processor_basic_info) -> bool { - self.cpu_type == other.cpu_type - && self.cpu_subtype == other.cpu_subtype - && self.running == other.running - && self.slot_num == other.slot_num - && self.is_master == other.is_master - } - } - impl Eq for processor_basic_info {} - impl hash::Hash for processor_basic_info { - fn hash(&self, state: &mut H) { - self.cpu_type.hash(state); - self.cpu_subtype.hash(state); - self.running.hash(state); - self.slot_num.hash(state); - self.is_master.hash(state); - } - } - - impl PartialEq for processor_set_basic_info { - fn eq(&self, other: &processor_set_basic_info) -> bool { - self.processor_count == other.processor_count - && self.default_policy == other.default_policy - } - } - impl Eq for processor_set_basic_info {} - impl hash::Hash for processor_set_basic_info { - fn hash(&self, state: &mut H) { - self.processor_count.hash(state); - self.default_policy.hash(state); - } - } - - impl PartialEq for processor_set_load_info { - fn eq(&self, other: &processor_set_load_info) -> bool { - self.task_count == other.task_count - && self.thread_count == other.thread_count - && self.load_average == other.load_average - && self.mach_factor == other.mach_factor - } - } - impl Eq for processor_set_load_info {} - impl hash::Hash for processor_set_load_info { - fn hash(&self, state: &mut H) { - self.task_count.hash(state); - self.thread_count.hash(state); - self.load_average.hash(state); - self.mach_factor.hash(state); - } - } - - impl PartialEq for time_value_t { - fn eq(&self, other: &time_value_t) -> bool { - self.seconds == other.seconds && self.microseconds == other.microseconds - } - } - impl Eq for time_value_t {} - impl hash::Hash for time_value_t { - fn hash(&self, state: &mut H) { - self.seconds.hash(state); - self.microseconds.hash(state); - } - } - impl PartialEq for thread_basic_info { - fn eq(&self, other: &thread_basic_info) -> bool { - self.user_time == other.user_time - && self.system_time == other.system_time - && self.cpu_usage == other.cpu_usage - && self.policy == other.policy - && self.run_state == other.run_state - && self.flags == other.flags - && self.suspend_count == other.suspend_count - && self.sleep_time == other.sleep_time - } - } - impl Eq for thread_basic_info {} - impl hash::Hash for thread_basic_info { - fn hash(&self, state: &mut H) { - self.user_time.hash(state); - self.system_time.hash(state); - self.cpu_usage.hash(state); - self.policy.hash(state); - self.run_state.hash(state); - self.flags.hash(state); - self.suspend_count.hash(state); - self.sleep_time.hash(state); - } - } - impl PartialEq for thread_extended_info { - fn eq(&self, other: &thread_extended_info) -> bool { - self.pth_user_time == other.pth_user_time - && self.pth_system_time == other.pth_system_time - && self.pth_cpu_usage == other.pth_cpu_usage - && self.pth_policy == other.pth_policy - && self.pth_run_state == other.pth_run_state - && self.pth_flags == other.pth_flags - && self.pth_sleep_time == other.pth_sleep_time - && self.pth_curpri == other.pth_curpri - && self.pth_priority == other.pth_priority - && self.pth_maxpriority == other.pth_maxpriority - && self - .pth_name - .iter() - .zip(other.pth_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for thread_extended_info {} - impl hash::Hash for thread_extended_info { - fn hash(&self, state: &mut H) { - self.pth_user_time.hash(state); - self.pth_system_time.hash(state); - self.pth_cpu_usage.hash(state); - self.pth_policy.hash(state); - self.pth_run_state.hash(state); - self.pth_flags.hash(state); - self.pth_sleep_time.hash(state); - self.pth_curpri.hash(state); - self.pth_priority.hash(state); - self.pth_maxpriority.hash(state); - self.pth_name.hash(state); - } - } - impl PartialEq for thread_identifier_info { - fn eq(&self, other: &thread_identifier_info) -> bool { - self.thread_id == other.thread_id - && self.thread_handle == other.thread_handle - && self.dispatch_qaddr == other.dispatch_qaddr - } - } - impl Eq for thread_identifier_info {} - impl hash::Hash for thread_identifier_info { - fn hash(&self, state: &mut H) { - self.thread_id.hash(state); - self.thread_handle.hash(state); - self.dispatch_qaddr.hash(state); - } - } - impl PartialEq for if_data64 { - fn eq(&self, other: &if_data64) -> bool { - self.ifi_type == other.ifi_type - && self.ifi_typelen == other.ifi_typelen - && self.ifi_physical == other.ifi_physical - && self.ifi_addrlen == other.ifi_addrlen - && self.ifi_hdrlen == other.ifi_hdrlen - && self.ifi_recvquota == other.ifi_recvquota - && self.ifi_xmitquota == other.ifi_xmitquota - && self.ifi_unused1 == other.ifi_unused1 - && self.ifi_mtu == other.ifi_mtu - && self.ifi_metric == other.ifi_metric - && self.ifi_baudrate == other.ifi_baudrate - && self.ifi_ipackets == other.ifi_ipackets - && self.ifi_ierrors == other.ifi_ierrors - && self.ifi_opackets == other.ifi_opackets - && self.ifi_oerrors == other.ifi_oerrors - && self.ifi_collisions == other.ifi_collisions - && self.ifi_ibytes == other.ifi_ibytes - && self.ifi_obytes == other.ifi_obytes - && self.ifi_imcasts == other.ifi_imcasts - && self.ifi_omcasts == other.ifi_omcasts - && self.ifi_iqdrops == other.ifi_iqdrops - && self.ifi_noproto == other.ifi_noproto - && self.ifi_recvtiming == other.ifi_recvtiming - && self.ifi_xmittiming == other.ifi_xmittiming - && self.ifi_lastchange == other.ifi_lastchange - } - } - impl Eq for if_data64 {} - impl hash::Hash for if_data64 { - fn hash(&self, state: &mut H) { - let ifi_type = self.ifi_type; - let ifi_typelen = self.ifi_typelen; - let ifi_physical = self.ifi_physical; - let ifi_addrlen = self.ifi_addrlen; - let ifi_hdrlen = self.ifi_hdrlen; - let ifi_recvquota = self.ifi_recvquota; - let ifi_xmitquota = self.ifi_xmitquota; - let ifi_unused1 = self.ifi_unused1; - let ifi_mtu = self.ifi_mtu; - let ifi_metric = self.ifi_metric; - let ifi_baudrate = self.ifi_baudrate; - let ifi_ipackets = self.ifi_ipackets; - let ifi_ierrors = self.ifi_ierrors; - let ifi_opackets = self.ifi_opackets; - let ifi_oerrors = self.ifi_oerrors; - let ifi_collisions = self.ifi_collisions; - let ifi_ibytes = self.ifi_ibytes; - let ifi_obytes = self.ifi_obytes; - let ifi_imcasts = self.ifi_imcasts; - let ifi_omcasts = self.ifi_omcasts; - let ifi_iqdrops = self.ifi_iqdrops; - let ifi_noproto = self.ifi_noproto; - let ifi_recvtiming = self.ifi_recvtiming; - let ifi_xmittiming = self.ifi_xmittiming; - let ifi_lastchange = self.ifi_lastchange; - ifi_type.hash(state); - ifi_typelen.hash(state); - ifi_physical.hash(state); - ifi_addrlen.hash(state); - ifi_hdrlen.hash(state); - ifi_recvquota.hash(state); - ifi_xmitquota.hash(state); - ifi_unused1.hash(state); - ifi_mtu.hash(state); - ifi_metric.hash(state); - ifi_baudrate.hash(state); - ifi_ipackets.hash(state); - ifi_ierrors.hash(state); - ifi_opackets.hash(state); - ifi_oerrors.hash(state); - ifi_collisions.hash(state); - ifi_ibytes.hash(state); - ifi_obytes.hash(state); - ifi_imcasts.hash(state); - ifi_omcasts.hash(state); - ifi_iqdrops.hash(state); - ifi_noproto.hash(state); - ifi_recvtiming.hash(state); - ifi_xmittiming.hash(state); - ifi_lastchange.hash(state); - } - } - impl PartialEq for if_msghdr2 { - fn eq(&self, other: &if_msghdr2) -> bool { - self.ifm_msglen == other.ifm_msglen - && self.ifm_version == other.ifm_version - && self.ifm_type == other.ifm_type - && self.ifm_addrs == other.ifm_addrs - && self.ifm_flags == other.ifm_flags - && self.ifm_index == other.ifm_index - && self.ifm_snd_len == other.ifm_snd_len - && self.ifm_snd_maxlen == other.ifm_snd_maxlen - && self.ifm_snd_drops == other.ifm_snd_drops - && self.ifm_timer == other.ifm_timer - && self.ifm_data == other.ifm_data - } - } - impl Eq for if_msghdr2 {} - impl hash::Hash for if_msghdr2 { - fn hash(&self, state: &mut H) { - let ifm_msglen = self.ifm_msglen; - let ifm_version = self.ifm_version; - let ifm_type = self.ifm_type; - let ifm_addrs = self.ifm_addrs; - let ifm_flags = self.ifm_flags; - let ifm_index = self.ifm_index; - let ifm_snd_len = self.ifm_snd_len; - let ifm_snd_maxlen = self.ifm_snd_maxlen; - let ifm_snd_drops = self.ifm_snd_drops; - let ifm_timer = self.ifm_timer; - let ifm_data = self.ifm_data; - ifm_msglen.hash(state); - ifm_version.hash(state); - ifm_type.hash(state); - ifm_addrs.hash(state); - ifm_flags.hash(state); - ifm_index.hash(state); - ifm_snd_len.hash(state); - ifm_snd_maxlen.hash(state); - ifm_snd_drops.hash(state); - ifm_timer.hash(state); - ifm_data.hash(state); - } - } - impl PartialEq for vm_statistics64 { - fn eq(&self, other: &vm_statistics64) -> bool { - // Otherwise rustfmt crashes... - let total_uncompressed = self.total_uncompressed_pages_in_compressor; - self.free_count == other.free_count - && self.active_count == other.active_count - && self.inactive_count == other.inactive_count - && self.wire_count == other.wire_count - && self.zero_fill_count == other.zero_fill_count - && self.reactivations == other.reactivations - && self.pageins == other.pageins - && self.pageouts == other.pageouts - && self.faults == other.faults - && self.cow_faults == other.cow_faults - && self.lookups == other.lookups - && self.hits == other.hits - && self.purges == other.purges - && self.purgeable_count == other.purgeable_count - && self.speculative_count == other.speculative_count - && self.decompressions == other.decompressions - && self.compressions == other.compressions - && self.swapins == other.swapins - && self.swapouts == other.swapouts - && self.compressor_page_count == other.compressor_page_count - && self.throttled_count == other.throttled_count - && self.external_page_count == other.external_page_count - && self.internal_page_count == other.internal_page_count - && total_uncompressed == other.total_uncompressed_pages_in_compressor - } - } - impl Eq for vm_statistics64 {} - impl hash::Hash for vm_statistics64 { - fn hash(&self, state: &mut H) { - let free_count = self.free_count; - let active_count = self.active_count; - let inactive_count = self.inactive_count; - let wire_count = self.wire_count; - let zero_fill_count = self.zero_fill_count; - let reactivations = self.reactivations; - let pageins = self.pageins; - let pageouts = self.pageouts; - let faults = self.faults; - let cow_faults = self.cow_faults; - let lookups = self.lookups; - let hits = self.hits; - let purges = self.purges; - let purgeable_count = self.purgeable_count; - let speculative_count = self.speculative_count; - let decompressions = self.decompressions; - let compressions = self.compressions; - let swapins = self.swapins; - let swapouts = self.swapouts; - let compressor_page_count = self.compressor_page_count; - let throttled_count = self.throttled_count; - let external_page_count = self.external_page_count; - let internal_page_count = self.internal_page_count; - // Otherwise rustfmt crashes... - let total_uncompressed = self.total_uncompressed_pages_in_compressor; - free_count.hash(state); - active_count.hash(state); - inactive_count.hash(state); - wire_count.hash(state); - zero_fill_count.hash(state); - reactivations.hash(state); - pageins.hash(state); - pageouts.hash(state); - faults.hash(state); - cow_faults.hash(state); - lookups.hash(state); - hits.hash(state); - purges.hash(state); - purgeable_count.hash(state); - speculative_count.hash(state); - decompressions.hash(state); - compressions.hash(state); - swapins.hash(state); - swapouts.hash(state); - compressor_page_count.hash(state); - throttled_count.hash(state); - external_page_count.hash(state); - internal_page_count.hash(state); - total_uncompressed.hash(state); - } - } - - impl PartialEq for mach_task_basic_info { - fn eq(&self, other: &mach_task_basic_info) -> bool { - self.virtual_size == other.virtual_size - && self.resident_size == other.resident_size - && self.resident_size_max == other.resident_size_max - && self.user_time == other.user_time - && self.system_time == other.system_time - && self.policy == other.policy - && self.suspend_count == other.suspend_count - } - } - impl Eq for mach_task_basic_info {} - impl hash::Hash for mach_task_basic_info { - fn hash(&self, state: &mut H) { - let virtual_size = self.virtual_size; - let resident_size = self.resident_size; - let resident_size_max = self.resident_size_max; - let user_time = self.user_time; - let system_time = self.system_time; - let policy = self.policy; - let suspend_count = self.suspend_count; - virtual_size.hash(state); - resident_size.hash(state); - resident_size_max.hash(state); - user_time.hash(state); - system_time.hash(state); - policy.hash(state); - suspend_count.hash(state); - } - } - - impl PartialEq for log2phys { - fn eq(&self, other: &log2phys) -> bool { - self.l2p_flags == other.l2p_flags - && self.l2p_contigbytes == other.l2p_contigbytes - && self.l2p_devoffset == other.l2p_devoffset - } - } - impl Eq for log2phys {} - impl hash::Hash for log2phys { - fn hash(&self, state: &mut H) { - let l2p_flags = self.l2p_flags; - let l2p_contigbytes = self.l2p_contigbytes; - let l2p_devoffset = self.l2p_devoffset; - l2p_flags.hash(state); - l2p_contigbytes.hash(state); - l2p_devoffset.hash(state); - } - } - impl PartialEq for os_unfair_lock { - fn eq(&self, other: &os_unfair_lock) -> bool { - self._os_unfair_lock_opaque == other._os_unfair_lock_opaque - } - } - - impl Eq for os_unfair_lock {} - - impl hash::Hash for os_unfair_lock { - fn hash(&self, state: &mut H) { - self._os_unfair_lock_opaque.hash(state); - } - } - - impl PartialEq for sockaddr_vm { - fn eq(&self, other: &sockaddr_vm) -> bool { - self.svm_len == other.svm_len - && self.svm_family == other.svm_family - && self.svm_reserved1 == other.svm_reserved1 - && self.svm_port == other.svm_port - && self.svm_cid == other.svm_cid - } - } - - impl Eq for sockaddr_vm {} - - impl hash::Hash for sockaddr_vm { - fn hash(&self, state: &mut H) { - let svm_len = self.svm_len; - let svm_family = self.svm_family; - let svm_reserved1 = self.svm_reserved1; - let svm_port = self.svm_port; - let svm_cid = self.svm_cid; - - svm_len.hash(state); - svm_family.hash(state); - svm_reserved1.hash(state); - svm_port.hash(state); - svm_cid.hash(state); - } - } - - impl PartialEq for ifdevmtu { - fn eq(&self, other: &ifdevmtu) -> bool { - self.ifdm_current == other.ifdm_current - && self.ifdm_min == other.ifdm_min - && self.ifdm_max == other.ifdm_max - } - } - - impl Eq for ifdevmtu {} - - impl hash::Hash for ifdevmtu { - fn hash(&self, state: &mut H) { - self.ifdm_current.hash(state); - self.ifdm_min.hash(state); - self.ifdm_max.hash(state); - } - } - impl PartialEq for __c_anonymous_ifk_data { fn eq(&self, other: &__c_anonymous_ifk_data) -> bool { unsafe { self.ifk_ptr == other.ifk_ptr && self.ifk_value == other.ifk_value } @@ -2602,21 +1711,6 @@ cfg_if! { } } - impl PartialEq for ifkpi { - fn eq(&self, other: &ifkpi) -> bool { - self.ifk_module_id == other.ifk_module_id && self.ifk_type == other.ifk_type - } - } - - impl Eq for ifkpi {} - - impl hash::Hash for ifkpi { - fn hash(&self, state: &mut H) { - self.ifk_module_id.hash(state); - self.ifk_type.hash(state); - } - } - impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -2669,21 +1763,6 @@ cfg_if! { } } - impl PartialEq for ifreq { - fn eq(&self, other: &ifreq) -> bool { - self.ifr_name == other.ifr_name && self.ifr_ifru == other.ifr_ifru - } - } - - impl Eq for ifreq {} - - impl hash::Hash for ifreq { - fn hash(&self, state: &mut H) { - self.ifr_name.hash(state); - self.ifr_ifru.hash(state); - } - } - impl Eq for __c_anonymous_ifc_ifcu {} impl PartialEq for __c_anonymous_ifc_ifcu { @@ -2734,14 +1813,6 @@ cfg_if! { } } } - - impl PartialEq for in6_ifreq { - fn eq(&self, other: &in6_ifreq) -> bool { - self.ifr_name == other.ifr_name && self.ifr_ifru == other.ifr_ifru - } - } - - impl Eq for in6_ifreq {} } } @@ -2934,9 +2005,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; pub const F_TLOCK: c_int = 2; @@ -3275,11 +2343,6 @@ pub const AT_SYMLINK_NOFOLLOW: c_int = 0x0020; pub const AT_SYMLINK_FOLLOW: c_int = 0x0040; pub const AT_REMOVEDIR: c_int = 0x0080; -pub const PTHREAD_INTROSPECTION_THREAD_CREATE: c_uint = 1; -pub const PTHREAD_INTROSPECTION_THREAD_START: c_uint = 2; -pub const PTHREAD_INTROSPECTION_THREAD_TERMINATE: c_uint = 3; -pub const PTHREAD_INTROSPECTION_THREAD_DESTROY: c_uint = 4; - pub const TIOCMODG: c_ulong = 0x40047403; pub const TIOCMODS: c_ulong = 0x80047404; pub const TIOCM_LE: c_int = 0x1; @@ -3322,6 +2385,7 @@ pub const TIOCMSET: c_ulong = 0x8004746d; pub const TIOCMBIS: c_ulong = 0x8004746c; pub const TIOCMBIC: c_ulong = 0x8004746b; pub const TIOCMGET: c_ulong = 0x4004746a; +#[deprecated(since = "0.2.178", note = "Removed in MacOSX 12.0.1")] pub const TIOCREMOTE: c_ulong = 0x80047469; pub const TIOCGWINSZ: c_ulong = 0x40087468; pub const TIOCSWINSZ: c_ulong = 0x80087467; @@ -3431,23 +2495,6 @@ pub const _SC_XOPEN_VERSION: c_int = 116; pub const _SC_XOPEN_XCU_VERSION: c_int = 121; pub const _SC_PHYS_PAGES: c_int = 200; -pub const PTHREAD_PROCESS_PRIVATE: c_int = 2; -pub const PTHREAD_PROCESS_SHARED: c_int = 1; -pub const PTHREAD_CREATE_JOINABLE: c_int = 1; -pub const PTHREAD_CREATE_DETACHED: c_int = 2; -pub const PTHREAD_INHERIT_SCHED: c_int = 1; -pub const PTHREAD_EXPLICIT_SCHED: c_int = 2; -pub const PTHREAD_CANCEL_ENABLE: c_int = 0x01; -pub const PTHREAD_CANCEL_DISABLE: c_int = 0x00; -pub const PTHREAD_CANCEL_DEFERRED: c_int = 0x02; -pub const PTHREAD_CANCEL_ASYNCHRONOUS: c_int = 0x00; -pub const PTHREAD_CANCELED: *mut c_void = 1 as *mut c_void; -pub const PTHREAD_SCOPE_SYSTEM: c_int = 1; -pub const PTHREAD_SCOPE_PROCESS: c_int = 2; -pub const PTHREAD_PRIO_NONE: c_int = 0; -pub const PTHREAD_PRIO_INHERIT: c_int = 1; -pub const PTHREAD_PRIO_PROTECT: c_int = 2; - #[cfg(target_arch = "aarch64")] pub const PTHREAD_STACK_MIN: size_t = 16384; #[cfg(not(target_arch = "aarch64"))] @@ -4074,26 +3121,6 @@ pub const _CS_DARWIN_USER_DIR: c_int = 65536; pub const _CS_DARWIN_USER_TEMP_DIR: c_int = 65537; pub const _CS_DARWIN_USER_CACHE_DIR: c_int = 65538; -pub const PTHREAD_MUTEX_NORMAL: c_int = 0; -pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; -pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; -pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; -pub const _PTHREAD_MUTEX_SIG_init: c_long = 0x32AAABA7; -pub const _PTHREAD_COND_SIG_init: c_long = 0x3CB0B1BB; -pub const _PTHREAD_RWLOCK_SIG_init: c_long = 0x2DA8B3B4; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __sig: _PTHREAD_MUTEX_SIG_init, - __opaque: [0; __PTHREAD_MUTEX_SIZE__], -}; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __sig: _PTHREAD_COND_SIG_init, - __opaque: [0; __PTHREAD_COND_SIZE__], -}; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __sig: _PTHREAD_RWLOCK_SIG_init, - __opaque: [0; __PTHREAD_RWLOCK_SIZE__], -}; - pub const OS_UNFAIR_LOCK_INIT: os_unfair_lock = os_unfair_lock { _os_unfair_lock_opaque: 0, }; @@ -4115,10 +3142,6 @@ pub const FD_SETSIZE: usize = 1024; pub const ST_NOSUID: c_ulong = 2; -pub const SCHED_OTHER: c_int = 1; -pub const SCHED_FIFO: c_int = 4; -pub const SCHED_RR: c_int = 2; - pub const EVFILT_READ: i16 = -1; pub const EVFILT_WRITE: i16 = -2; pub const EVFILT_AIO: i16 = -3; @@ -4777,7 +3800,7 @@ pub const UF_APPEND: c_uint = 0x00000004; pub const UF_OPAQUE: c_uint = 0x00000008; pub const UF_COMPRESSED: c_uint = 0x00000020; pub const UF_TRACKED: c_uint = 0x00000040; -pub const SF_SETTABLE: c_uint = 0xffff0000; +pub const SF_SETTABLE: c_uint = 0x3fff0000; pub const SF_ARCHIVED: c_uint = 0x00010000; pub const SF_IMMUTABLE: c_uint = 0x00020000; pub const SF_APPEND: c_uint = 0x00040000; @@ -5385,22 +4408,10 @@ extern "C" { #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_thread_self() -> mach_port_t; pub fn pthread_cond_timedwait_relative_np( - cond: *mut pthread_cond_t, - lock: *mut pthread_mutex_t, + cond: *mut crate::pthread_cond_t, + lock: *mut crate::pthread_mutex_t, timeout: *const crate::timespec, ) -> c_int; - pub fn pthread_once( - once_control: *mut crate::pthread_once_t, - init_routine: Option, - ) -> c_int; - pub fn pthread_attr_getinheritsched( - attr: *const crate::pthread_attr_t, - inheritsched: *mut c_int, - ) -> c_int; - pub fn pthread_attr_getschedpolicy( - attr: *const crate::pthread_attr_t, - policy: *mut c_int, - ) -> c_int; pub fn pthread_attr_getscope( attr: *const crate::pthread_attr_t, contentionscope: *mut c_int, @@ -5413,11 +4424,6 @@ extern "C" { attr: *const crate::pthread_attr_t, detachstate: *mut c_int, ) -> c_int; - pub fn pthread_attr_setinheritsched( - attr: *mut crate::pthread_attr_t, - inheritsched: c_int, - ) -> c_int; - pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; pub fn pthread_attr_setscope(attr: *mut crate::pthread_attr_t, contentionscope: c_int) -> c_int; pub fn pthread_attr_setstackaddr( @@ -5428,83 +4434,11 @@ extern "C" { pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; pub fn pthread_mach_thread_np(thread: crate::pthread_t) -> crate::mach_port_t; pub fn pthread_from_mach_thread_np(port: crate::mach_port_t) -> crate::pthread_t; - pub fn pthread_create_from_mach_thread( - thread: *mut crate::pthread_t, - attr: *const crate::pthread_attr_t, - f: extern "C" fn(*mut c_void) -> *mut c_void, - value: *mut c_void, - ) -> c_int; - pub fn pthread_stack_frame_decode_np( - frame_addr: crate::uintptr_t, - return_addr: *mut crate::uintptr_t, - ) -> crate::uintptr_t; pub fn pthread_get_stackaddr_np(thread: crate::pthread_t) -> *mut c_void; pub fn pthread_get_stacksize_np(thread: crate::pthread_t) -> size_t; - 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; pub fn pthread_main_np() -> 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_rwlockattr_getpshared( - attr: *const pthread_rwlockattr_t, - val: *mut c_int, - ) -> c_int; - pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int; pub fn pthread_threadid_np(thread: crate::pthread_t, thread_id: *mut u64) -> c_int; - pub fn pthread_attr_set_qos_class_np( - attr: *mut pthread_attr_t, - class: qos_class_t, - priority: c_int, - ) -> c_int; - pub fn pthread_attr_get_qos_class_np( - attr: *mut pthread_attr_t, - class: *mut qos_class_t, - priority: *mut c_int, - ) -> c_int; - pub fn pthread_set_qos_class_self_np(class: qos_class_t, priority: c_int) -> c_int; - pub fn pthread_get_qos_class_np( - thread: crate::pthread_t, - class: *mut qos_class_t, - priority: *mut c_int, - ) -> c_int; - pub fn pthread_attr_getschedparam( - attr: *const crate::pthread_attr_t, - param: *mut sched_param, - ) -> c_int; - pub fn pthread_attr_setschedparam( - attr: *mut crate::pthread_attr_t, - param: *const sched_param, - ) -> c_int; - pub fn pthread_getschedparam( - thread: crate::pthread_t, - policy: *mut c_int, - param: *mut sched_param, - ) -> c_int; - pub fn pthread_setschedparam( - thread: crate::pthread_t, - policy: c_int, - param: *const sched_param, - ) -> c_int; - // Available from Big Sur - pub fn pthread_introspection_hook_install( - hook: crate::pthread_introspection_hook_t, - ) -> crate::pthread_introspection_hook_t; - pub fn pthread_introspection_setspecific_np( - thread: crate::pthread_t, - key: crate::pthread_key_t, - value: *const c_void, - ) -> c_int; - pub fn pthread_introspection_getspecific_np( - thread: crate::pthread_t, - key: crate::pthread_key_t, - ) -> *mut c_void; pub fn pthread_jit_write_protect_np(enabled: c_int); pub fn pthread_jit_write_protect_supported_np() -> c_int; // An array of pthread_jit_write_with_callback_np must declare @@ -5823,14 +4757,6 @@ extern "C" { pref: *mut crate::cpu_type_t, ocount: *mut size_t, ) -> c_int; - pub fn posix_spawnattr_set_qos_class_np( - attr: *mut posix_spawnattr_t, - qos_class: crate::qos_class_t, - ) -> c_int; - pub fn posix_spawnattr_get_qos_class_np( - attr: *const posix_spawnattr_t, - qos_class: *mut crate::qos_class_t, - ) -> c_int; pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; diff --git a/src/unix/bsd/freebsdlike/dragonfly/errno.rs b/src/unix/bsd/freebsdlike/dragonfly/errno.rs deleted file mode 100644 index 874c1da84d3a5..0000000000000 --- a/src/unix/bsd/freebsdlike/dragonfly/errno.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::prelude::*; - -/* DIFF(main): module removed in de76fee6 */ - -// DragonFlyBSD's __error function is declared with "static inline", so it must -// be implemented in the libc crate, as a pointer to a static thread_local. -f! { - #[deprecated(since = "0.2.77", note = "Use `__errno_location()` instead")] - pub fn __error() -> *mut c_int { - &mut errno - } -} - -extern "C" { - #[thread_local] - pub static mut errno: c_int; -} diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 8720bf7fb3649..5c1aa9d1774be 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type dev_t = u32; pub type wchar_t = i32; @@ -45,13 +48,8 @@ pub type vm_map_entry_t = *mut vm_map_entry; pub type pmap = __c_anonymous_pmap; -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum sem {} } e! { @@ -411,9 +409,7 @@ s! { pub data: *mut c_void, pub size: size_t, } -} -s_no_extra_traits! { pub struct utmpx { pub ut_name: [c_char; 32], pub ut_id: [c_char; 4], @@ -442,8 +438,8 @@ s_no_extra_traits! { pub d_fileno: crate::ino_t, pub d_namlen: u16, pub d_type: u8, - __unused1: u8, - __unused2: u32, + __unused1: Padding, + __unused2: Padding, pub d_name: [c_char; 256], } @@ -476,13 +472,13 @@ s_no_extra_traits! { pub sigev_notify: c_int, // The union is 8-byte in size, so it is aligned at a 8-byte offset. #[cfg(target_pointer_width = "64")] - __unused1: c_int, + __unused1: Padding, pub sigev_signo: c_int, //actually a union // pad the union #[cfg(target_pointer_width = "64")] - __unused2: c_int, + __unused2: Padding, pub sigev_value: crate::sigval, - __unused3: *mut c_void, //actually a function pointer + __unused3: Padding<*mut c_void>, //actually a function pointer } pub struct mcontext_t { @@ -515,9 +511,9 @@ s_no_extra_traits! { pub mc_len: c_uint, pub mc_fpformat: c_uint, pub mc_ownedfp: c_uint, - __reserved: c_uint, - __unused: [c_uint; 8], - pub mc_fpregs: [[c_uint; 8]; 32], + __reserved: Padding, + __unused: Padding<[c_uint; 8]>, + pub mc_fpregs: [c_uint; 256], } // FIXME(1.0): This should not implement `PartialEq` @@ -529,256 +525,7 @@ s_no_extra_traits! { pub uc_stack: stack_t, pub uc_cofunc: Option, pub uc_arg: *mut c_void, - __pad: [c_int; 4], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_name == other.ut_name - && self.ut_id == other.ut_id - && self.ut_line == other.ut_line - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_unused == other.ut_unused - && self.ut_session == other.ut_session - && self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_exit == other.ut_exit - && self.ut_ss == other.ut_ss - && self.ut_tv == other.ut_tv - && self.ut_unused2 == other.ut_unused2 - } - } - impl Eq for utmpx {} - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_name.hash(state); - self.ut_id.hash(state); - self.ut_line.hash(state); - self.ut_host.hash(state); - self.ut_unused.hash(state); - self.ut_session.hash(state); - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_exit.hash(state); - self.ut_ss.hash(state); - self.ut_tv.hash(state); - self.ut_unused2.hash(state); - } - } - impl PartialEq for lastlogx { - fn eq(&self, other: &lastlogx) -> bool { - self.ll_tv == other.ll_tv - && self.ll_line == other.ll_line - && self.ll_host == other.ll_host - && self.ll_ss == other.ll_ss - } - } - impl Eq for lastlogx {} - impl hash::Hash for lastlogx { - fn hash(&self, state: &mut H) { - self.ll_tv.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - self.ll_ss.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_namlen == other.d_namlen - && self.d_type == other.d_type - // Ignore __unused1 - // Ignore __unused2 - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_namlen.hash(state); - self.d_type.hash(state); - // Ignore __unused1 - // Ignore __unused2 - self.d_name.hash(state); - } - } - - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_fsid == other.f_fsid - && self.f_owner == other.f_owner - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_fstypename == other.f_fstypename - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_fsid.hash(state); - self.f_owner.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_mntfromname.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - } - } - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_onstack == other.mc_onstack - && self.mc_rdi == other.mc_rdi - && self.mc_rsi == other.mc_rsi - && self.mc_rdx == other.mc_rdx - && self.mc_rcx == other.mc_rcx - && self.mc_r8 == other.mc_r8 - && self.mc_r9 == other.mc_r9 - && self.mc_rax == other.mc_rax - && self.mc_rbx == other.mc_rbx - && self.mc_rbp == other.mc_rbp - && self.mc_r10 == other.mc_r10 - && self.mc_r11 == other.mc_r11 - && self.mc_r12 == other.mc_r12 - && self.mc_r13 == other.mc_r13 - && self.mc_r14 == other.mc_r14 - && self.mc_r15 == other.mc_r15 - && self.mc_xflags == other.mc_xflags - && self.mc_trapno == other.mc_trapno - && self.mc_addr == other.mc_addr - && self.mc_flags == other.mc_flags - && self.mc_err == other.mc_err - && self.mc_rip == other.mc_rip - && self.mc_cs == other.mc_cs - && self.mc_rflags == other.mc_rflags - && self.mc_rsp == other.mc_rsp - && self.mc_ss == other.mc_ss - && self.mc_len == other.mc_len - && self.mc_fpformat == other.mc_fpformat - && self.mc_ownedfp == other.mc_ownedfp - && self.mc_fpregs == other.mc_fpregs - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_onstack.hash(state); - self.mc_rdi.hash(state); - self.mc_rsi.hash(state); - self.mc_rdx.hash(state); - self.mc_rcx.hash(state); - self.mc_r8.hash(state); - self.mc_r9.hash(state); - self.mc_rax.hash(state); - self.mc_rbx.hash(state); - self.mc_rbp.hash(state); - self.mc_r10.hash(state); - self.mc_r11.hash(state); - self.mc_r10.hash(state); - self.mc_r11.hash(state); - self.mc_r12.hash(state); - self.mc_r13.hash(state); - self.mc_r14.hash(state); - self.mc_r15.hash(state); - self.mc_xflags.hash(state); - self.mc_trapno.hash(state); - self.mc_addr.hash(state); - self.mc_flags.hash(state); - self.mc_err.hash(state); - self.mc_rip.hash(state); - self.mc_cs.hash(state); - self.mc_rflags.hash(state); - self.mc_rsp.hash(state); - self.mc_ss.hash(state); - self.mc_len.hash(state); - self.mc_fpformat.hash(state); - self.mc_ownedfp.hash(state); - self.mc_fpregs.hash(state); - } - } - // FIXME(msrv): suggested method was added in 1.85 - #[allow(unpredictable_function_pointer_comparisons)] - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_sigmask == other.uc_sigmask - && self.uc_mcontext == other.uc_mcontext - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_cofunc == other.uc_cofunc - && self.uc_arg == other.uc_arg - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state); - self.uc_mcontext.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_cofunc.hash(state); - self.uc_arg.hash(state); - } - } + __pad: Padding<[c_int; 4]>, } } @@ -1625,11 +1372,3 @@ extern "C" { entry: vm_map_entry_t, ) -> vm_map_entry_t; } - -// DIFF(main): module removed in de76fee6 -cfg_if! { - if #[cfg(libc_thread_local)] { - mod errno; - pub use self::errno::*; - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index e74c26bb46e2c..232770f6e00fa 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -6,7 +6,7 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; -s_no_extra_traits! { +s! { pub struct gpregs { pub gp_x: [crate::register_t; 30], pub gp_lr: crate::register_t, @@ -35,74 +35,6 @@ s_no_extra_traits! { pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for gpregs { - fn eq(&self, other: &gpregs) -> bool { - self.gp_x.iter().zip(other.gp_x.iter()).all(|(a, b)| a == b) - && self.gp_lr == other.gp_lr - && self.gp_sp == other.gp_sp - && self.gp_elr == other.gp_elr - && self.gp_spsr == other.gp_spsr - && self.gp_pad == other.gp_pad - } - } - impl Eq for gpregs {} - impl hash::Hash for gpregs { - fn hash(&self, state: &mut H) { - self.gp_x.hash(state); - self.gp_lr.hash(state); - self.gp_sp.hash(state); - self.gp_elr.hash(state); - self.gp_spsr.hash(state); - self.gp_pad.hash(state); - } - } - impl PartialEq for fpregs { - fn eq(&self, other: &fpregs) -> bool { - self.fp_q == other.fp_q - && self.fp_sr == other.fp_sr - && self.fp_cr == other.fp_cr - && self.fp_flags == other.fp_flags - && self.fp_pad == other.fp_pad - } - } - impl Eq for fpregs {} - impl hash::Hash for fpregs { - fn hash(&self, state: &mut H) { - self.fp_q.hash(state); - self.fp_sr.hash(state); - self.fp_cr.hash(state); - self.fp_flags.hash(state); - self.fp_pad.hash(state); - } - } - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_gpregs == other.mc_gpregs - && self.mc_fpregs == other.mc_fpregs - && self.mc_flags == other.mc_flags - && self.mc_pad == other.mc_pad - && self - .mc_spare - .iter() - .zip(other.mc_spare.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_gpregs.hash(state); - self.mc_fpregs.hash(state); - self.mc_flags.hash(state); - self.mc_pad.hash(state); - self.mc_spare.hash(state); - } - } - } -} - pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; pub const MAP_32BIT: c_int = 0x00080000; diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index c17e12913d8f8..a0f51834d45dd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -8,7 +8,7 @@ pub type register_t = i32; pub type __greg_t = c_uint; pub type __gregset_t = [crate::__greg_t; 17]; -s_no_extra_traits! { +s! { pub struct mcontext_t { pub __gregs: crate::__gregset_t, pub mc_vfp_size: usize, @@ -17,32 +17,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.__gregs == other.__gregs - && self.mc_vfp_size == other.mc_vfp_size - && self.mc_vfp_ptr == other.mc_vfp_ptr - && self - .mc_spare - .iter() - .zip(other.mc_spare.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.__gregs.hash(state); - self.mc_vfp_size.hash(state); - self.mc_vfp_ptr.hash(state); - self.mc_spare.hash(state); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs index dca7d6ee79988..cd0c3e071012f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs @@ -1,37 +1,29 @@ use crate::off_t; use crate::prelude::*; -#[repr(C)] -#[derive(Debug)] -#[cfg_attr(feature = "extra_traits", derive(Eq, Hash, PartialEq))] -pub struct stat { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: crate::blkcnt_t, - pub st_blksize: crate::blksize_t, - pub st_flags: crate::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: crate::time_t, - pub st_birthtime_nsec: c_long, - __unused: [u8; 8], -} - -impl Copy for crate::stat {} -impl Clone for crate::stat { - fn clone(&self) -> crate::stat { - *self +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + __unused: Padding<[u8; 8]>, } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs index 1f31aac0e3d3d..9e80a792a8c7b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs @@ -1,36 +1,28 @@ use crate::off_t; use crate::prelude::*; -#[repr(C)] -#[derive(Debug)] -#[cfg_attr(feature = "extra_traits", derive(Eq, Hash, PartialEq))] -pub struct stat { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: crate::blkcnt_t, - pub st_blksize: crate::blksize_t, - pub st_flags: crate::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: crate::time_t, - pub st_birthtime_nsec: c_long, -} - -impl Copy for crate::stat {} -impl Clone for crate::stat { - fn clone(&self) -> crate::stat { - *self +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index b3b032bc66949..e04fcc0cd82d3 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -210,9 +210,6 @@ s! { /// kthread flag. pub ki_tdflags: c_long, } -} - -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_reclen: u16, @@ -261,122 +258,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_mntdir == other.vn_mntdir - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_mntdir.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const ELAST: c_int = 96; pub const RAND_MAX: c_int = 0x7fff_fffd; pub const KI_NSPARE_PTR: usize = 6; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 962d7817a2649..bbce4af5e3eef 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -254,17 +254,15 @@ s! { pub st_gen: u64, pub st_spare: [u64; 10], } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, pub d_reclen: u16, pub d_type: u8, - d_pad0: u8, + d_pad0: Padding, pub d_namlen: u16, - d_pad1: u16, + d_pad1: Padding, pub d_name: [c_char; 256], } @@ -305,125 +303,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_charspare.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_mntdir == other.vn_mntdir - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_mntdir.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_fffd; pub const ELAST: c_int = 97; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 7b0e467ba375e..2f7dc72342898 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -267,17 +267,15 @@ s! { pub st_gen: u64, pub st_spare: [u64; 10], } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, pub d_reclen: u16, pub d_type: u8, - d_pad0: u8, + d_pad0: Padding, pub d_namlen: u16, - d_pad1: u16, + d_pad1: Padding, pub d_name: [c_char; 256], } @@ -318,125 +316,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_charspare.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_mntdir == other.vn_mntdir - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_mntdir.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_ffff; pub const ELAST: c_int = 97; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index f20a46655665d..c5c262ab68d32 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -269,17 +269,15 @@ s! { pub st_filerev: u64, pub st_spare: [u64; 9], } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, pub d_reclen: u16, pub d_type: u8, - d_pad0: u8, + d_pad0: Padding, pub d_namlen: u16, - d_pad1: u16, + d_pad1: Padding, pub d_name: [c_char; 256], } @@ -320,125 +318,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_charspare.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_mntdir == other.vn_mntdir - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_mntdir.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_ffff; pub const ELAST: c_int = 97; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index c0d27ef370e6f..4031a078b995d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -271,17 +271,15 @@ s! { pub st_filerev: u64, pub st_spare: [u64; 9], } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, pub d_reclen: u16, pub d_type: u8, - d_pad0: u8, + d_pad0: Padding, pub d_namlen: u16, - d_pad1: u16, + d_pad1: Padding, pub d_name: [c_char; 256], } @@ -322,125 +320,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_charspare.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_mntdir == other.vn_mntdir - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_mntdir.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_ffff; pub const ELAST: c_int = 97; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index a5166d4e15c75..c75e175b460a8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type fflags_t = u32; @@ -317,8 +320,8 @@ s! { pub struct msqid_ds { pub msg_perm: crate::ipc_perm, - __unused1: *mut c_void, - __unused2: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, pub msg_cbytes: crate::msglen_t, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -1116,7 +1119,7 @@ s! { pub struct shm_largepage_conf { pub psind: c_int, pub alloc_policy: c_int, - __pad: [c_int; 10], + __pad: Padding<[c_int; 10]>, } pub struct memory_type { @@ -1415,9 +1418,7 @@ s! { pub sp_max: off_t, pub sp_idle: crate::timeval, } -} -s_no_extra_traits! { pub struct utmpx { pub ut_type: c_short, pub ut_tv: crate::timeval, @@ -1429,11 +1430,6 @@ s_no_extra_traits! { pub __ut_spare: [c_char; 64], } - pub union __c_anonymous_cr_pid { - __cr_unused: *mut c_void, - pub cr_pid: crate::pid_t, - } - pub struct xucred { pub cr_version: c_uint, pub cr_uid: crate::uid_t, @@ -1458,19 +1454,7 @@ s_no_extra_traits! { pub mq_maxmsg: c_long, pub mq_msgsize: c_long, pub mq_curmsgs: c_long, - __reserved: [c_long; 4], - } - - pub struct sigevent { - pub sigev_notify: c_int, - pub sigev_signo: c_int, - pub sigev_value: crate::sigval, - //The rest of the structure is actually a union. We expose only - //sigev_notify_thread_id because it's the most useful union member. - pub sigev_notify_thread_id: crate::lwpid_t, - #[cfg(target_pointer_width = "64")] - __unused1: c_int, - __unused2: [c_long; 7], + __reserved: Padding<[c_long; 4]>, } pub struct ptsstat { @@ -1481,23 +1465,15 @@ s_no_extra_traits! { pub devname: [c_char; SPECNAMELEN as usize + 1], } - pub union __c_anonymous_elf32_auxv_union { - pub a_val: c_int, - } - pub struct Elf32_Auxinfo { pub a_type: c_int, pub a_un: __c_anonymous_elf32_auxv_union, } - pub union __c_anonymous_ifi_epoch { - pub tt: crate::time_t, - pub ph: u64, - } - - pub union __c_anonymous_ifi_lastchange { - pub tv: crate::timeval, - pub ph: __c_anonymous_ph, + pub struct ifreq { + /// if name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, } pub struct if_data { @@ -1553,35 +1529,6 @@ s_no_extra_traits! { pub __ifi_lastchange: __c_anonymous_ifi_lastchange, } - pub union __c_anonymous_ifr_ifru { - pub ifru_addr: crate::sockaddr, - pub ifru_dstaddr: crate::sockaddr, - pub ifru_broadaddr: crate::sockaddr, - pub ifru_buffer: ifreq_buffer, - pub ifru_flags: [c_short; 2], - pub ifru_index: c_short, - pub ifru_jid: c_int, - pub ifru_metric: c_int, - pub ifru_mtu: c_int, - pub ifru_phys: c_int, - pub ifru_media: c_int, - pub ifru_data: crate::caddr_t, - pub ifru_cap: [c_int; 2], - pub ifru_fib: c_uint, - pub ifru_vlan_pcp: c_uchar, - } - - pub struct ifreq { - /// if name, e.g. "en0" - pub ifr_name: [c_char; crate::IFNAMSIZ], - pub ifr_ifru: __c_anonymous_ifr_ifru, - } - - pub union __c_anonymous_ifc_ifcu { - pub ifcu_buf: crate::caddr_t, - pub ifcu_req: *mut ifreq, - } - pub struct ifstat { /// if name, e.g. "en0" pub ifs_name: [c_char; crate::IFNAMSIZ as usize], @@ -1643,7 +1590,7 @@ s_no_extra_traits! { pub struct sctp_error_invalid_stream { pub cause: sctp_error_cause, pub stream_id: u16, - __reserved: u16, + __reserved: Padding, } #[repr(packed)] @@ -1693,16 +1640,72 @@ s_no_extra_traits! { pub kf_fd: c_int, pub kf_ref_count: c_int, pub kf_flags: c_int, - _kf_pad0: c_int, + _kf_pad0: Padding, pub kf_offset: i64, _priv: [u8; 304], // FIXME(freebsd): this is really a giant union pub kf_status: u16, - _kf_pad1: u16, + _kf_pad1: Padding, _kf_ispare0: c_int, pub kf_cap_rights: crate::cap_rights_t, _kf_cap_spare: u64, pub kf_path: [c_char; crate::PATH_MAX as usize], } +} + +s_no_extra_traits! { + pub union __c_anonymous_cr_pid { + __cr_unused: *mut c_void, + pub cr_pid: crate::pid_t, + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: crate::sigval, + //The rest of the structure is actually a union. We expose only + //sigev_notify_thread_id because it's the most useful union member. + pub sigev_notify_thread_id: crate::lwpid_t, + #[cfg(target_pointer_width = "64")] + __unused1: c_int, + __unused2: [c_long; 7], + } + + pub union __c_anonymous_elf32_auxv_union { + pub a_val: c_int, + } + + pub union __c_anonymous_ifi_epoch { + pub tt: crate::time_t, + pub ph: u64, + } + + pub union __c_anonymous_ifi_lastchange { + pub tv: crate::timeval, + pub ph: __c_anonymous_ph, + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_buffer: ifreq_buffer, + pub ifru_flags: [c_short; 2], + pub ifru_index: c_short, + pub ifru_jid: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_phys: c_int, + pub ifru_media: c_int, + pub ifru_data: crate::caddr_t, + pub ifru_cap: [c_int; 2], + pub ifru_fib: c_uint, + pub ifru_vlan_pcp: c_uchar, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: crate::caddr_t, + pub ifcu_req: *mut ifreq, + } pub struct ucontext_t { pub uc_sigmask: crate::sigset_t, @@ -1785,40 +1788,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_tv == other.ut_tv - && self.ut_id == other.ut_id - && self.ut_pid == other.ut_pid - && self.ut_user == other.ut_user - && self.ut_line == other.ut_line - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self - .__ut_spare - .iter() - .zip(other.__ut_spare.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for utmpx {} - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_tv.hash(state); - self.ut_id.hash(state); - self.ut_pid.hash(state); - self.ut_user.hash(state); - self.ut_line.hash(state); - self.ut_host.hash(state); - self.__ut_spare.hash(state); - } - } - impl PartialEq for __c_anonymous_cr_pid { fn eq(&self, other: &__c_anonymous_cr_pid) -> bool { unsafe { self.cr_pid == other.cr_pid } @@ -1831,74 +1800,6 @@ cfg_if! { } } - impl PartialEq for xucred { - fn eq(&self, other: &xucred) -> bool { - self.cr_version == other.cr_version - && self.cr_uid == other.cr_uid - && self.cr_ngroups == other.cr_ngroups - && self.cr_groups == other.cr_groups - && self.cr_pid__c_anonymous_union == other.cr_pid__c_anonymous_union - } - } - impl Eq for xucred {} - impl hash::Hash for xucred { - fn hash(&self, state: &mut H) { - self.cr_version.hash(state); - self.cr_uid.hash(state); - self.cr_ngroups.hash(state); - self.cr_groups.hash(state); - self.cr_pid__c_anonymous_union.hash(state); - } - } - - impl PartialEq for sockaddr_dl { - fn eq(&self, other: &sockaddr_dl) -> bool { - self.sdl_len == other.sdl_len - && self.sdl_family == other.sdl_family - && self.sdl_index == other.sdl_index - && self.sdl_type == other.sdl_type - && self.sdl_nlen == other.sdl_nlen - && self.sdl_alen == other.sdl_alen - && self.sdl_slen == other.sdl_slen - && self - .sdl_data - .iter() - .zip(other.sdl_data.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_dl {} - impl hash::Hash for sockaddr_dl { - fn hash(&self, state: &mut H) { - self.sdl_len.hash(state); - self.sdl_family.hash(state); - self.sdl_index.hash(state); - self.sdl_type.hash(state); - self.sdl_nlen.hash(state); - self.sdl_alen.hash(state); - self.sdl_slen.hash(state); - self.sdl_data.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_flags == other.mq_flags - && self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_curmsgs == other.mq_curmsgs - } - } - impl Eq for mq_attr {} - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_flags.hash(state); - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_curmsgs.hash(state); - } - } - impl PartialEq for sigevent { fn eq(&self, other: &sigevent) -> bool { self.sigev_notify == other.sigev_notify @@ -1917,36 +1818,17 @@ cfg_if! { } } - impl PartialEq for ptsstat { - fn eq(&self, other: &ptsstat) -> bool { - let self_devname: &[c_char] = &self.devname; - let other_devname: &[c_char] = &other.devname; - - self.dev == other.dev && self_devname == other_devname - } - } - impl Eq for ptsstat {} - impl hash::Hash for ptsstat { - fn hash(&self, state: &mut H) { - let self_devname: &[c_char] = &self.devname; - - self.dev.hash(state); - self_devname.hash(state); - } - } - impl PartialEq for __c_anonymous_elf32_auxv_union { fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool { unsafe { self.a_val == other.a_val } } } impl Eq for __c_anonymous_elf32_auxv_union {} - impl PartialEq for Elf32_Auxinfo { - fn eq(&self, other: &Elf32_Auxinfo) -> bool { - self.a_type == other.a_type && self.a_un == other.a_un + impl hash::Hash for __c_anonymous_elf32_auxv_union { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); } } - impl Eq for Elf32_Auxinfo {} impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { @@ -1990,27 +1872,12 @@ cfg_if! { } } - impl PartialEq for ifreq { - fn eq(&self, other: &ifreq) -> bool { - self.ifr_name == other.ifr_name && self.ifr_ifru == other.ifr_ifru - } - } - impl Eq for ifreq {} - impl hash::Hash for ifreq { - fn hash(&self, state: &mut H) { - self.ifr_name.hash(state); - self.ifr_ifru.hash(state); - } - } - - impl Eq for __c_anonymous_ifc_ifcu {} - impl PartialEq for __c_anonymous_ifc_ifcu { fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { unsafe { self.ifcu_buf == other.ifcu_buf && self.ifcu_req == other.ifcu_req } } } - + impl Eq for __c_anonymous_ifc_ifcu {} impl hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { self.ifcu_buf.hash(state) }; @@ -2018,66 +1885,6 @@ cfg_if! { } } - impl PartialEq for ifstat { - fn eq(&self, other: &ifstat) -> bool { - let self_ascii: &[c_char] = &self.ascii; - let other_ascii: &[c_char] = &other.ascii; - - self.ifs_name == other.ifs_name && self_ascii == other_ascii - } - } - impl Eq for ifstat {} - impl hash::Hash for ifstat { - fn hash(&self, state: &mut H) { - self.ifs_name.hash(state); - self.ascii.hash(state); - } - } - - impl PartialEq for ifrsskey { - fn eq(&self, other: &ifrsskey) -> bool { - let self_ifrk_key: &[u8] = &self.ifrk_key; - let other_ifrk_key: &[u8] = &other.ifrk_key; - - self.ifrk_name == other.ifrk_name - && self.ifrk_func == other.ifrk_func - && self.ifrk_spare0 == other.ifrk_spare0 - && self.ifrk_keylen == other.ifrk_keylen - && self_ifrk_key == other_ifrk_key - } - } - impl Eq for ifrsskey {} - impl hash::Hash for ifrsskey { - fn hash(&self, state: &mut H) { - self.ifrk_name.hash(state); - self.ifrk_func.hash(state); - self.ifrk_spare0.hash(state); - self.ifrk_keylen.hash(state); - self.ifrk_key.hash(state); - } - } - - impl PartialEq for ifdownreason { - fn eq(&self, other: &ifdownreason) -> bool { - let self_ifdr_msg: &[c_char] = &self.ifdr_msg; - let other_ifdr_msg: &[c_char] = &other.ifdr_msg; - - self.ifdr_name == other.ifdr_name - && self.ifdr_reason == other.ifdr_reason - && self.ifdr_vendor == other.ifdr_vendor - && self_ifdr_msg == other_ifdr_msg - } - } - impl Eq for ifdownreason {} - impl hash::Hash for ifdownreason { - fn hash(&self, state: &mut H) { - self.ifdr_name.hash(state); - self.ifdr_reason.hash(state); - self.ifdr_vendor.hash(state); - self.ifdr_msg.hash(state); - } - } - impl PartialEq for __c_anonymous_ifi_epoch { fn eq(&self, other: &__c_anonymous_ifi_epoch) -> bool { unsafe { self.tt == other.tt && self.ph == other.ph } @@ -2107,291 +1914,6 @@ cfg_if! { } } } - - impl PartialEq for if_data { - fn eq(&self, other: &if_data) -> bool { - self.ifi_type == other.ifi_type - && self.ifi_physical == other.ifi_physical - && self.ifi_addrlen == other.ifi_addrlen - && self.ifi_hdrlen == other.ifi_hdrlen - && self.ifi_link_state == other.ifi_link_state - && self.ifi_vhid == other.ifi_vhid - && self.ifi_datalen == other.ifi_datalen - && self.ifi_mtu == other.ifi_mtu - && self.ifi_metric == other.ifi_metric - && self.ifi_baudrate == other.ifi_baudrate - && self.ifi_ipackets == other.ifi_ipackets - && self.ifi_ierrors == other.ifi_ierrors - && self.ifi_opackets == other.ifi_opackets - && self.ifi_oerrors == other.ifi_oerrors - && self.ifi_collisions == other.ifi_collisions - && self.ifi_ibytes == other.ifi_ibytes - && self.ifi_obytes == other.ifi_obytes - && self.ifi_imcasts == other.ifi_imcasts - && self.ifi_omcasts == other.ifi_omcasts - && self.ifi_iqdrops == other.ifi_iqdrops - && self.ifi_oqdrops == other.ifi_oqdrops - && self.ifi_noproto == other.ifi_noproto - && self.ifi_hwassist == other.ifi_hwassist - && self.__ifi_epoch == other.__ifi_epoch - && self.__ifi_lastchange == other.__ifi_lastchange - } - } - impl Eq for if_data {} - impl hash::Hash for if_data { - fn hash(&self, state: &mut H) { - self.ifi_type.hash(state); - self.ifi_physical.hash(state); - self.ifi_addrlen.hash(state); - self.ifi_hdrlen.hash(state); - self.ifi_link_state.hash(state); - self.ifi_vhid.hash(state); - self.ifi_datalen.hash(state); - self.ifi_mtu.hash(state); - self.ifi_metric.hash(state); - self.ifi_baudrate.hash(state); - self.ifi_ipackets.hash(state); - self.ifi_ierrors.hash(state); - self.ifi_opackets.hash(state); - self.ifi_oerrors.hash(state); - self.ifi_collisions.hash(state); - self.ifi_ibytes.hash(state); - self.ifi_obytes.hash(state); - self.ifi_imcasts.hash(state); - self.ifi_omcasts.hash(state); - self.ifi_iqdrops.hash(state); - self.ifi_oqdrops.hash(state); - self.ifi_noproto.hash(state); - self.ifi_hwassist.hash(state); - self.__ifi_epoch.hash(state); - self.__ifi_lastchange.hash(state); - } - } - - impl PartialEq for sctphdr { - fn eq(&self, other: &sctphdr) -> bool { - return { self.src_port } == { other.src_port } - && { self.dest_port } == { other.dest_port } - && { self.v_tag } == { other.v_tag } - && { self.checksum } == { other.checksum }; - } - } - impl Eq for sctphdr {} - impl hash::Hash for sctphdr { - fn hash(&self, state: &mut H) { - { self.src_port }.hash(state); - { self.dest_port }.hash(state); - { self.v_tag }.hash(state); - { self.checksum }.hash(state); - } - } - - impl PartialEq for sctp_chunkhdr { - fn eq(&self, other: &sctp_chunkhdr) -> bool { - return { self.chunk_type } == { other.chunk_type } - && { self.chunk_flags } == { other.chunk_flags } - && { self.chunk_length } == { other.chunk_length }; - } - } - impl Eq for sctp_chunkhdr {} - impl hash::Hash for sctp_chunkhdr { - fn hash(&self, state: &mut H) { - { self.chunk_type }.hash(state); - { self.chunk_flags }.hash(state); - { self.chunk_length }.hash(state); - } - } - - impl PartialEq for sctp_paramhdr { - fn eq(&self, other: &sctp_paramhdr) -> bool { - return { self.param_type } == { other.param_type } && { self.param_length } == { - other.param_length - }; - } - } - impl Eq for sctp_paramhdr {} - impl hash::Hash for sctp_paramhdr { - fn hash(&self, state: &mut H) { - { self.param_type }.hash(state); - { self.param_length }.hash(state); - } - } - - impl PartialEq for sctp_gen_error_cause { - fn eq(&self, other: &sctp_gen_error_cause) -> bool { - return { self.code } == { other.code } && { self.length } == { other.length } && { - self.info - } - .iter() - .zip({ other.info }.iter()) - .all(|(a, b)| a == b); - } - } - impl Eq for sctp_gen_error_cause {} - impl hash::Hash for sctp_gen_error_cause { - fn hash(&self, state: &mut H) { - { self.code }.hash(state); - { self.length }.hash(state); - { self.info }.hash(state); - } - } - - impl PartialEq for sctp_error_cause { - fn eq(&self, other: &sctp_error_cause) -> bool { - return { self.code } == { other.code } && { self.length } == { other.length }; - } - } - impl Eq for sctp_error_cause {} - impl hash::Hash for sctp_error_cause { - fn hash(&self, state: &mut H) { - { self.code }.hash(state); - { self.length }.hash(state); - } - } - - impl PartialEq for sctp_error_invalid_stream { - fn eq(&self, other: &sctp_error_invalid_stream) -> bool { - return { self.cause } == { other.cause } && { self.stream_id } == { - other.stream_id - }; - } - } - impl Eq for sctp_error_invalid_stream {} - impl hash::Hash for sctp_error_invalid_stream { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.stream_id }.hash(state); - } - } - - impl PartialEq for sctp_error_missing_param { - fn eq(&self, other: &sctp_error_missing_param) -> bool { - return { self.cause } == { other.cause } - && { self.num_missing_params } == { other.num_missing_params } - && { self.tpe } - .iter() - .zip({ other.tpe }.iter()) - .all(|(a, b)| a == b); - } - } - impl Eq for sctp_error_missing_param {} - impl hash::Hash for sctp_error_missing_param { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.num_missing_params }.hash(state); - { self.tpe }.hash(state); - } - } - - impl PartialEq for sctp_error_stale_cookie { - fn eq(&self, other: &sctp_error_stale_cookie) -> bool { - return { self.cause } == { other.cause } && { self.stale_time } == { - other.stale_time - }; - } - } - impl Eq for sctp_error_stale_cookie {} - impl hash::Hash for sctp_error_stale_cookie { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.stale_time }.hash(state); - } - } - - impl PartialEq for sctp_error_out_of_resource { - fn eq(&self, other: &sctp_error_out_of_resource) -> bool { - return { self.cause } == { other.cause }; - } - } - impl Eq for sctp_error_out_of_resource {} - impl hash::Hash for sctp_error_out_of_resource { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - } - } - - impl PartialEq for sctp_error_unresolv_addr { - fn eq(&self, other: &sctp_error_unresolv_addr) -> bool { - return { self.cause } == { other.cause }; - } - } - impl Eq for sctp_error_unresolv_addr {} - impl hash::Hash for sctp_error_unresolv_addr { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - } - } - - impl PartialEq for sctp_error_unrecognized_chunk { - fn eq(&self, other: &sctp_error_unrecognized_chunk) -> bool { - return { self.cause } == { other.cause } && { self.ch } == { other.ch }; - } - } - impl Eq for sctp_error_unrecognized_chunk {} - impl hash::Hash for sctp_error_unrecognized_chunk { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.ch }.hash(state); - } - } - - impl PartialEq for sctp_error_no_user_data { - fn eq(&self, other: &sctp_error_no_user_data) -> bool { - return { self.cause } == { other.cause } && { self.tsn } == { other.tsn }; - } - } - impl Eq for sctp_error_no_user_data {} - impl hash::Hash for sctp_error_no_user_data { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.tsn }.hash(state); - } - } - - impl PartialEq for sctp_error_auth_invalid_hmac { - fn eq(&self, other: &sctp_error_auth_invalid_hmac) -> bool { - return { self.cause } == { other.cause } && { self.hmac_id } == { other.hmac_id }; - } - } - impl Eq for sctp_error_auth_invalid_hmac {} - impl hash::Hash for sctp_error_auth_invalid_hmac { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.hmac_id }.hash(state); - } - } - - impl PartialEq for kinfo_file { - fn eq(&self, other: &kinfo_file) -> bool { - self.kf_structsize == other.kf_structsize - && self.kf_type == other.kf_type - && self.kf_fd == other.kf_fd - && self.kf_ref_count == other.kf_ref_count - && self.kf_flags == other.kf_flags - && self.kf_offset == other.kf_offset - && self.kf_status == other.kf_status - && self.kf_cap_rights == other.kf_cap_rights - && self - .kf_path - .iter() - .zip(other.kf_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for kinfo_file {} - impl hash::Hash for kinfo_file { - fn hash(&self, state: &mut H) { - self.kf_structsize.hash(state); - self.kf_type.hash(state); - self.kf_fd.hash(state); - self.kf_ref_count.hash(state); - self.kf_flags.hash(state); - self.kf_offset.hash(state); - self.kf_status.hash(state); - self.kf_cap_rights.hash(state); - self.kf_path.hash(state); - } - } } } @@ -3807,6 +3329,8 @@ pub const AT_HWCAP: c_int = 25; pub const AT_HWCAP2: c_int = 26; pub const AT_USRSTACKBASE: c_int = 35; pub const AT_USRSTACKLIM: c_int = 36; +pub const AT_HWCAP3: c_int = 38; +pub const AT_HWCAP4: c_int = 39; pub const TABDLY: crate::tcflag_t = 0x00000004; pub const TAB0: crate::tcflag_t = 0x00000000; @@ -5271,7 +4795,7 @@ extern "C" { pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int; pub fn setaudit(auditinfo: *const auditinfo_t) -> c_int; - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index e4275b10ba508..4c0e165af9d24 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -6,7 +6,7 @@ pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; -s_no_extra_traits! { +s! { #[repr(align(16))] pub struct mcontext_t { pub mc_vers: c_int, @@ -21,38 +21,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_vers == other.mc_vers - && self.mc_flags == other.mc_flags - && self.mc_onstack == other.mc_onstack - && self.mc_len == other.mc_len - && self.mc_avec == other.mc_avec - && self.mc_av == other.mc_av - && self.mc_frame == other.mc_frame - && self.mc_fpreg == other.mc_fpreg - && self.mc_vsxfpreg == other.mc_vsxfpreg - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_vers.hash(state); - self.mc_flags.hash(state); - self.mc_onstack.hash(state); - self.mc_len.hash(state); - self.mc_avec.hash(state); - self.mc_av.hash(state); - self.mc_frame.hash(state); - self.mc_fpreg.hash(state); - self.mc_vsxfpreg.hash(state); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index b5a81311ecc60..bfc6d5c2ccc2e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -6,7 +6,7 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; -s_no_extra_traits! { +s! { #[repr(align(16))] pub struct mcontext_t { pub mc_vers: c_int, @@ -21,38 +21,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_vers == other.mc_vers - && self.mc_flags == other.mc_flags - && self.mc_onstack == other.mc_onstack - && self.mc_len == other.mc_len - && self.mc_avec == other.mc_avec - && self.mc_av == other.mc_av - && self.mc_frame == other.mc_frame - && self.mc_fpreg == other.mc_fpreg - && self.mc_vsxfpreg == other.mc_vsxfpreg - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_vers.hash(state); - self.mc_flags.hash(state); - self.mc_onstack.hash(state); - self.mc_len.hash(state); - self.mc_avec.hash(state); - self.mc_av.hash(state); - self.mc_frame.hash(state); - self.mc_fpreg.hash(state); - self.mc_vsxfpreg.hash(state); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index 5ae5d34a74660..e2d7920541d9a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -6,7 +6,7 @@ pub type time_t = i64; pub type suseconds_t = c_long; pub type register_t = i64; -s_no_extra_traits! { +s! { pub struct gpregs { pub gp_ra: crate::register_t, pub gp_sp: crate::register_t, @@ -35,78 +35,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for gpregs { - fn eq(&self, other: &gpregs) -> bool { - self.gp_ra == other.gp_ra - && self.gp_sp == other.gp_sp - && self.gp_gp == other.gp_gp - && self.gp_tp == other.gp_tp - && self.gp_t.iter().zip(other.gp_t.iter()).all(|(a, b)| a == b) - && self.gp_s.iter().zip(other.gp_s.iter()).all(|(a, b)| a == b) - && self.gp_a.iter().zip(other.gp_a.iter()).all(|(a, b)| a == b) - && self.gp_sepc == other.gp_sepc - && self.gp_sstatus == other.gp_sstatus - } - } - impl Eq for gpregs {} - impl hash::Hash for gpregs { - fn hash(&self, state: &mut H) { - self.gp_ra.hash(state); - self.gp_sp.hash(state); - self.gp_gp.hash(state); - self.gp_tp.hash(state); - self.gp_t.hash(state); - self.gp_s.hash(state); - self.gp_a.hash(state); - self.gp_sepc.hash(state); - self.gp_sstatus.hash(state); - } - } - impl PartialEq for fpregs { - fn eq(&self, other: &fpregs) -> bool { - self.fp_x == other.fp_x - && self.fp_fcsr == other.fp_fcsr - && self.fp_flags == other.fp_flags - && self.pad == other.pad - } - } - impl Eq for fpregs {} - impl hash::Hash for fpregs { - fn hash(&self, state: &mut H) { - self.fp_x.hash(state); - self.fp_fcsr.hash(state); - self.fp_flags.hash(state); - self.pad.hash(state); - } - } - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_gpregs == other.mc_gpregs - && self.mc_fpregs == other.mc_fpregs - && self.mc_flags == other.mc_flags - && self.mc_pad == other.mc_pad - && self - .mc_spare - .iter() - .zip(other.mc_spare.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_gpregs.hash(state); - self.mc_fpregs.hash(state); - self.mc_flags.hash(state); - self.mc_pad.hash(state); - self.mc_spare.hash(state); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 5becde55db43e..a95914d8a49a2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -6,7 +6,7 @@ pub type time_t = i32; pub type suseconds_t = i32; pub type register_t = i32; -s_no_extra_traits! { +s! { #[repr(align(16))] pub struct mcontext_t { pub mc_onstack: register_t, @@ -42,88 +42,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_onstack == other.mc_onstack - && self.mc_gs == other.mc_gs - && self.mc_fs == other.mc_fs - && self.mc_es == other.mc_es - && self.mc_ds == other.mc_ds - && self.mc_edi == other.mc_edi - && self.mc_esi == other.mc_esi - && self.mc_ebp == other.mc_ebp - && self.mc_isp == other.mc_isp - && self.mc_ebx == other.mc_ebx - && self.mc_edx == other.mc_edx - && self.mc_ecx == other.mc_ecx - && self.mc_eax == other.mc_eax - && self.mc_trapno == other.mc_trapno - && self.mc_err == other.mc_err - && self.mc_eip == other.mc_eip - && self.mc_cs == other.mc_cs - && self.mc_eflags == other.mc_eflags - && self.mc_esp == other.mc_esp - && self.mc_ss == other.mc_ss - && self.mc_len == other.mc_len - && self.mc_fpformat == other.mc_fpformat - && self.mc_ownedfp == other.mc_ownedfp - && self.mc_flags == other.mc_flags - && self - .mc_fpstate - .iter() - .zip(other.mc_fpstate.iter()) - .all(|(a, b)| a == b) - && self.mc_fsbase == other.mc_fsbase - && self.mc_gsbase == other.mc_gsbase - && self.mc_xfpustate == other.mc_xfpustate - && self.mc_xfpustate_len == other.mc_xfpustate_len - && self - .mc_spare2 - .iter() - .zip(other.mc_spare2.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_onstack.hash(state); - self.mc_gs.hash(state); - self.mc_fs.hash(state); - self.mc_es.hash(state); - self.mc_ds.hash(state); - self.mc_edi.hash(state); - self.mc_esi.hash(state); - self.mc_ebp.hash(state); - self.mc_isp.hash(state); - self.mc_ebx.hash(state); - self.mc_edx.hash(state); - self.mc_ecx.hash(state); - self.mc_eax.hash(state); - self.mc_trapno.hash(state); - self.mc_err.hash(state); - self.mc_eip.hash(state); - self.mc_cs.hash(state); - self.mc_eflags.hash(state); - self.mc_esp.hash(state); - self.mc_ss.hash(state); - self.mc_len.hash(state); - self.mc_fpformat.hash(state); - self.mc_ownedfp.hash(state); - self.mc_flags.hash(state); - self.mc_fpstate.hash(state); - self.mc_fsbase.hash(state); - self.mc_gsbase.hash(state); - self.mc_xfpustate.hash(state); - self.mc_xfpustate_len.hash(state); - self.mc_spare2.hash(state); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index d665e3da01e87..2d7a2b66621cf 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -57,9 +57,7 @@ s! { pub r_rsp: i64, pub r_ss: i64, } -} -s_no_extra_traits! { pub struct fpreg32 { pub fpr_env: [u32; 7], pub fpr_acc: [[u8; 10]; 8], @@ -80,23 +78,6 @@ s_no_extra_traits! { pub xmm_reg: [[u8; 16]; 8], pub xmm_pad: [u8; 224], } - - pub union __c_anonymous_elf64_auxv_union { - pub a_val: c_long, - pub a_ptr: *mut c_void, - pub a_fcn: extern "C" fn(), - } - - pub struct Elf64_Auxinfo { - pub a_type: c_long, - pub a_un: __c_anonymous_elf64_auxv_union, - } - - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4], - } - #[repr(align(16))] #[cfg_attr(not(any(freebsd11, freebsd12, freebsd13, freebsd14)), non_exhaustive)] pub struct mcontext_t { @@ -148,70 +129,26 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for fpreg32 { - fn eq(&self, other: &fpreg32) -> bool { - self.fpr_env == other.fpr_env - && self.fpr_acc == other.fpr_acc - && self.fpr_ex_sw == other.fpr_ex_sw - && self - .fpr_pad - .iter() - .zip(other.fpr_pad.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for fpreg32 {} - impl hash::Hash for fpreg32 { - fn hash(&self, state: &mut H) { - self.fpr_env.hash(state); - self.fpr_acc.hash(state); - self.fpr_ex_sw.hash(state); - self.fpr_pad.hash(state); - } - } +s_no_extra_traits! { + pub union __c_anonymous_elf64_auxv_union { + pub a_val: c_long, + pub a_ptr: *mut c_void, + pub a_fcn: extern "C" fn(), + } - impl PartialEq for fpreg { - fn eq(&self, other: &fpreg) -> bool { - self.fpr_env == other.fpr_env - && self.fpr_acc == other.fpr_acc - && self.fpr_xacc == other.fpr_xacc - && self.fpr_spare == other.fpr_spare - } - } - impl Eq for fpreg {} - impl hash::Hash for fpreg { - fn hash(&self, state: &mut H) { - self.fpr_env.hash(state); - self.fpr_acc.hash(state); - self.fpr_xacc.hash(state); - self.fpr_spare.hash(state); - } - } + pub struct Elf64_Auxinfo { + pub a_type: c_long, + pub a_un: __c_anonymous_elf64_auxv_union, + } - impl PartialEq for xmmreg { - fn eq(&self, other: &xmmreg) -> bool { - self.xmm_env == other.xmm_env - && self.xmm_acc == other.xmm_acc - && self.xmm_reg == other.xmm_reg - && self - .xmm_pad - .iter() - .zip(other.xmm_pad.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for xmmreg {} - impl hash::Hash for xmmreg { - fn hash(&self, state: &mut H) { - self.xmm_env.hash(state); - self.xmm_acc.hash(state); - self.xmm_reg.hash(state); - self.xmm_pad.hash(state); - } - } + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} +cfg_if! { + if #[cfg(feature = "extra_traits")] { // FIXME(msrv): suggested method was added in 1.85 #[allow(unpredictable_function_pointer_comparisons)] impl PartialEq for __c_anonymous_elf64_auxv_union { @@ -224,102 +161,6 @@ cfg_if! { } } impl Eq for __c_anonymous_elf64_auxv_union {} - impl PartialEq for Elf64_Auxinfo { - fn eq(&self, other: &Elf64_Auxinfo) -> bool { - self.a_type == other.a_type && self.a_un == other.a_un - } - } - impl Eq for Elf64_Auxinfo {} - - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_onstack == other.mc_onstack - && self.mc_rdi == other.mc_rdi - && self.mc_rsi == other.mc_rsi - && self.mc_rdx == other.mc_rdx - && self.mc_rcx == other.mc_rcx - && self.mc_r8 == other.mc_r8 - && self.mc_r9 == other.mc_r9 - && self.mc_rax == other.mc_rax - && self.mc_rbx == other.mc_rbx - && self.mc_rbp == other.mc_rbp - && self.mc_r10 == other.mc_r10 - && self.mc_r11 == other.mc_r11 - && self.mc_r12 == other.mc_r12 - && self.mc_r13 == other.mc_r13 - && self.mc_r14 == other.mc_r14 - && self.mc_r15 == other.mc_r15 - && self.mc_trapno == other.mc_trapno - && self.mc_fs == other.mc_fs - && self.mc_gs == other.mc_gs - && self.mc_addr == other.mc_addr - && self.mc_flags == other.mc_flags - && self.mc_es == other.mc_es - && self.mc_ds == other.mc_ds - && self.mc_err == other.mc_err - && self.mc_rip == other.mc_rip - && self.mc_cs == other.mc_cs - && self.mc_rflags == other.mc_rflags - && self.mc_rsp == other.mc_rsp - && self.mc_ss == other.mc_ss - && self.mc_len == other.mc_len - && self.mc_fpformat == other.mc_fpformat - && self.mc_ownedfp == other.mc_ownedfp - && self - .mc_fpstate - .iter() - .zip(other.mc_fpstate.iter()) - .all(|(a, b)| a == b) - && self.mc_fsbase == other.mc_fsbase - && self.mc_gsbase == other.mc_gsbase - && self.mc_xfpustate == other.mc_xfpustate - && self.mc_xfpustate_len == other.mc_xfpustate_len - && self.mc_spare == other.mc_spare - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_onstack.hash(state); - self.mc_rdi.hash(state); - self.mc_rsi.hash(state); - self.mc_rdx.hash(state); - self.mc_rcx.hash(state); - self.mc_r8.hash(state); - self.mc_r9.hash(state); - self.mc_rax.hash(state); - self.mc_rbx.hash(state); - self.mc_rbp.hash(state); - self.mc_r10.hash(state); - self.mc_r11.hash(state); - self.mc_r12.hash(state); - self.mc_r13.hash(state); - self.mc_r14.hash(state); - self.mc_r15.hash(state); - self.mc_trapno.hash(state); - self.mc_fs.hash(state); - self.mc_gs.hash(state); - self.mc_addr.hash(state); - self.mc_flags.hash(state); - self.mc_es.hash(state); - self.mc_ds.hash(state); - self.mc_err.hash(state); - self.mc_rip.hash(state); - self.mc_cs.hash(state); - self.mc_rflags.hash(state); - self.mc_rsp.hash(state); - self.mc_ss.hash(state); - self.mc_len.hash(state); - self.mc_fpformat.hash(state); - self.mc_ownedfp.hash(state); - self.mc_fpstate.hash(state); - self.mc_fsbase.hash(state); - self.mc_gsbase.hash(state); - self.mc_xfpustate.hash(state); - self.mc_xfpustate_len.hash(state); - self.mc_spare.hash(state); - } - } } } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4bf62033474f0..4dc4e4a20207e 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -59,13 +59,8 @@ cfg_if! { // link.h -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } impl siginfo_t { @@ -118,12 +113,12 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, pub gl_pathv: *mut *mut c_char, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + __unused8: Padding<*mut c_void>, } pub struct addrinfo { @@ -150,8 +145,8 @@ s! { pub si_status: c_int, pub si_addr: *mut c_void, pub si_value: crate::sigval, - _pad1: c_long, - _pad2: [c_int; 7], + _pad1: Padding, + _pad2: Padding<[c_int; 7]>, } pub struct sigaction { @@ -386,43 +381,13 @@ s! { pub struct eui64 { pub octet: [u8; EUI64_LEN], } -} -s_no_extra_traits! { pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: crate::sa_family_t, - __ss_pad1: [u8; 6], + __ss_pad1: Padding<[u8; 6]>, __ss_align: i64, - __ss_pad2: [u8; 112], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self.__ss_pad1 == other.__ss_pad1 - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } + __ss_pad2: Padding<[u8; 112]>, } } @@ -577,9 +542,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; pub const F_TLOCK: c_int = 2; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 24531db853145..8ab3632968c95 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -131,9 +131,6 @@ s! { pub flag: *mut c_int, pub val: c_int, } -} - -s_no_extra_traits! { pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, @@ -164,73 +161,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_len == other.sun_len - && self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_un {} - - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_len.hash(state); - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - } - } - } -} - pub const LC_ALL: c_int = 0; pub const LC_COLLATE: c_int = 1; pub const LC_CTYPE: c_int = 2; @@ -468,19 +398,24 @@ pub const POLLWRNORM: c_short = 0x004; pub const POLLRDBAND: c_short = 0x080; pub const POLLWRBAND: c_short = 0x100; -pub const BIOCGBLEN: c_ulong = 0x40044266; -pub const BIOCSBLEN: c_ulong = 0xc0044266; -pub const BIOCFLUSH: c_uint = 0x20004268; -pub const BIOCPROMISC: c_uint = 0x20004269; -pub const BIOCGDLT: c_ulong = 0x4004426a; -pub const BIOCGETIF: c_ulong = 0x4020426b; -pub const BIOCSETIF: c_ulong = 0x8020426c; -pub const BIOCGSTATS: c_ulong = 0x4008426f; -pub const BIOCIMMEDIATE: c_ulong = 0x80044270; -pub const BIOCVERSION: c_ulong = 0x40044271; -pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; -pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; -pub const SIOCGIFADDR: c_ulong = 0xc0206921; +cfg_if! { + // Not yet implemented on NetBSD + if #[cfg(not(any(target_os = "netbsd")))] { + pub const BIOCGBLEN: c_ulong = 0x40044266; + pub const BIOCSBLEN: c_ulong = 0xc0044266; + pub const BIOCFLUSH: c_uint = 0x20004268; + pub const BIOCPROMISC: c_uint = 0x20004269; + pub const BIOCGDLT: c_ulong = 0x4004426a; + pub const BIOCGETIF: c_ulong = 0x4020426b; + pub const BIOCSETIF: c_ulong = 0x8020426c; + pub const BIOCGSTATS: c_ulong = 0x4008426f; + pub const BIOCIMMEDIATE: c_ulong = 0x80044270; + pub const BIOCVERSION: c_ulong = 0x40044271; + pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; + pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; + pub const SIOCGIFADDR: c_ulong = 0xc0206921; + } +} pub const REG_BASIC: c_int = 0o0000; pub const REG_EXTENDED: c_int = 0o0001; @@ -795,6 +730,7 @@ extern "C" { )] #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigsuspend14")] pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; pub fn sem_close(sem: *mut sem_t) -> c_int; pub fn getdtablesize() -> c_int; @@ -869,6 +805,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), link_name = "wait4@FBSD_1.0" )] + #[cfg_attr(target_os = "netbsd", link_name = "__wait450")] pub fn wait4( pid: crate::pid_t, status: *mut c_int, @@ -879,11 +816,13 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "getitimer$UNIX2003" )] + #[cfg_attr(target_os = "netbsd", link_name = "__getitimer50")] pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "setitimer$UNIX2003" )] + #[cfg_attr(target_os = "netbsd", link_name = "__setitimer50")] pub fn setitimer( which: c_int, new_value: *const crate::itimerval, @@ -944,7 +883,10 @@ extern "C" { locale: crate::locale_t, ) -> size_t; + #[cfg_attr(target_os = "netbsd", link_name = "__devname50")] pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char; + + pub fn issetugid() -> c_int; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index bc3e4cdf094ff..e1edcf9ffdc07 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -16,21 +16,9 @@ pub type id_t = u32; pub type sem_t = *mut sem; pub type key_t = c_long; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum timezone {} + pub enum sem {} } s! { @@ -73,22 +61,6 @@ s! { pub l_whence: c_short, } - pub struct ipc_perm { - pub cuid: crate::uid_t, - pub cgid: crate::gid_t, - pub uid: crate::uid_t, - pub gid: crate::gid_t, - pub mode: mode_t, - #[cfg(target_os = "openbsd")] - pub seq: c_ushort, - #[cfg(target_os = "netbsd")] - pub _seq: c_ushort, - #[cfg(target_os = "openbsd")] - pub key: crate::key_t, - #[cfg(target_os = "netbsd")] - pub _key: crate::key_t, - } - pub struct ptrace_io_desc { pub piod_op: c_int, pub piod_offs: *mut c_void, @@ -203,9 +175,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; pub const F_TLOCK: c_int = 2; @@ -735,7 +704,8 @@ extern "C" { pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: crate::dev_t) + -> c_int; pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; @@ -779,6 +749,7 @@ extern "C" { pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; pub fn shmdt(shmaddr: *const c_void) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__shmctl50")] pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; // DIFF(main): changed to `*const *mut` in e77f551de9 diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 9f0831323af79..a3c286875c092 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1,22 +1,20 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + cpuid_t, + lwpid_t, + off_t, +}; -pub type clock_t = c_uint; -pub type suseconds_t = c_int; -pub type dev_t = u64; pub type blksize_t = i32; +pub type eventfd_t = u64; pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u64; pub type idtype_t = c_int; -pub type mqd_t = c_int; type __pthread_spin_t = __cpu_simple_lock_nv_t; -pub type vm_size_t = crate::uintptr_t; // FIXME(deprecated): deprecated since long time -pub type lwpid_t = c_uint; pub type shmatt_t = c_uint; -pub type cpuid_t = c_ulong; pub type cpuset_t = _cpuset; pub type pthread_spin_t = c_uchar; -pub type timer_t = c_int; // elf.h @@ -47,6 +45,10 @@ e! { } } +extern_ty! { + pub enum _cpuset {} +} + cfg_if! { if #[cfg(target_pointer_width = "64")] { type Elf_Addr = Elf64_Addr; @@ -78,7 +80,7 @@ impl siginfo_t { _si_signo: c_int, _si_errno: c_int, _si_code: c_int, - __pad1: c_int, + __pad1: Padding, _pid: crate::pid_t, } (*(self as *const siginfo_t as *const siginfo_timer))._pid @@ -90,7 +92,7 @@ impl siginfo_t { _si_signo: c_int, _si_errno: c_int, _si_code: c_int, - __pad1: c_int, + __pad1: Padding, _pid: crate::pid_t, _uid: crate::uid_t, } @@ -103,7 +105,7 @@ impl siginfo_t { _si_signo: c_int, _si_errno: c_int, _si_code: c_int, - __pad1: c_int, + __pad1: Padding, _pid: crate::pid_t, _uid: crate::uid_t, value: crate::sigval, @@ -117,7 +119,7 @@ impl siginfo_t { _si_signo: c_int, _si_errno: c_int, _si_code: c_int, - __pad1: c_int, + __pad1: Padding, _pid: crate::pid_t, _uid: crate::uid_t, _value: crate::sigval, @@ -150,13 +152,13 @@ s! { pub gl_flags: c_int, pub gl_pathv: *mut *mut c_char, - __unused3: *mut c_void, + __unused3: Padding<*mut c_void>, - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + __unused8: Padding<*mut c_void>, } pub struct mq_attr { @@ -166,11 +168,6 @@ s! { pub mq_curmsgs: c_long, } - pub struct itimerspec { - pub it_interval: crate::timespec, - pub it_value: crate::timespec, - } - pub struct sigset_t { __bits: [u32; 4], } @@ -214,9 +211,9 @@ s! { pub si_signo: c_int, pub si_code: c_int, pub si_errno: c_int, - __pad1: c_int, + __pad1: Padding, pub si_addr: *mut c_void, - __pad2: [u64; 13], + __pad2: Padding<[u64; 13]>, } pub struct pthread_attr_t { @@ -298,8 +295,7 @@ s! { pub flags: u32, pub fflags: u32, pub data: i64, - // FIXME(netbsd): NetBSD 10.0 will finally have same layout as other BSD - pub udata: intptr_t, + pub udata: *mut c_void, } pub struct dqblk { @@ -347,38 +343,6 @@ s! { pub int_n_sign_posn: c_char, } - pub struct if_data { - pub ifi_type: c_uchar, - pub ifi_addrlen: c_uchar, - pub ifi_hdrlen: c_uchar, - pub ifi_link_state: c_int, - pub ifi_mtu: u64, - pub ifi_metric: u64, - pub ifi_baudrate: u64, - pub ifi_ipackets: u64, - pub ifi_ierrors: u64, - pub ifi_opackets: u64, - pub ifi_oerrors: u64, - pub ifi_collisions: u64, - pub ifi_ibytes: u64, - pub ifi_obytes: u64, - pub ifi_imcasts: u64, - pub ifi_omcasts: u64, - pub ifi_iqdrops: u64, - pub ifi_noproto: u64, - pub ifi_lastchange: crate::timespec, - } - - pub struct if_msghdr { - pub ifm_msglen: c_ushort, - pub ifm_version: c_uchar, - pub ifm_type: c_uchar, - pub ifm_addrs: c_int, - pub ifm_flags: c_int, - pub ifm_index: c_ushort, - pub ifm_data: if_data, - } - pub struct sockcred { pub sc_pid: crate::pid_t, pub sc_uid: crate::uid_t, @@ -393,7 +357,7 @@ s! { pub cr_unused: c_ushort, pub cr_uid: crate::uid_t, pub cr_gid: crate::gid_t, - pub cr_ngroups: c_int, + pub cr_ngroups: c_short, pub cr_groups: [crate::gid_t; NGROUPS_MAX as usize], } @@ -411,12 +375,7 @@ s! { pub sdl_nlen: u8, pub sdl_alen: u8, pub sdl_slen: u8, - pub sdl_data: [c_char; 12], - } - - pub struct __exit_status { - pub e_termination: u16, - pub e_exit: u16, + pub sdl_data: [c_char; 24], } pub struct shmid_ds { @@ -431,47 +390,6 @@ s! { _shm_internal: *mut c_void, } - pub struct utmp { - pub ut_line: [c_char; UT_LINESIZE], - pub ut_name: [c_char; UT_NAMESIZE], - pub ut_host: [c_char; UT_HOSTSIZE], - pub ut_time: crate::time_t, - } - - pub struct lastlog { - pub ll_line: [c_char; UT_LINESIZE], - pub ll_host: [c_char; UT_HOSTSIZE], - pub ll_time: crate::time_t, - } - - pub struct timex { - pub modes: c_uint, - pub offset: c_long, - pub freq: c_long, - pub maxerror: c_long, - pub esterror: c_long, - pub status: c_int, - pub constant: c_long, - pub precision: c_long, - pub tolerance: c_long, - pub ppsfreq: c_long, - pub jitter: c_long, - pub shift: c_int, - pub stabil: c_long, - pub jitcnt: c_long, - pub calcnt: c_long, - pub errcnt: c_long, - pub stbcnt: c_long, - } - - pub struct ntptimeval { - pub time: crate::timespec, - pub maxerror: c_long, - pub esterror: c_long, - pub tai: c_long, - pub time_state: c_int, - } - // elf.h pub struct Elf32_Phdr { @@ -519,10 +437,6 @@ s! { pub dlpi_tls_data: *mut c_void, } - pub struct _cpuset { - bits: [u32; 0], - } - pub struct accept_filter_arg { pub af_name: [c_char; 16], af_arg: [c_char; 256 - 16], @@ -643,8 +557,8 @@ s! { pub l_priority: u8, pub l_usrpri: u8, pub l_stat: i8, - l_pad1: i8, - l_pad2: i32, + l_pad1: Padding, + l_pad2: Padding, pub l_wmesg: [c_char; KI_WMESGLEN as usize], pub l_wchan: u64, pub l_cpuid: u64, @@ -676,7 +590,7 @@ s! { pub kve_vn_rdev: u64, pub kve_vn_type: u32, pub kve_vn_mode: u32, - pub kve_path: [[c_char; 32]; 32], + pub kve_path: [c_char; crate::PATH_MAX as usize], } pub struct __c_anonymous_posix_spawn_fae_open { @@ -710,6 +624,7 @@ s! { pub fae: *mut posix_spawn_file_actions_entry_t, } + #[deprecated(since = "0.2.178", note = "obsolete upstream")] pub struct ptrace_lwpinfo { pub pl_lwpid: lwpid_t, pub pl_event: c_int, @@ -739,15 +654,6 @@ s! { pub descr_str: [c_char; 1], } - pub struct ifreq { - pub _priv: [[c_char; 6]; 24], - } - - pub struct ifconf { - pub ifc_len: c_int, - pub ifc_ifcu: __c_anonymous_ifc_ifcu, - } - pub struct tcp_info { pub tcpi_state: u8, pub __tcpi_ca_state: u8, @@ -790,29 +696,6 @@ s! { pub tcpi_snd_zerowin: u32, pub __tcpi_pad: [u32; 26], } -} - -s_no_extra_traits! { - pub struct utmpx { - pub ut_name: [c_char; _UTX_USERSIZE], - pub ut_id: [c_char; _UTX_IDSIZE], - pub ut_line: [c_char; _UTX_LINESIZE], - pub ut_host: [c_char; _UTX_HOSTSIZE], - pub ut_session: u16, - pub ut_type: u16, - pub ut_pid: crate::pid_t, - pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported - pub ut_ss: sockaddr_storage, - pub ut_tv: crate::timeval, - pub ut_pad: [u8; _UTX_PADSIZE], - } - - pub struct lastlogx { - pub ll_tv: crate::timeval, - pub ll_line: [c_char; _UTX_LINESIZE], - pub ll_host: [c_char; _UTX_HOSTSIZE], - pub ll_ss: sockaddr_storage, - } pub struct in_pktinfo { pub ipi_addr: crate::in_addr, @@ -852,358 +735,38 @@ s_no_extra_traits! { pub d_name: [c_char; 512], } - pub struct statvfs { - pub f_flag: c_ulong, - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_iosize: c_ulong, - - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_bresvd: crate::fsblkcnt_t, - - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fresvd: crate::fsfilcnt_t, - - pub f_syncreads: u64, - pub f_syncwrites: u64, - - pub f_asyncreads: u64, - pub f_asyncwrites: u64, - - pub f_fsidx: crate::fsid_t, - pub f_fsid: c_ulong, - pub f_namemax: c_ulong, - pub f_owner: crate::uid_t, - - pub f_spare: [u32; 4], - - pub f_fstypename: [c_char; 32], - pub f_mntonname: [c_char; 1024], - pub f_mntfromname: [c_char; 1024], - } - pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: crate::sa_family_t, - __ss_pad1: [u8; 6], - __ss_pad2: i64, - __ss_pad3: [u8; 112], + __ss_pad1: Padding<[u8; 6]>, + __ss_pad2: Padding, + __ss_pad3: Padding<[u8; 112]>, } pub struct sigevent { pub sigev_notify: c_int, pub sigev_signo: c_int, pub sigev_value: crate::sigval, - __unused1: *mut c_void, //actually a function pointer + __unused1: Padding<*mut c_void>, //actually a function pointer pub sigev_notify_attributes: *mut c_void, } +} +s_no_extra_traits! { pub union __c_anonymous_posix_spawn_fae { pub open: __c_anonymous_posix_spawn_fae_open, pub dup2: __c_anonymous_posix_spawn_fae_dup2, } - - pub union __c_anonymous_ifc_ifcu { - pub ifcu_buf: *mut c_void, - pub ifcu_req: *mut ifreq, - } } cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_name == other.ut_name - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_ss == other.ut_ss - && self - .ut_pad - .iter() - .zip(other.ut_pad.iter()) - .all(|(a, b)| a == b) - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_name.hash(state); - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_ss.hash(state); - self.ut_pad.hash(state); - } - } - - impl PartialEq for lastlogx { - fn eq(&self, other: &lastlogx) -> bool { - self.ll_tv == other.ll_tv - && self.ll_line == other.ll_line - && self.ll_ss == other.ll_ss - && self - .ll_host - .iter() - .zip(other.ll_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for lastlogx {} - - impl hash::Hash for lastlogx { - fn hash(&self, state: &mut H) { - self.ll_tv.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - self.ll_ss.hash(state); - } - } - - impl PartialEq for in_pktinfo { - fn eq(&self, other: &in_pktinfo) -> bool { - self.ipi_addr == other.ipi_addr && self.ipi_ifindex == other.ipi_ifindex - } - } - impl Eq for in_pktinfo {} - impl hash::Hash for in_pktinfo { - fn hash(&self, state: &mut H) { - self.ipi_addr.hash(state); - self.ipi_ifindex.hash(state); - } - } - - impl PartialEq for arphdr { - fn eq(&self, other: &arphdr) -> bool { - self.ar_hrd == other.ar_hrd - && self.ar_pro == other.ar_pro - && self.ar_hln == other.ar_hln - && self.ar_pln == other.ar_pln - && self.ar_op == other.ar_op - } - } - impl Eq for arphdr {} - impl hash::Hash for arphdr { - fn hash(&self, state: &mut H) { - let ar_hrd = self.ar_hrd; - let ar_pro = self.ar_pro; - let ar_op = self.ar_op; - ar_hrd.hash(state); - ar_pro.hash(state); - self.ar_hln.hash(state); - self.ar_pln.hash(state); - ar_op.hash(state); - } - } - - impl PartialEq for in_addr { - fn eq(&self, other: &in_addr) -> bool { - self.s_addr == other.s_addr - } - } - impl Eq for in_addr {} - impl hash::Hash for in_addr { - fn hash(&self, state: &mut H) { - let s_addr = self.s_addr; - s_addr.hash(state); - } - } - - impl PartialEq for ip_mreq { - fn eq(&self, other: &ip_mreq) -> bool { - self.imr_multiaddr == other.imr_multiaddr - && self.imr_interface == other.imr_interface - } - } - impl Eq for ip_mreq {} - impl hash::Hash for ip_mreq { - fn hash(&self, state: &mut H) { - self.imr_multiaddr.hash(state); - self.imr_interface.hash(state); - } - } - - impl PartialEq for sockaddr_in { - fn eq(&self, other: &sockaddr_in) -> bool { - self.sin_len == other.sin_len - && self.sin_family == other.sin_family - && self.sin_port == other.sin_port - && self.sin_addr == other.sin_addr - && self.sin_zero == other.sin_zero - } - } - impl Eq for sockaddr_in {} - impl hash::Hash for sockaddr_in { - fn hash(&self, state: &mut H) { - self.sin_len.hash(state); - self.sin_family.hash(state); - self.sin_port.hash(state); - self.sin_addr.hash(state); - self.sin_zero.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_reclen == other.d_reclen - && self.d_namlen == other.d_namlen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_reclen.hash(state); - self.d_namlen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for statvfs { - fn eq(&self, other: &statvfs) -> bool { - self.f_flag == other.f_flag - && self.f_bsize == other.f_bsize - && self.f_frsize == other.f_frsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_bresvd == other.f_bresvd - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_favail == other.f_favail - && self.f_fresvd == other.f_fresvd - && self.f_syncreads == other.f_syncreads - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncreads == other.f_asyncreads - && self.f_asyncwrites == other.f_asyncwrites - && self.f_fsidx == other.f_fsidx - && self.f_fsid == other.f_fsid - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_spare == other.f_spare - && self.f_fstypename == other.f_fstypename - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statvfs {} - impl hash::Hash for statvfs { - fn hash(&self, state: &mut H) { - self.f_flag.hash(state); - self.f_bsize.hash(state); - self.f_frsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_bresvd.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_favail.hash(state); - self.f_fresvd.hash(state); - self.f_syncreads.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncreads.hash(state); - self.f_asyncwrites.hash(state); - self.f_fsidx.hash(state); - self.f_fsid.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_spare.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self.__ss_pad1 == other.__ss_pad1 - && self.__ss_pad2 == other.__ss_pad2 - && self - .__ss_pad3 - .iter() - .zip(other.__ss_pad3.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_pad2.hash(state); - self.__ss_pad3.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - impl Eq for __c_anonymous_posix_spawn_fae {} - impl PartialEq for __c_anonymous_posix_spawn_fae { fn eq(&self, other: &__c_anonymous_posix_spawn_fae) -> bool { unsafe { self.open == other.open || self.dup2 == other.dup2 } } } - impl hash::Hash for __c_anonymous_posix_spawn_fae { fn hash(&self, state: &mut H) { unsafe { @@ -1212,23 +775,6 @@ cfg_if! { } } } - - impl Eq for __c_anonymous_ifc_ifcu {} - - impl PartialEq for __c_anonymous_ifc_ifcu { - fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { - unsafe { self.ifcu_buf == other.ifcu_buf || self.ifcu_req == other.ifcu_req } - } - } - - impl hash::Hash for __c_anonymous_ifc_ifcu { - fn hash(&self, state: &mut H) { - unsafe { - self.ifcu_buf.hash(state); - self.ifcu_req.hash(state); - } - } - } } } @@ -1259,7 +805,6 @@ pub const AT_RGID: c_int = 2003; pub const AT_SUN_LDELF: c_int = 2004; pub const AT_SUN_LDSHDR: c_int = 2005; pub const AT_SUN_LDNAME: c_int = 2006; -pub const AT_SUN_LDPGSIZE: c_int = 2007; pub const AT_SUN_PLATFORM: c_int = 2008; pub const AT_SUN_HWCAP: c_int = 2009; pub const AT_SUN_IFLUSH: c_int = 2010; @@ -1395,22 +940,6 @@ pub const LOCAL_PEEREID: c_int = 0x0003; // get peer identification pub const LOCAL_CREDS: c_int = 0x0004; // pass credentials to receiver // https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373 -pub const IFF_UP: c_int = 0x0001; // interface is up -pub const IFF_BROADCAST: c_int = 0x0002; // broadcast address valid -pub const IFF_DEBUG: c_int = 0x0004; // turn on debugging -pub const IFF_LOOPBACK: c_int = 0x0008; // is a loopback net -pub const IFF_POINTOPOINT: c_int = 0x0010; // interface is point-to-point link -pub const IFF_NOTRAILERS: c_int = 0x0020; // avoid use of trailers -pub const IFF_RUNNING: c_int = 0x0040; // resources allocated -pub const IFF_NOARP: c_int = 0x0080; // no address resolution protocol -pub const IFF_PROMISC: c_int = 0x0100; // receive all packets -pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets -pub const IFF_OACTIVE: c_int = 0x0400; // transmission in progress -pub const IFF_SIMPLEX: c_int = 0x0800; // can't hear own transmissions -pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit -pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit -pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit -pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast // sys/netinet/in.h // Protocols (RFC 1700) @@ -1502,7 +1031,6 @@ pub const NET_RT_OOOIFLIST: c_int = 3; pub const NET_RT_OOIFLIST: c_int = 4; pub const NET_RT_OIFLIST: c_int = 5; pub const NET_RT_IFLIST: c_int = 6; -pub const NET_RT_MAXID: c_int = 7; pub const PF_OROUTE: c_int = AF_OROUTE; pub const PF_ARP: c_int = AF_ARP; @@ -1689,12 +1217,6 @@ pub const FD_SETSIZE: usize = 0x100; pub const ST_NOSUID: c_ulong = 8; -pub const BIOCGRSIG: c_ulong = 0x40044272; -pub const BIOCSRSIG: c_ulong = 0x80044273; -pub const BIOCSDLT: c_ulong = 0x80044278; -pub const BIOCGSEESENT: c_ulong = 0x40044276; -pub const BIOCSSEESENT: c_ulong = 0x80044277; - // pub const MNT_UNION: c_int = 0x00000020; pub const MNT_NOCOREDUMP: c_int = 0x00008000; @@ -1738,65 +1260,16 @@ pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> | (num) } -// -pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; -pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; pub const NTP_API: c_int = 4; -pub const MAXPHASE: c_long = 500000000; -pub const MAXFREQ: c_long = 500000; -pub const MINSEC: c_int = 256; -pub const MAXSEC: c_int = 2048; -pub const NANOSECOND: c_long = 1000000000; -pub const SCALE_PPM: c_int = 65; -pub const MAXTC: c_int = 10; -pub const MOD_OFFSET: c_uint = 0x0001; -pub const MOD_FREQUENCY: c_uint = 0x0002; -pub const MOD_MAXERROR: c_uint = 0x0004; -pub const MOD_ESTERROR: c_uint = 0x0008; -pub const MOD_STATUS: c_uint = 0x0010; -pub const MOD_TIMECONST: c_uint = 0x0020; -pub const MOD_PPSMAX: c_uint = 0x0040; -pub const MOD_TAI: c_uint = 0x0080; -pub const MOD_MICRO: c_uint = 0x1000; -pub const MOD_NANO: c_uint = 0x2000; -pub const MOD_CLKB: c_uint = 0x4000; -pub const MOD_CLKA: c_uint = 0x8000; -pub const STA_PLL: c_int = 0x0001; -pub const STA_PPSFREQ: c_int = 0x0002; -pub const STA_PPSTIME: c_int = 0x0004; -pub const STA_FLL: c_int = 0x0008; -pub const STA_INS: c_int = 0x0010; -pub const STA_DEL: c_int = 0x0020; -pub const STA_UNSYNC: c_int = 0x0040; -pub const STA_FREQHOLD: c_int = 0x0080; -pub const STA_PPSSIGNAL: c_int = 0x0100; -pub const STA_PPSJITTER: c_int = 0x0200; -pub const STA_PPSWANDER: c_int = 0x0400; -pub const STA_PPSERROR: c_int = 0x0800; -pub const STA_CLOCKERR: c_int = 0x1000; -pub const STA_NANO: c_int = 0x2000; -pub const STA_MODE: c_int = 0x4000; -pub const STA_CLK: c_int = 0x8000; -pub const STA_RONLY: c_int = STA_PPSSIGNAL - | STA_PPSJITTER - | STA_PPSWANDER - | STA_PPSERROR - | STA_CLOCKERR - | STA_NANO - | STA_MODE - | STA_CLK; -pub const TIME_OK: c_int = 0; -pub const TIME_INS: c_int = 1; -pub const TIME_DEL: c_int = 2; -pub const TIME_OOP: c_int = 3; -pub const TIME_WAIT: c_int = 4; -pub const TIME_ERROR: c_int = 5; pub const LITTLE_ENDIAN: c_int = 1234; pub const BIG_ENDIAN: c_int = 4321; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_NONE: c_int = 0; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_SIGNAL: c_int = 1; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_SUSPENDED: c_int = 2; cfg_if! { @@ -1984,7 +1457,6 @@ pub const CTL_PROC: c_int = 10; pub const CTL_VENDOR: c_int = 11; pub const CTL_EMUL: c_int = 12; pub const CTL_SECURITY: c_int = 13; -pub const CTL_MAXID: c_int = 14; pub const KERN_OSTYPE: c_int = 1; pub const KERN_OSRELEASE: c_int = 2; pub const KERN_OSREV: c_int = 3; @@ -2069,7 +1541,6 @@ pub const KERN_ARND: c_int = 81; pub const KERN_SYSVIPC: c_int = 82; pub const KERN_BOOTTIME: c_int = 83; pub const KERN_EVCNT: c_int = 84; -pub const KERN_MAXID: c_int = 85; pub const KERN_PROC_ALL: c_int = 0; pub const KERN_PROC_PID: c_int = 1; pub const KERN_PROC_PGRP: c_int = 2; @@ -2137,31 +1608,6 @@ pub const ONLRET: crate::tcflag_t = 0x40; pub const CDTRCTS: crate::tcflag_t = 0x00020000; pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS | crate::CDTRCTS; -// pub const _PATH_UTMPX: &[c_char; 14] = b"/var/run/utmpx"; -// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx"; -// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx"; -// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update"; -pub const UT_NAMESIZE: usize = 8; -pub const UT_LINESIZE: usize = 8; -pub const UT_HOSTSIZE: usize = 16; -pub const _UTX_USERSIZE: usize = 32; -pub const _UTX_LINESIZE: usize = 32; -pub const _UTX_PADSIZE: usize = 40; -pub const _UTX_IDSIZE: usize = 4; -pub const _UTX_HOSTSIZE: usize = 256; -pub const EMPTY: u16 = 0; -pub const RUN_LVL: u16 = 1; -pub const BOOT_TIME: u16 = 2; -pub const OLD_TIME: u16 = 3; -pub const NEW_TIME: u16 = 4; -pub const INIT_PROCESS: u16 = 5; -pub const LOGIN_PROCESS: u16 = 6; -pub const USER_PROCESS: u16 = 7; -pub const DEAD_PROCESS: u16 = 8; -pub const ACCOUNTING: u16 = 9; -pub const SIGNATURE: u16 = 10; -pub const DOWN_TIME: u16 = 11; - pub const SOCK_CLOEXEC: c_int = 0x10000000; pub const SOCK_NONBLOCK: c_int = 0x20000000; @@ -2176,9 +1622,10 @@ pub const FIBMAP: c_ulong = 0xc008667a; pub const SIGSTKSZ: size_t = 40960; -pub const REG_ENOSYS: c_int = 17; +pub const REG_ILLSEQ: c_int = 17; pub const PT_DUMPCORE: c_int = 12; +#[deprecated(note = "obsolete operation")] pub const PT_LWPINFO: c_int = 13; pub const PT_SYSCALL: c_int = 14; pub const PT_SYSCALLEMU: c_int = 15; @@ -2188,7 +1635,7 @@ pub const PT_GET_PROCESS_STATE: c_int = 18; pub const PT_SET_SIGINFO: c_int = 19; pub const PT_GET_SIGINFO: c_int = 20; pub const PT_RESUME: c_int = 21; -pub const PT_SUSPEND: c_int = 23; +pub const PT_SUSPEND: c_int = 22; pub const PT_STOP: c_int = 23; pub const PT_LWPSTATUS: c_int = 24; pub const PT_LWPNEXT: c_int = 25; @@ -2297,6 +1744,11 @@ pub const RTA_TAG: c_int = 0x100; pub const RTAX_TAG: c_int = 8; pub const RTAX_MAX: c_int = 9; +// For eventfd +pub const EFD_SEMAPHORE: c_int = crate::O_RDWR; +pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; +pub const EFD_CLOEXEC: c_int = crate::O_CLOEXEC; + // sys/timerfd.h pub const TFD_CLOEXEC: i32 = crate::O_CLOEXEC; pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK; @@ -2394,8 +1846,6 @@ safe_f! { } extern "C" { - pub fn ntp_adjtime(buf: *mut timex) -> c_int; - pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; pub fn clock_nanosleep( clk_id: crate::clockid_t, flags: c_int, @@ -2680,7 +2130,9 @@ extern "C" { ) -> c_int; pub fn timer_delete(timerid: crate::timer_t) -> c_int; pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; + #[link_name = "__timer_gettime50"] pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; + #[link_name = "__timer_settime50"] pub fn timer_settime( timerid: crate::timer_t, flags: c_int, @@ -2706,6 +2158,7 @@ extern "C" { flags: c_int, ) -> *mut c_void; + #[link_name = "__sched_rr_get_interval50"] pub fn sched_rr_get_interval(pid: crate::pid_t, t: *mut crate::timespec) -> c_int; pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; @@ -2748,18 +2201,21 @@ extern "C" { ntargets: size_t, hint: *const c_void, ) -> c_int; - #[link_name = "__getmntinfo13"] pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; - pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int; + pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int; + + pub fn eventfd(val: c_uint, flags: c_int) -> c_int; + pub fn eventfd_read(efd: c_int, valp: *mut eventfd_t) -> c_int; + pub fn eventfd_write(efd: c_int, val: eventfd_t) -> c_int; // Added in `NetBSD` 10.0 pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; - pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; pub fn timerfd_settime( fd: c_int, flags: c_int, - new_value: *const itimerspec, - old_value: *mut itimerspec, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, ) -> c_int; pub fn qsort_r( @@ -2795,7 +2251,7 @@ extern "C" { #[link(name = "util")] extern "C" { - #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + #[link_name = "__getpwent_r50"] pub fn getpwent_r( pwd: *mut crate::passwd, buf: *mut c_char, @@ -2809,26 +2265,6 @@ extern "C" { result: *mut *mut crate::group, ) -> c_int; - pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; - pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) - -> *mut lastlogx; - pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; - pub fn utmpxname(file: *const c_char) -> c_int; - pub fn getutxent() -> *mut utmpx; - pub fn getutxid(ut: *const utmpx) -> *mut utmpx; - pub fn getutxline(ut: *const utmpx) -> *mut utmpx; - pub fn pututxline(ut: *const utmpx) -> *mut utmpx; - pub fn setutxent(); - pub fn endutxent(); - - pub fn getutmp(ux: *const utmpx, u: *mut utmp); - pub fn getutmpx(u: *const utmp, ux: *mut utmpx); - - pub fn utpname(file: *const c_char) -> c_int; - pub fn setutent(); - pub fn endutent(); - pub fn getutent() -> *mut utmp; - pub fn efopen(p: *const c_char, m: *const c_char) -> crate::FILE; pub fn emalloc(n: size_t) -> *mut c_void; pub fn ecalloc(n: size_t, c: size_t) -> *mut c_void; @@ -2890,9 +2326,9 @@ extern "C" { precision: size_t, ) -> *mut c_char; #[link_name = "__login50"] - pub fn login(ut: *const utmp); + pub fn login(ut: *const crate::utmp); #[link_name = "__loginx50"] - pub fn loginx(ut: *const utmpx); + pub fn loginx(ut: *const crate::utmpx); pub fn logout(line: *const c_char); pub fn logoutx(line: *const c_char, status: c_int, tpe: c_int); pub fn logwtmp(line: *const c_char, name: *const c_char, host: *const c_char); diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index 47240cb2818c0..8cacb7250eddc 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -1,16 +1,15 @@ -use PT_FIRSTMACH; - use crate::prelude::*; +use crate::PT_FIRSTMACH; pub type __greg_t = u64; pub type __cpu_simple_lock_nv_t = c_int; pub type __gregset = [__greg_t; _NGREG]; -pub type __fregset = [__freg; _NFREG]; +pub type __fregset = [__fpreg; _NFREG]; s! { pub struct mcontext_t { pub __gregs: __gregset, - pub __fregs: __fpregset, + pub __fregs: __fregset, __spare: [crate::__greg_t; 7], } } @@ -22,6 +21,22 @@ s_no_extra_traits! { } } +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __fpreg { + fn eq(&self, other: &Self) -> bool { + unsafe { self.u_u64 == other.u_u64 } + } + } + impl Eq for __fpreg {} + impl hash::Hash for __fpreg { + fn hash(&self, state: &mut H) { + unsafe { self.u_u64.hash(state) }; + } + } + } +} + pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index 77daa4b1e9eb2..801b326b70fa5 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -4,11 +4,14 @@ use crate::PT_FIRSTMACH; pub type c___greg_t = u64; pub type __cpu_simple_lock_nv_t = c_uchar; +// FIXME(alignment): Type is `__aligned(8)` +type __fpregset_t = [c_char; 512]; + s! { pub struct mcontext_t { pub __gregs: [c___greg_t; 26], pub _mc_tlsbase: c___greg_t, - pub __fpregs: [[c_char; 32]; 16], + pub __fpregs: __fpregset_t, } pub struct ucontext_t { diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index b28f4557f5218..3249fd526a745 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1,6 +1,9 @@ use crate::prelude::*; use crate::unix::bsd::O_SYNC; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type clock_t = i64; pub type suseconds_t = c_long; @@ -72,13 +75,13 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, pub gl_pathv: *mut *mut c_char, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, } pub struct lconv { @@ -606,62 +609,7 @@ s! { pub tcpi_so_snd_sb_lowat: u32, pub tcpi_so_snd_sb_wat: u32, } -} - -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_char { - self.si_addr - } - - pub unsafe fn si_code(&self) -> c_int { - self.si_code - } - - pub unsafe fn si_errno(&self) -> c_int { - self.si_errno - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - #[repr(C)] - struct siginfo_timer { - _si_signo: c_int, - _si_code: c_int, - _si_errno: c_int, - _pad: [c_int; SI_PAD], - _pid: crate::pid_t, - } - (*(self as *const siginfo_t).cast::())._pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - #[repr(C)] - struct siginfo_timer { - _si_signo: c_int, - _si_code: c_int, - _si_errno: c_int, - _pad: [c_int; SI_PAD], - _pid: crate::pid_t, - _uid: crate::uid_t, - } - (*(self as *const siginfo_t).cast::())._uid - } - - pub unsafe fn si_value(&self) -> crate::sigval { - #[repr(C)] - struct siginfo_timer { - _si_signo: c_int, - _si_code: c_int, - _si_errno: c_int, - _pad: [c_int; SI_PAD], - _pid: crate::pid_t, - _uid: crate::uid_t, - value: crate::sigval, - } - (*(self as *const siginfo_t).cast::()).value - } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, @@ -704,30 +652,6 @@ s_no_extra_traits! { pub ut_time: crate::time_t, } - pub union mount_info { - pub ufs_args: ufs_args, - pub mfs_args: mfs_args, - pub nfs_args: nfs_args, - pub iso_args: iso_args, - pub msdosfs_args: msdosfs_args, - pub ntfs_args: ntfs_args, - pub tmpfs_args: tmpfs_args, - align: [c_char; 160], - } - - pub union __c_anonymous_ifr_ifru { - pub ifru_addr: crate::sockaddr, - pub ifru_dstaddr: crate::sockaddr, - pub ifru_broadaddr: crate::sockaddr, - pub ifru_flags: c_short, - pub ifru_metric: c_int, - pub ifru_vnetid: i64, - pub ifru_media: u64, - pub ifru_data: crate::caddr_t, - pub ifru_index: c_uint, - } - - // This type uses the union mount_info: pub struct statfs { pub f_flags: u32, pub f_bsize: u32, @@ -754,148 +678,111 @@ s_no_extra_traits! { } } +s_no_extra_traits! { + pub union mount_info { + pub ufs_args: ufs_args, + pub mfs_args: mfs_args, + pub nfs_args: nfs_args, + pub iso_args: iso_args, + pub msdosfs_args: msdosfs_args, + pub ntfs_args: ntfs_args, + pub tmpfs_args: tmpfs_args, + align: [c_char; 160], + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self - .d_name + impl PartialEq for mount_info { + fn eq(&self, other: &mount_info) -> bool { + unsafe { + self.align .iter() - .zip(other.d_name.iter()) + .zip(other.align.iter()) .all(|(a, b)| a == b) + } } } - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len && self.ss_family == other.ss_family - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - } - } - - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_code == other.si_code - && self.si_errno == other.si_errno - && self.si_addr == other.si_addr - } - } - - impl Eq for siginfo_t {} + impl Eq for mount_info {} - impl hash::Hash for siginfo_t { + impl hash::Hash for mount_info { fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_code.hash(state); - self.si_errno.hash(state); - self.si_addr.hash(state); + unsafe { self.align.hash(state) }; } } + } +} - impl PartialEq for lastlog { - fn eq(&self, other: &lastlog) -> bool { - self.ll_time == other.ll_time - && self - .ll_line - .iter() - .zip(other.ll_line.iter()) - .all(|(a, b)| a == b) - && self - .ll_host - .iter() - .zip(other.ll_host.iter()) - .all(|(a, b)| a == b) - } - } +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_char { + self.si_addr + } - impl Eq for lastlog {} + pub unsafe fn si_code(&self) -> c_int { + self.si_code + } - impl hash::Hash for lastlog { - fn hash(&self, state: &mut H) { - self.ll_time.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - } - } + pub unsafe fn si_errno(&self) -> c_int { + self.si_errno + } - impl PartialEq for utmp { - fn eq(&self, other: &utmp) -> bool { - self.ut_time == other.ut_time - && self - .ut_line - .iter() - .zip(other.ut_line.iter()) - .all(|(a, b)| a == b) - && self - .ut_name - .iter() - .zip(other.ut_name.iter()) - .all(|(a, b)| a == b) - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - } + pub unsafe fn si_pid(&self) -> crate::pid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: Padding<[c_int; SI_PAD]>, + _pid: crate::pid_t, } + (*(self as *const siginfo_t).cast::())._pid + } - impl Eq for utmp {} - - impl hash::Hash for utmp { - fn hash(&self, state: &mut H) { - self.ut_line.hash(state); - self.ut_name.hash(state); - self.ut_host.hash(state); - self.ut_time.hash(state); - } + pub unsafe fn si_uid(&self) -> crate::uid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: Padding<[c_int; SI_PAD]>, + _pid: crate::pid_t, + _uid: crate::uid_t, } + (*(self as *const siginfo_t).cast::())._uid + } - impl PartialEq for mount_info { - fn eq(&self, other: &mount_info) -> bool { - unsafe { - self.align - .iter() - .zip(other.align.iter()) - .all(|(a, b)| a == b) - } - } + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: Padding<[c_int; SI_PAD]>, + _pid: crate::pid_t, + _uid: crate::uid_t, + value: crate::sigval, } + (*(self as *const siginfo_t).cast::()).value + } +} - impl Eq for mount_info {} - - impl hash::Hash for mount_info { - fn hash(&self, state: &mut H) { - unsafe { self.align.hash(state) }; - } - } +s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_flags: c_short, + pub ifru_metric: c_int, + pub ifru_vnetid: i64, + pub ifru_media: u64, + pub ifru_data: crate::caddr_t, + pub ifru_index: c_uint, + } +} +cfg_if! { + if #[cfg(feature = "extra_traits")] { impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -929,78 +816,6 @@ cfg_if! { } } } - - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_favail == other.f_favail - && self.f_syncwrites == other.f_syncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncwrites == other.f_asyncwrites - && self.f_asyncreads == other.f_asyncreads - && self.f_fsid == other.f_fsid - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_ctime == other.f_ctime - && self - .f_fstypename - .iter() - .zip(other.f_fstypename.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntfromspec - .iter() - .zip(other.f_mntfromspec.iter()) - .all(|(a, b)| a == b) - && self.mount_info == other.mount_info - } - } - - impl Eq for statfs {} - - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_favail.hash(state); - self.f_syncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncwrites.hash(state); - self.f_asyncreads.hash(state); - self.f_fsid.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_ctime.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - self.f_mntfromspec.hash(state); - self.mount_info.hash(state); - } - } } } diff --git a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs index 984570c387013..4abe8a1a7c5ed 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -36,9 +36,7 @@ s! { pub sc_mask: c_int, pub sc_cookie: c_long, } -} -s_no_extra_traits! { #[repr(packed)] pub struct fxsave64 { pub fx_fcw: u16, @@ -56,48 +54,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - // `fxsave64` is packed, so field access is unaligned. - // use {x} to create temporary storage, copy field to it, and do aligned access. - impl PartialEq for fxsave64 { - fn eq(&self, other: &fxsave64) -> bool { - return { self.fx_fcw } == { other.fx_fcw } - && { self.fx_fsw } == { other.fx_fsw } - && { self.fx_ftw } == { other.fx_ftw } - && { self.fx_fop } == { other.fx_fop } - && { self.fx_rip } == { other.fx_rip } - && { self.fx_rdp } == { other.fx_rdp } - && { self.fx_mxcsr } == { other.fx_mxcsr } - && { self.fx_mxcsr_mask } == { other.fx_mxcsr_mask } - && { self.fx_st } - .iter() - .zip({ other.fx_st }.iter()) - .all(|(a, b)| a == b) - && { self.fx_xmm } - .iter() - .zip({ other.fx_xmm }.iter()) - .all(|(a, b)| a == b); - } - } - impl Eq for fxsave64 {} - impl hash::Hash for fxsave64 { - fn hash(&self, state: &mut H) { - { self.fx_fcw }.hash(state); - { self.fx_fsw }.hash(state); - { self.fx_ftw }.hash(state); - { self.fx_fop }.hash(state); - { self.fx_rip }.hash(state); - { self.fx_rdp }.hash(state); - { self.fx_mxcsr }.hash(state); - { self.fx_mxcsr_mask }.hash(state); - { self.fx_st }.hash(state); - { self.fx_xmm }.hash(state); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 12e30f3f9016c..94c156c8f41ce 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -28,13 +28,8 @@ pub type nlink_t = c_ushort; pub type suseconds_t = c_long; pub type useconds_t = c_ulong; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } pub type sigset_t = c_ulong; @@ -75,13 +70,8 @@ pub type nfds_t = c_uint; pub type sem_t = *mut sem; -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum sem {} } pub type tcflag_t = c_uint; @@ -377,9 +367,9 @@ s! { pub struct sockaddr_storage { pub ss_family: sa_family_t, - __ss_pad1: [c_char; 6], + __ss_pad1: Padding<[c_char; 6]>, __ss_align: i64, - __ss_pad2: [c_char; 112], + __ss_pad2: Padding<[c_char; 112]>, } pub struct stat { @@ -450,12 +440,19 @@ s! { pub f_namelen: c_long, pub f_spare: [c_long; 6], } -} -s_no_extra_traits! { - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4], + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct utsname { + pub sysname: [c_char; 66], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainname: [c_char; 65], } pub struct siginfo_t { @@ -464,7 +461,23 @@ s_no_extra_traits! { pub si_pid: pid_t, pub si_uid: uid_t, pub si_errno: c_int, - __pad: [u32; 32], + __pad: Padding<[u32; 32]>, + } + + pub struct dirent { + __d_version: u32, + pub d_ino: ino_t, + pub d_type: c_uchar, + __d_unused1: [c_uchar; 3], + __d_internal1: u32, + pub d_name: [c_char; 256], + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], } pub union __c_anonymous_ifr_ifru { @@ -478,7 +491,7 @@ s_no_extra_traits! { pub ifru_mtu: c_int, pub ifru_ifindex: c_int, pub ifru_data: *mut c_char, - __ifru_pad: [c_char; 28], + __ifru_pad: Padding<[c_char; 28]>, } pub struct ifreq { @@ -497,27 +510,16 @@ s_no_extra_traits! { pub ifc_ifcu: __c_anonymous_ifc_ifcu, } - pub struct dirent { - __d_version: u32, - pub d_ino: ino_t, - pub d_type: c_uchar, - __d_unused1: [c_uchar; 3], - __d_internal1: u32, - pub d_name: [c_char; 256], - } - - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108], - } - - pub struct utsname { - pub sysname: [c_char; 66], - pub nodename: [c_char; 65], - pub release: [c_char; 65], - pub version: [c_char; 65], - pub machine: [c_char; 65], - pub domainname: [c_char; 65], + pub struct utmpx { + pub ut_type: c_short, + pub ut_pid: pid_t, + pub ut_line: [c_char; UT_LINESIZE], + pub ut_id: [c_char; UT_IDLEN], + pub ut_time: time_t, + pub ut_user: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_addr: c_long, + pub ut_tv: timeval, } } @@ -570,122 +572,6 @@ impl siginfo_t { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_code == other.si_code - && self.si_pid == other.si_pid - && self.si_uid == other.si_uid - && self.si_errno == other.si_errno - } - } - - impl Eq for siginfo_t {} - - impl hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_code.hash(state); - self.si_pid.hash(state); - self.si_uid.hash(state); - self.si_errno.hash(state); - // Ignore __pad - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_un {} - - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - && self - .domainname - .iter() - .zip(other.domainname.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - self.domainname.hash(state); - } - } - } -} - pub const FD_SETSIZE: usize = 1024; pub const CPU_SETSIZE: c_int = 0x400; @@ -1015,6 +901,8 @@ pub const PATH_MAX: c_int = 4096; pub const PIPE_BUF: usize = 4096; pub const NGROUPS_MAX: c_int = 1024; +pub const FILENAME_MAX: c_int = 4096; + pub const FORK_RELOAD: c_int = 1; pub const FORK_NO_RELOAD: c_int = 0; @@ -1092,6 +980,19 @@ pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; pub const EAI_OVERFLOW: c_int = 14; +pub const UT_LINESIZE: usize = 16; +pub const UT_NAMESIZE: usize = 16; +pub const UT_HOSTSIZE: usize = 256; +pub const UT_IDLEN: usize = 2; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const NEW_TIME: c_short = 3; +pub const OLD_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; + pub const POLLIN: c_short = 0x1; pub const POLLPRI: c_short = 0x2; pub const POLLOUT: c_short = 0x4; @@ -1335,9 +1236,6 @@ pub const X_OK: c_int = 1; pub const SEEK_SET: c_int = 0; pub const SEEK_CUR: c_int = 1; pub const SEEK_END: c_int = 2; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const _SC_ARG_MAX: c_int = 0; pub const _SC_CHILD_MAX: c_int = 1; pub const _SC_CLK_TCK: c_int = 2; @@ -1746,6 +1644,8 @@ pub const _POSIX_VDISABLE: cc_t = 0; pub const GRND_NONBLOCK: c_uint = 0x1; pub const GRND_RANDOM: c_uint = 0x2; +pub const _IOFBF: c_int = 0; +pub const _IOLBF: c_int = 1; pub const _IONBF: c_int = 2; pub const BUFSIZ: c_int = 1024; @@ -2446,6 +2346,7 @@ extern "C" { winp: *const crate::winsize, ) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; pub fn getgrgid_r( gid: crate::gid_t, grp: *mut crate::group, @@ -2459,6 +2360,7 @@ extern "C" { groups: *mut crate::gid_t, ngroups: *mut c_int, ) -> c_int; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; pub fn getgrnam_r( name: *const c_char, grp: *mut crate::group, @@ -2474,4 +2376,13 @@ extern "C" { pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + + pub fn endutxent(); + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(id: *const utmpx) -> *mut utmpx; + pub fn getutxline(line: *const utmpx) -> *mut utmpx; + pub fn pututxline(utmpx: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn utmpxname(file: *const c_char) -> c_int; + pub fn updwtmpx(file: *const c_char, utmpx: *const utmpx); } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 964598e97ca35..6658968a885ee 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -80,13 +80,8 @@ pub type ACTION = c_int; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } impl siginfo_t { @@ -281,17 +276,17 @@ s! { pub struct glob_t { pub gl_pathc: size_t, - __unused1: size_t, + __unused1: Padding, pub gl_offs: size_t, - __unused2: size_t, + __unused2: Padding, pub gl_pathv: *mut *mut c_char, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + __unused8: Padding<*mut c_void>, } pub struct pthread_mutex_t { @@ -462,9 +457,7 @@ s! { pub flag: *mut c_int, pub val: c_int, } -} -s_no_extra_traits! { pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, @@ -473,9 +466,9 @@ s_no_extra_traits! { pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_pad2: u64, - __ss_pad3: [u8; 112], + __ss_pad1: Padding<[u8; 6]>, + __ss_pad2: Padding, + __ss_pad3: Padding<[u8; 112]>, } pub struct dirent { pub d_dev: dev_t, @@ -490,7 +483,7 @@ s_no_extra_traits! { pub sigev_notify: c_int, pub sigev_signo: c_int, pub sigev_value: crate::sigval, - __unused1: *mut c_void, // actually a function pointer + __unused1: Padding<*mut c_void>, // actually a function pointer pub sigev_notify_attributes: *mut crate::pthread_attr_t, } @@ -506,132 +499,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_tv == other.ut_tv - && self.ut_id == other.ut_id - && self.ut_pid == other.ut_pid - && self.ut_user == other.ut_user - && self.ut_line == other.ut_line - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.__ut_reserved == other.__ut_reserved - } - } - - impl Eq for utmpx {} - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_tv.hash(state); - self.ut_id.hash(state); - self.ut_pid.hash(state); - self.ut_user.hash(state); - self.ut_line.hash(state); - self.ut_host.hash(state); - self.__ut_reserved.hash(state); - } - } - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_len == other.sun_len - && self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_len.hash(state); - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self - .__ss_pad1 - .iter() - .zip(other.__ss_pad1.iter()) - .all(|(a, b)| a == b) - && self.__ss_pad2 == other.__ss_pad2 - && self - .__ss_pad3 - .iter() - .zip(other.__ss_pad3.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_pad2.hash(state); - self.__ss_pad3.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_dev == other.d_dev - && self.d_pdev == other.d_pdev - && self.d_ino == other.d_ino - && self.d_pino == other.d_pino - && self.d_reclen == other.d_reclen - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_dev.hash(state); - self.d_pdev.hash(state); - self.d_ino.hash(state); - self.d_pino.hash(state); - self.d_reclen.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - } -} - pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; pub const RAND_MAX: c_int = 2147483647; @@ -751,9 +618,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 13a203f92ff56..acf6b3486de79 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -37,200 +37,200 @@ pub type image_id = i32; c_enum! { // kernel/OS.h pub enum thread_state { - B_THREAD_RUNNING = 1, - B_THREAD_READY, - B_THREAD_RECEIVING, - B_THREAD_ASLEEP, - B_THREAD_SUSPENDED, - B_THREAD_WAITING, + pub B_THREAD_RUNNING = 1, + pub B_THREAD_READY, + pub B_THREAD_RECEIVING, + pub B_THREAD_ASLEEP, + pub B_THREAD_SUSPENDED, + pub B_THREAD_WAITING, } // kernel/image.h pub enum image_type { - B_APP_IMAGE = 1, - B_LIBRARY_IMAGE, - B_ADD_ON_IMAGE, - B_SYSTEM_IMAGE, + pub B_APP_IMAGE = 1, + pub B_LIBRARY_IMAGE, + pub B_ADD_ON_IMAGE, + pub B_SYSTEM_IMAGE, } // kernel/scheduler.h pub enum be_task_flags { - B_DEFAULT_MEDIA_PRIORITY = 0x000, - B_OFFLINE_PROCESSING = 0x001, - B_STATUS_RENDERING = 0x002, - B_USER_INPUT_HANDLING = 0x004, - B_LIVE_VIDEO_MANIPULATION = 0x008, - B_VIDEO_PLAYBACK = 0x010, - B_VIDEO_RECORDING = 0x020, - B_LIVE_AUDIO_MANIPULATION = 0x040, - B_AUDIO_PLAYBACK = 0x080, - B_AUDIO_RECORDING = 0x100, - B_LIVE_3D_RENDERING = 0x200, - B_NUMBER_CRUNCHING = 0x400, - B_MIDI_PROCESSING = 0x800, + pub B_DEFAULT_MEDIA_PRIORITY = 0x000, + pub B_OFFLINE_PROCESSING = 0x001, + pub B_STATUS_RENDERING = 0x002, + pub B_USER_INPUT_HANDLING = 0x004, + pub B_LIVE_VIDEO_MANIPULATION = 0x008, + pub B_VIDEO_PLAYBACK = 0x010, + pub B_VIDEO_RECORDING = 0x020, + pub B_LIVE_AUDIO_MANIPULATION = 0x040, + pub B_AUDIO_PLAYBACK = 0x080, + pub B_AUDIO_RECORDING = 0x100, + pub B_LIVE_3D_RENDERING = 0x200, + pub B_NUMBER_CRUNCHING = 0x400, + pub B_MIDI_PROCESSING = 0x800, } pub enum schduler_mode { - SCHEDULER_MODE_LOW_LATENCY, - SCHEDULER_MODE_POWER_SAVING, + pub SCHEDULER_MODE_LOW_LATENCY, + pub SCHEDULER_MODE_POWER_SAVING, } // FindDirectory.h pub enum path_base_directory { - B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY, - B_FIND_PATH_ADD_ONS_DIRECTORY, - B_FIND_PATH_APPS_DIRECTORY, - B_FIND_PATH_BIN_DIRECTORY, - B_FIND_PATH_BOOT_DIRECTORY, - B_FIND_PATH_CACHE_DIRECTORY, - B_FIND_PATH_DATA_DIRECTORY, - B_FIND_PATH_DEVELOP_DIRECTORY, - B_FIND_PATH_DEVELOP_LIB_DIRECTORY, - B_FIND_PATH_DOCUMENTATION_DIRECTORY, - B_FIND_PATH_ETC_DIRECTORY, - B_FIND_PATH_FONTS_DIRECTORY, - B_FIND_PATH_HEADERS_DIRECTORY, - B_FIND_PATH_LIB_DIRECTORY, - B_FIND_PATH_LOG_DIRECTORY, - B_FIND_PATH_MEDIA_NODES_DIRECTORY, - B_FIND_PATH_PACKAGES_DIRECTORY, - B_FIND_PATH_PREFERENCES_DIRECTORY, - B_FIND_PATH_SERVERS_DIRECTORY, - B_FIND_PATH_SETTINGS_DIRECTORY, - B_FIND_PATH_SOUNDS_DIRECTORY, - B_FIND_PATH_SPOOL_DIRECTORY, - B_FIND_PATH_TRANSLATORS_DIRECTORY, - B_FIND_PATH_VAR_DIRECTORY, - B_FIND_PATH_IMAGE_PATH = 1000, - B_FIND_PATH_PACKAGE_PATH, + pub B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY, + pub B_FIND_PATH_ADD_ONS_DIRECTORY, + pub B_FIND_PATH_APPS_DIRECTORY, + pub B_FIND_PATH_BIN_DIRECTORY, + pub B_FIND_PATH_BOOT_DIRECTORY, + pub B_FIND_PATH_CACHE_DIRECTORY, + pub B_FIND_PATH_DATA_DIRECTORY, + pub B_FIND_PATH_DEVELOP_DIRECTORY, + pub B_FIND_PATH_DEVELOP_LIB_DIRECTORY, + pub B_FIND_PATH_DOCUMENTATION_DIRECTORY, + pub B_FIND_PATH_ETC_DIRECTORY, + pub B_FIND_PATH_FONTS_DIRECTORY, + pub B_FIND_PATH_HEADERS_DIRECTORY, + pub B_FIND_PATH_LIB_DIRECTORY, + pub B_FIND_PATH_LOG_DIRECTORY, + pub B_FIND_PATH_MEDIA_NODES_DIRECTORY, + pub B_FIND_PATH_PACKAGES_DIRECTORY, + pub B_FIND_PATH_PREFERENCES_DIRECTORY, + pub B_FIND_PATH_SERVERS_DIRECTORY, + pub B_FIND_PATH_SETTINGS_DIRECTORY, + pub B_FIND_PATH_SOUNDS_DIRECTORY, + pub B_FIND_PATH_SPOOL_DIRECTORY, + pub B_FIND_PATH_TRANSLATORS_DIRECTORY, + pub B_FIND_PATH_VAR_DIRECTORY, + pub B_FIND_PATH_IMAGE_PATH = 1000, + pub B_FIND_PATH_PACKAGE_PATH, } pub enum directory_which { - B_DESKTOP_DIRECTORY = 0, - B_TRASH_DIRECTORY, - B_SYSTEM_DIRECTORY = 1000, - B_SYSTEM_ADDONS_DIRECTORY = 1002, - B_SYSTEM_BOOT_DIRECTORY, - B_SYSTEM_FONTS_DIRECTORY, - B_SYSTEM_LIB_DIRECTORY, - B_SYSTEM_SERVERS_DIRECTORY, - B_SYSTEM_APPS_DIRECTORY, - B_SYSTEM_BIN_DIRECTORY, - B_SYSTEM_DOCUMENTATION_DIRECTORY = 1010, - B_SYSTEM_PREFERENCES_DIRECTORY, - B_SYSTEM_TRANSLATORS_DIRECTORY, - B_SYSTEM_MEDIA_NODES_DIRECTORY, - B_SYSTEM_SOUNDS_DIRECTORY, - B_SYSTEM_DATA_DIRECTORY, - B_SYSTEM_DEVELOP_DIRECTORY, - B_SYSTEM_PACKAGES_DIRECTORY, - B_SYSTEM_HEADERS_DIRECTORY, - B_SYSTEM_ETC_DIRECTORY = 2008, - B_SYSTEM_SETTINGS_DIRECTORY = 2010, - B_SYSTEM_LOG_DIRECTORY = 2012, - B_SYSTEM_SPOOL_DIRECTORY, - B_SYSTEM_TEMP_DIRECTORY, - B_SYSTEM_VAR_DIRECTORY, - B_SYSTEM_CACHE_DIRECTORY = 2020, - B_SYSTEM_NONPACKAGED_DIRECTORY = 2023, - B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY, - B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY, - B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY, - B_SYSTEM_NONPACKAGED_BIN_DIRECTORY, - B_SYSTEM_NONPACKAGED_DATA_DIRECTORY, - B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY, - B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY, - B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY, - B_SYSTEM_NONPACKAGED_LIB_DIRECTORY, - B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY, - B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY, - B_USER_DIRECTORY = 3000, - B_USER_CONFIG_DIRECTORY, - B_USER_ADDONS_DIRECTORY, - B_USER_BOOT_DIRECTORY, - B_USER_FONTS_DIRECTORY, - B_USER_LIB_DIRECTORY, - B_USER_SETTINGS_DIRECTORY, - B_USER_DESKBAR_DIRECTORY, - B_USER_PRINTERS_DIRECTORY, - B_USER_TRANSLATORS_DIRECTORY, - B_USER_MEDIA_NODES_DIRECTORY, - B_USER_SOUNDS_DIRECTORY, - B_USER_DATA_DIRECTORY, - B_USER_CACHE_DIRECTORY, - B_USER_PACKAGES_DIRECTORY, - B_USER_HEADERS_DIRECTORY, - B_USER_NONPACKAGED_DIRECTORY, - B_USER_NONPACKAGED_ADDONS_DIRECTORY, - B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY, - B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY, - B_USER_NONPACKAGED_BIN_DIRECTORY, - B_USER_NONPACKAGED_DATA_DIRECTORY, - B_USER_NONPACKAGED_FONTS_DIRECTORY, - B_USER_NONPACKAGED_SOUNDS_DIRECTORY, - B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY, - B_USER_NONPACKAGED_LIB_DIRECTORY, - B_USER_NONPACKAGED_HEADERS_DIRECTORY, - B_USER_NONPACKAGED_DEVELOP_DIRECTORY, - B_USER_DEVELOP_DIRECTORY, - B_USER_DOCUMENTATION_DIRECTORY, - B_USER_SERVERS_DIRECTORY, - B_USER_APPS_DIRECTORY, - B_USER_BIN_DIRECTORY, - B_USER_PREFERENCES_DIRECTORY, - B_USER_ETC_DIRECTORY, - B_USER_LOG_DIRECTORY, - B_USER_SPOOL_DIRECTORY, - B_USER_VAR_DIRECTORY, - B_APPS_DIRECTORY = 4000, - B_PREFERENCES_DIRECTORY, - B_UTILITIES_DIRECTORY, - B_PACKAGE_LINKS_DIRECTORY, + pub B_DESKTOP_DIRECTORY = 0, + pub B_TRASH_DIRECTORY, + pub B_SYSTEM_DIRECTORY = 1000, + pub B_SYSTEM_ADDONS_DIRECTORY = 1002, + pub B_SYSTEM_BOOT_DIRECTORY, + pub B_SYSTEM_FONTS_DIRECTORY, + pub B_SYSTEM_LIB_DIRECTORY, + pub B_SYSTEM_SERVERS_DIRECTORY, + pub B_SYSTEM_APPS_DIRECTORY, + pub B_SYSTEM_BIN_DIRECTORY, + pub B_SYSTEM_DOCUMENTATION_DIRECTORY = 1010, + pub B_SYSTEM_PREFERENCES_DIRECTORY, + pub B_SYSTEM_TRANSLATORS_DIRECTORY, + pub B_SYSTEM_MEDIA_NODES_DIRECTORY, + pub B_SYSTEM_SOUNDS_DIRECTORY, + pub B_SYSTEM_DATA_DIRECTORY, + pub B_SYSTEM_DEVELOP_DIRECTORY, + pub B_SYSTEM_PACKAGES_DIRECTORY, + pub B_SYSTEM_HEADERS_DIRECTORY, + pub B_SYSTEM_ETC_DIRECTORY = 2008, + pub B_SYSTEM_SETTINGS_DIRECTORY = 2010, + pub B_SYSTEM_LOG_DIRECTORY = 2012, + pub B_SYSTEM_SPOOL_DIRECTORY, + pub B_SYSTEM_TEMP_DIRECTORY, + pub B_SYSTEM_VAR_DIRECTORY, + pub B_SYSTEM_CACHE_DIRECTORY = 2020, + pub B_SYSTEM_NONPACKAGED_DIRECTORY = 2023, + pub B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_BIN_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_DATA_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_LIB_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY, + pub B_USER_DIRECTORY = 3000, + pub B_USER_CONFIG_DIRECTORY, + pub B_USER_ADDONS_DIRECTORY, + pub B_USER_BOOT_DIRECTORY, + pub B_USER_FONTS_DIRECTORY, + pub B_USER_LIB_DIRECTORY, + pub B_USER_SETTINGS_DIRECTORY, + pub B_USER_DESKBAR_DIRECTORY, + pub B_USER_PRINTERS_DIRECTORY, + pub B_USER_TRANSLATORS_DIRECTORY, + pub B_USER_MEDIA_NODES_DIRECTORY, + pub B_USER_SOUNDS_DIRECTORY, + pub B_USER_DATA_DIRECTORY, + pub B_USER_CACHE_DIRECTORY, + pub B_USER_PACKAGES_DIRECTORY, + pub B_USER_HEADERS_DIRECTORY, + pub B_USER_NONPACKAGED_DIRECTORY, + pub B_USER_NONPACKAGED_ADDONS_DIRECTORY, + pub B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY, + pub B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY, + pub B_USER_NONPACKAGED_BIN_DIRECTORY, + pub B_USER_NONPACKAGED_DATA_DIRECTORY, + pub B_USER_NONPACKAGED_FONTS_DIRECTORY, + pub B_USER_NONPACKAGED_SOUNDS_DIRECTORY, + pub B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY, + pub B_USER_NONPACKAGED_LIB_DIRECTORY, + pub B_USER_NONPACKAGED_HEADERS_DIRECTORY, + pub B_USER_NONPACKAGED_DEVELOP_DIRECTORY, + pub B_USER_DEVELOP_DIRECTORY, + pub B_USER_DOCUMENTATION_DIRECTORY, + pub B_USER_SERVERS_DIRECTORY, + pub B_USER_APPS_DIRECTORY, + pub B_USER_BIN_DIRECTORY, + pub B_USER_PREFERENCES_DIRECTORY, + pub B_USER_ETC_DIRECTORY, + pub B_USER_LOG_DIRECTORY, + pub B_USER_SPOOL_DIRECTORY, + pub B_USER_VAR_DIRECTORY, + pub B_APPS_DIRECTORY = 4000, + pub B_PREFERENCES_DIRECTORY, + pub B_UTILITIES_DIRECTORY, + pub B_PACKAGE_LINKS_DIRECTORY, } // kernel/OS.h pub enum topology_level_type { - B_TOPOLOGY_UNKNOWN, - B_TOPOLOGY_ROOT, - B_TOPOLOGY_SMT, - B_TOPOLOGY_CORE, - B_TOPOLOGY_PACKAGE, + pub B_TOPOLOGY_UNKNOWN, + pub B_TOPOLOGY_ROOT, + pub B_TOPOLOGY_SMT, + pub B_TOPOLOGY_CORE, + pub B_TOPOLOGY_PACKAGE, } pub enum cpu_platform { - B_CPU_UNKNOWN, - B_CPU_x86, - B_CPU_x86_64, - B_CPU_PPC, - B_CPU_PPC_64, - B_CPU_M68K, - B_CPU_ARM, - B_CPU_ARM_64, - B_CPU_ALPHA, - B_CPU_MIPS, - B_CPU_SH, - B_CPU_SPARC, - B_CPU_RISC_V, + pub B_CPU_UNKNOWN, + pub B_CPU_x86, + pub B_CPU_x86_64, + pub B_CPU_PPC, + pub B_CPU_PPC_64, + pub B_CPU_M68K, + pub B_CPU_ARM, + pub B_CPU_ARM_64, + pub B_CPU_ALPHA, + pub B_CPU_MIPS, + pub B_CPU_SH, + pub B_CPU_SPARC, + pub B_CPU_RISC_V, } pub enum cpu_vendor { - B_CPU_VENDOR_UNKNOWN, - B_CPU_VENDOR_AMD, - B_CPU_VENDOR_CYRIX, - B_CPU_VENDOR_IDT, - B_CPU_VENDOR_INTEL, - B_CPU_VENDOR_NATIONAL_SEMICONDUCTOR, - B_CPU_VENDOR_RISE, - B_CPU_VENDOR_TRANSMETA, - B_CPU_VENDOR_VIA, - B_CPU_VENDOR_IBM, - B_CPU_VENDOR_MOTOROLA, - B_CPU_VENDOR_NEC, - B_CPU_VENDOR_HYGON, - B_CPU_VENDOR_SUN, - B_CPU_VENDOR_FUJITSU, + pub B_CPU_VENDOR_UNKNOWN, + pub B_CPU_VENDOR_AMD, + pub B_CPU_VENDOR_CYRIX, + pub B_CPU_VENDOR_IDT, + pub B_CPU_VENDOR_INTEL, + pub B_CPU_VENDOR_NATIONAL_SEMICONDUCTOR, + pub B_CPU_VENDOR_RISE, + pub B_CPU_VENDOR_TRANSMETA, + pub B_CPU_VENDOR_VIA, + pub B_CPU_VENDOR_IBM, + pub B_CPU_VENDOR_MOTOROLA, + pub B_CPU_VENDOR_NEC, + pub B_CPU_VENDOR_HYGON, + pub B_CPU_VENDOR_SUN, + pub B_CPU_VENDOR_FUJITSU, } } @@ -440,7 +440,7 @@ s! { } pub struct __c_anonymous_eax_3 { - __reserved: [u32; 2], + __reserved: Padding<[u32; 2]>, pub serial_number_high: u32, pub serial_number_low: u32, } @@ -451,6 +451,13 @@ s! { pub edx: u32, pub ecx: u32, } + + pub struct cpu_topology_node_info { + pub id: u32, + pub type_: topology_level_type, + pub level: u32, + pub data: __c_anonymous_cpu_topology_info_data, + } } s_no_extra_traits! { @@ -468,13 +475,6 @@ s_no_extra_traits! { pub package: cpu_topology_package_info, pub core: cpu_topology_core_info, } - - pub struct cpu_topology_node_info { - pub id: u32, - pub type_: topology_level_type, - pub level: u32, - pub data: __c_anonymous_cpu_topology_info_data, - } } cfg_if! { @@ -492,6 +492,11 @@ cfg_if! { } } impl Eq for cpuid_info {} + impl hash::Hash for cpuid_info { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); + } + } impl PartialEq for __c_anonymous_cpu_topology_info_data { fn eq(&self, other: &__c_anonymous_cpu_topology_info_data) -> bool { @@ -503,14 +508,11 @@ cfg_if! { } } impl Eq for __c_anonymous_cpu_topology_info_data {} - - impl PartialEq for cpu_topology_node_info { - fn eq(&self, other: &cpu_topology_node_info) -> bool { - self.id == other.id && self.type_ == other.type_ && self.level == other.level + impl hash::Hash for __c_anonymous_cpu_topology_info_data { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); } } - - impl Eq for cpu_topology_node_info {} } } diff --git a/src/unix/haiku/x86_64.rs b/src/unix/haiku/x86_64.rs index 16e2612ed760d..538ae30d438bf 100644 --- a/src/unix/haiku/x86_64.rs +++ b/src/unix/haiku/x86_64.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -s_no_extra_traits! { +s! { pub struct fpu_state { pub control: c_ushort, pub status: c_ushort, @@ -56,153 +56,3 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, } } - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for fpu_state { - fn eq(&self, other: &fpu_state) -> bool { - self.control == other.control - && self.status == other.status - && self.tag == other.tag - && self.opcode == other.opcode - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mscsr_mask == other.mscsr_mask - && self - ._fpreg - .iter() - .zip(other._fpreg.iter()) - .all(|(a, b)| a == b) - && self._xmm.iter().zip(other._xmm.iter()).all(|(a, b)| a == b) - && self - ._reserved_416_511 - .iter() - .zip(other._reserved_416_511.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for fpu_state {} - impl hash::Hash for fpu_state { - fn hash(&self, state: &mut H) { - self.control.hash(state); - self.status.hash(state); - self.tag.hash(state); - self.opcode.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mscsr_mask.hash(state); - self._fpreg.hash(state); - self._xmm.hash(state); - self._reserved_416_511.hash(state); - } - } - - impl PartialEq for xstate_hdr { - fn eq(&self, other: &xstate_hdr) -> bool { - self.bv == other.bv - && self.xcomp_bv == other.xcomp_bv - && self - ._reserved - .iter() - .zip(other._reserved.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for xstate_hdr {} - impl hash::Hash for xstate_hdr { - fn hash(&self, state: &mut H) { - self.bv.hash(state); - self.xcomp_bv.hash(state); - self._reserved.hash(state); - } - } - - impl PartialEq for savefpu { - fn eq(&self, other: &savefpu) -> bool { - self.fp_fxsave == other.fp_fxsave - && self.fp_xstate == other.fp_xstate - && self - ._fp_ymm - .iter() - .zip(other._fp_ymm.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for savefpu {} - impl hash::Hash for savefpu { - fn hash(&self, state: &mut H) { - self.fp_fxsave.hash(state); - self.fp_xstate.hash(state); - self._fp_ymm.hash(state); - } - } - - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.rax == other.rax - && self.rbx == other.rbx - && self.rbx == other.rbx - && self.rcx == other.rcx - && self.rdx == other.rdx - && self.rdi == other.rdi - && self.rsi == other.rsi - && self.r8 == other.r8 - && self.r9 == other.r9 - && self.r10 == other.r10 - && self.r11 == other.r11 - && self.r12 == other.r12 - && self.r13 == other.r13 - && self.r14 == other.r14 - && self.r15 == other.r15 - && self.rsp == other.rsp - && self.rip == other.rip - && self.rflags == other.rflags - && self.fpu == other.fpu - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.rax.hash(state); - self.rbx.hash(state); - self.rcx.hash(state); - self.rdx.hash(state); - self.rdi.hash(state); - self.rsi.hash(state); - self.rbp.hash(state); - self.r8.hash(state); - self.r9.hash(state); - self.r10.hash(state); - self.r11.hash(state); - self.r12.hash(state); - self.r13.hash(state); - self.r14.hash(state); - self.r15.hash(state); - self.rsp.hash(state); - self.rip.hash(state); - self.rflags.hash(state); - self.fpu.hash(state); - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_link == other.uc_link - && self.uc_sigmask == other.uc_sigmask - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_link.hash(state); - self.uc_sigmask.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - } - } - } -} diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 24e9fe56f392d..9b7811b460e1b 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -225,22 +225,9 @@ pub type nl_item = c_int; pub type iconv_t = *mut c_void; -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } -} - -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct + pub enum timezone {} } // structs @@ -428,7 +415,7 @@ s! { pub sigev_value: crate::sigval, pub sigev_signo: c_int, pub sigev_notify: c_int, - __unused1: *mut c_void, //actually a function pointer + __unused1: Padding<*mut c_void>, //actually a function pointer pub sigev_notify_attributes: *mut pthread_attr_t, } @@ -508,7 +495,7 @@ s! { pub stx_uid: u32, pub stx_gid: u32, pub stx_mode: u16, - __statx_pad1: [u16; 1], + __statx_pad1: Padding<[u16; 1]>, pub stx_ino: u64, pub stx_size: u64, pub stx_blocks: u64, @@ -521,7 +508,7 @@ s! { pub stx_rdev_minor: u32, pub stx_dev_major: u32, pub stx_dev_minor: u32, - __statx_pad2: [u64; 14], + __statx_pad2: Padding<[u64; 14]>, } pub struct statx_timestamp { @@ -608,7 +595,7 @@ s! { __return_value: ssize_t, pub aio_offset: off_t, #[cfg(all(not(target_arch = "x86_64"), target_pointer_width = "32"))] - __unused1: [c_char; 4], + __unused1: Padding<[c_char; 4]>, __glibc_reserved: [c_char; 32], } @@ -934,11 +921,11 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct glob64_t { @@ -947,11 +934,11 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct regex_t { @@ -1008,7 +995,7 @@ s! { __allocated: c_int, __used: c_int, __actions: *mut c_int, - __pad: [c_int; 16], + __pad: Padding<[c_int; 16]>, } pub struct posix_spawnattr_t { @@ -1018,7 +1005,7 @@ s! { __ss: crate::sigset_t, __sp: crate::sched_param, __policy: c_int, - __pad: [c_int; 16], + __pad: Padding<[c_int; 16]>, } pub struct regmatch_t { @@ -1032,9 +1019,7 @@ s! { pub flag: *mut c_int, pub val: c_int, } -} -s_no_extra_traits! { pub struct utmpx { pub ut_type: c_short, pub ut_pid: crate::pid_t, @@ -1060,48 +1045,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_user == other.ut_user - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.__glibc_reserved == other.__glibc_reserved - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.__glibc_reserved.hash(state); - } - } - } -} - impl siginfo_t { pub unsafe fn si_addr(&self) -> *mut c_void { self.si_addr @@ -1185,9 +1128,6 @@ pub const SHM_REMAP: c_int = 0o40000; pub const SHM_LOCK: c_int = 11; pub const SHM_UNLOCK: c_int = 12; // unistd.h -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const __FD_SETSIZE: usize = 256; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index b78c8a83623ea..1d2d34dfedc40 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -28,20 +28,13 @@ s! { pub arm_cpsr: c_ulong, pub fault_address: c_ulong, } -} -s_no_extra_traits! { pub struct __c_anonymous_uc_sigmask_with_padding { pub uc_sigmask: crate::sigset_t, /* Android has a wrong (smaller) sigset_t on x86. */ __padding_rt_sigset: u32, } - pub union __c_anonymous_uc_sigmask { - uc_sigmask: __c_anonymous_uc_sigmask_with_padding, - uc_sigmask64: crate::sigset64_t, - } - pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -50,28 +43,21 @@ s_no_extra_traits! { pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask, /* The kernel adds extra padding after uc_sigmask to match * glibc sigset_t on ARM. */ - __padding: [c_char; 120], + __padding: Padding<[c_char; 120]>, __align: [c_longlong; 0], uc_regspace: [c_ulong; 128], } } +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: crate::sigset64_t, + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask_with_padding { - fn eq(&self, other: &__c_anonymous_uc_sigmask_with_padding) -> bool { - self.uc_sigmask == other.uc_sigmask - // Ignore padding - } - } - impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl hash::Hash for __c_anonymous_uc_sigmask_with_padding { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state) - // Ignore padding - } - } - impl PartialEq for __c_anonymous_uc_sigmask { fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { unsafe { self.uc_sigmask == other.uc_sigmask } @@ -83,30 +69,6 @@ cfg_if! { unsafe { self.uc_sigmask.hash(state) } } } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask__c_anonymous_union == other.uc_sigmask__c_anonymous_union - && &self.uc_regspace[..] == &other.uc_regspace[..] - // Ignore padding field - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask__c_anonymous_union.hash(state); - self.uc_regspace[..].hash(state); - // Ignore padding field - } - } } } diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index d02dbf92d7924..62c3c4c32a4b6 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -28,14 +28,14 @@ s! { pub struct stat { pub st_dev: c_ulonglong, - __pad0: [c_uchar; 4], + __pad0: Padding<[c_uchar; 4]>, __st_ino: crate::ino_t, pub st_mode: c_uint, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: c_ulonglong, - __pad3: [c_uchar; 4], + __pad3: Padding<[c_uchar; 4]>, pub st_size: c_longlong, pub st_blksize: crate::blksize_t, pub st_blocks: c_ulonglong, @@ -50,14 +50,14 @@ s! { pub struct stat64 { pub st_dev: c_ulonglong, - __pad0: [c_uchar; 4], + __pad0: Padding<[c_uchar; 4]>, __st_ino: crate::ino_t, pub st_mode: c_uint, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: c_ulonglong, - __pad3: [c_uchar; 4], + __pad3: Padding<[c_uchar; 4]>, pub st_size: c_longlong, pub st_blksize: crate::blksize_t, pub st_blocks: c_ulonglong, diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index ca46c3c462246..22a8766e88bb3 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -27,20 +27,13 @@ s! { pub oldmask: c_ulong, pub cr2: c_ulong, } -} -s_no_extra_traits! { pub struct __c_anonymous_uc_sigmask_with_padding { pub uc_sigmask: crate::sigset_t, /* Android has a wrong (smaller) sigset_t on x86. */ __padding_rt_sigset: u32, } - pub union __c_anonymous_uc_sigmask { - uc_sigmask: __c_anonymous_uc_sigmask_with_padding, - uc_sigmask64: crate::sigset64_t, - } - pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -50,6 +43,13 @@ s_no_extra_traits! { __padding_rt_sigset: u32, __fpregs_mem: _libc_fpstate, } +} + +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: crate::sigset64_t, + } #[repr(align(8))] pub struct max_align_t { @@ -59,20 +59,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask_with_padding { - fn eq(&self, other: &__c_anonymous_uc_sigmask_with_padding) -> bool { - self.uc_sigmask == other.uc_sigmask - // Ignore padding - } - } - impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl hash::Hash for __c_anonymous_uc_sigmask_with_padding { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state) - // Ignore padding - } - } - impl PartialEq for __c_anonymous_uc_sigmask { fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { unsafe { self.uc_sigmask == other.uc_sigmask } @@ -84,28 +70,6 @@ cfg_if! { unsafe { self.uc_sigmask.hash(state) } } } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask__c_anonymous_union == other.uc_sigmask__c_anonymous_union - // Ignore padding field - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask__c_anonymous_union.hash(state); - // Ignore padding field - } - } } } diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 3c6131089ee89..7c7a08fdf334f 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -14,10 +14,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: c_ulong, + __pad1: Padding, pub st_size: off64_t, pub st_blksize: c_int, - __pad2: c_int, + __pad2: Padding, pub st_blocks: c_long, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -25,8 +25,8 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused4: c_uint, - __unused5: c_uint, + __unused4: Padding, + __unused5: Padding, } pub struct stat64 { @@ -37,10 +37,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: c_ulong, + __pad1: Padding, pub st_size: off64_t, pub st_blksize: c_int, - __pad2: c_int, + __pad2: Padding, pub st_blocks: c_long, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -48,8 +48,8 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused4: c_uint, - __unused5: c_uint, + __unused4: Padding, + __unused5: Padding, } pub struct user_regs_struct { @@ -74,7 +74,7 @@ s! { pub sp: c_ulonglong, pub pc: c_ulonglong, pub pstate: c_ulonglong, - __reserved: [u64; 512], + __reserved: Padding<[u64; 512]>, } pub struct user_fpsimd_struct { diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index 46ceed4c6dcba..05ec19d85ad5e 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -33,7 +33,7 @@ s! { pub guard_size: size_t, pub sched_policy: i32, pub sched_priority: i32, - __reserved: [c_char; 16], + __reserved: Padding<[c_char; 16]>, } pub struct passwd { @@ -115,9 +115,7 @@ s! { pub struct pthread_spinlock_t { __private: i64, } -} -s_no_extra_traits! { pub struct pthread_mutex_t { value: c_int, __reserved: [c_char; 36], @@ -142,78 +140,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.value == other.value - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_mutex_t {} - - impl hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.value.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.value == other.value - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_cond_t {} - - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.value.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.numLocks == other.numLocks - && self.writerThreadId == other.writerThreadId - && self.pendingReaders == other.pendingReaders - && self.pendingWriters == other.pendingWriters - && self.attr == other.attr - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_rwlock_t {} - - impl hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.numLocks.hash(state); - self.writerThreadId.hash(state); - self.pendingReaders.hash(state); - self.pendingWriters.hash(state); - self.attr.hash(state); - self.__reserved.hash(state); - } - } - } -} - // These constants must be of the same type of sigaction.sa_flags pub const SA_NOCLDSTOP: c_int = 0x00000001; pub const SA_NOCLDWAIT: c_int = 0x00000002; diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index ca8c727164ad7..dded1292b393f 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -15,10 +15,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: c_ulong, + __pad1: Padding, pub st_size: off64_t, pub st_blksize: c_int, - __pad2: c_int, + __pad2: Padding, pub st_blocks: c_long, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -26,8 +26,8 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused4: c_uint, - __unused5: c_uint, + __unused4: Padding, + __unused5: Padding, } pub struct stat64 { @@ -38,10 +38,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: c_ulong, + __pad1: Padding, pub st_size: off64_t, pub st_blksize: c_int, - __pad2: c_int, + __pad2: Padding, pub st_blocks: c_long, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -49,8 +49,8 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused4: c_uint, - __unused5: c_uint, + __unused4: Padding, + __unused5: Padding, } } diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index 0fddeb7bc267f..801235d13ec1b 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -24,7 +24,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: c_long, pub st_ctime_nsec: c_long, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct stat64 { @@ -44,7 +44,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: c_long, pub st_ctime_nsec: c_long, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct _libc_xmmreg { @@ -91,12 +91,12 @@ s! { pub start_code: c_ulong, pub start_stack: c_ulong, pub signal: c_long, - __reserved: c_int, + __reserved: Padding, #[cfg(target_pointer_width = "32")] - __pad1: u32, + __pad1: Padding, pub u_ar0: *mut user_regs_struct, #[cfg(target_pointer_width = "32")] - __pad2: u32, + __pad2: Padding, pub u_fpstate: *mut user_fpregs_struct, pub magic: c_ulong, pub u_comm: [c_char; 32], @@ -104,41 +104,11 @@ s! { pub error_code: c_ulong, pub fault_address: c_ulong, } -} - -s_no_extra_traits! { - pub union __c_anonymous_uc_sigmask { - uc_sigmask: crate::sigset_t, - uc_sigmask64: crate::sigset64_t, - } - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask { - fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { - unsafe { self.uc_sigmask == other.uc_sigmask } - } - } - impl Eq for __c_anonymous_uc_sigmask {} - impl hash::Hash for __c_anonymous_uc_sigmask { - fn hash(&self, state: &mut H) { - unsafe { self.uc_sigmask.hash(state) } - } - } - } -} - -s_no_extra_traits! { pub struct _libc_fpxreg { pub significand: [u16; 4], pub exponent: u16, - __padding: [u16; 3], + __padding: Padding<[u16; 3]>, } pub struct _libc_fpstate { @@ -185,127 +155,29 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for _libc_fpxreg { - fn eq(&self, other: &Self) -> bool { - self.significand == other.significand && self.exponent == other.exponent - // Ignore padding field - } - } - impl Eq for _libc_fpxreg {} - impl hash::Hash for _libc_fpxreg { - fn hash(&self, state: &mut H) { - self.significand.hash(state); - self.exponent.hash(state); - // Ignore padding field - } - } - - impl PartialEq for _libc_fpstate { - fn eq(&self, other: &Self) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self._st == other._st - && self._xmm == other._xmm - // Ignore padding field - } - } - impl Eq for _libc_fpstate {} - impl hash::Hash for _libc_fpstate { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self._st.hash(state); - self._xmm.hash(state); - // Ignore padding field - } - } - - impl PartialEq for mcontext_t { - fn eq(&self, other: &Self) -> bool { - self.gregs == other.gregs && self.fpregs == other.fpregs - // Ignore padding field - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.gregs.hash(state); - self.fpregs.hash(state); - // Ignore padding field - } - } +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: crate::sigset_t, + uc_sigmask64: crate::sigset64_t, + } - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask64 == other.uc_sigmask64 - // Ignore padding field - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask64.hash(state); - // Ignore padding field - } - } + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} - impl PartialEq for user_fpregs_struct { - fn eq(&self, other: &user_fpregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self.st_space == other.st_space - && self - .xmm_space - .iter() - .zip(other.xmm_space.iter()) - .all(|(a, b)| a == b) - // Ignore padding field +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } } } - - impl Eq for user_fpregs_struct {} - - impl hash::Hash for user_fpregs_struct { + impl Eq for __c_anonymous_uc_sigmask {} + impl hash::Hash for __c_anonymous_uc_sigmask { fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field + unsafe { self.uc_sigmask.hash(state) } } } } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index fbd8ac2f87cfc..2ea3345238610 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1,7 +1,10 @@ //! Android-specific definitions for linux-like values use crate::prelude::*; -use crate::{cmsghdr, msghdr}; +use crate::{ + cmsghdr, + msghdr, +}; cfg_if! { if #[cfg(doc)] { @@ -134,7 +137,7 @@ s! { pub struct sem_t { count: c_uint, #[cfg(target_pointer_width = "64")] - __reserved: [c_int; 3], + __reserved: Padding<[c_int; 3]>, } pub struct exit_status { @@ -176,11 +179,11 @@ s! { pub ssi_stime: c_ulonglong, pub ssi_addr: c_ulonglong, pub ssi_addr_lsb: u16, - _pad2: u16, + _pad2: Padding, pub ssi_syscall: i32, pub ssi_call_addr: u64, pub ssi_arch: u32, - _pad: [u8; 28], + _pad: Padding<[u8; 28]>, } pub struct itimerspec { @@ -497,12 +500,10 @@ s! { pub if_index: c_uint, pub if_name: *mut c_char, } -} -s_no_extra_traits! { pub struct sockaddr_nl { pub nl_family: crate::sa_family_t, - nl_pad: c_ushort, + nl_pad: Padding, pub nl_pid: u32, pub nl_groups: u32, } @@ -575,6 +576,14 @@ s_no_extra_traits! { pub absflat: [crate::__s32; ABS_CNT], } + pub struct prop_info { + __name: [c_char; 32], + __serial: c_uint, + __value: [c_char; 92], + } +} + +s_no_extra_traits! { /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this /// type are unsound and will be removed in the future. #[deprecated( @@ -587,12 +596,6 @@ s_no_extra_traits! { pub iv: [c_uchar; 0], } - pub struct prop_info { - __name: [c_char; 32], - __serial: c_uint, - __value: [c_char; 92], - } - pub union __c_anonymous_ifr_ifru { pub ifru_addr: crate::sockaddr, pub ifru_dstaddr: crate::sockaddr, @@ -627,244 +630,33 @@ s_no_extra_traits! { pub ifc_len: c_int, /* Size of buffer. */ pub ifc_ifcu: __c_anonymous_ifc_ifcu, } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_nl { - fn eq(&self, other: &sockaddr_nl) -> bool { - self.nl_family == other.nl_family - && self.nl_pid == other.nl_pid - && self.nl_groups == other.nl_groups - } - } - impl Eq for sockaddr_nl {} - impl hash::Hash for sockaddr_nl { - fn hash(&self, state: &mut H) { - self.nl_family.hash(state); - self.nl_pid.hash(state); - self.nl_groups.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent64 {} - - impl hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_errno == other.si_errno - && self.si_code == other.si_code - // Ignore _pad - // Ignore _align - } - } - - impl Eq for siginfo_t {} - - impl hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_errno.hash(state); - self.si_code.hash(state); - // Ignore _pad - // Ignore _align - } - } - - impl PartialEq for lastlog { - fn eq(&self, other: &lastlog) -> bool { - self.ll_time == other.ll_time - && self - .ll_line - .iter() - .zip(other.ll_line.iter()) - .all(|(a, b)| a == b) - && self - .ll_host - .iter() - .zip(other.ll_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for lastlog {} - - impl hash::Hash for lastlog { - fn hash(&self, state: &mut H) { - self.ll_time.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - } - } - - impl PartialEq for utmp { - fn eq(&self, other: &utmp) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self - .ut_line - .iter() - .zip(other.ut_line.iter()) - .all(|(a, b)| a == b) - && self.ut_id == other.ut_id - && self - .ut_user - .iter() - .zip(other.ut_user.iter()) - .all(|(a, b)| a == b) - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.unused == other.unused - } - } - - impl Eq for utmp {} - impl hash::Hash for utmp { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.unused.hash(state); - } - } - - impl PartialEq for sockaddr_alg { - fn eq(&self, other: &sockaddr_alg) -> bool { - self.salg_family == other.salg_family - && self - .salg_type - .iter() - .zip(other.salg_type.iter()) - .all(|(a, b)| a == b) - && self.salg_feat == other.salg_feat - && self.salg_mask == other.salg_mask - && self - .salg_name - .iter() - .zip(other.salg_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_alg {} - - impl hash::Hash for sockaddr_alg { - fn hash(&self, state: &mut H) { - self.salg_family.hash(state); - self.salg_type.hash(state); - self.salg_feat.hash(state); - self.salg_mask.hash(state); - self.salg_name.hash(state); - } - } - - impl PartialEq for uinput_setup { - fn eq(&self, other: &uinput_setup) -> bool { - self.id == other.id - && self.name[..] == other.name[..] - && self.ff_effects_max == other.ff_effects_max - } - } - impl Eq for uinput_setup {} - - impl hash::Hash for uinput_setup { - fn hash(&self, state: &mut H) { - self.id.hash(state); - self.name.hash(state); - self.ff_effects_max.hash(state); - } - } + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, + } - impl PartialEq for uinput_user_dev { - fn eq(&self, other: &uinput_user_dev) -> bool { - self.name[..] == other.name[..] - && self.id == other.id - && self.ff_effects_max == other.ff_effects_max - && self.absmax[..] == other.absmax[..] - && self.absmin[..] == other.absmin[..] - && self.absfuzz[..] == other.absfuzz[..] - && self.absflat[..] == other.absflat[..] - } - } - impl Eq for uinput_user_dev {} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } - impl hash::Hash for uinput_user_dev { - fn hash(&self, state: &mut H) { - self.name.hash(state); - self.id.hash(state); - self.ff_effects_max.hash(state); - self.absmax.hash(state); - self.absmin.hash(state); - self.absfuzz.hash(state); - self.absflat.hash(state); - } - } + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } +} +cfg_if! { + if #[cfg(feature = "extra_traits")] { #[allow(deprecated)] impl af_alg_iv { fn as_slice(&self) -> &[u8] { @@ -888,15 +680,6 @@ cfg_if! { self.as_slice().hash(state); } } - - impl PartialEq for prop_info { - fn eq(&self, other: &prop_info) -> bool { - self.__name == other.__name - && self.__serial == other.__serial - && self.__value == other.__value - } - } - impl Eq for prop_info {} } } @@ -1644,6 +1427,7 @@ pub const VSTART: usize = 8; pub const VSTOP: usize = 9; pub const VDISCARD: usize = 13; pub const VTIME: usize = 5; +pub const IUCLC: crate::tcflag_t = 0x00000200; pub const IXON: crate::tcflag_t = 0x00000400; pub const IXOFF: crate::tcflag_t = 0x00001000; pub const ONLCR: crate::tcflag_t = 0x4; @@ -3508,6 +3292,8 @@ pub const AT_RANDOM: c_ulong = 25; pub const AT_HWCAP2: c_ulong = 26; pub const AT_RSEQ_FEATURE_SIZE: c_ulong = 27; pub const AT_RSEQ_ALIGN: c_ulong = 28; +pub const AT_HWCAP3: c_ulong = 29; +pub const AT_HWCAP4: c_ulong = 30; pub const AT_EXECFN: c_ulong = 31; pub const AT_MINSIGSTKSZ: c_ulong = 51; @@ -3762,11 +3548,6 @@ extern "C" { timeout: c_int, ) -> c_int; pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; - pub fn pthread_getschedparam( - native: crate::pthread_t, - policy: *mut c_int, - param: *mut crate::sched_param, - ) -> c_int; pub fn unshare(flags: c_int) -> c_int; pub fn umount(target: *const c_char) -> c_int; pub fn sched_get_priority_max(policy: c_int) -> c_int; @@ -3780,7 +3561,7 @@ extern "C" { len: size_t, flags: c_uint, ) -> ssize_t; - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; @@ -3807,32 +3588,7 @@ extern "C" { timeout: *const crate::timespec, sigmask: *const sigset_t, ) -> c_int; - pub fn pthread_mutex_timedlock( - lock: *mut pthread_mutex_t, - abstime: *const crate::timespec, - ) -> c_int; - pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; - pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; - pub fn pthread_barrierattr_getpshared( - attr: *const crate::pthread_barrierattr_t, - shared: *mut c_int, - ) -> c_int; - pub fn pthread_barrierattr_setpshared( - attr: *mut crate::pthread_barrierattr_t, - shared: c_int, - ) -> c_int; - pub fn pthread_barrier_init( - barrier: *mut pthread_barrier_t, - attr: *const crate::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_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int; - pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int; - pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int; - pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int; - pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn clone( cb: extern "C" fn(*mut c_void) -> c_int, child_stack: *mut c_void, @@ -3847,29 +3603,11 @@ extern "C" { rqtp: *const crate::timespec, rmtp: *mut crate::timespec, ) -> c_int; - pub fn pthread_attr_getguardsize( - attr: *const crate::pthread_attr_t, - guardsize: *mut size_t, - ) -> c_int; - pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; - pub fn pthread_attr_getinheritsched( - attr: *const crate::pthread_attr_t, - flag: *mut c_int, - ) -> c_int; - pub fn pthread_attr_setinheritsched(attr: *mut crate::pthread_attr_t, flag: c_int) -> c_int; + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; pub fn sched_get_priority_min(policy: c_int) -> c_int; - pub fn pthread_condattr_getpshared( - attr: *const pthread_condattr_t, - pshared: *mut c_int, - ) -> c_int; pub fn sysinfo(info: *mut crate::sysinfo) -> c_int; pub fn umount2(target: *const c_char, flags: c_int) -> c_int; - pub fn pthread_setschedparam( - native: crate::pthread_t, - policy: c_int, - param: *const crate::sched_param, - ) -> c_int; pub fn swapon(path: *const c_char, swapflags: c_int) -> c_int; pub fn sched_setscheduler( pid: crate::pid_t, @@ -3897,10 +3635,8 @@ extern "C" { buflen: size_t, result: *mut *mut crate::group, ) -> c_int; - pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; pub fn getgrnam(name: *const c_char) -> *mut crate::group; - pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; pub fn sem_unlink(name: *const c_char) -> c_int; pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; pub fn getpwnam_r( @@ -3923,11 +3659,6 @@ extern "C" { timeout: *const crate::timespec, ) -> c_int; pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; - pub fn pthread_atfork( - prepare: Option, - parent: Option, - child: Option, - ) -> c_int; pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; pub fn getgrouplist( user: *const c_char, @@ -3936,18 +3667,8 @@ extern "C" { ngroups: *mut c_int, ) -> c_int; pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; - pub fn pthread_mutexattr_getpshared( - attr: *const pthread_mutexattr_t, - pshared: *mut c_int, - ) -> c_int; pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; - pub fn pthread_create( - native: *mut crate::pthread_t, - attr: *const crate::pthread_attr_t, - f: extern "C" fn(*mut c_void) -> *mut c_void, - value: *mut c_void, - ) -> c_int; pub fn __errno() -> *mut c_int; pub fn inotify_rm_watch(fd: c_int, wd: u32) -> c_int; pub fn inotify_init() -> c_int; @@ -3983,8 +3704,6 @@ extern "C" { pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; - pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; - pub fn __system_property_set(__name: *const c_char, __value: *const c_char) -> c_int; pub fn __system_property_get(__name: *const c_char, __value: *mut c_char) -> c_int; pub fn __system_property_find(__name: *const c_char) -> *const prop_info; @@ -4009,8 +3728,6 @@ extern "C" { pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; - pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; - pub fn dirname(path: *const c_char) -> *mut c_char; pub fn basename(path: *const c_char) -> *mut c_char; pub fn getopt_long( @@ -4098,38 +3815,6 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } -} - -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} - -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, -} - impl siginfo_t { unsafe fn sifields(&self) -> &sifields { &(*(self as *const siginfo_t as *const siginfo_f)).sifields diff --git a/src/unix/linux_like/emscripten/lfs64.rs b/src/unix/linux_like/emscripten/lfs64.rs index 06be875446bb6..501540943889f 100644 --- a/src/unix/linux_like/emscripten/lfs64.rs +++ b/src/unix/linux_like/emscripten/lfs64.rs @@ -109,7 +109,10 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. -pub use crate::{open as open64, openat as openat64}; +pub use crate::{ + open as open64, + openat as openat64, +}; #[inline] pub unsafe extern "C" fn posix_fadvise64( diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 417e3e593bc5e..8996527e2e8e1 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -41,13 +41,8 @@ pub type statfs64 = crate::statfs; pub type statvfs64 = crate::statvfs; pub type dirent64 = crate::dirent; -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } +extern_ty! { + pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct } s! { @@ -57,11 +52,11 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct passwd { @@ -120,11 +115,11 @@ s! { pub ssi_stime: u64, pub ssi_addr: u64, pub ssi_addr_lsb: u16, - _pad2: u16, + _pad2: Padding, pub ssi_syscall: i32, pub ssi_call_addr: u64, pub ssi_arch: u32, - _pad: [u8; 28], + _pad: Padding<[u8; 28]>, } pub struct fsid_t { @@ -175,8 +170,8 @@ s! { pub cgid: crate::gid_t, pub mode: mode_t, pub __seq: c_int, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } pub struct termios { @@ -265,8 +260,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct msqid_ds { @@ -279,8 +274,8 @@ s! { pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct statfs { @@ -339,9 +334,7 @@ s! { pub struct pthread_condattr_t { size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], } -} -s_no_extra_traits! { pub struct dirent { pub d_ino: crate::ino_t, pub d_off: off_t, @@ -380,113 +373,15 @@ s_no_extra_traits! { pub struct pthread_cond_t { size: [u8; crate::__SIZEOF_PTHREAD_COND_T], } +} +s_no_extra_traits! { #[repr(align(8))] pub struct max_align_t { priv_: [f64; 3], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sysinfo { - fn eq(&self, other: &sysinfo) -> bool { - self.uptime == other.uptime - && self.loads == other.loads - && self.totalram == other.totalram - && self.freeram == other.freeram - && self.sharedram == other.sharedram - && self.bufferram == other.bufferram - && self.totalswap == other.totalswap - && self.freeswap == other.freeswap - && self.procs == other.procs - && self.pad == other.pad - && self.totalhigh == other.totalhigh - && self.freehigh == other.freehigh - && self.mem_unit == other.mem_unit - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sysinfo {} - impl hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { - self.uptime.hash(state); - self.loads.hash(state); - self.totalram.hash(state); - self.freeram.hash(state); - self.sharedram.hash(state); - self.bufferram.hash(state); - self.totalswap.hash(state); - self.freeswap.hash(state); - self.procs.hash(state); - self.pad.hash(state); - self.totalhigh.hash(state); - self.freehigh.hash(state); - self.mem_unit.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_flags == other.mq_flags - && self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_curmsgs == other.mq_curmsgs - } - } - impl Eq for mq_attr {} - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_flags.hash(state); - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_curmsgs.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - impl Eq for pthread_cond_t {} - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - } -} - pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MS_NOUSER: c_ulong = 0x80000000; pub const MS_RMT_MASK: c_ulong = 0x02800051; @@ -1541,12 +1436,6 @@ extern "C" { pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; - pub fn pthread_create( - native: *mut crate::pthread_t, - attr: *const crate::pthread_attr_t, - f: extern "C" fn(*mut c_void) -> *mut c_void, - value: *mut c_void, - ) -> c_int; pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 465ceddeab64e..5fe9da78bb315 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -272,6 +272,7 @@ pub const TIOCM_DSR: c_int = 0x100; pub const BOTHER: crate::speed_t = 0o010000; pub const IBSHIFT: crate::tcflag_t = 16; +pub const IUCLC: crate::tcflag_t = 0o0001000; // RLIMIT Constants diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index ba688948a906d..e8ce0cb4fd109 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -242,6 +242,7 @@ pub const TIOCM_DSR: c_int = 0x400; pub const BOTHER: crate::speed_t = 0o010000; pub const IBSHIFT: crate::tcflag_t = 16; +pub const IUCLC: crate::tcflag_t = 0o0001000; // RLIMIT Constants diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index 3249a9f1b6a46..33440bf6ff7a5 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -227,6 +227,7 @@ pub const TIOCM_DSR: c_int = 0x100; pub const BOTHER: crate::speed_t = 0o0037; pub const IBSHIFT: crate::tcflag_t = 16; +pub const IUCLC: crate::tcflag_t = 0o0010000; // RLIMIT Constants diff --git a/src/unix/linux_like/linux/arch/sparc/mod.rs b/src/unix/linux_like/linux/arch/sparc/mod.rs index 4c108ba7b71c1..1b6729a3e1d8e 100644 --- a/src/unix/linux_like/linux/arch/sparc/mod.rs +++ b/src/unix/linux_like/linux/arch/sparc/mod.rs @@ -213,6 +213,7 @@ pub const TIOCM_DSR: c_int = 0x100; pub const BOTHER: crate::speed_t = 0x1000; pub const IBSHIFT: crate::tcflag_t = 16; +pub const IUCLC: crate::tcflag_t = 0o0001000; // RLIMIT Constants diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 900851ab5f42c..dadaa7a8f6892 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; @@ -53,17 +56,17 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct stat64 { pub st_dev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - __pad1: c_uint, + __pad1: Padding, #[cfg(not(gnu_time_bits64))] __st_ino: c_ulong, #[cfg(gnu_time_bits64)] @@ -74,7 +77,7 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - __pad2: c_uint, + __pad2: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, @@ -130,18 +133,18 @@ s! { pub shm_segsz: size_t, pub shm_atime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __unused1: c_ulong, + __unused1: Padding, pub shm_dtime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __unused2: c_ulong, + __unused2: Padding, pub shm_ctime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __unused3: c_ulong, + __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct msqid_ds { @@ -229,13 +232,6 @@ s! { pub arm_cpsr: c_ulong, pub arm_orig_r0: c_ulong, } -} - -s_no_extra_traits! { - #[repr(align(8))] - pub struct max_align_t { - priv_: [i64; 2], - } #[repr(align(8))] pub struct ucontext_t { @@ -248,27 +244,10 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - } - } +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 2], } } diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 95881894a4b94..978b4398e9073 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; @@ -52,23 +55,23 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct stat64 { pub st_dev: crate::dev_t, - __pad1: c_uint, + __pad1: Padding, __st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad2: c_uint, + __pad2: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, @@ -116,16 +119,16 @@ s! { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, - __unused1: c_ulong, + __unused1: Padding, pub shm_dtime: crate::time_t, - __unused2: c_ulong, + __unused2: Padding, pub shm_ctime: crate::time_t, - __unused3: c_ulong, + __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct msqid_ds { diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index d614fddeca9d9..d2eb7ee3ec9b4 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; @@ -54,21 +57,21 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, __seq: c_ushort, - __pad1: c_ushort, + __pad1: Padding, __glibc_reserved1: c_ulong, __glibc_reserved2: c_ulong, } pub struct stat64 { pub st_dev: crate::dev_t, - __pad1: c_ushort, + __pad1: Padding, pub __st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad2: c_ushort, + __pad2: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, @@ -149,7 +152,7 @@ s! { pub si_signo: c_int, pub si_code: c_int, pub si_errno: c_int, - _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } @@ -861,3 +864,22 @@ pub const SYS_landlock_restrict_self: c_long = 446; pub const SYS_process_mrelease: c_long = 448; pub const SYS_futex_waitv: c_long = 449; pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_cachestat: c_long = 451; +pub const SYS_fchmodat2: c_long = 452; +pub const SYS_map_shadow_stack: c_long = 453; +pub const SYS_futex_wake: c_long = 454; +pub const SYS_futex_wait: c_long = 455; +pub const SYS_futex_requeue: c_long = 456; +pub const SYS_statmount: c_long = 457; +pub const SYS_listmount: c_long = 458; +pub const SYS_lsm_get_self_attr: c_long = 459; +pub const SYS_lsm_set_self_attr: c_long = 460; +pub const SYS_lsm_list_modules: c_long = 461; +pub const SYS_mseal: c_long = 462; +pub const SYS_setxattrat: c_long = 463; +pub const SYS_getxattrat: c_long = 464; +pub const SYS_listxattrat: c_long = 465; +pub const SYS_removexattrat: c_long = 466; +pub const SYS_open_tree_attr: c_long = 467; +pub const SYS_file_get_attr: c_long = 468; +pub const SYS_file_set_attr: c_long = 469; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 3d2775cd800ae..99af57a4460c0 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; @@ -11,7 +14,7 @@ s! { pub st_dev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - st_pad1: [c_long; 3], + st_pad1: Padding<[c_long; 3]>, pub st_ino: crate::ino_t, @@ -26,14 +29,14 @@ s! { pub st_rdev: crate::dev_t, #[cfg(not(gnu_file_offset_bits64))] - st_pad2: [c_long; 2], + st_pad2: Padding<[c_long; 2]>, #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] - st_pad2: [c_long; 3], + st_pad2: Padding<[c_long; 3]>, pub st_size: off_t, #[cfg(not(gnu_file_offset_bits64))] - st_pad3: c_long, + st_pad3: Padding, #[cfg(gnu_time_bits64)] pub st_blksize: crate::blksize_t, @@ -56,11 +59,11 @@ s! { #[cfg(not(gnu_time_bits64))] pub st_blksize: crate::blksize_t, #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] - st_pad4: c_long, + st_pad4: Padding, #[cfg(not(gnu_time_bits64))] pub st_blocks: crate::blkcnt_t, #[cfg(not(gnu_time_bits64))] - st_pad5: [c_long; 14], + st_pad5: Padding<[c_long; 14]>, } pub struct stat64 { @@ -70,7 +73,7 @@ s! { pub st_dev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - st_pad1: [c_long; 3], + st_pad1: Padding<[c_long; 3]>, pub st_ino: crate::ino64_t, pub st_mode: crate::mode_t, @@ -84,7 +87,7 @@ s! { pub st_rdev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - st_pad2: [c_long; 3], + st_pad2: Padding<[c_long; 3]>, pub st_size: off64_t, @@ -109,11 +112,11 @@ s! { #[cfg(not(gnu_time_bits64))] pub st_blksize: crate::blksize_t, #[cfg(not(gnu_time_bits64))] - st_pad3: c_long, + st_pad3: Padding, #[cfg(not(gnu_time_bits64))] pub st_blocks: crate::blkcnt64_t, #[cfg(not(gnu_time_bits64))] - st_pad5: [c_long; 14], + st_pad5: Padding<[c_long; 14]>, } pub struct statfs { @@ -194,9 +197,9 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_ushort, - __pad1: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -208,8 +211,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct msqid_ds { diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index fe843a7643207..1855693dc6c7a 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -81,7 +81,7 @@ cfg_if! { pub st_dev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - __pad1: c_uint, + __pad1: Padding, #[cfg(any(gnu_time_bits64, not(gnu_file_offset_bits64)))] pub st_ino: crate::ino_t, @@ -96,7 +96,7 @@ cfg_if! { pub st_rdev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - __pad2: c_uint, + __pad2: Padding, pub st_size: off_t, @@ -176,7 +176,7 @@ s! { pub struct semid_ds { pub sem_perm: ipc_perm, #[cfg(all(not(gnu_time_bits64), target_arch = "powerpc"))] - __reserved: crate::__syscall_ulong_t, + __reserved: Padding, pub sem_otime: crate::time_t, #[cfg(not(any( gnu_time_bits64, @@ -184,9 +184,9 @@ s! { target_arch = "mips32r6", target_arch = "powerpc" )))] - __reserved: crate::__syscall_ulong_t, + __reserved: Padding, #[cfg(all(not(gnu_time_bits64), target_arch = "powerpc"))] - __reserved2: crate::__syscall_ulong_t, + __reserved2: Padding, pub sem_ctime: crate::time_t, #[cfg(not(any( gnu_time_bits64, @@ -194,7 +194,7 @@ s! { target_arch = "mips32r6", target_arch = "powerpc" )))] - __reserved2: crate::__syscall_ulong_t, + __reserved2: Padding, pub sem_nsems: crate::__syscall_ulong_t, #[cfg(all( gnu_time_bits64, @@ -206,7 +206,7 @@ s! { target_arch = "x86" )) ))] - __reserved2: crate::__syscall_ulong_t, + __reserved2: Padding, __glibc_reserved3: crate::__syscall_ulong_t, __glibc_reserved4: crate::__syscall_ulong_t, } @@ -214,13 +214,13 @@ s! { #[cfg(gnu_time_bits64)] pub struct timex { pub modes: c_uint, - _pad1: c_int, + _pad1: Padding, pub offset: c_longlong, pub freq: c_longlong, pub maxerror: c_longlong, pub esterror: c_longlong, pub status: c_int, - _pad2: c_int, + _pad2: Padding, pub constant: c_longlong, pub precision: c_longlong, pub tolerance: c_longlong, @@ -229,7 +229,7 @@ s! { pub ppsfreq: c_longlong, pub jitter: c_longlong, pub shift: c_int, - _pad3: c_int, + _pad3: Padding, pub stabil: c_longlong, pub jitcnt: c_longlong, pub calcnt: c_longlong, diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 791f14956806d..c84ee0c95cad5 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; @@ -54,7 +57,7 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, __seq: u32, - __pad1: u32, + __pad1: Padding, __glibc_reserved1: u64, __glibc_reserved2: u64, } @@ -62,7 +65,7 @@ s! { pub struct stat { pub st_dev: crate::dev_t, #[cfg(not(gnu_file_offset_bits64))] - __pad1: c_ushort, + __pad1: Padding, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, @@ -70,7 +73,7 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - __pad2: c_ushort, + __pad2: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, @@ -101,7 +104,7 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - __pad2: c_ushort, + __pad2: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index b04ee50462745..8da10a3c543b6 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; @@ -39,7 +42,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct statfs { @@ -124,11 +127,11 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -140,8 +143,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused5: c_ulong, - __unused6: c_ulong, + __unused5: Padding, + __unused6: Padding, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 801f31e2c0e34..303d4a1135715 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -1,7 +1,10 @@ //! SPARC-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; @@ -36,7 +39,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } @@ -54,7 +57,7 @@ s! { pub l_start: off64_t, pub l_len: off64_t, pub l_pid: crate::pid_t, - __reserved: c_short, + __reserved: Padding, } pub struct stack_t { @@ -66,14 +69,14 @@ s! { pub struct stat { pub st_dev: crate::dev_t, #[cfg(not(gnu_file_offset_bits64))] - __pad1: c_ushort, + __pad1: Padding, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad2: c_ushort, + __pad2: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, @@ -95,7 +98,7 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad2: c_ushort, + __pad2: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, @@ -146,12 +149,12 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - __pad1: c_ushort, + __pad1: Padding, pub mode: c_ushort, - __pad2: c_ushort, + __pad2: Padding, pub __seq: c_ushort, - __unused1: c_ulonglong, - __unused2: c_ulonglong, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -159,33 +162,33 @@ s! { #[cfg(gnu_time_bits64)] pub shm_segsz: size_t, #[cfg(not(gnu_time_bits64))] - __pad1: c_uint, + __pad1: Padding, pub shm_atime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __pad2: c_uint, + __pad2: Padding, pub shm_dtime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __pad3: c_uint, + __pad3: Padding, pub shm_ctime: crate::time_t, #[cfg(not(gnu_time_bits64))] pub shm_segsz: size_t, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __reserved1: c_ulong, - __reserved2: c_ulong, + __reserved1: Padding, + __reserved2: Padding, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, #[cfg(not(gnu_time_bits64))] - __pad1: c_uint, + __pad1: Padding, pub msg_stime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __pad2: c_uint, + __pad2: Padding, pub msg_rtime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __pad3: c_uint, + __pad3: Padding, pub msg_ctime: crate::time_t, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 5f0dfe90adf81..8c80598f84f41 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; pub type greg_t = i32; @@ -105,7 +108,7 @@ s! { pub start_code: c_ulong, pub start_stack: c_ulong, pub signal: c_long, - __reserved: c_int, + __reserved: Padding, pub u_ar0: *mut user_regs_struct, pub u_fpstate: *mut user_fpregs_struct, pub magic: c_ulong, @@ -127,17 +130,17 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct stat64 { pub st_dev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - __pad1: c_uint, + __pad1: Padding, #[cfg(not(gnu_time_bits64))] __st_ino: c_ulong, #[cfg(gnu_time_bits64)] @@ -148,22 +151,22 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, #[cfg(not(gnu_time_bits64))] - __pad2: c_uint, + __pad2: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, #[cfg(gnu_time_bits64)] - _atime_pad: c_int, + _atime_pad: Padding, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, #[cfg(gnu_time_bits64)] - _mtime_pad: c_int, + _mtime_pad: Padding, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, #[cfg(gnu_time_bits64)] - _ctime_pad: c_int, + _ctime_pad: Padding, #[cfg(not(gnu_time_bits64))] pub st_ino: crate::ino64_t, } @@ -204,18 +207,18 @@ s! { pub shm_segsz: size_t, pub shm_atime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __unused1: c_ulong, + __unused1: Padding, pub shm_dtime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __unused2: c_ulong, + __unused2: Padding, pub shm_ctime: crate::time_t, #[cfg(not(gnu_time_bits64))] - __unused3: c_ulong, + __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct msqid_ds { @@ -258,9 +261,7 @@ s! { pub ss_flags: c_int, pub ss_size: size_t, } -} -s_no_extra_traits! { pub struct user_fpxregs_struct { pub cwd: c_ushort, pub swd: c_ushort, @@ -271,7 +272,7 @@ s_no_extra_traits! { pub foo: c_long, pub fos: c_long, pub mxcsr: c_long, - __reserved: c_long, + __reserved: Padding, pub st_space: [c_long; 32], pub xmm_space: [c_long; 32], padding: [c_long; 56], @@ -286,79 +287,15 @@ s_no_extra_traits! { __private: [u8; 112], __ssp: [c_ulong; 4], } +} +s_no_extra_traits! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 6], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for user_fpxregs_struct { - fn eq(&self, other: &user_fpxregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.twd == other.twd - && self.fop == other.fop - && self.fip == other.fip - && self.fcs == other.fcs - && self.foo == other.foo - && self.fos == other.fos - && self.mxcsr == other.mxcsr - // Ignore __reserved field - && self.st_space == other.st_space - && self.xmm_space == other.xmm_space - // Ignore padding field - } - } - - impl Eq for user_fpxregs_struct {} - - impl hash::Hash for user_fpxregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.twd.hash(state); - self.fop.hash(state); - self.fip.hash(state); - self.fcs.hash(state); - self.foo.hash(state); - self.fos.hash(state); - self.mxcsr.hash(state); - // Ignore __reserved field - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - // Ignore __private field - } - } - - impl Eq for ucontext_t {} - - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - // Ignore __private field - } - } - } -} - pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: c_int = 0x8; pub const RTLD_GLOBAL: c_int = 0x100; 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 28b4e40fde543..d896257046df4 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -1,7 +1,10 @@ //! AArch64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; pub type nlink_t = u32; @@ -17,7 +20,7 @@ s! { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, #[cfg(target_arch = "sparc64")] - __reserved0: c_int, + __reserved0: Padding, pub sa_flags: c_int, pub sa_restorer: Option, } @@ -62,10 +65,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: crate::dev_t, + __pad1: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad2: c_int, + __pad2: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -73,7 +76,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct stat64 { @@ -84,10 +87,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: crate::dev_t, + __pad1: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, - __pad2: c_int, + __pad2: Padding, pub st_blocks: crate::blkcnt64_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -95,7 +98,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct statfs64 { @@ -162,9 +165,9 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_ushort, - __pad1: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -176,8 +179,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct siginfo_t { @@ -216,7 +219,7 @@ s! { pub sp: c_ulonglong, pub pc: c_ulonglong, pub pstate: c_ulonglong, - __reserved: [u64; 512], + __reserved: Padding<[u64; 512]>, } pub struct user_fpsimd_struct { diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index 8f15ce4d1529a..e3971eaafe0ae 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -1,5 +1,9 @@ use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; @@ -18,10 +22,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: crate::dev_t, + __pad1: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad2: c_int, + __pad2: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -29,7 +33,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct stat64 { @@ -51,7 +55,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct statfs { @@ -172,9 +176,9 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -186,8 +190,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct user_regs_struct { diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index 7f66330d9c7ed..dfec9203361d0 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -1,5 +1,9 @@ use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type blksize_t = i64; pub type nlink_t = u64; @@ -11,16 +15,16 @@ pub type __s64 = c_long; s! { pub struct stat { pub st_dev: c_ulong, - st_pad1: [c_long; 2], + st_pad1: Padding<[c_long; 2]>, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: c_ulong, - st_pad2: [c_ulong; 1], + st_pad2: Padding<[c_ulong; 1]>, pub st_size: off_t, - st_pad3: c_long, + st_pad3: Padding, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, @@ -28,9 +32,9 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - st_pad4: c_long, + st_pad4: Padding, pub st_blocks: crate::blkcnt_t, - st_pad5: [c_long; 7], + st_pad5: Padding<[c_long; 7]>, } pub struct statfs { @@ -66,14 +70,14 @@ s! { pub struct stat64 { pub st_dev: c_ulong, - st_pad1: [c_long; 2], + st_pad1: Padding<[c_long; 2]>, pub st_ino: crate::ino64_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: c_ulong, - st_pad2: [c_long; 2], + st_pad2: Padding<[c_long; 2]>, pub st_size: off64_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -82,9 +86,9 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - st_pad3: c_long, + st_pad3: Padding, pub st_blocks: crate::blkcnt64_t, - st_pad5: [c_long; 7], + st_pad5: Padding<[c_long; 7]>, } pub struct statfs64 { @@ -155,8 +159,8 @@ s! { pub si_signo: c_int, pub si_code: c_int, pub si_errno: c_int, - _pad: c_int, - _pad2: [c_long; 14], + _pad: Padding, + _pad2: Padding<[c_long; 14]>, } pub struct ipc_perm { @@ -167,9 +171,9 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_ushort, - __pad1: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -181,8 +185,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } } diff --git a/src/unix/linux_like/linux/gnu/b64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mod.rs index ba5678b459795..5a3022117c2a3 100644 --- a/src/unix/linux_like/linux/gnu/b64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mod.rs @@ -80,7 +80,7 @@ s! { target_arch = "sparc64", target_arch = "s390x", )))] - __reserved: crate::__syscall_ulong_t, + __reserved: Padding, pub sem_ctime: crate::time_t, #[cfg(not(any( target_arch = "aarch64", @@ -92,7 +92,7 @@ s! { target_arch = "sparc64", target_arch = "s390x", )))] - __reserved2: crate::__syscall_ulong_t, + __reserved2: Padding, pub sem_nsems: crate::__syscall_ulong_t, __glibc_reserved3: crate::__syscall_ulong_t, __glibc_reserved4: crate::__syscall_ulong_t, diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 047efe55b1a38..2d6957d5e51c7 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -1,7 +1,11 @@ //! PowerPC64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; pub type nlink_t = u64; @@ -9,6 +13,8 @@ pub type blksize_t = i64; pub type suseconds_t = i64; pub type __u64 = c_ulong; pub type __s64 = c_long; +pub type gregset_t = [c_ulong; __NGREG]; +pub type fpregset_t = [c_ulong; __NFPREG]; s! { // FIXME(1.0): This should not implement `PartialEq` @@ -17,7 +23,7 @@ s! { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, #[cfg(target_arch = "sparc64")] - __reserved0: c_int, + __reserved0: Padding, pub sa_flags: c_int, pub sa_restorer: Option, } @@ -61,7 +67,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -72,7 +78,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct stat64 { @@ -82,7 +88,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off64_t, pub st_blksize: crate::blksize_t, @@ -93,7 +99,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __reserved: [c_long; 3], + __reserved: Padding<[c_long; 3]>, } pub struct statfs64 { @@ -153,9 +159,9 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: u32, - __pad1: u32, - __unused1: u64, - __unused2: c_ulong, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -167,8 +173,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct siginfo_t { @@ -191,6 +197,21 @@ s! { pub ss_flags: c_int, pub ss_size: size_t, } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } } s_no_extra_traits! { @@ -198,6 +219,64 @@ s_no_extra_traits! { pub struct max_align_t { priv_: [i64; 4], } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + pub struct pt_regs { + pub gpr: [c_ulong; 32], + pub nip: c_ulong, + pub msr: c_ulong, + pub orig_gpr3: c_ulong, + pub ctr: c_ulong, + pub link: c_ulong, + pub xer: c_ulong, + pub ccr: c_ulong, + pub softe: c_ulong, + pub trap: c_ulong, + pub dar: c_ulong, + pub dsisr: c_ulong, + pub result: c_ulong, + } + + pub struct mcontext_t { + __glibc_reserved: [c_ulong; 4], + pub signal: c_int, + __pad0: c_int, + pub handler: c_ulong, + pub oldmask: c_ulong, + pub regs: *mut pt_regs, + pub gp_regs: crate::gregset_t, + pub fp_regs: crate::fpregset_t, + pub v_regs: *mut vrregset_t, + pub vmx_reserve: [c_long; __NVRREG + __NVRREG + 1], + } + + #[repr(align(16))] + pub struct vrregset_t { + pub vrregs: [[c_uint; 4]; 32], + pub vscr: vscr_t, + pub vrsave: c_uint, + __pad: [c_uint; 3], + } + + #[repr(align(4))] + pub struct vscr_t { + #[cfg(target_endian = "big")] + __pad: [c_uint; 3], + #[cfg(target_endian = "big")] + pub vscr_word: c_uint, + + #[cfg(target_endian = "little")] + pub vscr_word: c_uint, + #[cfg(target_endian = "little")] + __pad: [c_uint; 3], + } } pub const POSIX_FADV_DONTNEED: c_int = 4; @@ -210,6 +289,10 @@ pub const VEOF: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const __NGREG: usize = 48; +pub const __NFPREG: usize = 33; +pub const __NVRREG: usize = 34; + pub const O_APPEND: c_int = 1024; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; @@ -971,4 +1054,9 @@ extern "C" { newp: *mut c_void, newlen: size_t, ) -> c_int; + + pub fn getcontext(ucp: *mut ucontext_t) -> c_int; + pub fn setcontext(ucp: *const ucontext_t) -> c_int; + pub fn swapcontext(oucp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); } 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 bfbc8ee5cf683..3438a510d3bf9 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; @@ -37,7 +40,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2usize], + __unused: Padding<[c_int; 2usize]>, } pub struct stat64 { @@ -59,7 +62,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct statfs { @@ -159,11 +162,11 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -175,8 +178,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused5: c_ulong, - __unused6: c_ulong, + __unused5: Padding, + __unused6: Padding, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 029485c5b4a32..d45e153aee3a9 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -1,7 +1,11 @@ //! s390x use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type blksize_t = i64; pub type nlink_t = u64; @@ -57,8 +61,8 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - _pad: c_int, - _pad2: [c_long; 14], + _pad: Padding, + _pad2: Padding<[c_long; 14]>, } pub struct stack_t { @@ -74,7 +78,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - st_pad0: c_int, + st_pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_atime: crate::time_t, @@ -95,7 +99,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - st_pad0: c_int, + st_pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_atime: crate::time_t, @@ -121,9 +125,9 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_ushort, - __pad1: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -135,8 +139,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct statvfs { @@ -161,7 +165,7 @@ s! { pub struct fpregset_t { pub fpc: u32, - __pad: u32, + __pad: Padding, pub fprs: [fpreg_t; 16], } diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index f18e53a99b466..0b32562339690 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -1,7 +1,11 @@ //! SPARC64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; pub type nlink_t = u32; @@ -17,7 +21,7 @@ s! { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, #[cfg(target_arch = "sparc64")] - __reserved0: c_int, + __reserved0: Padding, pub sa_flags: c_int, pub sa_restorer: Option, } @@ -67,7 +71,7 @@ s! { pub l_start: off64_t, pub l_len: off64_t, pub l_pid: crate::pid_t, - __reserved: c_short, + __reserved: Padding, } pub struct stack_t { @@ -78,14 +82,14 @@ s! { pub struct stat { pub st_dev: crate::dev_t, - __pad0: u64, + __pad0: Padding, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: u64, + __pad1: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, @@ -95,19 +99,19 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 2], + __unused: Padding<[c_long; 2]>, } pub struct stat64 { pub st_dev: crate::dev_t, - __pad0: u64, + __pad0: Padding, pub st_ino: crate::ino64_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad2: c_int, + __pad2: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, @@ -117,7 +121,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __reserved: [c_long; 2], + __reserved: Padding<[c_long; 2]>, } pub struct statfs64 { @@ -176,10 +180,10 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: crate::mode_t, - __pad0: u16, + __pad0: Padding, pub __seq: c_ushort, - __unused1: c_ulonglong, - __unused2: c_ulonglong, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -191,8 +195,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __reserved1: c_ulong, - __reserved2: c_ulong, + __reserved1: Padding, + __reserved2: Padding, } } diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index f4555ee420230..8654559b148fb 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -1,7 +1,10 @@ //! x86_64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; pub type nlink_t = u64; @@ -18,7 +21,7 @@ s! { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, #[cfg(target_arch = "sparc64")] - __reserved0: c_int, + __reserved0: Padding, pub sa_flags: c_int, pub sa_restorer: Option, } @@ -83,7 +86,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -94,7 +97,7 @@ s! { pub st_mtime_nsec: i64, pub st_ctime: crate::time_t, pub st_ctime_nsec: i64, - __unused: [i64; 3], + __unused: Padding<[i64; 3]>, } pub struct stat64 { @@ -104,7 +107,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -115,7 +118,7 @@ s! { pub st_mtime_nsec: i64, pub st_ctime: crate::time_t, pub st_ctime_nsec: i64, - __reserved: [i64; 3], + __reserved: Padding<[i64; 3]>, } pub struct statfs64 { @@ -219,12 +222,12 @@ s! { pub start_code: c_ulonglong, pub start_stack: c_ulonglong, pub signal: c_longlong, - __reserved: c_int, + __reserved: Padding, #[cfg(target_pointer_width = "32")] - __pad1: u32, + __pad1: Padding, pub u_ar0: *mut user_regs_struct, #[cfg(target_pointer_width = "32")] - __pad2: u32, + __pad2: Padding, pub u_fpstate: *mut user_fpregs_struct, pub magic: c_ulonglong, pub u_comm: [c_char; 32], @@ -244,11 +247,11 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: u64, - __unused2: u64, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -260,8 +263,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: u64, - __unused5: u64, + __unused4: Padding, + __unused5: Padding, } pub struct ptrace_rseq_configuration { @@ -286,9 +289,7 @@ s! { pub set_tid_size: c_ulonglong, pub cgroup: c_ulonglong, } -} -s_no_extra_traits! { pub struct user_fpregs_struct { pub cwd: c_ushort, pub swd: c_ushort, @@ -310,84 +311,17 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, pub uc_sigmask: crate::sigset_t, __private: [u8; 512], - // FIXME(glibc): the shadow stack field requires glibc >= 2.28. - // Re-add once we drop compatibility with glibc versions older than - // 2.28. - // - // __ssp: [c_ulonglong; 4], + __ssp: [c_ulonglong; 4], } +} +s_no_extra_traits! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for user_fpregs_struct { - fn eq(&self, other: &user_fpregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self.st_space == other.st_space - && self - .xmm_space - .iter() - .zip(other.xmm_space.iter()) - .all(|(a, b)| a == b) - // Ignore padding field - } - } - - impl Eq for user_fpregs_struct {} - - impl hash::Hash for user_fpregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - // Ignore __private field - } - } - - impl Eq for ucontext_t {} - - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - // Ignore __private field - } - } - } -} - pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 17d11d27a4dea..96eed0d27ef2c 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -37,7 +37,7 @@ s! { not(target_arch = "x86_64"), target_pointer_width = "32" ))] - __unused1: [c_char; 4], + __unused1: Padding<[c_char; 4]>, __glibc_reserved: [c_char; 32], } @@ -57,11 +57,11 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct msghdr { @@ -153,27 +153,6 @@ s! { pub nm_gid: u32, } - pub struct rtentry { - pub rt_pad1: c_ulong, - pub rt_dst: crate::sockaddr, - pub rt_gateway: crate::sockaddr, - pub rt_genmask: crate::sockaddr, - pub rt_flags: c_ushort, - pub rt_pad2: c_short, - pub rt_pad3: c_ulong, - pub rt_tos: c_uchar, - pub rt_class: c_uchar, - #[cfg(target_pointer_width = "64")] - pub rt_pad4: [c_short; 3usize], - #[cfg(not(target_pointer_width = "64"))] - pub rt_pad4: c_short, - pub rt_metric: c_short, - pub rt_dev: *mut c_char, - pub rt_mtu: c_ulong, - pub rt_window: c_ulong, - pub rt_irtt: c_ushort, - } - pub struct ntptimeval { pub time: crate::timeval, pub maxerror: c_long, @@ -363,13 +342,57 @@ s! { pub struct timespec { pub tv_sec: time_t, #[cfg(all(gnu_time_bits64, target_endian = "big"))] - __pad: i32, + __pad: Padding, #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] pub tv_nsec: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] pub tv_nsec: i64, #[cfg(all(gnu_time_bits64, target_endian = "little"))] - __pad: i32, + __pad: Padding, + } + + pub struct utmpx { + pub ut_type: c_short, + pub ut_pid: crate::pid_t, + pub ut_line: [c_char; __UT_LINESIZE], + pub ut_id: [c_char; 4], + + pub ut_user: [c_char; __UT_NAMESIZE], + pub ut_host: [c_char; __UT_HOSTSIZE], + pub ut_exit: __exit_status, + + #[cfg(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + ))] + pub ut_session: c_long, + #[cfg(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + ))] + pub ut_tv: crate::timeval, + + #[cfg(not(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + )))] + pub ut_session: i32, + #[cfg(not(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + )))] + pub ut_tv: __timeval, + + pub ut_addr_v6: [i32; 4], + __glibc_reserved: [c_char; 20], } } @@ -399,36 +422,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { @@ -463,92 +479,10 @@ s_no_extra_traits! { pub exit: __c_anonymous_ptrace_syscall_info_exit, pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, } - - pub struct utmpx { - pub ut_type: c_short, - pub ut_pid: crate::pid_t, - pub ut_line: [c_char; __UT_LINESIZE], - pub ut_id: [c_char; 4], - - pub ut_user: [c_char; __UT_NAMESIZE], - pub ut_host: [c_char; __UT_HOSTSIZE], - pub ut_exit: __exit_status, - - #[cfg(any( - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - all(target_pointer_width = "32", not(target_arch = "x86_64")) - ))] - pub ut_session: c_long, - #[cfg(any( - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - all(target_pointer_width = "32", not(target_arch = "x86_64")) - ))] - pub ut_tv: crate::timeval, - - #[cfg(not(any( - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - all(target_pointer_width = "32", not(target_arch = "x86_64")) - )))] - pub ut_session: i32, - #[cfg(not(any( - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - all(target_pointer_width = "32", not(target_arch = "x86_64")) - )))] - pub ut_tv: __timeval, - - pub ut_addr_v6: [i32; 4], - __glibc_reserved: [c_char; 20], - } } cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_user == other.ut_user - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.__glibc_reserved == other.__glibc_reserved - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.__glibc_reserved.hash(state); - } - } - impl PartialEq for __c_anonymous_ptrace_syscall_info_data { fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { unsafe { @@ -892,42 +826,6 @@ pub const CLONE_NEWTIME: c_int = 0x80; pub const CLONE_CLEAR_SIGHAND: c_int = 0x100000000; pub const CLONE_INTO_CGROUP: c_int = 0x200000000; -// linux/keyctl.h -pub const KEYCTL_DH_COMPUTE: u32 = 23; -pub const KEYCTL_PKEY_QUERY: u32 = 24; -pub const KEYCTL_PKEY_ENCRYPT: u32 = 25; -pub const KEYCTL_PKEY_DECRYPT: u32 = 26; -pub const KEYCTL_PKEY_SIGN: u32 = 27; -pub const KEYCTL_PKEY_VERIFY: u32 = 28; -pub const KEYCTL_RESTRICT_KEYRING: u32 = 29; - -pub const KEYCTL_SUPPORTS_ENCRYPT: u32 = 0x01; -pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02; -pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04; -pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08; -cfg_if! { - if #[cfg(not(any( - target_arch = "mips", - target_arch = "mips32r6", - target_arch = "mips64", - target_arch = "mips64r6" - )))] { - pub const KEYCTL_MOVE: u32 = 30; - pub const KEYCTL_CAPABILITIES: u32 = 31; - - pub const KEYCTL_CAPS0_CAPABILITIES: u32 = 0x01; - pub const KEYCTL_CAPS0_PERSISTENT_KEYRINGS: u32 = 0x02; - pub const KEYCTL_CAPS0_DIFFIE_HELLMAN: u32 = 0x04; - pub const KEYCTL_CAPS0_PUBLIC_KEY: u32 = 0x08; - pub const KEYCTL_CAPS0_BIG_KEY: u32 = 0x10; - pub const KEYCTL_CAPS0_INVALIDATE: u32 = 0x20; - pub const KEYCTL_CAPS0_RESTRICT_KEYRING: u32 = 0x40; - pub const KEYCTL_CAPS0_MOVE: u32 = 0x80; - pub const KEYCTL_CAPS1_NS_KEYRING_NAME: u32 = 0x01; - pub const KEYCTL_CAPS1_NS_KEY_TAG: u32 = 0x02; - } -} - pub const M_MXFAST: c_int = 1; pub const M_NLBLKS: c_int = 2; pub const M_GRAIN: c_int = 3; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 14401077479ed..3a757ee8d2028 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1,7 +1,13 @@ //! Linux-specific definitions for linux-like values use crate::prelude::*; -use crate::{sock_filter, _IO, _IOR, _IOW, _IOWR}; +use crate::{ + sock_filter, + _IO, + _IOR, + _IOW, + _IOWR, +}; pub type useconds_t = u32; pub type dev_t = u64; @@ -67,8 +73,7 @@ pub type eventfd_t = u64; cfg_if! { if #[cfg(not(target_env = "gnu"))] { - missing! { - #[derive(Debug)] + extern_ty! { pub enum fpos64_t {} // FIXME(linux): fill this out with a struct } } @@ -85,11 +90,11 @@ e! { c_enum! { pub enum pid_type { - PIDTYPE_PID, - PIDTYPE_TGID, - PIDTYPE_PGID, - PIDTYPE_SID, - PIDTYPE_MAX, + pub PIDTYPE_PID, + pub PIDTYPE_TGID, + pub PIDTYPE_PGID, + pub PIDTYPE_SID, + pub PIDTYPE_MAX, } } @@ -100,11 +105,11 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct passwd { @@ -159,11 +164,11 @@ s! { pub ssi_stime: u64, pub ssi_addr: u64, pub ssi_addr_lsb: u16, - _pad2: u16, + _pad2: Padding, pub ssi_syscall: i32, pub ssi_call_addr: u64, pub ssi_arch: u32, - _pad: [u8; 28], + _pad: Padding<[u8; 28]>, } pub struct itimerspec { @@ -638,7 +643,7 @@ s! { __allocated: c_int, __used: c_int, __actions: *mut c_int, - __pad: [c_int; 16], + __pad: Padding<[c_int; 16]>, } pub struct posix_spawnattr_t { @@ -651,7 +656,7 @@ s! { #[cfg(not(any(target_env = "musl", target_env = "ohos")))] __sp: crate::sched_param, __policy: c_int, - __pad: [c_int; 16], + __pad: Padding<[c_int; 16]>, } pub struct genlmsghdr { @@ -1182,7 +1187,7 @@ s! { size: [u8; crate::__SIZEOF_PTHREAD_BARRIERATTR_T], } - #[cfg(not(target_env = "musl"))] + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] #[repr(align(8))] pub struct fanotify_event_metadata { pub event_len: __u32, @@ -1361,49 +1366,10 @@ s! { pub token_start: crate::__u32, pub token_count: crate::__u32, } -} - -cfg_if! { - if #[cfg(not(target_arch = "sparc64"))] { - s! { - pub struct iw_thrspy { - pub addr: crate::sockaddr, - pub qual: iw_quality, - pub low: iw_quality, - pub high: iw_quality, - } - - pub struct iw_mlme { - pub cmd: __u16, - pub reason_code: __u16, - pub addr: crate::sockaddr, - } - - pub struct iw_michaelmicfailure { - pub flags: __u32, - pub src_addr: crate::sockaddr, - pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE], - } - - pub struct __c_anonymous_elf32_rela { - pub r_offset: Elf32_Addr, - pub r_info: Elf32_Word, - pub r_addend: Elf32_Sword, - } - - pub struct __c_anonymous_elf64_rela { - pub r_offset: Elf64_Addr, - pub r_info: Elf64_Xword, - pub r_addend: Elf64_Sxword, - } - } - } -} -s_no_extra_traits! { pub struct sockaddr_nl { pub nl_family: crate::sa_family_t, - nl_pad: c_ushort, + nl_pad: Padding, pub nl_pid: u32, pub nl_groups: u32, } @@ -1416,6 +1382,14 @@ s_no_extra_traits! { pub d_name: [c_char; 256], } + pub struct dirent64 { + pub d_ino: crate::ino64_t, + pub d_off: off64_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + pub struct sockaddr_alg { pub salg_family: crate::sa_family_t, pub salg_type: [c_uchar; 14], @@ -1440,18 +1414,6 @@ s_no_extra_traits! { pub absflat: [__s32; ABS_CNT], } - /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this - /// type are unsound and will be removed in the future. - #[deprecated( - note = "this struct has unsafe trait implementations that will be \ - removed in the future", - since = "0.2.80" - )] - pub struct af_alg_iv { - pub ivlen: u32, - pub iv: [c_uchar; 0], - } - // x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 pub struct mq_attr { @@ -1478,55 +1440,12 @@ s_no_extra_traits! { pad: [c_long; 4], } - pub union __c_anonymous_ifr_ifru { - pub ifru_addr: crate::sockaddr, - pub ifru_dstaddr: crate::sockaddr, - pub ifru_broadaddr: crate::sockaddr, - pub ifru_netmask: crate::sockaddr, - pub ifru_hwaddr: crate::sockaddr, - pub ifru_flags: c_short, - pub ifru_ifindex: c_int, - pub ifru_metric: c_int, - pub ifru_mtu: c_int, - pub ifru_map: __c_anonymous_ifru_map, - pub ifru_slave: [c_char; crate::IFNAMSIZ], - pub ifru_newname: [c_char; crate::IFNAMSIZ], - pub ifru_data: *mut c_char, - } - - pub struct ifreq { - /// interface name, e.g. "en0" - pub ifr_name: [c_char; crate::IFNAMSIZ], - pub ifr_ifru: __c_anonymous_ifr_ifru, - } - - pub union __c_anonymous_ifc_ifcu { - pub ifcu_buf: *mut c_char, - pub ifcu_req: *mut crate::ifreq, - } - - /// Structure used in SIOCGIFCONF request. Used to retrieve interface configuration for - /// machine (useful for programs which must know all networks accessible). - pub struct ifconf { - /// Size of buffer - pub ifc_len: c_int, - pub ifc_ifcu: __c_anonymous_ifc_ifcu, - } - pub struct hwtstamp_config { pub flags: c_int, pub tx_type: c_int, pub rx_filter: c_int, } - pub struct dirent64 { - pub d_ino: crate::ino64_t, - pub d_off: off64_t, - pub d_reclen: c_ushort, - pub d_type: c_uchar, - pub d_name: [c_char; 256], - } - pub struct sched_attr { pub size: __u32, pub sched_policy: __u32, @@ -1538,21 +1457,6 @@ s_no_extra_traits! { pub sched_period: crate::__u64, } - 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, - } - #[cfg_attr( all( any(target_env = "musl", target_env = "ohos"), @@ -1705,6 +1609,107 @@ s_no_extra_traits! { pub struct pthread_barrier_t { size: [u8; crate::__SIZEOF_PTHREAD_BARRIER_T], } +} + +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + s! { + pub struct iw_thrspy { + pub addr: crate::sockaddr, + pub qual: iw_quality, + pub low: iw_quality, + pub high: iw_quality, + } + + pub struct iw_mlme { + pub cmd: __u16, + pub reason_code: __u16, + pub addr: crate::sockaddr, + } + + pub struct iw_michaelmicfailure { + pub flags: __u32, + pub src_addr: crate::sockaddr, + pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE], + } + + pub struct __c_anonymous_elf32_rela { + pub r_offset: Elf32_Addr, + pub r_info: Elf32_Word, + pub r_addend: Elf32_Sword, + } + + pub struct __c_anonymous_elf64_rela { + pub r_offset: Elf64_Addr, + pub r_info: Elf64_Xword, + pub r_addend: Elf64_Sxword, + } + } + } +} + +s_no_extra_traits! { + /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this + /// type are unsound and will be removed in the future. + #[deprecated( + note = "this struct has unsafe trait implementations that will be \ + removed in the future", + since = "0.2.80" + )] + pub struct af_alg_iv { + pub ivlen: u32, + pub iv: [c_uchar; 0], + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_netmask: crate::sockaddr, + pub ifru_hwaddr: crate::sockaddr, + pub ifru_flags: c_short, + pub ifru_ifindex: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_map: __c_anonymous_ifru_map, + pub ifru_slave: [c_char; crate::IFNAMSIZ], + pub ifru_newname: [c_char; crate::IFNAMSIZ], + pub ifru_data: *mut c_char, + } + + pub struct ifreq { + /// interface name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_char, + pub ifcu_req: *mut crate::ifreq, + } + + /// Structure used in SIOCGIFCONF request. Used to retrieve interface configuration for + /// machine (useful for programs which must know all networks accessible). + pub struct ifconf { + /// Size of buffer + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + 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 { @@ -1782,202 +1787,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_nl { - fn eq(&self, other: &sockaddr_nl) -> bool { - self.nl_family == other.nl_family - && self.nl_pid == other.nl_pid - && self.nl_groups == other.nl_groups - } - } - impl Eq for sockaddr_nl {} - impl hash::Hash for sockaddr_nl { - fn hash(&self, state: &mut H) { - self.nl_family.hash(state); - self.nl_pid.hash(state); - self.nl_groups.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent64 {} - - impl hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - - impl Eq for pthread_cond_t {} - - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - - impl Eq for pthread_mutex_t {} - - impl hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - - impl Eq for pthread_rwlock_t {} - - impl hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_barrier_t { - fn eq(&self, other: &pthread_barrier_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - - impl Eq for pthread_barrier_t {} - - impl hash::Hash for pthread_barrier_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for sockaddr_alg { - fn eq(&self, other: &sockaddr_alg) -> bool { - self.salg_family == other.salg_family - && self - .salg_type - .iter() - .zip(other.salg_type.iter()) - .all(|(a, b)| a == b) - && self.salg_feat == other.salg_feat - && self.salg_mask == other.salg_mask - && self - .salg_name - .iter() - .zip(other.salg_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_alg {} - - impl hash::Hash for sockaddr_alg { - fn hash(&self, state: &mut H) { - self.salg_family.hash(state); - self.salg_type.hash(state); - self.salg_feat.hash(state); - self.salg_mask.hash(state); - self.salg_name.hash(state); - } - } - - impl PartialEq for uinput_setup { - fn eq(&self, other: &uinput_setup) -> bool { - self.id == other.id - && self.name[..] == other.name[..] - && self.ff_effects_max == other.ff_effects_max - } - } - impl Eq for uinput_setup {} - - impl hash::Hash for uinput_setup { - fn hash(&self, state: &mut H) { - self.id.hash(state); - self.name.hash(state); - self.ff_effects_max.hash(state); - } - } - - impl PartialEq for uinput_user_dev { - fn eq(&self, other: &uinput_user_dev) -> bool { - self.name[..] == other.name[..] - && self.id == other.id - && self.ff_effects_max == other.ff_effects_max - && self.absmax[..] == other.absmax[..] - && self.absmin[..] == other.absmin[..] - && self.absfuzz[..] == other.absfuzz[..] - && self.absflat[..] == other.absflat[..] - } - } - impl Eq for uinput_user_dev {} - - impl hash::Hash for uinput_user_dev { - fn hash(&self, state: &mut H) { - self.name.hash(state); - self.id.hash(state); - self.ff_effects_max.hash(state); - self.absmax.hash(state); - self.absmin.hash(state); - self.absfuzz.hash(state); - self.absflat.hash(state); - } - } - #[allow(deprecated)] impl af_alg_iv { fn as_slice(&self) -> &[u8] { @@ -2001,65 +1810,6 @@ cfg_if! { self.as_slice().hash(state); } } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_flags == other.mq_flags - && self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_curmsgs == other.mq_curmsgs - } - } - impl Eq for mq_attr {} - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_flags.hash(state); - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_curmsgs.hash(state); - } - } - impl PartialEq for hwtstamp_config { - fn eq(&self, other: &hwtstamp_config) -> bool { - self.flags == other.flags - && self.tx_type == other.tx_type - && self.rx_filter == other.rx_filter - } - } - impl Eq for hwtstamp_config {} - impl hash::Hash for hwtstamp_config { - fn hash(&self, state: &mut H) { - self.flags.hash(state); - self.tx_type.hash(state); - self.rx_filter.hash(state); - } - } - - impl PartialEq for sched_attr { - fn eq(&self, other: &sched_attr) -> bool { - self.size == other.size - && self.sched_policy == other.sched_policy - && self.sched_flags == other.sched_flags - && self.sched_nice == other.sched_nice - && self.sched_priority == other.sched_priority - && self.sched_runtime == other.sched_runtime - && self.sched_deadline == other.sched_deadline - && self.sched_period == other.sched_period - } - } - impl Eq for sched_attr {} - impl hash::Hash for sched_attr { - fn hash(&self, state: &mut H) { - self.size.hash(state); - self.sched_policy.hash(state); - self.sched_flags.hash(state); - self.sched_nice.hash(state); - self.sched_priority.hash(state); - self.sched_runtime.hash(state); - self.sched_deadline.hash(state); - self.sched_period.hash(state); - } - } } } @@ -2544,6 +2294,8 @@ pub const AT_BASE_PLATFORM: c_ulong = 24; pub const AT_RANDOM: c_ulong = 25; pub const AT_HWCAP2: c_ulong = 26; +pub const AT_HWCAP3: c_ulong = 29; +pub const AT_HWCAP4: c_ulong = 30; pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value @@ -4481,22 +4233,22 @@ pub const RTNLGRP_STATS: c_uint = 0x24; // linux/cn_proc.h c_enum! { pub enum proc_cn_mcast_op { - PROC_CN_MCAST_LISTEN = 1, - PROC_CN_MCAST_IGNORE = 2, + pub PROC_CN_MCAST_LISTEN = 1, + pub PROC_CN_MCAST_IGNORE = 2, } pub enum proc_cn_event { - PROC_EVENT_NONE = 0x00000000, - PROC_EVENT_FORK = 0x00000001, - PROC_EVENT_EXEC = 0x00000002, - PROC_EVENT_UID = 0x00000004, - PROC_EVENT_GID = 0x00000040, - PROC_EVENT_SID = 0x00000080, - PROC_EVENT_PTRACE = 0x00000100, - PROC_EVENT_COMM = 0x00000200, - PROC_EVENT_NONZERO_EXIT = 0x20000000, - PROC_EVENT_COREDUMP = 0x40000000, - PROC_EVENT_EXIT = 0x80000000, + pub PROC_EVENT_NONE = 0x00000000, + pub PROC_EVENT_FORK = 0x00000001, + pub PROC_EVENT_EXEC = 0x00000002, + pub PROC_EVENT_UID = 0x00000004, + pub PROC_EVENT_GID = 0x00000040, + pub PROC_EVENT_SID = 0x00000080, + pub PROC_EVENT_PTRACE = 0x00000100, + pub PROC_EVENT_COMM = 0x00000200, + pub PROC_EVENT_NONZERO_EXIT = 0x20000000, + pub PROC_EVENT_COREDUMP = 0x40000000, + pub PROC_EVENT_EXIT = 0x80000000, } } @@ -4821,50 +4573,6 @@ const fn issecure_mask(x: c_int) -> c_int { 1 << x } -// linux/keyctl.h -pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; -pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; -pub const KEY_SPEC_SESSION_KEYRING: i32 = -3; -pub const KEY_SPEC_USER_KEYRING: i32 = -4; -pub const KEY_SPEC_USER_SESSION_KEYRING: i32 = -5; -pub const KEY_SPEC_GROUP_KEYRING: i32 = -6; -pub const KEY_SPEC_REQKEY_AUTH_KEY: i32 = -7; -pub const KEY_SPEC_REQUESTOR_KEYRING: i32 = -8; - -pub const KEY_REQKEY_DEFL_NO_CHANGE: i32 = -1; -pub const KEY_REQKEY_DEFL_DEFAULT: i32 = 0; -pub const KEY_REQKEY_DEFL_THREAD_KEYRING: i32 = 1; -pub const KEY_REQKEY_DEFL_PROCESS_KEYRING: i32 = 2; -pub const KEY_REQKEY_DEFL_SESSION_KEYRING: i32 = 3; -pub const KEY_REQKEY_DEFL_USER_KEYRING: i32 = 4; -pub const KEY_REQKEY_DEFL_USER_SESSION_KEYRING: i32 = 5; -pub const KEY_REQKEY_DEFL_GROUP_KEYRING: i32 = 6; -pub const KEY_REQKEY_DEFL_REQUESTOR_KEYRING: i32 = 7; - -pub const KEYCTL_GET_KEYRING_ID: u32 = 0; -pub const KEYCTL_JOIN_SESSION_KEYRING: u32 = 1; -pub const KEYCTL_UPDATE: u32 = 2; -pub const KEYCTL_REVOKE: u32 = 3; -pub const KEYCTL_CHOWN: u32 = 4; -pub const KEYCTL_SETPERM: u32 = 5; -pub const KEYCTL_DESCRIBE: u32 = 6; -pub const KEYCTL_CLEAR: u32 = 7; -pub const KEYCTL_LINK: u32 = 8; -pub const KEYCTL_UNLINK: u32 = 9; -pub const KEYCTL_SEARCH: u32 = 10; -pub const KEYCTL_READ: u32 = 11; -pub const KEYCTL_INSTANTIATE: u32 = 12; -pub const KEYCTL_NEGATE: u32 = 13; -pub const KEYCTL_SET_REQKEY_KEYRING: u32 = 14; -pub const KEYCTL_SET_TIMEOUT: u32 = 15; -pub const KEYCTL_ASSUME_AUTHORITY: u32 = 16; -pub const KEYCTL_GET_SECURITY: u32 = 17; -pub const KEYCTL_SESSION_TO_PARENT: u32 = 18; -pub const KEYCTL_REJECT: u32 = 19; -pub const KEYCTL_INSTANTIATE_IOV: u32 = 20; -pub const KEYCTL_INVALIDATE: u32 = 21; -pub const KEYCTL_GET_PERSISTENT: u32 = 22; - pub const IN_MASK_CREATE: u32 = 0x1000_0000; pub const IN_MASK_ADD: u32 = 0x2000_0000; pub const IN_ISDIR: u32 = 0x4000_0000; @@ -4955,7 +4663,8 @@ cfg_if! { pub const NFT_MSG_GETOBJ_RESET: c_int = 21; } } -pub const NFT_MSG_MAX: c_int = 25; + +pub const NFT_MSG_MAX: c_int = 34; pub const NFT_SET_ANONYMOUS: c_int = 0x1; pub const NFT_SET_CONSTANT: c_int = 0x2; @@ -5775,16 +5484,20 @@ f! { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); } - 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::(); + pub fn CMSG_NXTHDR( + mhdr: *const crate::msghdr, + cmsg: *const crate::cmsghdr, + ) -> *mut crate::cmsghdr { + if ((*cmsg).cmsg_len as usize) < size_of::() { + return core::ptr::null_mut::(); } - let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; + let next = + (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut crate::cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.wrapping_offset(1)) as usize > max || next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max { - core::ptr::null_mut::() + core::ptr::null_mut::() } else { next } @@ -6127,17 +5840,6 @@ cfg_if! { newattr: *const crate::mq_attr, oldattr: *mut crate::mq_attr, ) -> c_int; - - pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> c_int; - pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; - pub fn pthread_mutexattr_getrobust( - attr: *const pthread_mutexattr_t, - robustness: *mut c_int, - ) -> c_int; - pub fn pthread_mutexattr_setrobust( - attr: *mut pthread_mutexattr_t, - robustness: c_int, - ) -> c_int; } } } @@ -6292,17 +5994,6 @@ extern "C" { len: *mut crate::socklen_t, flg: c_int, ) -> c_int; - pub fn pthread_getaffinity_np( - thread: crate::pthread_t, - cpusetsize: size_t, - cpuset: *mut crate::cpu_set_t, - ) -> c_int; - pub fn pthread_setaffinity_np( - thread: crate::pthread_t, - cpusetsize: size_t, - cpuset: *const crate::cpu_set_t, - ) -> c_int; - pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int; pub fn reboot(how_to: c_int) -> c_int; pub fn setfsgid(gid: crate::gid_t) -> c_int; pub fn setfsuid(uid: crate::uid_t) -> c_int; @@ -6389,11 +6080,6 @@ extern "C" { timeout: c_int, ) -> c_int; pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; - pub fn pthread_getschedparam( - native: crate::pthread_t, - policy: *mut c_int, - param: *mut crate::sched_param, - ) -> c_int; pub fn unshare(flags: c_int) -> c_int; pub fn umount(target: *const c_char) -> c_int; pub fn sched_get_priority_max(policy: c_int) -> c_int; @@ -6408,7 +6094,7 @@ extern "C" { len: size_t, flags: c_uint, ) -> ssize_t; - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; @@ -6440,39 +6126,7 @@ extern "C" { timeout: *const crate::timespec, sigmask: *const sigset_t, ) -> c_int; - pub fn pthread_mutexattr_getprotocol( - attr: *const pthread_mutexattr_t, - protocol: *mut c_int, - ) -> c_int; - pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")] - pub fn pthread_mutex_timedlock( - lock: *mut pthread_mutex_t, - abstime: *const crate::timespec, - ) -> c_int; - pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; - pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; - pub fn pthread_barrierattr_getpshared( - attr: *const crate::pthread_barrierattr_t, - shared: *mut c_int, - ) -> c_int; - pub fn pthread_barrierattr_setpshared( - attr: *mut crate::pthread_barrierattr_t, - shared: c_int, - ) -> c_int; - pub fn pthread_barrier_init( - barrier: *mut pthread_barrier_t, - attr: *const crate::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_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int; - pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int; - pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int; - pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int; - pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int; pub fn clone( cb: extern "C" fn(*mut c_void) -> c_int, child_stack: *mut c_void, @@ -6488,45 +6142,10 @@ extern "C" { rqtp: *const crate::timespec, rmtp: *mut crate::timespec, ) -> c_int; - pub fn pthread_attr_getguardsize( - attr: *const crate::pthread_attr_t, - guardsize: *mut size_t, - ) -> c_int; - pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; - pub fn pthread_attr_getinheritsched( - attr: *const crate::pthread_attr_t, - inheritsched: *mut c_int, - ) -> c_int; - pub fn pthread_attr_setinheritsched( - attr: *mut crate::pthread_attr_t, - inheritsched: c_int, - ) -> c_int; - pub fn pthread_attr_getschedpolicy( - attr: *const crate::pthread_attr_t, - policy: *mut c_int, - ) -> c_int; - pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; - pub fn pthread_attr_getschedparam( - attr: *const crate::pthread_attr_t, - param: *mut crate::sched_param, - ) -> c_int; - pub fn pthread_attr_setschedparam( - attr: *mut crate::pthread_attr_t, - param: *const crate::sched_param, - ) -> c_int; pub fn sethostname(name: *const c_char, len: size_t) -> c_int; pub fn sched_get_priority_min(policy: c_int) -> c_int; - pub fn pthread_condattr_getpshared( - attr: *const pthread_condattr_t, - pshared: *mut c_int, - ) -> c_int; pub fn sysinfo(info: *mut crate::sysinfo) -> c_int; pub fn umount2(target: *const c_char, flags: c_int) -> c_int; - pub fn pthread_setschedparam( - native: crate::pthread_t, - policy: c_int, - param: *const crate::sched_param, - ) -> c_int; pub fn swapon(path: *const c_char, swapflags: c_int) -> c_int; pub fn sched_setscheduler( pid: crate::pid_t, @@ -6554,10 +6173,8 @@ extern "C" { result: *mut *mut crate::group, ) -> c_int; pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; - pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; pub fn getgrnam(name: *const c_char) -> *mut crate::group; - pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; pub fn sem_unlink(name: *const c_char) -> c_int; pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; pub fn getpwnam_r( @@ -6575,11 +6192,6 @@ extern "C" { result: *mut *mut passwd, ) -> c_int; pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; - pub fn pthread_atfork( - prepare: Option, - parent: Option, - child: Option, - ) -> c_int; pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; pub fn getgrouplist( user: *const c_char, @@ -6587,18 +6199,8 @@ extern "C" { groups: *mut crate::gid_t, ngroups: *mut c_int, ) -> c_int; - pub fn pthread_mutexattr_getpshared( - attr: *const pthread_mutexattr_t, - pshared: *mut c_int, - ) -> c_int; pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; - pub fn pthread_create( - native: *mut crate::pthread_t, - attr: *const crate::pthread_attr_t, - f: extern "C" fn(*mut c_void) -> *mut c_void, - value: *mut c_void, - ) -> c_int; pub fn dl_iterate_phdr( callback: Option< unsafe extern "C" fn( @@ -6751,7 +6353,6 @@ extern "C" { pub fn gethostid() -> c_long; - pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; pub fn memmem( haystack: *const c_void, haystacklen: size_t, @@ -6760,8 +6361,6 @@ extern "C" { ) -> *mut c_void; pub fn sched_getcpu() -> c_int; - pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; - pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; pub fn getopt_long( argc: c_int, argv: *const *mut c_char, @@ -6770,8 +6369,6 @@ extern "C" { longindex: *mut c_int, ) -> c_int; - pub fn pthread_once(control: *mut pthread_once_t, routine: extern "C" fn()) -> c_int; - pub fn copy_file_range( fd_in: c_int, off_in: *mut off64_t, @@ -6788,7 +6385,7 @@ extern "C" { // // * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones cfg_if! { - if #[cfg(not(target_env = "musl"))] { + if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] { extern "C" { pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int; pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index a04f05ea50db8..8051e6cf8253b 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -70,41 +70,41 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, - __unused1: c_int, + __unused1: Padding, pub shm_dtime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub shm_ctime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, pub msg_stime: crate::time_t, - __unused1: c_int, + __unused1: Padding, pub msg_rtime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub msg_ctime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct mcontext_t { @@ -130,9 +130,6 @@ s! { pub arm_cpsr: c_ulong, pub fault_address: c_ulong, } -} - -s_no_extra_traits! { pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -141,37 +138,15 @@ s_no_extra_traits! { pub uc_sigmask: crate::sigset_t, pub uc_regspace: [c_ulonglong; 64], } +} +s_no_extra_traits! { #[repr(align(8))] pub struct max_align_t { priv_: (i64, i64), } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - } - } - } -} - pub const SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; @@ -272,9 +247,6 @@ pub const MAP_NONBLOCK: c_int = 0x010000; pub const MAP_STACK: c_int = 0x020000; pub const MAP_SYNC: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const EDEADLK: c_int = 35; pub const ENAMETOOLONG: c_int = 36; pub const ENOLCK: c_int = 37; diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index b687953554184..54bfbda97ed5c 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -24,7 +24,7 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct stack_t { @@ -55,33 +55,33 @@ s! { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, - __unused1: c_int, + __unused1: Padding, pub shm_dtime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub shm_ctime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, pub msg_stime: crate::time_t, - __unused1: c_int, + __unused1: Padding, pub msg_rtime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub msg_ctime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } } @@ -244,8 +244,6 @@ pub const SIGXFSZ: c_int = 25; pub const SIG_SETMASK: c_int = 2; // FIXME(musl) check these pub const SIG_BLOCK: c_int = 0x000000; pub const SIG_UNBLOCK: c_int = 0x01; -pub const SOCK_DGRAM: c_int = 2; -pub const SOCK_STREAM: c_int = 1; pub const SOL_CAIF: c_int = 278; pub const SOL_IUCV: c_int = 277; pub const SOL_KCM: c_int = 281; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index a623ff9a9f757..d563c5e420a12 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -6,14 +6,14 @@ pub type wchar_t = c_int; s! { pub struct stat { pub st_dev: crate::dev_t, - __st_padding1: [c_long; 2], + __st_padding1: Padding<[c_long; 2]>, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __st_padding2: [c_long; 2], + __st_padding2: Padding<[c_long; 2]>, pub st_size: off_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -22,21 +22,21 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - __st_padding3: c_long, + __st_padding3: Padding, pub st_blocks: crate::blkcnt_t, - __st_padding4: [c_long; 14], + __st_padding4: Padding<[c_long; 14]>, } pub struct stat64 { pub st_dev: crate::dev_t, - __st_padding1: [c_long; 2], + __st_padding1: Padding<[c_long; 2]>, pub st_ino: crate::ino64_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __st_padding2: [c_long; 2], + __st_padding2: Padding<[c_long; 2]>, pub st_size: off_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -45,9 +45,9 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - __st_padding3: c_long, + __st_padding3: Padding, pub st_blocks: crate::blkcnt64_t, - __st_padding4: [c_long; 14], + __st_padding4: Padding<[c_long; 14]>, } pub struct stack_t { @@ -72,8 +72,8 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -85,34 +85,34 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, #[cfg(target_endian = "big")] - __unused1: c_int, + __unused1: Padding, pub msg_stime: crate::time_t, #[cfg(target_endian = "little")] - __unused1: c_int, + __unused1: Padding, #[cfg(target_endian = "big")] - __unused2: c_int, + __unused2: Padding, pub msg_rtime: crate::time_t, #[cfg(target_endian = "little")] - __unused2: c_int, + __unused2: Padding, #[cfg(target_endian = "big")] - __unused3: c_int, + __unused3: Padding, pub msg_ctime: crate::time_t, #[cfg(target_endian = "little")] - __unused3: c_int, + __unused3: Padding, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct statfs { @@ -338,9 +338,6 @@ pub const ENOTRECOVERABLE: c_int = 166; pub const EHWPOISON: c_int = 168; pub const ERFKILL: c_int = 167; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; - pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 8; pub const SA_NOCLDWAIT: c_int = 0x10000; @@ -363,7 +360,6 @@ pub const SIGTSTP: c_int = 24; pub const SIGURG: c_int = 21; pub const SIGIO: c_int = 22; pub const SIGSYS: c_int = 12; -pub const SIGSTKFLT: c_int = 7; pub const SIGPOLL: c_int = crate::SIGIO; pub const SIGPWR: c_int = 19; pub const SIG_SETMASK: c_int = 3; diff --git a/src/unix/linux_like/linux/musl/b32/mod.rs b/src/unix/linux_like/linux/musl/b32/mod.rs index 00b3d7705090f..ac76d3c659700 100644 --- a/src/unix/linux_like/linux/musl/b32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mod.rs @@ -15,22 +15,6 @@ s! { __val: [c_ulong; 32], } - pub struct msghdr { - pub msg_name: *mut c_void, - pub msg_namelen: crate::socklen_t, - pub msg_iov: *mut crate::iovec, - pub msg_iovlen: c_int, - pub msg_control: *mut c_void, - pub msg_controllen: crate::socklen_t, - pub msg_flags: c_int, - } - - pub struct cmsghdr { - pub cmsg_len: crate::socklen_t, - pub cmsg_level: c_int, - pub cmsg_type: c_int, - } - pub struct sem_t { __val: [c_int; 4], } diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index a07dfda17794e..984c88b86d143 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -33,7 +33,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 2], + __unused: Padding<[c_long; 2]>, } pub struct stat64 { @@ -54,7 +54,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 2], + __unused: Padding<[c_long; 2]>, } pub struct stack_t { @@ -79,43 +79,43 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __pad1: c_int, - __pad2: c_longlong, - __pad3: c_longlong, + __pad1: Padding, + __pad2: Padding, + __pad3: Padding, } pub struct shmid_ds { pub shm_perm: crate::ipc_perm, - __unused1: c_int, + __unused1: Padding, pub shm_atime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub shm_dtime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub shm_ctime: crate::time_t, - __unused4: c_int, + __unused4: Padding, pub shm_segsz: size_t, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, - __unused1: c_int, + __unused1: Padding, pub msg_stime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub msg_rtime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub msg_ctime: crate::time_t, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } } @@ -223,9 +223,6 @@ pub const MAP_SYNC: c_int = 0x080000; pub const PTRACE_SYSEMU: c_int = 0x1d; pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 0x1e; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const EDEADLK: c_int = 35; pub const ENAMETOOLONG: c_int = 36; pub const ENOLCK: c_int = 37; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index ea4b51f006f0f..4237c579a1a7f 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; @@ -25,7 +28,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2usize], + __unused: Padding<[c_int; 2usize]>, } pub struct stat64 { @@ -47,7 +50,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct stack_t { @@ -63,11 +66,11 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -79,25 +82,25 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused5: c_ulong, - __unused6: c_ulong, + __unused5: Padding, + __unused6: Padding, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, pub msg_stime: crate::time_t, - __unused1: c_int, + __unused1: Padding, pub msg_rtime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub msg_ctime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } } @@ -204,8 +207,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 4; pub const SA_NOCLDWAIT: c_int = 2; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index ae8b7d761dd6f..c51614240dbc3 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -74,45 +74,43 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, - __unused1: c_int, + __unused1: Padding, pub shm_dtime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub shm_ctime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, pub msg_stime: crate::time_t, - __unused1: c_int, + __unused1: Padding, pub msg_rtime: crate::time_t, - __unused2: c_int, + __unused2: Padding, pub msg_ctime: crate::time_t, - __unused3: c_int, + __unused3: Padding, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } -} -s_no_extra_traits! { pub struct user_fpxregs_struct { pub cwd: c_ushort, pub swd: c_ushort, @@ -123,7 +121,7 @@ s_no_extra_traits! { pub foo: c_long, pub fos: c_long, pub mxcsr: c_long, - __reserved: c_long, + __reserved: Padding, pub st_space: [c_long; 32], pub xmm_space: [c_long; 32], padding: [c_long; 56], @@ -137,83 +135,15 @@ s_no_extra_traits! { pub uc_sigmask: crate::sigset_t, __private: [u8; 112], } +} +s_no_extra_traits! { #[repr(align(8))] pub struct max_align_t { priv_: [f64; 3], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for user_fpxregs_struct { - fn eq(&self, other: &user_fpxregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.twd == other.twd - && self.fop == other.fop - && self.fip == other.fip - && self.fcs == other.fcs - && self.foo == other.foo - && self.fos == other.fos - && self.mxcsr == other.mxcsr - // Ignore __reserved field - && self.st_space == other.st_space - && self.xmm_space == other.xmm_space - // Ignore padding field - } - } - - impl Eq for user_fpxregs_struct {} - - impl hash::Hash for user_fpxregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.twd.hash(state); - self.fop.hash(state); - self.fip.hash(state); - self.fcs.hash(state); - self.foo.hash(state); - self.fos.hash(state); - self.mxcsr.hash(state); - // Ignore __reserved field - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - && self - .__private - .iter() - .zip(other.__private.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for ucontext_t {} - - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - self.__private.hash(state); - } - } - } -} - pub const SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; @@ -314,9 +244,6 @@ pub const MAP_NONBLOCK: c_int = 0x010000; pub const MAP_STACK: c_int = 0x020000; pub const MAP_SYNC: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const EDEADLK: c_int = 35; pub const ENAMETOOLONG: c_int = 36; pub const ENOLCK: c_int = 37; 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 67151a8d37116..cc52a179e7203 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -16,10 +16,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad0: c_ulong, + __pad0: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad1: c_int, + __pad1: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -27,7 +27,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_uint; 2], + __unused: Padding<[c_uint; 2]>, } pub struct stat64 { @@ -38,10 +38,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad0: c_ulong, + __pad0: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad1: c_int, + __pad1: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -49,7 +49,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_uint; 2], + __unused: Padding<[c_uint; 2]>, } pub struct user_regs_struct { @@ -84,8 +84,8 @@ s! { we'll follow that change in the future release." )] pub __seq: c_ushort, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } pub struct ucontext_t { @@ -103,7 +103,7 @@ s! { pub sp: c_ulong, pub pc: c_ulong, pub pstate: c_ulong, - __reserved: [u64; 512], + __reserved: Padding<[u64; 512]>, } #[repr(align(8))] @@ -279,9 +279,6 @@ pub const MAP_STACK: c_int = 0x020000; pub const MAP_HUGETLB: c_int = 0x040000; pub const MAP_SYNC: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000004; pub const SA_NOCLDWAIT: c_int = 0x00000002; diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index e014fbf48c0da..e973370a80c88 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -1,7 +1,10 @@ //! LoongArch-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; @@ -19,10 +22,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad1: crate::dev_t, + __pad1: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad2: c_int, + __pad2: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -30,7 +33,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2usize], + __unused: Padding<[c_int; 2usize]>, } pub struct stat64 { @@ -52,7 +55,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct ipc_perm { @@ -63,8 +66,8 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_int, - __unused1: c_ulong, - __unused2: c_ulong, + __unused1: Padding, + __unused2: Padding, } pub struct user_regs_struct { @@ -570,9 +573,6 @@ pub const VEOF: usize = 4; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 95dd37c889804..9626e3db78b8e 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -10,16 +10,16 @@ pub type blksize_t = i64; s! { pub struct stat { pub st_dev: crate::dev_t, - __pad1: [c_int; 3], + __pad1: Padding<[c_int; 3]>, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad2: [c_uint; 2], + __pad2: Padding<[c_uint; 2]>, pub st_size: off_t, - __pad3: c_int, + __pad3: Padding, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, @@ -27,23 +27,23 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - __pad4: c_uint, + __pad4: Padding, pub st_blocks: crate::blkcnt_t, - __pad5: [c_int; 14], + __pad5: Padding<[c_int; 14]>, } pub struct stat64 { pub st_dev: crate::dev_t, - __pad1: [c_int; 3], + __pad1: Padding<[c_int; 3]>, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad2: [c_uint; 2], + __pad2: Padding<[c_uint; 2]>, pub st_size: off_t, - __pad3: c_int, + __pad3: Padding, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, @@ -51,9 +51,9 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - __pad4: c_uint, + __pad4: Padding, pub st_blocks: crate::blkcnt_t, - __pad5: [c_int; 14], + __pad5: Padding<[c_int; 14]>, } pub struct stack_t { @@ -78,9 +78,9 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __pad1: c_int, - __unused1: c_ulong, - __unused2: c_ulong, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct statfs { @@ -584,9 +584,6 @@ pub const MAP_NONBLOCK: c_int = 0x20000; pub const MAP_STACK: c_int = 0x40000; pub const MAP_HUGETLB: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; - pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000008; pub const SA_NOCLDWAIT: c_int = 0x00010000; diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index 1bfd812ab2a34..6365dbece4578 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -30,8 +30,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __pad1: c_ulong, - __pad2: c_ulong, + __pad1: Padding, + __pad2: Padding, } pub struct msqid_ds { @@ -44,36 +44,8 @@ s! { pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __pad1: c_ulong, - __pad2: c_ulong, - } - - pub struct msghdr { - pub msg_name: *mut c_void, - pub msg_namelen: crate::socklen_t, - pub msg_iov: *mut crate::iovec, - #[cfg(target_endian = "big")] - __pad1: c_int, - pub msg_iovlen: c_int, - #[cfg(target_endian = "little")] - __pad1: c_int, - pub msg_control: *mut c_void, - #[cfg(target_endian = "big")] - __pad2: c_int, - pub msg_controllen: crate::socklen_t, - #[cfg(target_endian = "little")] - __pad2: c_int, - pub msg_flags: c_int, - } - - pub struct cmsghdr { - #[cfg(target_endian = "big")] - pub __pad1: c_int, - pub cmsg_len: crate::socklen_t, - #[cfg(target_endian = "little")] - pub __pad1: c_int, - pub cmsg_level: c_int, - pub cmsg_type: c_int, + __pad1: Padding, + __pad2: Padding, } pub struct sem_t { diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index bbcd382211dfd..dbf20c565e438 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -26,7 +26,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -37,7 +37,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct stat64 { @@ -47,7 +47,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -58,7 +58,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __reserved: [c_long; 3], + __reserved: Padding<[c_long; 3]>, } pub struct shmid_ds { @@ -70,7 +70,7 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, - __unused: [c_ulong; 2], + __unused: Padding<[c_ulong; 2]>, } pub struct ipc_perm { @@ -89,8 +89,8 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } } @@ -214,9 +214,6 @@ pub const MAP_SYNC: c_int = 0x080000; pub const PTRACE_SYSEMU: c_int = 0x1d; pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 0x1e; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000004; pub const SA_NOCLDWAIT: c_int = 0x00000002; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 8389af961cf58..b987f8358b365 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; @@ -30,7 +33,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2usize], + __unused: Padding<[c_int; 2usize]>, } pub struct stat64 { @@ -52,7 +55,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + __unused: Padding<[c_int; 2]>, } pub struct ipc_perm { @@ -62,11 +65,11 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } #[repr(align(8))] @@ -564,9 +567,6 @@ pub const VEOF: usize = 4; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 06cc61685b7ac..a7c4cb5d95f9c 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -26,8 +26,8 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __pad1: c_long, - __pad2: c_long, + __pad1: Padding, + __pad2: Padding, } pub struct stat { @@ -47,7 +47,7 @@ s! { pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct stat64 { @@ -67,7 +67,7 @@ s! { pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct statfs { @@ -84,6 +84,31 @@ s! { pub f_flags: c_uint, pub f_spare: [c_uint; 4], } + + pub struct __psw_t { + pub mask: c_ulong, + pub addr: c_ulong, + } + + pub struct fpregset_t { + pub fpc: c_uint, + pub fprs: [fpreg_t; 16], + } + + pub struct mcontext_t { + pub psw: __psw_t, + pub gregs: [c_ulong; 16], + pub aregs: [c_uint; 16], + pub fpregs: fpregset_t, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + } } s_no_extra_traits! { @@ -140,9 +165,6 @@ pub const SIGSTKSZ: size_t = 0x2000; pub const MINSIGSTKSZ: size_t = 2048; pub const SIG_SETMASK: c_int = 2; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const O_NOCTTY: c_int = 256; pub const O_SYNC: c_int = 1052672; pub const O_RSYNC: c_int = 1052672; diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs index 29750e79e17e6..d4d0fe69839b3 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -17,7 +17,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -28,7 +28,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct stat64 { @@ -38,7 +38,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -49,7 +49,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __reserved: [c_long; 3], + __reserved: Padding<[c_long; 3]>, } pub struct ipc_perm { @@ -68,8 +68,8 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } } @@ -584,9 +584,6 @@ pub const VEOF: usize = 4; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; @@ -681,7 +678,7 @@ pub const TOSTOP: crate::tcflag_t = 0x00000100; pub const FLUSHO: crate::tcflag_t = 0x00001000; cfg_if! { - if #[cfg(target_vendor = "wali")] { + if #[cfg(all(target_family = "wasm", target_env = "musl"))] { mod wali; pub use self::wali::*; } diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs b/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs index bda5c241c1d2d..f347e8a69ddd0 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs @@ -1,400 +1,400 @@ //! WebAssembly Linux Interface syscall specification +use crate::prelude::*; + // --- Autogenerated from WALI/scripts/autogen.py --- #[link(wasm_import_module = "wali")] extern "C" { /* 0 */ #[link_name = "SYS_read"] - pub fn __syscall_SYS_read(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_read(a1: i32, a2: i32, a3: u32) -> c_long; /* 1 */ #[link_name = "SYS_write"] - pub fn __syscall_SYS_write(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_write(a1: i32, a2: i32, a3: u32) -> c_long; /* 2 */ #[link_name = "SYS_open"] - pub fn __syscall_SYS_open(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_open(a1: i32, a2: i32, a3: i32) -> c_long; /* 3 */ #[link_name = "SYS_close"] - pub fn __syscall_SYS_close(a1: i32) -> ::c_long; + pub fn __syscall_SYS_close(a1: i32) -> c_long; /* 4 */ #[link_name = "SYS_stat"] - pub fn __syscall_SYS_stat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_stat(a1: i32, a2: i32) -> c_long; /* 5 */ #[link_name = "SYS_fstat"] - pub fn __syscall_SYS_fstat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fstat(a1: i32, a2: i32) -> c_long; /* 6 */ #[link_name = "SYS_lstat"] - pub fn __syscall_SYS_lstat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_lstat(a1: i32, a2: i32) -> c_long; /* 7 */ #[link_name = "SYS_poll"] - pub fn __syscall_SYS_poll(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_poll(a1: i32, a2: u32, a3: i32) -> c_long; /* 8 */ #[link_name = "SYS_lseek"] - pub fn __syscall_SYS_lseek(a1: i32, a2: i64, a3: i32) -> ::c_long; + pub fn __syscall_SYS_lseek(a1: i32, a2: i64, a3: i32) -> c_long; /* 9 */ #[link_name = "SYS_mmap"] - pub fn __syscall_SYS_mmap(a1: i32, a2: u32, a3: i32, a4: i32, a5: i32, a6: i64) -> ::c_long; + pub fn __syscall_SYS_mmap(a1: i32, a2: u32, a3: i32, a4: i32, a5: i32, a6: i64) -> c_long; /* 10 */ #[link_name = "SYS_mprotect"] - pub fn __syscall_SYS_mprotect(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_mprotect(a1: i32, a2: u32, a3: i32) -> c_long; /* 11 */ #[link_name = "SYS_munmap"] - pub fn __syscall_SYS_munmap(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_munmap(a1: i32, a2: u32) -> c_long; /* 12 */ #[link_name = "SYS_brk"] - pub fn __syscall_SYS_brk(a1: i32) -> ::c_long; + pub fn __syscall_SYS_brk(a1: i32) -> c_long; /* 13 */ #[link_name = "SYS_rt_sigaction"] - pub fn __syscall_SYS_rt_sigaction(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigaction(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 14 */ #[link_name = "SYS_rt_sigprocmask"] - pub fn __syscall_SYS_rt_sigprocmask(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigprocmask(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 15 */ #[link_name = "SYS_rt_sigreturn"] - pub fn __syscall_SYS_rt_sigreturn(a1: i64) -> ::c_long; + pub fn __syscall_SYS_rt_sigreturn(a1: i64) -> c_long; /* 16 */ #[link_name = "SYS_ioctl"] - pub fn __syscall_SYS_ioctl(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_ioctl(a1: i32, a2: i32, a3: i32) -> c_long; /* 17 */ #[link_name = "SYS_pread64"] - pub fn __syscall_SYS_pread64(a1: i32, a2: i32, a3: u32, a4: i64) -> ::c_long; + pub fn __syscall_SYS_pread64(a1: i32, a2: i32, a3: u32, a4: i64) -> c_long; /* 18 */ #[link_name = "SYS_pwrite64"] - pub fn __syscall_SYS_pwrite64(a1: i32, a2: i32, a3: u32, a4: i64) -> ::c_long; + pub fn __syscall_SYS_pwrite64(a1: i32, a2: i32, a3: u32, a4: i64) -> c_long; /* 19 */ #[link_name = "SYS_readv"] - pub fn __syscall_SYS_readv(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_readv(a1: i32, a2: i32, a3: i32) -> c_long; /* 20 */ #[link_name = "SYS_writev"] - pub fn __syscall_SYS_writev(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_writev(a1: i32, a2: i32, a3: i32) -> c_long; /* 21 */ #[link_name = "SYS_access"] - pub fn __syscall_SYS_access(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_access(a1: i32, a2: i32) -> c_long; /* 22 */ #[link_name = "SYS_pipe"] - pub fn __syscall_SYS_pipe(a1: i32) -> ::c_long; + pub fn __syscall_SYS_pipe(a1: i32) -> c_long; /* 23 */ #[link_name = "SYS_select"] - pub fn __syscall_SYS_select(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_select(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 24 */ #[link_name = "SYS_sched_yield"] - pub fn __syscall_SYS_sched_yield() -> ::c_long; + pub fn __syscall_SYS_sched_yield() -> c_long; /* 25 */ #[link_name = "SYS_mremap"] - pub fn __syscall_SYS_mremap(a1: i32, a2: u32, a3: u32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_mremap(a1: i32, a2: u32, a3: u32, a4: i32, a5: i32) -> c_long; /* 26 */ #[link_name = "SYS_msync"] - pub fn __syscall_SYS_msync(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_msync(a1: i32, a2: u32, a3: i32) -> c_long; /* 28 */ #[link_name = "SYS_madvise"] - pub fn __syscall_SYS_madvise(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_madvise(a1: i32, a2: u32, a3: i32) -> c_long; /* 32 */ #[link_name = "SYS_dup"] - pub fn __syscall_SYS_dup(a1: i32) -> ::c_long; + pub fn __syscall_SYS_dup(a1: i32) -> c_long; /* 33 */ #[link_name = "SYS_dup2"] - pub fn __syscall_SYS_dup2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_dup2(a1: i32, a2: i32) -> c_long; /* 35 */ #[link_name = "SYS_nanosleep"] - pub fn __syscall_SYS_nanosleep(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_nanosleep(a1: i32, a2: i32) -> c_long; /* 37 */ #[link_name = "SYS_alarm"] - pub fn __syscall_SYS_alarm(a1: i32) -> ::c_long; + pub fn __syscall_SYS_alarm(a1: i32) -> c_long; /* 38 */ #[link_name = "SYS_setitimer"] - pub fn __syscall_SYS_setitimer(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setitimer(a1: i32, a2: i32, a3: i32) -> c_long; /* 39 */ #[link_name = "SYS_getpid"] - pub fn __syscall_SYS_getpid() -> ::c_long; + pub fn __syscall_SYS_getpid() -> c_long; /* 41 */ #[link_name = "SYS_socket"] - pub fn __syscall_SYS_socket(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_socket(a1: i32, a2: i32, a3: i32) -> c_long; /* 42 */ #[link_name = "SYS_connect"] - pub fn __syscall_SYS_connect(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_connect(a1: i32, a2: i32, a3: u32) -> c_long; /* 43 */ #[link_name = "SYS_accept"] - pub fn __syscall_SYS_accept(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_accept(a1: i32, a2: i32, a3: i32) -> c_long; /* 44 */ #[link_name = "SYS_sendto"] - pub fn __syscall_SYS_sendto(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: u32) -> ::c_long; + pub fn __syscall_SYS_sendto(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: u32) -> c_long; /* 45 */ #[link_name = "SYS_recvfrom"] - pub fn __syscall_SYS_recvfrom(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: i32) - -> ::c_long; + pub fn __syscall_SYS_recvfrom(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: i32) -> c_long; /* 46 */ #[link_name = "SYS_sendmsg"] - pub fn __syscall_SYS_sendmsg(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_sendmsg(a1: i32, a2: i32, a3: i32) -> c_long; /* 47 */ #[link_name = "SYS_recvmsg"] - pub fn __syscall_SYS_recvmsg(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_recvmsg(a1: i32, a2: i32, a3: i32) -> c_long; /* 48 */ #[link_name = "SYS_shutdown"] - pub fn __syscall_SYS_shutdown(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_shutdown(a1: i32, a2: i32) -> c_long; /* 49 */ #[link_name = "SYS_bind"] - pub fn __syscall_SYS_bind(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_bind(a1: i32, a2: i32, a3: u32) -> c_long; /* 50 */ #[link_name = "SYS_listen"] - pub fn __syscall_SYS_listen(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_listen(a1: i32, a2: i32) -> c_long; /* 51 */ #[link_name = "SYS_getsockname"] - pub fn __syscall_SYS_getsockname(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getsockname(a1: i32, a2: i32, a3: i32) -> c_long; /* 52 */ #[link_name = "SYS_getpeername"] - pub fn __syscall_SYS_getpeername(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getpeername(a1: i32, a2: i32, a3: i32) -> c_long; /* 53 */ #[link_name = "SYS_socketpair"] - pub fn __syscall_SYS_socketpair(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_socketpair(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 54 */ #[link_name = "SYS_setsockopt"] - pub fn __syscall_SYS_setsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: u32) -> ::c_long; + pub fn __syscall_SYS_setsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: u32) -> c_long; /* 55 */ #[link_name = "SYS_getsockopt"] - pub fn __syscall_SYS_getsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_getsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 57 */ #[link_name = "SYS_fork"] - pub fn __syscall_SYS_fork() -> ::c_long; + pub fn __syscall_SYS_fork() -> c_long; /* 59 */ #[link_name = "SYS_execve"] - pub fn __syscall_SYS_execve(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_execve(a1: i32, a2: i32, a3: i32) -> c_long; /* 60 */ #[link_name = "SYS_exit"] - pub fn __syscall_SYS_exit(a1: i32) -> ::c_long; + pub fn __syscall_SYS_exit(a1: i32) -> c_long; /* 61 */ #[link_name = "SYS_wait4"] - pub fn __syscall_SYS_wait4(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_wait4(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 62 */ #[link_name = "SYS_kill"] - pub fn __syscall_SYS_kill(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_kill(a1: i32, a2: i32) -> c_long; /* 63 */ #[link_name = "SYS_uname"] - pub fn __syscall_SYS_uname(a1: i32) -> ::c_long; + pub fn __syscall_SYS_uname(a1: i32) -> c_long; /* 72 */ #[link_name = "SYS_fcntl"] - pub fn __syscall_SYS_fcntl(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_fcntl(a1: i32, a2: i32, a3: i32) -> c_long; /* 73 */ #[link_name = "SYS_flock"] - pub fn __syscall_SYS_flock(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_flock(a1: i32, a2: i32) -> c_long; /* 74 */ #[link_name = "SYS_fsync"] - pub fn __syscall_SYS_fsync(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fsync(a1: i32) -> c_long; /* 75 */ #[link_name = "SYS_fdatasync"] - pub fn __syscall_SYS_fdatasync(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fdatasync(a1: i32) -> c_long; /* 77 */ #[link_name = "SYS_ftruncate"] - pub fn __syscall_SYS_ftruncate(a1: i32, a2: i64) -> ::c_long; + pub fn __syscall_SYS_ftruncate(a1: i32, a2: i64) -> c_long; /* 78 */ #[link_name = "SYS_getdents"] - pub fn __syscall_SYS_getdents(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getdents(a1: i32, a2: i32, a3: i32) -> c_long; /* 79 */ #[link_name = "SYS_getcwd"] - pub fn __syscall_SYS_getcwd(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_getcwd(a1: i32, a2: u32) -> c_long; /* 80 */ #[link_name = "SYS_chdir"] - pub fn __syscall_SYS_chdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_chdir(a1: i32) -> c_long; /* 81 */ #[link_name = "SYS_fchdir"] - pub fn __syscall_SYS_fchdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fchdir(a1: i32) -> c_long; /* 82 */ #[link_name = "SYS_rename"] - pub fn __syscall_SYS_rename(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_rename(a1: i32, a2: i32) -> c_long; /* 83 */ #[link_name = "SYS_mkdir"] - pub fn __syscall_SYS_mkdir(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_mkdir(a1: i32, a2: i32) -> c_long; /* 84 */ #[link_name = "SYS_rmdir"] - pub fn __syscall_SYS_rmdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_rmdir(a1: i32) -> c_long; /* 86 */ #[link_name = "SYS_link"] - pub fn __syscall_SYS_link(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_link(a1: i32, a2: i32) -> c_long; /* 87 */ #[link_name = "SYS_unlink"] - pub fn __syscall_SYS_unlink(a1: i32) -> ::c_long; + pub fn __syscall_SYS_unlink(a1: i32) -> c_long; /* 88 */ #[link_name = "SYS_symlink"] - pub fn __syscall_SYS_symlink(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_symlink(a1: i32, a2: i32) -> c_long; /* 89 */ #[link_name = "SYS_readlink"] - pub fn __syscall_SYS_readlink(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_readlink(a1: i32, a2: i32, a3: u32) -> c_long; /* 90 */ #[link_name = "SYS_chmod"] - pub fn __syscall_SYS_chmod(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_chmod(a1: i32, a2: i32) -> c_long; /* 91 */ #[link_name = "SYS_fchmod"] - pub fn __syscall_SYS_fchmod(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fchmod(a1: i32, a2: i32) -> c_long; /* 92 */ #[link_name = "SYS_chown"] - pub fn __syscall_SYS_chown(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_chown(a1: i32, a2: i32, a3: i32) -> c_long; /* 93 */ #[link_name = "SYS_fchown"] - pub fn __syscall_SYS_fchown(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_fchown(a1: i32, a2: i32, a3: i32) -> c_long; /* 95 */ #[link_name = "SYS_umask"] - pub fn __syscall_SYS_umask(a1: i32) -> ::c_long; + pub fn __syscall_SYS_umask(a1: i32) -> c_long; /* 97 */ #[link_name = "SYS_getrlimit"] - pub fn __syscall_SYS_getrlimit(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getrlimit(a1: i32, a2: i32) -> c_long; /* 98 */ #[link_name = "SYS_getrusage"] - pub fn __syscall_SYS_getrusage(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getrusage(a1: i32, a2: i32) -> c_long; /* 99 */ #[link_name = "SYS_sysinfo"] - pub fn __syscall_SYS_sysinfo(a1: i32) -> ::c_long; + pub fn __syscall_SYS_sysinfo(a1: i32) -> c_long; /* 102 */ #[link_name = "SYS_getuid"] - pub fn __syscall_SYS_getuid() -> ::c_long; + pub fn __syscall_SYS_getuid() -> c_long; /* 104 */ #[link_name = "SYS_getgid"] - pub fn __syscall_SYS_getgid() -> ::c_long; + pub fn __syscall_SYS_getgid() -> c_long; /* 105 */ #[link_name = "SYS_setuid"] - pub fn __syscall_SYS_setuid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_setuid(a1: i32) -> c_long; /* 106 */ #[link_name = "SYS_setgid"] - pub fn __syscall_SYS_setgid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_setgid(a1: i32) -> c_long; /* 107 */ #[link_name = "SYS_geteuid"] - pub fn __syscall_SYS_geteuid() -> ::c_long; + pub fn __syscall_SYS_geteuid() -> c_long; /* 108 */ #[link_name = "SYS_getegid"] - pub fn __syscall_SYS_getegid() -> ::c_long; + pub fn __syscall_SYS_getegid() -> c_long; /* 109 */ #[link_name = "SYS_setpgid"] - pub fn __syscall_SYS_setpgid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setpgid(a1: i32, a2: i32) -> c_long; /* 110 */ #[link_name = "SYS_getppid"] - pub fn __syscall_SYS_getppid() -> ::c_long; + pub fn __syscall_SYS_getppid() -> c_long; /* 112 */ #[link_name = "SYS_setsid"] - pub fn __syscall_SYS_setsid() -> ::c_long; + pub fn __syscall_SYS_setsid() -> c_long; /* 113 */ #[link_name = "SYS_setreuid"] - pub fn __syscall_SYS_setreuid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setreuid(a1: i32, a2: i32) -> c_long; /* 114 */ #[link_name = "SYS_setregid"] - pub fn __syscall_SYS_setregid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setregid(a1: i32, a2: i32) -> c_long; /* 115 */ #[link_name = "SYS_getgroups"] - pub fn __syscall_SYS_getgroups(a1: u32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getgroups(a1: u32, a2: i32) -> c_long; /* 116 */ #[link_name = "SYS_setgroups"] - pub fn __syscall_SYS_setgroups(a1: u32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setgroups(a1: u32, a2: i32) -> c_long; /* 117 */ #[link_name = "SYS_setresuid"] - pub fn __syscall_SYS_setresuid(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setresuid(a1: i32, a2: i32, a3: i32) -> c_long; /* 119 */ #[link_name = "SYS_setresgid"] - pub fn __syscall_SYS_setresgid(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setresgid(a1: i32, a2: i32, a3: i32) -> c_long; /* 121 */ #[link_name = "SYS_getpgid"] - pub fn __syscall_SYS_getpgid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_getpgid(a1: i32) -> c_long; /* 124 */ #[link_name = "SYS_getsid"] - pub fn __syscall_SYS_getsid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_getsid(a1: i32) -> c_long; /* 127 */ #[link_name = "SYS_rt_sigpending"] - pub fn __syscall_SYS_rt_sigpending(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigpending(a1: i32, a2: u32) -> c_long; /* 130 */ #[link_name = "SYS_rt_sigsuspend"] - pub fn __syscall_SYS_rt_sigsuspend(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigsuspend(a1: i32, a2: u32) -> c_long; /* 131 */ #[link_name = "SYS_sigaltstack"] - pub fn __syscall_SYS_sigaltstack(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_sigaltstack(a1: i32, a2: i32) -> c_long; /* 132 */ #[link_name = "SYS_utime"] - pub fn __syscall_SYS_utime(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_utime(a1: i32, a2: i32) -> c_long; /* 137 */ #[link_name = "SYS_statfs"] - pub fn __syscall_SYS_statfs(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_statfs(a1: i32, a2: i32) -> c_long; /* 138 */ #[link_name = "SYS_fstatfs"] - pub fn __syscall_SYS_fstatfs(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fstatfs(a1: i32, a2: i32) -> c_long; /* 157 */ #[link_name = "SYS_prctl"] - pub fn __syscall_SYS_prctl(a1: i32, a2: u64, a3: u64, a4: u64, a5: u64) -> ::c_long; + pub fn __syscall_SYS_prctl(a1: i32, a2: u64, a3: u64, a4: u64, a5: u64) -> c_long; /* 160 */ #[link_name = "SYS_setrlimit"] - pub fn __syscall_SYS_setrlimit(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setrlimit(a1: i32, a2: i32) -> c_long; /* 161 */ #[link_name = "SYS_chroot"] - pub fn __syscall_SYS_chroot(a1: i32) -> ::c_long; + pub fn __syscall_SYS_chroot(a1: i32) -> c_long; /* 186 */ #[link_name = "SYS_gettid"] - pub fn __syscall_SYS_gettid() -> ::c_long; + pub fn __syscall_SYS_gettid() -> c_long; /* 200 */ #[link_name = "SYS_tkill"] - pub fn __syscall_SYS_tkill(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_tkill(a1: i32, a2: i32) -> c_long; /* 202 */ #[link_name = "SYS_futex"] - pub fn __syscall_SYS_futex(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> ::c_long; + pub fn __syscall_SYS_futex(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> c_long; /* 204 */ #[link_name = "SYS_sched_getaffinity"] - pub fn __syscall_SYS_sched_getaffinity(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_sched_getaffinity(a1: i32, a2: u32, a3: i32) -> c_long; /* 217 */ #[link_name = "SYS_getdents64"] - pub fn __syscall_SYS_getdents64(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getdents64(a1: i32, a2: i32, a3: i32) -> c_long; /* 218 */ #[link_name = "SYS_set_tid_address"] - pub fn __syscall_SYS_set_tid_address(a1: i32) -> ::c_long; + pub fn __syscall_SYS_set_tid_address(a1: i32) -> c_long; /* 221 */ #[link_name = "SYS_fadvise"] - pub fn __syscall_SYS_fadvise(a1: i32, a2: i64, a3: i64, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fadvise(a1: i32, a2: i64, a3: i64, a4: i32) -> c_long; /* 228 */ #[link_name = "SYS_clock_gettime"] - pub fn __syscall_SYS_clock_gettime(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_clock_gettime(a1: i32, a2: i32) -> c_long; /* 229 */ #[link_name = "SYS_clock_getres"] - pub fn __syscall_SYS_clock_getres(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_clock_getres(a1: i32, a2: i32) -> c_long; /* 230 */ #[link_name = "SYS_clock_nanosleep"] - pub fn __syscall_SYS_clock_nanosleep(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_clock_nanosleep(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 231 */ #[link_name = "SYS_exit_group"] - pub fn __syscall_SYS_exit_group(a1: i32) -> ::c_long; + pub fn __syscall_SYS_exit_group(a1: i32) -> c_long; /* 233 */ #[link_name = "SYS_epoll_ctl"] - pub fn __syscall_SYS_epoll_ctl(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_epoll_ctl(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 257 */ #[link_name = "SYS_openat"] - pub fn __syscall_SYS_openat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_openat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 258 */ #[link_name = "SYS_mkdirat"] - pub fn __syscall_SYS_mkdirat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_mkdirat(a1: i32, a2: i32, a3: i32) -> c_long; /* 260 */ #[link_name = "SYS_fchownat"] - pub fn __syscall_SYS_fchownat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_fchownat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 262 */ #[link_name = "SYS_fstatat"] - pub fn __syscall_SYS_fstatat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fstatat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 263 */ #[link_name = "SYS_unlinkat"] - pub fn __syscall_SYS_unlinkat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_unlinkat(a1: i32, a2: i32, a3: i32) -> c_long; /* 265 */ #[link_name = "SYS_linkat"] - pub fn __syscall_SYS_linkat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_linkat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 266 */ #[link_name = "SYS_symlinkat"] - pub fn __syscall_SYS_symlinkat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_symlinkat(a1: i32, a2: i32, a3: i32) -> c_long; /* 267 */ #[link_name = "SYS_readlinkat"] - pub fn __syscall_SYS_readlinkat(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_readlinkat(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 268 */ #[link_name = "SYS_fchmodat"] - pub fn __syscall_SYS_fchmodat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fchmodat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 269 */ #[link_name = "SYS_faccessat"] - pub fn __syscall_SYS_faccessat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_faccessat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 270 */ #[link_name = "SYS_pselect6"] - pub fn __syscall_SYS_pselect6(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) - -> ::c_long; + pub fn __syscall_SYS_pselect6(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> c_long; /* 271 */ #[link_name = "SYS_ppoll"] - pub fn __syscall_SYS_ppoll(a1: i32, a2: u32, a3: i32, a4: i32, a5: u32) -> ::c_long; + pub fn __syscall_SYS_ppoll(a1: i32, a2: u32, a3: i32, a4: i32, a5: u32) -> c_long; /* 280 */ #[link_name = "SYS_utimensat"] - pub fn __syscall_SYS_utimensat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_utimensat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 281 */ #[link_name = "SYS_epoll_pwait"] pub fn __syscall_SYS_epoll_pwait( @@ -404,38 +404,38 @@ extern "C" { a4: i32, a5: i32, a6: u32, - ) -> ::c_long; + ) -> c_long; /* 284 */ #[link_name = "SYS_eventfd"] - pub fn __syscall_SYS_eventfd(a1: i32) -> ::c_long; + pub fn __syscall_SYS_eventfd(a1: i32) -> c_long; /* 288 */ #[link_name = "SYS_accept4"] - pub fn __syscall_SYS_accept4(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_accept4(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 290 */ #[link_name = "SYS_eventfd2"] - pub fn __syscall_SYS_eventfd2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_eventfd2(a1: i32, a2: i32) -> c_long; /* 291 */ #[link_name = "SYS_epoll_create1"] - pub fn __syscall_SYS_epoll_create1(a1: i32) -> ::c_long; + pub fn __syscall_SYS_epoll_create1(a1: i32) -> c_long; /* 292 */ #[link_name = "SYS_dup3"] - pub fn __syscall_SYS_dup3(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_dup3(a1: i32, a2: i32, a3: i32) -> c_long; /* 293 */ #[link_name = "SYS_pipe2"] - pub fn __syscall_SYS_pipe2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_pipe2(a1: i32, a2: i32) -> c_long; /* 302 */ #[link_name = "SYS_prlimit64"] - pub fn __syscall_SYS_prlimit64(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_prlimit64(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 316 */ #[link_name = "SYS_renameat2"] - pub fn __syscall_SYS_renameat2(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_renameat2(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 318 */ #[link_name = "SYS_getrandom"] - pub fn __syscall_SYS_getrandom(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getrandom(a1: i32, a2: u32, a3: i32) -> c_long; /* 332 */ #[link_name = "SYS_statx"] - pub fn __syscall_SYS_statx(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_statx(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 439 */ #[link_name = "SYS_faccessat2"] - pub fn __syscall_SYS_faccessat2(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_faccessat2(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; } diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index ce8319f015e97..364e16b5c9257 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -16,7 +16,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -27,7 +27,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused: [c_long; 3], + __unused: Padding<[c_long; 3]>, } pub struct stat64 { @@ -37,7 +37,7 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -48,7 +48,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __reserved: [c_long; 3], + __reserved: Padding<[c_long; 3]>, } pub struct user_regs_struct { @@ -91,12 +91,12 @@ s! { pub start_code: c_ulong, pub start_stack: c_ulong, pub signal: c_long, - __reserved: c_int, + __reserved: Padding, #[cfg(target_pointer_width = "32")] - __pad1: u32, + __pad1: Padding, pub u_ar0: *mut user_regs_struct, #[cfg(target_pointer_width = "32")] - __pad2: u32, + __pad2: Padding, pub u_fpstate: *mut user_fpregs_struct, pub magic: c_ulong, pub u_comm: [c_char; 32], @@ -127,8 +127,8 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, pub __seq: c_int, - __unused1: c_long, - __unused2: c_long, + __unused1: Padding, + __unused2: Padding, } #[repr(align(8))] @@ -145,9 +145,7 @@ s! { pub set_tid_size: c_ulonglong, pub cgroup: c_ulonglong, } -} -s_no_extra_traits! { pub struct user_fpregs_struct { pub cwd: c_ushort, pub swd: c_ushort, @@ -170,82 +168,15 @@ s_no_extra_traits! { pub uc_sigmask: crate::sigset_t, __private: [u8; 512], } +} +s_no_extra_traits! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for user_fpregs_struct { - fn eq(&self, other: &user_fpregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self.st_space == other.st_space - && self - .xmm_space - .iter() - .zip(other.xmm_space.iter()) - .all(|(a, b)| a == b) - // Ignore padding field - } - } - - impl Eq for user_fpregs_struct {} - - impl hash::Hash for user_fpregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - && self - .__private - .iter() - .zip(other.__private.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for ucontext_t {} - - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - self.__private.hash(state); - } - } - } -} - // Syscall table pub const SYS_read: c_long = 0; @@ -818,9 +749,6 @@ pub const VEOF: usize = 4; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; diff --git a/src/unix/linux_like/linux/musl/lfs64.rs b/src/unix/linux_like/linux/musl/lfs64.rs index e6506fd3d385d..4d595fc42d72f 100644 --- a/src/unix/linux_like/linux/musl/lfs64.rs +++ b/src/unix/linux_like/linux/musl/lfs64.rs @@ -117,7 +117,10 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. -pub use crate::{open as open64, openat as openat64}; +pub use crate::{ + open as open64, + openat as openat64, +}; #[inline] pub unsafe extern "C" fn posix_fadvise64( diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 4bc11449145c7..e3f58b4ebf149 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -63,36 +63,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { @@ -192,7 +185,7 @@ s! { #[cfg(target_endian = "little")] pub f_fsid: c_ulong, #[cfg(target_pointer_width = "32")] - __pad: c_int, + __pad: Padding, #[cfg(target_endian = "big")] pub f_fsid: c_ulong, pub f_flag: c_ulong, @@ -212,7 +205,7 @@ s! { #[cfg(target_endian = "little")] pub f_fsid: c_ulong, #[cfg(target_pointer_width = "32")] - __pad: c_int, + __pad: Padding, #[cfg(target_endian = "big")] pub f_fsid: c_ulong, pub f_flag: c_ulong, @@ -252,7 +245,7 @@ s! { pub struct regex_t { __re_nsub: size_t, __opaque: *mut c_void, - __padding: [*mut c_void; 4usize], + __padding: Padding<[*mut c_void; 4usize]>, __nsub2: size_t, __padding2: c_char, } @@ -422,9 +415,7 @@ s! { pub f_flags: c_ulong, pub f_spare: [c_ulong; 4], } -} -s_no_extra_traits! { pub struct sysinfo { pub uptime: c_ulong, pub loads: [c_ulong; 3], @@ -444,7 +435,7 @@ s_no_extra_traits! { pub struct utmpx { pub ut_type: c_short, - __ut_pad1: c_short, + __ut_pad1: Padding, pub ut_pid: crate::pid_t, pub ut_line: [c_char; 32], pub ut_id: [c_char; 4], @@ -462,110 +453,18 @@ s_no_extra_traits! { #[cfg(musl_v1_2_3)] #[cfg(not(target_endian = "little"))] - __ut_pad2: c_int, + __ut_pad2: Padding, #[cfg(musl_v1_2_3)] pub ut_session: c_int, #[cfg(musl_v1_2_3)] #[cfg(target_endian = "little")] - __ut_pad2: c_int, + __ut_pad2: Padding, pub ut_tv: crate::timeval, pub ut_addr_v6: [c_uint; 4], - __unused: [c_char; 20], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sysinfo { - fn eq(&self, other: &sysinfo) -> bool { - self.uptime == other.uptime - && self.loads == other.loads - && self.totalram == other.totalram - && self.freeram == other.freeram - && self.sharedram == other.sharedram - && self.bufferram == other.bufferram - && self.totalswap == other.totalswap - && self.freeswap == other.freeswap - && self.procs == other.procs - && self.pad == other.pad - && self.totalhigh == other.totalhigh - && self.freehigh == other.freehigh - && self.mem_unit == other.mem_unit - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sysinfo {} - - impl hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { - self.uptime.hash(state); - self.loads.hash(state); - self.totalram.hash(state); - self.freeram.hash(state); - self.sharedram.hash(state); - self.bufferram.hash(state); - self.totalswap.hash(state); - self.freeswap.hash(state); - self.procs.hash(state); - self.pad.hash(state); - self.totalhigh.hash(state); - self.freehigh.hash(state); - self.mem_unit.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for utmpx { - #[allow(deprecated)] - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - //&& self.__ut_pad1 == other.__ut_pad1 - && self.ut_pid == other.ut_pid - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_user == other.ut_user - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a,b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - //&& self.__ut_pad2 == other.__ut_pad2 - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.__unused == other.__unused - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - #[allow(deprecated)] - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - //self.__ut_pad1.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - //self.__ut_pad2.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.__unused.hash(state); - } - } + __unused: Padding<[c_char; 20]>, } } @@ -848,20 +747,6 @@ cfg_if! { } extern "C" { - pub fn sendmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_uint, - ) -> c_int; - pub fn recvmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_uint, - timeout: *mut crate::timespec, - ) -> c_int; - pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; pub fn prlimit( diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index c54d77b194c48..7052d9daac2d2 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -44,14 +44,14 @@ s! { pub struct stat { pub st_dev: c_ulonglong, - __pad1: c_ushort, + __pad1: Padding, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: c_ulonglong, - __pad2: c_ushort, + __pad2: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, @@ -61,8 +61,8 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct stat64 { @@ -203,44 +203,44 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, pub msg_stime: crate::time_t, - __unused1: c_ulong, + __unused1: Padding, pub msg_rtime: crate::time_t, - __unused2: c_ulong, + __unused2: Padding, pub msg_ctime: crate::time_t, - __unused3: c_ulong, + __unused3: Padding, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, - __unused1: c_ulong, + __unused1: Padding, pub shm_dtime: crate::time_t, - __unused2: c_ulong, + __unused2: Padding, pub shm_ctime: crate::time_t, - __unused3: c_ulong, + __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } // FIXME(1.0) this is actually a union 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 7dd0440907855..56137bdc38e6d 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -20,7 +20,7 @@ pub type fsfilcnt64_t = u64; s! { pub struct stat { pub st_dev: crate::dev_t, - st_pad1: [c_long; 2], + st_pad1: Padding<[c_long; 2]>, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, @@ -29,7 +29,7 @@ s! { pub st_rdev: crate::dev_t, pub st_pad2: [c_long; 1], pub st_size: off_t, - st_pad3: c_long, + st_pad3: Padding, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, @@ -38,19 +38,19 @@ s! { pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - st_pad5: [c_long; 14], + st_pad5: Padding<[c_long; 14]>, } pub struct stat64 { pub st_dev: crate::dev_t, - st_pad1: [c_long; 2], + st_pad1: Padding<[c_long; 2]>, pub st_ino: crate::ino64_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - st_pad2: [c_long; 2], + st_pad2: Padding<[c_long; 2]>, pub st_size: off64_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -59,9 +59,9 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - st_pad3: c_long, + st_pad3: Padding, pub st_blocks: crate::blkcnt64_t, - st_pad5: [c_long; 14], + st_pad5: Padding<[c_long; 14]>, } pub struct statvfs64 { @@ -114,11 +114,11 @@ s! { pub gl_offs: size_t, pub gl_flags: c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct ipc_perm { @@ -129,9 +129,9 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_ushort, - __pad1: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -143,8 +143,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct msqid_ds { 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 39eb0242730d8..b6adb637493bb 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -15,16 +15,16 @@ pub type wchar_t = i32; s! { pub struct stat { pub st_dev: c_ulong, - st_pad1: [c_long; 2], + st_pad1: Padding<[c_long; 2]>, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: c_ulong, - st_pad2: [c_ulong; 1], + st_pad2: Padding<[c_ulong; 1]>, pub st_size: off_t, - st_pad3: c_long, + st_pad3: Padding, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, @@ -32,21 +32,21 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - st_pad4: c_long, + st_pad4: Padding, pub st_blocks: crate::blkcnt_t, - st_pad5: [c_long; 7], + st_pad5: Padding<[c_long; 7]>, } pub struct stat64 { pub st_dev: c_ulong, - st_pad1: [c_long; 2], + st_pad1: Padding<[c_long; 2]>, pub st_ino: crate::ino64_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: c_ulong, - st_pad2: [c_long; 2], + st_pad2: Padding<[c_long; 2]>, pub st_size: off64_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -55,9 +55,9 @@ s! { pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, - st_pad3: c_long, + st_pad3: Padding, pub st_blocks: crate::blkcnt64_t, - st_pad5: [c_long; 7], + st_pad5: Padding<[c_long; 7]>, } pub struct pthread_attr_t { @@ -85,8 +85,8 @@ s! { pub si_signo: c_int, pub si_code: c_int, pub si_errno: c_int, - _pad: c_int, - _pad2: [c_long; 14], + _pad: Padding, + _pad2: Padding<[c_long; 14]>, } pub struct ipc_perm { @@ -97,9 +97,9 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_ushort, - __pad1: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct shmid_ds { @@ -111,8 +111,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct msqid_ds { diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 4fef82ed8e167..69f1b006e1c01 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -181,36 +181,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { 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 1a2e4bcc1a897..ce6b192580f23 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -31,11 +31,11 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: c_ushort, // read / write - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } #[cfg(not(target_os = "l4re"))] @@ -72,8 +72,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused1: c_ulong, - __unused2: c_ulong, + __unused1: Padding, + __unused2: Padding, } pub struct msqid_ds { @@ -141,7 +141,7 @@ s! { pub st_mtime_nsec: c_ulong, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_ulong, - st_pad4: [c_long; 3], + st_pad4: Padding<[c_long; 3]>, } // FIXME(1.0): This should not implement `PartialEq` @@ -256,11 +256,11 @@ s! { pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, pub gl_flags: c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct cpu_set_t { diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index fd3fa996caad4..c4ce06c92ec25 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -8,8 +8,7 @@ pub type timer_t = *mut c_void; pub type key_t = c_int; pub type id_t = c_uint; -missing! { - #[derive(Debug)] +extern_ty! { pub enum timezone {} } @@ -205,6 +204,29 @@ s! { pub msg_hdr: crate::msghdr, pub msg_len: c_uint, } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + #[cfg(target_pointer_width = "32")] + __ss_pad2: [u8; 128 - 2 - 4], + #[cfg(target_pointer_width = "64")] + __ss_pad2: [u8; 128 - 2 - 8], + __ss_align: size_t, + } + + pub struct utsname { + pub sysname: [c_char; 65], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainname: [c_char; 65], + } } cfg_if! { @@ -248,7 +270,7 @@ cfg_if! { pub stx_uid: crate::__u32, pub stx_gid: crate::__u32, pub stx_mode: crate::__u16, - __statx_pad1: [crate::__u16; 1], + __statx_pad1: Padding<[crate::__u16; 1]>, pub stx_ino: crate::__u64, pub stx_size: crate::__u64, pub stx_blocks: crate::__u64, @@ -264,13 +286,13 @@ cfg_if! { pub stx_mnt_id: crate::__u64, pub stx_dio_mem_align: crate::__u32, pub stx_dio_offset_align: crate::__u32, - __statx_pad3: [crate::__u64; 12], + __statx_pad3: Padding<[crate::__u64; 12]>, } pub struct statx_timestamp { pub tv_sec: crate::__s64, pub tv_nsec: crate::__u32, - __statx_timestamp_pad1: [crate::__s32; 1], + __statx_timestamp_pad1: Padding<[crate::__s32; 1]>, } } } @@ -286,29 +308,6 @@ s_no_extra_traits! { pub u64: u64, } - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108], - } - - pub struct sockaddr_storage { - pub ss_family: sa_family_t, - #[cfg(target_pointer_width = "32")] - __ss_pad2: [u8; 128 - 2 - 4], - #[cfg(target_pointer_width = "64")] - __ss_pad2: [u8; 128 - 2 - 8], - __ss_align: size_t, - } - - pub struct utsname { - pub sysname: [c_char; 65], - pub nodename: [c_char; 65], - pub release: [c_char; 65], - pub version: [c_char; 65], - pub machine: [c_char; 65], - pub domainname: [c_char; 65], - } - pub struct sigevent { pub sigev_value: crate::sigval, pub sigev_signo: c_int, @@ -317,9 +316,9 @@ s_no_extra_traits! { // the most useful member pub sigev_notify_thread_id: c_int, #[cfg(target_pointer_width = "64")] - __unused1: [c_int; 11], + __unused1: Padding<[c_int; 11]>, #[cfg(target_pointer_width = "32")] - __unused1: [c_int; 12], + __unused1: Padding<[c_int; 12]>, } } @@ -340,91 +339,6 @@ cfg_if! { } } - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_pad2.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - && self - .domainname - .iter() - .zip(other.domainname.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - self.domainname.hash(state); - } - } - impl PartialEq for sigevent { fn eq(&self, other: &sigevent) -> bool { self.sigev_value == other.sigev_value @@ -541,9 +455,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; pub const SIGQUIT: c_int = 3; @@ -1932,17 +1843,6 @@ extern "C" { pub fn dirfd(dirp: *mut crate::DIR) -> c_int; - pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; - pub fn pthread_attr_getstack( - attr: *const crate::pthread_attr_t, - stackaddr: *mut *mut c_void, - stacksize: *mut size_t, - ) -> c_int; - pub fn pthread_attr_setstack( - attr: *mut crate::pthread_attr_t, - stackaddr: *mut c_void, - stacksize: size_t, - ) -> c_int; pub fn memalign(align: size_t, size: size_t) -> *mut c_void; pub fn setgroups(ngroups: size_t, ptr: *const crate::gid_t) -> c_int; pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; @@ -1967,21 +1867,7 @@ extern "C" { pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; - pub fn pthread_condattr_getclock( - attr: *const pthread_condattr_t, - clock_id: *mut clockid_t, - ) -> c_int; - pub fn pthread_condattr_setclock( - attr: *mut pthread_condattr_t, - clock_id: crate::clockid_t, - ) -> c_int; - pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; - pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; - pub fn pthread_rwlockattr_getpshared( - attr: *const pthread_rwlockattr_t, - val: *mut c_int, - ) -> c_int; - pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; pub fn clearenv() -> c_int; pub fn waitid( @@ -2075,7 +1961,11 @@ extern "C" { // * musl and Emscripten has 64-bit versions only so aliases the LFS64 symbols to the standard ones // * ulibc doesn't have preadv64/pwritev64 cfg_if! { - if #[cfg(not(any(target_env = "musl", target_os = "emscripten")))] { + if #[cfg(not(any( + target_env = "musl", + target_env = "ohos", + target_os = "emscripten", + )))] { extern "C" { pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; @@ -2135,7 +2025,8 @@ cfg_if! { if #[cfg(not(any( target_env = "uclibc", target_env = "musl", - target_os = "emscripten" + target_env = "ohos", + target_os = "emscripten", )))] { extern "C" { pub fn preadv64( diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6ba5d87de7ca0..62b2cdee67f19 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -37,10 +37,11 @@ cfg_if! { } } -missing! { - #[derive(Debug)] +extern_ty! { pub enum DIR {} } + +#[cfg(not(target_os = "nuttx"))] pub type locale_t = *mut c_void; s! { @@ -59,7 +60,7 @@ s! { pub struct timeval { pub tv_sec: time_t, #[cfg(not(gnu_time_bits64))] - pub tv_usec: suseconds_t, + pub tv_usec: crate::suseconds_t, // For 64 bit time on 32 bit linux glibc, suseconds_t is still // a 32 bit type. Use __suseconds64_t instead #[cfg(gnu_time_bits64)] @@ -68,7 +69,7 @@ s! { // linux x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 - #[cfg(not(target_env = "gnu"))] + #[cfg(all(not(target_env = "gnu"), not(target_os = "aix")))] pub struct timespec { pub tv_sec: time_t, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] @@ -87,51 +88,52 @@ s! { pub ru_stime: timeval, pub ru_maxrss: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad1: u32, + __pad1: Padding, pub ru_ixrss: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad2: u32, + __pad2: Padding, pub ru_idrss: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad3: u32, + __pad3: Padding, pub ru_isrss: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad4: u32, + __pad4: Padding, pub ru_minflt: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad5: u32, + __pad5: Padding, pub ru_majflt: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad6: u32, + __pad6: Padding, pub ru_nswap: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad7: u32, + __pad7: Padding, pub ru_inblock: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad8: u32, + __pad8: Padding, pub ru_oublock: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad9: u32, + __pad9: Padding, pub ru_msgsnd: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad10: u32, + __pad10: Padding, pub ru_msgrcv: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad11: u32, + __pad11: Padding, pub ru_nsignals: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad12: u32, + __pad12: Padding, pub ru_nvcsw: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad13: u32, + __pad13: Padding, pub ru_nivcsw: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - __pad14: u32, + __pad14: Padding, #[cfg(any(target_env = "musl", target_env = "ohos", target_os = "emscripten"))] - __reserved: [c_long; 16], + __reserved: Padding<[c_long; 16]>, } + #[cfg(not(target_os = "nuttx"))] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, #[cfg(target_os = "android")] @@ -349,7 +351,11 @@ cfg_if! { pub const FNM_NOMATCH: c_int = 1; cfg_if! { - if #[cfg(any(target_os = "illumos", target_os = "solaris",))] { + if #[cfg(any( + target_os = "illumos", + target_os = "solaris", + target_os = "netbsd" + ))] { pub const FNM_CASEFOLD: c_int = 1 << 3; } else if #[cfg(not(target_os = "aix"))] { pub const FNM_CASEFOLD: c_int = 1 << 4; @@ -363,6 +369,7 @@ cfg_if! { target_os = "android", target_os = "openbsd", target_os = "cygwin", + target_os = "netbsd", ))] { pub const FNM_PATHNAME: c_int = 1 << 1; } else { @@ -376,6 +383,8 @@ cfg_if! { target_os = "freebsd", target_os = "android", target_os = "openbsd", + target_os = "netbsd", + target_os = "cygwin", ))] { pub const FNM_NOESCAPE: c_int = 1 << 0; } else if #[cfg(target_os = "nto")] { @@ -567,15 +576,13 @@ cfg_if! { cfg_if! { if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] { - missing! { - #[derive(Debug)] + extern_ty! { pub enum fpos_t {} // FIXME(unix): fill this out with a struct } } } -missing! { - #[derive(Debug)] +extern_ty! { pub enum FILE {} } @@ -1259,94 +1266,100 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")] pub fn sched_yield() -> c_int; pub fn pthread_key_create( - key: *mut pthread_key_t, + key: *mut crate::pthread_key_t, dtor: Option, ) -> c_int; - pub fn pthread_key_delete(key: pthread_key_t) -> c_int; - pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; - pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_key_delete(key: crate::pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: crate::pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: crate::pthread_key_t, value: *const c_void) -> c_int; pub fn pthread_mutex_init( - lock: *mut pthread_mutex_t, - attr: *const pthread_mutexattr_t, + lock: *mut crate::pthread_mutex_t, + attr: *const crate::pthread_mutexattr_t, ) -> c_int; - pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; - pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; - pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; - pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_destroy(lock: *mut crate::pthread_mutex_t) -> c_int; + pub fn pthread_mutex_lock(lock: *mut crate::pthread_mutex_t) -> c_int; + pub fn pthread_mutex_trylock(lock: *mut crate::pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(lock: *mut crate::pthread_mutex_t) -> c_int; - pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_init(attr: *mut crate::pthread_mutexattr_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_mutexattr_destroy$UNIX2003" )] - pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; - pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + pub fn pthread_mutexattr_destroy(attr: *mut crate::pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_settype(attr: *mut crate::pthread_mutexattr_t, _type: c_int) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_cond_init$UNIX2003" )] - pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + pub fn pthread_cond_init( + cond: *mut crate::pthread_cond_t, + attr: *const crate::pthread_condattr_t, + ) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_cond_wait$UNIX2003" )] - pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_cond_wait( + cond: *mut crate::pthread_cond_t, + lock: *mut crate::pthread_mutex_t, + ) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_cond_timedwait$UNIX2003" )] #[cfg_attr(gnu_time_bits64, link_name = "__pthread_cond_timedwait64")] pub fn pthread_cond_timedwait( - cond: *mut pthread_cond_t, - lock: *mut pthread_mutex_t, + cond: *mut crate::pthread_cond_t, + lock: *mut crate::pthread_mutex_t, abstime: *const crate::timespec, ) -> c_int; - pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; - pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; - pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; - pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; - pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_cond_signal(cond: *mut crate::pthread_cond_t) -> c_int; + pub fn pthread_cond_broadcast(cond: *mut crate::pthread_cond_t) -> c_int; + pub fn pthread_cond_destroy(cond: *mut crate::pthread_cond_t) -> c_int; + pub fn pthread_condattr_init(attr: *mut crate::pthread_condattr_t) -> c_int; + pub fn pthread_condattr_destroy(attr: *mut crate::pthread_condattr_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_init$UNIX2003" )] pub fn pthread_rwlock_init( - lock: *mut pthread_rwlock_t, - attr: *const pthread_rwlockattr_t, + lock: *mut crate::pthread_rwlock_t, + attr: *const crate::pthread_rwlockattr_t, ) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_destroy$UNIX2003" )] - pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_destroy(lock: *mut crate::pthread_rwlock_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_rdlock$UNIX2003" )] - pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_rdlock(lock: *mut crate::pthread_rwlock_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_tryrdlock$UNIX2003" )] - pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut crate::pthread_rwlock_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_wrlock$UNIX2003" )] - pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_wrlock(lock: *mut crate::pthread_rwlock_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_trywrlock$UNIX2003" )] - pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut crate::pthread_rwlock_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_unlock$UNIX2003" )] - pub fn pthread_rwlock_unlock(lock: *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_rwlock_unlock(lock: *mut crate::pthread_rwlock_t) -> c_int; + pub fn pthread_rwlockattr_init(attr: *mut crate::pthread_rwlockattr_t) -> c_int; + pub fn pthread_rwlockattr_destroy(attr: *mut crate::pthread_rwlockattr_t) -> c_int; #[cfg_attr( any(target_os = "illumos", target_os = "solaris"), @@ -1466,6 +1479,7 @@ extern "C" { link_name = "mknod@FBSD_1.0" )] pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; + #[cfg(not(target_os = "espidf"))] pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; pub fn endservent(); pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; @@ -1536,9 +1550,9 @@ extern "C" { pub fn sem_trywait(sem: *mut sem_t) -> c_int; pub fn sem_post(sem: *mut sem_t) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] - pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; + pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] - pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; + pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] pub fn sigemptyset(set: *mut sigset_t) -> c_int; @@ -1639,6 +1653,7 @@ cfg_if! { target_os = "aix", )))] { extern "C" { + #[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")] #[cfg_attr(gnu_time_bits64, link_name = "__adjtime64")] pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; } @@ -1825,18 +1840,31 @@ cfg_if! { } cfg_if! { - if #[cfg(target_os = "aix")] { + if #[cfg(any(target_os = "aix", target_os = "nto"))] { extern "C" { pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; + } + } else if #[cfg(not(any(target_os = "solaris", target_os = "illumos",)))] { + extern "C" { + pub fn cfmakeraw(termios: *mut crate::termios); + } + } +} + +cfg_if! { + if #[cfg(any( + target_os = "aix", + all(target_os = "nto", target_env = "nto80") + ))] { + extern "C" { pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; } } else if #[cfg(not(any( target_os = "solaris", target_os = "illumos", - target_os = "nto", + target_os = "nto" )))] { extern "C" { - pub fn cfmakeraw(termios: *mut crate::termios); pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; } } diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs index e4640580e2478..56c268fc5f2bb 100644 --- a/src/unix/newlib/aarch64/mod.rs +++ b/src/unix/newlib/aarch64/mod.rs @@ -49,4 +49,8 @@ pub const MSG_WAITALL: c_int = 0; pub const MSG_MORE: c_int = 0; pub const MSG_NOSIGNAL: c_int = 0; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index aea4ed764b03c..26f3d52436b84 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -51,4 +51,8 @@ pub const MSG_WAITALL: c_int = 0; pub const MSG_MORE: c_int = 0; pub const MSG_NOSIGNAL: c_int = 0; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 57a033fcaf263..9bec89a7d78d4 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -117,4 +117,8 @@ extern "C" { pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; } -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 0193083f4e63b..6b68a06cb0624 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -176,6 +176,8 @@ s! { pub f_namemax: c_ulong, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_handler: extern "C" fn(arg1: c_int), pub sa_mask: sigset_t, @@ -557,10 +559,6 @@ cfg_if! { pub const RTLD_LAZY: c_int = 0x1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; - pub const SEEK_SET: c_int = 0; pub const SEEK_CUR: c_int = 1; pub const SEEK_END: c_int = 2; diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs index c4d4a2ed07c5e..f51a1b2cbe602 100644 --- a/src/unix/newlib/powerpc/mod.rs +++ b/src/unix/newlib/powerpc/mod.rs @@ -3,7 +3,11 @@ use crate::prelude::*; pub type clock_t = c_ulong; pub type wchar_t = c_int; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; // the newlib shipped with devkitPPC does not support the following components: // - sockaddr diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 62cd300e1d6f0..2a456f47363d9 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -82,7 +82,7 @@ s! { pub struct dirent { __offset: [u8; 88], pub d_name: [c_char; 256usize], - __pad: [u8; 8], + __pad: Padding<[u8; 8]>, } } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 75f5b56902f7f..962e660f2bc16 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -72,13 +72,8 @@ pub type sem_t = sync_t; pub type nl_item = c_int; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } s! { @@ -311,6 +306,8 @@ s! { pub rlim_max: rlim64_t, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct glob_t { pub gl_pathc: size_t, pub gl_matchc: c_int, @@ -319,11 +316,11 @@ s! { pub gl_flags: c_int, pub gl_errfunc: extern "C" fn(*const c_char, c_int) -> c_int, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, } pub struct passwd { @@ -488,7 +485,7 @@ s! { pub c_cflag: crate::tcflag_t, pub c_lflag: crate::tcflag_t, pub c_cc: [crate::cc_t; crate::NCCS], - __reserved: [c_uint; 3], + __reserved: Padding<[c_uint; 3]>, pub c_ispeed: crate::speed_t, pub c_ospeed: crate::speed_t, } @@ -541,7 +538,7 @@ s! { pub aio_sigevent: crate::sigevent, pub aio_lio_opcode: c_int, pub _aio_lio_state: *mut c_void, - _aio_pad: [c_int; 3], + _aio_pad: Padding<[c_int; 3]>, pub _aio_next: *mut crate::aiocb, pub _aio_flag: c_uint, pub _aio_iotype: c_uint, @@ -596,7 +593,7 @@ s! { pub __prioceiling: c_int, pub __clockid: c_int, pub __count: c_int, - __reserved: [c_int; 3], + __reserved: Padding<[c_int; 3]>, } pub struct sockcred { @@ -673,9 +670,6 @@ s! { pub uc_stack: stack_t, pub uc_mcontext: mcontext_t, } -} - -s_no_extra_traits! { pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, @@ -685,9 +679,9 @@ s_no_extra_traits! { pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, - __ss_pad1: [c_char; 6], + __ss_pad1: Padding<[c_char; 6]>, __ss_align: i64, - __ss_pad2: [c_char; 112], + __ss_pad2: Padding<[c_char; 112]>, } pub struct utsname { @@ -727,32 +721,6 @@ s_no_extra_traits! { pub mq_recvwait: c_long, } - pub struct msg { - pub msg_next: *mut crate::msg, - pub msg_type: c_long, - pub msg_ts: c_ushort, - pub msg_spot: c_short, - _pad: [u8; 4], - } - - pub struct msqid_ds { - pub msg_perm: crate::ipc_perm, - pub msg_first: *mut crate::msg, - pub msg_last: *mut crate::msg, - pub msg_cbytes: crate::msglen_t, - pub msg_qnum: crate::msgqnum_t, - pub msg_qbytes: crate::msglen_t, - pub msg_lspid: crate::pid_t, - pub msg_lrpid: crate::pid_t, - pub msg_stime: crate::time_t, - msg_pad1: c_long, - pub msg_rtime: crate::time_t, - msg_pad2: c_long, - pub msg_ctime: crate::time_t, - msg_pad3: c_long, - msg_pad4: [c_long; 4], - } - #[cfg(not(target_env = "nto71_iosock"))] pub struct sockaddr_dl { pub sdl_len: c_uchar, @@ -776,6 +744,34 @@ s_no_extra_traits! { pub sdl_slen: c_uchar, pub sdl_data: [c_char; 46], } +} + +s_no_extra_traits! { + pub struct msg { + pub msg_next: *mut crate::msg, + pub msg_type: c_long, + pub msg_ts: c_ushort, + pub msg_spot: c_short, + _pad: Padding<[u8; 4]>, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_first: *mut crate::msg, + pub msg_last: *mut crate::msg, + pub msg_cbytes: crate::msglen_t, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + pub msg_stime: crate::time_t, + msg_pad1: Padding, + pub msg_rtime: crate::time_t, + msg_pad2: Padding, + pub msg_ctime: crate::time_t, + msg_pad3: Padding, + msg_pad4: Padding<[c_long; 4]>, + } pub struct sync_t { __u: c_uint, // union @@ -785,7 +781,7 @@ s_no_extra_traits! { #[repr(align(4))] pub struct pthread_barrier_t { // union - __pad: [u8; 28], // union + __pad: Padding<[u8; 28]>, // union } pub struct pthread_rwlock_t { @@ -801,215 +797,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - // sigevent - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.__sigev_un2 == other.__sigev_un2 - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.__sigev_un2.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_len == other.sun_len - && self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_len.hash(state); - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - // sigset_t - impl PartialEq for sigset_t { - fn eq(&self, other: &sigset_t) -> bool { - self.__val == other.__val - } - } - impl Eq for sigset_t {} - impl hash::Hash for sigset_t { - fn hash(&self, state: &mut H) { - self.__val.hash(state); - } - } - - // msg - - // msqid_ds - - // sockaddr_dl - impl PartialEq for sockaddr_dl { - fn eq(&self, other: &sockaddr_dl) -> bool { - self.sdl_len == other.sdl_len - && self.sdl_family == other.sdl_family - && self.sdl_index == other.sdl_index - && self.sdl_type == other.sdl_type - && self.sdl_nlen == other.sdl_nlen - && self.sdl_alen == other.sdl_alen - && self.sdl_slen == other.sdl_slen - && self - .sdl_data - .iter() - .zip(other.sdl_data.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_dl {} - impl hash::Hash for sockaddr_dl { - fn hash(&self, state: &mut H) { - self.sdl_len.hash(state); - self.sdl_family.hash(state); - self.sdl_index.hash(state); - self.sdl_type.hash(state); - self.sdl_nlen.hash(state); - self.sdl_alen.hash(state); - self.sdl_slen.hash(state); - self.sdl_data.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_flags == other.mq_flags - && self.mq_curmsgs == other.mq_curmsgs - && self.mq_msgsize == other.mq_msgsize - && self.mq_sendwait == other.mq_sendwait - && self.mq_recvwait == other.mq_recvwait - } - } - - impl Eq for mq_attr {} - - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_flags.hash(state); - self.mq_curmsgs.hash(state); - self.mq_sendwait.hash(state); - self.mq_recvwait.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self.__ss_pad1 == other.__ss_pad1 - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_offset == other.d_offset - && self.d_reclen == other.d_reclen - && self.d_namelen == other.d_namelen - && self.d_name[..self.d_namelen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_offset.hash(state); - self.d_reclen.hash(state); - self.d_namelen.hash(state); - self.d_name[..self.d_namelen as _].hash(state); - } - } - } -} - pub const _SYSNAME_SIZE: usize = 256 + 1; pub const RLIM_INFINITY: crate::rlim_t = 0xfffffffffffffffd; pub const O_LARGEFILE: c_int = 0o0100000; @@ -1059,10 +846,6 @@ pub const X_OK: c_int = 1; pub const W_OK: c_int = 2; pub const R_OK: c_int = 4; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; - pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; pub const SIGQUIT: c_int = 3; @@ -3347,7 +3130,7 @@ impl siginfo_t { pub unsafe fn si_addr(&self) -> *mut c_void { #[repr(C)] struct siginfo_si_addr { - _pad: [u8; 32], + _pad: Padding<[u8; 32]>, si_addr: *mut c_void, } (*(self as *const siginfo_t as *const siginfo_si_addr)).si_addr @@ -3356,7 +3139,7 @@ impl siginfo_t { pub unsafe fn si_value(&self) -> crate::sigval { #[repr(C)] struct siginfo_si_value { - _pad: [u8; 32], + _pad: Padding<[u8; 32]>, si_value: crate::sigval, } (*(self as *const siginfo_t as *const siginfo_si_value)).si_value @@ -3365,7 +3148,7 @@ impl siginfo_t { pub unsafe fn si_pid(&self) -> crate::pid_t { #[repr(C)] struct siginfo_si_pid { - _pad: [u8; 16], + _pad: Padding<[u8; 16]>, si_pid: crate::pid_t, } (*(self as *const siginfo_t as *const siginfo_si_pid)).si_pid @@ -3374,7 +3157,7 @@ impl siginfo_t { pub unsafe fn si_uid(&self) -> crate::uid_t { #[repr(C)] struct siginfo_si_uid { - _pad: [u8; 24], + _pad: Padding<[u8; 24]>, si_uid: crate::uid_t, } (*(self as *const siginfo_t as *const siginfo_si_uid)).si_uid @@ -3383,7 +3166,7 @@ impl siginfo_t { pub unsafe fn si_status(&self) -> c_int { #[repr(C)] struct siginfo_si_status { - _pad: [u8; 28], + _pad: Padding<[u8; 28]>, si_status: c_int, } (*(self as *const siginfo_t as *const siginfo_si_status)).si_status diff --git a/src/unix/nto/neutrino.rs b/src/unix/nto/neutrino.rs index 8aac468009785..5d12d24047188 100644 --- a/src/unix/nto/neutrino.rs +++ b/src/unix/nto/neutrino.rs @@ -239,7 +239,7 @@ s_no_extra_traits! { pub pminfo: syspage_entry_info, pub old_mdriver: syspage_entry_info, spare0: [u32; 1], - __reserved: [u8; 160], // anonymous union with architecture dependent structs + __reserved: Padding<[u8; 160]>, // anonymous union with architecture dependent structs pub new_asinfo: syspage_array_info, pub new_cpuinfo: syspage_array_info, pub new_cacheattr: syspage_array_info, @@ -1245,13 +1245,13 @@ extern "C" { __id: crate::clockid_t, _new: *const crate::_clockperiod, __old: *mut crate::_clockperiod, - __reserved: c_int, + __reserved: Padding, ) -> c_int; pub fn ClockPeriod_r( __id: crate::clockid_t, _new: *const crate::_clockperiod, __old: *mut crate::_clockperiod, - __reserved: c_int, + __reserved: Padding, ) -> c_int; pub fn ClockId(__pid: crate::pid_t, __tid: c_int) -> c_int; pub fn ClockId_r(__pid: crate::pid_t, __tid: c_int) -> c_int; diff --git a/src/unix/nto/x86_64.rs b/src/unix/nto/x86_64.rs index 521b5d4ab7879..1fbfe3bb449bf 100644 --- a/src/unix/nto/x86_64.rs +++ b/src/unix/nto/x86_64.rs @@ -23,11 +23,11 @@ s! { pub r15: u64, pub rip: u64, pub cs: u32, - rsvd1: u32, + rsvd1: Padding, pub rflags: u64, pub rsp: u64, pub ss: u32, - rsvd2: u32, + rsvd2: Padding, } #[repr(align(8))] diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 3d3e2c3448841..e3ad7bafd153c 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -1,5 +1,10 @@ use crate::prelude::*; -use crate::{in6_addr, in_addr_t, timespec, DIR}; +use crate::{ + in6_addr, + in_addr_t, + timespec, + DIR, +}; pub type nlink_t = u16; pub type ino_t = u16; @@ -42,7 +47,7 @@ s! { pub st_ctim: timespec, pub st_blksize: blksize_t, pub st_blocks: i64, - __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, } pub struct sockaddr { @@ -58,7 +63,7 @@ s! { pub pw_gecos: *const c_char, pub pw_dir: *const c_char, pub pw_shell: *const c_char, - __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, } pub struct sem_t { @@ -113,7 +118,7 @@ s! { pub int_p_cs_precedes: i8, pub int_p_sep_by_space: i8, pub int_p_sign_posn: i8, - __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, } pub struct tm { @@ -128,7 +133,7 @@ s! { pub tm_isdst: i32, pub tm_gmtoff: isize, pub tm_zone: *const c_char, - __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, } pub struct addrinfo { @@ -140,7 +145,7 @@ s! { pub ai_addr: *mut sockaddr, pub ai_canonname: *mut c_char, pub ai_next: *mut addrinfo, - __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, } pub struct pthread_rwlock_t { @@ -159,7 +164,7 @@ s! { pub f_fsid: usize, pub f_flag: usize, pub f_namemax: usize, - __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, } pub struct dirent { @@ -180,7 +185,7 @@ s! { pub sa_mask: sigset_t, pub sa_flags: i32, pub sa_user: usize, - __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, } pub struct termios { @@ -190,7 +195,7 @@ s! { pub c_lflag: tcflag_t, pub c_cc: [cc_t; 12], pub c_speed: speed_t, - __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, } pub struct in_addr { @@ -231,11 +236,6 @@ s! { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: u32, } - - pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } } // Reserved two pointer size for reserved area for some structures. @@ -509,9 +509,6 @@ pub const TCP_NODELAY: i32 = 0x10; pub const FIONBIO: i32 = 0x30a; // unistd.h -pub const STDIN_FILENO: i32 = 0; -pub const STDOUT_FILENO: i32 = 1; -pub const STDERR_FILENO: i32 = 2; pub const _SC_PAGESIZE: i32 = 0x36; pub const _SC_THREAD_STACK_MIN: i32 = 0x58; pub const _SC_GETPW_R_SIZE_MAX: i32 = 0x25; @@ -523,7 +520,6 @@ 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; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 50bdaf4d4f06b..439e8db35b4e0 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -28,20 +28,14 @@ pub type suseconds_t = c_int; pub type tcflag_t = u32; pub type time_t = c_longlong; pub type id_t = c_uint; -pub type pid_t = usize; pub type uid_t = c_int; pub type gid_t = c_int; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } -s_no_extra_traits! { +s! { #[repr(C)] pub struct utsname { pub sysname: [c_char; UTSLENGTH], @@ -70,9 +64,7 @@ s_no_extra_traits! { __ss_padding: [u8; 128 - size_of::() - size_of::()], __ss_align: c_ulong, } -} -s! { pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, @@ -170,7 +162,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } @@ -211,7 +203,7 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - _pad: [c_char; 24], + _pad: Padding<[c_char; 24]>, } pub struct statvfs { @@ -254,7 +246,7 @@ s! { } pub struct ucred { - pub pid: pid_t, + pub pid: crate::pid_t, pub uid: uid_t, pub gid: gid_t, } @@ -1071,9 +1063,6 @@ pub const _IONBF: c_int = 2; pub const SEEK_SET: c_int = 0; pub const SEEK_CUR: c_int = 1; pub const SEEK_END: c_int = 2; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const _PC_LINK_MAX: c_int = 0; pub const _PC_MAX_CANON: c_int = 1; @@ -1186,6 +1175,18 @@ extern "C" { // unistd.h pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; pub fn getdtablesize() -> c_int; + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; // grp.h pub fn getgrent() -> *mut crate::group; @@ -1375,122 +1376,3 @@ extern "C" { // utmp.h pub fn login_tty(fd: c_int) -> c_int; } - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_un {} - - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self.__ss_align == self.__ss_align - && self - .__ss_padding - .iter() - .zip(other.__ss_padding.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_padding.hash(state); - self.__ss_align.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - && self - .domainname - .iter() - .zip(other.domainname.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - self.domainname.hash(state); - } - } - } -} diff --git a/src/unix/solarish/compat.rs b/src/unix/solarish/compat.rs index 22bcf12edcc82..6876a9d8fd319 100644 --- a/src/unix/solarish/compat.rs +++ b/src/unix/solarish/compat.rs @@ -3,7 +3,11 @@ use core::cmp::min; use crate::unix::solarish::*; -use crate::{c_char, c_int, size_t}; +use crate::{ + c_char, + c_int, + size_t, +}; pub unsafe fn cfmakeraw(termios: *mut crate::termios) { (*termios).c_iflag &= diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index fbeadaf344fa0..c0a17823bb9a7 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -1,7 +1,13 @@ use crate::prelude::*; use crate::{ - exit_status, off_t, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, - PRIV_PFEXEC, PRIV_XPOLICY, + exit_status, + off_t, + NET_MAC_AWARE, + NET_MAC_AWARE_INHERIT, + PRIV_AWARE_RESET, + PRIV_DEBUG, + PRIV_PFEXEC, + PRIV_XPOLICY, }; pub type lgrp_rsrc_t = c_int; @@ -41,9 +47,7 @@ s! { pub fi_pos: c_int, pub fi_name: [c_char; crate::FILNAME_MAX as usize], } -} -s_no_extra_traits! { #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] pub struct epoll_event { pub events: u32, @@ -65,63 +69,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_user == other.ut_user - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_syslen == other.ut_syslen - && self.ut_pad == other.ut_pad - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_user.hash(state); - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_syslen.hash(state); - self.ut_pad.hash(state); - } - } - - impl PartialEq for epoll_event { - fn eq(&self, other: &epoll_event) -> bool { - self.events == other.events && self.u64 == other.u64 - } - } - impl Eq for epoll_event {} - impl hash::Hash for epoll_event { - fn hash(&self, state: &mut H) { - let events = self.events; - let u64 = self.u64; - events.hash(state); - u64.hash(state); - } - } - } -} - pub const _UTX_USERSIZE: usize = 32; pub const _UTX_LINESIZE: usize = 32; pub const _UTX_PADSIZE: usize = 5; @@ -265,7 +212,7 @@ pub const TFD_TIMER_ABSTIME: i32 = 1 << 0; pub const TFD_TIMER_CANCEL_ON_SET: i32 = 1 << 1; extern "C" { - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn epoll_pwait( epfd: c_int, diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index d8b32dfc0aae9..5341b811fa557 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -55,22 +55,9 @@ pub type lgrp_view_t = c_uint; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} - -#[derive(Debug)] -pub enum ucred_t {} -impl Copy for ucred_t {} -impl Clone for ucred_t { - fn clone(&self) -> ucred_t { - *self - } +extern_ty! { + pub enum timezone {} + pub enum ucred_t {} } s! { @@ -239,24 +226,24 @@ s! { pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, - __unused1: *mut c_void, - __unused2: c_int, + __unused1: Padding<*mut c_void>, + __unused2: Padding, #[cfg(target_os = "illumos")] - __unused3: c_int, + __unused3: Padding, #[cfg(target_os = "illumos")] - __unused4: c_int, + __unused4: Padding, #[cfg(target_os = "illumos")] - __unused5: *mut c_void, + __unused5: Padding<*mut c_void>, #[cfg(target_os = "illumos")] - __unused6: *mut c_void, + __unused6: Padding<*mut c_void>, #[cfg(target_os = "illumos")] - __unused7: *mut c_void, + __unused7: Padding<*mut c_void>, #[cfg(target_os = "illumos")] - __unused8: *mut c_void, + __unused8: Padding<*mut c_void>, #[cfg(target_os = "illumos")] - __unused9: *mut c_void, + __unused9: Padding<*mut c_void>, #[cfg(target_os = "illumos")] - __unused10: *mut c_void, + __unused10: Padding<*mut c_void>, } pub struct addrinfo { @@ -313,7 +300,7 @@ s! { pub struct sched_param { pub sched_priority: c_int, - sched_pad: [c_int; 8], + sched_pad: Padding<[c_int; 8]>, } pub struct Dl_info { @@ -406,7 +393,7 @@ s! { pub mq_maxmsg: c_long, pub mq_msgsize: c_long, pub mq_curmsgs: c_long, - _pad: [c_int; 12], + _pad: Padding<[c_int; 12]>, } pub struct port_event { @@ -497,9 +484,7 @@ s! { pub flag: *mut c_int, pub val: c_int, } -} -s_no_extra_traits! { pub struct sockaddr_un { pub sun_family: sa_family_t, pub sun_path: [c_char; 108], @@ -522,20 +507,9 @@ s_no_extra_traits! { pub struct sockaddr_storage { pub ss_family: crate::sa_family_t, - __ss_pad1: [u8; 6], + __ss_pad1: Padding<[u8; 6]>, __ss_align: i64, - __ss_pad2: [u8; 240], - } - - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - #[cfg(target_pointer_width = "64")] - pub si_pad: c_int, - - __data_pad: [c_int; SIGINFO_DATA_SIZE], + __ss_pad2: Padding<[u8; 240]>, } pub struct sockaddr_dl { @@ -554,7 +528,20 @@ s_no_extra_traits! { pub sigev_value: crate::sigval, pub ss_sp: *mut c_void, pub sigev_notify_attributes: *const crate::pthread_attr_t, - __sigev_pad2: c_int, + __sigev_pad2: Padding, + } +} + +s_no_extra_traits! { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + #[cfg(target_pointer_width = "64")] + pub si_pad: c_int, + + __data_pad: [c_int; SIGINFO_DATA_SIZE], } #[repr(align(16))] @@ -572,100 +559,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for utsname {} - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - } - } - - impl PartialEq for fd_set { - fn eq(&self, other: &fd_set) -> bool { - self.fds_bits - .iter() - .zip(other.fds_bits.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for fd_set {} - impl hash::Hash for fd_set { - fn hash(&self, state: &mut H) { - self.fds_bits.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self.__ss_pad1 == other.__ss_pad1 - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - impl siginfo_t { /// The siginfo_t will have differing contents based on the delivered signal. Based on /// `si_signo`, this determines how many of the `c_int` pad fields contain valid data @@ -730,54 +623,6 @@ cfg_if! { } } - impl PartialEq for sockaddr_dl { - fn eq(&self, other: &sockaddr_dl) -> bool { - self.sdl_family == other.sdl_family - && self.sdl_index == other.sdl_index - && self.sdl_type == other.sdl_type - && self.sdl_nlen == other.sdl_nlen - && self.sdl_alen == other.sdl_alen - && self.sdl_slen == other.sdl_slen - && self - .sdl_data - .iter() - .zip(other.sdl_data.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_dl {} - impl hash::Hash for sockaddr_dl { - fn hash(&self, state: &mut H) { - self.sdl_family.hash(state); - self.sdl_index.hash(state); - self.sdl_type.hash(state); - self.sdl_nlen.hash(state); - self.sdl_alen.hash(state); - self.sdl_slen.hash(state); - self.sdl_data.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.ss_sp == other.ss_sp - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.ss_sp.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - impl PartialEq for pad128_t { fn eq(&self, other: &pad128_t) -> bool { unsafe { @@ -823,71 +668,38 @@ cfg_if! { } } -#[repr(C)] -struct siginfo_fault { - addr: *mut c_void, - trapno: c_int, - pc: *mut crate::caddr_t, -} -impl Copy for siginfo_fault {} -impl Clone for siginfo_fault { - fn clone(&self) -> Self { - *self +s_no_extra_traits! { + struct siginfo_fault { + addr: *mut c_void, + trapno: c_int, + pc: *mut crate::caddr_t, } -} -#[repr(C)] -struct siginfo_cldval { - utime: crate::clock_t, - status: c_int, - stime: crate::clock_t, -} -impl Copy for siginfo_cldval {} -impl Clone for siginfo_cldval { - fn clone(&self) -> Self { - *self + struct siginfo_cldval { + utime: crate::clock_t, + status: c_int, + stime: crate::clock_t, } -} -#[repr(C)] -struct siginfo_killval { - uid: crate::uid_t, - value: crate::sigval, - // Pad out to match the SIGCLD value size - _pad: *mut c_void, -} -impl Copy for siginfo_killval {} -impl Clone for siginfo_killval { - fn clone(&self) -> Self { - *self + struct siginfo_killval { + uid: crate::uid_t, + value: crate::sigval, + // Pad out to match the SIGCLD value size + _pad: Padding<*mut c_void>, } -} -#[repr(C)] -struct siginfo_sigcld { - pid: crate::pid_t, - val: siginfo_cldval, - ctid: crate::ctid_t, - zoneid: crate::zoneid_t, -} -impl Copy for siginfo_sigcld {} -impl Clone for siginfo_sigcld { - fn clone(&self) -> Self { - *self + struct siginfo_sigcld { + pid: crate::pid_t, + val: siginfo_cldval, + ctid: crate::ctid_t, + zoneid: crate::zoneid_t, } -} -#[repr(C)] -struct siginfo_kill { - pid: crate::pid_t, - val: siginfo_killval, - ctid: crate::ctid_t, - zoneid: crate::zoneid_t, -} -impl Copy for siginfo_kill {} -impl Clone for siginfo_kill { - fn clone(&self) -> Self { - *self + struct siginfo_kill { + pid: crate::pid_t, + val: siginfo_killval, + ctid: crate::ctid_t, + zoneid: crate::zoneid_t, } } @@ -1159,9 +971,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; pub const F_TLOCK: c_int = 2; diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index 58b097a16269b..2b9ace5e9c490 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -1,7 +1,14 @@ use crate::prelude::*; use crate::{ - exit_status, off_t, termios, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, - PRIV_DEBUG, PRIV_PFEXEC, PRIV_XPOLICY, + exit_status, + off_t, + termios, + NET_MAC_AWARE, + NET_MAC_AWARE_INHERIT, + PRIV_AWARE_RESET, + PRIV_DEBUG, + PRIV_PFEXEC, + PRIV_XPOLICY, }; pub type door_attr_t = c_uint; @@ -55,6 +62,20 @@ s! { pub xrs_id: c_ulong, pub xrs_ptr: *mut c_char, } + + pub struct utmpx { + pub ut_user: [c_char; _UTMP_USER_LEN], + pub ut_id: [c_char; _UTMP_ID_LEN], + pub ut_line: [c_char; _UTMP_LINE_LEN], + pub ut_pid: crate::pid_t, + pub ut_type: c_short, + pub ut_exit: exit_status, + pub ut_tv: crate::timeval, + pub ut_session: c_int, + pub pad: [c_int; 5], + pub ut_syslen: c_short, + pub ut_host: [c_char; 257], + } } s_no_extra_traits! { @@ -82,62 +103,6 @@ s_no_extra_traits! { pub rbuf: *const c_char, pub rsize: size_t, } - - pub struct utmpx { - pub ut_user: [c_char; _UTMP_USER_LEN], - pub ut_id: [c_char; _UTMP_ID_LEN], - pub ut_line: [c_char; _UTMP_LINE_LEN], - pub ut_pid: crate::pid_t, - pub ut_type: c_short, - pub ut_exit: exit_status, - pub ut_tv: crate::timeval, - pub ut_session: c_int, - pub pad: [c_int; 5], - pub ut_syslen: c_short, - pub ut_host: [c_char; 257], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_user == other.ut_user - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_syslen == other.ut_syslen - && self.pad == other.pad - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_user.hash(state); - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_syslen.hash(state); - self.pad.hash(state); - } - } - } } // FIXME(solaris): O_DIRECT and SIGINFO are NOT available on Solaris. diff --git a/src/unix/solarish/x86_64.rs b/src/unix/solarish/x86_64.rs index a45ca4b7d0976..a4c48064aaaa9 100644 --- a/src/unix/solarish/x86_64.rs +++ b/src/unix/solarish/x86_64.rs @@ -59,13 +59,6 @@ s! { #[cfg(target_os = "solaris")] pub dlpi_tls_data: *mut c_void, } -} - -s_no_extra_traits! { - pub union __c_anonymous_fp_reg_set { - pub fpchip_state: __c_anonymous_fpchip_state, - pub f_fpregs: [[u32; 13]; 10], - } pub struct fpregset_t { pub fp_reg_set: __c_anonymous_fp_reg_set, @@ -97,6 +90,13 @@ s_no_extra_traits! { } } +s_no_extra_traits! { + pub union __c_anonymous_fp_reg_set { + pub fpchip_state: __c_anonymous_fpchip_state, + pub f_fpregs: [[u32; 13]; 10], + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for __c_anonymous_fp_reg_set { @@ -112,29 +112,13 @@ cfg_if! { } } impl Eq for __c_anonymous_fp_reg_set {} - impl PartialEq for fpregset_t { - fn eq(&self, other: &fpregset_t) -> bool { - self.fp_reg_set == other.fp_reg_set - } - } - impl Eq for fpregset_t {} - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.gregs == other.gregs && self.fpregs == other.fpregs - } - } - impl Eq for mcontext_t {} - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_sigmask == other.uc_sigmask - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_filler == other.uc_filler + impl hash::Hash for __c_anonymous_fp_reg_set { + fn hash(&self, state: &mut H) { + unsafe { + self.f_fpregs.hash(state); + } } } - impl Eq for ucontext_t {} } } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 809640d112221..5f22a7cee7297 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -4,13 +4,8 @@ use core::ptr::null_mut; use crate::prelude::*; -#[derive(Debug)] -pub enum DIR {} -impl Copy for DIR {} -impl Clone for DIR { - fn clone(&self) -> DIR { - *self - } +extern_ty! { + pub enum DIR {} } pub type intmax_t = i64; @@ -21,6 +16,10 @@ pub type intptr_t = isize; pub type ptrdiff_t = isize; pub type size_t = crate::uintptr_t; pub type ssize_t = intptr_t; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type clock_t = c_long; +pub type cc_t = c_uchar; pub type pid_t = c_int; pub type in_addr_t = u32; @@ -95,13 +94,8 @@ pub type sa_family_t = c_uchar; // mqueue.h pub type mqd_t = c_int; -#[derive(Debug)] -pub enum _Vx_semaphore {} -impl Copy for _Vx_semaphore {} -impl Clone for _Vx_semaphore { - fn clone(&self) -> _Vx_semaphore { - *self - } +extern_ty! { + pub enum _Vx_semaphore {} } impl siginfo_t { @@ -225,8 +219,17 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_size: off_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_atim: timespec, + #[cfg(vxworks_lt_25_09)] pub st_atime: crate::time_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_mtim: timespec, + #[cfg(vxworks_lt_25_09)] pub st_mtime: crate::time_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_ctim: timespec, + #[cfg(vxworks_lt_25_09)] pub st_ctime: crate::time_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, @@ -245,6 +248,15 @@ s! { // b_struct__Sched_param.h pub struct sched_param { + pub sched_priority: c_int, /* scheduling priority */ + pub sched_ss_low_priority: c_int, /* low scheduling priority */ + pub sched_ss_repl_period: crate::timespec, /* replenishment period */ + pub sched_ss_init_budget: crate::timespec, /* initial budget */ + pub sched_ss_max_repl: c_int, /* max pending replenishment */ + } + + // b_struct__Sched_param.h + pub struct _Sched_param { pub sched_priority: c_int, /* scheduling priority */ pub sched_ss_low_priority: c_int, /* low scheduling priority */ pub sched_ss_repl_period: crate::_Timespec, /* replenishment period */ @@ -264,13 +276,16 @@ s! { pub threadAttrSchedpolicy: c_int, pub threadAttrName: *mut c_char, pub threadAttrOptions: c_int, - pub threadAttrSchedparam: crate::sched_param, + pub threadAttrSchedparam: crate::_Sched_param, } // signal.h pub struct sigaction { + #[cfg(vxworks_lt_25_09)] pub sa_u: crate::sa_u_t, + #[cfg(not(vxworks_lt_25_09))] + pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, pub sa_flags: c_int, } @@ -335,6 +350,20 @@ s! { pub tm_isdst: c_int, } + // sys/times.h + pub struct tms { + pub tms_utime: crate::clock_t, + pub tms_stime: crate::clock_t, + pub tms_cutime: crate::clock_t, + pub tms_cstime: crate::clock_t, + } + + // utime.h + pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + // in.h pub struct in_addr { pub s_addr: in_addr_t, @@ -370,6 +399,30 @@ s! { pub ai_next: *mut crate::addrinfo, } + // netdb.h + pub struct servent { + pub s_name: *mut c_char, + pub s_aliases: *mut *mut c_char, + pub s_port: c_int, + pub s_proto: *mut c_char, + } + + // netdb.h + pub struct protoent { + pub p_name: *mut c_char, + pub p_aliases: *mut *mut c_char, + pub p_proto: c_int, + } + + // netdb.h + pub struct hostent { + pub h_name: *mut c_char, + pub h_aliases: *mut *mut c_char, + pub h_addrtype: c_int, + pub h_length: c_int, + pub h_addr_list: *mut *mut c_char, + } + // in.h pub struct sockaddr_in { pub sin_len: u8, @@ -402,6 +455,98 @@ s! { pub mq_flags: c_long, pub mq_curmsgs: c_long, } + + pub struct winsize { + pub ws_row: c_ushort, + pub ws_col: c_ushort, + pub ws_xpixel: c_ushort, + pub ws_ypixel: c_ushort, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_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, + } + + pub struct lconv { + pub currency_symbol: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_grouping: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub negative_sign: *mut c_char, + pub positive_sign: *mut c_char, + pub frac_digits: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub n_sign_posn: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub int_frac_digits: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub decimal_point: *mut c_char, + pub grouping: *mut c_char, + pub thousands_sep: *mut c_char, + pub _Frac_grouping: *mut c_char, + pub _Frac_sep: *mut c_char, + pub _False: *mut c_char, + pub _True: *mut c_char, + + pub _No: *mut c_char, + pub _Yes: *mut c_char, + } + + // grp.h + pub struct group { + pub gr_name: *mut c_char, + pub gr_passwd: *mut c_char, + pub gr_gid: c_int, + pub gr_mem: *mut *mut c_char, + } + + pub struct utsname { + pub sysname: [c_char; 80], + pub nodename: [c_char; 256], + pub release: [c_char; 80], + pub version: [c_char; 256], + pub machine: [c_char; 256], + pub endian: [c_char; 80], + pub kernelversion: [c_char; 80], + pub releaseversion: [c_char; 80], + pub processor: [c_char; 80], + pub bsprevision: [c_char; 80], + pub builddate: [c_char; 80], + } } s_no_extra_traits! { @@ -495,10 +640,6 @@ cfg_if! { } } -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; - pub const EXIT_SUCCESS: c_int = 0; pub const EXIT_FAILURE: c_int = 1; @@ -506,6 +647,9 @@ pub const EAI_SERVICE: c_int = 9; pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; +pub const INT_MAX: c_int = 0x7fffffff; +pub const INT_MIN: c_int = -INT_MAX - 1; + // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); @@ -693,12 +837,22 @@ const objErrorBase: c_int = 0x003d0000; pub const S_taskLib_NAME_NOT_FOUND: c_int = taskErrorBase + 0x0065; pub const S_taskLib_TASK_HOOK_TABLE_FULL: c_int = taskErrorBase + 0x0066; pub const S_taskLib_TASK_HOOK_NOT_FOUND: c_int = taskErrorBase + 0x0067; -pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x0068; +pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x006D; // FIXME(vxworks): could also be useful for TASK_DESC type pub const VX_TASK_NAME_LENGTH: c_int = 31; pub const VX_TASK_RENAME_LENGTH: c_int = 16; +pub const TCIFLUSH: c_int = 0; + +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VMIN: usize = 16; +pub const VTIME: usize = 17; + // semLibCommon.h pub const S_semLib_INVALID_STATE: c_int = semErrorBase + 0x0065; pub const S_semLib_INVALID_OPTION: c_int = semErrorBase + 0x0066; @@ -712,9 +866,28 @@ pub const S_objLib_OBJ_DELETED: c_int = objErrorBase + 0x0003; pub const S_objLib_OBJ_TIMEOUT: c_int = objErrorBase + 0x0004; pub const S_objLib_OBJ_NO_METHOD: c_int = objErrorBase + 0x0005; -// in.h +// netinet/in.h pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_ICMP: c_int = 1; +pub const IPPROTO_TCP: c_int = 6; pub const IPPROTO_IPV6: c_int = 41; +pub const IPPROTO_ICMPV6: c_int = 58; + +pub const INADDR_ANY: in_addr_t = 0; +pub const INADDR_LOOPBACK: in_addr_t = 2130706433; +pub const INADDR_BROADCAST: in_addr_t = 4294967295; +pub const INADDR_NONE: in_addr_t = 4294967295; + +// netinet6/in6.h +pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], +}; +pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], +}; + +// udp.h +pub const IPPROTO_UDP: c_int = 17; pub const IP_TTL: c_int = 4; pub const IP_MULTICAST_IF: c_int = 9; @@ -723,6 +896,9 @@ pub const IP_MULTICAST_LOOP: c_int = 11; pub const IP_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13; +// netdb.h +pub const NI_MAXHOST: c_int = 1025; + // in6.h pub const IPV6_V6ONLY: c_int = 1; pub const IPV6_UNICAST_HOPS: c_int = 4; @@ -823,8 +999,12 @@ pub const MSG_COMPAT: c_int = 0x8000; pub const AF_UNSPEC: c_int = 0; pub const AF_LOCAL: c_int = 1; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_UNIX: c_int = PF_LOCAL; +pub const PF_UNSPEC: c_int = AF_UNSPEC; pub const AF_UNIX: c_int = AF_LOCAL; pub const AF_INET: c_int = 2; +pub const PF_INET: c_int = AF_INET; pub const AF_NETLINK: c_int = 16; pub const AF_ROUTE: c_int = 17; pub const AF_LINK: c_int = 18; @@ -832,17 +1012,111 @@ pub const AF_PACKET: c_int = 19; pub const pseudo_AF_KEY: c_int = 27; pub const AF_KEY: c_int = pseudo_AF_KEY; pub const AF_INET6: c_int = 28; +pub const PF_INET6: c_int = AF_INET6; pub const AF_SOCKDEV: c_int = 31; pub const AF_TIPC: c_int = 33; pub const AF_MIPC: c_int = 34; pub const AF_MIPC_SAFE: c_int = 35; -pub const AF_MAX: c_int = 37; +pub const AF_MAX: c_int = 39; + +// termios.h +pub const B0: crate::speed_t = 0; +pub const B50: crate::speed_t = 50; +pub const B75: crate::speed_t = 75; +pub const B110: crate::speed_t = 110; +pub const B134: crate::speed_t = 134; +pub const B150: crate::speed_t = 150; +pub const B200: crate::speed_t = 200; +pub const B300: crate::speed_t = 300; +pub const B600: crate::speed_t = 600; +pub const B1200: crate::speed_t = 1200; +pub const B1800: crate::speed_t = 1800; +pub const B2400: crate::speed_t = 2400; +pub const B4800: crate::speed_t = 4800; +pub const B9600: crate::speed_t = 9600; +pub const B19200: crate::speed_t = 19200; +pub const B38400: crate::speed_t = 38400; +pub const B57600: crate::speed_t = 57600; +pub const B115200: crate::speed_t = 115200; +pub const B230400: crate::speed_t = 230400; + +pub const IGNBRK: crate::tcflag_t = 0x00000001; +pub const BRKINT: crate::tcflag_t = 0x00000002; +pub const IGNCR: crate::tcflag_t = 0x00000200; +pub const IGNPAR: crate::tcflag_t = 0x00000000; +pub const INPCK: crate::tcflag_t = 0x00000020; +pub const ISTRIP: crate::tcflag_t = 0x00000040; +pub const INLCR: crate::tcflag_t = 0x00000100; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const IXOFF: crate::tcflag_t = 0x00010000; +pub const IXON: crate::tcflag_t = 0x00002000; +pub const PARMRK: crate::tcflag_t = 0x00000000; +pub const NOFLSH: crate::tcflag_t = 0x00000000; +pub const NCCS: usize = 20; + +pub const OPOST: crate::tcflag_t = 0x00000001; +pub const ONLCR: crate::tcflag_t = 0x00000004; +pub const ECHO: crate::tcflag_t = 0x00000010; +pub const OCRNL: crate::tcflag_t = 0x00000010; +pub const ECHOE: crate::tcflag_t = 0x00000020; +pub const ECHOK: crate::tcflag_t = 0x00000040; +pub const ECHONL: crate::tcflag_t = 0x00000100; + +// net/if.h +pub const IFNAMSIZ: size_t = 16; +pub const IF_NAMESIZE: size_t = IFNAMSIZ; + +// sioLibCommon.h +pub const CLOCAL: crate::tcflag_t = 0x1; +pub const CREAD: crate::tcflag_t = 0x2; +pub const CS5: crate::tcflag_t = 0x0; +pub const CS6: crate::tcflag_t = 0x4; +pub const CS7: crate::tcflag_t = 0x8; +pub const CS8: crate::tcflag_t = 0xc; +pub const CSTOPB: crate::tcflag_t = 0x20; +pub const CSIZE: crate::tcflag_t = 0xc; + +pub const PARODD: crate::tcflag_t = 0x80; +pub const PARENB: crate::tcflag_t = 0x40; + +pub const DT_FIFO: c_uchar = 1; +pub const DT_CHR: c_uchar = 2; +pub const DT_DIR: c_uchar = 4; +pub const DT_BLK: c_uchar = 6; +pub const DT_REG: c_uchar = 8; +pub const DT_LNK: c_uchar = 10; +pub const DT_SOCK: c_uchar = 12; + +pub const FNM_NOMATCH: c_int = 1; +pub const FNM_NOESCAPE: c_int = 1; +pub const FNM_PATHNAME: c_int = 2; +pub const FNM_PERIOD: c_int = 4; +pub const FNM_CASEFOLD: c_int = 16; + +pub const F_OK: c_int = 0; +pub const X_OK: c_int = 1; +pub const W_OK: c_int = 2; + +pub const _PC_CHOWN_RESTRICTED: c_int = 4; +pub const _PC_LINK_MAX: c_int = 6; +pub const _PC_MAX_CANON: c_int = 7; +pub const _PC_MAX_INPUT: c_int = 8; +pub const _PC_NAME_MAX: c_int = 9; +pub const _PC_NO_TRUNC: c_int = 10; +pub const _PC_PATH_MAX: c_int = 11; +pub const _PC_PIPE_BUF: c_int = 12; +pub const _PC_VDISABLE: c_int = 20; + +pub const HUPCL: crate::tcflag_t = 0x10; pub const SHUT_RD: c_int = 0; pub const SHUT_WR: c_int = 1; pub const SHUT_RDWR: c_int = 2; -pub const IPPROTO_TCP: c_int = 6; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const ICRNL: crate::tcflag_t = 0x00000400; +pub const IEXTEN: crate::tcflag_t = 0x00000000; + pub const TCP_NODELAY: c_int = 1; pub const TCP_MAXSEG: c_int = 2; pub const TCP_NOPUSH: c_int = 3; @@ -850,6 +1124,10 @@ pub const TCP_KEEPIDLE: c_int = 4; pub const TCP_KEEPINTVL: c_int = 5; pub const TCP_KEEPCNT: c_int = 6; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + // ioLib.h pub const FIONREAD: c_int = 0x40040001; pub const FIOFLUSH: c_int = 2; @@ -898,6 +1176,48 @@ pub const F_SETLK: c_int = 8; pub const F_SETLKW: c_int = 9; pub const F_DUPFD_CLOEXEC: c_int = 14; +pub const LOG_EMERG: c_int = 0; +pub const LOG_ALERT: c_int = 1; +pub const LOG_CRIT: c_int = 2; +pub const LOG_ERR: c_int = 3; +pub const LOG_WARNING: c_int = 4; +pub const LOG_NOTICE: c_int = 5; +pub const LOG_INFO: c_int = 6; +pub const LOG_DEBUG: c_int = 7; + +pub const LOG_KERN: c_int = 0 << 3; +pub const LOG_USER: c_int = 1 << 3; +pub const LOG_MAIL: c_int = 2 << 3; +pub const LOG_DAEMON: c_int = 3 << 3; +pub const LOG_AUTH: c_int = 4 << 3; +pub const LOG_SYSLOG: c_int = 5 << 3; +pub const LOG_LPR: c_int = 6 << 3; +pub const LOG_NEWS: c_int = 7 << 3; +pub const LOG_UUCP: c_int = 8 << 3; +pub const LOG_LOCAL0: c_int = 16 << 3; +pub const LOG_LOCAL1: c_int = 17 << 3; +pub const LOG_LOCAL2: c_int = 18 << 3; +pub const LOG_LOCAL3: c_int = 19 << 3; +pub const LOG_LOCAL4: c_int = 20 << 3; +pub const LOG_LOCAL5: c_int = 21 << 3; +pub const LOG_LOCAL6: c_int = 22 << 3; +pub const LOG_LOCAL7: c_int = 23 << 3; + +pub const LOG_PID: c_int = 0x01; +pub const LOG_CONS: c_int = 0x02; +pub const LOG_ODELAY: c_int = 0x04; +pub const LOG_NDELAY: c_int = 0x08; +pub const LOG_NOWAIT: c_int = 0x10; + +pub const LOG_PRIMASK: c_int = 0x7; +pub const LOG_FACMASK: c_int = 0x3f8; + +// dlfcn.h +pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_LAZY: c_int = 1; +pub const RTLD_NOW: c_int = 2; +pub const RTLD_GLOBAL: c_int = 256; + // signal.h pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; @@ -962,6 +1282,11 @@ pub const SI_MESGQ: c_int = -5; pub const SI_CHILD: c_int = -6; pub const SI_KILL: c_int = SI_USER; +pub const AT_FDCWD: c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x100; +pub const AT_REMOVEDIR: c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: c_int = 0x400; + // vxParams.h definitions pub const _PARM_NAME_MAX: c_int = 255; pub const _PARM_PATH_MAX: c_int = 1024; @@ -969,6 +1294,7 @@ pub const _PARM_PATH_MAX: c_int = 1024; // WAIT STUFF pub const WNOHANG: c_int = 0x01; pub const WUNTRACED: c_int = 0x02; +pub const WCONTINUED: c_int = 0x04; const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t = pthread_mutexattr_t { mutexAttrStatus: PTHREAD_INITIALIZED_OBJ, @@ -1026,8 +1352,22 @@ pub const VX_RTP_NAME_LENGTH: c_int = 255; pub const RTP_ID_ERROR: crate::RTP_ID = -1; // h/public/unistd.h -pub const _SC_GETPW_R_SIZE_MAX: c_int = 21; // Via unistd.h +// h/public/unistd.h +pub const R_OK: c_int = 4; +pub const _SC_ARG_MAX: c_int = 4; // Via unistd.h +pub const _SC_CHILD_MAX: c_int = 12; +pub const _SC_CLK_TCK: c_int = 13; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 21; +pub const _SC_HOST_NAME_MAX: c_int = 22; +pub const _SC_NGROUPS_MAX: c_int = 36; +pub const _SC_OPEN_MAX: c_int = 37; +pub const _SC_PAGE_SIZE: c_int = 38; pub const _SC_PAGESIZE: c_int = 39; +pub const _SC_STREAM_MAX: c_int = 59; +pub const _SC_SYMLOOP_MAX: c_int = 60; +pub const _SC_TTY_NAME_MAX: c_int = 87; +pub const _SC_TZNAME_MAX: c_int = 89; +pub const _SC_VERSION: c_int = 94; pub const O_ACCMODE: c_int = 3; pub const O_CLOEXEC: c_int = 0x100000; // fcntlcom pub const O_EXCL: c_int = 0x0800; @@ -1052,23 +1392,19 @@ pub const MAP_ANONYMOUS: c_int = MAP_ANON; pub const MAP_FIXED: c_int = 0x0010; pub const MAP_CONTIG: c_int = 0x0020; +pub const MS_SYNC: c_int = 0x0001; +pub const MS_ASYNC: c_int = 0x0002; +pub const MS_INVALIDATE: c_int = 0x0004; + pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +// sys/ttycom.h +pub const TIOCGWINSZ: c_int = 0x1740087468; +pub const TIOCSWINSZ: c_int = -0x7ff78b99; + +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct } f! { @@ -1171,6 +1507,10 @@ extern "C" { pub fn system(s: *const c_char) -> c_int; pub fn getenv(s: *const c_char) -> *mut c_char; + pub fn cfgetospeed(termios: *const crate::termios) -> crate::speed_t; + pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; + pub fn cfsetispeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + pub fn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; @@ -1188,6 +1528,7 @@ extern "C" { pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, n: size_t) -> size_t; pub fn strerror(n: c_int) -> *mut c_char; pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; @@ -1198,8 +1539,39 @@ extern "C" { pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t; pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; + pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn times(buf: *mut crate::tms) -> crate::clock_t; + pub fn tcflush(fd: c_int, action: c_int) -> c_int; + pub fn pclose(stream: *mut crate::FILE) -> c_int; + pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + + pub fn linkat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + + pub fn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int; + + // netdb.h + pub fn getprotobyname(name: *const c_char) -> *mut protoent; + pub fn getprotobynumber(proto: c_int) -> *mut protoent; + pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; + + pub fn fchownat( + dirfd: c_int, + pathname: *const c_char, + owner: crate::uid_t, + group: crate::gid_t, + flags: c_int, + ) -> c_int; } extern "C" { @@ -1261,6 +1633,7 @@ extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; pub fn pthread_exit(value: *mut c_void) -> !; pub fn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_equal(t1: crate::pthread_t, t2: crate::pthread_t) -> c_int; pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; @@ -1272,6 +1645,13 @@ extern "C" { pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + #[link_name = "_rtld_dlopen"] pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; @@ -1300,6 +1680,7 @@ extern "C" { pub fn usleep(secs: crate::useconds_t) -> c_int; pub fn putenv(string: *mut c_char) -> c_int; pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char; + pub fn localeconv() -> *mut lconv; 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; @@ -1317,7 +1698,19 @@ extern "C" { pub fn setlogmask(maskpri: c_int) -> c_int; pub fn syslog(priority: c_int, message: *const c_char, ...); pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; + pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int; + pub fn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int; + pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int; + pub fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t; + pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int; + + pub fn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int; + // sys/stat.h + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; + + // utime.h + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; } extern "C" { @@ -1727,6 +2120,9 @@ extern "C" { // unistd.h pub fn getppid() -> pid_t; + // unistd.h + pub fn setpgid(pid: pid_t, pgid: pid_t) -> pid_t; + // wait.h pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; @@ -1831,6 +2227,9 @@ extern "C" { // signal.h pub fn sigemptyset(__set: *mut sigset_t) -> c_int; + pub fn sigfillset(set: *mut sigset_t) -> 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; // pthread.h for kernel // signal.h for user @@ -1949,6 +2348,9 @@ safe_f! { pub const fn WEXITSTATUS(status: c_int) -> c_int { status & 0xFF } + pub const fn WIFCONTINUED(status: c_int) -> c_int { + (status >> 24) & 0xFF + } pub const fn WTERMSIG(status: c_int) -> c_int { (status >> 8) & 0xFF } diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index bb3b729548780..9f2539b9400a0 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -33,6 +33,10 @@ pub type wchar_t = i32; pub type nl_item = c_int; pub type __wasi_rights_t = u64; pub type locale_t = *mut __locale_struct; +pub type pthread_t = *mut c_void; +pub type pthread_once_t = c_int; +pub type pthread_key_t = c_uint; +pub type pthread_spinlock_t = c_int; s_no_extra_traits! { #[repr(align(16))] @@ -155,7 +159,7 @@ s! { pub st_mode: mode_t, pub st_uid: uid_t, pub st_gid: gid_t, - __pad0: c_uint, + __pad0: Padding, pub st_rdev: dev_t, pub st_size: off_t, pub st_blksize: blksize_t, @@ -163,13 +167,49 @@ s! { pub st_atim: timespec, pub st_mtim: timespec, pub st_ctim: timespec, - __reserved: [c_longlong; 3], + __reserved: Padding<[c_longlong; 3]>, } pub struct fd_set { __nfds: usize, __fds: [c_int; FD_SETSIZE as usize], } + + pub struct pthread_attr_t { + size: [c_long; 9], + } + + pub struct pthread_mutexattr_t { + __attr: c_uint, + } + + pub struct pthread_condattr_t { + __attr: c_uint, + } + + pub struct pthread_barrierattr_t { + __attr: c_uint, + } + + pub struct pthread_rwlockattr_t { + __attr: [c_uint; 2], + } + + pub struct pthread_cond_t { + size: [*mut c_void; 12], + } + + pub struct pthread_mutex_t { + size: [*mut c_void; 6], + } + + pub struct pthread_rwlock_t { + size: [*mut c_void; 8], + } + + pub struct pthread_barrier_t { + size: [*mut c_void; 5], + } } // Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash, @@ -262,7 +302,9 @@ pub const DT_BLK: u8 = 1; pub const DT_CHR: u8 = 2; pub const DT_DIR: u8 = 3; pub const DT_REG: u8 = 4; +pub const DT_FIFO: u8 = 6; pub const DT_LNK: u8 = 7; +pub const DT_SOCK: u8 = 20; pub const FIONREAD: c_int = 1; pub const FIONBIO: c_int = 2; pub const F_OK: c_int = 0; @@ -438,6 +480,9 @@ pub const NOEXPR: crate::nl_item = 0x50001; pub const YESSTR: crate::nl_item = 0x50002; pub const NOSTR: crate::nl_item = 0x50003; +pub const PTHREAD_STACK_MIN: usize = 2048; +pub const TIMER_ABSTIME: c_int = 1; + f! { pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let set = &*set; @@ -748,6 +793,7 @@ extern "C" { timeout: *const timeval, ) -> c_int; + #[cfg(target_env = "p1")] pub fn __wasilibc_register_preopened_fd(fd: c_int, path: *const c_char) -> c_int; pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int; pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int; @@ -843,6 +889,72 @@ extern "C" { pub fn arc4random_uniform(a: u32) -> u32; pub fn __errno_location() -> *mut c_int; + + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; + + pub fn pthread_self() -> pthread_t; + pub fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn pthread_equal(t1: pthread_t, t2: pthread_t) -> c_int; + pub fn pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int; + 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_getstacksize(attr: *const pthread_attr_t, stacksize: *mut size_t) -> c_int; + pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int; + pub fn pthread_attr_setdetachstate(attr: *mut pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_detach(thread: pthread_t) -> c_int; + + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: Option, + ) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + + pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const timespec, + ) -> c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + + pub fn pthread_rwlock_init( + lock: *mut pthread_rwlock_t, + attr: *const pthread_rwlockattr_t, + ) -> c_int; + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> c_int; + pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> c_int; } cfg_if! { diff --git a/src/windows/gnu/mod.rs b/src/windows/gnu/mod.rs index aee2c1efed108..7ea6a933c8e85 100644 --- a/src/windows/gnu/mod.rs +++ b/src/windows/gnu/mod.rs @@ -18,9 +18,6 @@ cfg_if! { } } -pub const L_tmpnam: c_uint = 14; -pub const TMP_MAX: c_uint = 0x7fff; - // stdio file descriptor numbers pub const STDIN_FILENO: c_int = 0; pub const STDOUT_FILENO: c_int = 1; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 2f35af84c7493..775be13bac91c 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -29,14 +29,11 @@ cfg_if! { pub type off_t = i32; pub type dev_t = u32; pub type ino_t = u16; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } + +extern_ty! { + pub enum timezone {} } + pub type time64_t = i64; pub type SOCKET = crate::uintptr_t; @@ -243,6 +240,9 @@ pub const SIG_GET: crate::sighandler_t = 2; pub const SIG_SGE: crate::sighandler_t = 3; pub const SIG_ACK: crate::sighandler_t = 4; +pub const L_tmpnam: c_uint = 260; +pub const TMP_MAX: c_uint = 0x7fff_ffff; + // DIFF(main): removed in 458c58f409 // FIXME(msrv): done by `std` starting in 1.79.0 // inline comment below appeases style checker @@ -251,21 +251,9 @@ pub const SIG_ACK: crate::sighandler_t = 4; #[link(name = "libcmt", cfg(target_feature = "crt-static"))] extern "C" {} -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(windows): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(windows): fill this out with a struct } // Special handling for all print and scan type functions because of https://github.com/rust-lang/libc/issues/2860 diff --git a/src/windows/msvc/mod.rs b/src/windows/msvc/mod.rs index 5b620bc6c1afa..967df8c57f8bd 100644 --- a/src/windows/msvc/mod.rs +++ b/src/windows/msvc/mod.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub const L_tmpnam: c_uint = 260; -pub const TMP_MAX: c_uint = 0x7fff_ffff; - // POSIX Supplement (from errno.h) // This particular error code is only currently available in msvc toolchain pub const EOTHER: c_int = 131; diff --git a/triagebot.toml b/triagebot.toml index 6a6dfccd18e21..7e8f309b40c67 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -18,6 +18,11 @@ check-commits = false # don't forbid links to issues # Prevents mentions in commits to avoid users being spammed [no-mentions] +# Enable comments linking to triagebot range-diff when a PR is rebased +# onto a different base commit +# Documentation at: https://forge.rust-lang.org/triagebot/range-diff.html +[range-diff] + [autolabel."A-CI"] trigger_files = [ ".cirrus.yml", @@ -29,7 +34,10 @@ trigger_files = [ new_pr = true [autolabel."O-android"] -trigger_files = ["src/unix/linux_like/android"] +trigger_files = [ + "src/new/bionic_libc", + "src/unix/linux_like/android", +] [autolabel."O-arm"] trigger_files = [ @@ -70,7 +78,11 @@ trigger_files = [ trigger_files = ["src/unix/linux_like/mod.rs"] [autolabel."O-macos"] -trigger_files = ["src/unix/bsd/apple"] +trigger_files = [ + "src/unix/bsd/apple", + "src/new/apple_lib", + "src/new/apple_xnu", +] [autolabel."O-mips"] trigger_files = [