[project @ 2000-05-15 09:20:11 by simonmar]
[ghc-hetmet.git] / ghc / includes / Block.h
index c665583..bf21ba3 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Block.h,v 1.5 1999/03/02 19:44:07 sof Exp $
+ * $Id: Block.h,v 1.7 2000/04/05 14:26:31 panne Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -66,6 +66,16 @@ typedef struct _bdescr {
 #define BDESCR_SHIFT 5
 #endif
 
+/* Finding the block descriptor for a given block -------------------------- */
+
+static inline bdescr *Bdescr(StgPtr p)
+{
+  return (bdescr *)
+    ((((W_)p &  MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) 
+     | ((W_)p & ~MBLOCK_MASK)
+     );
+}
+
 /* Useful Macros ------------------------------------------------------------ */
 
 /* Offset of first real data block in a megablock */
@@ -100,4 +110,4 @@ typedef struct _bdescr {
 #define BLOCKS_TO_MBLOCKS(n) \
    (1 + (W_)MBLOCK_ROUND_UP((n-BLOCKS_PER_MBLOCK) * BLOCK_SIZE) / MBLOCK_SIZE)
 
-#endif BLOCK_H
+#endif /* BLOCK_H */