diff options
author | bors <bors@rust-lang.org> | 2020-11-27 07:30:39 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2020-11-27 07:30:39 +0000 |
commit | 8e62c982741710861007ca711e3f2a0e0ea43908 (patch) | |
tree | e7076fc3b2853658377c12d23280d73f4e7e8809 | |
parent | e5b7d9ff28f63f8c6d52c23434ed4ca7a1b07367 (diff) | |
parent | 99b36350794dc5afaaadd1a536c4cc713c3819ae (diff) | |
download | rust-libc-8e62c982741710861007ca711e3f2a0e0ea43908.tar.gz |
Auto merge of #1982 - Thomasdezeeuw:freebsd-getrandom, r=JohnTitor
Add getrandom to FreeBSD
Introduced in FreeBSD 12.0.
Manual page: https://www.freebsd.org/cgi/man.cgi?query=getrandom.
Not sure if the constants should be `c_int`, just matching the `flags` argument in the function, in c they're macros.
-rwxr-xr-x | libc-test/build.rs | 1 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index 04b05000ef..433d0a86e4 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1711,6 +1711,7 @@ fn test_freebsd(target: &str) { "sys/msg.h", "sys/procdesc.h", "sys/ptrace.h", + "sys/random.h", "sys/resource.h", "sys/rtprio.h", "sys/shm.h", diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 94baa09059..89729a8162 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -197,12 +197,16 @@ pub const F_SEAL_SHRINK: ::c_int = 0x0002; pub const F_SEAL_GROW: ::c_int = 0x0004; pub const F_SEAL_WRITE: ::c_int = 0x0008; +pub const GRND_NONBLOCK: ::c_uint = 0x1; +pub const GRND_RANDOM: ::c_uint = 0x2; + cfg_if! { if #[cfg(not(freebsd13))] { pub const ELAST: ::c_int = 96; } else { pub const EINTEGRITY: ::c_int = 97; pub const ELAST: ::c_int = 97; + pub const GRND_INSECURE: ::c_uint = 0x4; } } @@ -229,6 +233,12 @@ extern "C" { ) -> ::c_int; pub fn fdatasync(fd: ::c_int) -> ::c_int; + + pub fn getrandom( + buf: *mut ::c_void, + buflen: ::size_t, + flags: ::c_uint + ) -> ::ssize_t; } cfg_if! { |