From 6c46dada59a56f8748f6d956ef5d318155195840 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 12 Mar 1996 10:01:41 +0000 Subject: [PATCH] Tue Mar 12 04:57:57 1996 Roland McGrath * setjmp/Makefile (tests): Add jmpbug. * setjmp/jmpbug.c: New file. --- ChangeLog | 5 +++++ setjmp/Makefile | 2 +- setjmp/jmpbug.c | 32 ++++++++++++++++++++++++++++++++ sysdeps/sparc/__longjmp.S | 1 + sysdeps/sparc/jmp_buf.h | 22 ++++++++++++---------- sysdeps/sparc/setjmp.S | 2 ++ 6 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 setjmp/jmpbug.c diff --git a/ChangeLog b/ChangeLog index e94bfeea0b..b31a0fbcc7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 12 04:57:57 1996 Roland McGrath + + * setjmp/Makefile (tests): Add jmpbug. + * setjmp/jmpbug.c: New file. + Tue Mar 12 04:42:01 1996 Roland McGrath * sysdeps/sparc/jmp_buf.h: Rewritten; use array of ints, not struct. diff --git a/setjmp/Makefile b/setjmp/Makefile index 4773b617e1..3d004852c8 100644 --- a/setjmp/Makefile +++ b/setjmp/Makefile @@ -26,7 +26,7 @@ headers := setjmp.h jmp_buf.h routines := setjmp sigjmp bsd-setjmp bsd-_setjmp \ longjmp __longjmp jmp-unwind -tests := tst-setjmp +tests := tst-setjmp jmpbug include ../Rules diff --git a/setjmp/jmpbug.c b/setjmp/jmpbug.c new file mode 100644 index 0000000000..57a1de0978 --- /dev/null +++ b/setjmp/jmpbug.c @@ -0,0 +1,32 @@ +/* setjmp vs alloca test case. Exercised bug on sparc. */ + +#include +#include +#include + +void +sub5 (jmp_buf buf) +{ + longjmp (buf, 1); +} + +int +main (void) +{ + jmp_buf buf; + char *foo; + int arr[100]; + + arr[77] = 76; + if (setjmp (buf)) + { + printf ("made it ok; %d\n", arr[77]); + exit (0); + } + + foo = (char *) alloca (128); + sub5 (buf); + + /* NOTREACHED */ + return 1; +} diff --git a/sysdeps/sparc/__longjmp.S b/sysdeps/sparc/__longjmp.S index 38bc7bbac8..5424300fe5 100644 --- a/sysdeps/sparc/__longjmp.S +++ b/sysdeps/sparc/__longjmp.S @@ -18,6 +18,7 @@ Cambridge, MA 02139, USA. */ #include +#define _ASM 1 #include #define ENV(reg) [%g1 + (reg * 4)] diff --git a/sysdeps/sparc/jmp_buf.h b/sysdeps/sparc/jmp_buf.h index a5a592fd47..43bae1a496 100644 --- a/sysdeps/sparc/jmp_buf.h +++ b/sysdeps/sparc/jmp_buf.h @@ -1,14 +1,16 @@ /* Define the machine-dependent type `jmp_buf'. SPARC version. */ -/* NOTE: The assembly code in __longjmp.S and setjmp.S knows the layout - of this structure. You must hack the assembly code if you want to change - the order of the members. */ +#if defined (__USE_MISC) || defined (_ASM) +#define JB_SP 0 +#define JB_FP 1 +#define JB_PC 2 +#endif -typedef struct - { - /* Return PC (register o7). */ - __ptr_t __pc; +#ifndef _ASM +typedef int __jmp_buf[3]; +#endif - /* Saved FP. */ - __ptr_t __fp; - } __jmp_buf[1]; +/* Test if longjmp to JMPBUF would unwind the frame + containing a local variable at ADDRESS. */ +#define _JMPBUF_UNWINDS(jmpbuf, address) \ + ((int) (address) < (jmpbuf)[JB_SP]) diff --git a/sysdeps/sparc/setjmp.S b/sysdeps/sparc/setjmp.S index 2cf92cddd7..db8a3c2916 100644 --- a/sysdeps/sparc/setjmp.S +++ b/sysdeps/sparc/setjmp.S @@ -17,6 +17,8 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include + +#define _ASM 1 #include ENTRY (__sigsetjmp)