From c2cda8db316ff726cc84227e015a43e9910a67dd Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:04:40 +0200 Subject: [PATCH] Fix `errno` on dragonfly and vxworks --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 94c4dcc..d72e5b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -513,10 +513,16 @@ mod unix { } } + #[cfg(not(target_os = "vxworks"))] fn errno() -> i32 { unsafe { *errno_location() as i32 } } + #[cfg(target_os = "vxworks")] + fn errno() -> i32 { + libc::errnoGet() as i32 + } + pub fn format_error(errnum: i32, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut buf = [0 as c_char; 128]; @@ -537,7 +543,7 @@ mod unix { } extern "C" { - #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))] + #[cfg(not(target_os = "vxworks"))] #[cfg_attr( any( target_os = "linux", @@ -545,6 +551,7 @@ mod unix { target_os = "fuchsia", target_os = "l4re", target_os = "hurd", + target_os = "dragonfly" ), link_name = "__errno_location" )]