-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlifetime.c
More file actions
88 lines (79 loc) · 1.53 KB
/
Copy pathlifetime.c
File metadata and controls
88 lines (79 loc) · 1.53 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <stdio.h>
void fgoto(unsigned n) {
unsigned j = 0;
unsigned* p = 0;
unsigned* q;
AGAIN:
if (p) printf("%u: p and q are %s, *p is %u\n",
j,
(q == p) ? "equal" : "unequal",
*p);
q = p;
p = &((unsigned){ j, });
++j;
if (j <= n) goto AGAIN;
}
void fgotoblock(unsigned n) {
unsigned j = 0;
unsigned* p = 0;
unsigned* q;
AGAIN:
{
if (p) printf("%u: p and q are %s, *p is %u\n",
j,
(q == p) ? "equal" : "unequal",
*p);
q = p;
p = &((unsigned){ j, });
++j;
if (j <= n) goto AGAIN;
}
}
__attribute__((noinline))
void ffor1(void) {
unsigned j = 1;
printf("%u: p and q are %s, *p is %u\n",
j,
"unequal",
j-1);
}
__attribute__((noinline))
void fforn(unsigned n) {
ffor1();
for (unsigned j = 2; j <= n; ++j) {
printf("%u: p and q are %s, *p is %u\n",
j,
"equal",
j-1);
}
}
void ffor(unsigned n) {
switch (n) {
case 0: break;
case 1: ffor1(); break;
default: fforn(n); break;
}
}
void fVLA(unsigned n) {
unsigned volatile j = 0;
unsigned* p = 0;
unsigned* q;
AGAIN:
{
if (p) printf("%u: p and q are %s\n",
j,
(q == p) ? "equal" : "unequal");
q = p;
unsigned VLA[j+1];
for (unsigned i = 0; i <= j; ++i)
VLA[i] = j;
p = VLA;
++j;
if (j <= n) goto AGAIN;
}
}
int main(int argc, char* argv[]) {
fgoto(argc+1);
fgotoblock(argc+1);
ffor(argc+1);
}