2005-02-05 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / io-layer / threads.c
index 31c1176a12c50b211a050bfb036fdbfcab095cb8..f464f0b94230e4f83d2dcb43c2636bb23e2aa0d9 100644 (file)
@@ -709,6 +709,12 @@ static pthread_key_t TLS_keys[TLS_MINIMUM_AVAILABLE];
 static gboolean TLS_used[TLS_MINIMUM_AVAILABLE]={FALSE};
 static guint32 TLS_spinlock=0;
 
+guint32
+mono_pthread_key_for_tls (guint32 idx)
+{
+       return (guint32)TLS_keys [idx];
+}
+
 /**
  * TlsAlloc:
  *
@@ -863,8 +869,10 @@ gboolean TlsSetValue(guint32 idx, gpointer value)
        }
        
 #if HAVE_BOEHM_GC
-       if (!tls_gc_hash)
+       if (!tls_gc_hash) {
+               MONO_GC_REGISTER_ROOT (tls_gc_hash);
                tls_gc_hash = mono_g_hash_table_new(g_direct_hash, g_direct_equal);
+       }
        mono_g_hash_table_insert (tls_gc_hash, MAKE_GC_ID (idx), value);
 #endif