hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/sysroot/usr/lib/libc/syscalls.c
blob: ad959b960b38630f251036daf55c61f9814d89a5 (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
#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);
}