summaryrefslogtreecommitdiff
path: root/service/lib
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2025-01-27 02:05:07 +0000
committerAda Christine <adachristine18@gmail.com>2025-01-27 02:05:07 +0000
commit0d2ddecc9aeb232746b76b4eebdb1381053a8951 (patch)
tree31fe2fc38ead88a0d982b06b3783aae4f094b8ad /service/lib
parent6faeb8d3aed797ddfac66ecc21fc8a717d5e848a (diff)
checkpoint. we can fake syscall with the dummy gdt
Diffstat (limited to 'service/lib')
-rw-r--r--service/lib/posix.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/service/lib/posix.c b/service/lib/posix.c
new file mode 100644
index 0000000..a912977
--- /dev/null
+++ b/service/lib/posix.c
@@ -0,0 +1,19 @@
+#include <unistd.h>
+
+ssize_t write(int fd, const void *buffer, size_t length)
+{
+ ssize_t result;
+
+ __asm__ (
+ "movq %0, %%rdi\n"
+ "movq %1, %%rsi\n"
+ "movq %2, %%rdx\n"
+ "movq $1, %%rax\n"
+ "syscall"
+ : "=a"(result)
+ : "g"(fd), "g"(buffer), "g"(length)
+ : "rdi", "rsi","rdx");
+
+ return result;
+}
+