diff options
| author | ivmarkov <ivan.markov@gmail.com> | 2021-07-29 20:18:22 +0300 |
|---|---|---|
| committer | ivmarkov <imarkov@vmware.com> | 2021-08-10 12:09:00 +0300 |
| commit | 459eaa6baea4127b37769d0b7944fa00c175e770 (patch) | |
| tree | 100c65b39f217096a01f3c0f256a672bfeaacd42 /library/std/src/sys/unix/rand.rs | |
| parent | ae90dcf0207c57c3034f00b07048d63f8b2363c8 (diff) | |
| download | rust-459eaa6baea4127b37769d0b7944fa00c175e770.tar.gz rust-459eaa6baea4127b37769d0b7944fa00c175e770.zip | |
STD support for the ESP-IDF framework
Diffstat (limited to 'library/std/src/sys/unix/rand.rs')
| -rw-r--r-- | library/std/src/sys/unix/rand.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/rand.rs b/library/std/src/sys/unix/rand.rs index 32895001a65..7a3f6b0d95a 100644 --- a/library/std/src/sys/unix/rand.rs +++ b/library/std/src/sys/unix/rand.rs @@ -44,12 +44,17 @@ mod imp { unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), libc::GRND_NONBLOCK) } } - #[cfg(not(any(target_os = "linux", target_os = "android")))] + #[cfg(target_os = "espidf")] + fn getrandom(buf: &mut [u8]) -> libc::ssize_t { + unsafe { libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) } + } + + #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "espidf")))] fn getrandom_fill_bytes(_buf: &mut [u8]) -> bool { false } - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(any(target_os = "linux", target_os = "android", target_os = "espidf"))] fn getrandom_fill_bytes(v: &mut [u8]) -> bool { use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sys::os::errno; |
