Path: blob/develop/nixpkgs-overlays/mobile-ghc/8.6.y/android-patches/strict-align.patch
1 views
diff --git a/libraries/bytestring/Data/ByteString/Builder/Prim/Internal.hs b/libraries/bytestring/Data/ByteString/Builder/Prim/Internal.hs1index fb52404..572b4b7 1006442--- a/libraries/bytestring/Data/ByteString/Builder/Prim/Internal.hs3+++ b/libraries/bytestring/Data/ByteString/Builder/Prim/Internal.hs4@@ -198,7 +198,19 @@ liftFixedToBounded = toB56{-# INLINE CONLIKE storableToF #-}7storableToF :: forall a. Storable a => FixedPrim a8+-- Not all architectures are forgiving of unaligned accesses; whitelist ones9+-- which are known not to trap (either to the kernel for emulation, or crash).10+#if defined(i386_HOST_ARCH) || defined(x86_64_HOST_ARCH) \11+ || ((defined(arm_HOST_ARCH) || defined(aarch64_HOST_ARCH)) \12+ && defined(__ARM_FEATURE_UNALIGNED)) \13+ || defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) \14+ || defined(powerpc64le_HOST_ARCH)15storableToF = FP (sizeOf (undefined :: a)) (\x op -> poke (castPtr op) x)16+#else17+storableToF = FP (sizeOf (undefined :: a)) $ \x op ->18+ if ptrToWordPtr op `mod` fromIntegral (alignment (undefined :: a)) == 0 then poke (castPtr op) x19+ else with x $ \tp -> copyBytes op (castPtr tp) (sizeOf (undefined :: a))20+#endif2122{-23{-# INLINE CONLIKE liftIOF #-}2425