~ chicken-core (chicken-5) 309e9afacad23433509901aad99b51b59ebdb5d9


commit 309e9afacad23433509901aad99b51b59ebdb5d9
Author:     Mario Domenech Goulart <mario@parenteses.org>
AuthorDate: Fri May 10 19:50:53 2019 +0200
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Sun May 12 11:36:46 2019 +1200

    Use arc4random on FreeBSD
    
    Patch by Tobias Kortkamp. Source:
    
    https://svnweb.freebsd.org/ports/head/lang/chicken5/files/patch-runtime.c?revision=478932&view=co
    
    This patch was pointed out by gahr in #chicken.
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/NEWS b/NEWS
index c37366f2..7b3a9790 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+5.0.3
+- Runtime system
+  - Use arc4random on FreeBSD (thanks to Tobias Kortkamp and gahr)
+
 5.0.2
 
 - Core libraries
diff --git a/runtime.c b/runtime.c
index 5638df55..55a7aa32 100644
--- a/runtime.c
+++ b/runtime.c
@@ -13286,7 +13286,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;
Trap