Tue Mar 12 04:57:57 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>

* setjmp/Makefile (tests): Add jmpbug.
	* setjmp/jmpbug.c: New file.
This commit is contained in:
Roland McGrath 1996-03-12 10:01:41 +00:00
parent 1177c8babf
commit 6c46dada59
6 changed files with 53 additions and 11 deletions

View File

@ -1,3 +1,8 @@
Tue Mar 12 04:57:57 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
* setjmp/Makefile (tests): Add jmpbug.
* setjmp/jmpbug.c: New file.
Tue Mar 12 04:42:01 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
* sysdeps/sparc/jmp_buf.h: Rewritten; use array of ints, not struct.

View File

@ -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

32
setjmp/jmpbug.c Normal file
View File

@ -0,0 +1,32 @@
/* setjmp vs alloca test case. Exercised bug on sparc. */
#include <stdio.h>
#include <setjmp.h>
#include <alloca.h>
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;
}

View File

@ -18,6 +18,7 @@ Cambridge, MA 02139, USA. */
#include <sysdep.h>
#define _ASM 1
#include <jmp_buf.h>
#define ENV(reg) [%g1 + (reg * 4)]

View File

@ -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])

View File

@ -17,6 +17,8 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <sysdep.h>
#define _ASM 1
#include <jmp_buf.h>
ENTRY (__sigsetjmp)