1 /* -----------------------------------------------------------------------------
2 * $Id: BlockAlloc.h,v 1.8 1999/11/09 15:46:49 simonmar Exp $
4 * (c) The GHC Team, 1998-1999
6 * Block Allocator Interface
8 * ---------------------------------------------------------------------------*/
13 /* Initialisation ---------------------------------------------------------- */
15 extern void initBlockAllocator(void);
17 /* Allocation -------------------------------------------------------------- */
19 extern bdescr *allocGroup(nat n);
20 extern bdescr *allocBlock(void);
22 /* De-Allocation ----------------------------------------------------------- */
24 extern void freeGroup(bdescr *p);
25 extern void freeChain(bdescr *p);
27 /* Round a value to megablocks --------------------------------------------- */
29 #define WORDS_PER_MBLOCK (BLOCKS_PER_MBLOCK * BLOCK_SIZE_W)
32 round_to_mblocks(nat words)
34 if (words > WORDS_PER_MBLOCK) {
35 if ((words % WORDS_PER_MBLOCK) < (WORDS_PER_MBLOCK / 2)) {
36 words = (words / WORDS_PER_MBLOCK) * WORDS_PER_MBLOCK;
38 words = ((words / WORDS_PER_MBLOCK) + 1) * WORDS_PER_MBLOCK;
44 /* Debugging -------------------------------------------------------------- */
47 extern void checkFreeListSanity(void);
48 nat countFreeList(void);