From 2e3748a53caa337842e2226c9ed040973d033a0b Mon Sep 17 00:00:00 2001 From: Chuck Musser <cmusser@sonic.net> Date: Sun, 23 Aug 2020 19:23:21 -0700 Subject: [PATCH] Restore the __error() function, but add a deprecation warning. --- src/unix/bsd/freebsdlike/dragonfly/errno.rs | 13 +++++++++++++ src/unix/bsd/freebsdlike/dragonfly/mod.rs | 7 +++++++ 2 files changed, 20 insertions(+) create mode 100644 src/unix/bsd/freebsdlike/dragonfly/errno.rs diff --git a/src/unix/bsd/freebsdlike/dragonfly/errno.rs b/src/unix/bsd/freebsdlike/dragonfly/errno.rs new file mode 100644 index 00000000..434ac63a --- /dev/null +++ b/src/unix/bsd/freebsdlike/dragonfly/errno.rs @@ -0,0 +1,13 @@ +// DragonFlyBSD's __error function is declared with "static inline", so it must +// be implemented in the libc crate, as a pointer to a static thread_local. +f! { + #[deprecated(since = "0.2.77", "Use `__errno_location()` instead")] + pub fn __error() -> *mut ::c_int { + &mut errno + } +} + +extern "C" { + #[thread_local] + pub static mut errno: ::c_int; +} diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 26799e61..47e3b7c1 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1078,3 +1078,10 @@ extern "C" { needlelen: ::size_t, ) -> *mut ::c_void; } + +cfg_if! { + if #[cfg(libc_thread_local)] { + mod errno; + pub use self::errno::*; + } +} -- GitLab