2010-12-03 05:34:57 +01:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "runtime.h"
|
2011-10-27 01:57:58 +02:00
|
|
|
#include "arch.h"
|
2010-12-03 05:34:57 +01:00
|
|
|
#include "malloc.h"
|
|
|
|
|
|
|
|
void*
|
|
|
|
runtime_SysAlloc(uintptr n)
|
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
|
|
|
|
mstats.sys += n;
|
|
|
|
errno = posix_memalign(&p, PageSize, n);
|
|
|
|
if (errno > 0) {
|
|
|
|
perror("posix_memalign");
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime_SysUnused(void *v, uintptr n)
|
|
|
|
{
|
|
|
|
USED(v);
|
|
|
|
USED(n);
|
|
|
|
// TODO(rsc): call madvise MADV_DONTNEED
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime_SysFree(void *v, uintptr n)
|
|
|
|
{
|
|
|
|
mstats.sys -= n;
|
|
|
|
free(v);
|
|
|
|
}
|
|
|
|
|
2011-03-17 00:05:44 +01:00
|
|
|
void*
|
|
|
|
runtime_SysReserve(void *v, uintptr n)
|
|
|
|
{
|
2011-12-13 22:59:26 +01:00
|
|
|
USED(v);
|
2011-03-17 00:05:44 +01:00
|
|
|
return runtime_SysAlloc(n);
|
|
|
|
}
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
void
|
2011-03-17 00:05:44 +01:00
|
|
|
runtime_SysMap(void *v, uintptr n)
|
2010-12-03 05:34:57 +01:00
|
|
|
{
|
2011-12-13 22:59:26 +01:00
|
|
|
USED(v);
|
|
|
|
USED(n);
|
2010-12-03 05:34:57 +01:00
|
|
|
}
|