diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-05-02 14:16:59 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-05-02 14:16:59 -0400 |
| commit | 7998e2b0f41bff86d8fbbb8112dd6c629d47e849 (patch) | |
| tree | 9f7bca5991f9fcdb291da10e2c830a749769dfad /src/os.cpp | |
| parent | 5656f5090d8646e076db50da03cfc6ae686eb76b (diff) | |
| parent | 8ebcca6734e07aea29098ca4c63c0216b3099d0e (diff) | |
| download | zig-7998e2b0f41bff86d8fbbb8112dd6c629d47e849.tar.gz zig-7998e2b0f41bff86d8fbbb8112dd6c629d47e849.zip | |
Merge remote-tracking branch 'origin/master' into FireFox317-windows-evented-io
Diffstat (limited to 'src/os.cpp')
| -rw-r--r-- | src/os.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/os.cpp b/src/os.cpp index 16d6847d4e..26ed0dc4e1 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -1462,6 +1462,14 @@ static void init_rand() { unsigned seed; memcpy(&seed, ptr_random, sizeof(seed)); srand(seed); +#elif defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) + unsigned seed; + size_t len = sizeof(seed); + int mib[2] = { CTL_KERN, KERN_ARND }; + if (sysctl(mib, 2, &seed, &len, NULL, 0) != 0) { + zig_panic("unable to query random data from sysctl"); + } + srand(seed); #else int fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC); if (fd == -1) { |
