commit 01fda6199ee0e2b5f79e58cbd862bd4882615a4b (tree)
parent 1d3c25e92880c6b845300bcd40666fac85c7cd71
Author: Andrew Kelley <superjoe30@gmail.com>
Date: Sat, 13 Feb 2016 22:59:49 -0700
dummy implementation of os_get_random_bytes for windows
Diffstat:
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/std/os.zig b/std/os.zig
@@ -5,13 +5,24 @@ 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,
- }
+ switch (@compile_var("os")) {
+ linux => {
+ 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,
+ }
+ }
+ },
+ windows => {
+ // TODO
+ for (buf) |_, i| {
+ buf[i] = 4;
+ }
+ },
+ else => unreachable{},
}
}