[project @ 2000-10-27 14:45:18 by simonmar]
[ghc-hetmet.git] / ghc / includes / Block.h
index b8a0260..bf21ba3 100644 (file)
@@ -1,5 +1,7 @@
 /* -----------------------------------------------------------------------------
- * $Id: Block.h,v 1.2 1998/12/02 13:20:53 simonm Exp $
+ * $Id: Block.h,v 1.7 2000/04/05 14:26:31 panne Exp $
+ *
+ * (c) The GHC Team, 1998-1999
  *
  * Block structure for the storage manager
  *
@@ -43,13 +45,14 @@ typedef struct _bdescr {
   StgPtr free;                 /* first free byte of memory */
   struct _bdescr *link;                /* used for chaining blocks together */
   struct _bdescr *back;                /* used (occasionally) for doubly-linked lists*/
-  StgNat32 gen;                        /* generation */
-  StgNat32 step;               /* step */
-  StgNat32 blocks;             /* no. of blocks (if grp head, 0 otherwise) */
+  struct _generation *gen;     /* generation */
+  struct _step *step;          /* step */
+  StgWord32 blocks;            /* no. of blocks (if grp head, 0 otherwise) */
+  StgWord32 evacuated;           /* block is in to-space */
 #if SIZEOF_VOID_P == 8
-  StgNat32 _padding[5];
+  StgWord32 _padding[2];
 #else
-  StgNat32 _padding[1];
+  StgWord32 _padding[0];
 #endif
 } bdescr;
 
@@ -63,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 */
@@ -97,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 */