diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-10-23 22:26:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-23 22:26:29 +0200 |
| commit | d287861309bb9a4e7529d6032c2b67347e0ee6e8 (patch) | |
| tree | ef64a69f3e4338f990b7d502cc7827e57097e41c | |
| parent | 1322f9263410116cc565129bb517a35227c28479 (diff) | |
| parent | 4b73cf3446b3b5aea7996de7cddbe5ebb46b7ca0 (diff) | |
| download | rust-d287861309bb9a4e7529d6032c2b67347e0ee6e8.tar.gz rust-d287861309bb9a4e7529d6032c2b67347e0ee6e8.zip | |
Rollup merge of #107159 - devnexen:random_fbsd_update, r=workingjubilee
rand use getrandom for freebsd (available since 12.x)
| -rw-r--r-- | library/std/src/sys/unix/rand.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/library/std/src/sys/unix/rand.rs b/library/std/src/sys/unix/rand.rs index fbf158f56fc..bdf725fbe5a 100644 --- a/library/std/src/sys/unix/rand.rs +++ b/library/std/src/sys/unix/rand.rs @@ -62,18 +62,15 @@ mod imp { unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), libc::GRND_NONBLOCK) } } - #[cfg(any(target_os = "espidf", target_os = "horizon"))] + #[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "freebsd"))] fn getrandom(buf: &mut [u8]) -> libc::ssize_t { - unsafe { libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) } - } - - #[cfg(target_os = "freebsd")] - fn getrandom(buf: &mut [u8]) -> libc::ssize_t { - // FIXME: using the above when libary std's libc is updated + #[cfg(not(target_os = "freebsd"))] + use libc::getrandom; + #[cfg(target_os = "freebsd")] extern "C" { fn getrandom( - buffer: *mut libc::c_void, - length: libc::size_t, + buf: *mut libc::c_void, + buflen: libc::size_t, flags: libc::c_uint, ) -> libc::ssize_t; } @@ -236,6 +233,7 @@ mod imp { } } +// FIXME: once the 10.x release becomes the minimum, this can be dropped for simplification. #[cfg(target_os = "netbsd")] mod imp { use crate::ptr; |
