[project @ 1999-03-02 19:50:12 by sof]
[ghc-hetmet.git] / ghc / rts / BlockAlloc.h
index d3e6d53..ab6b199 100644 (file)
@@ -1,5 +1,7 @@
 /* -----------------------------------------------------------------------------
- * $Id: BlockAlloc.h,v 1.2 1998/12/02 13:28:13 simonm Exp $
+ * $Id: BlockAlloc.h,v 1.5 1999/02/05 16:02:36 simonm Exp $
+ *
+ * (c) The GHC Team, 1998-1999
  *
  * Block Allocator Interface
  *
@@ -32,10 +34,28 @@ static inline bdescr *Bdescr(StgPtr p)
      );
 }
 
+/* Round a value to megablocks --------------------------------------------- */
+
+#define WORDS_PER_MBLOCK  (BLOCKS_PER_MBLOCK * BLOCK_SIZE_W)
+
+static inline 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;
+}
+
 /* Debugging  -------------------------------------------------------------- */
 
 #ifdef DEBUG
 extern void checkFreeListSanity(void);
+nat         countFreeList(void);
 #endif
 
 #endif BLOCK_ALLOC_H