aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-04-17 23:42:18 +0200
committerjohannst <johannes.stoelp@gmail.com>2021-04-17 23:42:18 +0200
commitb3f93e87f773c0e9099f256c78c1485fd7ce1dce (patch)
tree164fa334e09d5e5dbcb3eec8594a8de1f49b2b73
parent1bcaa7aceefad99c7bda9cb7bf6fcc5b48b53a75 (diff)
downloaddynld-b3f93e87f773c0e9099f256c78c1485fd7ce1dce.tar.gz
dynld-b3f93e87f773c0e9099f256c78c1485fd7ce1dce.zip
io: make use of write syscall wrapper
-rw-r--r--lib/src/io.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/src/io.c b/lib/src/io.c
index b5e0dc5..5194042 100644
--- a/lib/src/io.c
+++ b/lib/src/io.c
@@ -1,10 +1,9 @@
// Copyright (c) 2020 Johannes Stoelp
-#include <io.h>
#include <fmt.h>
+#include <io.h>
#include <syscall.h>
-
-#include <asm/unistd.h>
+#include <syscalls.h>
// `pfmt` uses fixed-size buffer on the stack for formating the message
// (for simplicity and since we don't impl buffered I/O).
@@ -21,14 +20,14 @@ static int vdfmt(int fd, const char* fmt, va_list ap) {
int ret = vfmt(buf, sizeof(buf), fmt, ap);
if (ret > MAX_PRINTF_LEN - 1) {
- syscall3(__NR_write, fd, buf, MAX_PRINTF_LEN - 1);
+ write(fd, buf, MAX_PRINTF_LEN - 1);
static const char warn[] = "\npfmt: Message truncated, max length can be configured by defining MAX_PRINTF_LEN\n";
- syscall3(__NR_write, FD_STDERR, warn, sizeof(warn));
+ write(FD_STDERR, warn, sizeof(warn));
return MAX_PRINTF_LEN - 1;
}
- syscall3(__NR_write, fd, buf, ret);
+ write(fd, buf, ret);
return ret;
}