summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/cgo
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
commit758ff64c69e34965f8af5b2d6ffd65e8d7ab2150 (patch)
tree6d6b34f8c678862fe9b56c945a7b63f68502c245 /src/pkg/runtime/cgo
parent3e45412327a2654a77944249962b3652e6142299 (diff)
downloadgolang-758ff64c69e34965f8af5b2d6ffd65e8d7ab2150.tar.gz
Imported Upstream version 2011-02-01.1upstream/2011-02-01.1
Diffstat (limited to 'src/pkg/runtime/cgo')
-rw-r--r--src/pkg/runtime/cgo/Makefile9
-rwxr-xr-xsrc/pkg/runtime/cgo/windows_386.c13
2 files changed, 17 insertions, 5 deletions
diff --git a/src/pkg/runtime/cgo/Makefile b/src/pkg/runtime/cgo/Makefile
index 55b6967d9..768fe80ac 100644
--- a/src/pkg/runtime/cgo/Makefile
+++ b/src/pkg/runtime/cgo/Makefile
@@ -10,6 +10,10 @@ ifeq ($(GOARCH),arm)
ENABLED:=0
endif
+ifeq ($(DISABLE_CGO),1)
+ENABLED:=0
+endif
+
TARG=runtime/cgo
GOFILES=\
@@ -30,7 +34,11 @@ OFILES=\
_cgo_import.$O\
$(CGO_OFILES)\
+ifeq ($(GOOS),windows)
+CGO_LDFLAGS=-lm -mthreads
+else
CGO_LDFLAGS=-lpthread
+endif
ifeq ($(GOOS),freebsd)
OFILES+=\
@@ -48,7 +56,6 @@ _cgo_defun.c:
_cgo_main.c:
echo 'int main() { return 0; }' >$@
- echo 'void *crosscall2;' >>$@
endif
$(GOARCH).o: $(GOARCH).S
diff --git a/src/pkg/runtime/cgo/windows_386.c b/src/pkg/runtime/cgo/windows_386.c
index 5f5235bd2..f39309cb1 100755
--- a/src/pkg/runtime/cgo/windows_386.c
+++ b/src/pkg/runtime/cgo/windows_386.c
@@ -30,6 +30,7 @@ static void*
threadentry(void *v)
{
ThreadStart ts;
+ void *tls0;
ts = *(ThreadStart*)v;
free(v);
@@ -45,13 +46,17 @@ threadentry(void *v)
/*
* Set specific keys in thread local storage.
*/
+ tls0 = (void*)LocalAlloc(LPTR, 32);
asm volatile (
- "MOVL %%fs:0x2c, %%eax\n" // MOVL 0x24(FS), tmp
- "movl %0, 0(%%eax)\n" // MOVL g, 0(FS)
- "movl %1, 4(%%eax)\n" // MOVL m, 4(FS)
- :: "r"(ts.g), "r"(ts.m) : "%eax"
+ "movl %0, %%fs:0x2c\n" // MOVL tls0, 0x2c(FS)
+ "movl %%fs:0x2c, %%eax\n" // MOVL 0x2c(FS), tmp
+ "movl %1, 0(%%eax)\n" // MOVL g, 0(FS)
+ "movl %2, 4(%%eax)\n" // MOVL m, 4(FS)
+ :: "r"(tls0), "r"(ts.g), "r"(ts.m) : "%eax"
);
crosscall_386(ts.fn);
+
+ LocalFree(tls0);
return nil;
}