X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStable.h;h=66486bd6380b32779dd9345ece1b57fb39dee9ca;hb=9213df4a0c5a8f121832d36d6d3afbf1c80f1a0a;hp=c8685045d5ba44d6043b0c343d8fac93fa3bc953;hpb=4bba3f6ef0d8b637118383cf2a9944341f0678f1;p=ghc-hetmet.git diff --git a/ghc/includes/Stable.h b/ghc/includes/Stable.h index c868504..66486bd 100644 --- a/ghc/includes/Stable.h +++ b/ghc/includes/Stable.h @@ -1,11 +1,21 @@ /* ----------------------------------------------------------------------------- - * $Id: Stable.h,v 1.5 2000/04/13 15:37:11 panne Exp $ + * $Id: Stable.h,v 1.7 2000/11/07 17:05:47 simonmar Exp $ * - * (c) The GHC Team, 1998-1999 + * (c) The GHC Team, 1998-2000 * - * Stable names and stable pointers + * Stable Pointers: A stable pointer is represented as an index into + * the stable pointer table in the low BITS_PER_WORD-8 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*. + * + * ----------------------------------------------------------------------------*/ + +#define STABLEPTR_WEIGHT_MASK ((StgWord)0xff << ((sizeof(StgWord)-1) * BITS_PER_BYTE)) +#define STABLEPTR_WEIGHT_SHIFT (BITS_IN(StgWord) - 8) /* ----------------------------------------------------------------------------- External C Interface @@ -48,7 +58,8 @@ freeStablePtr(StgStablePtr sp) && stable_ptr_table[sn].addr != NULL && stable_ptr_table[sn].weight > 0); - stable_ptr_table[sn].weight += (stgCast(StgWord,sp) & STABLEPTR_WEIGHT_MASK) >> STABLEPTR_WEIGHT_SHIFT; + stable_ptr_table[sn].weight += + 1 << ((((StgWord)sp & STABLEPTR_WEIGHT_MASK) >> STABLEPTR_WEIGHT_SHIFT) - 1); } extern inline StgStablePtr