Module Name:    src
Committed By:   riz
Date:           Thu Mar 14 22:36:06 UTC 2013

Modified Files:
        src/lib/libc/arch/alpha/gen [netbsd-6]: __longjmp14.c __setjmp14.S

Log Message:
Pull up following revision(s) (requested by martin in ticket #846):
        lib/libc/arch/alpha/gen/__setjmp14.S: revision 1.6
        lib/libc/arch/alpha/gen/__longjmp14.c: revision 1.6
        lib/libc/arch/alpha/gen/__longjmp14.c: revision 1.7
Save the GP register value and restore it on longjmp.
While formally GP is not a callee-saved register, for static linking
the link time optimization described in section 3.2.3 of the "Calling
Standard for Alpha Systems" allows the caller to rely on GP being the
value needed within setjmp() - and not restore it after return if setjmp
and the call site share a GP value.
This fixes longjmp/setjmp for statically linked programs, e.g. /rescue/csh
or the static tcsh variant from pkgsrc.
Remove clearing of ucontext_t, the only random register values now are
argument and scratch registers (which will be reloaded after return anyway).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.24.1 src/lib/libc/arch/alpha/gen/__longjmp14.c
cvs rdiff -u -r1.5 -r1.5.4.1 src/lib/libc/arch/alpha/gen/__setjmp14.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/arch/alpha/gen/__longjmp14.c
diff -u src/lib/libc/arch/alpha/gen/__longjmp14.c:1.5 src/lib/libc/arch/alpha/gen/__longjmp14.c:1.5.24.1
--- src/lib/libc/arch/alpha/gen/__longjmp14.c:1.5	Mon Apr 28 20:22:55 2008
+++ src/lib/libc/arch/alpha/gen/__longjmp14.c	Thu Mar 14 22:36:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: __longjmp14.c,v 1.5 2008/04/28 20:22:55 martin Exp $	*/
+/*	$NetBSD: __longjmp14.c,v 1.5.24.1 2013/03/14 22:36:06 riz Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -74,6 +74,7 @@ __longjmp14(jmp_buf env, int val)
 	uc.uc_mcontext.__gregs[_REG_S5] = sc->sc_regs[R_S5];
 	uc.uc_mcontext.__gregs[_REG_S6] = sc->sc_regs[R_S6];
 	uc.uc_mcontext.__gregs[_REG_RA] = sc->sc_regs[R_RA];
+	uc.uc_mcontext.__gregs[_REG_GP] = sc->sc_regs[R_GP];
 	uc.uc_mcontext.__gregs[_REG_SP] = sc->sc_sp;
 	uc.uc_mcontext.__gregs[_REG_PC] = sc->sc_pc;
 	uc.uc_mcontext.__gregs[_REG_PS] =

Index: src/lib/libc/arch/alpha/gen/__setjmp14.S
diff -u src/lib/libc/arch/alpha/gen/__setjmp14.S:1.5 src/lib/libc/arch/alpha/gen/__setjmp14.S:1.5.4.1
--- src/lib/libc/arch/alpha/gen/__setjmp14.S:1.5	Sun Jun 12 05:44:36 2011
+++ src/lib/libc/arch/alpha/gen/__setjmp14.S	Thu Mar 14 22:36:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: __setjmp14.S,v 1.5 2011/06/12 05:44:36 matt Exp $ */
+/* $NetBSD: __setjmp14.S,v 1.5.4.1 2013/03/14 22:36:05 riz Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -55,6 +55,7 @@ LEAF(__setjmp14, 1)
 	stq	s6, (SC_REGS+_REG_S6)(a0)
 	stq	ra, (SC_REGS+_REG_RA)(a0)
 	stq	sp, (SC_REGS+_REG_SP)(a0)
+	stq	gp, (SC_REGS+_REG_GP)(a0)
 
 	/*
 	 * get signal information

Reply via email to