unsigned integers for sizes of things

Closes #62.
This commit is contained in:
Andrew Kelley
2016-07-26 20:40:11 -07:00
parent 76f87cdd96
commit bc81ddfea6
19 changed files with 264 additions and 394 deletions

View File

@@ -7,9 +7,10 @@ pub error Unexpected;
pub fn get_random_bytes(buf: []u8) -> %void {
switch (@compile_var("os")) {
linux => {
const amt_got = linux.getrandom(buf.ptr, buf.len, 0);
if (amt_got < 0) {
return switch (-amt_got) {
const ret = linux.getrandom(buf.ptr, buf.len, 0);
const err = linux.get_errno(ret);
if (err > 0) {
return switch (err) {
errno.EINVAL => unreachable{},
errno.EFAULT => unreachable{},
errno.EINTR => error.SigInterrupt,