mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std: factor out the write syscall and make it public
This commit is contained in:
parent
e411467e1d
commit
630917b29b
1 changed files with 7 additions and 3 deletions
10
std/std.zig
10
std/std.zig
|
|
@ -13,11 +13,15 @@ fn syscall3(number: isize, arg1: isize, arg2: isize, arg3: isize) -> isize {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO constants for SYS_write and stdout_fileno
|
||||||
|
pub fn write(fd: isize, buf: *const u8, count: usize) -> isize {
|
||||||
|
let SYS_write : isize = 1;
|
||||||
|
return syscall3(SYS_write, fd, buf as isize, count as isize);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO error handling
|
// TODO error handling
|
||||||
// TODO handle buffering and flushing
|
// TODO handle buffering and flushing
|
||||||
// TODO constants for SYS_write and stdout_fileno
|
|
||||||
pub fn print_str(str : string) -> isize {
|
pub fn print_str(str : string) -> isize {
|
||||||
let SYS_write : isize = 1;
|
|
||||||
let stdout_fileno : isize = 1;
|
let stdout_fileno : isize = 1;
|
||||||
return syscall3(SYS_write, stdout_fileno, str.ptr as isize, str.len as isize);
|
return write(stdout_fileno, str.ptr, str.len);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue