From 0b3f97d8efad4768134110d1a366693e3ce193ca Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Sun, 31 May 2026 18:05:11 +0200 Subject: [PATCH] vxworks: gate `off64_t` behind cfg VxWorks exposes a different bit width for `off64_t`. This will depend on whether the program is a real-time-process. `off_t` will be 64-bits if it is. `off64_t` only exists when compiling kernels. `off_t` may then be 32-bits or 64-bits wide. This will depend on whether the target follows LP64. `off64_t` is then 64-bits wide. Two routines were removed. They were explicitly excluded from the shipped SDK. --- build.rs | 8 ++++++++ libc-test/build.rs | 13 ++++++++++--- src/vxworks/mod.rs | 18 ++++++++---------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/build.rs b/build.rs index ee07f965228c..6c5545af8a36 100644 --- a/build.rs +++ b/build.rs @@ -35,6 +35,10 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64 "musl_redir_time64", "vxworks_lt_25_09", + // Corresponds with `__RTP__` in VxWorks. This feature test macro is exposed + // when compiling real-time-processes. Do not be set if compiling VxWorks + // kernels. + "vxworks_rtp", ]; // Extra values to allow for check-cfg. @@ -180,6 +184,10 @@ fn main() { } } + if target_os == "vxworks" && env_flag("CARGO_CFG_LIBC_UNSTABLE_VXWORKS_RTP") { + set_cfg("vxworks_rtp"); + } + // On CI: deny all warnings if libc_ci { set_cfg("libc_deny_warnings"); diff --git a/libc-test/build.rs b/libc-test/build.rs index 50c813e66576..210af820fa1f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3510,6 +3510,13 @@ fn test_vxworks(target: &str) { cfg.cfg("vxworks_lt_25_09", None); } + if env::var("CARGO_CFG_LIBC_UNSTABLE_VXWORKS_RTP") + .and_then(|val| val.parse::().map_err(|_| env::VarError::NotPresent)) + .is_ok_and(|val| val != 0) + { + cfg.cfg("vxworks_rtp", None); + } + headers!( cfg, "vxWorks.h", @@ -3594,7 +3601,7 @@ fn test_vxworks(target: &str) { _ => false, }); // FIXME(vxworks) - cfg.skip_alias(move |ty| match ty.ident() { + cfg.skip_alias(|ty| match ty.ident() { "stat64" | "sighandler_t" | "off64_t" => true, _ => false, }); @@ -4399,7 +4406,7 @@ fn test_linux(target: &str) { | "SO_TXREHASH" => return true, // requires linux 5.19 - "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" + "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" | "NLM_F_BULK" | "SO_RCVMARK" | "TLS_INFO_ZC_RO_TX" => return true, @@ -4505,7 +4512,7 @@ fn test_linux(target: &str) { | "IPV6_PMTUDISC_OMIT" | "IPV6_ROUTER_ALERT_ISOLATE" // linux/elf.h - | "NT_PRFPREG" + | "NT_PRFPREG" // linux/sem.h | "SEM_STAT_ANY" // linux/shm.h diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 536930467dde..84fe1114c2cb 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -57,8 +57,14 @@ pub type stat64 = crate::stat; pub type pthread_key_t = c_ulong; // From b_off_t.h -pub type off_t = c_longlong; -pub type off64_t = off_t; +cfg_if! { + if #[cfg(vxworks_rtp)] { + pub type off_t = c_longlong; + } else { + pub type off_t = c_long; + pub type off64_t = c_longlong; + } +} // From b_BOOL.h pub type BOOL = c_int; @@ -2414,14 +2420,6 @@ safe_f! { } } -pub unsafe fn pread(_fd: c_int, _buf: *mut c_void, _count: size_t, _offset: off64_t) -> ssize_t { - -1 -} - -pub unsafe fn pwrite(_fd: c_int, _buf: *const c_void, _count: size_t, _offset: off64_t) -> ssize_t { - -1 -} - pub unsafe fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int { // check to see if align is a power of 2 and if align is a multiple // of sizeof(void *)