X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FBlock.h;fp=ghc%2Fincludes%2FBlock.h;h=0000000000000000000000000000000000000000;hb=0065d5ab628975892cea1ec7303f968c3338cbe1;hp=d1705ad68650afddb9451d415d6f3d3db1c9a0b8;hpb=28a464a75e14cece5db40f2765a29348273ff2d2;p=ghc-hetmet.git diff --git a/ghc/includes/Block.h b/ghc/includes/Block.h deleted file mode 100644 index d1705ad..0000000 --- a/ghc/includes/Block.h +++ /dev/null @@ -1,202 +0,0 @@ -/* ----------------------------------------------------------------------------- - * - * (c) The GHC Team, 1998-1999 - * - * Block structure for the storage manager - * - * ---------------------------------------------------------------------------*/ - -#ifndef BLOCK_H -#define BLOCK_H - -/* The actual block and megablock-size constants are defined in - * includes/Constants.h, all constants here are derived from these. - */ - -/* Block related constants (BLOCK_SHIFT is defined in Constants.h) */ - -#define BLOCK_SIZE (1<> (BLOCK_SHIFT-BDESCR_SHIFT)) \ - | ((p) & ~MBLOCK_MASK)) - -#else - -INLINE_HEADER bdescr *Bdescr(StgPtr p) -{ - return (bdescr *) - ((((W_)p & MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) - | ((W_)p & ~MBLOCK_MASK) - ); -} - -#endif - -/* Useful Macros ------------------------------------------------------------ */ - -/* Offset of first real data block in a megablock */ - -#define FIRST_BLOCK_OFF \ - ((W_)BLOCK_ROUND_UP(BDESCR_SIZE * (MBLOCK_SIZE / BLOCK_SIZE))) - -/* First data block in a given megablock */ - -#define FIRST_BLOCK(m) ((void *)(FIRST_BLOCK_OFF + (W_)(m))) - -/* Last data block in a given megablock */ - -#define LAST_BLOCK(m) ((void *)(MBLOCK_SIZE-BLOCK_SIZE + (W_)(m))) - -/* First real block descriptor in a megablock */ - -#define FIRST_BDESCR(m) \ - ((bdescr *)((FIRST_BLOCK_OFF>>(BLOCK_SHIFT-BDESCR_SHIFT)) + (W_)(m))) - -/* Number of usable blocks in a megablock */ - -#define BLOCKS_PER_MBLOCK ((MBLOCK_SIZE - FIRST_BLOCK_OFF) / BLOCK_SIZE) - -/* How many blocks in this megablock group */ - -#define MBLOCK_GROUP_BLOCKS(n) \ - (BLOCKS_PER_MBLOCK + (n-1) * (MBLOCK_SIZE / BLOCK_SIZE)) - -/* Compute the required size of a megablock group */ - -#define BLOCKS_TO_MBLOCKS(n) \ - (1 + (W_)MBLOCK_ROUND_UP((n-BLOCKS_PER_MBLOCK) * BLOCK_SIZE) / MBLOCK_SIZE) - - -#ifndef CMINUSMINUS -/* to the end... */ - -/* Double-linked block lists: --------------------------------------------- */ - -INLINE_HEADER void -dbl_link_onto(bdescr *bd, bdescr **list) -{ - bd->link = *list; - bd->u.back = NULL; - if (*list) { - (*list)->u.back = bd; /* double-link the list */ - } - *list = bd; -} - -/* 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 */