hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/sysroot/usr
diff options
context:
space:
mode:
Diffstat (limited to 'sysroot/usr')
-rw-r--r--sysroot/usr/include/sys/syscall.h15
-rw-r--r--sysroot/usr/include/unistd.h5
-rw-r--r--sysroot/usr/lib/libc/syscalls.c20
3 files changed, 38 insertions, 2 deletions
diff --git a/sysroot/usr/include/sys/syscall.h b/sysroot/usr/include/sys/syscall.h
index 4a23a53..eecd257 100644
--- a/sysroot/usr/include/sys/syscall.h
+++ b/sysroot/usr/include/sys/syscall.h
@@ -7,8 +7,19 @@
#define SYS_open 7
#define SYS_close 8
#define SYS_lseek 9
-#define SYS_brk 10
-#define SYS_sbrk 11
+#define SYS_brk 10
+#define SYS_sbrk 11
+#define SYS_fork 12
+#define SYS_exec 13
+#define SYS_wait 14
+#define SYS_getpid 15
+
+static inline long __syscall0(long number)
+{
+ long result;
+ __asm__ volatile("int $0x80" : "=a"(result) : "a"(number) : "memory");
+ return result;
+}
static inline long __syscall1(long number, long a1)
{
diff --git a/sysroot/usr/include/unistd.h b/sysroot/usr/include/unistd.h
index f5a67ab..65414d5 100644
--- a/sysroot/usr/include/unistd.h
+++ b/sysroot/usr/include/unistd.h
@@ -15,4 +15,9 @@ long lseek(int fd, long offset, int whence);
void* sbrk(long increment);
int brk(void* address);
+int fork(void);
+int exec(const char* path, const char* arg);
+int wait(int* status);
+int getpid(void);
+
#endif
diff --git a/sysroot/usr/lib/libc/syscalls.c b/sysroot/usr/lib/libc/syscalls.c
index ad959b9..33bbb12 100644
--- a/sysroot/usr/lib/libc/syscalls.c
+++ b/sysroot/usr/lib/libc/syscalls.c
@@ -36,3 +36,23 @@ int brk(void* address)
{
return (int)__syscall1(SYS_brk, (long)address);
}
+
+int fork(void)
+{
+ return (int)__syscall0(SYS_fork);
+}
+
+int exec(const char* path, const char* arg)
+{
+ return (int)__syscall2(SYS_exec, (long)path, (long)arg);
+}
+
+int wait(int* status)
+{
+ return (int)__syscall1(SYS_wait, (long)status);
+}
+
+int getpid(void)
+{
+ return (int)__syscall0(SYS_getpid);
+}