blob: 3a2b7bcdf22ee741c2d0b045a0190097c9d007b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include <setjmp.h>
#include "test.h"
int reached;
void *
_jump(arg)
void *arg;
{
jmp_buf foo;
reached = 0;
if (_setjmp(foo)) {
ASSERT(reached);
return NULL;
}
reached = 1;
_longjmp(foo, 1);
PANIC("_longjmp");
}
void *
jump(arg)
void *arg;
{
jmp_buf foo;
reached = 0;
if (setjmp(foo)) {
ASSERT(reached);
return NULL;
}
reached = 1;
longjmp(foo, 1);
PANIC("longjmp");
}
int
main()
{
pthread_t child;
void *res;
printf("jumping in main thread\n");
(void)jump(NULL);
printf("_jumping in main thread\n");
(void)_jump(NULL);
printf("jumping in child thread\n");
CHECKr(pthread_create(&child, NULL, jump, NULL));
CHECKr(pthread_join(child, &res));
printf("_jumping in child thread\n");
CHECKr(pthread_create(&child, NULL, _jump, NULL));
CHECKr(pthread_join(child, &res));
SUCCEED;
}
|