Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libgc
diff options
context:
space:
mode:
authorPaolo Molaro <lupus@oddwiz.org>2006-02-02 12:39:47 +0300
committerPaolo Molaro <lupus@oddwiz.org>2006-02-02 12:39:47 +0300
commit1d2e52d593f0f061e0c50410470c9162642e2746 (patch)
tree33def4462e9ecb44a793a3515c10f6cd1fda8778 /libgc
parent639d7c0b7fcbc5f8d99a0b503ff87c748baab759 (diff)
Thu Feb 2 10:38:53 CET 2006 Paolo Molaro <lupus@ximian.com>
* pthread_support.c: make sure the proper cleanup also happens when using __thread vars. svn path=/branches/mono-1-1-13/mono/; revision=56438
Diffstat (limited to 'libgc')
-rw-r--r--libgc/ChangeLog6
-rw-r--r--libgc/pthread_support.c27
2 files changed, 25 insertions, 8 deletions
diff --git a/libgc/ChangeLog b/libgc/ChangeLog
index 0d2e7244d98..b38ab737155 100644
--- a/libgc/ChangeLog
+++ b/libgc/ChangeLog
@@ -1,3 +1,9 @@
+
+Thu Feb 2 10:38:53 CET 2006 Paolo Molaro <lupus@ximian.com>
+
+ * pthread_support.c: make sure the proper cleanup also happens
+ when using __thread vars.
+
2006-01-21 Martin Baulig <martin@ximian.com>
* include/Makefile.am: Don't install libgc-mono-debugger.h.
diff --git a/libgc/pthread_support.c b/libgc/pthread_support.c
index a5f164202b1..0cf6c74afc4 100644
--- a/libgc/pthread_support.c
+++ b/libgc/pthread_support.c
@@ -84,6 +84,12 @@
# if !defined(USE_PTHREAD_SPECIFIC) && !defined(USE_COMPILER_TLS)
# include "private/specific.h"
# endif
+
+/* Note that these macros should be used only to get/set the GC_thread pointer.
+ * We need to use both tls and pthread because we use the pthread_create function hook to
+ * free the data for foreign threads. When that doesn't happen, libgc could have old
+ * pthread_t that get reused...
+ */
# if defined(USE_PTHREAD_SPECIFIC)
# define GC_getspecific pthread_getspecific
# define GC_setspecific pthread_setspecific
@@ -91,10 +97,10 @@
typedef pthread_key_t GC_key_t;
# endif
# if defined(USE_COMPILER_TLS)
-# define GC_getspecific(x) (x)
-# define GC_setspecific(key, v) ((key) = (v), 0)
-# define GC_key_create(key, d) 0
- typedef void * GC_key_t;
+# define GC_getspecific(x) (GC_thread_tls)
+# define GC_setspecific(key, v) (GC_thread_tls = (v), pthread_setspecific ((key), (v)))
+# define GC_key_create pthread_key_create
+ typedef pthread_key_t GC_key_t;
# endif
# endif
# include <stdlib.h>
@@ -177,10 +183,11 @@ void GC_init_parallel();
#include "mono/utils/mono-compiler.h"
static
+GC_key_t GC_thread_key;
+
#ifdef USE_COMPILER_TLS
- __thread MONO_TLS_FAST
+static __thread MONO_TLS_FAST void* GC_thread_tls;
#endif
-GC_key_t GC_thread_key;
static GC_bool keys_initialized;
@@ -221,7 +228,8 @@ static void return_freelists(ptr_t *fl, ptr_t *gfl)
/* we arrange for those to fault asap.) */
static ptr_t size_zero_object = (ptr_t)(&size_zero_object);
-void GC_delete_thread(pthread_t id);
+void GC_delete_gc_thread(pthread_t id, GC_thread gct);
+void GC_destroy_thread_local(GC_thread p);
void GC_thread_deregister_foreign (void *data)
{
@@ -230,7 +238,10 @@ void GC_thread_deregister_foreign (void *data)
if (me -> flags & FOREIGN_THREAD) {
LOCK();
/* GC_fprintf0( "\n\n\n\n --- FOO ---\n\n\n\n\n" ); */
- GC_delete_thread(me->id);
+#if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)
+ GC_destroy_thread_local (me);
+#endif
+ GC_delete_gc_thread(me->id, me);
UNLOCK();
}
}