diff options
| author | joboet <jonasboettiger@icloud.com> | 2024-08-15 13:28:02 +0200 |
|---|---|---|
| committer | joboet <jonasboettiger@icloud.com> | 2024-09-23 10:29:51 +0200 |
| commit | 5c1c72572479afe98734d5f78fa862abe662c41a (patch) | |
| tree | 4f43788d776b0b1dfc423ef8d9852ece3960f9b3 /library/std/src/sys/random/fuchsia.rs | |
| parent | 702987f75b74f789ba227ee04a3d7bb1680c2309 (diff) | |
| download | rust-5c1c72572479afe98734d5f78fa862abe662c41a.tar.gz rust-5c1c72572479afe98734d5f78fa862abe662c41a.zip | |
std: implement the `random` feature
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
Diffstat (limited to 'library/std/src/sys/random/fuchsia.rs')
| -rw-r--r-- | library/std/src/sys/random/fuchsia.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/std/src/sys/random/fuchsia.rs b/library/std/src/sys/random/fuchsia.rs new file mode 100644 index 00000000000..77d72b3c5b7 --- /dev/null +++ b/library/std/src/sys/random/fuchsia.rs @@ -0,0 +1,13 @@ +//! Random data generation using the Zircon kernel. +//! +//! Fuchsia, as always, is quite nice and provides exactly the API we need: +//! <https://fuchsia.dev/reference/syscalls/cprng_draw>. + +#[link(name = "zircon")] +extern "C" { + fn zx_cprng_draw(buffer: *mut u8, len: usize); +} + +pub fn fill_bytes(bytes: &mut [u8]) { + unsafe { zx_cprng_draw(bytes.as_mut_ptr(), bytes.len()) } +} |
