@@ -13,6 +13,7 @@ pub fn system_time_to_duration<'tcx>(time: &SystemTime) -> InterpResult<'tcx, Du
1313 . map_err ( |_| err_unsup_format ! ( "times before the Unix epoch are not supported" ) . into ( ) )
1414}
1515
16+
1617impl < ' mir , ' tcx > EvalContextExt < ' mir , ' tcx > for crate :: MiriEvalContext < ' mir , ' tcx > { }
1718pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriEvalContextExt < ' mir , ' tcx > {
1819 fn clock_gettime (
@@ -159,4 +160,25 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
159160 u64:: try_from ( duration. as_nanos ( ) )
160161 . map_err ( |_| err_unsup_format ! ( "programs running longer than 2^64 nanoseconds are not supported" ) . into ( ) )
161162 }
163+
164+ fn mach_timebase_info ( & mut self , info_op : OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , i32 > {
165+ let this = self . eval_context_mut ( ) ;
166+
167+ this. assert_target_os ( "macos" , "mach_timebase_info" ) ;
168+ this. check_no_isolation ( "mach_timebase_info" ) ?;
169+
170+ let info = this. deref_operand ( info_op) ?;
171+
172+ // Since we return nanoseceonds instead of ticks from
173+ // `mach_absolute_time`, we don't need to scale the absolute
174+ // time.
175+ let ( numer, denom) = ( 1 , 1 ) ;
176+ let imms = [
177+ immty_from_int_checked ( numer, this. libc_ty_layout ( "uint32_t" ) ?) ?,
178+ immty_from_int_checked ( denom, this. libc_ty_layout ( "uint32_t" ) ?) ?
179+ ] ;
180+
181+ this. write_packed_immediates ( info, & imms) ?;
182+ Ok ( 0 )
183+ }
162184}
0 commit comments