Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
runtime: fix build failures after CL 137410043
Browse files Browse the repository at this point in the history
No promise about correctness, but they do build.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/143720043
  • Loading branch information
rsc committed Sep 9, 2014
1 parent 15b76ad commit 8ac35be
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/runtime/asm_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ TEXT setg_gcc<>(SB), NOSPLIT, $0
MOVL DX, g(AX)
RET

// check that SP is in range [g->stackbase, g->stackguard)
// check that SP is in range [g->stack.lo, g->stack.hi)
TEXT runtime·stackcheck(SB), NOSPLIT, $0-0
get_tls(CX)
MOVL g(CX), AX
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/asm_amd64p32.s
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ TEXT runtime·setg(SB), NOSPLIT, $0-4
MOVL 0, AX
RET

// check that SP is in range [g->stackbase, g->stackguard)
// check that SP is in range [g->stack.lo, g->stack.hi)
TEXT runtime·stackcheck(SB), NOSPLIT, $0-0
get_tls(CX)
MOVL g(CX), AX
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/os_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ runtime·newosproc(M *mp, void *stk)

// NOTE(rsc): This code is confused. stackbase is the top of the stack
// and is equal to stk. However, it's working, so I'm not changing it.
param.stack_base = (void*)mp->g0->stackbase;
param.stack_size = (byte*)stk - (byte*)mp->g0->stackbase;
param.stack_base = (void*)mp->g0->stack.hi;
param.stack_size = (byte*)stk - (byte*)mp->g0->stack.hi;

param.child_tid = (void*)&mp->procid;
param.parent_tid = nil;
Expand Down
5 changes: 4 additions & 1 deletion src/runtime/os_solaris.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,17 @@ runtime·newosproc(M *mp, void *stk)
Sigset oset;
Pthread tid;
int32 ret;
uint64 size;

USED(stk);
if(runtime·pthread_attr_init(&attr) != 0)
runtime·throw("pthread_attr_init");
if(runtime·pthread_attr_setstack(&attr, 0, 0x200000) != 0)
runtime·throw("pthread_attr_setstack");
if(runtime·pthread_attr_getstack(&attr, (void**)&mp->g0->stackbase, &mp->g0->stacksize) != 0)
size = 0;
if(runtime·pthread_attr_getstack(&attr, (void**)&mp->g0->stack.hi, &size) != 0)
runtime·throw("pthread_attr_getstack");
mp->g0->stack.lo = mp->g0->stack.hi - size;
if(runtime·pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
runtime·throw("pthread_attr_setdetachstate");

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/sys_plan9_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0
// change stack
MOVL g_m(BX), BX
MOVL m_gsignal(BX), BP
MOVL g_stackbase(BP), BP
MOVL (g_stack+stack_hi)(BP), BP
MOVL BP, SP

// make room for args and g
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/sys_plan9_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0
// change stack
MOVQ g_m(BX), BX
MOVQ m_gsignal(BX), R10
MOVQ g_stackbase(R10), BP
MOVQ (g_stack+stack_hi)(R10), BP
MOVQ BP, SP

// make room for args and g
Expand Down
6 changes: 4 additions & 2 deletions src/runtime/sys_solaris_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ TEXT runtime·tstart_sysvicall(SB),NOSPLIT,$0

// Layout new m scheduler stack on os stack.
MOVQ SP, AX
MOVQ AX, g_stackbase(DX)
MOVQ AX, (g_stack+stack_hi)(DX)
SUBQ $(0x100000), AX // stack size
MOVQ AX, g_stackguard(DX)
MOVQ AX, (g_stack+stack_lo)(DX)
ADDQ $const_StackGuard, AX
MOVQ AX, g_stackguard0(DX)
MOVQ AX, g_stackguard1(DX)

// Someday the convention will be D is always cleared.
CLD
Expand Down
16 changes: 11 additions & 5 deletions src/runtime/sys_windows_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,19 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0
LEAL g_end(SP), BX
MOVL BX, g_m(SP)
LEAL -4096(SP), CX
MOVL CX, g_stackguard(SP)
MOVL DX, g_stackbase(SP)
MOVL CX, (g_stack+stack_lo)(SP)
ADDL $const_StackGuard, CX
MOVL CX, g_stackguard0(SP)
MOVL CX, g_stackguard1(SP)
MOVL DX, (g_stack+stack_hi)(SP)

PUSHL 16(BP) // arg for handler
CALL 8(BP)
POPL CX

get_tls(CX)
MOVL g(CX), CX
MOVL g_stackbase(CX), SP
MOVL (g_stack+stack_hi)(CX), SP
POPL 0x14(FS)
POPL DI
POPL SI
Expand Down Expand Up @@ -293,9 +296,12 @@ TEXT runtime·tstart(SB),NOSPLIT,$0

// Layout new m scheduler stack on os stack.
MOVL SP, AX
MOVL AX, g_stackbase(DX)
MOVL AX, (g_stack+stack_hi)(DX)
SUBL $(64*1024), AX // stack size
MOVL AX, g_stackguard(DX)
MOVL AX, (g_stack+stack_lo)(DX)
ADDL $const_StackGuard, AX
MOVL AX, g_stackguard0(DX)
MOVL AX, g_stackguard1(DX)

// Set up tls.
LEAL m_tls(CX), SI
Expand Down
16 changes: 11 additions & 5 deletions src/runtime/sys_windows_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,19 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0
MOVQ BX, g_m(SP)

LEAQ -8192(SP), CX
MOVQ CX, g_stackguard(SP)
MOVQ DX, g_stackbase(SP)
MOVQ CX, (g_stack+stack_lo)(SP)
ADDQ $const_StackGuard, CX
MOVQ CX, g_stackguard0(SP)
MOVQ CX, g_stackguard1(SP)
MOVQ DX, (g_stack+stack_hi)(SP)

PUSHQ 32(BP) // arg for handler
CALL 16(BP)
POPQ CX

get_tls(CX)
MOVQ g(CX), CX
MOVQ g_stackbase(CX), SP
MOVQ (g_stack+stack_hi)(CX), SP
POPQ 0x28(GS)
POPQ DI
POPQ SI
Expand Down Expand Up @@ -334,9 +337,12 @@ TEXT runtime·tstart_stdcall(SB),NOSPLIT,$0

// Layout new m scheduler stack on os stack.
MOVQ SP, AX
MOVQ AX, g_stackbase(DX)
MOVQ AX, (g_stack+stack_hi)(DX)
SUBQ $(64*1024), AX // stack size
MOVQ AX, g_stackguard(DX)
MOVQ AX, (g_stack+stack_lo)(DX)
ADDQ $const_StackGuard, AX
MOVQ AX, g_stackguard0(DX)
MOVQ AX, g_stackguard1(DX)

// Set up tls.
LEAQ m_tls(CX), SI
Expand Down

0 comments on commit 8ac35be

Please sign in to comment.