summaryrefslogtreecommitdiff
path: root/internal/c_wrap_linux.tnsl
diff options
context:
space:
mode:
authorKai Gunger <kgunger12@gmail.com>2026-11-15 04:23:39 -0500
committerKai Gunger <kgunger12@gmail.com>2026-11-15 04:23:39 -0500
commit3e09a6ae3aea3b90961e4216339368775ea7c842 (patch)
tree181277b38e19e04d24868e29ca58a9002e1ec284 /internal/c_wrap_linux.tnsl
parent11a6fb0fed699a4028bcd454c0f175ca01607a68 (diff)
cstring Map to void pointer
Diffstat (limited to 'internal/c_wrap_linux.tnsl')
-rw-r--r--internal/c_wrap_linux.tnsl23
1 files changed, 22 insertions, 1 deletions
diff --git a/internal/c_wrap_linux.tnsl b/internal/c_wrap_linux.tnsl
index 31bee1a..6c3f27e 100644
--- a/internal/c_wrap_linux.tnsl
+++ b/internal/c_wrap_linux.tnsl
@@ -1,5 +1,5 @@
# Must be included at the top of the file
-asm "extern malloc, realloc, free, printf, putchar, open, close, read, write, lseek, perror"
+asm "extern malloc, realloc, free, printf, putchar, open, close, read, write, lseek, perror, realpath"
~void NULL = 0
@@ -250,6 +250,27 @@ asm "extern malloc, realloc, free, printf, putchar, open, close, read, write, ls
return out
;/
+/; _realpath (~uint8 path) [~uint8]
+ ~uint8 out
+
+ asm "mov rax, rsp"
+ asm "xor rdx, rdx"
+ asm "mov rcx, 16"
+ asm "div rcx"
+ asm "sub rsp, rdx"
+ asm "sub rsp, 128"
+
+ # Call libc
+ asm "mov rdi, r10" # handle
+ asm "mov rsi, 0" # resolved_path
+ asm "mov rdx, 1" # one byte
+ asm "call realpath wrt ..plt"
+
+ asm "mov r11, rax"
+
+ return out
+;/
+
/; _perror (~void str)
asm "mov rax, rsp"