Skip to content

Commit

Permalink
make ExitProcess Windows-only
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 4, 2024
1 parent 85e061a commit 745e3f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/tools/miri/src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,8 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
}

// Aborting the process.
"exit" | "ExitProcess" => {
let exp_abi = if link_name.as_str() == "exit" {
Abi::C { unwind: false }
} else {
Abi::System { unwind: false }
};
let [code] = this.check_shim(abi, exp_abi, link_name, args)?;
// it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
"exit" => {
let [code] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let code = this.read_scalar(code)?.to_i32()?;
throw_machine_stop!(TerminationInfo::Exit { code: code.into(), leak_check: false });
}
Expand Down
6 changes: 6 additions & 0 deletions src/tools/miri/src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
}

// Miscellaneous
"ExitProcess" => {
let [code] =
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
let code = this.read_scalar(code)?.to_u32()?;
throw_machine_stop!(TerminationInfo::Exit { code: code.into(), leak_check: false });
}
"SystemFunction036" => {
// This is really 'RtlGenRandom'.
let [ptr, len] =
Expand Down

0 comments on commit 745e3f2

Please sign in to comment.