hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/sysroot/usr/lib/libc/syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysroot/usr/lib/libc/syscalls.c')
-rw-r--r--sysroot/usr/lib/libc/syscalls.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/sysroot/usr/lib/libc/syscalls.c b/sysroot/usr/lib/libc/syscalls.c
new file mode 100644
index 0000000..ad959b9
--- /dev/null
+++ b/sysroot/usr/lib/libc/syscalls.c
@@ -0,0 +1,38 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/syscall.h>
+
+long read(int fd, void* buffer, size_t length)
+{
+ return __syscall3(SYS_read, fd, (long)buffer, (long)length);
+}
+
+long write(int fd, const void* buffer, size_t length)
+{
+ return __syscall3(SYS_write, fd, (long)buffer, (long)length);
+}
+
+int open(const char* path, int flags)
+{
+ return (int)__syscall2(SYS_open, (long)path, flags);
+}
+
+int close(int fd)
+{
+ return (int)__syscall1(SYS_close, fd);
+}
+
+long lseek(int fd, long offset, int whence)
+{
+ return __syscall3(SYS_lseek, fd, offset, whence);
+}
+
+void* sbrk(long increment)
+{
+ return (void*)__syscall1(SYS_sbrk, increment);
+}
+
+int brk(void* address)
+{
+ return (int)__syscall1(SYS_brk, (long)address);
+}