From 7c5acceda5991f7bc5a8ea227969a882ca0bf050 Mon Sep 17 00:00:00 2001 From: rUv Date: Fri, 20 Feb 2026 21:38:48 +0000 Subject: [PATCH] fix(rvlite): use platform-specific errno on macOS/BSD (fixes #174) rvlite's writer_lease.rs used __errno_location (Linux libc) under a generic #[cfg(unix)] guard, causing link failures on macOS where the equivalent is __error. Split the extern and wrapper into separate #[cfg(target_os)] blocks matching the pattern already used in rvf-runtime/src/locking.rs. Closes #174 Co-Authored-By: claude-flow --- crates/rvlite/src/storage/writer_lease.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/rvlite/src/storage/writer_lease.rs b/crates/rvlite/src/storage/writer_lease.rs index 87bb6a93a..e3c7f4cab 100644 --- a/crates/rvlite/src/storage/writer_lease.rs +++ b/crates/rvlite/src/storage/writer_lease.rs @@ -322,19 +322,33 @@ fn is_pid_alive(pid: u32) -> bool { #[cfg(unix)] extern "C" { fn kill(pid: i32, sig: i32) -> i32; +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +extern "C" { fn __errno_location() -> *mut i32; } +#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] +extern "C" { + fn __error() -> *mut i32; +} + #[cfg(unix)] unsafe fn libc_kill(pid: i32, sig: i32) -> i32 { unsafe { kill(pid, sig) } } -#[cfg(unix)] +#[cfg(any(target_os = "linux", target_os = "android"))] unsafe fn errno_location() -> *mut i32 { unsafe { __errno_location() } } +#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] +unsafe fn errno_location() -> *mut i32 { + unsafe { __error() } +} + #[cfg(test)] mod tests { use super::*;