summaryrefslogtreecommitdiff
path: root/src/user/lib/stdlib.c
blob: 179bd8f96f23de10580e0d13ddecd37b6e9df95a (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
#include <camellia/syscalls.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <user/lib/elfload.h>

int errno = 0;

int fork(void) {
	return _syscall_fork(0, NULL);
}

int close(handle_t h) {
	return _syscall_close(h);
}

_Noreturn void exit(int c) {
	_syscall_exit(c);
}

int execv(const char *path, char *const argv[]) {
	(void)argv;

	FILE *file = fopen(path, "r");
	if (!file)
		return -1;

	elf_execf(file);
	fclose(file);
	errno = EINVAL;
	return -1;
}