diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-02-13 22:59:49 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-02-13 22:59:49 -0700 |
| commit | 01fda6199ee0e2b5f79e58cbd862bd4882615a4b (patch) | |
| tree | 7dbe999836deee3a5fb5e8b135e96e2968536642 /std/os.zig | |
| parent | 1d3c25e92880c6b845300bcd40666fac85c7cd71 (diff) | |
| download | zig-01fda6199ee0e2b5f79e58cbd862bd4882615a4b.tar.gz zig-01fda6199ee0e2b5f79e58cbd862bd4882615a4b.zip | |
dummy implementation of os_get_random_bytes for windows
Diffstat (limited to 'std/os.zig')
| -rw-r--r-- | std/os.zig | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/std/os.zig b/std/os.zig index b82ab0c048..75cc163f21 100644 --- 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{}, } } |
