Skip to content

Commit

Permalink
std::rand: fix dragonflybsd after rust-lang#121942.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Mar 12, 2024
1 parent 4a0cc88 commit 3a81e1d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion library/std/src/sys/pal/unix/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ mod imp {
target_os = "espidf",
target_os = "horizon",
target_os = "freebsd",
target_os = "dragonfly",
netbsd10
))]
fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
unsafe { libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) }
}

#[cfg(target_os = "dragonfly")]
fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
extern "C" {
fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> c_int;
}
unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) }
}

#[cfg(not(any(
target_os = "linux",
target_os = "android",
Expand Down

0 comments on commit 3a81e1d

Please sign in to comment.