X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FBlockAlloc.h;h=504e954c9876f6c7cd63affe165b2129178ef825;hb=49bff3215bf3fe9ada24dac2cf80f97db4e597dd;hp=1ef18d4dc34aa7ad9ece96926c3eac9431886a1f;hpb=4391e44f910ce579f269986faef9e5db8907a6c0;p=ghc-hetmet.git diff --git a/ghc/rts/BlockAlloc.h b/ghc/rts/BlockAlloc.h index 1ef18d4..504e954 100644 --- a/ghc/rts/BlockAlloc.h +++ b/ghc/rts/BlockAlloc.h @@ -1,5 +1,7 @@ /* ----------------------------------------------------------------------------- - * $Id: BlockAlloc.h,v 1.3 1999/01/13 17:25:38 simonm Exp $ + * $Id: BlockAlloc.h,v 1.9 2001/05/03 16:32:55 simonmar Exp $ + * + * (c) The GHC Team, 1998-1999 * * Block Allocator Interface * @@ -22,14 +24,21 @@ extern bdescr *allocBlock(void); extern void freeGroup(bdescr *p); extern void freeChain(bdescr *p); -/* Finding the block descriptor for a given block -------------------------- */ +/* Round a value to megablocks --------------------------------------------- */ + +#define WORDS_PER_MBLOCK (BLOCKS_PER_MBLOCK * BLOCK_SIZE_W) -static inline bdescr *Bdescr(StgPtr p) +static inline nat +round_to_mblocks(nat words) { - return (bdescr *) - ((((W_)p & MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) - | ((W_)p & ~MBLOCK_MASK) - ); + if (words > WORDS_PER_MBLOCK) { + if ((words % WORDS_PER_MBLOCK) < (WORDS_PER_MBLOCK / 2)) { + words = (words / WORDS_PER_MBLOCK) * WORDS_PER_MBLOCK; + } else { + words = ((words / WORDS_PER_MBLOCK) + 1) * WORDS_PER_MBLOCK; + } + } + return words; } /* Debugging -------------------------------------------------------------- */ @@ -39,4 +48,4 @@ extern void checkFreeListSanity(void); nat countFreeList(void); #endif -#endif BLOCK_ALLOC_H +#endif /* BLOCK_ALLOC_H */