Round = PAGESIZE-1
};
-void*
-runtime·SysAlloc(uintptr nbytes, uint64 *stat)
+static void*
+brk(uintptr nbytes)
{
uintptr bl;
}
bloc = (byte*)bl + nbytes;
runtime·unlock(&memlock);
- runtime·xadd64(stat, nbytes);
return (void*)bl;
+
+}
+
+void*
+runtime·SysAlloc(uintptr nbytes, uint64 *stat)
+{
+ void *p;
+
+ p = brk(nbytes);
+ if(p != nil)
+ runtime·xadd64(stat, nbytes);
+ return p;
}
void
void
runtime·SysMap(void *v, uintptr nbytes, bool reserved, uint64 *stat)
{
- USED(v, nbytes, reserved, stat);
+ // SysReserve has already allocated all heap memory,
+ // but has not adjusted stats.
+ USED(v, reserved);
+ runtime·xadd64(stat, nbytes);
}
void
{
USED(v);
*reserved = true;
- return runtime·SysAlloc(nbytes, &mstats.heap_sys);
+ return brk(nbytes);
}