@@ -195,6 +195,7 @@ module Streamly.Internal.Data.Array.Foreign.Mut.Type
195 -- , appendSliceFrom
195 -- , appendSliceFrom
197 -- * Utilities
197 -- * Utilities
200 , c_memchr
201 , c_memchr
@@ -202,6 +203,7 @@ module Streamly.Internal.Data.Array.Foreign.Mut.Type
204#include "inline.hs"
205#include "inline.hs"
206+#include "MachDeps.h"
206#ifdef USE_C_MALLOC
208#ifdef USE_C_MALLOC
207#define USE_FOREIGN_PTR
209#define USE_FOREIGN_PTR
@@ -211,7 +213,7 @@ import Control.Exception (assert)
211import Control.DeepSeq (NFData(..))
213import Control.DeepSeq (NFData(..))
212import Control.Monad (when, void)
214import Control.Monad (when, void)
213import Control.Monad.IO.Class (MonadIO(..))
215import Control.Monad.IO.Class (MonadIO(..))
214−import Data.Bits ((.&.))
216+import Data.Bits (shiftR, (.|.), (.&.))
215#if __GLASGOW_HASKELL__ < 808
217#if __GLASGOW_HASKELL__ < 808
216import Data.Semigroup (Semigroup(..))
218import Data.Semigroup (Semigroup(..))
@@ -687,10 +689,21 @@ roundUpLargeArray size =
687 ((size + blockSize - 1) .&. negate blockSize)
689 ((size + blockSize - 1) .&. negate blockSize)
688 else size
690 else size
691roundUpToPower2 :: Int -> Int
692roundUpToPower2 :: Int -> Int
692−roundUpToPower2 = undefined
693+roundUpToPower2 x =
693−-}
694+#if WORD_SIZE_IN_BITS == 64
701+ z1 = z .|. z `shiftR` 1
702+ z2 = z1 .|. z1 `shiftR` 2
703+ z3 = z2 .|. z2 `shiftR` 4
704+ z4 = z3 .|. z3 `shiftR` 8
705+ z5 = z4 .|. z4 `shiftR` 16
706+ z6 = z5 .|. z5 `shiftR` 32
695-- | @allocBytesToBytes elem allocatedBytes@ returns the array size in bytes
708-- | @allocBytesToBytes elem allocatedBytes@ returns the array size in bytes
696-- such that the real allocation is less than or equal to @allocatedBytes@,
709-- such that the real allocation is less than or equal to @allocatedBytes@,