@@ -5,6 +5,7 @@ use std::time::{Duration, SystemTime};
55
66use chrono:: { DateTime , Datelike , Offset , Timelike , Utc } ;
77use chrono_tz:: Tz ;
8+ use rustc_target:: spec:: Os ;
89
910use crate :: * ;
1011
@@ -31,8 +32,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3132 }
3233
3334 // Some further platform-specific names we support.
34- match this. tcx . sess . target . os . as_ref ( ) {
35- "linux" | "freebsd" | "android" => {
35+ match & this. tcx . sess . target . os {
36+ Os :: Linux | Os :: FreeBsd | Os :: Android => {
3637 // Linux further distinguishes regular and "coarse" clocks, but the "coarse" version
3738 // is just specified to be "faster and less precise", so we treat it like normal
3839 // clocks.
@@ -42,7 +43,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
4243 return Some ( TimeoutClock :: Monotonic ) ;
4344 }
4445 }
45- "macos" => {
46+ Os :: MacOs => {
4647 // `CLOCK_UPTIME_RAW` supposed to not increment while the system is asleep... but
4748 // that's not really something a program running inside Miri can tell, anyway.
4849 // We need to support it because std uses it.
@@ -176,7 +177,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
176177 // solaris/illumos system tm struct does not have
177178 // the additional tm_zone/tm_gmtoff fields.
178179 // https://docs.oracle.com/cd/E36784_01/html/E36874/localtime-r-3c.html
179- if !matches ! ( & * this. tcx. sess. target. os, "solaris" | "illumos" ) {
180+ if !matches ! ( & this. tcx. sess. target. os, Os :: Solaris | Os :: Illumos ) {
180181 // tm_zone represents the timezone value in the form of: +0730, +08, -0730 or -08.
181182 // This may not be consistent with libc::localtime_r's result.
182183
@@ -215,7 +216,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
215216 ) -> InterpResult < ' tcx > {
216217 let this = self . eval_context_mut ( ) ;
217218
218- this. assert_target_os ( "windows" , shim_name) ;
219+ this. assert_target_os ( Os :: Windows , shim_name) ;
219220 this. check_no_isolation ( shim_name) ?;
220221
221222 let filetime = this. deref_pointer_as ( LPFILETIME_op , this. windows_ty_layout ( "FILETIME" ) ) ?;
@@ -237,7 +238,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
237238 ) -> InterpResult < ' tcx , Scalar > {
238239 let this = self . eval_context_mut ( ) ;
239240
240- this. assert_target_os ( "windows" , "QueryPerformanceCounter" ) ;
241+ this. assert_target_os ( Os :: Windows , "QueryPerformanceCounter" ) ;
241242
242243 // QueryPerformanceCounter uses a hardware counter as its basis.
243244 // Miri will emulate a counter with a resolution of 1 nanosecond.
@@ -260,7 +261,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
260261 ) -> InterpResult < ' tcx , Scalar > {
261262 let this = self . eval_context_mut ( ) ;
262263
263- this. assert_target_os ( "windows" , "QueryPerformanceFrequency" ) ;
264+ this. assert_target_os ( Os :: Windows , "QueryPerformanceFrequency" ) ;
264265
265266 // Retrieves the frequency of the hardware performance counter.
266267 // The frequency of the performance counter is fixed at system boot and
@@ -301,7 +302,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
301302 fn mach_absolute_time ( & self ) -> InterpResult < ' tcx , Scalar > {
302303 let this = self . eval_context_ref ( ) ;
303304
304- this. assert_target_os ( "macos" , "mach_absolute_time" ) ;
305+ this. assert_target_os ( Os :: MacOs , "mach_absolute_time" ) ;
305306
306307 // This returns a u64, with time units determined dynamically by `mach_timebase_info`.
307308 // We return plain nanoseconds.
@@ -316,7 +317,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
316317 fn mach_timebase_info ( & mut self , info_op : & OpTy < ' tcx > ) -> InterpResult < ' tcx , Scalar > {
317318 let this = self . eval_context_mut ( ) ;
318319
319- this. assert_target_os ( "macos" , "mach_timebase_info" ) ;
320+ this. assert_target_os ( Os :: MacOs , "mach_timebase_info" ) ;
320321
321322 let info = this. deref_pointer_as ( info_op, this. libc_ty_layout ( "mach_timebase_info" ) ) ?;
322323
@@ -418,7 +419,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
418419 fn Sleep ( & mut self , timeout : & OpTy < ' tcx > ) -> InterpResult < ' tcx > {
419420 let this = self . eval_context_mut ( ) ;
420421
421- this. assert_target_os ( "windows" , "Sleep" ) ;
422+ this. assert_target_os ( Os :: Windows , "Sleep" ) ;
422423
423424 let timeout_ms = this. read_scalar ( timeout) ?. to_u32 ( ) ?;
424425
0 commit comments