[project @ 2000-04-13 15:37:11 by panne]
authorpanne <unknown>
Thu, 13 Apr 2000 15:37:11 +0000 (15:37 +0000)
committerpanne <unknown>
Thu, 13 Apr 2000 15:37:11 +0000 (15:37 +0000)
StgStablePtr is now void*, as required by The Happy Bit Fiddlers

ghc/includes/HsFFI.h
ghc/includes/PrimOps.h
ghc/includes/Stable.h
ghc/includes/StgTypes.h

index a6b2673..17486b5 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: HsFFI.h,v 1.2 2000/04/06 13:40:15 panne Exp $
+ * $Id: HsFFI.h,v 1.3 2000/04/13 15:37:11 panne Exp $
  *
  * (c) The GHC Team, 2000
  *
@@ -60,7 +60,7 @@ typedef StgDouble             HsDouble;
 typedef StgBool                        HsBool;
 typedef void*                  HsAddr;         /* this should better match StgAddr */
 typedef void*                  HsForeignObj;   /* ... and this StgForeignPtr       */
-typedef void*                  HsStablePtr;    /* NOTE: THIS IS CURRENTLY WRONG!!! */
+typedef void*                  HsStablePtr;
 
 /* this should correspond to the type of StgChar in StgTypes.h */
 #define HS_CHAR_MIN            (0)
index 36011b4..c2457ab 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PrimOps.h,v 1.51 2000/04/12 17:12:23 simonmar Exp $
+ * $Id: PrimOps.h,v 1.52 2000/04/13 15:37:11 panne Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -700,12 +700,12 @@ EF_(makeStableNamezh_fast);
    r = RET_STGCALL1(StgStablePtr,getStablePtr,a)
 
 #define deRefStablePtrzh(r,sp) do {            \
-  ASSERT(stable_ptr_table[sp & ~STABLEPTR_WEIGHT_MASK].weight > 0);    \
-  r = stable_ptr_table[sp & ~STABLEPTR_WEIGHT_MASK].addr; \
+  ASSERT(stable_ptr_table[stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK].weight > 0);   \
+  r = stable_ptr_table[stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK].addr; \
 } while (0);
 
 #define eqStablePtrzh(r,sp1,sp2) \
-    (r = ((sp1 & ~STABLEPTR_WEIGHT_MASK) == (sp2 & ~STABLEPTR_WEIGHT_MASK)))
+    (r = ((stgCast(StgWord,sp1) & ~STABLEPTR_WEIGHT_MASK) == (stgCast(StgWord,sp2) & ~STABLEPTR_WEIGHT_MASK)))
 
 #endif
 
index 960ac27..c868504 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Stable.h,v 1.4 1999/03/02 19:44:16 sof Exp $
+ * $Id: Stable.h,v 1.5 2000/04/13 15:37:11 panne Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -35,28 +35,28 @@ 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
index 2e165df..4b367ac 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgTypes.h,v 1.10 2000/04/06 13:41:16 panne Exp $
+ * $Id: StgTypes.h,v 1.11 2000/04/13 15:37:11 panne Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -112,7 +112,7 @@ typedef StgWord            StgOffset;        /* byte offset within closure */
                            
 typedef struct StgTSO_*    StgTSOPtr;
 
-typedef void *             StgForeignPtr;
+typedef void*              StgForeignPtr;
 
 typedef StgInt             StgStackOffset;   /* offset in words! */
 
@@ -130,8 +130,12 @@ typedef StgWord64         LW_;
 /* Stable Pointers:  A stable pointer is represented as an index into
  * the stable pointer table in the low 24 bits with a weight in the
  * upper 8 bits.
+ * SUP: StgStablePtr used to be a synonym for StgWord, but stable pointers
+ * are guaranteed to be void* on the C-side, so we have to do some occasional
+ * casting. Size is not a matter, because StgWord is always the same size as
+ * a void*.
  */
-typedef StgWord            StgStablePtr;
+typedef void*             StgStablePtr;
 
 #define STABLEPTR_WEIGHT_MASK   ((StgWord)0xff << ((sizeof(StgWord)-1) * BITS_PER_BYTE))
 #define STABLEPTR_WEIGHT_SHIFT  (BITS_IN(StgWord) - 8)