/* -----------------------------------------------------------------------------
- * $Id: BlockAlloc.h,v 1.3 1999/01/13 17:25:38 simonm Exp $
+ *
+ * (c) The GHC Team, 1998-1999
*
* Block Allocator Interface
*
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)
+INLINE_HEADER 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 -------------------------------------------------------------- */
nat countFreeList(void);
#endif
-#endif BLOCK_ALLOC_H
+#endif /* BLOCK_ALLOC_H */