aboutsummaryrefslogtreecommitdiff
path: root/std/std.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2015-12-14 03:06:54 -0700
committerAndrew Kelley <superjoe30@gmail.com>2015-12-14 03:06:54 -0700
commit630917b29b00f8bc1a867921c3f0e34d798a0515 (patch)
treec80434c4ce704c69c539f3fed8d9715887cc0856 /std/std.zig
parente411467e1dd4557bb11698f2a5d979dfcbaea444 (diff)
downloadzig-630917b29b00f8bc1a867921c3f0e34d798a0515.tar.gz
zig-630917b29b00f8bc1a867921c3f0e34d798a0515.zip
std: factor out the write syscall and make it public
Diffstat (limited to 'std/std.zig')
-rw-r--r--std/std.zig10
1 files changed, 7 insertions, 3 deletions
diff --git a/std/std.zig b/std/std.zig
index 08036d73ee..fbf71f2fd8 100644
--- a/std/std.zig
+++ b/std/std.zig
@@ -13,11 +13,15 @@ fn syscall3(number: isize, arg1: isize, arg2: isize, arg3: isize) -> isize {
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 handle buffering and flushing
-// TODO constants for SYS_write and stdout_fileno
pub fn print_str(str : string) -> isize {
- let SYS_write : 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);
}