usb 0.6.0.2 → 0.6.0.3
raw patch · 2 files changed
+19/−6 lines, 2 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- System/USB/Internal.hs +17/−4
- usb.cabal +2/−2
System/USB/Internal.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE UnicodeSyntax, NoImplicitPrelude, DeriveDataTypeable #-}+{-# LANGUAGE CPP, UnicodeSyntax, NoImplicitPrelude, DeriveDataTypeable #-} module System.USB.Internal where @@ -22,7 +22,7 @@ import Foreign.ForeignPtr ( ForeignPtr, newForeignPtr, withForeignPtr) import Control.Applicative ( liftA2 ) import Control.Exception ( Exception, throwIO, bracket, bracket_- , block, unblock, onException, assert+ , onException, assert ) import Control.Monad ( Monad, return, (>>=), (>>), (=<<), fail, when, forM ) import Control.Arrow ( (&&&) )@@ -71,7 +71,20 @@ , decodeBCD ) +#if MIN_VERSION_base(4,3,0)+import Control.Exception ( mask )+#else+import Control.Exception ( blocked, block, unblock )+import Data.Function ( id )+mask ∷ ((IO α → IO α) → IO β) → IO β+mask io = do+ b ← blocked+ if b+ then io id+ else block $ io unblock+#endif + -------------------------------------------------------------------------------- -- * Initialization --------------------------------------------------------------------------------@@ -212,12 +225,12 @@ -} getDevices ∷ Ctx → IO [Device] getDevices ctx =- alloca $ \devPtrArrayPtr → block $ do+ alloca $ \devPtrArrayPtr → mask $ \restore → do numDevs ← withCtxPtr ctx $ flip c'libusb_get_device_list devPtrArrayPtr when (numDevs ≡ c'LIBUSB_ERROR_NO_MEM) $ throwIO NoMemException devPtrArray ← peek devPtrArrayPtr let freeDevPtrArray = c'libusb_free_device_list devPtrArray 0- devs ← unblock (mapPeekArray mkDev (fromIntegral numDevs) devPtrArray)+ devs ← restore (mapPeekArray mkDev (fromIntegral numDevs) devPtrArray) `onException` freeDevPtrArray freeDevPtrArray return devs
usb.cabal view
@@ -1,5 +1,5 @@ name: usb-version: 0.6.0.2+version: 0.6.0.3 cabal-version: >=1.6 build-type: Custom license: BSD3@@ -59,7 +59,7 @@ Library GHC-Options: -Wall- build-depends: base >= 4 && < 4.3+ build-depends: base >= 4 && < 4.4 , base-unicode-symbols >= 0.1.1 && < 0.3 , bindings-libusb >= 1.3 && < 1.5 , bytestring >= 0.9 && < 0.10