File tree Expand file tree Collapse file tree 6 files changed +35
-15
lines changed
unix/bsd/freebsdlike/dragonfly Expand file tree Collapse file tree 6 files changed +35
-15
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,9 @@ rustc-std-workspace-core = { version = "1.0.0", optional = true }
26
26
default = [" std" ]
27
27
std = []
28
28
align = []
29
- rustc-dep-of-std = [' align' , ' rustc-std-workspace-core' ]
29
+ rustc-dep-of-std = [' align' , ' rustc-std-workspace-core' , ' unstable ' ]
30
30
extra_traits = []
31
+ unstable = []
31
32
# use_std is deprecated, use `std` instead
32
33
use_std = [ ' std' ]
33
34
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ libc = "0.2"
35
35
* ` extra_traits ` : all ` struct ` s implemented in ` libc ` are ` Copy ` and ` Clone ` .
36
36
This feature derives ` Debug ` , ` Eq ` , ` Hash ` , and ` PartialEq ` .
37
37
38
+ * ` unstable ` : enable currently unstable bindings. Right now, this just allows
39
+ bindings to ` #[thread_local] ` statics on certain platforms. Requires nightly.
40
+
38
41
* ** deprecated** : ` use_std ` is deprecated, and is equivalent to ` std ` .
39
42
40
43
## Rust version support
Original file line number Diff line number Diff line change @@ -5,18 +5,18 @@ use std::str;
5
5
fn main ( ) {
6
6
let rustc_minor_ver =
7
7
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 ( ) ;
10
+ let unstable_cargo_feature = env:: var ( "CARGO_FEATURE_UNSTABLE " ) . is_ok ( ) ;
11
11
12
- if std :: env:: var ( "CARGO_FEATURE_USE_STD" ) . is_ok ( ) {
12
+ if env:: var ( "CARGO_FEATURE_USE_STD" ) . is_ok ( ) {
13
13
println ! (
14
14
"cargo:warning=\" libc's use_std cargo feature is deprecated since libc 0.2.55; \
15
15
please consider using the `std` cargo feature instead\" "
16
16
) ;
17
17
}
18
18
19
- if std :: env:: var ( "LIBC_CI" ) . is_ok ( ) {
19
+ if env:: var ( "LIBC_CI" ) . is_ok ( ) {
20
20
if let Some ( 12 ) = which_freebsd ( ) {
21
21
println ! ( "cargo:rustc-cfg=freebsd12" ) ;
22
22
}
@@ -53,6 +53,11 @@ fn main() {
53
53
if rustc_minor_ver >= 33 || rustc_dep_of_std {
54
54
println ! ( "cargo:rustc-cfg=libc_packedN" ) ;
55
55
}
56
+
57
+ // #[thread_local] is currently unstable
58
+ if unstable_cargo_feature || rustc_dep_of_std {
59
+ println ! ( "cargo:rustc-cfg=libc_thread_local" ) ;
60
+ }
56
61
}
57
62
58
63
fn rustc_minor_version ( ) -> Option < u32 > {
Original file line number Diff line number Diff line change 21
21
feature = "rustc-dep-of-std" ,
22
22
feature( cfg_target_vendor, link_cfg, no_core)
23
23
) ]
24
+ #![ cfg_attr( libc_thread_local, feature( thread_local) ) ]
24
25
// Enable extra lints:
25
26
#![ cfg_attr( feature = "extra_traits" , deny( missing_debug_implementations) ) ]
26
27
#![ 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 @@ -1036,18 +1036,9 @@ f! {
1036
1036
( _CMSG_ALIGN( :: mem:: size_of:: <:: cmsghdr>( ) ) +
1037
1037
_CMSG_ALIGN( length as usize ) ) as :: c_uint
1038
1038
}
1039
-
1040
- #[ cfg( libc_thread_local) ]
1041
- pub fn __error( ) -> * mut :: c_int {
1042
- & mut errno
1043
- }
1044
1039
}
1045
1040
1046
1041
extern {
1047
- #[ cfg( libc_thread_local) ]
1048
- #[ thread_local]
1049
- static mut errno: :: c_int ;
1050
-
1051
1042
pub fn setgrent ( ) ;
1052
1043
pub fn mprotect ( addr : * mut :: c_void , len : :: size_t , prot : :: c_int )
1053
1044
-> :: c_int ;
@@ -1069,3 +1060,10 @@ extern {
1069
1060
pub fn fstatfs ( fd : :: c_int , buf : * mut statfs ) -> :: c_int ;
1070
1061
pub fn uname ( buf : * mut :: utsname ) -> :: c_int ;
1071
1062
}
1063
+
1064
+ cfg_if ! {
1065
+ if #[ cfg( libc_thread_local) ] {
1066
+ mod errno;
1067
+ pub use self :: errno:: * ;
1068
+ }
1069
+ }
You can’t perform that action at this time.
0 commit comments