OSDN Git Service

PR boehm-gc/11412
[pf3gnuchains/gcc-fork.git] / boehm-gc / testsuite / boehm-gc.lib / staticrootstest.c
1 /* { dg-add-shlib "staticrootslib.c" } */
2
3 #include <stdio.h>
4
5 #ifndef GC_DEBUG
6 # define GC_DEBUG
7 #endif
8
9 #include "gc.h"
10 #include "gc_backptr.h"
11
12 struct treenode {
13     struct treenode *x;
14     struct treenode *y;
15 } * root[10];
16
17 static char *staticroot = 0;
18
19 extern struct treenode * libsrl_mktree(int i);
20 extern void * libsrl_init(void);
21 extern void * libsrl_collect (void);
22
23 int main(void)
24 {
25   int i;
26   staticroot = libsrl_init();
27   for (i = 0; i < sizeof(struct treenode); ++i) {
28     staticroot[i] = 0x42;
29   }
30   libsrl_collect();
31   for (i = 0; i < 10; ++i) {
32     root[i] = libsrl_mktree(12);
33     libsrl_collect();
34   }
35   for (i = 0; i < sizeof(struct treenode); ++i) {
36     if (staticroot[i] != 0x42)
37       return -1;
38   }
39   for (i = 0; i < 10; ++i) {
40     root[i] = libsrl_mktree(12);
41     libsrl_collect();
42   }
43   for (i = 0; i < sizeof(struct treenode); ++i) {
44     if (staticroot[i] != 0x42)
45       return -1;
46   }
47   return 0;
48 }