@@ -73,17 +73,23 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
7373 . not_undef ( )
7474 }
7575
76+ /// Helper function to get a `libc` constant as an `i32`.
77+ fn eval_libc_i32 ( & mut self , name : & str ) -> InterpResult < ' tcx , i32 > {
78+ // TODO: Cache the result.
79+ self . eval_libc ( name) ?. to_i32 ( )
80+ }
81+
7682 /// Helper function to get a `windows` constant as a `Scalar`.
77- fn eval_windows ( & mut self , name : & str ) -> InterpResult < ' tcx , Scalar < Tag > > {
83+ fn eval_windows ( & mut self , module : & str , name : & str ) -> InterpResult < ' tcx , Scalar < Tag > > {
7884 self . eval_context_mut ( )
79- . eval_path_scalar ( & [ "std" , "sys" , "windows" , "c" , name] ) ?
85+ . eval_path_scalar ( & [ "std" , "sys" , "windows" , module , name] ) ?
8086 . not_undef ( )
8187 }
8288
83- /// Helper function to get a `libc ` constant as an `i32 `.
84- fn eval_libc_i32 ( & mut self , name : & str ) -> InterpResult < ' tcx , i32 > {
89+ /// Helper function to get a `windows ` constant as an `u64 `.
90+ fn eval_windows_u64 ( & mut self , module : & str , name : & str ) -> InterpResult < ' tcx , u64 > {
8591 // TODO: Cache the result.
86- self . eval_libc ( name) ?. to_i32 ( )
92+ self . eval_windows ( module , name) ?. to_u64 ( )
8793 }
8894
8995 /// Helper function to get the `TyAndLayout` of a `libc` type
@@ -93,6 +99,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
9399 this. layout_of ( ty)
94100 }
95101
102+ /// Helper function to get the `TyAndLayout` of a `windows` type
103+ fn windows_ty_layout ( & mut self , name : & str ) -> InterpResult < ' tcx , TyAndLayout < ' tcx > > {
104+ let this = self . eval_context_mut ( ) ;
105+ let ty = this. resolve_path ( & [ "std" , "sys" , "windows" , "c" , name] ) . monomorphic_ty ( * this. tcx ) ;
106+ this. layout_of ( ty)
107+ }
108+
96109 /// Write a 0 of the appropriate size to `dest`.
97110 fn write_null ( & mut self , dest : PlaceTy < ' tcx , Tag > ) -> InterpResult < ' tcx > {
98111 self . eval_context_mut ( ) . write_scalar ( Scalar :: from_int ( 0 , dest. layout . size ) , dest)
@@ -350,7 +363,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
350363 }
351364 }
352365
353- // Writes several `ImmTy`s contiguosly into memory. This is useful when you have to pack
366+ // Writes several `ImmTy`s contiguously into memory. This is useful when you have to pack
354367 // different values into a struct.
355368 fn write_packed_immediates (
356369 & mut self ,
@@ -439,7 +452,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
439452 } ) ?
440453 } else if target_os == "windows" {
441454 // FIXME: we have to finish implementing the Windows equivalent of this.
442- this. eval_windows ( match e. kind ( ) {
455+ this. eval_windows ( "c" , match e. kind ( ) {
443456 NotFound => "ERROR_FILE_NOT_FOUND" ,
444457 _ => throw_unsup_format ! ( "io error {} cannot be transformed into a raw os error" , e)
445458 } ) ?
0 commit comments