Skip to content

Commit

Permalink
BSD add deterministic rand api
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Feb 14, 2022
1 parent e2e056b commit 0a01589
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libc-test/semver/dragonfly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,8 @@ difftime
dirfd
dl_iterate_phdr
dl_phdr_info
drand48
erand48
duplocale
endgrent
endpwent
Expand Down Expand Up @@ -1307,6 +1309,7 @@ if_nameindex
ifaddrs
in6_pktinfo
initgroups
jrand48
kevent
killpg
kinfo_cputime
Expand All @@ -1315,9 +1318,11 @@ kqueue
labs
lastlog
lchflags
lcong48
lio_listio
lockf
login_tty
lrand48
lutimes
lwp_rtprio
lwpid_t
Expand All @@ -1343,12 +1348,14 @@ mq_timedreceive
mq_timedsend
mq_unlink
mqd_t
mrand48
msghdr
newlocale
nice
nl_item
nl_langinfo
nl_langinfo_l
nrand48
ntp_adjtime
ntp_gettime
ntptimeval
Expand Down Expand Up @@ -1428,6 +1435,7 @@ sched_param
sched_rr_get_interval
sched_setparam
sched_setscheduler
seed48
seekdir
sem
sem_close
Expand Down Expand Up @@ -1469,6 +1477,7 @@ sigwait
sigwaitinfo
sockaddr_dl
srand
srand48
stack_t
statfs
strcasecmp
Expand Down
9 changes: 9 additions & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1462,12 +1462,14 @@ difftime
dirfd
dl_iterate_phdr
dl_phdr_info
drand48
dup3
duplocale
endgrent
endpwent
endservent
endutxent
erand48
explicit_bzero
extattr_delete_fd
extattr_delete_file
Expand Down Expand Up @@ -1568,6 +1570,7 @@ jail_attach
jail_get
jail_remove
jail_set
jrand48
kevent
key_t
killpg
Expand All @@ -1579,9 +1582,11 @@ kld_isloaded
kld_load
labs
lchflags
lcong48
lio_listio
lockf
login_tty
lrand48
lutimes
lwpid_t
madvise
Expand Down Expand Up @@ -1613,6 +1618,7 @@ mq_timedreceive
mq_timedsend
mq_unlink
mqd_t
mrand48
msgctl
msgget
msghdr
Expand All @@ -1628,6 +1634,7 @@ nl_item
nl_langinfo
nl_langinfo_l
nmount
nrand48
ntp_adjtime
ntp_gettime
ntptimeval
Expand Down Expand Up @@ -1760,6 +1767,7 @@ sched_rr_get_interval
sched_setparam
sched_setscheduler
sdallocx
seed48
seekdir
sem_close
sem_destroy
Expand Down Expand Up @@ -1809,6 +1817,7 @@ sigwaitinfo
sockaddr_dl
sockcred
srand
srand48
stack_t
statfs
strcasecmp
Expand Down
9 changes: 9 additions & 0 deletions libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1139,11 +1139,13 @@ dirfd
dl_iterate_phdr
dl_phdr_info
dqblk
drand48
dup3
duplocale
easprintf
efopen
emalloc
erand48
erealloc
ereallocarr
esetfunc
Expand Down Expand Up @@ -1247,6 +1249,7 @@ in_pktinfo
initgroups
ipc_perm
itimerspec
jrand48
kevent
key_t
killpg
Expand All @@ -1258,6 +1261,7 @@ labs
lastlog
lastlogx
lchflags
lcong48
lgetxattr
lio_listio
listxattr
Expand All @@ -1271,6 +1275,7 @@ logoutx
logwtmp
logwtmpx
login_tty
lrand48
lremovexattr
lsetxattr
lutimes
Expand Down Expand Up @@ -1299,11 +1304,13 @@ mq_timedreceive
mq_timedsend
mq_unlink
mqd_t
mrand48
msghdr
newlocale
nice
nl_item
nl_langinfo
nrand48
ntp_adjtime
ntp_gettime
ntptimeval
Expand Down Expand Up @@ -1394,6 +1401,7 @@ sched_rr_get_interval
sched_setparam
sched_setscheduler
secure_path
seed48
seekdir
sem
sem_close
Expand Down Expand Up @@ -1438,6 +1446,7 @@ snprintb_m
sockaddr_dl
sockcred
srand
srand48
stack_t
strcasecmp
strcasestr
Expand Down
12 changes: 12 additions & 0 deletions libc-test/semver/openbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -937,11 +937,13 @@ difftime
dirfd
dl_iterate_phdr
dl_phdr_info
drand48
dup3
duplocale
endgrent
endpwent
endservent
erand48
execvpe
explicit_bzero
export_args
Expand Down Expand Up @@ -1002,15 +1004,19 @@ initgroups
ip_mreqn
ipc_perm
iso_args
jrand48
kevent
key_t
killpg
kinfo_vmentry
kqueue
labs
lastlog
lcong48
lcong48_deterministic
lockf
login_tty
lrand48
madvise
malloc_conceal
memmem
Expand All @@ -1024,13 +1030,15 @@ mkostemp
mkostemps
mkstemps
mount_info
mrand48
msdosfs_args
msghdr
newlocale
nfs_args
nice
nl_item
nl_langinfo
nrand48
ntfs_args
open_memstream
open_wmemstream
Expand Down Expand Up @@ -1084,6 +1092,8 @@ regmatch_t
regoff_t
sched_get_priority_max
sched_get_priority_min
seed48
seed48_deterministic
seekdir
sem
sem_close
Expand Down Expand Up @@ -1121,6 +1131,8 @@ sockaddr_dl
sockpeercred
splice
srand
srand48
srand48_deterministic
stack_t
statfs
strcasecmp
Expand Down
10 changes: 10 additions & 0 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,16 @@ extern "C" {
pub fn arc4random() -> u32;
pub fn arc4random_buf(buf: *mut ::c_void, size: ::size_t);
pub fn arc4random_uniform(l: u32) -> u32;

pub fn drand48() -> ::c_double;
pub fn erand48(xseed: *mut ::c_ushort) -> ::c_double;
pub fn lrand48() -> ::c_long;
pub fn nrand48(xseed: *mut ::c_ushort) -> ::c_long;
pub fn mrand48() -> ::c_long;
pub fn jrand48(xseed: *mut ::c_ushort) -> ::c_long;
pub fn srand48(seed: ::c_long);
pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
pub fn lcong48(p: *mut ::c_ushort);
}

cfg_if! {
Expand Down
4 changes: 4 additions & 0 deletions src/unix/bsd/netbsdlike/openbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,10 @@ extern "C" {
pub fn freezero(ptr: *mut ::c_void, size: ::size_t);
pub fn malloc_conceal(size: ::size_t) -> *mut ::c_void;
pub fn calloc_conceal(nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;

pub fn srand48_deterministic(seed: ::c_long);
pub fn seed48_deterministic(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
pub fn lcong48_deterministic(p: *mut ::c_ushort);
}

#[link(name = "execinfo")]
Expand Down

0 comments on commit 0a01589

Please sign in to comment.