diff mbox

[libgo] Build fix for sparc-linux

Message ID 54B97688.5070402@redhat.com
State New
Headers show

Commit Message

Richard Henderson Jan. 16, 2015, 8:37 p.m. UTC
The glibc setcontext modifies %g7, so the SETCONTEXT_CLOBBERS_TLS configure
test triggers.

My guess is that Solaris doesn't clobber %g7, or Rainer would have noticed this
before.  Is it worth also checking for __linux__ in the elif test, or just wait
until someone notices that they have an incompatible set of <ucontext.h>
definitions?


r~

Comments

Ian Lance Taylor Jan. 16, 2015, 11:23 p.m. UTC | #1
On Fri, Jan 16, 2015 at 12:37 PM, Richard Henderson <rth@redhat.com> wrote:
>
> The glibc setcontext modifies %g7, so the SETCONTEXT_CLOBBERS_TLS configure
> test triggers.
>
> My guess is that Solaris doesn't clobber %g7, or Rainer would have noticed this
> before.  Is it worth also checking for __linux__ in the elif test, or just wait
> until someone notices that they have an incompatible set of <ucontext.h>
> definitions?

Thanks, committed to mainline.

I agree with just committing it--let's see if anybody complains.

Ian
diff mbox

Patch

diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c
index 20fbc0a..3b00a65 100644
--- a/libgo/runtime/proc.c
+++ b/libgo/runtime/proc.c
@@ -126,6 +126,30 @@  fixcontext(ucontext_t* c)
 	c->uc_mcontext._mc_tlsbase = tlsbase;
 }
 
+# elif defined(__sparc__)
+
+static inline void
+initcontext(void)
+{
+}
+
+static inline void
+fixcontext(ucontext_t *c)
+{
+	/* ??? Using 
+	     register unsigned long thread __asm__("%g7");
+	     c->uc_mcontext.gregs[REG_G7] = thread;
+	   results in
+	     error: variable ‘thread’ might be clobbered by \
+		‘longjmp’ or ‘vfork’ [-Werror=clobbered]
+	   which ought to be false, as %g7 is a fixed register.  */
+
+	if (sizeof (c->uc_mcontext.gregs[REG_G7]) == 8)
+		asm ("stx %%g7, %0" : "=m"(c->uc_mcontext.gregs[REG_G7]));
+	else
+		asm ("st %%g7, %0" : "=m"(c->uc_mcontext.gregs[REG_G7]));
+}
+
 # else
 
 #  error unknown case for SETCONTEXT_CLOBBERS_TLS