Skip to content

Commit

Permalink
Auto merge of #3071 - devnexen:netbsd10_update_random, r=JohnTitor
Browse files Browse the repository at this point in the history
netbsd 10 adding getentropy/getrandom.
  • Loading branch information
bors committed Jan 18, 2023
2 parents 36d0272 + b5f7e1b commit 8958df1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ fn test_netbsd(target: &str) {
"MS_NOUSER" => true,
"MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13
"BOTHER" => true,
"GRND_RANDOM" | "GRND_INSECURE" | "GRND_NONBLOCK" => true, // netbsd 10 minimum

_ => false,
}
Expand All @@ -1168,6 +1169,8 @@ fn test_netbsd(target: &str) {
match name {
// FIXME: https://github.com/rust-lang/libc/issues/1272
"execv" | "execve" | "execvp" => true,
// FIXME: netbsd 10 minimum
"getentropy" | "getrandom" => true,

"getrlimit" | "getrlimit64" | // non-int in 1st arg
"setrlimit" | "setrlimit64" | // non-int in 1st arg
Expand Down
5 changes: 5 additions & 0 deletions libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ GLOB_NOMATCH
GLOB_NOSORT
GLOB_NOSPACE
GLOB_NOSYS
GRND_INSECURE
GRND_NONBLOCK
GRND_RANDOM
HW_NCPU
IFF_ALLMULTI
IFF_BROADCAST
Expand Down Expand Up @@ -1238,6 +1241,7 @@ getdiskrawname
getdistcookedname
getdomainname
getdtablesize
getentropy
getfsspecname
getgrent
getgrent_r
Expand All @@ -1260,6 +1264,7 @@ getprogname
getpwent
getpwent_r
getpwnam_r
getrandom
getrlimit
getrusage
getservbyport
Expand Down
1 change: 1 addition & 0 deletions src/unix/bsd/netbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ extern "C" {

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
}

cfg_if! {
Expand Down
6 changes: 6 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,11 @@ pub const XATTR_REPLACE: ::c_int = 0x02;
// sys/extattr.h
pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0;

// For getrandom()
pub const GRND_NONBLOCK: ::c_uint = 0x1;
pub const GRND_RANDOM: ::c_uint = 0x2;
pub const GRND_INSECURE: ::c_uint = 0x4;

const_fn! {
{const} fn _ALIGN(p: usize) -> usize {
(p + _ALIGNBYTES) & !_ALIGNBYTES
Expand Down Expand Up @@ -2870,6 +2875,7 @@ extern "C" {
fd: ::c_int,
newfd: ::c_int,
) -> ::c_int;
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
}

#[link(name = "util")]
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,6 @@ extern "C" {
newp: *mut ::c_void,
newlen: ::size_t,
) -> ::c_int;
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: caddr_t, data: ::c_int) -> ::c_int;
Expand Down

0 comments on commit 8958df1

Please sign in to comment.