diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-02 20:13:10 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-02 20:13:10 -0700 |
| commit | 258bc73eee557ada944c9d25ed85d9baf8035ad7 (patch) | |
| tree | d34d6cca4d4f91a6938ff27fb5eb55c9b7ce1915 /std/std.zig | |
| parent | 187d00ca835d2c923cbc0a3ab9e861e82888d403 (diff) | |
| download | zig-258bc73eee557ada944c9d25ed85d9baf8035ad7.tar.gz zig-258bc73eee557ada944c9d25ed85d9baf8035ad7.zip | |
fix implicit cast after unreachable bad code gen
Diffstat (limited to 'std/std.zig')
| -rw-r--r-- | std/std.zig | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/std/std.zig b/std/std.zig index f486ceaadf..50bdbe9222 100644 --- a/std/std.zig +++ b/std/std.zig @@ -19,8 +19,8 @@ fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) -> usize { : "rcx", "r11") } -pub fn getrandom(buf: &u8, count: usize, flags: u32) -> isize { - return syscall3(SYS_getrandom, buf as usize, count, flags as usize) as isize; +pub fn getrandom(buf: &u8, count: usize, flags: u32) -> i32 { + return syscall3(SYS_getrandom, buf as usize, count, flags as usize) as i32; } pub fn write(fd: isize, buf: &const u8, count: usize) -> isize { @@ -32,6 +32,30 @@ pub fn exit(status: i32) -> unreachable { unreachable; } +// TODO error handling +pub fn os_get_random_bytes(buf: &u8, count: usize) -> i32 { + return getrandom(buf, count, 0); +} + +// TODO error handling +// TODO handle buffering and flushing (mutex protected) +pub fn print_str(str: string) -> isize { fprint_str(stdout_fileno, str) } + +// TODO error handling +// TODO handle buffering and flushing (mutex protected) +pub fn fprint_str(fd: isize, str: string) -> isize { + return write(fd, str.ptr, str.len); +} + +// TODO handle buffering and flushing (mutex protected) +// TODO error handling +pub fn print_u64(x: u64) -> isize { + // TODO use max_u64_base10_digits instead of hardcoding 20 + var buf: [u8; 20]; + const len = buf_print_u64(buf.ptr, x); + return write(stdout_fileno, buf.ptr, len); +} + fn digit_to_char(digit: u64) -> u8 { '0' + (digit as u8) } const max_u64_base10_digits: usize = 20; @@ -63,26 +87,3 @@ fn buf_print_u64(out_buf: &u8, x: u64) -> usize { return len; } -// TODO error handling -// TODO handle buffering and flushing (mutex protected) -pub fn print_str(str: string) -> isize { fprint_str(stdout_fileno, str) } - -// TODO error handling -// TODO handle buffering and flushing (mutex protected) -pub fn fprint_str(fd: isize, str: string) -> isize { - return write(fd, str.ptr, str.len); -} - -// TODO handle buffering and flushing (mutex protected) -// TODO error handling -pub fn print_u64(x: u64) -> isize { - // TODO use max_u64_base10_digits instead of hardcoding 20 - var buf: [u8; 20]; - const len = buf_print_u64(buf.ptr, x); - return write(stdout_fileno, buf.ptr, len); -} - -// TODO error handling -pub fn os_get_random_bytes(buf: &u8, count: usize) -> isize { - return getrandom(buf, count, 0); -} |
