+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.
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 ); */
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;
# 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();
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;
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;
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.