File tree Expand file tree Collapse file tree 6 files changed +31
-5
lines changed
bsd/freebsdlike/dragonfly Expand file tree Collapse file tree 6 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,17 @@ use std::str;
55fn 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
5862fn rustc_minor_version ( ) -> Option < u32 > {
Original file line number Diff line number Diff line change 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) ]
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments