aboutsummaryrefslogtreecommitdiff
path: root/src/unix/netbsd.c
diff options
context:
space:
mode:
authornia <nia@NetBSD.org>2019-10-21 20:33:48 +0100
committerSaúl Ibarra Corretgé <s@saghul.net>2019-10-29 13:36:05 +0100
commita62f8ced7af51d1c4fd8abceb521bd24f362ab14 (patch)
tree1a310442703c2f05a79dbb6c2094386d4f2adfae /src/unix/netbsd.c
parent2dcf2e8188f433fb668ffc586ffd485d0ff91059 (diff)
downloadlibuv-a62f8ced7af51d1c4fd8abceb521bd24f362ab14.tar.gz
libuv-a62f8ced7af51d1c4fd8abceb521bd24f362ab14.zip
netbsd: use KERN_ARND sysctl to get entropy
PR-URL: https://github.com/libuv/libuv/pull/2528 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Diffstat (limited to 'src/unix/netbsd.c')
-rw-r--r--src/unix/netbsd.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/unix/netbsd.c b/src/unix/netbsd.c
index cfe2c6a4..690bd79e 100644
--- a/src/unix/netbsd.c
+++ b/src/unix/netbsd.c
@@ -234,3 +234,26 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
uv__free(cp_times);
return 0;
}
+
+int uv__random_sysctl(void* buf, size_t len) {
+ static int name[] = {CTL_KERN, KERN_ARND};
+ size_t count, req;
+ unsigned char* p;
+
+ p = buf;
+ while (len) {
+ req = len < 32 ? len : 32;
+ count = req;
+
+ if (sysctl(name, ARRAY_SIZE(name), p, &count, NULL, 0) == -1)
+ return UV__ERR(errno);
+
+ if (count != req)
+ return UV_EIO; /* Can't happen. */
+
+ p += count;
+ len -= count;
+ }
+
+ return 0;
+}