summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-03 15:29:04 +0000
committerGitHub <noreply@github.com>2020-10-03 15:29:04 +0000
commit7e46b95057b0d8e391c3fb72fdec08f3a4689631 (patch)
tree15ab6d6e58302b862c590ce49102e7ef465803f3 /src
parent7ed28204ec7de979d64802ee1621d5d09be61858 (diff)
parentf5ee22db489f78b9c003ef60b7ad1b837503bc4a (diff)
downloadnix-7e46b95057b0d8e391c3fb72fdec08f3a4689631.zip
Merge #1296
1296: DragonFlyBSD: use __errno_location now provided by the libc crate r=asomers a=cmusser Dragonfly recently (in Dfly 5.8) added an `__errno_location()` function to make it easy to access the thread-local `errno` variable. This has been exposed in rust-libc as of 0.2.77. This PR uses that functionality instead of the locally compiled C language shim, which the PR removes. One issue is backwards compatibilty. It requires 0.2.77 libc and DragonFly 5.8. Not sure how to gracefully handle older DragonFly versions, although I'm also not sure doing so is worth it. Co-authored-by: Chuck Musser <cmusser@sonic.net>
Diffstat (limited to 'src')
-rw-r--r--src/errno.rs24
-rw-r--r--src/errno_dragonfly.c3
2 files changed, 3 insertions, 24 deletions
diff --git a/src/errno.rs b/src/errno.rs
index eda097d8..03a7f0e2 100644
--- a/src/errno.rs
+++ b/src/errno.rs
@@ -1,5 +1,4 @@
use cfg_if::cfg_if;
-#[cfg(not(target_os = "dragonfly"))]
use libc::{c_int, c_void};
use std::{fmt, io, error};
use crate::{Error, Result};
@@ -13,32 +12,15 @@ cfg_if! {
unsafe fn errno_location() -> *mut c_int {
libc::__error()
}
- } else if #[cfg(target_os = "dragonfly")] {
- // DragonFly uses a thread-local errno variable, but #[thread_local] is
- // feature-gated and not available in stable Rust as of this writing
- // (Rust 1.21.0). We have to use a C extension to access it
- // (src/errno_dragonfly.c).
- //
- // Tracking issue for `thread_local` stabilization:
- //
- // https://github.com/rust-lang/rust/issues/29594
- //
- // Once this becomes stable, we can remove build.rs,
- // src/errno_dragonfly.c, and use:
- //
- // extern { #[thread_local] static errno: c_int; }
- //
- #[link(name="errno_dragonfly", kind="static")]
- extern {
- pub fn errno_location() -> *mut c_int;
- }
} else if #[cfg(any(target_os = "android",
target_os = "netbsd",
target_os = "openbsd"))] {
unsafe fn errno_location() -> *mut c_int {
libc::__errno()
}
- } else if #[cfg(any(target_os = "linux", target_os = "redox"))] {
+ } else if #[cfg(any(target_os = "linux",
+ target_os = "redox",
+ target_os = "dragonfly"))] {
unsafe fn errno_location() -> *mut c_int {
libc::__errno_location()
}
diff --git a/src/errno_dragonfly.c b/src/errno_dragonfly.c
deleted file mode 100644
index 32fb4dab..00000000
--- a/src/errno_dragonfly.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <errno.h>
-
-int *errno_location() { return &errno; }