packages feed

conduit-extra 1.1.13.1 → 1.1.13.2

raw patch · 4 files changed

+36/−15 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Conduit.Network.UDP: Message :: SrictNotUnpackedByteString -> SrictNotUnpackedSockAddr -> Message
+ Data.Conduit.Network.UDP: Message :: {-# UNPACK #-} ~ByteString -> ~SockAddr -> Message
- Data.Conduit.Network.UDP: [msgData] :: Message -> SrictNotUnpackedByteString
+ Data.Conduit.Network.UDP: [msgData] :: Message -> {-# UNPACK #-} ~ByteString
- Data.Conduit.Network.UDP: [msgSender] :: Message -> SrictNotUnpackedSockAddr
+ Data.Conduit.Network.UDP: [msgSender] :: Message -> ~SockAddr

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.1.13.2++* Fix alignment issues on non-X86 archs+ ## 1.1.13.1  * Fix an incorrect comment
Data/Conduit/Binary.hs view
@@ -76,6 +76,10 @@ import Control.Monad.Catch (MonadThrow (..)) import Control.Exception (Exception) import Data.Typeable (Typeable)+import Foreign.Ptr (Ptr)+#ifndef ALLOW_UNALIGNED_ACCESS+import Foreign.Marshal (alloca, copyBytes)+#endif  -- | Stream the contents of a file as binary data. --@@ -501,7 +505,14 @@      -- Given a bytestring of exactly the correct size, grab the value     process bs = return $! wrap $! inlinePerformIO $!-        unsafeUseAsCString bs (peek . castPtr)+        unsafeUseAsCString bs (safePeek undefined . castPtr)++    safePeek :: a -> Ptr a -> IO a+#ifdef ALLOW_UNALIGNED_ACCESS+    safePeek _ = peek+#else+    safePeek val ptr = alloca (\t -> copyBytes t ptr (sizeOf val) >> peek t)+#endif {-# INLINE sinkStorableHelper #-}  data SinkStorableException = SinkStorableInsufficientBytes
conduit-extra.cabal view
@@ -1,5 +1,5 @@ Name:                conduit-extra-Version:             1.1.13.1+Version:             1.1.13.2 Synopsis:            Batteries included conduit: adapters for common libraries. Description:     The conduit package itself maintains relative small dependencies. The purpose of this package is to collect commonly used utility functions wrapping other library dependencies, without depending on heavier-weight dependencies. The basic idea is that this package should only depend on haskell-platform packages and conduit.@@ -32,6 +32,10 @@                        Data.Conduit.Zlib   if !os(windows)       Exposed-modules: Data.Conduit.Network.Unix++  if arch(x86_64) || arch(i386)+      -- These architectures are able to perform unaligned memory accesses+      cpp-options: -DALLOW_UNALIGNED_ACCESS    Build-depends:       base                     >= 4.5          && < 5                      , conduit                  >= 1.1          && < 1.3
test/Data/Conduit/BinarySpec.hs view
@@ -20,9 +20,11 @@ import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary) import Test.QuickCheck.Gen (Gen, oneof) import Data.Word (Word8)-import Foreign.Storable (Storable, sizeOf, pokeByteOff)+import Foreign.Storable (Storable, sizeOf, pokeByteOff, alignment) import Data.Typeable (Typeable)-import Data.ByteString.Internal (unsafeCreate)+import Data.ByteString.Internal (createAndTrim')+import Foreign.Ptr (alignPtr, minusPtr)+import System.IO.Unsafe (unsafePerformIO) import Control.Applicative ((<$>), (<*>))  spec :: Spec@@ -277,19 +279,19 @@                  -> b withSomeStorable (SomeStorable x) f = f x -someStorables :: [SomeStorable] -> S.ByteString-someStorables stores0 =-    unsafeCreate size start+someStorable :: SomeStorable -> S.ByteString+someStorable store =+    fst $ unsafePerformIO $ createAndTrim' (size + align) start   where-    size = sum $ map (\x -> withSomeStorable x sizeOf) stores0+    size = withSomeStorable store sizeOf+    align = withSomeStorable store alignment+    start ptr = do+        let off = minusPtr ptr (alignPtr ptr align)+        withSomeStorable store (pokeByteOff ptr off)+        return (off, size, ()) -    start ptr =-        go stores0 0-      where-        go [] _ = return ()-        go (x:rest) off = do-            withSomeStorable x (pokeByteOff ptr off)-            go rest (off + withSomeStorable x sizeOf)+someStorables :: [SomeStorable] -> S.ByteString+someStorables = S.concat . map someStorable  it' :: String -> IO () -> Spec it' = it