1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-1999
5 * Block Allocator Interface
7 * ---------------------------------------------------------------------------*/
12 /* Initialisation ---------------------------------------------------------- */
14 extern void initBlockAllocator(void);
16 /* Allocation -------------------------------------------------------------- */
18 extern bdescr *allocGroup(nat n);
19 extern bdescr *allocBlock(void);
21 /* De-Allocation ----------------------------------------------------------- */
23 extern void freeGroup(bdescr *p);
24 extern void freeChain(bdescr *p);
26 /* Round a value to megablocks --------------------------------------------- */
28 #define WORDS_PER_MBLOCK (BLOCKS_PER_MBLOCK * BLOCK_SIZE_W)
31 round_to_mblocks(nat words)
33 if (words > WORDS_PER_MBLOCK) {
34 if ((words % WORDS_PER_MBLOCK) < (WORDS_PER_MBLOCK / 2)) {
35 words = (words / WORDS_PER_MBLOCK) * WORDS_PER_MBLOCK;
37 words = ((words / WORDS_PER_MBLOCK) + 1) * WORDS_PER_MBLOCK;
43 /* Debugging -------------------------------------------------------------- */
46 extern void checkFreeListSanity(void);
47 nat countFreeList(void);
50 #endif /* BLOCK_ALLOC_H */