Skip to content

Commit

Permalink
Rollup merge of rust-lang#51637 - abarth:new_prng, r=cramertj
Browse files Browse the repository at this point in the history
Update zx_cprng_draw_new on Fuchsia

Fuchsia is changing the semantics for zx_cprng_draw and
zx_cprng_draw_new is a temporary name for the new semantics.
  • Loading branch information
kennytm authored Jun 22, 2018
2 parents aa3a627 + 03a40b3 commit e920d21
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/libstd/sys/unix/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,14 @@ mod imp {
mod imp {
#[link(name = "zircon")]
extern {
fn zx_cprng_draw(buffer: *mut u8, len: usize, actual: *mut usize) -> i32;
fn zx_cprng_draw_new(buffer: *mut u8, len: usize) -> i32;
}

fn getrandom(buf: &mut [u8]) -> Result<usize, i32> {
unsafe {
let mut actual = 0;
let status = zx_cprng_draw(buf.as_mut_ptr(), buf.len(), &mut actual);
let status = zx_cprng_draw_new(buf.as_mut_ptr(), buf.len());
if status == 0 {
Ok(actual)
Ok(buf.len())
} else {
Err(status)
}
Expand Down

0 comments on commit e920d21

Please sign in to comment.