@@ -114,7 +114,7 @@ impl Hash for Timespec {
114114 }
115115}
116116
117- #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
117+ #[ cfg( any( all ( target_os = "macos" , not ( target_arch = "aarch64" ) ) , target_os = "ios" ) ) ]
118118mod inner {
119119 use crate :: fmt;
120120 use crate :: sync:: atomic:: { AtomicU64 , Ordering } ;
@@ -146,14 +146,12 @@ mod inner {
146146 type mach_timebase_info_t = * mut mach_timebase_info ;
147147 type kern_return_t = libc:: c_int ;
148148
149- pub type clockid_t = libc:: clockid_t ;
150-
151149 impl Instant {
152150 pub fn now ( ) -> Instant {
153151 extern "C" {
154- fn clock_gettime_nsec_np ( clock_id : clockid_t ) -> u64 ;
152+ fn mach_absolute_time ( ) -> u64 ;
155153 }
156- Instant { t : unsafe { clock_gettime_nsec_np ( 8 ) } }
154+ Instant { t : unsafe { mach_absolute_time ( ) } }
157155 }
158156
159157 pub fn checked_sub_instant ( & self , other : & Instant ) -> Option < Duration > {
@@ -265,7 +263,7 @@ mod inner {
265263 }
266264}
267265
268- #[ cfg( not( any( target_os = "macos" , target_os = "ios" ) ) ) ]
266+ #[ cfg( not( any( all ( target_os = "macos" , not ( target_arch = "aarch64" ) ) , target_os = "ios" ) ) ) ]
269267mod inner {
270268 use crate :: fmt;
271269 use crate :: sys:: cvt;
@@ -287,7 +285,11 @@ mod inner {
287285
288286 impl Instant {
289287 pub fn now ( ) -> Instant {
290- Instant { t : now ( libc:: CLOCK_MONOTONIC ) }
288+ #[ cfg( target_os = "macos" ) ]
289+ const clock_id: clock_t = 8 ;
290+ #[ cfg( not( target_os = "macos" ) ) ]
291+ const clock_id: clock_t = libc:: CLOCK_MONOTONIC ;
292+ Instant { t : now ( clock_id) }
291293 }
292294
293295 pub fn checked_sub_instant ( & self , other : & Instant ) -> Option < Duration > {
@@ -345,10 +347,12 @@ mod inner {
345347 }
346348 }
347349
348- #[ cfg( not( any( target_os = "dragonfly" , target_os = "espidf" ) ) ) ]
350+ #[ cfg( not( any( target_os = "dragonfly" , target_os = "espidf" , target_os = "macos" ) ) ) ]
349351 pub type clock_t = libc:: c_int ;
350352 #[ cfg( any( target_os = "dragonfly" , target_os = "espidf" ) ) ]
351353 pub type clock_t = libc:: c_ulong ;
354+ #[ cfg( target_os = "macos" ) ]
355+ pub type clock_t = libc:: clockid_t ;
352356
353357 fn now ( clock : clock_t ) -> Timespec {
354358 let mut t = Timespec { t : libc:: timespec { tv_sec : 0 , tv_nsec : 0 } } ;
0 commit comments