[project @ 2002-05-14 08:17:38 by matthewc]
[ghc-hetmet.git] / ghc / rts / Storage.c
index f492931..79c3ef7 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.62 2002/04/23 11:21:39 simonmar Exp $
+ * $Id: Storage.c,v 1.66 2002/05/14 08:17:38 matthewc Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -579,8 +579,9 @@ allocatePinned( nat n )
     // we always return 8-byte aligned memory.  bd->free must be
     // 8-byte aligned to begin with, so we just round up n to
     // the nearest multiple of 8 bytes.
-    ASSERT(((StgWord)bd->free & 7) == 0);
-    n = (n+7) & ~8;
+    if (sizeof(StgWord) == 4) {
+       n = (n+1) & ~1;
+    }
 
     // If we don't have a block of pinned objects yet, or the current
     // one isn't large enough to hold the new object, allocate a new one.
@@ -617,10 +618,8 @@ stgAllocForGMP (size_t size_in_bytes)
   StgArrWords* arr;
   nat data_size_in_words, total_size_in_words;
   
-  /* should be a multiple of sizeof(StgWord) (whole no. of limbs) */
-  ASSERT(size_in_bytes % sizeof(W_) == 0);
-  
-  data_size_in_words  = size_in_bytes / sizeof(W_);
+  /* round up to a whole number of words */
+  data_size_in_words  = (size_in_bytes + sizeof(W_) + 1) / sizeof(W_);
   total_size_in_words = sizeofW(StgArrWords) + data_size_in_words;
   
   /* allocate and fill it in. */