Skip to content

Commit 8958df1

Browse files
committed
Auto merge of #3071 - devnexen:netbsd10_update_random, r=JohnTitor
netbsd 10 adding getentropy/getrandom.
2 parents 36d0272 + b5f7e1b commit 8958df1

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

libc-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,7 @@ fn test_netbsd(target: &str) {
11591159
"MS_NOUSER" => true,
11601160
"MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13
11611161
"BOTHER" => true,
1162+
"GRND_RANDOM" | "GRND_INSECURE" | "GRND_NONBLOCK" => true, // netbsd 10 minimum
11621163

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

11721175
"getrlimit" | "getrlimit64" | // non-int in 1st arg
11731176
"setrlimit" | "setrlimit64" | // non-int in 1st arg

libc-test/semver/netbsd.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ GLOB_NOMATCH
396396
GLOB_NOSORT
397397
GLOB_NOSPACE
398398
GLOB_NOSYS
399+
GRND_INSECURE
400+
GRND_NONBLOCK
401+
GRND_RANDOM
399402
HW_NCPU
400403
IFF_ALLMULTI
401404
IFF_BROADCAST
@@ -1238,6 +1241,7 @@ getdiskrawname
12381241
getdistcookedname
12391242
getdomainname
12401243
getdtablesize
1244+
getentropy
12411245
getfsspecname
12421246
getgrent
12431247
getgrent_r
@@ -1260,6 +1264,7 @@ getprogname
12601264
getpwent
12611265
getpwent_r
12621266
getpwnam_r
1267+
getrandom
12631268
getrlimit
12641269
getrusage
12651270
getservbyport

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ extern "C" {
746746

747747
pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
748748
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
749+
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
749750
}
750751

751752
cfg_if! {

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,6 +2321,11 @@ pub const XATTR_REPLACE: ::c_int = 0x02;
23212321
// sys/extattr.h
23222322
pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0;
23232323

2324+
// For getrandom()
2325+
pub const GRND_NONBLOCK: ::c_uint = 0x1;
2326+
pub const GRND_RANDOM: ::c_uint = 0x2;
2327+
pub const GRND_INSECURE: ::c_uint = 0x4;
2328+
23242329
const_fn! {
23252330
{const} fn _ALIGN(p: usize) -> usize {
23262331
(p + _ALIGNBYTES) & !_ALIGNBYTES
@@ -2870,6 +2875,7 @@ extern "C" {
28702875
fd: ::c_int,
28712876
newfd: ::c_int,
28722877
) -> ::c_int;
2878+
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
28732879
}
28742880

28752881
#[link(name = "util")]

src/unix/bsd/netbsdlike/openbsd/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,6 @@ extern "C" {
18221822
newp: *mut ::c_void,
18231823
newlen: ::size_t,
18241824
) -> ::c_int;
1825-
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
18261825
pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
18271826
pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
18281827
pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: caddr_t, data: ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)