Improve random number generation on __Fuchsia__.
Thanks to Felix Wilhelm for suggesting this!
#if defined(__linux__) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
#include <sys/random.h>
#endif
+#if defined(__Fuchsia__) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
+#include <zircon/syscalls.h>
+#endif
#define uHZ 1000
@@ -141,6 +144,19 @@ read_random(void *buf, size_t size)
}
return;
}
+#elif defined(__Fuchsia__)
+void
+init_random(void)
+{
+ return;
+}
+
+void
+read_random(void *buf, size_t size)
+{
+ zx_cprng_draw(buf, size);
+ return;
+}
#else
void
init_random(void)
