[project @ 2003-02-01 09:10:16 by mthomas]
[ghc-hetmet.git] / ghc / rts / Storage.c
index 6f6fe70..f92e653 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.74 2003/01/23 12:13:12 simonmar Exp $
+ * $Id: Storage.c,v 1.76 2003/02/01 09:10:17 mthomas Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -39,10 +39,10 @@ nat alloc_blocks_lim;               /* approximate limit on alloc_blocks */
 StgPtr alloc_Hp    = NULL;     /* next free byte in small_alloc_list */
 StgPtr alloc_HpLim = NULL;     /* end of block at small_alloc_list   */
 
-generation *generations;       /* all the generations */
-generation *g0;                        /* generation 0, for convenience */
-generation *oldest_gen;                /* oldest generation, for convenience */
-step *g0s0;                    /* generation 0, step 0, for convenience */
+generation *generations = NULL;        /* all the generations */
+generation *g0         = NULL; /* generation 0, for convenience */
+generation *oldest_gen  = NULL; /* oldest generation, for convenience */
+step *g0s0             = NULL; /* generation 0, step 0, for convenience */
 
 lnat total_allocated = 0;      /* total memory allocated during run */
 
@@ -68,6 +68,11 @@ initStorage( void )
   step *stp;
   generation *gen;
 
+  if (generations != NULL) {
+      // multi-init protection
+      return;
+  }
+
     /* Sanity check to make sure the LOOKS_LIKE_ macros appear to be
      * doing something reasonable.
      */
@@ -143,6 +148,7 @@ initStorage( void )
       stp = &generations[g].steps[s];
       stp->no = s;
       stp->blocks = NULL;
+      stp->n_to_blocks = 0;
       stp->n_blocks = 0;
       stp->gen = &generations[g];
       stp->gen_no = g;