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
This commit is contained in:
Shenghou Ma 2014-03-07 15:11:16 -05:00
parent 3d5e219e02
commit 84570aa9a1
5 changed files with 18 additions and 13 deletions

View file

@ -555,8 +555,8 @@ copystack(G *gp, uintptr nframes, uintptr newsize)
}
// round x up to a power of 2.
static int32
round2(int32 x)
int32
runtime·round2(int32 x)
{
int32 s;
@ -683,7 +683,7 @@ runtime·newstack(void)
if(framesize < StackMin)
framesize = StackMin;
framesize += StackSystem;
framesize = round2(framesize);
framesize = runtime·round2(framesize);
stk = runtime·stackalloc(gp, framesize);
if(gp->stacksize > runtime·maxstacksize) {
runtime·printf("runtime: goroutine stack exceeds %D-byte limit\n", (uint64)runtime·maxstacksize);