Skip to content

Commit

Permalink
Auto merge of #1698 - RalfJung:rustup, r=RalfJung
Browse files Browse the repository at this point in the history
rustup; remove some no-longer-needed Windows shims

libstd now calls these lock functions directly, and `GetModuleHandleW` isn't use either any more since rust-lang/rust#81478.
  • Loading branch information
bors committed Jan 31, 2021
2 parents 8d24b02 + 052cd3b commit 39a7bd0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 57 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9b3242982202707be2485b1e4cf5f3b34466a38d
0e63af5da3400ace48a0345117980473fd21ad73
2 changes: 2 additions & 0 deletions src/shims/posix/dlsym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
ret: Option<(PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();

check_abi(abi, Abi::C)?;

match dlsym {
Dlsym::Linux(dlsym) => linux::EvalContextExt::call_dlsym(this, dlsym, args, ret),
Dlsym::MacOs(dlsym) => macos::EvalContextExt::call_dlsym(this, dlsym, args, ret),
Expand Down
54 changes: 4 additions & 50 deletions src/shims/windows/dlsym.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
use rustc_middle::mir;
use rustc_target::spec::abi::Abi;

use log::trace;

use crate::*;
use helpers::{check_abi, check_arg_count};
use shims::windows::sync::EvalContextExt as _;
use helpers::check_abi;

#[derive(Debug, Copy, Clone)]
pub enum Dlsym {
AcquireSRWLockExclusive,
ReleaseSRWLockExclusive,
TryAcquireSRWLockExclusive,
AcquireSRWLockShared,
ReleaseSRWLockShared,
TryAcquireSRWLockShared,
}

impl Dlsym {
// Returns an error for unsupported symbols, and None if this symbol
// should become a NULL pointer (pretend it does not exist).
pub fn from_str(name: &str) -> InterpResult<'static, Option<Dlsym>> {
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,
_ => throw_unsup_format!("unsupported Windows dlsym: {}", name),
})
Expand All @@ -40,46 +25,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
&mut self,
dlsym: Dlsym,
abi: Abi,
args: &[OpTy<'tcx, Tag>],
_args: &[OpTy<'tcx, Tag>],
ret: Option<(PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
) -> InterpResult<'tcx> {
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");

check_abi(abi, Abi::System)?;

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(())
match dlsym {}
}
}
6 changes: 0 additions & 6 deletions src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// Just fake a HANDLE
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::") => {
#[allow(non_snake_case)]
let &[_hConsoleOutput, _wAttribute] = check_arg_count(args)?;
Expand Down

0 comments on commit 39a7bd0

Please sign in to comment.