aboutsummaryrefslogtreecommitdiff
path: root/lib/src/syscalls.c
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-03-26 23:17:46 +0100
committerjohannst <johannes.stoelp@gmail.com>2021-03-26 23:17:46 +0100
commit1d2a6f21294f8390b683e4e097cb49210ed832d1 (patch)
tree19f6854c3e1fa6a82ec4ed4bb57b2d3dadf979b8 /lib/src/syscalls.c
parentcf97ecd5b52c2f7a8953fd1674742d46fd15418a (diff)
downloaddynld-1d2a6f21294f8390b683e4e097cb49210ed832d1.tar.gz
dynld-1d2a6f21294f8390b683e4e097cb49210ed832d1.zip
Added dyn allocator + syscall wrappers + minor fixes.
Diffstat (limited to 'lib/src/syscalls.c')
-rw-r--r--lib/src/syscalls.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/src/syscalls.c b/lib/src/syscalls.c
new file mode 100644
index 0000000..d6ac1a5
--- /dev/null
+++ b/lib/src/syscalls.c
@@ -0,0 +1,22 @@
+// Copyright (c) 2021 Johannes Stoelp
+
+#include <asm/unistd.h> // __NR_*
+#include <syscall.h>
+#include <syscalls.h>
+
+int open(const char* path, int flags) {
+ return syscall2(__NR_open, path, flags);
+}
+
+ssize_t read(int fd, void* buf, size_t count) {
+ return syscall3(__NR_read, fd, buf, count);
+}
+
+off_t lseek(int fd, off_t offset, int whence) {
+ return syscall3(__NR_lseek, fd, offset, whence);
+}
+
+void _exit(int status) {
+ syscall1(__NR_exit, status);
+ __builtin_unreachable();
+}