* libgo patch committed: NetBSD fix
@ 2012-11-05 17:41 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2012-11-05 17:41 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 250 bytes --]
This patch from Shenghou Ma fixes gccgo on libgo by not losing the TLS
pointer. This works around what I would describe as a bug in the NetBSD
libc. Bootstrapped on x86_64-unknown-linux-gnu, not that that proves
much. Committed to mainline.
Ian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 760 bytes --]
diff -r df61836f495f libgo/runtime/proc.c
--- a/libgo/runtime/proc.c Mon Nov 05 09:36:01 2012 -0800
+++ b/libgo/runtime/proc.c Mon Nov 05 09:37:21 2012 -0800
@@ -82,7 +82,7 @@
{
}
-# else
+#else
# if defined(__x86_64__) && defined(__sun__)
@@ -110,6 +110,28 @@
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-11-05 17:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05 17:41 libgo patch committed: NetBSD fix Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).