2012-03-27 23:13:14 +00:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "runtime.h"
|
|
|
|
#include "arch.h"
|
|
|
|
#include "malloc.h"
|
|
|
|
|
|
|
|
void*
|
|
|
|
runtime_SysAlloc(uintptr n)
|
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
mstats()->sys += n;
|
2012-03-27 23:13:14 +00:00
|
|
|
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)
|
|
|
|
{
|
2017-10-07 00:16:47 +00:00
|
|
|
mstats()->sys -= n;
|
2012-03-27 23:13:14 +00:00
|
|
|
free(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
|
|
|
runtime_SysReserve(void *v, uintptr n)
|
|
|
|
{
|
|
|
|
USED(v);
|
|
|
|
return runtime_SysAlloc(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime_SysMap(void *v, uintptr n)
|
|
|
|
{
|
|
|
|
USED(v);
|
|
|
|
USED(n);
|
|
|
|
}
|