From efcc50dfdc94c82ee0292bf71992ecb7c0123061 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 14 May 2013 18:39:35 +0200 Subject: Imported Upstream version 1.1 --- src/pkg/runtime/cgo/gcc_linux_386.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/pkg/runtime/cgo/gcc_linux_386.c') diff --git a/src/pkg/runtime/cgo/gcc_linux_386.c b/src/pkg/runtime/cgo/gcc_linux_386.c index 9357a63f7..c25c7b70f 100644 --- a/src/pkg/runtime/cgo/gcc_linux_386.c +++ b/src/pkg/runtime/cgo/gcc_linux_386.c @@ -8,13 +8,15 @@ #include "libcgo.h" static void *threadentry(void*); +static void (*setmg_gcc)(void*, void*); void -x_cgo_init(G *g) +x_cgo_init(G *g, void (*setmg)(void*, void*)) { pthread_attr_t attr; size_t size; + setmg_gcc = setmg; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); g->stackguard = (uintptr)&attr - size + 4096; @@ -69,18 +71,9 @@ threadentry(void *v) ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096; /* - * Set specific keys. On Linux/ELF, the thread local storage - * is just before %gs:0. Our dynamic 8.out's reserve 8 bytes - * for the two words g and m at %gs:-8 and %gs:-4. - * Xen requires us to access those words indirect from %gs:0 - * which points at itself. + * Set specific keys. */ - asm volatile ( - "movl %%gs:0, %%eax\n" // MOVL 0(GS), tmp - "movl %0, -8(%%eax)\n" // MOVL g, -8(GS) - "movl %1, -4(%%eax)\n" // MOVL m, -4(GS) - :: "r"(ts.g), "r"(ts.m) : "%eax" - ); + setmg_gcc((void*)ts.m, (void*)ts.g); crosscall_386(ts.fn); return nil; -- cgit v1.2.3