-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move getentropy handling to a shared location for foreign item implem…
…entation
- Loading branch information
1 parent
7555cbb
commit a24506e
Showing
4 changed files
with
32 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ pub mod dlsym; | |
pub mod env; | ||
pub mod os_str; | ||
pub mod panic; | ||
pub mod rand; | ||
pub mod time; | ||
pub mod tls; | ||
|
||
|
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,19 @@ | ||
use crate::*; | ||
|
||
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {} | ||
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { | ||
fn getentropy( | ||
&mut self, | ||
buffer_op: &OpTy<'tcx, Provenance>, | ||
length_op: &OpTy<'tcx, Provenance>, | ||
) -> InterpResult<'tcx, Scalar<Provenance>> { | ||
let this = self.eval_context_mut(); | ||
this.assert_target_os("macos", "getentropy"); | ||
|
||
let ptr = this.read_pointer(buffer_op)?; | ||
let len = this.read_target_usize(length_op)?; | ||
this.gen_random(ptr, len)?; | ||
|
||
Ok(Scalar::from_i32(0)) // KERN_SUCCESS | ||
} | ||
} |
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