5 #endif /* not NOSIGNAL */
9 * A program to test setjmp(III) and longjmp,
10 * in particular with respect to register variables
26 if (nerrors) return nerrors;
29 if (setjmp(envm) == 0) {
35 printf("Setjmp/longjmp work ok, even with register variables\n");
38 printf("WARNING: The setjmp/longjmp of this machine restore register variables\n\
39 to the value they had at the time of the \"setjmp\"\n");
42 printf("Aha, I just found one last error\n");
51 fprintf(stderr,"Error %d in test %d\n",n,whichtest);
57 printf("TEST 1 : one integer register variable\n");
67 printf("TEST 2 : two integer register variables\n");
78 printf("TEST 3 : three integer register variables\n");
80 p = 200; q = 300; r = 400;
92 printf("TEST 4 : one pointer register variable\n");
96 if (p != &buf[100]) e(1);
102 printf("TEST 5 : two pointer register variables\n");
104 p = &buf[100]; q = &buf[200];
106 if (p != &buf[100]) e(1);
107 if (q != &buf[200]) e(2);
111 register char *p,*q,*r;
113 printf("TEST 6 : three pointer register variables\n");
115 p = &buf[100]; q = &buf[200]; r = &buf[300];
117 if (p != &buf[100]) e(1);
118 if (q != &buf[200]) e(2);
119 if (r != &buf[300]) e(3);
124 /* return address of local variable.
125 This way we can check that the stack is not polluted.
136 register char *p,*q,*r;
143 i = 10; j = 20; k = 30;
144 switch(setjmp(env)) {
153 if (p != &buf[300]) e(14);
154 if (q != &buf[400]) e(15);
155 if (r != &buf[500]) e(16);
164 if (p != &buf[300]) e(24);
165 if (q != &buf[400]) e(25);
166 if (r != &buf[500]) e(26);
174 if (p != &buf[300]) e(34);
175 if (q != &buf[400]) e(35);
176 if (r != &buf[500]) e(36);
184 if (p != &buf[300]) e(44);
185 if (q != &buf[400]) e(45);
186 if (r != &buf[500]) e(46);
230 printf(" signal caught\n");
237 signal(SIGHUP,catch);
238 for(p = buf;p <= &buf[511]; p++) *p = 025;
239 printf("Sending signal ...");
240 kill(getpid(),SIGHUP);
242 #endif /* not NOSIGNAL */