Skip to content

Commit

Permalink
std::rand: fix dragonflybsd after #121942.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Mar 12, 2024
1 parent 4a0cc88 commit 1455ae4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions library/std/src/sys/pal/unix/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ mod imp {
unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), libc::GRND_NONBLOCK) }
}

#[cfg(any(
target_os = "espidf",
target_os = "horizon",
target_os = "freebsd",
target_os = "dragonfly",
netbsd10
))]
#[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "freebsd", 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 1455ae4

Please sign in to comment.