aboutsummaryrefslogtreecommitdiff
path: root/core/math/rand/system_linux.odin
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2024-04-21 21:16:50 +0900
committerYawning Angel <yawning@schwanenlied.me>2024-04-23 11:47:43 +0900
commite2fa9be7e2c02ad950e4f3205f5e67c9ebd3a70c (patch)
treefd5df47d5968012bb4aaaeba57f3cce5f79085fb /core/math/rand/system_linux.odin
parenta6eb64df6cd136639d1234e5a157ad280a1a32a8 (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.odin29
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