Skip to content

Commit

Permalink
Rollup merge of #122356 - devnexen:dfbsd_build_fix, r=jhpratt
Browse files Browse the repository at this point in the history
std::rand: fix dragonflybsd after #121942.
  • Loading branch information
jhpratt committed Apr 4, 2024
2 parents 4fd4797 + 6a16638 commit 875d254
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions library/std/src/sys/pal/unix/rand.rs
Expand Up @@ -62,17 +62,23 @@ 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 libc::c_void,
buflen: libc::size_t,
flags: libc::c_uint,
) -> libc::ssize_t;
}
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 875d254

Please sign in to comment.