From c76cd8da16677d14c8995421fba62ff3db465f10 Mon Sep 17 00:00:00 2001
From: Antoine Latter <aslatter@gmail.com>
Date: Fri, 1 Jan 2010 18:34:37 +0000
Subject: [PATCH] FIX #38000 Store StgArrWords payload size in bytes

---
 cbits/gmp-wrappers.cmm | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/cbits/gmp-wrappers.cmm b/cbits/gmp-wrappers.cmm
index e5d24ad..e41be8f 100644
--- a/cbits/gmp-wrappers.cmm
+++ b/cbits/gmp-wrappers.cmm
@@ -67,7 +67,7 @@ integer_cmm_int2Integerzh
 
    p = Hp - SIZEOF_StgArrWords;
    SET_HDR(p, stg_ARR_WORDS_info, W_[CCCS]);
-   StgArrWords_words(p) = 1;
+   StgArrWords_bytes(p) = SIZEOF_W;
 
    /* mpz_set_si is inlined here, makes things simpler */
    if (%lt(val,0)) {
@@ -101,7 +101,7 @@ integer_cmm_word2Integerzh
 
    p = Hp - SIZEOF_StgArrWords;
    SET_HDR(p, stg_ARR_WORDS_info, W_[CCCS]);
-   StgArrWords_words(p) = 1;
+   StgArrWords_bytes(p) = SIZEOF_W;
 
    if (val != 0) {
         s = 1;
@@ -148,7 +148,7 @@ integer_cmm_int64ToIntegerzh
 
    p = Hp - SIZEOF_StgArrWords - WDS(words_needed) + WDS(1);
    SET_HDR(p, stg_ARR_WORDS_info, W_[CCCS]);
-   StgArrWords_words(p) = words_needed;
+   StgArrWords_bytes(p) = WDS(words_needed);
 
    if ( %lt(hi,0) ) {
      neg = 1;
@@ -203,7 +203,7 @@ integer_cmm_word64ToIntegerzh
 
    p = Hp - SIZEOF_StgArrWords - WDS(words_needed) + WDS(1);
    SET_HDR(p, stg_ARR_WORDS_info, W_[CCCS]);
-   StgArrWords_words(p) = words_needed;
+   StgArrWords_bytes(p) = WDS(words_needed);
 
    if ( hi != 0 ) {
      s = 2;
@@ -248,10 +248,10 @@ name                                                                    \
   mp_tmp1    = Sp - 1 * SIZEOF_MP_INT;                                  \
   mp_tmp2    = Sp - 2 * SIZEOF_MP_INT;                                  \
   mp_result1 = Sp - 3 * SIZEOF_MP_INT;                                  \
-  MP_INT__mp_alloc(mp_tmp1) = W_TO_INT(StgArrWords_words(d1));          \
+  MP_INT__mp_alloc(mp_tmp1) = W_TO_INT(BYTE_ARR_WDS(d1));               \
   MP_INT__mp_size(mp_tmp1)  = (s1);                                     \
   MP_INT__mp_d(mp_tmp1)     = BYTE_ARR_CTS(d1);                         \
-  MP_INT__mp_alloc(mp_tmp2) = W_TO_INT(StgArrWords_words(d2));          \
+  MP_INT__mp_alloc(mp_tmp2) = W_TO_INT(BYTE_ARR_WDS(d2));               \
   MP_INT__mp_size(mp_tmp2)  = (s2);                                     \
   MP_INT__mp_d(mp_tmp2)     = BYTE_ARR_CTS(d2);                         \
                                                                         \
@@ -284,7 +284,7 @@ name                                                                    \
                                                                         \
   mp_tmp     = Sp - 1 * SIZEOF_MP_INT;                                  \
   mp_result  = Sp - 2 * SIZEOF_MP_INT;                                  \
-  MP_INT__mp_alloc(mp_tmp) = W_TO_INT(StgArrWords_words(d1));           \
+  MP_INT__mp_alloc(mp_tmp) = W_TO_INT(BYTE_ARR_WDS(d1));                \
   MP_INT__mp_size(mp_tmp)  = (s1);                                      \
   MP_INT__mp_d(mp_tmp)     = BYTE_ARR_CTS(d1);                          \
                                                                         \
@@ -315,7 +315,7 @@ name                                                                    \
                                                                         \
   mp_tmp1    = Sp - 1 * SIZEOF_MP_INT;                                  \
   mp_result1 = Sp - 2 * SIZEOF_MP_INT;                                  \
-  MP_INT__mp_alloc(mp_tmp1)     = W_TO_INT(StgArrWords_words(d1));      \
+  MP_INT__mp_alloc(mp_tmp1)     = W_TO_INT(BYTE_ARR_WDS(d1));           \
   MP_INT__mp_size(mp_tmp1)      = (s1);                                 \
   MP_INT__mp_d(mp_tmp1)         = BYTE_ARR_CTS(d1);                     \
                                                                         \
@@ -352,10 +352,10 @@ name
   mp_tmp2    = Sp - 2 * SIZEOF_MP_INT;                                                  \
   mp_result1 = Sp - 3 * SIZEOF_MP_INT;                                                  \
   mp_result2 = Sp - 4 * SIZEOF_MP_INT;                                                  \
-  MP_INT__mp_alloc(mp_tmp1)     = W_TO_INT(StgArrWords_words(d1));                      \
+  MP_INT__mp_alloc(mp_tmp1)     = W_TO_INT(BYTE_ARR_WDS(d1));                           \
   MP_INT__mp_size(mp_tmp1)      = (s1);                                                 \
   MP_INT__mp_d(mp_tmp1)         = BYTE_ARR_CTS(d1);                                     \
-  MP_INT__mp_alloc(mp_tmp2)     = W_TO_INT(StgArrWords_words(d2));                      \
+  MP_INT__mp_alloc(mp_tmp2)     = W_TO_INT(BYTE_ARR_WDS(d2));                           \
   MP_INT__mp_size(mp_tmp2)      = (s2);                                                 \
   MP_INT__mp_d(mp_tmp2)         = BYTE_ARR_CTS(d2);                                     \
                                                                                         \
@@ -571,7 +571,7 @@ integer_cmm_decodeDoublezh
        where mantissa.d can be put (it does not care about the rest) */
     p = Hp - ARR_SIZE + WDS(1);
     SET_HDR(p, stg_ARR_WORDS_info, W_[CCCS]);
-    StgArrWords_words(p) = BYTES_TO_WDS(DOUBLE_MANTISSA_SIZE);
+    StgArrWords_bytes(p) = DOUBLE_MANTISSA_SIZE;
     MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(p);
 
     /* Perform the operation */
-- 
GitLab