From 0857c9696f6c5efda0ff08aed8dcd47f03472d2c Mon Sep 17 00:00:00 2001 From: Tobias Kortkamp Date: Sun, 2 Sep 2018 15:54:07 +0200 Subject: [PATCH] Use arc4random_buf(3) on FreeBSD too Signed-off-by: Tobias Kortkamp --- manual/Module (chicken random) | 2 +- runtime.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manual/Module (chicken random) b/manual/Module (chicken random) index 24f83028..e28a6369 100644 --- a/manual/Module (chicken random) +++ b/manual/Module (chicken random) @@ -8,7 +8,7 @@ system) and a pseudo random number generator. On UNIX systems entropy is by default obtained from {{/dev/urandom}}. On Linux, the {{getrandom(2)}} system call is used instead, if available. -On OpenBSD it is {{arc4random_buf(3)}}, on Windows {{RtlGenRandom}}. +On OpenBSD and FreeBSD it is {{arc4random_buf(3)}}, on Windows {{RtlGenRandom}}. The pseudo random number generator is an implementation of the [[WELL512|https://en.wikipedia.org/wiki/Well_equidistributed_long-period_linear]] algorithm. diff --git a/runtime.c b/runtime.c index 518fb7cb..bd0ee918 100644 --- a/runtime.c +++ b/runtime.c @@ -12577,7 +12577,7 @@ C_word C_random_bytes(C_word buf, C_word size) int r = 0; int off = 0; -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) || defined(__FreeBSD__) arc4random_buf(C_data_pointer(buf), count); #elif defined(SYS_getrandom) && defined(__NR_getrandom) static int use_urandom = 0; -- 2.18.0