Debian Codegraph @

external/bdwgc/tests/staticrootslib.c

raw
1
2 /* This test file is intended to be compiled into a DLL. */
3
4 #ifndef GC_DEBUG
5 # define GC_DEBUG
6 #endif
7
8 #include "gc.h"
9
10 #ifndef GC_TEST_EXPORT_API
11 # if defined(GC_VISIBILITY_HIDDEN_SET) \
12 && !defined(__CEGCC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
13 # define GC_TEST_EXPORT_API \
14 extern __attribute__((__visibility__("default")))
15 # else
16 # define GC_TEST_EXPORT_API extern
17 # endif
18 #endif
19
20 struct treenode {
21 struct treenode *x;
22 struct treenode *y;
23 };
24
25 static struct treenode *root[10] = { 0 };
26 static struct treenode *root_nz[10] = { (struct treenode *)(GC_word)2 };
27
28 #ifdef STATICROOTSLIB2
29 # define libsrl_getpelem libsrl_getpelem2
30 #else
31
32 GC_TEST_EXPORT_API struct treenode * libsrl_mktree(int i)
33 {
34 struct treenode * r = GC_NEW(struct treenode);
35 if (0 == i)
36 return 0;
37 if (1 == i)
38 r = (struct treenode *)GC_MALLOC_ATOMIC(sizeof(struct treenode));
39 if (r) {
40 r -> x = libsrl_mktree(i-1);
41 r -> y = libsrl_mktree(i-1);
42 }
43 return r;
44 }
45
46 GC_TEST_EXPORT_API void * libsrl_init(void)
47 {
48 # ifndef STATICROOTSLIB_INIT_IN_MAIN
49 GC_INIT();
50 # endif
51 return GC_MALLOC(sizeof(struct treenode));
52 }
53
54 #endif /* !STATICROOTSLIB2 */
55
56 GC_TEST_EXPORT_API struct treenode ** libsrl_getpelem(int i, int j)
57 {
58 return &((j & 1) != 0 ? root_nz : root)[i];
59 }