From 3e09a6ae3aea3b90961e4216339368775ea7c842 Mon Sep 17 00:00:00 2001 From: Kai Gunger Date: Sun, 15 Nov 2026 04:23:39 -0500 Subject: cstring Map to void pointer --- internal/c_wrap_linux.tnsl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'internal/c_wrap_linux.tnsl') 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" -- cgit v1.3.1