[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gc] Calling ‘GC_INIT’ from a secondary thread
From: |
Ludovic Courtès |
Subject: |
Re: [Gc] Calling ‘GC_INIT’ from a secondary thread |
Date: |
Sun, 17 Apr 2011 21:49:10 +0200 |
User-agent: |
Gnus/5.110015 (No Gnus v0.15) Emacs/23.3 (gnu/linux) |
Hi Ivan,
Ivan Maidanski <address@hidden> writes:
> NP, I think. Just prepare a patch.
Here’s one, without the re-generated files.
Thanks,
Ludo’.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/ChangeLog,v
retrieving revision 1.467
diff -u -B -b -r1.467 ChangeLog
--- ChangeLog 16 Apr 2011 09:32:15 -0000 1.467
+++ ChangeLog 17 Apr 2011 19:46:58 -0000
@@ -1,3 +1,10 @@
+2011-04-17 Ludovic Courtès <address@hidden>
+
+ * tests/tests.am (TESTS, check_PROGRAMS)[THREADS]: Add
+ `initsecondarythread'.
+ (initsecondarythread_SOURCES)
+ (initsecondarythread_LDADD)[THREADS]: New variables.
+
2011-04-16 Ivan Maidanski <address@hidden>
* os_dep.c (GC_get_main_stack_base): Try to use
Index: tests/tests.am
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/tests/tests.am,v
retrieving revision 1.9
diff -u -B -b -r1.9 tests.am
--- tests/tests.am 23 Mar 2010 07:53:03 -0000 1.9
+++ tests/tests.am 17 Apr 2011 19:47:25 -0000
@@ -67,6 +67,11 @@
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
--- /dev/null 2011-04-15 17:57:42.483006363 +0200
+++ tests/initsecondarythread.c 2011-04-17 21:48:31.000000000 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011 Ludovic Courtès <address@hidden>
+ *
+ * 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. See
+ *
<http://article.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/4490>
+ * for the original report. */
+
+#if defined(__sun__) || defined(sun)
+
+/* Solaris expects `GC_INIT' to be called from the main thread, so skip this
+ * test. */
+
+int main(int argc, char *argv[])
+{
+ /* Skip. */
+ return 77;
+}
+
+#else /* ! __sun__ */
+
+#define GC_THREADS 1
+#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(int argc, char *argv[])
+{
+ pthread_t t;
+
+ pthread_create (&t, NULL, thread, NULL);
+ pthread_join (t, NULL);
+
+ return EXIT_SUCCESS;
+}
+
+#endif /* ! __sun__ */