[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / rts / BlockAlloc.h
1 /* -----------------------------------------------------------------------------
2  * $Id: BlockAlloc.h,v 1.2 1998/12/02 13:28:13 simonm Exp $
3  *
4  * Block Allocator Interface
5  *
6  * ---------------------------------------------------------------------------*/
7
8 #ifndef BLOCK_ALLOC_H
9 #define BLOCK_ALLOC_H
10
11 /* Initialisation ---------------------------------------------------------- */
12
13 extern void initBlockAllocator(void);
14
15 /* Allocation -------------------------------------------------------------- */
16
17 extern bdescr *allocGroup(nat n);
18 extern bdescr *allocBlock(void);
19
20 /* De-Allocation ----------------------------------------------------------- */
21
22 extern void freeGroup(bdescr *p);
23 extern void freeChain(bdescr *p);
24
25 /* Finding the block descriptor for a given block -------------------------- */
26
27 static inline bdescr *Bdescr(StgPtr p)
28 {
29   return (bdescr *)
30     ((((W_)p &  MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) 
31      | ((W_)p & ~MBLOCK_MASK)
32      );
33 }
34
35 /* Debugging  -------------------------------------------------------------- */
36
37 #ifdef DEBUG
38 extern void checkFreeListSanity(void);
39 #endif
40
41 #endif BLOCK_ALLOC_H