summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorivmai <ivmai>2011-04-19 00:11:59 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:57 +0200
commit7a55f019e77692779a151ba6da816a39275ec50d (patch)
treeb88e1beb7999e99448f2f630e1d35cb9650b7de6 /tests
parent1178f485b6757985b906b7821cb458cba826f696 (diff)
2011-04-18 Ivan Maidanski <ivmai@mail.ru> (really Ludovic Courtes)
* tests/tests.am (TESTS, check_PROGRAMS): Add 'initsecondarythread'. * tests/tests.am (initsecondarythread_SOURCES, initsecondarythread_LDADD): New variable. * Makefile.in: Regenerate. * configure: Ditto.
Diffstat (limited to 'tests')
-rw-r--r--tests/initsecondarythread.c43
-rw-r--r--tests/tests.am5
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/initsecondarythread.c b/tests/initsecondarythread.c
new file mode 100644
index 0000000..feed560
--- /dev/null
+++ b/tests/initsecondarythread.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Ludovic Courtes <ludo@gnu.org>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+/* Make sure 'GC_INIT' can be called from threads other than the initial
+ * thread.
+ */
+
+#ifndef GC_THREADS
+# define GC_THREADS
+#endif
+
+#define GC_NO_THREAD_REDIRECTS 1
+
+#include "gc.h"
+
+#include <pthread.h>
+#include <stdlib.h>
+
+static void *thread(void *arg)
+{
+ GC_INIT ();
+ GC_MALLOC (123);
+ GC_MALLOC (12345);
+ return NULL;
+}
+
+int main(void)
+{
+ pthread_t t;
+ pthread_create (&t, NULL, thread, NULL);
+ pthread_join (t, NULL);
+ return 0;
+}
diff --git a/tests/tests.am b/tests/tests.am
index b655c2b..e773c45 100644
--- a/tests/tests.am
+++ b/tests/tests.am
@@ -67,6 +67,11 @@ TESTS += threadleaktest$(EXEEXT)
check_PROGRAMS += threadleaktest
threadleaktest_SOURCES = tests/thread_leak_test.c
threadleaktest_LDADD = $(test_ldadd)
+
+TESTS += initsecondarythread$(EXEEXT)
+check_PROGRAMS += initsecondarythread
+initsecondarythread_SOURCES = tests/initsecondarythread.c
+initsecondarythread_LDADD = $(test_ldadd)
endif
if CPLUSPLUS