aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/os.zig17
-rw-r--r--std/std.zig12
2 files changed, 17 insertions, 12 deletions
diff --git a/std/os.zig b/std/os.zig
new file mode 100644
index 0000000000..b82ab0c048
--- /dev/null
+++ b/std/os.zig
@@ -0,0 +1,17 @@
+import "syscall.zig";
+import "errno.zig";
+
+pub error SigInterrupt;
+pub error Unexpected;
+
+pub fn os_get_random_bytes(buf: []u8) -> %void {
+ const amt_got = getrandom(buf.ptr, buf.len, 0);
+ if (amt_got < 0) {
+ return switch (-amt_got) {
+ EINVAL => unreachable{},
+ EFAULT => unreachable{},
+ EINTR => error.SigInterrupt,
+ else => error.Unexpected,
+ }
+ }
+}
diff --git a/std/std.zig b/std/std.zig
index d628692ae0..70753c0c82 100644
--- a/std/std.zig
+++ b/std/std.zig
@@ -160,18 +160,6 @@ pub struct InStream {
}
}
-pub fn os_get_random_bytes(buf: []u8) -> %void {
- const amt_got = getrandom(buf.ptr, buf.len, 0);
- if (amt_got < 0) {
- return switch (-amt_got) {
- EINVAL => unreachable{},
- EFAULT => unreachable{},
- EINTR => error.SigInterrupt,
- else => error.Unexpected,
- }
- }
-}
-
#attribute("cold")
pub fn abort() -> unreachable {
raise(SIGABRT);