aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
diff options
context:
space:
mode:
authorShenghou Ma <minux.ma@gmail.com>2014-03-07 15:11:16 -0500
committerShenghou Ma <minux.ma@gmail.com>2014-03-07 15:11:16 -0500
commit84570aa9a18fa46dba1402004a54cedc7cf5e043 (patch)
treef1cae531ab508b4f3ff452d9bba885eb1fdb0d98 /src/pkg/runtime/proc.c
parent3d5e219e020115e98762821ac688e77b1b50787d (diff)
downloadgo-84570aa9a18fa46dba1402004a54cedc7cf5e043.tar.xz
runtime: round stack size to power of 2.
Fixes build on windows/386 and plan9/386. Fixes #7487. LGTM=mattn.jp, dvyukov, rsc R=golang-codereviews, mattn.jp, dvyukov, 0intro, rsc CC=golang-codereviews https://golang.org/cl/72360043
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r--src/pkg/runtime/proc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index bf55912783..eb7dfe4f84 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -1751,12 +1751,13 @@ runtime·malg(int32 stacksize)
newg = runtime·malloc(sizeof(G));
if(stacksize >= 0) {
+ stacksize = runtime·round2(StackSystem + stacksize);
if(g == m->g0) {
// running on scheduler stack already.
- stk = runtime·stackalloc(newg, StackSystem + stacksize);
+ stk = runtime·stackalloc(newg, stacksize);
} else {
// have to call stackalloc on scheduler stack.
- newg->stacksize = StackSystem + stacksize;
+ newg->stacksize = stacksize;
g->param = newg;
runtime·mcall(mstackalloc);
stk = g->param;
@@ -1765,7 +1766,7 @@ runtime·malg(int32 stacksize)
newg->stack0 = (uintptr)stk;
newg->stackguard = (uintptr)stk + StackGuard;
newg->stackguard0 = newg->stackguard;
- newg->stackbase = (uintptr)stk + StackSystem + stacksize - sizeof(Stktop);
+ newg->stackbase = (uintptr)stk + stacksize - sizeof(Stktop);
}
return newg;
}