Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.

Commit a2870ad

Browse files
Merge branch 'master' of https://github.com/rust-lang/libc into wii
1 parent 14a6ad4 commit a2870ad

File tree

7 files changed

+32
-6
lines changed

7 files changed

+32
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libc"
3-
version = "0.2.59"
3+
version = "0.2.60"
44
authors = ["The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"

build.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ use std::str;
55
fn main() {
66
let rustc_minor_ver =
77
rustc_minor_version().expect("Failed to get rustc version");
8-
let rustc_dep_of_std =
9-
std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
10-
let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok();
8+
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
9+
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
1110

12-
if std::env::var("CARGO_FEATURE_USE_STD").is_ok() {
11+
if env::var("CARGO_FEATURE_USE_STD").is_ok() {
1312
println!(
1413
"cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \
1514
please consider using the `std` cargo feature instead\""
1615
);
1716
}
1817

19-
if std::env::var("LIBC_CI").is_ok() {
18+
if env::var("LIBC_CI").is_ok() {
2019
if let Some(12) = which_freebsd() {
2120
println!("cargo:rustc-cfg=freebsd12");
2221
}
@@ -53,6 +52,11 @@ fn main() {
5352
if rustc_minor_ver >= 33 || rustc_dep_of_std {
5453
println!("cargo:rustc-cfg=libc_packedN");
5554
}
55+
56+
// #[thread_local] is currently unstable
57+
if rustc_dep_of_std {
58+
println!("cargo:rustc-cfg=libc_thread_local");
59+
}
5660
}
5761

5862
fn rustc_minor_version() -> Option<u32> {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
feature = "rustc-dep-of-std",
2222
feature(cfg_target_vendor, link_cfg, no_core)
2323
)]
24+
#![cfg_attr(libc_thread_local, feature(thread_local))]
2425
// Enable extra lints:
2526
#![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
2627
#![deny(missing_copy_implementations, safe_packed_borrows)]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// DragonFlyBSD's __error function is declared with "static inline", so it must
2+
// be implemented in the libc crate, as a pointer to a static thread_local.
3+
f! {
4+
pub fn __error() -> *mut ::c_int {
5+
&mut errno
6+
}
7+
}
8+
9+
extern {
10+
#[thread_local]
11+
pub static mut errno: ::c_int;
12+
}

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,3 +1060,10 @@ extern {
10601060
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
10611061
pub fn uname(buf: *mut ::utsname) -> ::c_int;
10621062
}
1063+
1064+
cfg_if! {
1065+
if #[cfg(libc_thread_local)] {
1066+
mod errno;
1067+
pub use self::errno::*;
1068+
}
1069+
}

src/unix/haiku/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,7 @@ extern {
12671267
pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
12681268
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
12691269
buflen: ::size_t) -> ::c_int;
1270+
pub fn _errnop() -> *mut ::c_int;
12701271

12711272
pub fn abs(i: ::c_int) -> ::c_int;
12721273
pub fn atof(s: *const ::c_char) -> ::c_double;

src/unix/redox/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ extern {
539539

540540
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
541541
buflen: ::size_t) -> ::c_int;
542+
pub fn __errno_location() -> *mut ::c_int;
542543

543544
// malloc.h
544545
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;

0 commit comments

Comments
 (0)