StgStablePtr is now void*, as required by The Happy Bit Fiddlers
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $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
*
*
* (c) The GHC Team, 2000
*
typedef StgBool HsBool;
typedef void* HsAddr; /* this should better match StgAddr */
typedef void* HsForeignObj; /* ... and this StgForeignPtr */
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)
/* this should correspond to the type of StgChar in StgTypes.h */
#define HS_CHAR_MIN (0)
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $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
*
*
* (c) The GHC Team, 1998-1999
*
r = RET_STGCALL1(StgStablePtr,getStablePtr,a)
#define deRefStablePtrzh(r,sp) do { \
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) \
} 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)))
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $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
*
*
* (c) The GHC Team, 1998-1999
*
extern inline StgPtr
deRefStablePtr(StgStablePtr sp)
{
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)
{
}
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);
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 */
}
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
}
/* No deRefStableName, because the existence of a stable name doesn't
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $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
*
*
* (c) The GHC Team, 1998-1999
*
typedef struct StgTSO_* StgTSOPtr;
typedef struct StgTSO_* StgTSOPtr;
-typedef void * StgForeignPtr;
+typedef void* StgForeignPtr;
typedef StgInt StgStackOffset; /* offset in words! */
typedef StgInt StgStackOffset; /* offset in words! */
/* 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.
/* 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)
#define STABLEPTR_WEIGHT_MASK ((StgWord)0xff << ((sizeof(StgWord)-1) * BITS_PER_BYTE))
#define STABLEPTR_WEIGHT_SHIFT (BITS_IN(StgWord) - 8)