_getheap.c - scc - simple c99 compiler
(HTM) git clone git://git.simple-cc.org/scc
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
_getheap.c (433B)
---
1 #include <errno.h>
2 #include <stddef.h>
3
4 #include "../../syscall.h"
5
6 static char heap[16384];
7
8 /*
9 * TODO: Temporary solution until we implement mmap in Darwin
10 * because it does not support any form of brk().
11 */
12 void *
13 _getheap(void)
14 {
15 return heap;
16 }
17
18 int
19 _brk(void *addr)
20 {
21 static char *cur = heap;
22 char *p = addr;
23
24 if (p < heap || p > &heap[sizeof(heap) - 1]) {
25 errno = ENOMEM;
26 return -1;
27 }
28 cur = p;
29
30 return 0;
31 }