]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
runtime: provide initcontext and fixcontext for NetBSD
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 5 Nov 2012 17:41:07 +0000 (17:41 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 5 Nov 2012 17:41:07 +0000 (17:41 +0000)
From-SVN: r193173

libgo/runtime/proc.c

index 8e82d1287817e556a3b416b0ecb720f44251fbdc..43071e581cc485809753f6dcccf2ab1b82e1bc73 100644 (file)
@@ -82,7 +82,7 @@ fixcontext(ucontext_t *c __attribute__ ((unused)))
 {
 }
 
-# else
+#else
 
 # if defined(__x86_64__) && defined(__sun__)
 
@@ -110,6 +110,28 @@ fixcontext(ucontext_t* c)
        c->uc_mcontext.gregs[REG_FSBASE] = fs;
 }
 
+# elif defined(__NetBSD__)
+
+// NetBSD has a bug: setcontext clobbers tlsbase, we need to save
+// and restore it ourselves.
+
+static __thread __greg_t tlsbase;
+
+static inline void
+initcontext(void)
+{
+       ucontext_t c;
+
+       getcontext(&c);
+       tlsbase = c.uc_mcontext._mc_tlsbase;
+}
+
+static inline void
+fixcontext(ucontext_t* c)
+{
+       c->uc_mcontext._mc_tlsbase = tlsbase;
+}
+
 # else
 
 #  error unknown case for SETCONTEXT_CLOBBERS_TLS