1 /* Test 9 setjmp with register variables. Author: Ceriel Jacobs */
14 int main(int argc
, char *argv
[]);
37 if (argc
== 2) m
= atoi(argv
[1]);
38 for (j
= 0; j
< 100; j
++) {
39 if (m
& 00001) test9a();
40 if (m
& 00002) test9b();
41 if (m
& 00004) test9c();
42 if (m
& 00010) test9d();
43 if (m
& 00020) test9e();
44 if (m
& 00040) test9f();
48 if (setjmp(envm
) == 0) {
55 printf("WARNING: The setjmp/longjmp of this machine restore register variables\n\
56 to the value they had at the time of the Setjmp\n");
58 printf("Aha, I just found one last error\n");
63 return(-1); /* impossible */
111 if (p
!= &buf
[100]) e(1);
116 register char *p
, *q
;
122 if (p
!= &buf
[100]) e(1);
123 if (q
!= &buf
[200]) e(2);
128 register char *p
, *q
, *r
;
135 if (p
!= &buf
[100]) e(1);
136 if (q
!= &buf
[200]) e(2);
137 if (r
!= &buf
[300]) e(3);
142 /* return address of local variable.
143 This way we can check that the stack is not polluted.
156 register int i
, j
, k
;
157 register char *p
, *q
, *r
;
166 switch (setjmp(env
)) {
171 * to defeat the smartness of the GNU C optimizer we pretend we
172 * use 'a'. Otherwise the optimizer will not detect the looping
173 * effectuated by setjmp/longjmp, so that it thinks it can get
174 * rid of the assignment to 'a'.
184 if (p
!= &buf
[300]) e(14);
185 if (q
!= &buf
[400]) e(15);
186 if (r
!= &buf
[500]) e(16);
188 if (a
!= tmpa
) e(17);
195 if (p
!= &buf
[300]) e(24);
196 if (q
!= &buf
[400]) e(25);
197 if (r
!= &buf
[500]) e(26);
199 if (a
!= tmpa
) e(27);
206 if (p
!= &buf
[300]) e(34);
207 if (q
!= &buf
[400]) e(35);
208 if (r
!= &buf
[500]) e(36);
210 if (a
!= tmpa
) e(37);
216 if (p
!= &buf
[300]) e(44);
217 if (q
!= &buf
[400]) e(45);
218 if (r
!= &buf
[500]) e(46);
220 if (a
!= tmpa
) e(47);
240 * to defeat the smartness of the GNU C optimizer we pretend we
241 * use 'a'. Otherwise the optimizer will not detect the looping
242 * effectuated by setjmp/longjmp, so that it thinks it can get
243 * rid of the assignment to 'a'.
284 signal(SIGHUP
, catch);
285 for (p
= buf
; p
<= &buf
[511]; p
++) *p
= 025;
286 kill(getpid(), SIGHUP
);