Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/tests/setjmptest.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 457 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 /*
2 * setjmptest.c
3 */
4
5 #include <stdio.h>
6 #include <setjmp.h>
7
8 static jmp_buf buf;
9
10 void do_stuff(int v)
11 {
12 printf("calling longjmp with %d... ", v + 1);
13 longjmp(buf, v + 1);
14 }
15
16 void recurse(int ctr, int v)
17 {
18 if (ctr--) {
19 recurse(ctr, v);
20 } else {
21 do_stuff(v);
22 }
23
24 printf("ERROR!\n"); /* We should never get here... */
25 }
26
27 int main(void)
28 {
29 int v;
30
31 v = setjmp(buf);
32 printf("setjmp returned %d\n", v);
33
34 if (v < 256)
35 recurse(v, v);
36
37 return 0;
38 }