Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
reflex-frp
GitHub Repository: reflex-frp/reflex-platform
Path: blob/develop/nixpkgs-overlays/mobile-ghc/8.6.y/android-patches/strict-align.patch
1 views
1
diff --git a/libraries/bytestring/Data/ByteString/Builder/Prim/Internal.hs b/libraries/bytestring/Data/ByteString/Builder/Prim/Internal.hs
2
index fb52404..572b4b7 100644
3
--- a/libraries/bytestring/Data/ByteString/Builder/Prim/Internal.hs
4
+++ b/libraries/bytestring/Data/ByteString/Builder/Prim/Internal.hs
5
@@ -198,7 +198,19 @@ liftFixedToBounded = toB
6
7
{-# INLINE CONLIKE storableToF #-}
8
storableToF :: forall a. Storable a => FixedPrim a
9
+-- Not all architectures are forgiving of unaligned accesses; whitelist ones
10
+-- which are known not to trap (either to the kernel for emulation, or crash).
11
+#if defined(i386_HOST_ARCH) || defined(x86_64_HOST_ARCH) \
12
+ || ((defined(arm_HOST_ARCH) || defined(aarch64_HOST_ARCH)) \
13
+ && defined(__ARM_FEATURE_UNALIGNED)) \
14
+ || defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) \
15
+ || defined(powerpc64le_HOST_ARCH)
16
storableToF = FP (sizeOf (undefined :: a)) (\x op -> poke (castPtr op) x)
17
+#else
18
+storableToF = FP (sizeOf (undefined :: a)) $ \x op ->
19
+ if ptrToWordPtr op `mod` fromIntegral (alignment (undefined :: a)) == 0 then poke (castPtr op) x
20
+ else with x $ \tp -> copyBytes op (castPtr tp) (sizeOf (undefined :: a))
21
+#endif
22
23
{-
24
{-# INLINE CONLIKE liftIOF #-}
25