packages feed

lukko 0.1.1.1 → 0.1.1.2

raw patch · 3 files changed

+27/−40 lines, 3 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

lukko.cabal view
@@ -1,14 +1,14 @@ cabal-version:      2.2 name:               lukko-version:            0.1.1.1+version:            0.1.1.2 synopsis:           File locking category:           System, Concurrency description:   This package provides access to platform dependent file locking APIs:   .-  * Open file descriptor locking on Linux ("Lukko.OFD")-  * @flock@ locking on unix platforms ("Lukko.FLock")-  * Windows locking @LockFileEx@ ("Lukko.Windows")+  * <https://www.gnu.org/software/libc/manual/html_node/Open-File-Description-Locks.html Open file descriptor locking> on Linux ("Lukko.OFD")+  * BSD-style @flock(2)@ locks on UNIX platforms ("Lukko.FLock")+  * Windows locking via <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-lockfilee LockFileEx> ("Lukko.Windows")   * No-op locking, which throws exceptions ("Lukko.NoOp")   * "Lukko" module exports the best option for the target platform with uniform API.   .@@ -52,7 +52,8 @@    || ==8.2.2    || ==8.4.4    || ==8.6.5-   || ==8.8.1+   || ==8.8.3+   || ==8.10.1  source-repository head   type:     git@@ -67,7 +68,7 @@ library   default-language:   Haskell2010   hs-source-dirs:     src-  build-depends:      base >=4.5 && <4.14+  build-depends:      base >=4.5 && <4.15   build-tool-depends: hsc2hs:hsc2hs >=0.67 && <0.69    -- Main library module
src-flock/Lukko/FLock.hsc view
@@ -2,7 +2,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE Trustworthy #-}--- | File locking via POSIX @flock@.+-- | File locking via BSD-style @flock(2)@. module Lukko.FLock (     -- * Types     FileLockingNotSupported(..),@@ -58,15 +58,15 @@ -- FD ------------------------------------------------------------------------------- --- | Lock using OFD locks.+-- | Lock using BSD-style locks. fdLock :: FD -> LockMode -> IO () fdLock fd mode = void (lockImpl Nothing fd "fdLock" mode True) --- | Try to lock using OFD locks.+-- | Try to lock using BSD-style locks. fdTryLock :: FD -> LockMode -> IO Bool fdTryLock fd mode = lockImpl Nothing fd "fdTryLock" mode False --- | Unlock using OFD locks.+-- | Unlock using BSD-style locks. fdUnlock :: FD -> IO () fdUnlock = unlockImpl @@ -74,19 +74,19 @@ -- Handle ------------------------------------------------------------------------------- --- | Lock using OFD locks.+-- | Lock using BSD-style locks. hLock :: Handle -> LockMode -> IO () hLock h mode = do     fd <- handleToFd h     void (lockImpl (Just h) fd "hLock" mode True) --- | Try to lock using OFD locks.+-- | Try to lock using BSD-style locks. hTryLock :: Handle -> LockMode -> IO Bool hTryLock h mode = do     fd <- handleToFd h     lockImpl (Just h) fd "hTryLock" mode False --- | Unlock using OFD locks.+-- | Unlock using BSD-style locks. hUnlock :: Handle -> IO () hUnlock h = do     fd <- handleToFd h
src-windows/Lukko/Windows.hsc view
@@ -2,6 +2,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE Trustworthy #-}+ -- | File locking for Windows. module Lukko.Windows (     -- * Types@@ -43,9 +44,9 @@ import Lukko.Internal.Types  #if defined(i386_HOST_ARCH)-#define WINDOWS_CCONV stdcall+##define WINDOWS_CCONV stdcall #elif defined(x86_64_HOST_ARCH)-#define WINDOWS_CCONV ccall+##define WINDOWS_CCONV ccall #else #error Unknown mingw32 arch #endif@@ -69,15 +70,15 @@ -- FD ------------------------------------------------------------------------------- --- | Lock using OFD locks.+-- | Lock using Win32 locks. fdLock :: FD -> LockMode -> IO () fdLock fd mode = void (lockImpl Nothing fd "fdLock" mode True) --- | Try to lock using OFD locks.+-- | Try to lock using Win32 locks. fdTryLock :: FD -> LockMode -> IO Bool fdTryLock fd mode = lockImpl Nothing fd "fdTryLock" mode False --- | Unlock using OFD locks.+-- | Unlock using Win32 locks. fdUnlock :: FD -> IO () fdUnlock = unlockImpl @@ -85,19 +86,19 @@ -- Handle ------------------------------------------------------------------------------- --- | Lock using OFD locks.+-- | Lock using Win32 locks. hLock :: Handle -> LockMode -> IO () hLock h mode = do     fd <- handleToFd h     void (lockImpl (Just h) fd "hLock" mode True) --- | Try to lock using OFD locks.+-- | Try to lock using Win32 locks. hTryLock :: Handle -> LockMode -> IO Bool hTryLock h mode = do     fd <- handleToFd h     lockImpl (Just h) fd "hTryLock" mode False --- | Unlock using OFD locks.+-- | Unlock using Win32 locks. hUnlock :: Handle -> IO () hUnlock h = do     fd <- handleToFd h@@ -117,7 +118,7 @@     -- "locking a region that goes beyond the current end-of-file position is     -- not an error", hence we pass maximum value as the number of bytes to     -- lock.-    fix $ \retry -> c_LockFileEx wh flags 0 0xffffffff 0xffffffff ovrlpd >>= \res -> case res of+    fix $ \retry -> c_LockFileEx wh flags 0 #{const INFINITE} #{const INFINITE} ovrlpd >>= \res -> case res of       True  -> return True       False -> getLastError >>= \err -> case () of         _ | not block && err == #{const ERROR_LOCK_VIOLATION} -> return False@@ -134,31 +135,16 @@ unlockImpl (FD wh) = do   allocaBytes sizeof_OVERLAPPED $ \ovrlpd -> do     fillBytes ovrlpd 0 sizeof_OVERLAPPED-    c_UnlockFileEx wh 0 0xffffffff 0xffffffff ovrlpd >>= \res -> case res of+    c_UnlockFileEx wh 0 #{const INFINITE} #{const INFINITE} ovrlpd >>= \res -> case res of       True  -> return ()       False -> getLastError >>= failWith "fdUnlock"   where     sizeof_OVERLAPPED = #{size OVERLAPPED}-#if defined(i386_HOST_ARCH)  -- https://docs.microsoft.com/en-gb/windows/win32/api/fileapi/nf-fileapi-lockfileex-foreign import stdcall interruptible "LockFileEx"-  c_LockFileEx :: HANDLE -> DWORD -> DWORD -> DWORD -> DWORD -> Ptr () -> IO BOOL---- https://docs.microsoft.com/en-gb/windows/win32/api/fileapi/nf-fileapi-unlockfileex-foreign import stdcall interruptible "UnlockFileEx"-  c_UnlockFileEx :: HANDLE -> DWORD -> DWORD -> DWORD -> Ptr () -> IO BOOL--#elif defined(x86_64_HOST_ARCH)---- https://docs.microsoft.com/en-gb/windows/win32/api/fileapi/nf-fileapi-lockfileex-foreign import ccall interruptible "LockFileEx"+foreign import WINDOWS_CCONV interruptible "LockFileEx"   c_LockFileEx :: HANDLE -> DWORD -> DWORD -> DWORD -> DWORD -> Ptr () -> IO BOOL  -- https://docs.microsoft.com/en-gb/windows/win32/api/fileapi/nf-fileapi-unlockfileex-foreign import ccall interruptible "UnlockFileEx"+foreign import WINDOWS_CCONV interruptible "UnlockFileEx"   c_UnlockFileEx :: HANDLE -> DWORD -> DWORD -> DWORD -> Ptr () -> IO BOOL--#else-#error Unknown mingw32 arch-#endif