Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Fix Bdescr Cmm macro #466

Merged
merged 1 commit into from
Mar 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions ghc-toolkit/ghc-libdir/include/rts/storage/Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
#define BLOCK_SIZE_W (BLOCK_SIZE/sizeof(W_))
#define BLOCK_MASK (BLOCK_SIZE-1)

#if defined(CMINUSMINUS)
#define BLOCK_ROUND_UP(p) ((p+BLOCK_SIZE-1) & ~BLOCK_MASK)
#define BLOCK_ROUND_DOWN(p) ((p & ~BLOCK_MASK))
#else
#define BLOCK_ROUND_UP(p) (((W_)(p)+BLOCK_SIZE-1) & ~BLOCK_MASK)
#define BLOCK_ROUND_DOWN(p) ((void *) ((W_)(p) & ~BLOCK_MASK))
#endif

/* Megablock related constants (MBLOCK_SHIFT is defined in Constants.h) */

Expand Down Expand Up @@ -158,13 +163,7 @@ typedef struct bdescr_ {

/* Finding the block descriptor for a given block -------------------------- */

#if defined(CMINUSMINUS)

#define Bdescr(p) \
((((p) & MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) \
| ((p) & ~MBLOCK_MASK))

#else
#if !defined(CMINUSMINUS)

EXTERN_INLINE bdescr *Bdescr(StgPtr p);
EXTERN_INLINE bdescr *Bdescr(StgPtr p)
Expand All @@ -181,8 +180,13 @@ EXTERN_INLINE bdescr *Bdescr(StgPtr p)

/* Offset of first real data block in a megablock */

#if defined(CMINUSMINUS)
#define FIRST_BLOCK_OFF \
(BLOCK_ROUND_UP(BDESCR_SIZE * (MBLOCK_SIZE / BLOCK_SIZE)))
#else
#define FIRST_BLOCK_OFF \
((W_)BLOCK_ROUND_UP(BDESCR_SIZE * (MBLOCK_SIZE / BLOCK_SIZE)))
#endif

/* First data block in a given megablock */

Expand All @@ -194,8 +198,13 @@ EXTERN_INLINE bdescr *Bdescr(StgPtr p)

/* First real block descriptor in a megablock */

#if defined(CMINUSMINUS)
#define FIRST_BDESCR(m) \
((FIRST_BLOCK_OFF>>(BLOCK_SHIFT-BDESCR_SHIFT)) + m)
#else
#define FIRST_BDESCR(m) \
((bdescr *)((FIRST_BLOCK_OFF>>(BLOCK_SHIFT-BDESCR_SHIFT)) + (W_)(m)))
#endif

/* Last real block descriptor in a megablock */

Expand All @@ -218,6 +227,12 @@ EXTERN_INLINE bdescr *Bdescr(StgPtr p)
#define BLOCKS_TO_MBLOCKS(n) \
(1 + (W_)MBLOCK_ROUND_UP((n-BLOCKS_PER_MBLOCK) * BLOCK_SIZE) / MBLOCK_SIZE)

/* Finding the block descriptor for a given block (custom asterius macro) -- */

#if defined(CMINUSMINUS)
#define Bdescr(p) \
((p & ~MBLOCK_MASK) + FIRST_BDESCR(0))
#endif

#if !defined(CMINUSMINUS)
/* to the end... */
Expand Down