@@ -114,7 +114,7 @@ impl Hash for Timespec {
114
114
}
115
115
}
116
116
117
- #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
117
+ #[ cfg( any( all ( target_os = "macos" , not ( target_arch = "aarch64" ) ) , target_os = "ios" ) ) ]
118
118
mod inner {
119
119
use crate :: fmt;
120
120
use crate :: sync:: atomic:: { AtomicU64 , Ordering } ;
@@ -146,14 +146,12 @@ mod inner {
146
146
type mach_timebase_info_t = * mut mach_timebase_info ;
147
147
type kern_return_t = libc:: c_int ;
148
148
149
- pub type clockid_t = libc:: clockid_t ;
150
-
151
149
impl Instant {
152
150
pub fn now ( ) -> Instant {
153
151
extern "C" {
154
- fn clock_gettime_nsec_np ( clock_id : clockid_t ) -> u64 ;
152
+ fn mach_absolute_time ( ) -> u64 ;
155
153
}
156
- Instant { t : unsafe { clock_gettime_nsec_np ( 8 ) } }
154
+ Instant { t : unsafe { mach_absolute_time ( ) } }
157
155
}
158
156
159
157
pub fn checked_sub_instant ( & self , other : & Instant ) -> Option < Duration > {
@@ -265,7 +263,7 @@ mod inner {
265
263
}
266
264
}
267
265
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" ) ) ) ]
269
267
mod inner {
270
268
use crate :: fmt;
271
269
use crate :: sys:: cvt;
@@ -287,7 +285,11 @@ mod inner {
287
285
288
286
impl Instant {
289
287
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) }
291
293
}
292
294
293
295
pub fn checked_sub_instant ( & self , other : & Instant ) -> Option < Duration > {
@@ -345,10 +347,12 @@ mod inner {
345
347
}
346
348
}
347
349
348
- #[ cfg( not( any( target_os = "dragonfly" , target_os = "espidf" ) ) ) ]
350
+ #[ cfg( not( any( target_os = "dragonfly" , target_os = "espidf" , target_os = "macos" ) ) ) ]
349
351
pub type clock_t = libc:: c_int ;
350
352
#[ cfg( any( target_os = "dragonfly" , target_os = "espidf" ) ) ]
351
353
pub type clock_t = libc:: c_ulong ;
354
+ #[ cfg( target_os = "macos" ) ]
355
+ pub type clock_t = libc:: clockid_t ;
352
356
353
357
fn now ( clock : clock_t ) -> Timespec {
354
358
let mut t = Timespec { t : libc:: timespec { tv_sec : 0 , tv_nsec : 0 } } ;
0 commit comments