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:
authorZoltan Varga <vargaz@gmail.com>2006-02-01 17:26:05 +0300
committerZoltan Varga <vargaz@gmail.com>2006-02-01 17:26:05 +0300
commitb9d938c5f3ff2ba1050b645b521e6420900f8b5a (patch)
tree7fde6062153d1a62a961ef8e17e3343f92d9fea0 /libgc
parentab6c43e84a500fcf8c222d83daace840f224ead8 (diff)
2006-02-01 Zoltan Varga <vargaz@gmail.com>
* pthread_support.c (GC_thread_deregister_foreign): New public API function to deregister a foreign thread from the GC. (GC_destroy_thread_local): Clean up the TLS key too. svn path=/trunk/mono/; revision=56387
Diffstat (limited to 'libgc')
-rw-r--r--libgc/ChangeLog5
-rw-r--r--libgc/include/private/pthread_support.h2
-rw-r--r--libgc/pthread_support.c23
-rw-r--r--libgc/solaris_threads.c4
4 files changed, 30 insertions, 4 deletions
diff --git a/libgc/ChangeLog b/libgc/ChangeLog
index 4d9efc5f618..a28896bac03 100644
--- a/libgc/ChangeLog
+++ b/libgc/ChangeLog
@@ -1,4 +1,9 @@
+2006-02-01 Zoltan Varga <vargaz@gmail.com>
+ * pthread_support.c (GC_thread_deregister_foreign): New public API
+ function to deregister a foreign thread from the GC.
+ (GC_destroy_thread_local): Clean up the TLS key too.
+
Tue Jan 24 12:34:06 CET 2006 Paolo Molaro <lupus@ximian.com>
* *: update from upstream changes.
diff --git a/libgc/include/private/pthread_support.h b/libgc/include/private/pthread_support.h
index c2c48c22e01..b4a762b542c 100644
--- a/libgc/include/private/pthread_support.h
+++ b/libgc/include/private/pthread_support.h
@@ -92,7 +92,7 @@ extern GC_bool GC_thr_initialized;
GC_thread GC_lookup_thread(pthread_t id);
-void GC_thread_deregister_foreign (void *data);
+void GC_thread_deregister_foreign (void);
void GC_stop_init();
diff --git a/libgc/pthread_support.c b/libgc/pthread_support.c
index 97b204d32a0..cef3de4d917 100644
--- a/libgc/pthread_support.c
+++ b/libgc/pthread_support.c
@@ -223,7 +223,8 @@ static ptr_t size_zero_object = (ptr_t)(&size_zero_object);
void GC_delete_thread(pthread_t id);
-void GC_thread_deregister_foreign (void *data)
+/* Called by pthreads when the TLS entry is destroyed */
+static void GC_thread_deregister_foreign_internal (void *data)
{
GC_thread me = (GC_thread)data;
/* GC_fprintf1( "\n\n\n\n --- Deregister %x ---\n\n\n\n\n", me->flags ); */
@@ -243,7 +244,7 @@ void GC_init_thread_local(GC_thread p)
int i;
if (!keys_initialized) {
- if (0 != GC_key_create(&GC_thread_key, GC_thread_deregister_foreign)) {
+ if (0 != GC_key_create(&GC_thread_key, GC_thread_deregister_foreign_internal)) {
ABORT("Failed to create key for local allocator");
}
keys_initialized = TRUE;
@@ -283,6 +284,7 @@ void GC_destroy_thread_local(GC_thread p)
# ifdef GC_GCJ_SUPPORT
return_freelists(p -> gcj_freelists, GC_gcjobjfreelist);
# endif
+ GC_setspecific(GC_thread_key, NULL);
}
extern GC_PTR GC_generic_malloc_many();
@@ -671,7 +673,7 @@ void GC_delete_thread(pthread_t id)
int hv = ((word)id) % THREAD_TABLE_SZ;
register GC_thread p = GC_threads[hv];
register GC_thread prev = 0;
-
+
while (!pthread_equal(p -> id, id)) {
prev = p;
p = p -> next;
@@ -1301,6 +1303,21 @@ int GC_thread_register_foreign (void *base_addr)
return me != NULL;
}
+void GC_thread_deregister_foreign (void)
+{
+ GC_thread me;
+
+ LOCK ();
+ me = GC_lookup_thread (pthread_self ());
+ if (me->flags & FOREIGN_THREAD) {
+ GC_delete_thread (me->id);
+#if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)
+ GC_destroy_thread_local (me);
+#endif
+ }
+ UNLOCK ();
+}
+
void * GC_start_routine(void * arg)
{
int dummy;
diff --git a/libgc/solaris_threads.c b/libgc/solaris_threads.c
index 5c49c1206b8..a2f0a5d2aa1 100644
--- a/libgc/solaris_threads.c
+++ b/libgc/solaris_threads.c
@@ -641,6 +641,10 @@ int GC_thread_register_foreign (void *base_addr)
return 0;
}
+void GC_thread_deregister_foreign (void)
+{
+}
+
/* Solaris 2/Intel uses an initial stack size limit slightly bigger than the
SPARC default of 8 MB. Account for this to warn only if the user has
raised the limit beyond the default.