@@ -114,11 +114,7 @@ impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mi
114114pub trait EvalContextExt < ' mir , ' tcx : ' mir > : crate :: MiriEvalContextExt < ' mir , ' tcx > {
115115 fn getenv ( & mut self , name_op : & OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , Pointer < Option < Tag > > > {
116116 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" ) ;
122118
123119 let name_ptr = this. read_pointer ( name_op) ?;
124120 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
212208 value_op : & OpTy < ' tcx , Tag > ,
213209 ) -> InterpResult < ' tcx , i32 > {
214210 let 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" ) ;
220212
221213 let name_ptr = this. read_pointer ( name_op) ?;
222214 let value_ptr = this. read_pointer ( value_op) ?;
@@ -286,11 +278,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
286278
287279 fn unsetenv ( & mut self , name_op : & OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , i32 > {
288280 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" ) ;
294282
295283 let name_ptr = this. read_pointer ( name_op) ?;
296284 let mut success = None ;
@@ -320,11 +308,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
320308 size_op : & OpTy < ' tcx , Tag > ,
321309 ) -> InterpResult < ' tcx , Pointer < Option < Tag > > > {
322310 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" ) ;
328312
329313 let buf = this. read_pointer ( buf_op) ?;
330314 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
379363
380364 fn chdir ( & mut self , path_op : & OpTy < ' tcx , Tag > ) -> InterpResult < ' tcx , i32 > {
381365 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- "`chdir` is only available for the UNIX target family"
386- ) ;
366+ this. assert_target_os_is_unix ( "chdir" ) ;
387367
388368 let path = this. read_path_from_c_str ( this. read_pointer ( path_op) ?) ?;
389369
@@ -469,11 +449,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
469449
470450 fn getpid ( & mut self ) -> InterpResult < ' tcx , i32 > {
471451 let this = self . eval_context_mut ( ) ;
472- let target_os = & this. tcx . sess . target . os ;
473- assert ! (
474- target_os == "linux" || target_os == "macos" ,
475- "`getpid` is only available for the UNIX target family"
476- ) ;
452+ this. assert_target_os_is_unix ( "getpid" ) ;
477453
478454 this. check_no_isolation ( "`getpid`" ) ?;
479455
0 commit comments