aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-02-04 01:00:54 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-02-04 01:00:54 -0700
commitbb4a532785e8bcd0080eeac291bd3b205279f045 (patch)
treeb119dff287b80f7c184da87ac9ec09ae510895f0 /std
parent1f9734d1eefa98c4c51ee740717a6cc003a5a7ed (diff)
downloadzig-bb4a532785e8bcd0080eeac291bd3b205279f045.tar.gz
zig-bb4a532785e8bcd0080eeac291bd3b205279f045.zip
move os_get_random_bytes to os.zig
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);