From e03bce158fba5f13dd7f2f0a86a40eb14958300b Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 7 Aug 2014 09:00:02 -0400 Subject: cmd/cc, runtime: eliminate use of the unnamed substructure C extension Eliminating use of this extension makes it easier to port the Go runtime to other compilers. This CL also disables the extension in cc to prevent accidental use. LGTM=rsc, khr R=rsc, aram, khr, dvyukov CC=axwalk, golang-codereviews https://golang.org/cl/106790044 --- src/pkg/runtime/malloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/pkg/runtime/malloc.c') diff --git a/src/pkg/runtime/malloc.c b/src/pkg/runtime/malloc.c index be3280e0f1..8b9447dad6 100644 --- a/src/pkg/runtime/malloc.c +++ b/src/pkg/runtime/malloc.c @@ -45,9 +45,9 @@ runtime·mlookup(void *v, byte **base, uintptr *size, MSpan **sp) g->m->mcache->local_nlookup++; if (sizeof(void*) == 4 && g->m->mcache->local_nlookup >= (1<<30)) { // purge cache stats to prevent overflow - runtime·lock(&runtime·mheap); + runtime·lock(&runtime·mheap.lock); runtime·purgecachedstats(g->m->mcache); - runtime·unlock(&runtime·mheap); + runtime·unlock(&runtime·mheap.lock); } s = runtime·MHeap_LookupMaybe(&runtime·mheap, v); @@ -341,7 +341,7 @@ runtime·MHeap_SysAlloc(MHeap *h, uintptr n) static struct { - Lock; + Lock lock; byte* pos; byte* end; } persistent; @@ -370,19 +370,19 @@ runtime·persistentalloc(uintptr size, uintptr align, uint64 *stat) align = 8; if(size >= PersistentAllocMaxBlock) return runtime·SysAlloc(size, stat); - runtime·lock(&persistent); + 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); if(persistent.pos == nil) { - runtime·unlock(&persistent); + runtime·unlock(&persistent.lock); runtime·throw("runtime: cannot allocate memory"); } persistent.end = persistent.pos + PersistentAllocChunk; } p = persistent.pos; persistent.pos += size; - runtime·unlock(&persistent); + runtime·unlock(&persistent.lock); if(stat != &mstats.other_sys) { // reaccount the allocation against provided stat runtime·xadd64(stat, size); -- cgit v1.3-5-g9baa