scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 1/*
 2 * TODO: This is a temporary solution until we implement brk()
 3 * in Qute. This has been copied from arch/darwin/_getheap.c.
 4 */
 5
 6#include <errno.h>
 7#include <stddef.h>
 8
 9#include "../../syscall.h"
10
11static char heap[4096];
12
13void *
14_getheap(void)
15{
16	return heap;
17}
18
19int
20_brk(void *addr)
21{
22	static char *cur = heap;
23	char *p = addr;
24
25	if (p < heap || p > &heap[sizeof(heap) - 1]) {
26		errno = ENOMEM;
27		return -1;
28	}
29	cur = p;
30
31	return 0;
32}