Skip to content

Commit

Permalink
PURE_HASKELL always defined
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyl20 committed Jan 8, 2024
1 parent 2b2055d commit 3996c2c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Data/ByteString/Builder/Prim/Internal/Base16.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Data.ByteString.Builder.Prim.Internal.Base16 (

import Foreign
import GHC.Exts (Addr#, Ptr(..))
#if defined(PURE_HASKELL)
#if PURE_HASKELL
import qualified Data.ByteString.Internal.Pure as Pure
#else
import Foreign.C.Types
Expand All @@ -40,7 +40,7 @@ data EncodingTable = EncodingTable Addr#
-- e.g., deadbeef.
lowerTable :: EncodingTable
lowerTable =
#if defined(PURE_HASKELL)
#if PURE_HASKELL
case Pure.lower_hex_table of
Ptr p# -> EncodingTable p#
#else
Expand Down
8 changes: 4 additions & 4 deletions Data/ByteString/Builder/RealFloat/D2S.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import Data.Maybe (fromMaybe)
import GHC.Int (Int32(..))
import GHC.Word (Word64(..))

#if !defined(PURE_HASKELL)
#if !PURE_HASKELL
import GHC.Ptr (Ptr(..))
#endif

-- See Data.ByteString.Builder.RealFloat.TableGenerator for a high-level
-- explanation of the ryu algorithm

#if !defined(PURE_HASKELL)
#if !PURE_HASKELL
-- | Table of 2^k / 5^q + 1
--
-- > splitWord128s $ fmap (finv double_pow5_inv_bitcount) [0..double_max_inv_split]
Expand Down Expand Up @@ -110,7 +110,7 @@ mulShift64 m (factorHi, factorLo) shift =

-- | Index into the 128-bit word lookup table double_pow5_inv_split
get_double_pow5_inv_split :: Int -> (Word64, Word64)
#if !defined(PURE_HASKELL)
#if !PURE_HASKELL
get_double_pow5_inv_split = getWord128At double_pow5_inv_split
#else
-- > putStr $ case128 (finv double_pow5_inv_bitcount) [0..double_max_inv_split]
Expand Down Expand Up @@ -411,7 +411,7 @@ get_double_pow5_inv_split i = case i of

-- | Index into the 128-bit word lookup table double_pow5_split
get_double_pow5_split :: Int -> (Word64, Word64)
#if !defined(PURE_HASKELL)
#if !PURE_HASKELL
get_double_pow5_split = getWord128At double_pow5_split
#else
-- > > putStr $ case128 (fnorm double_pow5_bitcount) [0..double_max_split]
Expand Down
8 changes: 4 additions & 4 deletions Data/ByteString/Builder/RealFloat/F2S.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import Data.ByteString.Builder.RealFloat.Internal
import GHC.Int (Int32(..))
import GHC.Word (Word32(..), Word64(..))

#if !defined(PURE_HASKELL)
#if !PURE_HASKELL
import GHC.Ptr (Ptr(..))
#endif

-- See Data.ByteString.Builder.RealFloat.TableGenerator for a high-level
-- explanation of the ryu algorithm

#if !defined(PURE_HASKELL)
#if !PURE_HASKELL
-- | Table of 2^k / 5^q + 1
--
-- > fmap (finv float_pow5_inv_bitcount) [0..float_max_inv_split]
Expand Down Expand Up @@ -76,7 +76,7 @@ mulShift32 m factor shift =

-- | Index into the 64-bit word lookup table float_pow5_inv_split
get_float_pow5_inv_split :: Int -> Word64
#if !defined(PURE_HASKELL)
#if !PURE_HASKELL
get_float_pow5_inv_split = getWord64At float_pow5_inv_split
#else
-- > putStr $ case64 (finv float_pow5_inv_bitcount) [0..float_max_inv_split]
Expand Down Expand Up @@ -116,7 +116,7 @@ get_float_pow5_inv_split i = case i of

-- | Index into the 64-bit word lookup table float_pow5_split
get_float_pow5_split :: Int -> Word64
#if !defined(PURE_HASKELL)
#if !PURE_HASKELL
get_float_pow5_split = getWord64At float_pow5_split
#else
-- > putStr $ case64 (fnorm float_pow5_bitcount) [0..float_max_split]
Expand Down
4 changes: 2 additions & 2 deletions Data/ByteString/Builder/RealFloat/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import Data.ByteString.Internal (c2w)
import Data.ByteString.Builder.Prim.Internal (BoundedPrim, boundedPrim)
import Data.ByteString.Builder.RealFloat.TableGenerator
import Data.ByteString.Utils.UnalignedWrite
#if defined(PURE_HASKELL)
#if PURE_HASKELL
import qualified Data.ByteString.Internal.Pure as Pure
#else
import Foreign.C.Types
Expand Down Expand Up @@ -751,7 +751,7 @@ unpackWord16 w =
-- | Static array of 2-digit pairs 00..99 for faster ascii rendering
digit_table :: Ptr Word16
digit_table =
#if defined(PURE_HASKELL)
#if PURE_HASKELL
castPtr Pure.digit_pairs_table
#else
castPtr c_digit_pairs_table
Expand Down
4 changes: 2 additions & 2 deletions Data/ByteString/Internal/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ import Foreign.C.Types
import Foreign.C.String (CString)
import Foreign.Marshal.Utils

#if defined(PURE_HASKELL)
#if PURE_HASKELL
import qualified Data.ByteString.Internal.Pure as Pure
#endif

Expand Down Expand Up @@ -1141,7 +1141,7 @@ memset p w sz = c_memset p (fromIntegral w) sz
-- Uses our C code
--

#if !defined(PURE_HASKELL)
#if !PURE_HASKELL

foreign import ccall unsafe "static fpstring.h fps_reverse" c_reverse
:: Ptr Word8 -> Ptr Word8 -> CSize -> IO ()
Expand Down
2 changes: 1 addition & 1 deletion Data/ByteString/Short/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ import Foreign.C.String
( CString
, CStringLen
)
#if !MIN_VERSION_base(4,11,0) && !defined(PURE_HASKELL)
#if !MIN_VERSION_base(4,11,0) && !PURE_HASKELL
import Foreign.C.Types
( CSize(..)
, CInt(..)
Expand Down
3 changes: 2 additions & 1 deletion bytestring.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ library
-fspec-constr-count=6

if arch(javascript) || flag(pure-haskell)
cpp-options: -DPURE_HASKELL
cpp-options: -DPURE_HASKELL=1
other-modules: Data.ByteString.Internal.Pure
else
cpp-options: -DPURE_HASKELL=0

c-sources: cbits/fpstring.c
cbits/itoa.c
Expand Down
2 changes: 1 addition & 1 deletion include/bytestring-cpp-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
&& defined(__ARM_FEATURE_UNALIGNED)) \
|| defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) \
|| defined(powerpc64le_HOST_ARCH) \
|| defined(PURE_HASKELL)
|| defined(javascript_HOST_ARCH)
/*
Not all architectures are forgiving of unaligned accesses; whitelist ones
which are known not to trap (either to the kernel for emulation, or crash).
Expand Down

0 comments on commit 3996c2c

Please sign in to comment.