From 3184a232c112a73d0c6d9f16015df4924a1a666f Mon Sep 17 00:00:00 2001 From: art <> Date: Fri, 4 Jan 2002 13:48:52 +0000 Subject: Test _longjmp too. (Don't hate me for the '_' option). sigsetjmp should be tested too, but that wasn't as easy to fit in here (and it wasn't broken on alpha anyway). --- src/regress/lib/libc/longjmp/Makefile | 7 +++++++ src/regress/lib/libc/longjmp/longjmp.c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'src/regress/lib/libc') diff --git a/src/regress/lib/libc/longjmp/Makefile b/src/regress/lib/libc/longjmp/Makefile index 1444cd4374..d17a94182e 100644 --- a/src/regress/lib/libc/longjmp/Makefile +++ b/src/regress/lib/libc/longjmp/Makefile @@ -1,3 +1,10 @@ PROG= longjmp +do-longjmp: ${PROG} + ./longjmp +do-_longjmp: ${PROG} + ./longjmp -_ + +REGRESSTARGETS=do-longjmp do-_longjmp + .include diff --git a/src/regress/lib/libc/longjmp/longjmp.c b/src/regress/lib/libc/longjmp/longjmp.c index 4d8edb4716..9940dc5b9a 100644 --- a/src/regress/lib/libc/longjmp/longjmp.c +++ b/src/regress/lib/libc/longjmp/longjmp.c @@ -1,8 +1,11 @@ -/* $OpenBSD: longjmp.c,v 1.2 2002/01/04 13:33:17 art Exp $ */ +/* $OpenBSD: longjmp.c,v 1.3 2002/01/04 13:48:52 art Exp $ */ /* * Artur Grabowski Public Domain. */ +#include +#include +#include #include #include #include @@ -19,10 +22,29 @@ jmp_buf buf; * The rlimit is here in case we start spinning. */ int -main() +main(int argc, char **argv) { struct rlimit rl; volatile int i, expect; + int (*sj)(jmp_buf); + void (*lj)(jmp_buf, int); + int ch; + extern char *__progname; + + sj = setjmp; + lj = longjmp; + + while ((ch = getopt(argc, argv, "_")) != -1) { + switch (ch) { + case '_': + sj = _setjmp; + lj = _longjmp; + break; + default: + fprintf(stderr, "Usage: %s [-_]\n", __progname); + exit(1); + } + } rl.rlim_cur = 2; rl.rlim_max = 2; @@ -30,20 +52,20 @@ main() err(1, "setrlimit"); expect = 0; - i = setjmp(buf); + i = (*sj)(buf); if (i == 0 && expect != 0) errx(1, "setjmp returns 0 on longjmp(.., 0)"); if (expect == 0) { expect = -1; - longjmp(buf, 0); + (*lj)(buf, 0); } expect = 0; - i = setjmp(buf); + i = (*sj)(buf); if (i != expect) errx(1, "bad return from setjmp %d/%d", expect, i); if (expect < 1000) - longjmp(buf, expect += 2); + (*lj)(buf, expect += 2); return 0; } -- cgit v1.2.3-55-g6feb