diff options
| author | Yawning Angel <yawning@schwanenlied.me> | 2024-04-21 21:16:50 +0900 |
|---|---|---|
| committer | Yawning Angel <yawning@schwanenlied.me> | 2024-04-23 11:47:43 +0900 |
| commit | e2fa9be7e2c02ad950e4f3205f5e67c9ebd3a70c (patch) | |
| tree | fd5df47d5968012bb4aaaeba57f3cce5f79085fb /core/math/rand/system_linux.odin | |
| parent | a6eb64df6cd136639d1234e5a157ad280a1a32a8 (diff) | |
core/math/rand: Use `core:crypto` for the system RNG
This removes some code duplication and expands support for the system
RNG to all targets that `core:crypto` supports.
Diffstat (limited to 'core/math/rand/system_linux.odin')
| -rw-r--r-- | core/math/rand/system_linux.odin | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/core/math/rand/system_linux.odin b/core/math/rand/system_linux.odin deleted file mode 100644 index 42c9f86fa..000000000 --- a/core/math/rand/system_linux.odin +++ /dev/null @@ -1,29 +0,0 @@ -package rand - -import "core:sys/linux" - -@(require_results) -_system_random :: proc() -> u64 { - for { - value: u64 - value_buf := (cast([^]u8)&value)[:size_of(u64)] - _, errno := linux.getrandom(value_buf, {}) - #partial switch errno { - case .NONE: - // Do nothing - case .EINTR: - // Call interupted by a signal handler, just retry the request. - continue - case .ENOSYS: - // The kernel is apparently prehistoric (< 3.17 circa 2014) - // and does not support getrandom. - panic("getrandom not available in kernel") - case: - // All other failures are things that should NEVER happen - // unless the kernel interface changes (ie: the Linux - // developers break userland). - panic("getrandom failed") - } - return value - } -}
\ No newline at end of file |