summaryrefslogtreecommitdiff
path: root/src/user/lib/stdlib.c
blob: 38e87ad1cea0654127049dee1832c89aa4722c1e (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
45
46
#include <camellia/flags.h>
#include <camellia/syscalls.h>
#include <errno.h>
#include <string.h>
#include <user/lib/panic.h>

_Noreturn void abort(void) {
	_syscall_exit(1);
}

int mkstemp(char *template) {
	// TODO randomize template
	handle_t h = _syscall_open(template, strlen(template), OPEN_CREATE);
	if (h < 0) {
		errno = -h;
		return -1;
	}
	// TODO truncate
	return h;
}

// TODO process env
char *getenv(const char *name) {
	(void)name;
	return NULL;
}

// TODO system()
int system(const char *cmd) {
	(void)cmd;
	errno = ENOSYS;
	return -1;
}

int abs(int i) {
	return i < 0 ? -i : i;
}

int atoi(const char *s) {
	return strtol(s, NULL, 10);
}

double atof(const char *s) {
	(void)s;
	__libc_panic("unimplemented");
}