Auto merge of #1698 - RalfJung:rustup, r=RalfJung

rustup; remove some no-longer-needed Windows shims

libstd now calls these lock functions directly, and `GetModuleHandleW` isn't use either any more since https://github.com/rust-lang/rust/pull/81478.
This commit is contained in:
bors 2021-01-31 13:25:37 +00:00
commit 39a7bd09f1
4 changed files with 7 additions and 57 deletions

View File

@ -1 +1 @@
9b3242982202707be2485b1e4cf5f3b34466a38d 0e63af5da3400ace48a0345117980473fd21ad73

View File

@ -34,7 +34,9 @@ fn call_dlsym(
ret: Option<(PlaceTy<'tcx, Tag>, mir::BasicBlock)>, ret: Option<(PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
) -> InterpResult<'tcx> { ) -> InterpResult<'tcx> {
let this = self.eval_context_mut(); let this = self.eval_context_mut();
check_abi(abi, Abi::C)?; check_abi(abi, Abi::C)?;
match dlsym { match dlsym {
Dlsym::Linux(dlsym) => linux::EvalContextExt::call_dlsym(this, dlsym, args, ret), Dlsym::Linux(dlsym) => linux::EvalContextExt::call_dlsym(this, dlsym, args, ret),
Dlsym::MacOs(dlsym) => macos::EvalContextExt::call_dlsym(this, dlsym, args, ret), Dlsym::MacOs(dlsym) => macos::EvalContextExt::call_dlsym(this, dlsym, args, ret),

View File

@ -1,20 +1,11 @@
use rustc_middle::mir; use rustc_middle::mir;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use log::trace;
use crate::*; use crate::*;
use helpers::{check_abi, check_arg_count}; use helpers::check_abi;
use shims::windows::sync::EvalContextExt as _;
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum Dlsym { pub enum Dlsym {
AcquireSRWLockExclusive,
ReleaseSRWLockExclusive,
TryAcquireSRWLockExclusive,
AcquireSRWLockShared,
ReleaseSRWLockShared,
TryAcquireSRWLockShared,
} }
impl Dlsym { impl Dlsym {
@ -22,12 +13,6 @@ impl Dlsym {
// should become a NULL pointer (pretend it does not exist). // should become a NULL pointer (pretend it does not exist).
pub fn from_str(name: &str) -> InterpResult<'static, Option<Dlsym>> { pub fn from_str(name: &str) -> InterpResult<'static, Option<Dlsym>> {
Ok(match name { Ok(match name {
"AcquireSRWLockExclusive" => Some(Dlsym::AcquireSRWLockExclusive),
"ReleaseSRWLockExclusive" => Some(Dlsym::ReleaseSRWLockExclusive),
"TryAcquireSRWLockExclusive" => Some(Dlsym::TryAcquireSRWLockExclusive),
"AcquireSRWLockShared" => Some(Dlsym::AcquireSRWLockShared),
"ReleaseSRWLockShared" => Some(Dlsym::ReleaseSRWLockShared),
"TryAcquireSRWLockShared" => Some(Dlsym::TryAcquireSRWLockShared),
"GetSystemTimePreciseAsFileTime" => None, "GetSystemTimePreciseAsFileTime" => None,
_ => throw_unsup_format!("unsupported Windows dlsym: {}", name), _ => throw_unsup_format!("unsupported Windows dlsym: {}", name),
}) })
@ -40,46 +25,15 @@ fn call_dlsym(
&mut self, &mut self,
dlsym: Dlsym, dlsym: Dlsym,
abi: Abi, abi: Abi,
args: &[OpTy<'tcx, Tag>], _args: &[OpTy<'tcx, Tag>],
ret: Option<(PlaceTy<'tcx, Tag>, mir::BasicBlock)>, ret: Option<(PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
) -> InterpResult<'tcx> { ) -> InterpResult<'tcx> {
let this = self.eval_context_mut(); let this = self.eval_context_mut();
let (dest, ret) = ret.expect("we don't support any diverging dlsym"); let (_dest, _ret) = ret.expect("we don't support any diverging dlsym");
assert!(this.tcx.sess.target.os == "windows"); assert!(this.tcx.sess.target.os == "windows");
check_abi(abi, Abi::System)?; check_abi(abi, Abi::System)?;
match dlsym { match dlsym {}
Dlsym::AcquireSRWLockExclusive => {
let &[ptr] = check_arg_count(args)?;
this.AcquireSRWLockExclusive(ptr)?;
}
Dlsym::ReleaseSRWLockExclusive => {
let &[ptr] = check_arg_count(args)?;
this.ReleaseSRWLockExclusive(ptr)?;
}
Dlsym::TryAcquireSRWLockExclusive => {
let &[ptr] = check_arg_count(args)?;
let ret = this.TryAcquireSRWLockExclusive(ptr)?;
this.write_scalar(Scalar::from_u8(ret), dest)?;
}
Dlsym::AcquireSRWLockShared => {
let &[ptr] = check_arg_count(args)?;
this.AcquireSRWLockShared(ptr)?;
}
Dlsym::ReleaseSRWLockShared => {
let &[ptr] = check_arg_count(args)?;
this.ReleaseSRWLockShared(ptr)?;
}
Dlsym::TryAcquireSRWLockShared => {
let &[ptr] = check_arg_count(args)?;
let ret = this.TryAcquireSRWLockShared(ptr)?;
this.write_scalar(Scalar::from_u8(ret), dest)?;
}
}
trace!("{:?}", this.dump_place(*dest));
this.go_to_block(ret);
Ok(())
} }
} }

View File

@ -300,12 +300,6 @@ fn emulate_foreign_item_by_name(
// Just fake a HANDLE // Just fake a HANDLE
this.write_scalar(Scalar::from_machine_isize(1, this), dest)?; this.write_scalar(Scalar::from_machine_isize(1, this), dest)?;
} }
"GetModuleHandleW" if this.frame().instance.to_string().starts_with("std::sys::windows::") => {
#[allow(non_snake_case)]
let &[_lpModuleName] = check_arg_count(args)?;
// Pretend this does not exist / nothing happened, by returning zero.
this.write_null(dest)?;
}
"SetConsoleTextAttribute" if this.frame().instance.to_string().starts_with("std::sys::windows::") => { "SetConsoleTextAttribute" if this.frame().instance.to_string().starts_with("std::sys::windows::") => {
#[allow(non_snake_case)] #[allow(non_snake_case)]
let &[_hConsoleOutput, _wAttribute] = check_arg_count(args)?; let &[_hConsoleOutput, _wAttribute] = check_arg_count(args)?;