From c354c216ff12a99ecf0d69e2f7875bc5a7ae3c2d Mon Sep 17 00:00:00 2001
From: Chuck Musser <cmusser@sonic.net>
Date: Sun, 23 Aug 2020 09:37:00 -0700
Subject: [PATCH] Dragonfly: expose __errno_location() rather than define
 __error().

Expose __errno_location() (introduced in DragonFlyBSD 5.8), which
returns the current thread's errno value. This is similar to Linux
and avoids having a separate module that defines both errno (which
depends on the thread_local feature) and an __error() function.
---
 src/unix/bsd/freebsdlike/dragonfly/errno.rs | 12 ------------
 src/unix/bsd/freebsdlike/dragonfly/mod.rs   |  8 +-------
 2 files changed, 1 insertion(+), 19 deletions(-)
 delete 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
deleted file mode 100644
index e9ad63b8..00000000
--- a/src/unix/bsd/freebsdlike/dragonfly/errno.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// 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! {
-    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 4a15c3b8..26799e61 100644
--- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
@@ -1044,6 +1044,7 @@ f! {
 }
 
 extern "C" {
+    pub fn __errno_location() -> *mut ::c_int;
     pub fn setgrent();
     pub fn mprotect(
         addr: *mut ::c_void,
@@ -1077,10 +1078,3 @@ extern "C" {
         needlelen: ::size_t,
     ) -> *mut ::c_void;
 }
-
-cfg_if! {
-    if #[cfg(libc_thread_local)] {
-        mod errno;
-        pub use self::errno::*;
-    }
-}
-- 
GitLab