From 06ace75d4bcebf8bcc021dfe918b9866fba3108c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 12 May 2017 12:49:34 +0000 Subject: runtime: fix build for non-split-stack systems Change memory allocation accounting for stacks to use stacks_sys, since that seems to be what it is for. Reviewed-on: https://go-review.googlesource.com/43297 From-SVN: r247967 --- libgo/go/runtime/runtime2.go | 7 +++++++ libgo/runtime/proc.c | 4 +++- libgo/runtime/stack.c | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'libgo') diff --git a/libgo/go/runtime/runtime2.go b/libgo/go/runtime/runtime2.go index 8deb620..8bfdcbc 100644 --- a/libgo/go/runtime/runtime2.go +++ b/libgo/go/runtime/runtime2.go @@ -793,3 +793,10 @@ type g_ucontext_t [(_sizeof_ucontext_t + 15) / unsafe.Sizeof(uintptr(0))]uintptr // sigset is the Go version of the C type sigset_t. // _sigset_t is defined by the Makefile from . type sigset _sigset_t + +// getMemstats returns a pointer to the internal memstats variable, +// for C code. +//go:linkname getMemstats runtime.getMemstats +func getMemstats() *mstats { + return &memstats +} diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index cc56642..14ee673 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -406,6 +406,8 @@ extern void globrunqput(G*) __asm__(GOSYM_PREFIX "runtime.globrunqput"); extern P* pidleget(void) __asm__(GOSYM_PREFIX "runtime.pidleget"); +extern struct mstats* getMemstats(void) + __asm__(GOSYM_PREFIX "runtime.getMemstats"); bool runtime_isstarted; @@ -726,7 +728,7 @@ runtime_malg(bool allocatestack, bool signalstack, byte** ret_stack, uintptr* re // 32-bit mode, the Go allocation space is all of // memory anyhow. if(sizeof(void*) == 8) { - void *p = runtime_sysAlloc(stacksize, &mstats()->other_sys); + void *p = runtime_sysAlloc(stacksize, &getMemstats()->stacks_sys); if(p == nil) runtime_throw("runtime: cannot allocate memory for goroutine stack"); *ret_stack = (byte*)p; diff --git a/libgo/runtime/stack.c b/libgo/runtime/stack.c index 98f98fe..1ce30db 100644 --- a/libgo/runtime/stack.c +++ b/libgo/runtime/stack.c @@ -80,7 +80,6 @@ static void doscanstack1(G *gp, void *gcw) { scanstackblock(sp, (uintptr)(spsize), gcw); } #else - M *mp; byte* bottom; byte* top; -- cgit v1.1