summaryrefslogtreecommitdiff
path: root/src/init/syscalls.c
blob: 01dda519b8eb07220205d4eb5dd7f67bc7d7b797 (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
// this file could probably just get generated by a script
#include <shared/syscalls.h>

int _syscall(int, int, int, int);

_Noreturn void _syscall_exit(const char *msg, size_t len) {
	_syscall(_SYSCALL_EXIT, (int)msg, len, 0);
	__builtin_unreachable();
}

int _syscall_fork(void) {
	return _syscall(_SYSCALL_FORK, 0, 0, 0);
}

int _syscall_await(char *buf, int len) {
	return _syscall(_SYSCALL_AWAIT, (int)buf, (int)len, 0);
}

fd_t _syscall_fs_open(const char *path, int len) {
	return _syscall(_SYSCALL_FS_OPEN, (int)path, len, 0);
}

int _syscall_mount(const char *path, int len, fd_t fd) {
	return _syscall(_SYSCALL_MOUNT, (int)path, len, fd);
}

int _syscall_fd_read(fd_t fd, char *buf, int len) {
	return _syscall(_SYSCALL_FD_READ, fd, (int)buf, len);
}

int _syscall_fd_write(fd_t fd, char *buf, int len) {
	return _syscall(_SYSCALL_FD_WRITE, fd, (int)buf, len);
}

int _syscall_fd_close(fd_t fd) {
	return _syscall(_SYSCALL_FD_CLOSE, fd, 0, 0);
}