@@ -109,6 +109,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
109109 this. write_scalar ( result, dest) ?;
110110 }
111111
112+ // Random generation related shims
113+ "getentropy" => {
114+ let [ buf, bufsize] =
115+ this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
116+ let result = this. getentropy ( buf, bufsize) ?;
117+ this. write_scalar ( result, dest) ?;
118+ }
119+
112120 // Access to command-line arguments
113121 "_NSGetArgc" => {
114122 let [ ] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
@@ -198,4 +206,19 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
198206
199207 Ok ( EmulateByNameResult :: NeedsJumping )
200208 }
209+
210+ fn getentropy (
211+ & mut self ,
212+ buffer_op : & OpTy < ' tcx , Provenance > ,
213+ length_op : & OpTy < ' tcx , Provenance > ,
214+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
215+ let this = self . eval_context_mut ( ) ;
216+ this. assert_target_os ( "macos" , "getentropy" ) ;
217+
218+ let ptr = this. read_pointer ( buffer_op) ?;
219+ let len = this. read_target_usize ( length_op) ?;
220+ this. gen_random ( ptr, len) ?;
221+
222+ Ok ( Scalar :: from_i32 ( 0 ) ) // KERN_SUCCESS
223+ }
201224}
0 commit comments