diff options
Diffstat (limited to 'src/pkg/runtime/cgo/gcc_windows_386.c')
-rw-r--r-- | src/pkg/runtime/cgo/gcc_windows_386.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/pkg/runtime/cgo/gcc_windows_386.c b/src/pkg/runtime/cgo/gcc_windows_386.c index 02eab12e5..cdc866468 100644 --- a/src/pkg/runtime/cgo/gcc_windows_386.c +++ b/src/pkg/runtime/cgo/gcc_windows_386.c @@ -5,6 +5,8 @@ #define WIN32_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,16 +50,13 @@ threadentry(void *v) /* * Set specific keys in thread local storage. */ - tls0 = (void*)LocalAlloc(LPTR, 32); asm volatile ( "movl %0, %%fs:0x14\n" // MOVL tls0, 0x14(FS) "movl %%fs:0x14, %%eax\n" // MOVL 0x14(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" + :: "r"(ts.tls), "r"(ts.g), "r"(ts.m) : "%eax" ); crosscall_386(ts.fn); - - LocalFree(tls0); } |