File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,10 @@ fn main() {
7272 println ! ( "cargo:rustc-cfg=libc_cfg_target_vendor" ) ;
7373 }
7474
75+ if rustc_minor_ver >= 51 || rustc_dep_of_std {
76+ println ! ( "cargo:rustc-cfg=libc_ptr_addr_of" ) ;
77+ }
78+
7579 // #[thread_local] is currently unstable
7680 if rustc_dep_of_std {
7781 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 {
341341 ) *
342342 }
343343}
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;
352352pub const _SC_IOV_MAX: c_int = 60 ;
353353pub const _SC_SYMLOOP_MAX: c_int = 173 ;
354354
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) ) } ;
359361
360362#[ cfg_attr(
361363 feature = "rustc-dep-of-std" ,
You can’t perform that action at this time.
0 commit comments