Skip to content

Commit 1455ae4

Browse files
committed
std::rand: fix dragonflybsd after #121942.
1 parent 4a0cc88 commit 1455ae4

File tree

1 file changed

+9
-7
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+9
-7
lines changed

library/std/src/sys/pal/unix/rand.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,19 @@ mod imp {
6262
unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), libc::GRND_NONBLOCK) }
6363
}
6464

65-
#[cfg(any(
66-
target_os = "espidf",
67-
target_os = "horizon",
68-
target_os = "freebsd",
69-
target_os = "dragonfly",
70-
netbsd10
71-
))]
65+
#[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "freebsd", netbsd10))]
7266
fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
7367
unsafe { libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) }
7468
}
7569

70+
#[cfg(target_os = "dragonfly")]
71+
fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
72+
extern "C" {
73+
fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> c_int;
74+
}
75+
unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) }
76+
}
77+
7678
#[cfg(not(any(
7779
target_os = "linux",
7880
target_os = "android",

0 commit comments

Comments
 (0)