Commit 0316dafd authored by Russ Cox's avatar Russ Cox

runtime: rename SysAlloc to sysAlloc for Go

Renaming the C SysAlloc will let Go define a prototype without exporting it.
For use in cpuprof.goc's translation to Go.

LGTM=mdempsky
R=golang-codereviews, mdempsky
CC=golang-codereviews, iant
https://golang.org/cl/140060043
parent d4df63c3
......@@ -137,7 +137,7 @@ runtime·SetCPUProfileRate(intgo hz)
runtime·lock(&lk);
if(hz > 0) {
if(prof == nil) {
prof = runtime·SysAlloc(sizeof *prof, &mstats.other_sys);
prof = runtime·sysAlloc(sizeof *prof, &mstats.other_sys);
if(prof == nil) {
runtime·printf("runtime: cpu profiling cannot allocate memory\n");
runtime·unlock(&lk);
......
......@@ -825,7 +825,7 @@ makeheapobjbv(byte *p, uintptr size)
if(tmpbuf != nil)
runtime·SysFree(tmpbuf, tmpbufsize, &mstats.other_sys);
tmpbufsize = nptr*BitsPerPointer/8+1;
tmpbuf = runtime·SysAlloc(tmpbufsize, &mstats.other_sys);
tmpbuf = runtime·sysAlloc(tmpbufsize, &mstats.other_sys);
if(tmpbuf == nil)
runtime·throw("heapdump: out of memory");
}
......
......@@ -320,7 +320,7 @@ runtime·MHeap_SysAlloc(MHeap *h, uintptr n)
// try to get memory at a location chosen by the OS
// and hope that it is in the range we allocated bitmap for.
p_size = ROUND(n, PageSize) + PageSize;
p = runtime·SysAlloc(p_size, &mstats.heap_sys);
p = runtime·sysAlloc(p_size, &mstats.heap_sys);
if(p == nil)
return nil;
......@@ -361,7 +361,7 @@ enum
PersistentAllocMaxBlock = 64<<10, // VM reservation granularity is 64K on windows
};
// Wrapper around SysAlloc that can allocate small chunks.
// Wrapper around sysAlloc that can allocate small chunks.
// There is no associated free operation.
// Intended for things like function/type/debug-related persistent data.
// If align is 0, uses default align (currently 8).
......@@ -378,11 +378,11 @@ runtime·persistentalloc(uintptr size, uintptr align, uint64 *stat)
} else
align = 8;
if(size >= PersistentAllocMaxBlock)
return runtime·SysAlloc(size, stat);
return runtime·sysAlloc(size, stat);
runtime·lock(&persistent.lock);
persistent.pos = (byte*)ROUND((uintptr)persistent.pos, align);
if(persistent.pos + size > persistent.end) {
persistent.pos = runtime·SysAlloc(PersistentAllocChunk, &mstats.other_sys);
persistent.pos = runtime·sysAlloc(PersistentAllocChunk, &mstats.other_sys);
if(persistent.pos == nil) {
runtime·unlock(&persistent.lock);
runtime·throw("runtime: cannot allocate memory");
......
......@@ -160,12 +160,12 @@ struct MLink
MLink *next;
};
// SysAlloc obtains a large chunk of zeroed memory from the
// sysAlloc obtains a large chunk of zeroed memory from the
// operating system, typically on the order of a hundred kilobytes
// or a megabyte.
// NOTE: SysAlloc returns OS-aligned memory, but the heap allocator
// NOTE: sysAlloc returns OS-aligned memory, but the heap allocator
// may use larger alignment, so the caller must be careful to realign the
// memory obtained by SysAlloc.
// memory obtained by sysAlloc.
//
// SysUnused notifies the operating system that the contents
// of the memory region are no longer needed and can be reused
......@@ -187,16 +187,16 @@ struct MLink
// reserved, false if it has merely been checked.
// NOTE: SysReserve returns OS-aligned memory, but the heap allocator
// may use larger alignment, so the caller must be careful to realign the
// memory obtained by SysAlloc.
// memory obtained by sysAlloc.
//
// SysMap maps previously reserved address space for use.
// The reserved argument is true if the address space was really
// reserved, not merely checked.
//
// SysFault marks a (already SysAlloc'd) region to fault
// SysFault marks a (already sysAlloc'd) region to fault
// if accessed. Used only for debugging the runtime.
void* runtime·SysAlloc(uintptr nbytes, uint64 *stat);
void* runtime·sysAlloc(uintptr nbytes, uint64 *stat);
void runtime·SysFree(void *v, uintptr nbytes, uint64 *stat);
void runtime·SysUnused(void *v, uintptr nbytes);
void runtime·SysUsed(void *v, uintptr nbytes);
......@@ -205,7 +205,7 @@ void* runtime·SysReserve(void *v, uintptr nbytes, bool *reserved);
void runtime·SysFault(void *v, uintptr nbytes);
// FixAlloc is a simple free-list allocator for fixed size objects.
// Malloc uses a FixAlloc wrapped around SysAlloc to manages its
// Malloc uses a FixAlloc wrapped around sysAlloc to manages its
// MCache and MSpan objects.
//
// Memory returned by FixAlloc_Alloc is not zeroed.
......
......@@ -9,7 +9,7 @@
#include "malloc.h"
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *v;
......
......@@ -14,7 +14,7 @@ enum
};
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *v;
......
......@@ -14,7 +14,7 @@ enum
};
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *v;
......
......@@ -58,7 +58,7 @@ mmap_fixed(byte *v, uintptr n, int32 prot, int32 flags, int32 fd, uint32 offset)
}
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *p;
......
......@@ -14,19 +14,19 @@ enum
};
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *v;
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(v < (void*)4096) {
if(Debug)
runtime·printf("SysAlloc(%p): %p\n", n, v);
runtime·printf("sysAlloc(%p): %p\n", n, v);
return nil;
}
runtime·xadd64(stat, n);
if(Debug)
runtime·printf("SysAlloc(%p) = %p\n", n, v);
runtime·printf("sysAlloc(%p) = %p\n", n, v);
return v;
}
......
......@@ -14,7 +14,7 @@ enum
};
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *v;
......
......@@ -14,7 +14,7 @@ enum
};
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *v;
......
......@@ -36,7 +36,7 @@ brk(uintptr nbytes)
}
void*
runtime·SysAlloc(uintptr nbytes, uint64 *stat)
runtime·sysAlloc(uintptr nbytes, uint64 *stat)
{
void *p;
......@@ -53,7 +53,7 @@ runtime·SysFree(void *v, uintptr nbytes, uint64 *stat)
runtime·lock(&memlock);
// from tiny/mem.c
// Push pointer back if this is a free
// of the most recent SysAlloc.
// of the most recent sysAlloc.
nbytes += (nbytes + Round) & ~Round;
if(bloc == (byte*)v+nbytes)
bloc -= nbytes;
......
......@@ -14,7 +14,7 @@ enum
};
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *v;
......
......@@ -26,7 +26,7 @@ extern void *runtime·VirtualFree;
extern void *runtime·VirtualProtect;
void*
runtime·SysAlloc(uintptr n, uint64 *stat)
runtime·sysAlloc(uintptr n, uint64 *stat)
{
runtime·xadd64(stat, n);
return runtime·stdcall4(runtime·VirtualAlloc, 0, n, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
......
......@@ -36,7 +36,7 @@ RecordSpan(void *vh, byte *p)
cap = 64*1024/sizeof(all[0]);
if(cap < h->nspancap*3/2)
cap = h->nspancap*3/2;
all = (MSpan**)runtime·SysAlloc(cap*sizeof(all[0]), &mstats.other_sys);
all = (MSpan**)runtime·sysAlloc(cap*sizeof(all[0]), &mstats.other_sys);
if(all == nil)
runtime·throw("runtime: cannot allocate memory");
if(h->allspans) {
......
......@@ -38,7 +38,7 @@ stkbucket(int32 typ, uintptr size, uintptr *stk, int32 nstk, bool alloc)
Bucket *b;
if(buckhash == nil) {
buckhash = runtime·SysAlloc(BuckHashSize*sizeof buckhash[0], &mstats.buckhash_sys);
buckhash = runtime·sysAlloc(BuckHashSize*sizeof buckhash[0], &mstats.buckhash_sys);
if(buckhash == nil)
runtime·throw("runtime: cannot allocate memory");
}
......
......@@ -206,7 +206,7 @@ runtime·stackalloc(G *gp, uint32 n)
gp->stacksize += n;
if(runtime·debug.efence || StackFromSystem) {
v = runtime·SysAlloc(ROUND(n, PageSize), &mstats.stacks_sys);
v = runtime·sysAlloc(ROUND(n, PageSize), &mstats.stacks_sys);
if(v == nil)
runtime·throw("out of memory (stackalloc)");
return v;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment