[project @ 2000-04-19 09:59:55 by panne]
[ghc-hetmet.git] / ghc / includes / Stable.h
index 4552439..c868504 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Stable.h,v 1.2 1999/02/05 16:02:28 simonm Exp $
+ * $Id: Stable.h,v 1.5 2000/04/13 15:37:11 panne Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -22,41 +22,41 @@ extern StgStablePtr   splitStablePtr(StgStablePtr sp);
 extern StgStablePtr getStablePtr(StgPtr p);
 
 typedef struct { 
-  StgPtr  addr;                        /* either Haskell object or free list */
+  StgPtr  addr;                        /* Haskell object, free list, or NULL */
   StgWord weight;              /* used for reference counting */
-  unsigned int keep;           /* set by the garbage collector */
+  StgClosure *sn_obj;          /* the StableName object (or NULL) */
 } snEntry;
 
-extern snEntry *stable_ptr_table;
-extern snEntry *stable_ptr_free;
+extern DLL_IMPORT_RTS snEntry *stable_ptr_table;
+extern DLL_IMPORT_RTS snEntry *stable_ptr_free;
 
-extern unsigned int SPT_size;
+extern DLL_IMPORT_RTS unsigned int SPT_size;
 
 extern inline StgPtr
 deRefStablePtr(StgStablePtr sp)
 {
-  ASSERT(stable_ptr_table[sp & ~STABLEPTR_WEIGHT_MASK].weight > 0);
-  return stable_ptr_table[sp & ~STABLEPTR_WEIGHT_MASK].addr;
+  ASSERT(stable_ptr_table[stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK].weight > 0);
+  return stable_ptr_table[stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK].addr;
 }
 
 extern inline void
 freeStablePtr(StgStablePtr sp)
 {
-  StgWord sn = sp & ~STABLEPTR_WEIGHT_MASK;
+  StgWord sn = stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK;
   
   ASSERT(sn < SPT_size
         && stable_ptr_table[sn].addr != NULL
         && stable_ptr_table[sn].weight > 0);
   
-  stable_ptr_table[sn].weight += (sp & STABLEPTR_WEIGHT_MASK) >> STABLEPTR_WEIGHT_SHIFT;
+  stable_ptr_table[sn].weight += (stgCast(StgWord,sp) & STABLEPTR_WEIGHT_MASK) >> STABLEPTR_WEIGHT_SHIFT;
 }
 
 extern inline StgStablePtr
 splitStablePtr(StgStablePtr sp)
 {
   /* doesn't need access to the stable pointer table */
-  StgWord weight = (sp & STABLEPTR_WEIGHT_MASK) / 2;
-  return (sp & ~STABLEPTR_WEIGHT_MASK) + weight;
+  StgWord weight = (stgCast(StgWord,sp) & STABLEPTR_WEIGHT_MASK) / 2;
+  return stgCast(StgStablePtr,(stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK) + weight);
 }
 
 /* No deRefStableName, because the existence of a stable name doesn't