aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime
diff options
context:
space:
mode:
authorWei Guangjing <vcc.163@gmail.com>2011-07-19 10:47:33 -0400
committerRuss Cox <rsc@golang.org>2011-07-19 10:47:33 -0400
commit9f636598ba2425cbc31e416599f430829fa36b20 (patch)
tree19bc60df7034f0e6cddfc7566be8297d6095e3a2 /src/pkg/runtime
parent0b200b4d0902459551812dd18642332e494c7d12 (diff)
downloadgo-9f636598ba2425cbc31e416599f430829fa36b20.tar.xz
cgo: windows amd64 port
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4725041
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r--src/pkg/runtime/amd64/asm.s4
-rwxr-xr-xsrc/pkg/runtime/cgo/windows_amd64.c9
-rw-r--r--src/pkg/runtime/windows/amd64/rt0.s3
3 files changed, 12 insertions, 4 deletions
diff --git a/src/pkg/runtime/amd64/asm.s b/src/pkg/runtime/amd64/asm.s
index 2734ae1dca..2b16587f8c 100644
--- a/src/pkg/runtime/amd64/asm.s
+++ b/src/pkg/runtime/amd64/asm.s
@@ -18,7 +18,8 @@ TEXT _rt0_amd64(SB),7,$-8
TESTQ AX, AX
JZ needtls
CALL AX
- JMP ok
+ CMPL runtime·iswindows(SB), $0
+ JEQ ok
needtls:
LEAQ runtime·tls0(SB), DI
@@ -432,6 +433,7 @@ TEXT runtime·asmcgocall(SB),7,$0
MOVQ DI, 16(SP) // save g
MOVQ DX, 8(SP) // save SP
MOVQ BX, DI // DI = first argument in AMD64 ABI
+ MOVQ BX, CX // CX = first argument in Win64
CALL AX
// Restore registers, g, stack pointer.
diff --git a/src/pkg/runtime/cgo/windows_amd64.c b/src/pkg/runtime/cgo/windows_amd64.c
index fd5b397ab5..e8313e250a 100755
--- a/src/pkg/runtime/cgo/windows_amd64.c
+++ b/src/pkg/runtime/cgo/windows_amd64.c
@@ -30,6 +30,7 @@ static void*
threadentry(void *v)
{
ThreadStart ts;
+ void *tls0;
ts = *(ThreadStart*)v;
free(v);
@@ -45,11 +46,13 @@ threadentry(void *v)
/*
* Set specific keys in thread local storage.
*/
+ tls0 = (void*)LocalAlloc(LPTR, 64);
asm volatile (
+ "movq %0, %%gs:0x58\n" // MOVL tls0, 0x58(GS)
"movq %%gs:0x58, %%rax\n" // MOVQ 0x58(GS), tmp
- "movq %0, 0(%%rax)\n" // MOVQ g, 0(GS)
- "movq %1, 8(%%rax)\n" // MOVQ m, 8(GS)
- :: "r"(ts.g), "r"(ts.m) : "%rax"
+ "movq %1, 0(%%rax)\n" // MOVQ g, 0(GS)
+ "movq %2, 8(%%rax)\n" // MOVQ m, 8(GS)
+ :: "r"(tls0), "r"(ts.g), "r"(ts.m) : "%rax"
);
crosscall_amd64(ts.fn);
diff --git a/src/pkg/runtime/windows/amd64/rt0.s b/src/pkg/runtime/windows/amd64/rt0.s
index e54e7edeb9..35978bc746 100644
--- a/src/pkg/runtime/windows/amd64/rt0.s
+++ b/src/pkg/runtime/windows/amd64/rt0.s
@@ -8,3 +8,6 @@ TEXT _rt0_amd64_windows(SB),7,$-8
MOVQ $_rt0_amd64(SB), AX
MOVQ SP, DI
JMP AX
+
+DATA runtime·iswindows(SB)/4, $1
+GLOBL runtime·iswindows(SB), $4