shithub: scc

ref: 7d06d1d348ce9fb9dc585d81f146e12193be85e4
dir: /src/libc/arch/darwin/_getheap.c/

View raw version
#include <errno.h>
#include <stddef.h>

#include "../../syscall.h"

static char heap[16384];

/*
 * TODO: Temporary solution until we implement mmap in Darwin
 *       because it does not support any form of brk().
 */
void *
_getheap(void)
{
	return heap;
}

int
_brk(void *addr)
{
	static char *cur = heap;
	char *p = addr;

	if (p < heap || p > &heap[sizeof(heap) - 1]) {
		errno = ENOMEM;
		return -1;
	}
	cur = p;

	return 0;
}