Skip to content

Commit 99b3635

Browse files
committed
Add getrandom to FreeBSD
Introduced in FreeBSD 12.0. Manual page: https://www.freebsd.org/cgi/man.cgi?query=getrandom.
1 parent c9fb51b commit 99b3635

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,7 @@ fn test_freebsd(target: &str) {
17061706
"sys/msg.h",
17071707
"sys/procdesc.h",
17081708
"sys/ptrace.h",
1709+
"sys/random.h",
17091710
"sys/resource.h",
17101711
"sys/rtprio.h",
17111712
"sys/shm.h",

src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,16 @@ pub const F_SEAL_SHRINK: ::c_int = 0x0002;
197197
pub const F_SEAL_GROW: ::c_int = 0x0004;
198198
pub const F_SEAL_WRITE: ::c_int = 0x0008;
199199

200+
pub const GRND_NONBLOCK: ::c_uint = 0x1;
201+
pub const GRND_RANDOM: ::c_uint = 0x2;
202+
200203
cfg_if! {
201204
if #[cfg(not(freebsd13))] {
202205
pub const ELAST: ::c_int = 96;
203206
} else {
204207
pub const EINTEGRITY: ::c_int = 97;
205208
pub const ELAST: ::c_int = 97;
209+
pub const GRND_INSECURE: ::c_uint = 0x4;
206210
}
207211
}
208212

@@ -229,6 +233,12 @@ extern "C" {
229233
) -> ::c_int;
230234

231235
pub fn fdatasync(fd: ::c_int) -> ::c_int;
236+
237+
pub fn getrandom(
238+
buf: *mut ::c_void,
239+
buflen: ::size_t,
240+
flags: ::c_uint
241+
) -> ::ssize_t;
232242
}
233243

234244
cfg_if! {

0 commit comments

Comments
 (0)