From 8e77cc51a75e820fdaef987344f3374a3d6e30a3 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 3 Apr 2025 04:02:49 +0000 Subject: [PATCH 01/25] Make triagebot aware of labels related to `ctest` (backport ) (cherry picked from commit 009619644b96a94dc13802901c09792255de2e48) --- triagebot.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/triagebot.toml b/triagebot.toml index d4ad3459c1fc8..c749fc11d9445 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -3,6 +3,7 @@ allow-unauthenticated = [ "C-*", "O-*", "S-*", + "ctest", "stable-nominated", ] @@ -152,6 +153,12 @@ trigger_files = [ "src/vxworks/x86_64.rs", ] +[autolabel.ctest] +trigger_files = [ + "ctest", + "ctest-test", +] + [review-submitted] # These labels are removed when a review is submitted. review_labels = ["S-waiting-on-review"] From 704a28cad7a4c6c39a66d8e81c275bc0343efdf4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 3 Apr 2025 19:14:00 +0000 Subject: [PATCH 02/25] Add links to common header sources in the PR template (backport ) (cherry picked from commit 5adc1ecc46f4b39cd76fc13ad1cda1ba13e1ab38) --- .github/PULL_REQUEST_TEMPLATE.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5aafd9213ef20..c3d315acc5ada 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,8 +12,20 @@ Please fill out the below template. # Sources - + # Checklist From a96d4548468195fcb1fa2607a968db4bf2b41702 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sun, 6 Apr 2025 05:22:49 -0700 Subject: [PATCH 03/25] Define Linux ioctl codes on more architectures. Define ioctl codes including `FICLONE` and `FS_IOC32_GETVERSION` using `_IOR` and `_IOW` so that they're automatically supported on all architectures, including riscv32gc-unknown-linux-gnu. (backport ) (cherry picked from commit 4b439b0953573e0383da7e092b1f516ba21f3398) --- src/unix/linux_like/linux/arch/generic/mod.rs | 75 ++++--------------- 1 file changed, 15 insertions(+), 60 deletions(-) diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 61d2e3fe19180..ec3179b431f97 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -use crate::Ioctl; +use crate::{Ioctl, _IOR, _IOW}; s! { pub struct termios2 { @@ -158,21 +158,8 @@ pub const SO_DEVMEM_LINEAR: c_int = 78; pub const SO_DEVMEM_DMABUF: c_int = 79; pub const SO_DEVMEM_DONTNEED: c_int = 80; -cfg_if! { - if #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "riscv64", - target_arch = "s390x", - target_arch = "csky", - target_arch = "loongarch64" - ))] { - pub const FICLONE: c_ulong = 0x40049409; - pub const FICLONERANGE: c_ulong = 0x4020940D; - } -} +pub const FICLONE: Ioctl = _IOW::(0x94, 9) as Ioctl; +pub const FICLONERANGE: Ioctl = _IOW::(0x94, 13) as Ioctl; // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; @@ -293,50 +280,18 @@ pub const TUNGETVNETBE: Ioctl = 0x800454df; pub const TUNSETSTEERINGEBPF: Ioctl = 0x800454e0; pub const TUNSETFILTEREBPF: Ioctl = 0x800454e1; -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(any( - target_arch = "x86", - target_arch = "arm", - target_arch = "csky" - ))] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x80046601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x40046602; - pub const FS_IOC_GETVERSION: Ioctl = 0x80047601; - pub const FS_IOC_SETVERSION: Ioctl = 0x40047602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x80046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x40046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x80047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x40047602; - pub const TUNATTACHFILTER: Ioctl = 0x400854d5; - pub const TUNDETACHFILTER: Ioctl = 0x400854d6; - pub const TUNGETFILTER: Ioctl = 0x800854db; - } else if #[cfg(any( - target_arch = "x86_64", - target_arch = "riscv64", - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - target_arch = "wasm32" - ))] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x80086601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x40086602; - pub const FS_IOC_GETVERSION: Ioctl = 0x80087601; - pub const FS_IOC_SETVERSION: Ioctl = 0x40087602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x80046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x40046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x80047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x40047602; - pub const TUNATTACHFILTER: Ioctl = 0x401054d5; - pub const TUNDETACHFILTER: Ioctl = 0x401054d6; - pub const TUNGETFILTER: Ioctl = 0x801054db; - } -} +pub const FS_IOC_GETFLAGS: Ioctl = _IOR::('f' as u32, 1) as Ioctl; +pub const FS_IOC_SETFLAGS: Ioctl = _IOW::('f' as u32, 2) as Ioctl; +pub const FS_IOC_GETVERSION: Ioctl = _IOR::('v' as u32, 1) as Ioctl; +pub const FS_IOC_SETVERSION: Ioctl = _IOW::('v' as u32, 2) as Ioctl; +pub const FS_IOC32_GETFLAGS: Ioctl = _IOR::('f' as u32, 1) as Ioctl; +pub const FS_IOC32_SETFLAGS: Ioctl = _IOW::('f' as u32, 2) as Ioctl; +pub const FS_IOC32_GETVERSION: Ioctl = _IOR::('v' as u32, 1) as Ioctl; +pub const FS_IOC32_SETVERSION: Ioctl = _IOW::('v' as u32, 2) as Ioctl; + +pub const TUNATTACHFILTER: Ioctl = _IOW::('T' as u32, 213) as Ioctl; +pub const TUNDETACHFILTER: Ioctl = _IOW::('T' as u32, 214) as Ioctl; +pub const TUNGETFILTER: Ioctl = _IOR::('T' as u32, 219) as Ioctl; cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] { From f7f3c7c9cb514275bc2bff749961ea0e25063d33 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Apr 2025 01:50:56 +0000 Subject: [PATCH 04/25] FreeBSD: Deprecate TCP_PCAP_OUT and TCP_PCAP_IN FreeBSD removed these upstream in [1], so deprecate them here. This resolves a recent CI failure. These constants were originally added in [2]. [1]: https://github.com/freebsd/freebsd-src/commit/6e76489098c6dc415ac3f2ae084154c3c22558ec [2]: https://github.com/rust-lang/libc/pull/1151 (backport ) (cherry picked from commit c8f09101420163c946cc3ecbb27de54263a3effb) --- libc-test/build.rs | 3 +++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 9b28def466c70..3cc6a1042550a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2855,6 +2855,9 @@ fn test_freebsd(target: &str) { "CAP_UNUSED0_44" | "CAP_UNUSED0_57" | "CAP_UNUSED1_22" | "CAP_UNUSED1_57" | "CAP_ALL0" | "CAP_ALL1" => true, + // FIXME(freebsd): Removed in FreeBSD 15, deprecated in libc + "TCP_PCAP_OUT" | "TCP_PCAP_IN" => true, + _ => false, } }); diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index ff096e51c731c..375c51b3de669 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3771,7 +3771,9 @@ pub const TCP_PERF_INFO: c_int = 78; pub const TCP_LRD: c_int = 79; pub const TCP_KEEPINIT: c_int = 128; pub const TCP_FASTOPEN: c_int = 1025; +#[deprecated(since = "0.2.171", note = "removed in FreeBSD 15")] pub const TCP_PCAP_OUT: c_int = 2048; +#[deprecated(since = "0.2.171", note = "removed in FreeBSD 15")] pub const TCP_PCAP_IN: c_int = 4096; pub const TCP_FUNCTION_BLK: c_int = 8192; pub const TCP_FUNCTION_ALIAS: c_int = 8193; From 232dabcd8984bcd19698d23b11ae264613766c41 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Wed, 11 Dec 2024 15:54:27 +0100 Subject: [PATCH 05/25] ci: Use $PWD instead of $(pwd) in run-docker Less commands makes for a cleaner `set -x` log. And it is more efficient. (backport ) (cherry picked from commit afa5c65d2dad6a0534c48d330c8bb555075c5cf4) --- ci/run-docker.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/run-docker.sh b/ci/run-docker.sh index fcd9e1a9d2e03..622d9453cbd08 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -47,8 +47,8 @@ run() { --env CARGO_TARGET_DIR=/checkout/target \ --volume "$CARGO_HOME":/cargo \ --volume "$(rustc --print sysroot)":/rust:ro \ - --volume "$(pwd)":/checkout:ro \ - --volume "$(pwd)"/target:/checkout/target \ + --volume "$PWD":/checkout:ro \ + --volume "$PWD"/target:/checkout/target \ $kvm \ --init \ --workdir /checkout \ From e45d8e089adcc1d9e88044e6e9a685127a99ddd3 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 14 Mar 2025 11:18:37 +0100 Subject: [PATCH 06/25] ci: Add matrix env variables to the environment Variables set with `env` in the matrix never propagated into the environment. Add a step in test_tier1 and test_tier2 that reads the env context from the matrix and adds the variables to the environment used by later steps. (backport ) (cherry picked from commit 84a04a156b9dd4f5576491aa7e8c2bdb4776608d) --- .github/workflows/ci.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fe37151bccba3..0610fbc51c6e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -108,6 +108,13 @@ jobs: with: key: ${{ matrix.target }} + - name: Add matrix env variables to the environment + if: matrix.env + run: | + echo '${{ toJson(matrix.env) }}' | + jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV + shell: bash + - name: Run natively if: "!matrix.docker" run: ./ci/run.sh ${{ matrix.target }} @@ -174,6 +181,13 @@ jobs: with: key: ${{ matrix.target }} + - name: Add matrix env variables to the environment + if: matrix.env + run: | + echo '${{ toJson(matrix.env) }}' | + jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV + shell: bash + - name: Execute run-docker.sh run: ./ci/run-docker.sh ${{ matrix.target }} From 4aba8adfbc5923c9412868c038be1554e72412c6 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 14 Mar 2025 14:48:33 +0100 Subject: [PATCH 07/25] ci: Always upload successfully created artifacts The `Create I artifacts` step is always run, whether earlier steps succeeds or not. But the upload step would only run if all preceeding steps wer successfull. Add a conditional to always run except if artifact creation failed. (backport ) (cherry picked from commit f10e8e4340bd3c9b681fe0b01ba141eec9f5db0b) --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0610fbc51c6e7..1302aece0f7e5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -123,9 +123,11 @@ jobs: 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 + if: always() && steps.create_artifacts.outcome == 'success' with: name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }} path: ${{ env.ARCHIVE_PATH }} @@ -192,9 +194,11 @@ jobs: 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 + if: always() && steps.create_artifacts.outcome == 'success' with: name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }} path: ${{ env.ARCHIVE_PATH }} From aed5b56449b05aacd602b04499a9a92d3d96c373 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 14 Mar 2025 16:04:22 +0100 Subject: [PATCH 08/25] gnu: build settings for _FILE_OFFSET_BITS=64 (backport ) (cherry picked from commit a184436eca52a191dc8af9f16c7e9f22d966a7f0) --- build.rs | 23 +++++++++++++++++++++++ libc-test/build.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/build.rs b/build.rs index a09826fe87b76..0e83c0eb89da0 100644 --- a/build.rs +++ b/build.rs @@ -13,6 +13,8 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd13", "freebsd14", "freebsd15", + // Corresponds to `_FILE_OFFSET_BITS=64` in glibc + "gnu_file_offset_bits64", // FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn` "libc_const_extern_fn", "libc_deny_warnings", @@ -44,6 +46,10 @@ fn main() { let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); + let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + let target_ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); // The ABI of libc used by std is backward compatible with FreeBSD 12. // The ABI of libc from crates.io is backward compatible with FreeBSD 11. @@ -85,6 +91,23 @@ fn main() { if linux_time_bits64 { set_cfg("linux_time_bits64"); } + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"); + match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") { + Ok(val) if val == "64" => { + if target_env == "gnu" + && target_os == "linux" + && target_ptr_width == "32" + && target_arch != "riscv32" + && target_arch != "x86_64" + { + set_cfg("gnu_file_offset_bits64"); + } + } + Ok(val) if val != "32" => { + panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'") + } + _ => {} + } // On CI: deny all warnings if libc_ci { diff --git a/libc-test/build.rs b/libc-test/build.rs index 3cc6a1042550a..c84bddca80960 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3664,6 +3664,26 @@ fn test_vxworks(target: &str) { cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); } +fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { + match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") { + Ok(val) if val == "64" => { + if target.contains("gnu") + && target.contains("linux") + && !target.ends_with("x32") + && !target.contains("riscv32") + && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32" + { + cfg.define("_FILE_OFFSET_BITS", Some("64")); + cfg.cfg("gnu_file_offset_bits64", None); + } + } + Ok(val) if val != "32" => { + panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'") + } + _ => {} + } +} + fn test_linux(target: &str) { assert!(target.contains("linux")); @@ -3707,6 +3727,8 @@ fn test_linux(target: &str) { // glibc versions older than 2.29. cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None); + config_gnu_bits(target, &mut cfg); + headers! { cfg: "ctype.h", "dirent.h", @@ -4869,6 +4891,7 @@ fn test_linux_like_apis(target: &str) { if linux || android || emscripten { // test strerror_r from the `string.h` header let mut cfg = ctest_cfg(); + config_gnu_bits(target, &mut cfg); cfg.skip_type(|_| true).skip_static(|_| true); headers! { cfg: "string.h" } @@ -4885,6 +4908,7 @@ fn test_linux_like_apis(target: &str) { // test fcntl - see: // http://man7.org/linux/man-pages/man2/fcntl.2.html let mut cfg = ctest_cfg(); + config_gnu_bits(target, &mut cfg); if musl { cfg.header("fcntl.h"); @@ -4914,6 +4938,7 @@ fn test_linux_like_apis(target: &str) { if (linux && !wali) || android { // test termios let mut cfg = ctest_cfg(); + config_gnu_bits(target, &mut cfg); cfg.header("asm/termbits.h"); cfg.header("linux/termios.h"); cfg.skip_type(|_| true) @@ -4938,6 +4963,7 @@ fn test_linux_like_apis(target: &str) { if linux || android { // test IPV6_ constants: let mut cfg = ctest_cfg(); + config_gnu_bits(target, &mut cfg); headers! { cfg: "linux/in6.h" @@ -4969,6 +4995,7 @@ fn test_linux_like_apis(target: &str) { // "resolve.h" defines a `p_type` macro that expands to `__p_type` // making the tests for these fails when both are included. let mut cfg = ctest_cfg(); + config_gnu_bits(target, &mut cfg); cfg.header("elf.h"); cfg.skip_fn(|_| true) .skip_static(|_| true) @@ -4988,6 +5015,7 @@ fn test_linux_like_apis(target: &str) { if (linux && !wali) || android { // Test `ARPHRD_CAN`. let mut cfg = ctest_cfg(); + config_gnu_bits(target, &mut cfg); cfg.header("linux/if_arp.h"); cfg.skip_fn(|_| true) .skip_static(|_| true) From 4d009b4ff5de597c74dd44a31f628f1bd3ee3b93 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 14 Mar 2025 16:05:07 +0100 Subject: [PATCH 09/25] gnu: Set up the CI for _FILE_OFFSET_BITS=64 Add new jobs for i686 in test_tier1 and arm and powerpc in test_tier2 where RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64. Use artifact-tag to avoid artifact name collisions. (backport ) (cherry picked from commit 874e3994740d84a0e5c52ed4a845076d021b4fd4) --- .github/workflows/ci.yaml | 27 +++++++++++++++++++++------ ci/run-docker.sh | 1 + ci/verify-build.sh | 9 +++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1302aece0f7e5..73d2f9f42c785 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -77,6 +77,12 @@ jobs: - 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: x86_64-unknown-linux-gnu docker: true os: ubuntu-24.04 @@ -129,7 +135,7 @@ jobs: - uses: actions/upload-artifact@v4 if: always() && steps.create_artifacts.outcome == 'success' with: - name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }} + name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} path: ${{ env.ARCHIVE_PATH }} retention-days: 5 @@ -149,15 +155,11 @@ jobs: - aarch64-unknown-linux-gnu - aarch64-unknown-linux-musl - arm-linux-androideabi - - arm-unknown-linux-gnueabihf - arm-unknown-linux-musleabihf - i686-linux-android - i686-unknown-linux-musl - loongarch64-unknown-linux-gnu - loongarch64-unknown-linux-musl - # FIXME(ppc): SIGILL running tests, see - # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 - # - powerpc-unknown-linux-gnu - powerpc64-unknown-linux-gnu - powerpc64le-unknown-linux-gnu - riscv64gc-unknown-linux-gnu @@ -172,6 +174,19 @@ jobs: # 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 + # 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 timeout-minutes: 25 env: TARGET: ${{ matrix.target }} @@ -200,7 +215,7 @@ jobs: - uses: actions/upload-artifact@v4 if: always() && steps.create_artifacts.outcome == 'success' with: - name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }} + name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} path: ${{ env.ARCHIVE_PATH }} retention-days: 5 diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 622d9453cbd08..6e18e520ce2d1 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -43,6 +43,7 @@ run() { --user "$(id -u)":"$(id -g)" \ --env LIBC_CI \ --env LIBC_CI_ZBUILD_STD \ + --env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --volume "$CARGO_HOME":/cargo \ diff --git a/ci/verify-build.sh b/ci/verify-build.sh index 7ee562312b410..375a5de1b0a2f 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -75,6 +75,11 @@ test_target() { if [ "$os" = "linux" ]; then # Test with the equivalent of __USE_TIME_BITS64 RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd + case "$target" in + # Test with the equivalent of __FILE_OFFSET_BITS=64 + arm*-gnu*|i*86*-gnu|powerpc-*-gnu*|mips*-gnu|sparc-*-gnu|thumb-*gnu*) + RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd;; + esac fi # Test again without default features, i.e. without "std" @@ -92,7 +97,7 @@ test_target() { 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" @@ -300,7 +305,7 @@ filter_and_run() { if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then return fi - + test_target "$target" "$no_dist" some_tests_run=1 fi From 399f9836e72d5730944d34c565b09b9d2603db7a Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 16 Dec 2024 14:00:22 +0100 Subject: [PATCH 10/25] gnu: Handle basic file types for 32bit with _FILE_OFFSET_BITS=64 Set the basic types correctly for gnu_file_offset_bits64 (_FILE_OFFSET_BITS=64). (backport ) (cherry picked from commit f44fdc17f287e9a3560586dcaf2a120e8b76d32e) --- src/unix/linux_like/linux/gnu/b32/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 134bfb05b7470..4f4ad065243b1 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -27,6 +27,16 @@ cfg_if! { pub type fsfilcnt_t = u64; pub type rlim_t = u64; pub type blksize_t = i64; + } else if #[cfg(gnu_file_offset_bits64)] { + pub type time_t = i32; + pub type suseconds_t = i32; + pub type ino_t = u64; + pub type off_t = i64; + pub type blkcnt_t = i64; + pub type fsblkcnt_t = u64; + pub type fsfilcnt_t = u64; + pub type rlim_t = u64; + pub type blksize_t = i32; } else { pub type time_t = i32; pub type suseconds_t = i32; From c2501a64c42892228dd83d028586b5bad8ac6a94 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 20 Mar 2023 14:31:28 +0100 Subject: [PATCH 11/25] gnu: Update F_GETLK for gnu_file_offset_bits64 gnu_file_offset_bits64 means _FILE_OFFSET_BITS=64. (backport ) (cherry picked from commit 862ba8aa2f22099b4411547ec1884232c5b02ae2) --- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 8 +++++++- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 8 +++++++- src/unix/linux_like/linux/gnu/b32/powerpc.rs | 8 +++++++- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 28514c0bf42d8..70a0e5dc1162f 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -397,7 +397,13 @@ pub const MCL_ONFAULT: c_int = 0x0004; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const F_GETLK: c_int = 5; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} pub const F_GETOWN: c_int = 9; pub const F_SETOWN: c_int = 8; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index cc9ebf2e901d9..aaf5f388bba91 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -745,7 +745,13 @@ pub const MAP_HUGETLB: c_int = 0x080000; pub const EFD_NONBLOCK: c_int = 0x80; -pub const F_GETLK: c_int = 14; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 33; + } else { + pub const F_GETLK: c_int = 14; + } +} pub const F_GETOWN: c_int = 23; pub const F_SETOWN: c_int = 24; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index b789a86a97728..1632de8de658e 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -301,7 +301,13 @@ pub const MCL_ONFAULT: c_int = 0x8000; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const F_GETLK: c_int = 5; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} pub const F_GETOWN: c_int = 9; pub const F_SETOWN: c_int = 8; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 2ec8692e36a8d..4c9e4493a8ed6 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -499,7 +499,13 @@ pub const SA_NOCLDWAIT: c_int = 0x00000002; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const F_GETLK: c_int = 5; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} pub const F_GETOWN: c_int = 9; pub const F_SETOWN: c_int = 8; From d788f3a39fa62c837f78d03c4f189df2d42f593f Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 20 Mar 2023 14:32:07 +0100 Subject: [PATCH 12/25] gnu: Update F_SETLK and F_SETLKW for gnu_file_offset_bits64 (backport ) (cherry picked from commit 6ed2bc820c2b55ca4711672fa199c9c4f3d4400a) --- src/unix/linux_like/linux/gnu/b32/mod.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 4f4ad065243b1..d132a1b4f6582 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -177,9 +177,6 @@ cfg_if! { pub const PTRACE_DETACH: c_uint = 11; - pub const F_SETLK: c_int = 8; - pub const F_SETLKW: c_int = 9; - pub const F_RDLCK: c_int = 1; pub const F_WRLCK: c_int = 2; pub const F_UNLCK: c_int = 3; @@ -223,9 +220,6 @@ cfg_if! { pub const PTRACE_DETACH: c_uint = 17; - pub const F_SETLK: c_int = 6; - pub const F_SETLKW: c_int = 7; - pub const F_RDLCK: c_int = 0; pub const F_WRLCK: c_int = 1; pub const F_UNLCK: c_int = 2; @@ -261,6 +255,24 @@ cfg_if! { pub const EFD_CLOEXEC: c_int = 0x80000; } } +cfg_if! { + if #[cfg(target_arch = "sparc")] { + pub const F_SETLK: c_int = 8; + pub const F_SETLKW: c_int = 9; + } else if #[cfg(all( + gnu_file_offset_bits64, + any(target_arch = "mips", target_arch = "mips32r6") + ))] { + pub const F_SETLK: c_int = 34; + pub const F_SETLKW: c_int = 35; + } else if #[cfg(gnu_file_offset_bits64)] { + pub const F_SETLK: c_int = 13; + pub const F_SETLKW: c_int = 14; + } else { + pub const F_SETLK: c_int = 6; + pub const F_SETLKW: c_int = 7; + } +} #[cfg(target_endian = "little")] pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { From d4fe9e63764a2d7d080fe88be1ccd91e8cc9c11b Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Tue, 11 Mar 2025 14:33:48 +0100 Subject: [PATCH 13/25] gnu: Set RLIM_INFINITY for mips with gnu_file_offset_bits64 (backport ) (cherry picked from commit 5c5c3645615d0aaee87a60c2e1667386d62e286b) --- src/unix/linux_like/linux/arch/mips/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 1e12a1097202b..eee7cc81a47e4 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -379,8 +379,13 @@ cfg_if! { cfg_if! { if #[cfg(all( any(target_arch = "mips", target_arch = "mips32r6"), - any(target_env = "uclibc", target_env = "gnu"), - linux_time_bits64 + any( + all(target_env = "uclibc", linux_time_bits64), + all( + target_env = "gnu", + any(linux_time_bits64, gnu_file_offset_bits64) + ) + ) ))] { pub const RLIM_INFINITY: crate::rlim_t = !0; } else if #[cfg(all( From c6a40ea40a53d95de397d9db5e08551b3b20417a Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Thu, 21 Nov 2024 16:25:30 +0100 Subject: [PATCH 14/25] gnu: Use _FILE_OFFSET_BITS=64 versions of glibc symbols When _FILE_OFFSET_BITS=64, glibc redirects some function calls to 64 bit versions. These symbols are sometimes the public LFS variants, sometimes hidden variants. (backport ) (cherry picked from commit 2b4fafbbea40c66c8fc5c7001afb3ed2dbe141c4) --- src/unix/linux_like/linux/gnu/mod.rs | 5 +++++ src/unix/linux_like/linux/mod.rs | 14 ++++++++++++++ src/unix/linux_like/mod.rs | 5 +++++ src/unix/mod.rs | 27 +++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 0272166e76e14..35e479196a058 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1200,8 +1200,11 @@ extern "C" { pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "getrlimit64")] pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "setrlimit64")] pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "prlimit64")] pub fn prlimit( pid: crate::pid_t, resource: crate::__rlimit_resource_t, @@ -1242,6 +1245,7 @@ extern "C" { dirfd: c_int, path: *const c_char, ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64v2")] pub fn preadv2( fd: c_int, iov: *const crate::iovec, @@ -1249,6 +1253,7 @@ extern "C" { offset: off_t, flags: c_int, ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64v2")] pub fn pwritev2( fd: c_int, iov: *const crate::iovec, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 17d99962eeee9..dc065eafb79bb 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -6300,17 +6300,23 @@ cfg_if! { cfg_if! { if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] { extern "C" { + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_read64")] pub fn aio_read(aiocbp: *mut aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_write64")] pub fn aio_write(aiocbp: *mut aiocb) -> c_int; pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_error64")] pub fn aio_error(aiocbp: *const aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_return64")] pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; pub fn aio_suspend( aiocb_list: *const *const aiocb, nitems: c_int, timeout: *const crate::timespec, ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_cancel64")] pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "lio_listio64")] pub fn lio_listio( mode: c_int, aiocb_list: *const *mut aiocb, @@ -6324,12 +6330,14 @@ cfg_if! { cfg_if! { if #[cfg(not(target_env = "uclibc"))] { extern "C" { + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64")] pub fn pwritev( fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t, ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64")] pub fn preadv( fd: c_int, iov: *const crate::iovec, @@ -6494,7 +6502,9 @@ extern "C" { pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; pub fn __errno_location() -> *mut c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fallocate64")] pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fallocate64")] pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t; pub fn getxattr( @@ -6601,12 +6611,14 @@ extern "C" { ... ) -> *mut c_void; + #[cfg_attr(gnu_file_offset_bits64, link_name = "glob64")] pub fn glob( pattern: *const c_char, flags: c_int, errfunc: Option c_int>, pglob: *mut crate::glob_t, ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "globfree64")] pub fn globfree(pglob: *mut crate::glob_t); pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; @@ -6632,6 +6644,7 @@ extern "C" { addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemps64")] pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; @@ -6796,6 +6809,7 @@ extern "C" { policy: c_int, param: *const crate::sched_param, ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "sendfile64")] pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t; pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; pub fn getgrgid_r( diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 875814dcc08e1..4d1d0a5399b8a 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1792,9 +1792,12 @@ extern "C" { pub fn memalign(align: size_t, size: size_t) -> *mut c_void; pub fn setgroups(ngroups: size_t, ptr: *const crate::gid_t) -> c_int; pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "statfs64")] pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatfs64")] pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fadvise64")] pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; pub fn utimensat( @@ -1900,7 +1903,9 @@ extern "C" { ) -> size_t; pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkostemp64")] pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkostemps64")] pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 32af26a8a4056..7fd9d71744cb7 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -578,17 +578,20 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "fopen$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fopen64")] pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "freopen$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "freopen64")] pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; pub fn fflush(file: *mut FILE) -> c_int; pub fn fclose(file: *mut FILE) -> c_int; pub fn remove(filename: *const c_char) -> c_int; pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "tmpfile64")] pub fn tmpfile() -> *mut FILE; pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; pub fn setbuf(stream: *mut FILE, buf: *mut c_char); @@ -614,8 +617,10 @@ extern "C" { pub fn ftell(stream: *mut FILE) -> c_long; pub fn rewind(stream: *mut FILE); #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fgetpos64")] pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fsetpos64")] pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; @@ -827,6 +832,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "fstat@FBSD_1.0" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstat64")] pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; @@ -840,6 +846,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "stat@FBSD_1.0" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "stat64")] pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; pub fn pclose(stream: *mut crate::FILE) -> c_int; @@ -854,16 +861,19 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "open$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "open64")] pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "creat$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "creat64")] pub fn creat(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "fcntl$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "__fcntl_time64")] pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; #[cfg_attr( @@ -886,6 +896,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "readdir@FBSD_1.0" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64")] pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), @@ -924,6 +935,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "fstatat@FBSD_1.1" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatat64")] pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; pub fn linkat( olddirfd: c_int, @@ -998,6 +1010,7 @@ extern "C" { pub fn isatty(fd: c_int) -> c_int; #[cfg_attr(target_os = "solaris", link_name = "__link_xpg4")] pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "lseek64")] pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; pub fn pathconf(path: *const c_char, name: c_int) -> c_long; pub fn pipe(fds: *mut c_int) -> c_int; @@ -1060,11 +1073,13 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "pread$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "pread64")] pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pwrite$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwrite64")] pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t; pub fn umask(mask: mode_t) -> mode_t; @@ -1091,6 +1106,7 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "mmap$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "mmap64")] pub fn mmap( addr: *mut c_void, len: size_t, @@ -1117,6 +1133,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "lstat@FBSD_1.0" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "lstat64")] pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; #[cfg_attr( @@ -1139,7 +1156,9 @@ extern "C" { pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "truncate64")] pub fn truncate(path: *const c_char, length: off_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "ftruncate64")] pub fn ftruncate(fd: c_int, length: off_t) -> c_int; pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; @@ -1444,7 +1463,9 @@ extern "C" { pub fn sem_wait(sem: *mut sem_t) -> c_int; pub fn sem_trywait(sem: *mut sem_t) -> c_int; pub fn sem_post(sem: *mut sem_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] @@ -1468,7 +1489,9 @@ extern "C" { pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fseeko64")] pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "ftello64")] pub fn ftello(stream: *mut crate::FILE) -> off_t; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), @@ -1485,6 +1508,7 @@ extern "C" { pub fn tcflush(fd: c_int, action: c_int) -> c_int; pub fn tcgetsid(fd: c_int) -> crate::pid_t; pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemp64")] pub fn mkstemp(template: *mut c_char) -> c_int; pub fn mkdtemp(template: *mut c_char) -> *mut c_char; @@ -1509,6 +1533,7 @@ extern "C" { pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "lockf64")] pub fn lockf(fd: c_int, cmd: c_int, len: off_t) -> c_int; } @@ -1609,6 +1634,7 @@ cfg_if! { pub fn pause() -> c_int; pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")] pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; #[cfg_attr( @@ -1637,6 +1663,7 @@ cfg_if! { /// https://illumos.org/man/3lib/libc /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html /// https://www.unix.com/man-page/opensolaris/3LIB/libc/ + #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64_r")] pub fn readdir_r( dirp: *mut crate::DIR, entry: *mut crate::dirent, From 25d4c0aad65dc88ac4de77231399899ef26b1f1a Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Tue, 18 Mar 2025 16:47:20 +0100 Subject: [PATCH 15/25] gnu powerpc: Use a separate stat struct for powerpc Like mips, the stat struct will become different once support for gnu_file_offset_bits64 is added. (backport ) (cherry picked from commit 0c6d56cfe115847344d62756e5d7334740011572) --- src/unix/linux_like/linux/gnu/b32/mod.rs | 6 +++++- src/unix/linux_like/linux/gnu/b32/powerpc.rs | 22 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index d132a1b4f6582..726c41e9eb5c0 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -51,7 +51,11 @@ cfg_if! { } cfg_if! { - if #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] { + if #[cfg(not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc" + )))] { s! { pub struct stat { pub st_dev: crate::dev_t, diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 1632de8de658e..ce91e988b8bca 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -57,6 +57,28 @@ s! { __glibc_reserved2: u64, } + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: c_ushort, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __glibc_reserved4: c_ulong, + __glibc_reserved5: c_ulong, + } + pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino64_t, From e6202841f37d81fec0ab1394ad7c0deac2f01762 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Thu, 20 Mar 2025 12:14:19 +0100 Subject: [PATCH 16/25] gnu sparc: Use a separate stat struct for 32bit powerpc Like mips and powerpc, the stat struct will become different once support for gnu_file_offset_bits64 is added. (backport ) (cherry picked from commit e1349594daebb742b2ef3af63255eaba9699d203) --- src/unix/linux_like/linux/gnu/b32/mod.rs | 3 ++- .../linux_like/linux/gnu/b32/sparc/mod.rs | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 726c41e9eb5c0..cbcb38f5a7769 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -54,7 +54,8 @@ cfg_if! { if #[cfg(not(any( target_arch = "mips", target_arch = "mips32r6", - target_arch = "powerpc" + target_arch = "powerpc", + target_arch = "sparc" )))] { s! { pub struct stat { diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 968cf7734ef8e..2e17f80965c76 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -60,6 +60,29 @@ s! { pub ss_size: size_t, } + pub struct stat { + pub st_dev: crate::dev_t, + __pad1: c_ushort, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: c_ushort, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __glibc_reserved4: c_ulong, + __glibc_reserved5: c_ulong, + } + pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino64_t, From a8df758817c948d09c734604149f54bfa7e739c2 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Thu, 19 Dec 2024 14:11:40 +0100 Subject: [PATCH 17/25] gnu: Adapt struct stat for gnu_file_offset_bits64 Change the __padX members in b32/mod.rs from short to uint even though they are actually unsigned short in C. Using unsigned int will give the same alignment, and make the struct equivalent to stat64 when gnu_file_offset_bits64 is set. (backport ) (cherry picked from commit 5a5abc2b284829dd4dc8c901bcb702c7adcc241f) --- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 14 ++++++++ src/unix/linux_like/linux/gnu/b32/mod.rs | 35 +++++++++++++++---- src/unix/linux_like/linux/gnu/b32/powerpc.rs | 2 ++ .../linux_like/linux/gnu/b32/sparc/mod.rs | 1 + 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index aaf5f388bba91..2a0055b8b4f58 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -8,22 +8,36 @@ s! { pub st_dev: c_ulong, st_pad1: [c_long; 3], + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, + pub st_rdev: c_ulong, + + #[cfg(not(gnu_file_offset_bits64))] st_pad2: [c_long; 2], + #[cfg(gnu_file_offset_bits64)] + st_pad2: [c_long; 3], + pub st_size: off_t, + + #[cfg(not(gnu_file_offset_bits64))] st_pad3: c_long, + pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + #[cfg(gnu_file_offset_bits64)] + st_pad4: c_long, pub st_blocks: crate::blkcnt_t, st_pad5: [c_long; 14], } diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index cbcb38f5a7769..e9a958478c543 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -20,7 +20,9 @@ cfg_if! { if #[cfg(target_arch = "riscv32")] { pub type time_t = i64; pub type suseconds_t = i64; - pub type ino_t = u64; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino64_t; pub type off_t = i64; pub type blkcnt_t = i64; pub type fsblkcnt_t = u64; @@ -30,7 +32,9 @@ cfg_if! { } else if #[cfg(gnu_file_offset_bits64)] { pub type time_t = i32; pub type suseconds_t = i32; - pub type ino_t = u64; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino64_t; pub type off_t = i64; pub type blkcnt_t = i64; pub type fsblkcnt_t = u64; @@ -40,7 +44,9 @@ cfg_if! { } else { pub type time_t = i32; pub type suseconds_t = i32; - pub type ino_t = u32; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino_t; pub type off_t = i32; pub type blkcnt_t = i32; pub type fsblkcnt_t = c_ulong; @@ -61,25 +67,40 @@ cfg_if! { pub struct stat { pub st_dev: crate::dev_t, - __pad1: c_short, + __pad1: c_uint, + + #[cfg(not(gnu_file_offset_bits64))] pub st_ino: crate::ino_t, + #[cfg(all(gnu_file_offset_bits64))] + __st_ino: __ino_t, + pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, - __pad2: c_short, + + __pad2: c_uint, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused4: c_long, - __unused5: c_long, + + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved4: c_long, + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved5: c_long, + #[cfg(gnu_file_offset_bits64)] + pub st_ino: crate::ino_t, } } } diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index ce91e988b8bca..36da977d688a3 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -59,6 +59,8 @@ s! { pub struct stat { pub st_dev: crate::dev_t, + #[cfg(not(gnu_file_offset_bits64))] + __pad1: c_ushort, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 2e17f80965c76..d60f6f2a1dfa6 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -62,6 +62,7 @@ s! { pub struct stat { pub st_dev: crate::dev_t, + #[cfg(not(gnu_file_offset_bits64))] __pad1: c_ushort, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, From 0789132dd27136f99ea5fcf443045d392e0fd9da Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Tue, 18 Mar 2025 16:00:29 +0100 Subject: [PATCH 18/25] gnu: Adapt stat64 for gnu_file_offset_bits64 (backport ) (cherry picked from commit 96e81e718d4ca91f29353b362d9b5e93c176663f) --- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 70a0e5dc1162f..2dd4a88674f3e 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -61,7 +61,7 @@ s! { pub struct stat64 { pub st_dev: crate::dev_t, __pad1: c_uint, - __st_ino: crate::ino_t, + __st_ino: c_ulong, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 4c9e4493a8ed6..c0eb9e89bc442 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -135,7 +135,7 @@ s! { pub struct stat64 { pub st_dev: crate::dev_t, __pad1: c_uint, - __st_ino: crate::ino_t, + __st_ino: c_ulong, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, From 4c67438a92597f3b523b9bbf40fd7826541d772d Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Thu, 20 Mar 2025 11:15:33 +0100 Subject: [PATCH 19/25] gnu: Correct the struct stat64 padding for 32bit mips (backport ) (cherry picked from commit 169d50bd2b1818292d2e329cb7f67373edc72517) --- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 2a0055b8b4f58..6c2f499b5914b 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -51,7 +51,7 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: c_ulong, - st_pad2: [c_long; 2], + st_pad2: [c_long; 3], pub st_size: off64_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, From b6ad13550ab83bb64629d7607a2592552590bbb6 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Thu, 20 Mar 2025 12:14:52 +0100 Subject: [PATCH 20/25] gnu: Correct struct stat64 for sparc Struct stat and stat64 needs to match when gnu_file_offset_bits64 is set. (backport ) (cherry picked from commit 22ac02cc253d23e55451dafdcba60158e8be5023) --- src/unix/linux_like/linux/gnu/b32/sparc/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index d60f6f2a1dfa6..abd49cf455cc3 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -102,7 +102,8 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __reserved: [c_long; 2], + __glibc_reserved4: c_ulong, + __glibc_reserved5: c_ulong, } pub struct statfs64 { From 8da41612148451033ffadf804f16d591b0c7e3eb Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 17 Mar 2025 16:53:11 +0100 Subject: [PATCH 21/25] gnu: Add the __f_unused field to struct statvfs for sparc The __f_unused field should be the same in statvfs and statvfs64 (where it was already included) as can be seen in https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/statvfs.h;h=1aed2f54aa86e43ac1c1d3a33197b3232be76580;hb=HEAD (backport ) (cherry picked from commit 131efe92084f65f8170f84016f5622a4eb4e12c4) --- src/unix/linux_like/linux/gnu/b32/sparc/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index abd49cf455cc3..16e48b490c313 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -131,6 +131,7 @@ s! { pub f_ffree: u64, pub f_favail: u64, pub f_fsid: c_ulong, + __f_unused: c_int, pub f_flag: c_ulong, pub f_namemax: c_ulong, __f_spare: [c_int; 6], From f5dc0701a6f5e23bacf243321eb763f78d3ef8bb Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Tue, 18 Mar 2025 15:14:48 +0100 Subject: [PATCH 22/25] gnu: Add missing f_flags field to struct statfs for sparc (backport ) (cherry picked from commit c1e48123b2ea5f5cc7dd3b56a56604702c3df19d) --- src/unix/linux_like/linux/gnu/b32/sparc/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 16e48b490c313..7533ad689bb42 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -26,7 +26,8 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + pub f_flags: crate::__fsword_t, + f_spare: [crate::__fsword_t; 4], } pub struct siginfo_t { From 394f97fa5a1f84d6b145d43cba6f5b94c002a206 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Thu, 21 Nov 2024 13:49:17 +0100 Subject: [PATCH 23/25] gnu: Add proper structs for fpos_t and fpos64_t (backport ) (cherry picked from commit 872642ada4a2992d9125bd7c47d31a2d50491b1d) --- src/unix/linux_like/linux/gnu/mod.rs | 18 ++++++++++++++++++ src/unix/linux_like/linux/mod.rs | 11 ++++++++--- src/unix/mod.rs | 11 +++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 35e479196a058..7cf0dadc8e782 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -407,6 +407,24 @@ s! { #[cfg(target_pointer_width = "64")] __size: [c_char; 32], } + + pub struct mbstate_t { + __count: c_int, + __wchb: [c_char; 4], + } + + pub struct fpos64_t { + __pos: off64_t, + __state: crate::mbstate_t, + } + + pub struct fpos_t { + #[cfg(not(gnu_file_offset_bits64))] + __pos: off_t, + #[cfg(gnu_file_offset_bits64)] + __pos: off64_t, + __state: crate::mbstate_t, + } } impl siginfo_t { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index dc065eafb79bb..d9e3e5d2508ca 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -74,9 +74,14 @@ pub type iconv_t = *mut c_void; pub type sctp_assoc_t = __s32; pub type eventfd_t = u64; -missing! { - #[cfg_attr(feature = "extra_traits", derive(Debug))] - pub enum fpos64_t {} // FIXME(linux): fill this out with a struct + +cfg_if! { + if #[cfg(not(target_env = "gnu"))] { + missing! { + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum fpos64_t {} // FIXME(linux): fill this out with a struct + } + } } e! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 7fd9d71744cb7..fa88de25f4aa2 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -539,11 +539,18 @@ cfg_if! { } } +cfg_if! { + if #[cfg(not(target_env = "gnu"))] { + missing! { + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum fpos_t {} // FIXME(unix): fill this out with a struct + } + } +} + missing! { #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} - #[cfg_attr(feature = "extra_traits", derive(Debug))] - pub enum fpos_t {} // FIXME(unix): fill this out with a struct } extern "C" { From c553ad52c336e3782d41bdeba73d6ac4038bdd67 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 20 Mar 2023 14:33:33 +0100 Subject: [PATCH 24/25] gnu: Update struct aiocb for gnu_file_offset_bits64 (backport ) (cherry picked from commit 7ba56f2adf2585e6ca6293c934209ccf20f8eb67) --- src/unix/linux_like/linux/gnu/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 7cf0dadc8e782..7f4ff568ac8e8 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -32,7 +32,11 @@ s! { __error_code: c_int, __return_value: ssize_t, pub aio_offset: off_t, - #[cfg(all(not(target_arch = "x86_64"), target_pointer_width = "32"))] + #[cfg(all( + not(gnu_file_offset_bits64), + not(target_arch = "x86_64"), + target_pointer_width = "32" + ))] __unused1: [c_char; 4], __glibc_reserved: [c_char; 32], } From dca8f0909d1978c98b6ae022532aeb12a4e30752 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Tue, 11 Mar 2025 14:33:11 +0100 Subject: [PATCH 25/25] gnu: Adapt struct flock on mips for gnu_file_offset_bits64 (backport ) (cherry picked from commit 4a7c9a98756914a515b7d9874ab620e2c3b97414) --- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 6c2f499b5914b..649a8e04bd470 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -190,9 +190,11 @@ s! { pub l_whence: c_short, pub l_start: off_t, pub l_len: off_t, + #[cfg(not(gnu_file_offset_bits64))] pub l_sysid: c_long, pub l_pid: crate::pid_t, - pad: [c_long; 4], + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved0: [c_long; 4], } }