Skip to content

Commit 41b893f

Browse files
committed
fix Windows stdout/stderr
1 parent 7db453d commit 41b893f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/fn_call.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,12 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
596596
this.write_scalar(Scalar::from_uint(key, dest.layout.size), dest)?;
597597
}
598598
"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;
600600
let ptr = this.machine.tls.load_tls(key)?;
601601
this.write_scalar(ptr, dest)?;
602602
}
603603
"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;
605605
let new_ptr = this.read_scalar(args[1])?.not_undef()?;
606606
this.machine.tls.store_tls(key, new_ptr)?;
607607

@@ -615,22 +615,22 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
615615
this.write_scalar(handle, dest)?;
616616
}
617617
"WriteFile" => {
618-
let handle = this.read_scalar(args[0])?.to_i32()?;
618+
let handle = this.read_scalar(args[0])?.to_isize(this)?;
619619
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()?;
621621
let written_place = this.deref_operand(args[3])?;
622622
this.write_null(written_place.into())?; // spec says we always write 0 first
623623
let written = if handle == -11 || handle == -12 {
624624
// stdout/stderr
625625
use std::io::{self, Write};
626626

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)))?;
628628
let res = if handle == -11 {
629629
io::stdout().write(buf_cont)
630630
} else {
631631
io::stderr().write(buf_cont)
632632
};
633-
res.ok().map(|n| n as u64)
633+
res.ok().map(|n| n as u32)
634634
} else {
635635
eprintln!("Miri: Ignored output to handle {}", handle);
636636
Some(n) // pretend it all went well

0 commit comments

Comments
 (0)