@@ -596,12 +596,12 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
596
596
this. write_scalar ( Scalar :: from_uint ( key, dest. layout . size ) , dest) ?;
597
597
}
598
598
"TlsGetValue" => {
599
- let key = this. read_scalar ( args[ 0 ] ) ?. to_bits ( args [ 0 ] . layout . size ) ? ;
599
+ let key = this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ? as u128 ;
600
600
let ptr = this. machine . tls . load_tls ( key) ?;
601
601
this. write_scalar ( ptr, dest) ?;
602
602
}
603
603
"TlsSetValue" => {
604
- let key = this. read_scalar ( args[ 0 ] ) ?. to_bits ( args [ 0 ] . layout . size ) ? ;
604
+ let key = this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ? as u128 ;
605
605
let new_ptr = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
606
606
this. machine . tls . store_tls ( key, new_ptr) ?;
607
607
@@ -615,22 +615,22 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
615
615
this. write_scalar ( handle, dest) ?;
616
616
}
617
617
"WriteFile" => {
618
- let handle = this. read_scalar ( args[ 0 ] ) ?. to_i32 ( ) ?;
618
+ let handle = this. read_scalar ( args[ 0 ] ) ?. to_isize ( this ) ?;
619
619
let buf = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
620
- let n = this. read_scalar ( args[ 2 ] ) ?. to_usize ( & * this . tcx ) ?;
620
+ let n = this. read_scalar ( args[ 2 ] ) ?. to_u32 ( ) ?;
621
621
let written_place = this. deref_operand ( args[ 3 ] ) ?;
622
622
this. write_null ( written_place. into ( ) ) ?; // spec says we always write 0 first
623
623
let written = if handle == -11 || handle == -12 {
624
624
// stdout/stderr
625
625
use std:: io:: { self , Write } ;
626
626
627
- let buf_cont = this. memory ( ) . read_bytes ( buf, Size :: from_bytes ( n ) ) ?;
627
+ let buf_cont = this. memory ( ) . read_bytes ( buf, Size :: from_bytes ( u64 :: from ( n ) ) ) ?;
628
628
let res = if handle == -11 {
629
629
io:: stdout ( ) . write ( buf_cont)
630
630
} else {
631
631
io:: stderr ( ) . write ( buf_cont)
632
632
} ;
633
- res. ok ( ) . map ( |n| n as u64 )
633
+ res. ok ( ) . map ( |n| n as u32 )
634
634
} else {
635
635
eprintln ! ( "Miri: Ignored output to handle {}" , handle) ;
636
636
Some ( n) // pretend it all went well
0 commit comments