diff options
| author | bors <bors@rust-lang.org> | 2024-06-28 07:31:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-28 07:31:21 +0000 |
| commit | 9c21872a405de514044b9cc8ec93f50b35b0f0cb (patch) | |
| tree | e3cb67e762f966d6a0917070b874223229c2cb29 /src | |
| parent | b280af45f430d1efc85d7e4fcc4933d4ec9f94b2 (diff) | |
| parent | 9d69154f5621391abad5aa055390545c1867c5ab (diff) | |
| download | rust-9c21872a405de514044b9cc8ec93f50b35b0f0cb.tar.gz rust-9c21872a405de514044b9cc8ec93f50b35b0f0cb.zip | |
Auto merge of #3716 - cgettys-microsoft:dev/cgettys/process_id_fixup-03, r=RalfJung
Remove GetCurrentProcessId's frame_in_std check Most of the support required to close #1727 was actually added a while back, in #2215. However, for some reason, even though the Unix/Linux syscall equivalent has no `frame_in_std()` check, the Windows `GetCurrentProcessId` check did. While the vast majority of use cases use `std::process::id`, there's no particular reason to penalize any Windows code that is no_std or for whatever other reason choses to call the function directly (e.g. via the generated [windows-sys](https://docs.rs/windows-sys/latest/windows_sys/Win32/System/Threading/fn.GetCurrentProcessId.html) method). The emulation should still work fine. Given there's no reason not to, we might as well simplify the code a tiny bit and save that branch / frame check during runtime too. This PR removes the `frame_in_std` restriction for `GetCurrentProcessId`, and also moves it into the environment related shim section per discussion in https://github.com/rust-lang/miri/issues/1727#issuecomment-2184679952. Still passes existing tests/pass/getpid.rs test. Closes #1727 unless we wish to give a dummy value when isolated, which we don't seem to want to do at this time.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/miri/src/shims/windows/foreign_items.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index a8403669774..c9db798caad 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -138,6 +138,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let result = this.GetUserProfileDirectoryW(token, buf, size)?; this.write_scalar(result, dest)?; } + "GetCurrentProcessId" => { + let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; + let result = this.GetCurrentProcessId()?; + this.write_int(result, dest)?; + } // File related shims "NtWriteFile" => { @@ -743,11 +748,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Any non zero value works for the stdlib. This is just used for stack overflows anyway. this.write_int(1, dest)?; } - "GetCurrentProcessId" if this.frame_in_std() => { - let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; - let result = this.GetCurrentProcessId()?; - this.write_int(result, dest)?; - } // this is only callable from std because we know that std ignores the return value "SwitchToThread" if this.frame_in_std() => { let [] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; |
