Skip to content

Commit 31657a5

Browse files
committed
Auto merge of #2686 - devnexen:bsd_nonsec_random_api, r=Amanieu
BSD add deterministic rand api
2 parents b3c9c69 + 0a01589 commit 31657a5

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

libc-test/semver/dragonfly.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,8 @@ difftime
12371237
dirfd
12381238
dl_iterate_phdr
12391239
dl_phdr_info
1240+
drand48
1241+
erand48
12401242
duplocale
12411243
endgrent
12421244
endpwent
@@ -1307,6 +1309,7 @@ if_nameindex
13071309
ifaddrs
13081310
in6_pktinfo
13091311
initgroups
1312+
jrand48
13101313
kevent
13111314
killpg
13121315
kinfo_cputime
@@ -1315,9 +1318,11 @@ kqueue
13151318
labs
13161319
lastlog
13171320
lchflags
1321+
lcong48
13181322
lio_listio
13191323
lockf
13201324
login_tty
1325+
lrand48
13211326
lutimes
13221327
lwp_rtprio
13231328
lwpid_t
@@ -1343,12 +1348,14 @@ mq_timedreceive
13431348
mq_timedsend
13441349
mq_unlink
13451350
mqd_t
1351+
mrand48
13461352
msghdr
13471353
newlocale
13481354
nice
13491355
nl_item
13501356
nl_langinfo
13511357
nl_langinfo_l
1358+
nrand48
13521359
ntp_adjtime
13531360
ntp_gettime
13541361
ntptimeval
@@ -1428,6 +1435,7 @@ sched_param
14281435
sched_rr_get_interval
14291436
sched_setparam
14301437
sched_setscheduler
1438+
seed48
14311439
seekdir
14321440
sem
14331441
sem_close
@@ -1469,6 +1477,7 @@ sigwait
14691477
sigwaitinfo
14701478
sockaddr_dl
14711479
srand
1480+
srand48
14721481
stack_t
14731482
statfs
14741483
strcasecmp

libc-test/semver/freebsd.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,12 +1462,14 @@ difftime
14621462
dirfd
14631463
dl_iterate_phdr
14641464
dl_phdr_info
1465+
drand48
14651466
dup3
14661467
duplocale
14671468
endgrent
14681469
endpwent
14691470
endservent
14701471
endutxent
1472+
erand48
14711473
explicit_bzero
14721474
extattr_delete_fd
14731475
extattr_delete_file
@@ -1568,6 +1570,7 @@ jail_attach
15681570
jail_get
15691571
jail_remove
15701572
jail_set
1573+
jrand48
15711574
kevent
15721575
key_t
15731576
killpg
@@ -1579,9 +1582,11 @@ kld_isloaded
15791582
kld_load
15801583
labs
15811584
lchflags
1585+
lcong48
15821586
lio_listio
15831587
lockf
15841588
login_tty
1589+
lrand48
15851590
lutimes
15861591
lwpid_t
15871592
madvise
@@ -1613,6 +1618,7 @@ mq_timedreceive
16131618
mq_timedsend
16141619
mq_unlink
16151620
mqd_t
1621+
mrand48
16161622
msgctl
16171623
msgget
16181624
msghdr
@@ -1628,6 +1634,7 @@ nl_item
16281634
nl_langinfo
16291635
nl_langinfo_l
16301636
nmount
1637+
nrand48
16311638
ntp_adjtime
16321639
ntp_gettime
16331640
ntptimeval
@@ -1760,6 +1767,7 @@ sched_rr_get_interval
17601767
sched_setparam
17611768
sched_setscheduler
17621769
sdallocx
1770+
seed48
17631771
seekdir
17641772
sem_close
17651773
sem_destroy
@@ -1809,6 +1817,7 @@ sigwaitinfo
18091817
sockaddr_dl
18101818
sockcred
18111819
srand
1820+
srand48
18121821
stack_t
18131822
statfs
18141823
strcasecmp

