File tree 3 files changed +26
-4
lines changed
3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,10 @@ fn main() {
72
72
println ! ( "cargo:rustc-cfg=libc_cfg_target_vendor" ) ;
73
73
}
74
74
75
+ if rustc_minor_ver >= 51 || rustc_dep_of_std {
76
+ println ! ( "cargo:rustc-cfg=libc_ptr_addr_of" ) ;
77
+ }
78
+
75
79
// #[thread_local] is currently unstable
76
80
if rustc_dep_of_std {
77
81
println ! ( "cargo:rustc-cfg=libc_thread_local" ) ;
Original file line number Diff line number Diff line change @@ -341,3 +341,19 @@ macro_rules! deprecated_mach {
341
341
) *
342
342
}
343
343
}
344
+
345
+ #[ allow( unused_macros) ]
346
+ #[ cfg( not( libc_ptr_addr_of) ) ]
347
+ macro_rules! ptr_addr_of {
348
+ ( $place: expr) => {
349
+ & $place
350
+ } ;
351
+ }
352
+
353
+ #[ allow( unused_macros) ]
354
+ #[ cfg( libc_ptr_addr_of) ]
355
+ macro_rules! ptr_addr_of {
356
+ ( $place: expr) => {
357
+ :: core:: ptr:: addr_of!( $place)
358
+ } ;
359
+ }
Original file line number Diff line number Diff line change @@ -352,10 +352,12 @@ pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
352
352
pub const _SC_IOV_MAX: c_int = 60 ;
353
353
pub const _SC_SYMLOOP_MAX: c_int = 173 ;
354
354
355
- pub static CLOCK_MONOTONIC : clockid_t = unsafe { clockid_t ( & _CLOCK_MONOTONIC) } ;
356
- pub static CLOCK_PROCESS_CPUTIME_ID : clockid_t = unsafe { clockid_t ( & _CLOCK_PROCESS_CPUTIME_ID) } ;
357
- pub static CLOCK_REALTIME : clockid_t = unsafe { clockid_t ( & _CLOCK_REALTIME) } ;
358
- pub static CLOCK_THREAD_CPUTIME_ID : clockid_t = unsafe { clockid_t ( & _CLOCK_THREAD_CPUTIME_ID) } ;
355
+ pub static CLOCK_MONOTONIC : clockid_t = unsafe { clockid_t ( ptr_addr_of ! ( _CLOCK_MONOTONIC) ) } ;
356
+ pub static CLOCK_PROCESS_CPUTIME_ID : clockid_t =
357
+ unsafe { clockid_t ( ptr_addr_of ! ( _CLOCK_PROCESS_CPUTIME_ID) ) } ;
358
+ pub static CLOCK_REALTIME : clockid_t = unsafe { clockid_t ( ptr_addr_of ! ( _CLOCK_REALTIME) ) } ;
359
+ pub static CLOCK_THREAD_CPUTIME_ID : clockid_t =
360
+ unsafe { clockid_t ( ptr_addr_of ! ( _CLOCK_THREAD_CPUTIME_ID) ) } ;
359
361
360
362
#[ cfg_attr(
361
363
feature = "rustc-dep-of-std" ,
You can’t perform that action at this time.
0 commit comments