Skip to content

Commit

Permalink
Fix errno on dragonfly and vxworks
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0246 committed Jun 14, 2024
1 parent 896f405 commit c2cda8d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -537,14 +543,15 @@ mod unix {
}

extern "C" {
#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))]
#[cfg(not(target_os = "vxworks"))]
#[cfg_attr(
any(
target_os = "linux",
target_os = "emscripten",
target_os = "fuchsia",
target_os = "l4re",
target_os = "hurd",
target_os = "dragonfly"
),
link_name = "__errno_location"
)]
Expand Down

0 comments on commit c2cda8d

Please sign in to comment.