Skip to content

Commit 7e46b95

Browse files
bors[bot]cmusser
andauthored
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 <[email protected]>
2 parents 7ed2820 + f5ee22d commit 7e46b95

File tree

3 files changed

+3
-33
lines changed

3 files changed

+3
-33
lines changed

build.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/errno.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use cfg_if::cfg_if;
2-
#[cfg(not(target_os = "dragonfly"))]
32
use libc::{c_int, c_void};
43
use std::{fmt, io, error};
54
use crate::{Error, Result};
@@ -13,32 +12,15 @@ cfg_if! {
1312
unsafe fn errno_location() -> *mut c_int {
1413
libc::__error()
1514
}
16-
} else if #[cfg(target_os = "dragonfly")] {
17-
// DragonFly uses a thread-local errno variable, but #[thread_local] is
18-
// feature-gated and not available in stable Rust as of this writing
19-
// (Rust 1.21.0). We have to use a C extension to access it
20-
// (src/errno_dragonfly.c).
21-
//
22-
// Tracking issue for `thread_local` stabilization:
23-
//
24-
// https://github.com/rust-lang/rust/issues/29594
25-
//
26-
// Once this becomes stable, we can remove build.rs,
27-
// src/errno_dragonfly.c, and use:
28-
//
29-
// extern { #[thread_local] static errno: c_int; }
30-
//
31-
#[link(name="errno_dragonfly", kind="static")]
32-
extern {
33-
pub fn errno_location() -> *mut c_int;
34-
}
3515
} else if #[cfg(any(target_os = "android",
3616
target_os = "netbsd",
3717
target_os = "openbsd"))] {
3818
unsafe fn errno_location() -> *mut c_int {
3919
libc::__errno()
4020
}
41-
} else if #[cfg(any(target_os = "linux", target_os = "redox"))] {
21+
} else if #[cfg(any(target_os = "linux",
22+
target_os = "redox",
23+
target_os = "dragonfly"))] {
4224
unsafe fn errno_location() -> *mut c_int {
4325
libc::__errno_location()
4426
}

src/errno_dragonfly.c

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)