@@ -114,11 +114,7 @@ impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mi
114
114
pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriEvalContextExt < ' mir , ' tcx > {
115
115
fn getenv ( & mut self , name_op : & OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , Pointer < Option < Tag > > > {
116
116
let this = self . eval_context_mut ( ) ;
117
- let target_os = & this. tcx . sess . target . os ;
118
- assert ! (
119
- target_os == "linux" || target_os == "macos" ,
120
- "`getenv` is only available for the UNIX target family"
121
- ) ;
117
+ this. assert_target_os_is_unix ( "getenv" ) ;
122
118
123
119
let name_ptr = this. read_pointer ( name_op) ?;
124
120
let name = this. read_os_str_from_c_str ( name_ptr) ?;
@@ -212,11 +208,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
212
208
value_op : & OpTy < ' tcx , Tag > ,
213
209
) -> InterpResult < ' tcx , i32 > {
214
210
let mut this = self . eval_context_mut ( ) ;
215
- let target_os = & this. tcx . sess . target . os ;
216
- assert ! (
217
- target_os == "linux" || target_os == "macos" ,
218
- "`setenv` is only available for the UNIX target family"
219
- ) ;
211
+ this. assert_target_os_is_unix ( "setenv" ) ;
220
212
221
213
let name_ptr = this. read_pointer ( name_op) ?;
222
214
let value_ptr = this. read_pointer ( value_op) ?;
@@ -286,11 +278,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
286
278
287
279
fn unsetenv ( & mut self , name_op : & OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , i32 > {
288
280
let this = self . eval_context_mut ( ) ;
289
- let target_os = & this. tcx . sess . target . os ;
290
- assert ! (
291
- target_os == "linux" || target_os == "macos" ,
292
- "`unsetenv` is only available for the UNIX target family"
293
- ) ;
281
+ this. assert_target_os_is_unix ( "unsetenv" ) ;
294
282
295
283
let name_ptr = this. read_pointer ( name_op) ?;
296
284
let mut success = None ;
@@ -320,11 +308,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
320
308
size_op : & OpTy < ' tcx , Tag > ,
321
309
) -> InterpResult < ' tcx , Pointer < Option < Tag > > > {
322
310
let this = self . eval_context_mut ( ) ;
323
- let target_os = & this. tcx . sess . target . os ;
324
- assert ! (
325
- target_os == "linux" || target_os == "macos" ,
326
- "`getcwd` is only available for the UNIX target family"
327
- ) ;
311
+ this. assert_target_os_is_unix ( "getcwd" ) ;
328
312
329
313
let buf = this. read_pointer ( & buf_op) ?;
330
314
let size = this. read_scalar ( & size_op) ?. to_machine_usize ( & * this. tcx ) ?;
@@ -379,11 +363,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
379
363
380
364
fn chdir ( & mut self , path_op : & OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , i32 > {
381
365
let this = self . eval_context_mut ( ) ;
382
- let target_os = & this. tcx . sess . target . os ;
383
- assert ! (
384
- target_os == "linux" || target_os == "macos" ,
385
- "`getcwd` is only available for the UNIX target family"
386
- ) ;
366
+ this. assert_target_os_is_unix ( "chdir" ) ;
387
367
388
368
let path = this. read_path_from_c_str ( this. read_pointer ( path_op) ?) ?;
389
369
0 commit comments