From 755a4bc081f7cdd8ffd9685cd5182b7a79f1071d Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 15 Sep 2024 14:53:52 +0300 Subject: [PATCH] crypto.rand: fix compilation on macos with `-cc tcc -no-retry-compilation -gc none` --- vlib/crypto/rand/rand_darwin.c.v | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vlib/crypto/rand/rand_darwin.c.v b/vlib/crypto/rand/rand_darwin.c.v index 1053753c657ddb..60158af3164225 100644 --- a/vlib/crypto/rand/rand_darwin.c.v +++ b/vlib/crypto/rand/rand_darwin.c.v @@ -4,16 +4,14 @@ module rand -#include +#include -#flag darwin -framework Security - -fn C.SecRandomCopyBytes(rnd C.SecRandomRef, count usize, bytes voidptr) int +fn C.getentropy(buf voidptr, buflen usize) int // read returns an array of `bytes_needed` random bytes read from the OS. pub fn read(bytes_needed int) ![]u8 { mut buffer := []u8{len: bytes_needed} - status := C.SecRandomCopyBytes(C.SecRandomRef(0), bytes_needed, buffer.data) + status := C.getentropy(buffer.data, bytes_needed) if status != 0 { return &ReadError{} }