#ifndef RTS_STORAGE_MBLOCK_H
#define RTS_STORAGE_MBLOCK_H
+extern lnat peak_mblocks_allocated;
extern lnat mblocks_allocated;
extern void initMBlocks(void);
extern void * getMBlock(void);
extern void * getMBlocks(nat n);
+extern void freeMBlocks(void *addr, nat n);
extern void freeAllMBlocks(void);
-#ifdef DEBUG
extern void *getFirstMBlock(void);
extern void *getNextMBlock(void *mblock);
+
+#ifdef THREADED_RTS
+// needed for HEAP_ALLOCED below
+extern SpinLock gc_alloc_block_sync;
#endif
/* -----------------------------------------------------------------------------
#define MBC_LINE_BITS 0
#define MBC_TAG_BITS 15
-typedef StgWord32 MbcCacheLine; // could use 16, but 32 was faster
+
+#if x86_64_HOST_ARCH
+// 32bits are enough for 'entry' as modern amd64 boxes have
+// only 48bit sized virtual addres.
+typedef StgWord32 MbcCacheLine;
+#else
+// 32bits is not enough here as some arches (like ia64) use
+// upper address bits to distinct memory areas.
+typedef StgWord64 MbcCacheLine;
+#endif
+
typedef StgWord8 MBlockMapLine;
#define MBLOCK_MAP_LINE(p) (((StgWord)p & 0xffffffff) >> (MBLOCK_SHIFT + MBC_LINE_BITS))
extern lnat mpc_misses;
-#ifdef THREADED_RTS
-extern SpinLock gc_alloc_block_sync;
-#endif
-
StgBool HEAP_ALLOCED_miss(StgWord mblock, void *p);
INLINE_HEADER