X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/69598fec083b67c8567293c7b8a397b64175bd45..2e969e5e75fb8f544ff468584fb4e33d891e2954:/lcorernd.pas?ds=sidebyside diff --git a/lcorernd.pas b/lcorernd.pas index b7a3bf2..aa3d253 100644 --- a/lcorernd.pas +++ b/lcorernd.pas @@ -285,6 +285,13 @@ begin end; +{$ifdef bsd} +function arc4random: cardinal; cdecl; external 'c' name 'arc4random'; +procedure arc4random_buf(buf: Pointer; nbytes: SizeUInt); cdecl; external 'c' name 'arc4random_buf'; +function arc4random_uniform(upper_bound: cardinal): cardinal; cdecl; external 'c' name 'arc4random_uniform'; +{$endif} + + {$ifdef linux} {$ifdef i386} const sys_getrandom = 355; @@ -317,6 +324,11 @@ begin a := do_syscall(sys_getrandom,tsysparam(@l.devrnd),sizeof(l.devrnd),0); {$endif} + {$ifdef bsd} + a := sizeof(l.devrnd); + arc4random_buf(@l.devrnd, a); + {$endif} + if (a < sizeof(l.devrnd)) then begin {if syscall misses or fails, fall back to /dev/urandom} assignfile(f,'/dev/urandom');