summaryrefslogtreecommitdiff
path: root/src/user/lib/stdlib.c
blob: 0795d3db6f67d61a59ad4a4b2fa101800921a258 (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, (void*)argv, NULL);
	fclose(file);
	errno = EINVAL;
	return -1;
}