summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/cgo/gcc_freebsd_386.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/cgo/gcc_freebsd_386.c')
-rw-r--r--src/pkg/runtime/cgo/gcc_freebsd_386.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/pkg/runtime/cgo/gcc_freebsd_386.c b/src/pkg/runtime/cgo/gcc_freebsd_386.c
index 7c62a1bc4..6797824c6 100644
--- a/src/pkg/runtime/cgo/gcc_freebsd_386.c
+++ b/src/pkg/runtime/cgo/gcc_freebsd_386.c
@@ -10,13 +10,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;
@@ -66,15 +68,9 @@ threadentry(void *v)
ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096;
/*
- * Set specific keys. On FreeBSD/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.
+ * Set specific keys.
*/
- asm volatile (
- "movl %0, %%gs:-8\n" // MOVL g, -8(GS)
- "movl %1, %%gs:-4\n" // MOVL m, -4(GS)
- :: "r"(ts.g), "r"(ts.m)
- );
+ setmg_gcc((void*)ts.m, (void*)ts.g);
crosscall_386(ts.fn);
return nil;