diff options
author | davek <davek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-05-06 16:20:53 +0000 |
---|---|---|
committer | davek <davek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-05-06 16:20:53 +0000 |
commit | 74c9c69994e4c51823569ce8df1e566909422a25 (patch) | |
tree | 91f7bcbe088102bbf76a8dbb8798ec9902aae6fd /boehm-gc/tests | |
parent | cc0a307f9b27e3173aae727f44ede494a8aa723d (diff) | |
download | gcc-74c9c69994e4c51823569ce8df1e566909422a25.tar.gz |
PR target/42811
* tests/staticrootstest.c: New test source file.
* tests/staticrootslib.c: New test library source file.
* Makefile.am (test_ldadd): New variable.
(gctest_LDADD): Use it.
(TESTS): Add leaktest, middletest and staticrootstest.
(check_PROGRAMS): Likewise.
(leaktest_SOURCES): New libtool variable definition.
(leaktest_LDADD): Likewise.
(leaktest_LDFLAGS): Likewise.
(leaktest_LINK): Likewise.
(middletest_SOURCES): Likewise.
(middletest_LDADD): Likewise.
(middletest_LDFLAGS): Likewise.
(middletest_LINK): Likewise.
(staticrootstest_SOURCES): Likewise.
(staticrootstest_LDADD): Likewise.
(staticrootstest_LDFLAGS): Likewise.
(staticrootstest_LINK): Likewise.
(check_LTLIBRARIES): Likewise.
(libstaticrootslib_la_SOURCES): Likewise.
(libstaticrootslib_la_LIBADD): Likewise.
(libstaticrootslib_la_LDFLAGS): Likewise.
(libstaticrootslib_la_DEPENDENCIES): Likewise.
* Makefile.in: Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159115 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'boehm-gc/tests')
-rw-r--r-- | boehm-gc/tests/staticrootslib.c | 33 | ||||
-rw-r--r-- | boehm-gc/tests/staticrootstest.c | 46 |
2 files changed, 79 insertions, 0 deletions
diff --git a/boehm-gc/tests/staticrootslib.c b/boehm-gc/tests/staticrootslib.c new file mode 100644 index 00000000000..6e13278a6c0 --- /dev/null +++ b/boehm-gc/tests/staticrootslib.c @@ -0,0 +1,33 @@ +#include <stdio.h> + +#ifndef GC_DEBUG +# define GC_DEBUG +#endif + +#include "gc.h" + +struct treenode { + struct treenode *x; + struct treenode *y; +} * root[10]; + +struct treenode * libsrl_mktree(int i) +{ + struct treenode * r = GC_MALLOC(sizeof(struct treenode)); + if (0 == i) return 0; + if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode)); + r -> x = libsrl_mktree(i-1); + r -> y = libsrl_mktree(i-1); + return r; +} + +void * libsrl_init(void) +{ + GC_INIT(); + return GC_MALLOC(sizeof(struct treenode)); +} + +void * libsrl_collect (void) +{ + GC_gcollect(); +} diff --git a/boehm-gc/tests/staticrootstest.c b/boehm-gc/tests/staticrootstest.c new file mode 100644 index 00000000000..68ff9eaea1e --- /dev/null +++ b/boehm-gc/tests/staticrootstest.c @@ -0,0 +1,46 @@ +#include <stdio.h> + +#ifndef GC_DEBUG +# define GC_DEBUG +#endif + +#include "gc.h" +#include "gc_backptr.h" + +struct treenode { + struct treenode *x; + struct treenode *y; +} * root[10]; + +static char *staticroot = 0; + +extern struct treenode * libsrl_mktree(int i); +extern void * libsrl_init(void); +extern void * libsrl_collect (void); + +int main(void) +{ + int i; + staticroot = libsrl_init(); + for (i = 0; i < sizeof(struct treenode); ++i) { + staticroot[i] = 0x42; + } + libsrl_collect(); + for (i = 0; i < 10; ++i) { + root[i] = libsrl_mktree(12); + libsrl_collect(); + } + for (i = 0; i < sizeof(struct treenode); ++i) { + if (staticroot[i] != 0x42) + return -1; + } + for (i = 0; i < 10; ++i) { + root[i] = libsrl_mktree(12); + libsrl_collect(); + } + for (i = 0; i < sizeof(struct treenode); ++i) { + if (staticroot[i] != 0x42) + return -1; + } + return 0; +} |