From 4bba3f6ef0d8b637118383cf2a9944341f0678f1 Mon Sep 17 00:00:00 2001 From: panne Date: Thu, 13 Apr 2000 15:37:11 +0000 Subject: [PATCH] [project @ 2000-04-13 15:37:11 by panne] StgStablePtr is now void*, as required by The Happy Bit Fiddlers --- ghc/includes/HsFFI.h | 4 ++-- ghc/includes/PrimOps.h | 8 ++++---- ghc/includes/Stable.h | 14 +++++++------- ghc/includes/StgTypes.h | 10 +++++++--- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ghc/includes/HsFFI.h b/ghc/includes/HsFFI.h index a6b2673..17486b5 100644 --- a/ghc/includes/HsFFI.h +++ b/ghc/includes/HsFFI.h @@ -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) diff --git a/ghc/includes/PrimOps.h b/ghc/includes/PrimOps.h index 36011b4..c2457ab 100644 --- a/ghc/includes/PrimOps.h +++ b/ghc/includes/PrimOps.h @@ -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 diff --git a/ghc/includes/Stable.h b/ghc/includes/Stable.h index 960ac27..c868504 100644 --- a/ghc/includes/Stable.h +++ b/ghc/includes/Stable.h @@ -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 diff --git a/ghc/includes/StgTypes.h b/ghc/includes/StgTypes.h index 2e165df..4b367ac 100644 --- a/ghc/includes/StgTypes.h +++ b/ghc/includes/StgTypes.h @@ -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) -- 1.7.10.4