aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/inc/sys.h9
-rw-r--r--libc/sys.c15
2 files changed, 21 insertions, 3 deletions
diff --git a/libc/inc/sys.h b/libc/inc/sys.h
index d95b760..0914bc4 100644
--- a/libc/inc/sys.h
+++ b/libc/inc/sys.h
@@ -14,6 +14,7 @@ int sys2(enum sys num, int d1, int d2);
int sys3(enum sys num, int d1, int d2, int d3);
int sys4(enum sys num, int d1, int d2, int d3, int d4);
int sys5(enum sys num, int d1, int d2, int d3, int d4, int d5);
+int sysv(enum sys num, ...);
/**
* Wrappers
@@ -22,10 +23,12 @@ int sys5(enum sys num, int d1, int d2, int d3, int d4, int d5);
#define loop() sys0(SYS_LOOP)
#define read(path) (void *)sys1(SYS_READ, (int)path)
#define write(path, buf) sys2(SYS_WRITE, (int)path, buf)
-#define exec(path) sys1(SYS_EXEC, (int)path)
+#define exec(path, ...) sysv(SYS_EXEC, (int)path, ##__VA_ARGS__)
#define exit() \
- sys0(SYS_EXIT); \
- while (1) { \
+ { \
+ sys0(SYS_EXIT); \
+ while (1) { \
+ } \
}
#endif
diff --git a/libc/sys.c b/libc/sys.c
index d676445..a2c789e 100644
--- a/libc/sys.c
+++ b/libc/sys.c
@@ -1,6 +1,7 @@
// MIT License, Copyright (c) 2020 Marvin Borner
// Syscall implementation
+#include <arg.h>
#include <sys.h>
/**
@@ -55,3 +56,17 @@ int sys5(enum sys num, int d1, int d2, int d3, int d4, int d5)
"D"((int)d5));
return a;
}
+
+#include <print.h>
+int sysv(enum sys num, ...)
+{
+ va_list ap;
+ int args[5];
+
+ va_start(ap, num);
+ for (int i = 0; i < 5; i++)
+ args[i] = va_arg(ap, int);
+ va_end(ap);
+
+ return sys5(num, args[0], args[1], args[2], args[3], args[4]);
+}