diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 70b3fbd1e2ce..4014d75b0780 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,12 +51,18 @@ jobs: name: Verify build strategy: matrix: - toolchain: [stable, nightly, 1.63.0] - os: [ubuntu-24.04, macos-15, windows-2025] + 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 }} @@ -78,12 +84,15 @@ 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" \ + ${{ 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,41 +101,25 @@ 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-2025 - env: - ARCH_BITS: 64 - ARCH: x86_64 - - target: x86_64-pc-windows-msvc - os: windows-2025 + - 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-2025 - runs-on: ${{ matrix.os }} + - 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 }} @@ -146,17 +139,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,79 +159,64 @@ 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 + 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 }} @@ -257,14 +235,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) }} @@ -277,13 +259,14 @@ jobs: strategy: fail-fast: true matrix: - target: - - x86_64-pc-solaris + include: + - target: x86_64-pc-solaris timeout-minutes: 25 steps: - uses: actions/checkout@v5 - name: test on Solaris uses: vmactions/solaris-vm@v1.1.5 + if: contains(matrix.target, 'solaris') with: release: "11.4-gcc" usesh: true diff --git a/Cargo.lock b/Cargo.lock index 512d405c94c0..30d8813e9114 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" @@ -90,9 +90,9 @@ dependencies = [ [[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" @@ -120,9 +120,9 @@ 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" @@ -184,9 +184,9 @@ dependencies = [ [[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", @@ -196,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", @@ -207,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" @@ -316,9 +316,9 @@ 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/README.md b/README.md index c616d8b29f52..607bf308d01e 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 0d1cef644057..b2c63f673c4d 100644 --- a/build.rs +++ b/build.rs @@ -21,6 +21,7 @@ const ALLOWED_CFGS: &[&str] = &[ // 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. @@ -85,6 +86,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 @@ -274,6 +281,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/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index 8ed15a5234d1..0e5baf085423 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 a4faeb4a8b96..e6b1798b1cfb 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 f57c5fa6055c..3bbf58aa3b8b 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 e81623f7bf0e..23afe49970e7 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 8f2d3ea80d06..e6cdf778d78c 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 c6bd116b6f1c..e4628e8befbd 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 330493f54a1d..284389360ac2 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 c8fb40cc3d3c..312eca1146db 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 24d15872efd0..96507d7fc227 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 fae0b566d33f..5a2f4c9dd43e 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 287f325e9151..82f2b786eda2 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 138b9a195adb..ab13f33f1187 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 ec632c33f7af..dcf75b428a29 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 535202951d2c..99c5f1389209 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 a8a9dd8c9226..f7907a32347a 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 0d6110f39149..f2f0a6e20c7b 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 40a661149f7d..c21ce6a3d509 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 43138af5da23..10395b72406b 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 aa3490228c4d..4e0e3e7d514f 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 0dfad20fb7a1..58133e216c84 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 c55d57105a11..728586f11954 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -1,11 +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 + 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 969a0ffca0be..e068ad59f94c 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/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index 950c2a9fdc61..76b80a894b2b 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 3e9494809502..ed9734ca2b6f 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 92a92b1dfe98..0d5cdd7daafb 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 194a6e7847f5..5b524c31eff7 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 f5516553707d..d43e29470dab 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -5,12 +5,15 @@ 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 diff --git a/ci/run-docker.sh b/ci/run-docker.sh index db10c3b061ba..c34bcff6ed78 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 0938b695d403..8a7abf2e20f7 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -25,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/verify-build.py b/ci/verify-build.py new file mode 100755 index 000000000000..483dc5cfa96f --- /dev/null +++ b/ci/verify-build.py @@ -0,0 +1,388 @@ +#!/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 typing import Optional + + +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) + + 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 + + +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): + print(*args, file=sys.stderr, **kw) + + +def xtrace(args: list[str], /, env: Optional[dict[str, str]]): + """Print commands before running them.""" + astr = " ".join(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: list[str], /, env: Optional[dict[str, str]] = None) -> str: + xtrace(args, env=env) + return sp.check_output(args, env=env, encoding="utf8") + + +def run(args: list[str], /, env: Optional[dict[str, str]] = None): + xtrace(args, env=env) + sp.run(args, env=env, check=True) + + +def check_dup_targets(): + 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 test_target(cfg: Cfg, target: 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 `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)}, + ) + + is_stable = cfg.toolchain == Toolchain.STABLE + # FIXME(semver): can't pass `--target` to `cargo-semver-checks` so we restrict to + # the host target + is_host = tname == cfg.host_target + if is_stable and is_host: + eprint("Running semver checks") + run( + [ + "cargo", + "semver-checks", + "--only-explicit-features", + "--features=std,extra_traits", + ] + ) + else: + eprint("Skipping semver checks") + + elapsed = round(time.time() - start, 2) + eprint(f"Finished checking target {tname} in {elapsed} seconds") + + +def main(): + 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( + "--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) + 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" + + 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}") + test_target(cfg, target) + eprint("::endgroup::") + + elapsed = round(time.time() - start, 2) + eprint(f"Checked {total} targets in {elapsed} seconds") + + +main() diff --git a/ci/verify-build.sh b/ci/verify-build.sh deleted file mode 100755 index e833de2e04c5..000000000000 --- 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/libc-test/Cargo.toml b/libc-test/Cargo.toml index f761bab3a4dd..a1b54af127ae 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.1" -regex = "1.11.1" +regex = "1.12.2" [features] default = ["std"] diff --git a/libc-test/build.rs b/libc-test/build.rs index 51457f3b4f6e..c31fa7e3fb5d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -106,7 +106,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. @@ -317,7 +317,7 @@ fn test_apple(target: &str) { (x86_64, "crt_externs.h"), ); - cfg.skip_struct(|s| { + cfg.skip_struct(move |s| { match s.ident() { // FIXME(union): actually a union "sigval" => true, @@ -326,6 +326,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" if x86_64 => true, _ => false, } }); @@ -351,6 +354,8 @@ 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 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, _ => false, @@ -3472,13 +3477,33 @@ 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(); + + 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", @@ -3495,13 +3520,11 @@ fn test_vxworks(target: &str) { "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", @@ -3513,6 +3536,9 @@ fn test_vxworks(target: &str) { "stdio.h", "stdlib.h", "string.h", + "sys/select.h", + "sys/stat.h", + "sys/poll.h", "sys/file.h", "sys/ioctl.h", "sys/socket.h", @@ -3523,7 +3549,14 @@ fn test_vxworks(target: &str) { "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", @@ -3532,16 +3565,22 @@ fn test_vxworks(target: &str) { "utime.h", "wchar.h", "errno.h", - "sys/mman.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) @@ -3552,7 +3591,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, }, ); @@ -3571,11 +3615,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(); } @@ -4079,8 +4128,14 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.12 kernel headers. "mnt_ns_info" => true, - // Struct has changed for new musl versions - "tcp_info" if old_musl => 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, + + // FIXME(musl): New fields in newer versions + "utmpx" if !old_musl => true, _ => false, } @@ -4134,35 +4189,26 @@ fn test_linux(target: &str) { if name.starts_with("NI_IDN") { 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; - } - // FIXME: Does not exist on non-x86 architectures, slated for removal - // in libc in 1.0 - if ppc64 && name == "MAP_32BIT" { - return true; - } - } - if old_musl { - // Constants that don't exist on the old version of musl we test with, but do exist - // on newer versions. + match name { - "FAN_EVENT_INFO_TYPE_ERROR" + // 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" @@ -4175,21 +4221,39 @@ fn test_linux(target: &str) { | "FAN_REPORT_TARGET_FID" | "FAN_RESPONSE_INFO_AUDIT_RULE" | "FAN_RESPONSE_INFO_NONE" - | "IPPROTO_ETHERNET" - | "IPPROTO_MPTCP" | "PR_GET_MDWE" | "PR_MDWE_NO_INHERIT" | "PR_MDWE_REFUSE_EXEC_GAIN" | "PR_SET_MDWE" - | "RLIM_NLIMITS" + | "IPPROTO_ETHERNET" + | "IPPROTO_MPTCP" | "SI_DETHREAD" - | "SO_BUSY_POLL_BUDGET" - | "SO_PREFER_BUSY_POLL" => return true, - // Values changed in newer musl versions on these arches + | "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 @@ -4302,23 +4366,6 @@ fn test_linux(target: &str) { // is a private value for kernel usage normally "FUSE_SUPER_MAGIC" => true, - // Not present on old musl - "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" - if old_musl => - { - true - } - // Not present in glibc "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" if gnu => true, @@ -4509,20 +4556,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 @@ -4548,9 +4597,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, } }); @@ -4660,7 +4706,7 @@ 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 @@ -5352,11 +5398,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 diff --git a/libc-test/semver/vxworks.txt b/libc-test/semver/vxworks.txt new file mode 100644 index 000000000000..bb5f32ccc608 --- /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/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 5a3d0784c434..134a2faf8796 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -1468,9 +1468,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; diff --git a/src/macros.rs b/src/macros.rs index a5359db0f62c..eec90c7e44cc 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -142,30 +142,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)* } } ); } @@ -202,17 +202,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 { @@ -222,7 +222,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( @@ -231,7 +231,7 @@ macro_rules! s_no_extra_traits { ::core::fmt::Debug, )] $(#[$attr])* - pub struct $i { $($field)* } + $pub struct $i { $($field)* } } ); } @@ -427,6 +427,23 @@ 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; @@ -528,4 +545,62 @@ mod tests { 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 index 79645f12d736..c99b206b7168 100644 --- a/src/new/aix/mod.rs +++ b/src/new/aix/mod.rs @@ -2,3 +2,5 @@ //! //! * 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 000000000000..8d55ee582331 --- /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/mod.rs b/src/new/apple_libc/mod.rs index f53b8baa38ea..d7fcc90d12ff 100644 --- a/src/new/apple_libc/mod.rs +++ b/src/new/apple_libc/mod.rs @@ -1,3 +1,6 @@ //! Entrypoint for Apple headers, usually found as part of the Xcode SDK. +//! +//! pub(crate) mod signal; +pub(crate) mod unistd; diff --git a/src/new/apple_libc/signal.rs b/src/new/apple_libc/signal.rs index 971c47318c04..b5f8d59b2d7f 100644 --- a/src/new/apple_libc/signal.rs +++ b/src/new/apple_libc/signal.rs @@ -1,5 +1,5 @@ //! Header: `signal.h` //! -//! https://github.com/apple-oss-distributions/Libc/blob/main/include/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 000000000000..8d55ee582331 --- /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_xnu/arm/_mcontext.rs b/src/new/apple_xnu/arm/_mcontext.rs index e57bc4f8adb0..ae22f7a4ec77 100644 --- a/src/new/apple_xnu/arm/_mcontext.rs +++ b/src/new/apple_xnu/arm/_mcontext.rs @@ -1,6 +1,6 @@ //! Header: `arm/_mcontext.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/arm/_mcontext.h +//! pub use crate::mach::machine::_structs::*; diff --git a/src/new/apple_xnu/i386/_mcontext.rs b/src/new/apple_xnu/i386/_mcontext.rs index 8ca3b116d9f2..2b07ad1bf6e6 100644 --- a/src/new/apple_xnu/i386/_mcontext.rs +++ b/src/new/apple_xnu/i386/_mcontext.rs @@ -1,6 +1,6 @@ //! Header: `i386/_mcontext.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/i386/_mcontext.h +//! pub use crate::mach::machine::_structs::*; diff --git a/src/new/apple_xnu/mach/arm/_structs.rs b/src/new/apple_xnu/mach/arm/_structs.rs index d8d3b958ad5d..c0ebce437aed 100644 --- a/src/new/apple_xnu/mach/arm/_structs.rs +++ b/src/new/apple_xnu/mach/arm/_structs.rs @@ -1,6 +1,6 @@ //! Header: `arm/_structs.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/arm/_structs.h +//! #[cfg(target_arch = "arm")] use crate::prelude::*; diff --git a/src/new/apple_xnu/mach/i386/_structs.rs b/src/new/apple_xnu/mach/i386/_structs.rs index ea274e26a688..15822f7710de 100644 --- a/src/new/apple_xnu/mach/i386/_structs.rs +++ b/src/new/apple_xnu/mach/i386/_structs.rs @@ -1,6 +1,6 @@ //! Header: `i386/_structs.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/i386/_structs.h +//! use crate::prelude::*; diff --git a/src/new/apple_xnu/mach/machine/_structs.rs b/src/new/apple_xnu/mach/machine/_structs.rs index 47df1005c86f..6acae8d9acbd 100644 --- a/src/new/apple_xnu/mach/machine/_structs.rs +++ b/src/new/apple_xnu/mach/machine/_structs.rs @@ -1,6 +1,6 @@ //! Header: `mach/machine/_structs.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/machine/_structs.h +//! cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { diff --git a/src/new/apple_xnu/mach/mod.rs b/src/new/apple_xnu/mach/mod.rs index d5fbee83e970..90751260a7a7 100644 --- a/src/new/apple_xnu/mach/mod.rs +++ b/src/new/apple_xnu/mach/mod.rs @@ -1,6 +1,6 @@ //! Directory: `mach/` //! -//! https://github.com/apple-oss-distributions/xnu/tree/main/osfmk/mach +//! /// Directory: `mach/arm` #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] diff --git a/src/new/apple_xnu/sys/mod.rs b/src/new/apple_xnu/sys/mod.rs index 8fdbe2846b58..5a7545792669 100644 --- a/src/new/apple_xnu/sys/mod.rs +++ b/src/new/apple_xnu/sys/mod.rs @@ -1,6 +1,6 @@ //! Directory: `sys/` //! -//! https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys +//! pub(crate) mod signal; diff --git a/src/new/apple_xnu/sys/signal.rs b/src/new/apple_xnu/sys/signal.rs index 8399c830dc8c..844793e119b3 100644 --- a/src/new/apple_xnu/sys/signal.rs +++ b/src/new/apple_xnu/sys/signal.rs @@ -1,6 +1,6 @@ //! Header: `sys/signal.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/signal.h +//! pub use crate::machine::_mcontext::*; pub use crate::sys::_types::_ucontext::*; diff --git a/src/new/bionic_libc/mod.rs b/src/new/bionic_libc/mod.rs index 2863b72cc2ed..b608e2f123c9 100644 --- a/src/new/bionic_libc/mod.rs +++ b/src/new/bionic_libc/mod.rs @@ -3,3 +3,4 @@ //! pub(crate) mod sys; +pub(crate) mod unistd; diff --git a/src/new/bionic_libc/unistd.rs b/src/new/bionic_libc/unistd.rs new file mode 100644 index 000000000000..8d55ee582331 --- /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/mod.rs b/src/new/common/mod.rs index cb0588ca2610..acb18917c899 100644 --- a/src/new/common/mod.rs +++ b/src/new/common/mod.rs @@ -16,7 +16,7 @@ target_os = "netbsd", target_os = "openbsd", ))] -mod bsd; +pub(crate) mod bsd; #[cfg(any( target_os = "android", @@ -24,15 +24,16 @@ mod bsd; target_os = "l4re", target_os = "linux", ))] -mod linux_like; +pub(crate) mod linux_like; #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] -mod freebsd_like; +pub(crate) mod freebsd_like; #[cfg(any(target_os = "netbsd", target_os = "openbsd"))] -mod netbsd_like; +pub(crate) mod netbsd_like; #[cfg(any(target_os = "illumos", target_os = "solaris"))] -mod solarish; +pub(crate) mod solarish; -mod posix; +#[cfg(target_family = "unix")] +pub(crate) mod posix; diff --git a/src/new/common/posix/mod.rs b/src/new/common/posix/mod.rs index cb33296a9c65..454b840404c9 100644 --- a/src/new/common/posix/mod.rs +++ b/src/new/common/posix/mod.rs @@ -1 +1,3 @@ //! POSIX APIs that are used by a number of platforms + +pub(crate) mod unistd; diff --git a/src/new/common/posix/unistd.rs b/src/new/common/posix/unistd.rs new file mode 100644 index 000000000000..0c02cbaa699f --- /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/cygwin/mod.rs b/src/new/cygwin/mod.rs index 29d62f02f9fe..356ae587653d 100644 --- a/src/new/cygwin/mod.rs +++ b/src/new/cygwin/mod.rs @@ -1,3 +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 000000000000..8d55ee582331 --- /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 index 9ea26f522be6..4a1b2c4998d0 100644 --- a/src/new/dragonfly/mod.rs +++ b/src/new/dragonfly/mod.rs @@ -2,3 +2,5 @@ //! //! * 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 000000000000..8d55ee582331 --- /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 index e58a3aceada1..fec0fe3bfdd4 100644 --- a/src/new/emscripten/mod.rs +++ b/src/new/emscripten/mod.rs @@ -1,3 +1,5 @@ //! Emscripten libc. //! //! * Headers: + +pub(crate) mod unistd; diff --git a/src/new/emscripten/unistd.rs b/src/new/emscripten/unistd.rs new file mode 100644 index 000000000000..8d55ee582331 --- /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/freebsd/mod.rs b/src/new/freebsd/mod.rs index a1241c7a68ce..87c2e487560b 100644 --- a/src/new/freebsd/mod.rs +++ b/src/new/freebsd/mod.rs @@ -2,3 +2,5 @@ //! //! * 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 000000000000..8d55ee582331 --- /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 index c1d275c95b3f..b3a908349bf3 100644 --- a/src/new/fuchsia/mod.rs +++ b/src/new/fuchsia/mod.rs @@ -1,2 +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 000000000000..8d55ee582331 --- /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 index 871482090641..534aba86a493 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -2,3 +2,24 @@ //! //! * 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 { + pub(crate) mod unix; +} + +pub(crate) use posix::*; +#[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 000000000000..907066c458df --- /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/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs new file mode 100644 index 000000000000..0ecee596c5b1 --- /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 000000000000..2851451652df --- /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 000000000000..55a895d4d0de --- /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 index c119b6737626..a565afe10d9c 100644 --- a/src/new/haiku/mod.rs +++ b/src/new/haiku/mod.rs @@ -1,2 +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 000000000000..8d55ee582331 --- /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/illumos/mod.rs b/src/new/illumos/mod.rs index 66f6cb1ffd3c..83d15da8801f 100644 --- a/src/new/illumos/mod.rs +++ b/src/new/illumos/mod.rs @@ -1,2 +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 000000000000..8d55ee582331 --- /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/mod.rs b/src/new/mod.rs index 27f232cb5688..1846ada479fb 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -43,7 +43,7 @@ mod common; cfg_if! { if #[cfg(target_os = "aix")] { mod aix; - // pub(crate) use aix::*; + pub(crate) use aix::*; } else if #[cfg(target_os = "android")] { mod bionic_libc; pub(crate) use bionic_libc::*; @@ -54,25 +54,25 @@ cfg_if! { pub(crate) use apple_xnu::*; } else if #[cfg(target_os = "cygwin")] { mod cygwin; - // pub(crate) use cygwin::*; + pub(crate) use cygwin::*; } else if #[cfg(target_os = "dragonfly")] { mod dragonfly; - // pub(crate) use dragonfly::*; + pub(crate) use dragonfly::*; } else if #[cfg(target_os = "emscripten")] { mod emscripten; - // pub(crate) use 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::*; + pub(crate) use freebsd::*; } else if #[cfg(target_os = "fuchsia")] { mod fuchsia; - // pub(crate) use fuchsia::*; + pub(crate) use fuchsia::*; } else if #[cfg(target_os = "haiku")] { mod haiku; - // pub(crate) use haiku::*; + pub(crate) use haiku::*; } else if #[cfg(target_os = "hermit")] { mod hermit_abi; // pub(crate) use hermit_abi::*; @@ -84,7 +84,7 @@ cfg_if! { // pub(crate) use hurd::*; } else if #[cfg(target_os = "illumos")] { mod illumos; - // pub(crate) use illumos::*; + pub(crate) use illumos::*; } else if #[cfg(target_os = "l4re")] { mod l4re; // pub(crate) use l4re::*; @@ -93,25 +93,25 @@ cfg_if! { pub(crate) use linux_uapi::*; } else if #[cfg(target_os = "netbsd")] { mod netbsd; - // pub(crate) use netbsd::*; + pub(crate) use netbsd::*; } else if #[cfg(target_os = "nto")] { mod nto; - // pub(crate) use nto::*; + pub(crate) use nto::*; } else if #[cfg(target_os = "nuttx")] { mod nuttx; - // pub(crate) use nuttx::*; + pub(crate) use nuttx::*; } else if #[cfg(target_os = "openbsd")] { mod openbsd; - // pub(crate) use 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::*; + pub(crate) use rtems::*; } else if #[cfg(target_os = "solaris")] { mod solaris; - // pub(crate) use solaris::*; + pub(crate) use solaris::*; } else if #[cfg(target_os = "solid_asp3")] { mod solid; // pub(crate) use solid::*; @@ -126,7 +126,7 @@ cfg_if! { // pub(crate) use vita::*; } else if #[cfg(target_os = "vxworks")] { mod vxworks; - // pub(crate) use vxworks::*; + pub(crate) use vxworks::*; } else if #[cfg(target_os = "wasi")] { mod wasi; // pub(crate) use wasi::*; @@ -141,28 +141,34 @@ cfg_if! { // Multi-platform libc cfg_if! { - if #[cfg(target_env = "gnu")] { + // 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(target_env = "musl")] { + 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::*; + pub(crate) use musl::*; } else if #[cfg(target_env = "newlib")] { mod newlib; - // pub(crate) use newlib::*; + pub(crate) use newlib::*; } else if #[cfg(target_env = "relibc")] { mod relibc; - // pub(crate) use 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::*; + pub(crate) use uclibc::*; } } -// Headers we export +// Per-OS headers we export cfg_if! { if #[cfg(target_os = "android")] { pub use sys::socket::*; @@ -172,7 +178,19 @@ cfg_if! { 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 signal::*; } } + +// Per-env headers we export +cfg_if! { + if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + pub use sys::socket::*; + } +} + +#[cfg(target_family = "unix")] +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 000000000000..ac02505c882b --- /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 000000000000..77b53e489c3d --- /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 000000000000..2f02036d254c --- /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 000000000000..77b53e489c3d --- /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 000000000000..6a45b067b998 --- /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 000000000000..514d7b4bdfea --- /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 index 49f9abae21fb..d6297a8d27dd 100644 --- a/src/new/musl/mod.rs +++ b/src/new/musl/mod.rs @@ -2,3 +2,29 @@ //! //! * 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. + } + } +} + +/// Directory: `sys/` +/// +/// +pub(crate) mod sys { + pub(crate) mod socket; +} + +pub(crate) mod unistd; diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs new file mode 100644 index 000000000000..f7105c9bbca1 --- /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 000000000000..8d55ee582331 --- /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 index 14b6a5f869e8..b43e7aeb088d 100644 --- a/src/new/netbsd/mod.rs +++ b/src/new/netbsd/mod.rs @@ -1,3 +1,5 @@ //! NetBSD libc. //! //! * Manual pages: + +pub(crate) mod unistd; diff --git a/src/new/netbsd/unistd.rs b/src/new/netbsd/unistd.rs new file mode 100644 index 000000000000..8d55ee582331 --- /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/newlib/mod.rs b/src/new/newlib/mod.rs index d5564cafcfd5..b5c7e3dc73a0 100644 --- a/src/new/newlib/mod.rs +++ b/src/new/newlib/mod.rs @@ -1,2 +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 000000000000..8d55ee582331 --- /dev/null +++ b/src/new/newlib/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/nto/mod.rs b/src/new/nto/mod.rs index 8fa2d814eb8d..df8ec183bd78 100644 --- a/src/new/nto/mod.rs +++ b/src/new/nto/mod.rs @@ -1,2 +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 000000000000..8d55ee582331 --- /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 index 89b9c05e849b..513c945dbfd9 100644 --- a/src/new/nuttx/mod.rs +++ b/src/new/nuttx/mod.rs @@ -1,2 +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 000000000000..8d55ee582331 --- /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 index f97044effe76..d5debb80f392 100644 --- a/src/new/openbsd/mod.rs +++ b/src/new/openbsd/mod.rs @@ -2,3 +2,5 @@ //! //! * Headers: //! * Manual pages: + +pub(crate) mod unistd; diff --git a/src/new/openbsd/unistd.rs b/src/new/openbsd/unistd.rs new file mode 100644 index 000000000000..8d55ee582331 --- /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/relibc/mod.rs b/src/new/relibc/mod.rs index baf26912ec7f..d2449123218a 100644 --- a/src/new/relibc/mod.rs +++ b/src/new/relibc/mod.rs @@ -1,3 +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 000000000000..8d55ee582331 --- /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/sgx/mod.rs b/src/new/sgx/mod.rs index 8b137891791f..8c15dadb4a0b 100644 --- a/src/new/sgx/mod.rs +++ b/src/new/sgx/mod.rs @@ -1 +1 @@ - +//! Fortanix SGX. diff --git a/src/new/sgx/unistd.rs b/src/new/sgx/unistd.rs new file mode 100644 index 000000000000..8d55ee582331 --- /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 index b5d55492995d..97ae47333deb 100644 --- a/src/new/solaris/mod.rs +++ b/src/new/solaris/mod.rs @@ -1,3 +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 000000000000..8d55ee582331 --- /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/uclibc/mod.rs b/src/new/uclibc/mod.rs index eda4b01d92d2..4cb25389c91b 100644 --- a/src/new/uclibc/mod.rs +++ b/src/new/uclibc/mod.rs @@ -2,3 +2,5 @@ //! //! * About: //! * Headers: (mirror) + +pub(crate) mod unistd; diff --git a/src/new/uclibc/unistd.rs b/src/new/uclibc/unistd.rs new file mode 100644 index 000000000000..8d55ee582331 --- /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/vita/mod.rs b/src/new/vita/mod.rs index 21205ebd046f..38783a3f19fb 100644 --- a/src/new/vita/mod.rs +++ b/src/new/vita/mod.rs @@ -1,2 +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 000000000000..8d55ee582331 --- /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 index a3116fce0380..65630565e53e 100644 --- a/src/new/vxworks/mod.rs +++ b/src/new/vxworks/mod.rs @@ -1,2 +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 000000000000..8d55ee582331 --- /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/unix/aix/mod.rs b/src/unix/aix/mod.rs index b699a3c8001c..0b91a22cae8c 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -326,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, @@ -1273,7 +1275,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; @@ -2272,9 +2275,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 1b62859ae163..f3a4419efb38 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -448,7 +448,7 @@ cfg_if! { 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/mod.rs b/src/unix/bsd/apple/mod.rs index ec05791d9aed..e85323c73227 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2932,9 +2932,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/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 453d3e0734f0..98996f260709 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -572,9 +572,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/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 294d334490bc..dc5e4528cf29 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -191,9 +191,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/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 028ac80cb52d..0e5faff17fb8 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1325,9 +1325,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; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 98764c497f0f..7c3f07e0ad9b 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -746,9 +746,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/hurd/mod.rs b/src/unix/hurd/mod.rs index acd0981b1a8b..a0be74022e25 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -1172,9 +1172,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/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index afd9fe339618..b877fc296d5d 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -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, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 45031ab2aa32..ebbc9a44818e 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1187,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, @@ -5739,16 +5739,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 } @@ -6752,7 +6756,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 a04f05ea50db..189a294ea624 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -272,9 +272,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 b68795355418..1c29114338ad 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -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 7564dcf612f9..d8c3ee9d5473 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -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; diff --git a/src/unix/linux_like/linux/musl/b32/mod.rs b/src/unix/linux_like/linux/musl/b32/mod.rs index 00b3d7705090..ac76d3c65970 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 a07dfda17794..60305b304101 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -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 d78df7528d26..04ecf1b46c42 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -207,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 ae8b7d761dd6..43ea2e88ff46 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -314,9 +314,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 67151a8d3711..087e39001e84 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -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 6ae9637cb58c..c151b0ec3204 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -573,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 95dd37c88980..4d40637c0cb9 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -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 1bfd812ab2a3..35545402d11d 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -48,34 +48,6 @@ s! { __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, - } - pub struct sem_t { __val: [c_int; 8], } diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index bbcd382211df..34d56192a585 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -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 cd93ef706dee..29e950cc372f 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -567,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 490d130c65bc..c0332205a794 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -165,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 00dc4e5b97f2..903bd48a3732 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -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; 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 ce8319f015e9..ebb8084468b6 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 @@ -818,9 +818,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/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 4bc11449145c..813bba693097 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -848,20 +848,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/mod.rs b/src/unix/linux_like/mod.rs index 0b1f376233a6..b431643dfa3e 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -540,9 +540,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; @@ -2074,7 +2071,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; @@ -2134,7 +2135,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/newlib/mod.rs b/src/unix/newlib/mod.rs index 0193083f4e63..abec6d4991c3 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -557,10 +557,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/nto/mod.rs b/src/unix/nto/mod.rs index a81c210c80cf..0ac1e682268f 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -1054,10 +1054,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; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index fe7c6ecb3007..79e3f170e0c1 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -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; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 55a8c15a234e..9567099e59c4 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1066,9 +1066,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; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index f78b09a3db63..fd52e353ef1d 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1146,9 +1146,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/vxworks/mod.rs b/src/vxworks/mod.rs index ce6c91678caf..5f22a7cee729 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -16,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; @@ -215,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, @@ -235,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 */ @@ -254,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, } @@ -325,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, @@ -360,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, @@ -392,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! { @@ -485,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; @@ -496,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(); @@ -683,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; @@ -702,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; @@ -713,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; @@ -813,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; @@ -822,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; @@ -840,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; @@ -888,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; @@ -952,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; @@ -959,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, @@ -1016,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; @@ -1042,8 +1392,16 @@ 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; +// 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 @@ -1149,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; @@ -1166,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; @@ -1176,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" { @@ -1239,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; @@ -1250,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; @@ -1278,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; @@ -1295,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" { @@ -1705,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; @@ -1809,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 @@ -1927,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 }