svn commit: r204676 - in user/jmallett/octeon: lib/libc/mips/gen
sys/mips/include
Juli Mallett
jmallett at FreeBSD.org
Wed Mar 3 22:42:16 UTC 2010
Author: jmallett
Date: Wed Mar 3 22:42:15 2010
New Revision: 204676
URL: http://svn.freebsd.org/changeset/base/204676
Log:
o) Store gp in the jmpbuf for n32 and n64.
o) Attempt to make PIC- and N32-friendly *setjmp.
Modified:
user/jmallett/octeon/lib/libc/mips/gen/_setjmp.S
user/jmallett/octeon/lib/libc/mips/gen/setjmp.S
user/jmallett/octeon/lib/libc/mips/gen/sigsetjmp.S
user/jmallett/octeon/sys/mips/include/asm.h
user/jmallett/octeon/sys/mips/include/setjmp.h
Modified: user/jmallett/octeon/lib/libc/mips/gen/_setjmp.S
==============================================================================
--- user/jmallett/octeon/lib/libc/mips/gen/_setjmp.S Wed Mar 3 21:59:45 2010 (r204675)
+++ user/jmallett/octeon/lib/libc/mips/gen/_setjmp.S Wed Mar 3 22:42:15 2010 (r204676)
@@ -1,4 +1,4 @@
-/* $NetBSD: _setjmp.S,v 1.20 2005/10/07 17:16:40 tsutsui Exp $ */
+/* $NetBSD: _setjmp.S,v 1.20.34.5 2010/02/03 23:46:47 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -36,14 +36,15 @@
__FBSDID("$FreeBSD$");
#include <machine/regnum.h>
-#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)_setjmp.s 8.1 (Berkeley) 6/4/93")
- ASMSTR("$NetBSD: _setjmp.S,v 1.20 2005/10/07 17:16:40 tsutsui Exp $")
-#endif /* LIBC_SCCS and not lint */
+#include "SYS.h"
-#ifdef __ABICALLS__
- .abicalls
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+ RCSID("from: @(#)_setjmp.s 8.1 (Berkeley) 6/4/93")
+#else
+ RCSID("$NetBSD: _setjmp.S,v 1.20.34.5 2010/02/03 23:46:47 matt Exp $")
#endif
+#endif /* LIBC_SCCS and not lint */
/*
* C library -- _setjmp, _longjmp
@@ -56,15 +57,11 @@ __FBSDID("$FreeBSD$");
* The previous signal state is NOT restored.
*/
+ .set noreorder
LEAF(_setjmp)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- subu sp, sp, CALLFRAME_SIZ # allocate stack frame
- .cprestore 16
-#endif
- li v0, _JB_MAGIC__SETJMP
+ REG_PROLOGUE
+ REG_LI v0, _JB_MAGIC__SETJMP
REG_S v0, (_JB_MAGIC * SZREG)(a0)
REG_S ra, (_JB_REG_RA * SZREG)(a0)
REG_S s0, (_JB_REG_S0 * SZREG)(a0)
@@ -76,42 +73,57 @@ LEAF(_setjmp)
REG_S s6, (_JB_REG_S6 * SZREG)(a0)
REG_S s7, (_JB_REG_S7 * SZREG)(a0)
REG_S s8, (_JB_REG_S8 * SZREG)(a0)
-#ifdef __ABICALLS__
- addu sp, sp, CALLFRAME_SIZ # un-allocate the stack frame
-#endif
+#if defined(__mips_n32) || defined(__mips_n64)
+ REG_S gp, (_JB_REG_GP * SZREG)(a0) # newabi gp is callee-saved
+#endif
REG_S sp, (_JB_REG_SP * SZREG)(a0)
+ REG_EPILOGUE
+
j ra
move v0, zero
END(_setjmp)
LEAF(_longjmp)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- subu sp, sp, CALLFRAME_SIZ # allocate stack frame
- .cprestore 16
-#endif
- REG_L v0, (_JB_MAGIC * SZREG)(a0)
- REG_L ra, (_JB_REG_RA * SZREG)(a0)
- li t0, _JB_MAGIC__SETJMP
- bne v0, t0, botch # jump if error
- REG_L s0, (_JB_REG_S0 * SZREG)(a0)
- REG_L s1, (_JB_REG_S1 * SZREG)(a0)
- REG_L s2, (_JB_REG_S2 * SZREG)(a0)
- REG_L s3, (_JB_REG_S3 * SZREG)(a0)
- REG_L s4, (_JB_REG_S4 * SZREG)(a0)
- REG_L s5, (_JB_REG_S5 * SZREG)(a0)
- REG_L s6, (_JB_REG_S6 * SZREG)(a0)
- REG_L s7, (_JB_REG_S7 * SZREG)(a0)
- REG_L sp, (_JB_REG_SP * SZREG)(a0)
- REG_L s8, (_JB_REG_S8 * SZREG)(a0)
+ PIC_PROLOGUE(_longjmp)
+ PTR_SUBU sp, sp, CALLFRAME_SIZ
+ SAVE_GP(CALLFRAME_GP)
+
+ REG_PROLOGUE
+ REG_L v0, (_JB_MAGIC * SZREG)(a0) # get magic number
+ REG_L ra, (_JB_REG_RA * SZREG)(a0)
+ REG_LI t0, _JB_MAGIC__SETJMP
+ bne v0, t0, botch # jump if error
+ PTR_ADDU sp, sp, CALLFRAME_SIZ # does not matter, sanity
+ REG_L s0, (_JB_REG_S0 * SZREG)(a0)
+ REG_L s1, (_JB_REG_S1 * SZREG)(a0)
+ REG_L s2, (_JB_REG_S2 * SZREG)(a0)
+ REG_L s3, (_JB_REG_S3 * SZREG)(a0)
+ REG_L s4, (_JB_REG_S4 * SZREG)(a0)
+ REG_L s5, (_JB_REG_S5 * SZREG)(a0)
+ REG_L s6, (_JB_REG_S6 * SZREG)(a0)
+ REG_L s7, (_JB_REG_S7 * SZREG)(a0)
+#if defined(__mips_n32) || defined(__mips_n64)
+ REG_L gp, (_JB_REG_GP * SZREG)(a0)
+#endif
+ REG_L sp, (_JB_REG_SP * SZREG)(a0)
+ REG_L s8, (_JB_REG_S8 * SZREG)(a0)
+ REG_EPILOGUE
+ move v0, a1 # get return value in 1st arg
j ra
- move v0, a1
+ nop
botch:
- jal _C_LABEL(longjmperror)
+ /*
+ * We know we aren't returning so we don't care about restoring
+ * our caller's GP.
+ */
+ PTR_LA t9, _C_LABEL(longjmperror)
+ jalr t9
nop
- jal _C_LABEL(abort)
+
+ PIC_TAILCALL(abort)
+ PTR_LA t9, _C_LABEL(abort)
+ jal t9
nop
END(_longjmp)
Modified: user/jmallett/octeon/lib/libc/mips/gen/setjmp.S
==============================================================================
--- user/jmallett/octeon/lib/libc/mips/gen/setjmp.S Wed Mar 3 21:59:45 2010 (r204675)
+++ user/jmallett/octeon/lib/libc/mips/gen/setjmp.S Wed Mar 3 22:42:15 2010 (r204676)
@@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$");
ASMSTR("$NetBSD: setjmp.S,v 1.17 2005/09/17 11:49:39 tsutsui Exp $")
#endif /* LIBC_SCCS and not lint */
+#include "SYS.h"
+
#ifdef __ABICALLS__
.abicalls
#endif
@@ -61,30 +63,28 @@ __FBSDID("$FreeBSD$");
NESTED(setjmp, SETJMP_FRAME_SIZE, ra)
.mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
- .set noreorder
-#ifdef __ABICALLS__
- .cpload t9
-#endif
- subu sp, sp, SETJMP_FRAME_SIZE # allocate stack frame
-#ifdef __ABICALLS__
- .cprestore 16
-#endif
+ SETUP_GP
+ PTR_SUBU sp, sp, SETJMP_FRAME_SIZE # allocate stack frame
+ SAVE_GP(CALLFRAME_GP)
+ SETUP_GP64(CALLFRAME_GP, setjmp)
+
REG_S ra, CALLFRAME_RA(sp) # save RA
REG_S a0, CALLFRAME_SIZ(sp) # store env
/* Get the signal mask. */
- addu a2, a0, _JB_SIGMASK * SZREG # &oenv
+ PTR_ADDU a2, a0, _JB_SIGMASK * SZREG # &oenv
li a0, 1 # SIG_SETBLOCK
move a1, zero # &env == 0
- la t9, _C_LABEL(sigprocmask) # get current signal mask
- jal t9
- nop
+ PTR_LA t9, _C_LABEL(sigprocmask) # get current signal mask
+ jalr t9
+ RESTORE_GP64
REG_L a0, CALLFRAME_SIZ(sp) # restore env pointer
REG_L ra, CALLFRAME_RA(sp) # restore RA
- addu sp, sp, SETJMP_FRAME_SIZE # pop stack frame
+ PTR_ADDU sp, sp, SETJMP_FRAME_SIZE # pop stack frame
- li v0, _JB_MAGIC_SETJMP
+ REG_PROLOGUE
+ REG_LI v0, _JB_MAGIC_SETJMP
REG_S v0, (_JB_MAGIC * SZREG)(a0)
REG_S ra, (_JB_REG_RA * SZREG)(a0)
REG_S s0, (_JB_REG_S0 * SZREG)(a0)
@@ -97,26 +97,23 @@ NESTED(setjmp, SETJMP_FRAME_SIZE, ra)
REG_S s7, (_JB_REG_S7 * SZREG)(a0)
REG_S sp, (_JB_REG_SP * SZREG)(a0)
REG_S s8, (_JB_REG_S8 * SZREG)(a0)
+ REG_S gp, (_JB_REG_GP * SZREG)(a0)
+ REG_EPILOGUE
move v0, zero
- j ra
END(setjmp)
#define LONGJMP_FRAME_SIZE (CALLFRAME_SIZ + (SZREG * 2))
NESTED(longjmp, LONGJMP_FRAME_SIZE, ra)
.mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
- .set noreorder
-#ifdef __ABICALLS__
- .cpload t9
-#endif
- subu sp, sp, LONGJMP_FRAME_SIZE # allocate stack frame
-#ifdef __ABICALLS__
- .cprestore 16
-#endif
+ PIC_PROLOGUE(longjmp)
+ PTR_SUBU sp, sp, LONGJMP_FRAME_SIZE # allocate stack frame
+ SAVE_GP(CALLFRAME_GP)
+
REG_S ra, CALLFRAME_RA(sp) # save RA
REG_L v0, (_JB_MAGIC * SZREG)(a0)
- li t0, _JB_MAGIC_SETJMP
+ REG_LI t0, _JB_MAGIC_SETJMP
bne v0, t0, botch # jump if error
nop
@@ -124,16 +121,17 @@ NESTED(longjmp, LONGJMP_FRAME_SIZE, ra)
REG_S a1, (CALLFRAME_SIZ + SZREG)(sp) # save return value
# set sigmask
- addu a1, a0, _JB_SIGMASK * SZREG # &set
+ PTR_ADDU a1, a0, _JB_SIGMASK * SZREG # &set
move a2, zero # &oset == NULL
li a0, 3 # SIG_SETMASK
- la t9,_C_LABEL(sigprocmask) # set current signal mask
+ PTR_LA t9,_C_LABEL(sigprocmask) # set current signal mask
jal t9
nop
REG_L a0, CALLFRAME_SIZ(sp) # restore env
REG_L a1, (CALLFRAME_SIZ + SZREG)(sp) # restore return value
+ REG_PROLOGUE
REG_L ra, (_JB_REG_RA * SZREG)(a0)
REG_L s0, (_JB_REG_S0 * SZREG)(a0)
REG_L s1, (_JB_REG_S1 * SZREG)(a0)
@@ -145,16 +143,24 @@ NESTED(longjmp, LONGJMP_FRAME_SIZE, ra)
REG_L s7, (_JB_REG_S7 * SZREG)(a0)
REG_L sp, (_JB_REG_SP * SZREG)(a0)
REG_L s8, (_JB_REG_S8 * SZREG)(a0)
+ REG_L gp, (_JB_REG_GP * SZREG)(a0)
+
+ REG_EPILOGUE
move v0, a1
j ra
nop
botch:
- la t9, _C_LABEL(longjmperror)
- jal t9
+ /*
+ * We know we aren't returning so we don't care about restoring
+ * our caller's GP.
+ */
+ PTR_LA t9, _C_LABEL(longjmperror)
+ jalr t9
nop
- la t9, _C_LABEL(abort)
+ PIC_TAILCALL(abort)
+ PTR_LA t9, _C_LABEL(abort)
jal t9
nop
END(longjmp)
Modified: user/jmallett/octeon/lib/libc/mips/gen/sigsetjmp.S
==============================================================================
--- user/jmallett/octeon/lib/libc/mips/gen/sigsetjmp.S Wed Mar 3 21:59:45 2010 (r204675)
+++ user/jmallett/octeon/lib/libc/mips/gen/sigsetjmp.S Wed Mar 3 22:42:15 2010 (r204676)
@@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$");
ASMSTR("$NetBSD: sigsetjmp.S,v 1.8 2005/09/17 11:49:39 tsutsui Exp $")
#endif /* LIBC_SCCS and not lint */
+#include "SYS.h"
+
#ifdef __ABICALLS__
.abicalls
#endif
@@ -57,30 +59,19 @@ __FBSDID("$FreeBSD$");
*/
LEAF(sigsetjmp)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
+ PIC_PROLOGUE(sigsetjmp)
+
bne a1, 0x0, 1f # do saving of signal mask?
- la t9, _setjmp
- jr t9
+ PIC_TAILCALL(_setjmp)
-1: la t9, setjmp
- jr t9
+1: PIC_TAILCALL(setjmp)
END(sigsetjmp)
LEAF(siglongjmp)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
+ PIC_PROLOGUE(siglongjmp)
REG_L t0, (_JB_MAGIC * SZREG)(a0)
- li t1, _JB_MAGIC__SETJMP
+ REG_LI t1, _JB_MAGIC__SETJMP
bne t0, t1, 1f # setjmp or _setjmp magic?
- la t9, _longjmp
- jr t9
-1: la t9, longjmp
- jr t9
+ PIC_TAILCALL(_longjmp)
+1: PIC_TAILCALL(longjmp)
END(siglongjmp)
Modified: user/jmallett/octeon/sys/mips/include/asm.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/asm.h Wed Mar 3 21:59:45 2010 (r204675)
+++ user/jmallett/octeon/sys/mips/include/asm.h Wed Mar 3 22:42:15 2010 (r204676)
@@ -782,10 +782,11 @@ _C_LABEL(x):
* 9 S7
* 10 SP
* 11 S8
- * 12 signal mask (dependant on magic)
- * 13 (con't)
+ * 12 GP (dependent on ABI)
+ * 13 signal mask (dependant on magic)
* 14 (con't)
* 15 (con't)
+ * 16 (con't)
*
* The magic number number identifies the jmp_buf and
* how the buffer was created as well as providing
@@ -810,9 +811,12 @@ _C_LABEL(x):
#define _JB_REG_S7 9
#define _JB_REG_SP 10
#define _JB_REG_S8 11
+#if defined(__mips_n32) || defined(__mips_n64)
+#define _JB_REG_GP 12
+#endif
/* Only valid with the _JB_MAGIC_SETJMP magic */
-#define _JB_SIGMASK 12
+#define _JB_SIGMASK 13
#endif /* !_MACHINE_ASM_H_ */
Modified: user/jmallett/octeon/sys/mips/include/setjmp.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/setjmp.h Wed Mar 3 21:59:45 2010 (r204675)
+++ user/jmallett/octeon/sys/mips/include/setjmp.h Wed Mar 3 22:42:15 2010 (r204676)
@@ -39,7 +39,7 @@
#include <sys/cdefs.h>
-#define _JBLEN 95 /* size, in longs, of a jmp_buf */
+#define _JBLEN 95 /* size, in longs (or long longs), of a jmp_buf */
/*
* jmp_buf and sigjmp_buf are encapsulated in different structs to force
More information about the svn-src-user
mailing list