-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #1461 - RalfJung:rwlock-win, r=oli-obk
Implement rwlocks on Windows Fixes #1059
- Loading branch information
Showing
45 changed files
with
522 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use rustc_middle::mir; | ||
|
||
use crate::*; | ||
use shims::posix::linux::dlsym as linux; | ||
use shims::posix::macos::dlsym as macos; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub enum Dlsym { | ||
Linux(linux::Dlsym), | ||
MacOs(macos::Dlsym), | ||
} | ||
|
||
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, target_os: &str) -> InterpResult<'static, Option<Dlsym>> { | ||
Ok(match target_os { | ||
"linux" => linux::Dlsym::from_str(name)?.map(Dlsym::Linux), | ||
"macos" => macos::Dlsym::from_str(name)?.map(Dlsym::MacOs), | ||
_ => unreachable!(), | ||
}) | ||
} | ||
} | ||
|
||
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {} | ||
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> { | ||
fn call_dlsym( | ||
&mut self, | ||
dlsym: Dlsym, | ||
args: &[OpTy<'tcx, Tag>], | ||
ret: Option<(PlaceTy<'tcx, Tag>, mir::BasicBlock)>, | ||
) -> InterpResult<'tcx> { | ||
let this = self.eval_context_mut(); | ||
match dlsym { | ||
Dlsym::Linux(dlsym) => linux::EvalContextExt::call_dlsym(this, dlsym, args, ret), | ||
Dlsym::MacOs(dlsym) => macos::EvalContextExt::call_dlsym(this, dlsym, args, ret), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use rustc_middle::mir; | ||
|
||
use crate::*; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub enum Dlsym { | ||
} | ||
|
||
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 { | ||
"__pthread_get_minstack" => None, | ||
_ => throw_unsup_format!("unsupported Linux dlsym: {}", name), | ||
}) | ||
} | ||
} | ||
|
||
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {} | ||
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> { | ||
fn call_dlsym( | ||
&mut self, | ||
dlsym: Dlsym, | ||
_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"); | ||
assert!(this.tcx.sess.target.target.target_os == "linux"); | ||
|
||
match dlsym {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod foreign_items; | ||
pub mod dlsym; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use rustc_middle::mir; | ||
|
||
use crate::*; | ||
use helpers::check_arg_count; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
#[allow(non_camel_case_types)] | ||
pub enum Dlsym { | ||
getentropy, | ||
} | ||
|
||
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 { | ||
"getentropy" => Some(Dlsym::getentropy), | ||
_ => throw_unsup_format!("unsupported macOS dlsym: {}", name), | ||
}) | ||
} | ||
} | ||
|
||
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {} | ||
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> { | ||
fn call_dlsym( | ||
&mut self, | ||
dlsym: Dlsym, | ||
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"); | ||
assert!(this.tcx.sess.target.target.target_os == "macos"); | ||
|
||
match dlsym { | ||
Dlsym::getentropy => { | ||
let &[ptr, len] = check_arg_count(args)?; | ||
let ptr = this.read_scalar(ptr)?.not_undef()?; | ||
let len = this.read_scalar(len)?.to_machine_usize(this)?; | ||
this.gen_random(ptr, len)?; | ||
this.write_null(dest)?; | ||
} | ||
} | ||
|
||
this.dump_place(*dest); | ||
this.go_to_block(ret); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod foreign_items; | ||
pub mod dlsym; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod foreign_items; | ||
pub mod dlsym; | ||
|
||
mod fs; | ||
mod sync; | ||
|
Oops, something went wrong.