implemented Setup.hs to build boehm cpp libs and install them;
[hs-boehmgc.git] / gc-7.2 / tests / staticrootstest.c
1
2 #include <stdio.h>
3 #include <string.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
22 /*
23 struct treenode * mktree(int i) {
24   struct treenode * r = GC_MALLOC(sizeof(struct treenode));
25   if (0 == i) return 0;
26   if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
27   r -> x = mktree(i-1);
28   r -> y = mktree(i-1);
29   return r;
30 }*/
31
32 int main(void)
33 {
34   int i;
35   /*GC_INIT();
36   staticroot = GC_MALLOC(sizeof(struct treenode));*/
37   staticroot = libsrl_init();
38   memset(staticroot, 0x42, sizeof(struct treenode));
39   GC_gcollect();
40   for (i = 0; i < 10; ++i) {
41     root[i] = libsrl_mktree(12);
42     GC_gcollect();
43   }
44   for (i = 0; i < (int)sizeof(struct treenode); ++i) {
45     if (staticroot[i] != 0x42)
46       return -1;
47   }
48   for (i = 0; i < 10; ++i) {
49     root[i] = libsrl_mktree(12);
50     GC_gcollect();
51   }
52   for (i = 0; i < (int)sizeof(struct treenode); ++i) {
53     if (staticroot[i] != 0x42)
54       return -1;
55   }
56   return 0;
57 }