aboutsummaryrefslogtreecommitdiff
path: root/sys/src/internal.h
diff options
context:
space:
mode:
authorNicholas <nbnoll@eml.cc>2021-11-15 15:10:35 -0800
committerNicholas <nbnoll@eml.cc>2021-11-15 15:10:35 -0800
commit0b8cebc1f074626f3c3e43a26152a3034ada7153 (patch)
tree8eb1cae101b089680830ad89606ee618357f9bd6 /sys/src/internal.h
parente9ff1c6fbbbac9ece2604876ab589ac282360446 (diff)
Feat: prototype of self-hosted library
This is very much a work in progress. Still ruminating on the structure of the library. It feels right but I want a more "social" presence - namely the ability to link to a libc seemlessly. The solution is most likely weak aliasing that musl uses - but musl itself weak aliases global symbols, e.g malloc. We would have to define weak internal symbols that musl defines as strong links but this knows too much about the internals of musl...
Diffstat (limited to 'sys/src/internal.h')
-rw-r--r--sys/src/internal.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/src/internal.h b/sys/src/internal.h
new file mode 100644
index 0000000..2bb1422
--- /dev/null
+++ b/sys/src/internal.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <u.h>
+#include <internal/syscall.h>
+
+#define syscall1(n,a1) _syscall1(n,sysarg(a1))
+#define syscall2(n,a1,a2) _syscall2(n,sysarg(a1),sysarg(a2))
+#define syscall3(n,a1,a2,a3) _syscall3(n,sysarg(a1),sysarg(a2),sysarg(a3))
+#define syscall4(n,a1,a2,a3,a4) _syscall4(n,sysarg(a1),sysarg(a2),sysarg(a3),sysarg(a4))
+#define syscall5(n,a1,a2,a3,a4,a5) _syscall5(n,sysarg(a1),sysarg(a2),sysarg(a3),sysarg(a4),sysarg(a5))
+#define syscall6(n,a1,a2,a3,a4,a5,a6) _syscall6(n,sysarg(a1),sysarg(a2),sysarg(a3),sysarg(a4),sysarg(a5),sysarg(a6))
+#define syscall7(n,a1,a2,a3,a4,a5,a6,a7) _syscall7(n,sysarg(a1),sysarg(a2),sysarg(a3),sysarg(a4),sysarg(a5),sysarg(a6),sysarg(a7))
+
+#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
+#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)
+#define __SYSCALL_CONCAT_X(a,b) a##b
+#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b)
+#define __SYSCALL_DISP(b,...) __SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
+
+#define syscall(...) __SYSCALL_DISP(syscall,__VA_ARGS__)
+