Split GC.c, and move storage manager into sm/ directory
[ghc-hetmet.git] / rts / Stable.c
index 2391cb1..e5e8dfb 100644 (file)
@@ -19,6 +19,7 @@
 #include "RtsFlags.h"
 #include "OSThreads.h"
 #include "Trace.h"
+#include "Stable.h"
 
 /* Comment from ADR's implementation in old RTS:
 
@@ -159,6 +160,21 @@ initStablePtrTable(void)
 #endif
 }
 
+void
+exitStablePtrTable(void)
+{
+  if (addrToStableHash)
+    freeHashTable(addrToStableHash, NULL);
+  addrToStableHash = NULL;
+  if (stable_ptr_table)
+    stgFree(stable_ptr_table);
+  stable_ptr_table = NULL;
+  SPT_size = 0;
+#ifdef THREADED_RTS
+  closeMutex(&stable_mutex);
+#endif
+}
+
 /*
  * get at the real stuff...remove indirections.
  *
@@ -400,15 +416,15 @@ gcStablePtrTable( void )
                if (p->sn_obj == NULL) {
                    // StableName object is dead
                    freeStableName(p);
-                   debugTrace(DEBUG_stable, "GC'd Stable name %ld", 
-                              p - stable_ptr_table);
+                   debugTrace(DEBUG_stable, "GC'd Stable name %ld",
+                              (long)(p - stable_ptr_table));
                    continue;
                    
                } else {
                  p->addr = (StgPtr)isAlive((StgClosure *)p->addr);
                  debugTrace(DEBUG_stable, 
                             "stable name %ld still alive at %p, ref %ld\n",
-                            p - stable_ptr_table, p->addr, p->ref);
+                            (long)(p - stable_ptr_table), p->addr, p->ref);
                }
            }
        }