summaryrefslogtreecommitdiff
path: root/LibC/unistd.cpp
blob: 81570ece7061ad3aab3bcc0d1cf9ab73610b3e6c (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
#include "unistd.h"
#include "string.h"
#include <Kernel/Syscall.h>

extern "C" {

uid_t getuid()
{
    return Syscall::invoke(Syscall::PosixGetuid);
}

uid_t getgid()
{
    return Syscall::invoke(Syscall::PosixGetgid);
}

uid_t getpid()
{
    return Syscall::invoke(Syscall::PosixGetpid);
}

int open(const char* path)
{
    size_t length = strlen(path);
    return Syscall::invoke(Syscall::PosixOpen, (dword)path, (dword)length);
}

ssize_t read(int fd, void* buf, size_t count)
{
    return Syscall::invoke(Syscall::PosixRead, (dword)fd, (dword)buf, (dword)count);
}

int close(int fd)
{
    return Syscall::invoke(Syscall::PosixClose, fd);
}

pid_t waitpid(pid_t waitee)
{
    return Syscall::invoke(Syscall::PosixWaitpid, waitee);
}

}