libc-test/semver/netbsd.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,11 +1139,13 @@ dirfd
11391139
dl_iterate_phdr
11401140
dl_phdr_info
11411141
dqblk
1142+
drand48
11421143
dup3
11431144
duplocale
11441145
easprintf
11451146
efopen
11461147
emalloc
1148+
erand48
11471149
erealloc
11481150
ereallocarr
11491151
esetfunc
@@ -1247,6 +1249,7 @@ in_pktinfo
12471249
initgroups
12481250
ipc_perm
12491251
itimerspec
1252+
jrand48
12501253
kevent
12511254
key_t
12521255
killpg
@@ -1258,6 +1261,7 @@ labs
12581261
lastlog
12591262
lastlogx
12601263
lchflags
1264+
lcong48
12611265
lgetxattr
12621266
lio_listio
12631267
listxattr
@@ -1271,6 +1275,7 @@ logoutx
12711275
logwtmp
12721276
logwtmpx
12731277
login_tty
1278+
lrand48
12741279
lremovexattr
12751280
lsetxattr
12761281
lutimes
@@ -1299,11 +1304,13 @@ mq_timedreceive
12991304
mq_timedsend
13001305
mq_unlink
13011306
mqd_t
1307+
mrand48
13021308
msghdr
13031309
newlocale
13041310
nice
13051311
nl_item
13061312
nl_langinfo
1313+
nrand48
13071314
ntp_adjtime
13081315
ntp_gettime
13091316
ntptimeval
@@ -1394,6 +1401,7 @@ sched_rr_get_interval
13941401
sched_setparam
13951402
sched_setscheduler
13961403
secure_path
1404+
seed48
13971405
seekdir
13981406
sem
13991407
sem_close
@@ -1438,6 +1446,7 @@ snprintb_m
14381446
sockaddr_dl
14391447
sockcred
14401448
srand
1449+
srand48
14411450
stack_t
14421451
strcasecmp
14431452
strcasestr

libc-test/semver/openbsd.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,13 @@ difftime
937937
dirfd
938938
dl_iterate_phdr
939939
dl_phdr_info
940+
drand48
940941
dup3
941942
duplocale
942943
endgrent
943944
endpwent
944945
endservent
946+
erand48
945947
execvpe
946948
explicit_bzero
947949
export_args
@@ -1002,15 +1004,19 @@ initgroups
10021004
ip_mreqn
10031005
ipc_perm
10041006
iso_args
1007+
jrand48
10051008
kevent
10061009
key_t
10071010
killpg
10081011
kinfo_vmentry
10091012
kqueue
10101013
labs
10111014
lastlog
1015+
lcong48
1016+
lcong48_deterministic
10121017
lockf
10131018
login_tty
1019+
lrand48
10141020
madvise
10151021
malloc_conceal
10161022
memmem
@@ -1024,13 +1030,15 @@ mkostemp
10241030
mkostemps
10251031
mkstemps
10261032
mount_info
1033+
mrand48
10271034
msdosfs_args
10281035
msghdr
10291036
newlocale
10301037
nfs_args
10311038
nice
10321039
nl_item
10331040
nl_langinfo
1041+
nrand48
10341042
ntfs_args
10351043
open_memstream
10361044
open_wmemstream
@@ -1084,6 +1092,8 @@ regmatch_t
10841092
regoff_t
10851093
sched_get_priority_max
10861094
sched_get_priority_min
1095+
seed48
1096+
seed48_deterministic
10871097
seekdir
10881098
sem
10891099
sem_close
@@ -1121,6 +1131,8 @@ sockaddr_dl
11211131
sockpeercred
11221132
splice
11231133
srand
1134+
srand48
1135+
srand48_deterministic
11241136
stack_t
11251137
statfs
11261138
strcasecmp

src/unix/bsd/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,16 @@ extern "C" {
867867
pub fn arc4random() -> u32;
868868
pub fn arc4random_buf(buf: *mut ::c_void, size: ::size_t);
869869
pub fn arc4random_uniform(l: u32) -> u32;
870+
871+
pub fn drand48() -> ::c_double;
872+
pub fn erand48(xseed: *mut ::c_ushort) -> ::c_double;
873+
pub fn lrand48() -> ::c_long;
874+
pub fn nrand48(xseed: *mut ::c_ushort) -> ::c_long;
875+
pub fn mrand48() -> ::c_long;
876+
pub fn jrand48(xseed: *mut ::c_ushort) -> ::c_long;
877+
pub fn srand48(seed: ::c_long);
878+
pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
879+
pub fn lcong48(p: *mut ::c_ushort);
870880
}
871881

872882
cfg_if! {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,10 @@ extern "C" {
16331633
pub fn freezero(ptr: *mut ::c_void, size: ::size_t);
16341634
pub fn malloc_conceal(size: ::size_t) -> *mut ::c_void;
16351635
pub fn calloc_conceal(nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
1636+
1637+
pub fn srand48_deterministic(seed: ::c_long);
1638+
pub fn seed48_deterministic(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
1639+
pub fn lcong48_deterministic(p: *mut ::c_ushort);
16361640
}
16371641

16381642
#[link(name = "execinfo")]

0 commit comments

Comments
 (0)