diff options
Diffstat (limited to 'src/pkg/runtime/windows/386/sys.s')
-rw-r--r-- | src/pkg/runtime/windows/386/sys.s | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/pkg/runtime/windows/386/sys.s b/src/pkg/runtime/windows/386/sys.s index d1a8a49a9..bca48febe 100644 --- a/src/pkg/runtime/windows/386/sys.s +++ b/src/pkg/runtime/windows/386/sys.s @@ -99,6 +99,45 @@ TEXT runtime·sigtramp1(SB),0,$16-28 sigdone: RET +// Windows runs the ctrl handler in a new thread. +TEXT runtime·ctrlhandler(SB),7,$0 + PUSHL BP + MOVL SP, BP + PUSHL BX + PUSHL SI + PUSHL DI + PUSHL 0x2c(FS) + MOVL SP, BX + + // setup dummy m, g + SUBL $(m_sehframe+4), SP // at least space for m_sehframe + LEAL m_tls(SP), CX + MOVL CX, 0x2c(FS) + MOVL SP, m(CX) + MOVL SP, DX + SUBL $8, SP // space for g_stack{guard,base} + MOVL SP, g(CX) + MOVL SP, m_g0(DX) + LEAL -4096(SP), CX + MOVL CX, g_stackguard(SP) + MOVL BX, g_stackbase(SP) + + PUSHL 8(BP) + CALL runtime·ctrlhandler1(SB) + POPL CX + + get_tls(CX) + MOVL g(CX), CX + MOVL g_stackbase(CX), SP + POPL 0x2c(FS) + POPL DI + POPL SI + POPL BX + POPL BP + MOVL 0(SP), CX + ADDL $8, SP + JMP CX + // Called from dynamic function created by ../thread.c compilecallback, // running on Windows stack (not Go stack). // BX, BP, SI, DI registers and DF flag are preserved @@ -107,7 +146,11 @@ sigdone: // DX = total size of arguments // TEXT runtime·callbackasm+0(SB),7,$0 + // preserve whatever's at the memory location that + // the callback will use to store the return value LEAL 8(SP), CX + PUSHL 0(CX)(DX*1) + ADDL $4, DX // extend argsize by size of return value // save registers as required for windows callback PUSHL 0(FS) @@ -129,7 +172,7 @@ TEXT runtime·callbackasm+0(SB),7,$0 CALL runtime·cgocallback(SB) // restore registers as required for windows callback - POPL CX + POPL AX POPL CX POPL DX POPL BX @@ -139,6 +182,8 @@ TEXT runtime·callbackasm+0(SB),7,$0 POPL 0(FS) CLD + MOVL -4(CX)(DX*1), AX + POPL -4(CX)(DX*1) RET // void tstart(M *newm); |