summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/windows/386
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-18 09:50:58 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-18 09:50:58 +0100
commitc072558b90f1bbedc2022b0f30c8b1ac4712538e (patch)
tree67767591619e4bd8111fb05fac185cde94fb7378 /src/pkg/runtime/windows/386
parent5859517b767c99749a45651c15d4bae5520ebae8 (diff)
downloadgolang-upstream/2011.02.15.tar.gz
Imported Upstream version 2011.02.15upstream/2011.02.15
Diffstat (limited to 'src/pkg/runtime/windows/386')
-rw-r--r--src/pkg/runtime/windows/386/defs.h3
-rw-r--r--src/pkg/runtime/windows/386/signal.c7
-rw-r--r--src/pkg/runtime/windows/386/sys.s47
3 files changed, 50 insertions, 7 deletions
diff --git a/src/pkg/runtime/windows/386/defs.h b/src/pkg/runtime/windows/386/defs.h
index a2a882103..49fc19504 100644
--- a/src/pkg/runtime/windows/386/defs.h
+++ b/src/pkg/runtime/windows/386/defs.h
@@ -10,6 +10,9 @@ enum {
PROT_EXEC = 0x4,
MAP_ANON = 0x1,
MAP_PRIVATE = 0x2,
+ SIGINT = 0x2,
+ CTRL_C_EVENT = 0,
+ CTRL_BREAK_EVENT = 0x1,
EXCEPTION_ACCESS_VIOLATION = 0xc0000005,
EXCEPTION_BREAKPOINT = 0x80000003,
EXCEPTION_FLT_DENORMAL_OPERAND = 0xc000008d,
diff --git a/src/pkg/runtime/windows/386/signal.c b/src/pkg/runtime/windows/386/signal.c
index 69178cdd0..903636910 100644
--- a/src/pkg/runtime/windows/386/signal.c
+++ b/src/pkg/runtime/windows/386/signal.c
@@ -27,12 +27,7 @@ runtime·dumpregs(Context *r)
void
runtime·initsig(int32)
{
-}
-
-String
-runtime·signame(int32)
-{
- return runtime·emptystring;
+ runtime·siginit();
}
uint32
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);