File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
741741 )
742742 }
743743
744+ /// Helper function used inside the shims of foreign functions to assert that the target OS
745+ /// is one of `target_oses`. It panics showing a message with the `name` of the foreign function
746+ /// if this is not the case.
747+ fn assert_target_os_is_one_of ( & self , target_oses : & [ & str ] , name : & str ) {
748+ assert ! (
749+ target_oses. contains( & self . eval_context_ref( ) . tcx. sess. target. os. as_ref( ) ) ,
750+ "`{name}` is only available on the {} target OS's" ,
751+ target_oses. iter( ) . enumerate( ) . map( |( i, t) | match i {
752+ 0 => format!( "`{t}`" ) ,
753+ _ => format!( ", `{t}`" ) ,
754+ } ) . collect:: <String >( )
755+ )
756+ }
757+
744758 /// Helper function used inside the shims of foreign functions to assert that the target OS
745759 /// is part of the UNIX family. It panics showing a message with the `name` of the foreign function
746760 /// if this is not the case.
Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
284284
285285 fn linux_gettid ( & mut self ) -> InterpResult < ' tcx , Scalar > {
286286 let this = self . eval_context_ref ( ) ;
287- this. assert_target_os ( "linux" , "gettid" ) ;
287+ this. assert_target_os_is_one_of ( & [ "linux" , "android" ] , "gettid" ) ;
288288
289289 let index = this. machine . threads . active_thread ( ) . to_u32 ( ) ;
290290
You can’t perform that action at this time.
0 commit comments