summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/cgo/gcc_windows_amd64.c
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2014-06-19 09:22:53 +0200
committerMichael Stapelberg <stapelberg@debian.org>2014-06-19 09:22:53 +0200
commit8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (patch)
tree4449f2036cccf162e8417cc5841a35815b3e7ac5 /src/pkg/runtime/cgo/gcc_windows_amd64.c
parentc8bf49ef8a92e2337b69c14b9b88396efe498600 (diff)
downloadgolang-upstream/1.3.tar.gz
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'src/pkg/runtime/cgo/gcc_windows_amd64.c')
-rw-r--r--src/pkg/runtime/cgo/gcc_windows_amd64.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/pkg/runtime/cgo/gcc_windows_amd64.c b/src/pkg/runtime/cgo/gcc_windows_amd64.c
index f7695a1cc..d8dd69b4a 100644
--- a/src/pkg/runtime/cgo/gcc_windows_amd64.c
+++ b/src/pkg/runtime/cgo/gcc_windows_amd64.c
@@ -5,6 +5,8 @@
#define WIN64_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>
+#include <stdlib.h>
+#include <stdio.h>
#include "libcgo.h"
static void threadentry(void*);
@@ -25,14 +27,19 @@ x_cgo_init(G *g)
void
_cgo_sys_thread_start(ThreadStart *ts)
{
- _beginthread(threadentry, 0, ts);
+ uintptr_t thandle;
+
+ thandle = _beginthread(threadentry, 0, ts);
+ if(thandle == -1) {
+ fprintf(stderr, "runtime: failed to create new OS thread (%d)\n", errno);
+ abort();
+ }
}
static void
threadentry(void *v)
{
ThreadStart ts;
- void *tls0;
ts = *(ThreadStart*)v;
free(v);
@@ -43,13 +50,12 @@ threadentry(void *v)
/*
* Set specific keys in thread local storage.
*/
- tls0 = (void*)LocalAlloc(LPTR, 64);
asm volatile (
"movq %0, %%gs:0x28\n" // MOVL tls0, 0x28(GS)
"movq %%gs:0x28, %%rax\n" // MOVQ 0x28(GS), tmp
"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"
+ :: "r"(ts.tls), "r"(ts.g), "r"(ts.m) : "%rax"
);
crosscall_amd64(ts.fn);