authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-02-13 22:59:49-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-02-13 22:59:49-07:00
log01fda6199ee0e2b5f79e58cbd862bd4882615a4b
tree7dbe999836deee3a5fb5e8b135e96e2968536642
parent1d3c25e92880c6b845300bcd40666fac85c7cd71

dummy implementation of os_get_random_bytes for windows


1 files changed, 19 insertions(+), 8 deletions(-)

std/os.zig+19-8
......@@ -5,13 +5,24 @@ pub error SigInterrupt;
55pub error Unexpected;
66
77pub fn os_get_random_bytes(buf: []u8) -> %void {
8 const amt_got = getrandom(buf.ptr, buf.len, 0);
9 if (amt_got < 0) {
10 return switch (-amt_got) {
11 EINVAL => unreachable{},
12 EFAULT => unreachable{},
13 EINTR => error.SigInterrupt,
14 else => error.Unexpected,
15 }
8 switch (@compile_var("os")) {
9 linux => {
10 const amt_got = getrandom(buf.ptr, buf.len, 0);
11 if (amt_got < 0) {
12 return switch (-amt_got) {
13 EINVAL => unreachable{},
14 EFAULT => unreachable{},
15 EINTR => error.SigInterrupt,
16 else => error.Unexpected,
17 }
18 }
19 },
20 windows => {
21 // TODO
22 for (buf) |_, i| {
23 buf[i] = 4;
24 }
25 },
26 else => unreachable{},
1627 }
1728}