Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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");
Expand Down
13 changes: 10 additions & 3 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>().map_err(|_| env::VarError::NotPresent))
.is_ok_and(|val| val != 0)
{
cfg.cfg("vxworks_rtp", None);
}

headers!(
cfg,
"vxWorks.h",
Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions src/vxworks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 *)
Expand Down