/* -----------------------------------------------------------------------------
- * $Id: Block.h,v 1.17 2004/08/13 13:09:09 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
StgWord *bitmap;
} u;
unsigned int gen_no; /* generation */
- struct _step *step; /* step */
+ struct step_ *step; /* step */
StgWord32 blocks; /* no. of blocks (if grp head, 0 otherwise) */
StgWord32 flags; /* block is in to-space */
#if SIZEOF_VOID_P == 8
#define BF_PINNED 4
/* Block is part of a compacted generation */
#define BF_COMPACTED 8
+/* Block is free, and on the free list */
+#define BF_FREE 16
/* Finding the block descriptor for a given block -------------------------- */
(1 + (W_)MBLOCK_ROUND_UP((n-BLOCKS_PER_MBLOCK) * BLOCK_SIZE) / MBLOCK_SIZE)
+#ifndef CMINUSMINUS
+/* to the end... */
+
/* Double-linked block lists: --------------------------------------------- */
-#ifndef CMINUSMINUS
INLINE_HEADER void
dbl_link_onto(bdescr *bd, bdescr **list)
{
}
*list = bd;
}
-#endif
+/* Initialisation ---------------------------------------------------------- */
+
+extern void initBlockAllocator(void);
+
+/* Allocation -------------------------------------------------------------- */
+
+bdescr *allocGroup(nat n);
+bdescr *allocBlock(void);
+
+// versions that take the storage manager lock for you:
+bdescr *allocGroup_lock(nat n);
+bdescr *allocBlock_lock(void);
+
+/* De-Allocation ----------------------------------------------------------- */
+
+void freeGroup(bdescr *p);
+void freeChain(bdescr *p);
+
+// versions that take the storage manager lock for you:
+void freeGroup_lock(bdescr *p);
+void freeChain_lock(bdescr *p);
+
+/* Round a value to megablocks --------------------------------------------- */
+
+#define WORDS_PER_MBLOCK (BLOCKS_PER_MBLOCK * BLOCK_SIZE_W)
+
+INLINE_HEADER nat
+round_to_mblocks(nat words)
+{
+ 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;
+}
+
+#endif /* !CMINUSMINUS */
#endif /* BLOCK_H */