hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/sysroot/usr/lib/libc/syscalls.c
blob: 33bbb12fb6b8930bf7619d4558951dfde8783e3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <unistd.h>
#include <fcntl.h>
#include <sys/syscall.h>

long read(int fd, void* buffer, size_t length)
{
    return __syscall3(SYS_read, fd, (long)buffer, (long)length);
}

long write(int fd, const void* buffer, size_t length)
{
    return __syscall3(SYS_write, fd, (long)buffer, (long)length);
}

int open(const char* path, int flags)
{
    return (int)__syscall2(SYS_open, (long)path, flags);
}

int close(int fd)
{
    return (int)__syscall1(SYS_close, fd);
}

long lseek(int fd, long offset, int whence)
{
    return __syscall3(SYS_lseek, fd, offset, whence);
}

void* sbrk(long increment)
{
    return (void*)__syscall1(SYS_sbrk, increment);
}

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);
}