authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-06-19 21:39:44-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-06-19 21:39:44-04:00
log221286433aa5825dcb177596dbf697d873c6f1cb
tree5965523c3081016ee5a4da928c7421893676abe6
parent62b23f5da5a29f54499f5339bc0f98c06e27af8f

don't call c.getrandom because older libcs don't have it

See #397

1 files changed, 3 insertions(+), 5 deletions(-)

std/os/index.zig+3-5
...@@ -59,11 +59,9 @@ pub fn getRandomBytes(buf: []u8) -> %void {...@@ -59,11 +59,9 @@ pub fn getRandomBytes(buf: []u8) -> %void {
59 while (true) {59 while (true) {
60 const err = switch (builtin.os) {60 const err = switch (builtin.os) {
61 Os.linux => {61 Os.linux => {
62 if (builtin.link_libc) {62 // TODO check libc version and potentially call c.getrandom.
63 if (c.getrandom(buf.ptr, buf.len, 0) == -1) *c._errno() else 063 // See #397
64 } else {64 posix.getErrno(posix.getrandom(buf.ptr, buf.len, 0))
65 posix.getErrno(posix.getrandom(buf.ptr, buf.len, 0))
66 }
67 },65 },
68 Os.darwin, Os.macosx, Os.ios => {66 Os.darwin, Os.macosx, Os.ios => {
69 if (builtin.link_libc) {67 if (builtin.link_libc) {