]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: rename SysAlloc to sysAlloc for Go
authorRuss Cox <rsc@golang.org>
Sat, 30 Aug 2014 04:54:40 +0000 (00:54 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 30 Aug 2014 04:54:40 +0000 (00:54 -0400)
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

17 files changed:
src/pkg/runtime/cpuprof.goc
src/pkg/runtime/heapdump.c
src/pkg/runtime/malloc.c
src/pkg/runtime/malloc.h
src/pkg/runtime/mem_darwin.c
src/pkg/runtime/mem_dragonfly.c
src/pkg/runtime/mem_freebsd.c
src/pkg/runtime/mem_linux.c
src/pkg/runtime/mem_nacl.c
src/pkg/runtime/mem_netbsd.c
src/pkg/runtime/mem_openbsd.c
src/pkg/runtime/mem_plan9.c
src/pkg/runtime/mem_solaris.c
src/pkg/runtime/mem_windows.c
src/pkg/runtime/mheap.c
src/pkg/runtime/mprof.goc
src/pkg/runtime/stack.c

index 8ae06edcb1b4aa06db3808471f38bec798225d58..0d6d078ffd5a70f5ac6bfc1098bbd78cf36fae78 100644 (file)
@@ -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);
index fe67e15f35fa8d624083c43b86644a7264540bd9..29a9ae6476086428448c15ae024e651f31ca4429 100644 (file)
@@ -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");
        }
index 143d9e5e9e2228df49705a45163d308d8ed16b96..8210081553619f140902a1fbe1a9d3234cfade2d 100644 (file)
@@ -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");
index 6cd72fb31f6b995a0eef5da912d62df0a1cc1622..699455745957673f6a14861bcfd9273c2372cef6 100644 (file)
@@ -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.
index 878c4e1c5577a48d8a003ee9af9e3076c03e6892..ca0ac72de99e6d02254d688d925700e4c328f94d 100644 (file)
@@ -9,7 +9,7 @@
 #include "malloc.h"
 
 void*
-runtime·SysAlloc(uintptr n, uint64 *stat)
+runtime·sysAlloc(uintptr n, uint64 *stat)
 {
        void *v;
 
index c270332cb9e5d585e2926031f6050f5d799d18de..55410cef64e264eb9fbbc40c194d98888c366d5f 100644 (file)
@@ -14,7 +14,7 @@ enum
 };
 
 void*
-runtime·SysAlloc(uintptr n, uint64 *stat)
+runtime·sysAlloc(uintptr n, uint64 *stat)
 {
        void *v;
 
index 586947a2dcb257c2809580261079bd5c75b22a31..a033bfcdc069e31f328557529216c7ec178e5cc3 100644 (file)
@@ -14,7 +14,7 @@ enum
 };
 
 void*
-runtime·SysAlloc(uintptr n, uint64 *stat)
+runtime·sysAlloc(uintptr n, uint64 *stat)
 {
        void *v;
 
index 635594c3651065afed06b3c5a67f8326ed79d93e..429f820f8bfcf7a9eebe1a33d87139d463dc56f4 100644 (file)
@@ -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;
 
index e2bca40a4904b1b965a99da064772c8c1925165f..5c5f806324515196c67c276e1238e2021faf6724 100644 (file)
@@ -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;
 }
 
index 861ae90c7e00941b2c7dfd65e81f7c3cb0d6d383..cf4b24f92000108d6635e31417c551624f164780 100644 (file)
@@ -14,7 +14,7 @@ enum
 };
 
 void*
-runtime·SysAlloc(uintptr n, uint64 *stat)
+runtime·sysAlloc(uintptr n, uint64 *stat)
 {
        void *v;
 
index 861ae90c7e00941b2c7dfd65e81f7c3cb0d6d383..cf4b24f92000108d6635e31417c551624f164780 100644 (file)
@@ -14,7 +14,7 @@ enum
 };
 
 void*
-runtime·SysAlloc(uintptr n, uint64 *stat)
+runtime·sysAlloc(uintptr n, uint64 *stat)
 {
        void *v;
 
index 8d31bcfe2dc096079c58ad11a8326bdb54086304..aec652995f21a9e89a4539e6e7e528e671f83734 100644 (file)
@@ -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;
index 034222887bce8247c2df62d2dcfdccd269422199..87536f6837255ca4067fec2662b714eabc7b5cd4 100644 (file)
@@ -14,7 +14,7 @@ enum
 };
 
 void*
-runtime·SysAlloc(uintptr n, uint64 *stat)
+runtime·sysAlloc(uintptr n, uint64 *stat)
 {
        void *v;
 
index 5eb43b2a9320f377edad04188c0a9699c1e53db6..cb1c9de907b25ff2df71ea3e672876a8ce67d64c 100644 (file)
@@ -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);
index 90acd55f9f178676809a96f26fffa4783bc4eb1c..9b165d6caddbf29b7d9b2d9d31f5e5d5f71bd4a2 100644 (file)
@@ -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) {
index a340ebdafb4db2740cdc285f0df575782b075b14..589863a15631497c4d8f8262e0757b4b04d6637f 100644 (file)
@@ -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");
        }
index 96f1946db2c316ae91d0eee1cc58dfb38160921e..e499b1f8b6d05ad90fe40efe367b8087fb9a9dc7 100644 (file)
@@ -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;