Bug 497723 - forgot to restore callgrind output cleanup
[valgrind.git] / dhat / tests / sig.c
blob64b0dbd94c283d6e42a331187a7a2f82b38f6905
1 // This test implements sorting of a tree involving a mix of significant and
2 // insignificant nodes. The layout of these functions matches the layout of
3 // the tree produced by dh_view.js, when sorted by "total bytes".
5 #include <stdlib.h>
7 #define F(f, parent) void* f(size_t n) { return parent(n); }
9 F(am, malloc)
10 // main
11 F(a2, am) // main
12 F(a3, am)
13 // main
14 // main
15 F(bm, malloc)
16 // main
17 F(b2, bm) // main
18 F(b3, bm)
19 // main
20 // main
21 F(cm, malloc)
22 // main
23 F(c2, cm) // main
24 F(c3, cm)
25 // main
26 // main
27 F(dm, malloc)
28 // main
29 F(d2, dm) // main
30 F(d3, dm)
31 // main
32 // main
34 char access(char* p, size_t n)
36 for (int i = 0; i < 1499; i++) {
37 for (int j = 0; j < n; j++) {
38 p[j] = j;
41 char x = 0;
42 for (int j = 0; j < n; j++) {
43 x += p[j];
45 return x;
48 int main(void)
51 char* p;
53 // Call all the leaves in the above tree. The pointers we pass to access()
54 // become significant in a high-access sort and insignificant in a
55 // zero-reads-or-zero-writes sort, and vice versa.
57 p = am(11); access(p, 11);
58 p = a2(10); access(p, 10);
59 p = a3(5); access(p, 5);
60 p = a3(4); access(p, 5);
62 p = bm(10); access(p, 10);
63 p = b2(9); access(p, 9);
64 p = b3(5);
65 p = b3(3);
67 p = cm(9); access(p, 9);
68 p = c2(8);
69 p = c3(4);
70 p = c3(3);
72 p = dm(8);
73 p = d2(7);
74 p = d3(4);
75 p = d3(2);