1 /* Test 9 setjmp with register variables. Author: Ceriel Jacobs */
13 int main(int argc
, char *argv
[]);
36 if (argc
== 2) m
= atoi(argv
[1]);
37 for (j
= 0; j
< 100; j
++) {
38 if (m
& 00001) test9a();
39 if (m
& 00002) test9b();
40 if (m
& 00004) test9c();
41 if (m
& 00010) test9d();
42 if (m
& 00020) test9e();
43 if (m
& 00040) test9f();
47 if (setjmp(envm
) == 0) {
54 printf("WARNING: The setjmp/longjmp of this machine restore register variables\n\
55 to the value they had at the time of the Setjmp\n");
57 printf("Aha, I just found one last error\n");
62 return(-1); /* impossible */
110 if (p
!= &buf
[100]) e(1);
115 register char *p
, *q
;
121 if (p
!= &buf
[100]) e(1);
122 if (q
!= &buf
[200]) e(2);
127 register char *p
, *q
, *r
;
134 if (p
!= &buf
[100]) e(1);
135 if (q
!= &buf
[200]) e(2);
136 if (r
!= &buf
[300]) e(3);
141 /* return address of local variable.
142 This way we can check that the stack is not polluted.
155 register int i
, j
, k
;
156 register char *p
, *q
, *r
;
165 switch (setjmp(env
)) {
170 * to defeat the smartness of the GNU C optimizer we pretend we
171 * use 'a'. Otherwise the optimizer will not detect the looping
172 * effectuated by setjmp/longjmp, so that it thinks it can get
173 * rid of the assignment to 'a'.
183 if (p
!= &buf
[300]) e(14);
184 if (q
!= &buf
[400]) e(15);
185 if (r
!= &buf
[500]) e(16);
187 if (a
!= tmpa
) e(17);
194 if (p
!= &buf
[300]) e(24);
195 if (q
!= &buf
[400]) e(25);
196 if (r
!= &buf
[500]) e(26);
198 if (a
!= tmpa
) e(27);
205 if (p
!= &buf
[300]) e(34);
206 if (q
!= &buf
[400]) e(35);
207 if (r
!= &buf
[500]) e(36);
209 if (a
!= tmpa
) e(37);
215 if (p
!= &buf
[300]) e(44);
216 if (q
!= &buf
[400]) e(45);
217 if (r
!= &buf
[500]) e(46);
219 if (a
!= tmpa
) e(47);
239 * to defeat the smartness of the GNU C optimizer we pretend we
240 * use 'a'. Otherwise the optimizer will not detect the looping
241 * effectuated by setjmp/longjmp, so that it thinks it can get
242 * rid of the assignment to 'a'.
283 signal(SIGHUP
, catch);
284 for (p
= buf
; p
<= &buf
[511]; p
++) *p
= 025;
285 kill(getpid(), SIGHUP
);