unix-memory 0.1.1 → 0.1.2
raw patch · 4 files changed
+35/−23 lines, 4 filesdep +tastydep +tasty-hunitdep +tasty-quickcheckdep −HUnitdep −test-frameworkdep −test-framework-hunitdep ~QuickCheck
Dependencies added: tasty, tasty-hunit, tasty-quickcheck
Dependencies removed: HUnit, test-framework, test-framework-hunit, test-framework-quickcheck2
Dependency ranges changed: QuickCheck
Files
- README.md +4/−0
- System/Posix/Memory.hsc +20/−13
- tests/Tests.hs +6/−4
- unix-memory.cabal +5/−6
README.md view
@@ -1,6 +1,10 @@ unix-memory =========== +[](https://travis-ci.org/vincenthz/hs-unix-memory)+[](http://en.wikipedia.org/wiki/BSD_licenses)+[](http://haskell.org)+ Provide access to lowlevel syscalls for memory mapping. typically mmap, munmap, msync, mlock, mprotect, .. Documentation: [unix-memory on hackage](http://hackage.haskell.org/package/unix-memory)
System/Posix/Memory.hsc view
@@ -21,19 +21,22 @@ #include <unistd.h> {-# LANGUAGE ForeignFunctionInterface #-}-module System.Posix.Memory (- memoryMap,- memoryUnmap,- memoryAdvise,- memoryLock,- memoryUnlock,- memoryProtect,- memorySync,- MemoryMapFlag(..),- MemoryProtection(..),- MemoryAdvice(..),- MemorySyncFlag(..),- sysconfPageSize+{-# LANGUAGE CPP #-}+module System.Posix.Memory+ ( memoryMap+ , memoryUnmap+ , memoryAdvise+ , memoryLock+ , memoryUnlock+ , memoryProtect+ , memorySync+ -- * Flags types+ , MemoryMapFlag(..)+ , MemoryProtection(..)+ , MemoryAdvice(..)+ , MemorySyncFlag(..)+ -- * system page size+ , sysconfPageSize ) where import System.Posix.Types@@ -134,7 +137,11 @@ .|. maybe 0 (const cMapFixed) initPtr .|. toMapFlag flag +#ifdef __APPLE__+ cMapAnon = (#const MAP_ANON)+#else cMapAnon = (#const MAP_ANONYMOUS)+#endif cMapFixed = (#const MAP_FIXED) toMapFlag MemoryMapShared = (#const MAP_SHARED)
tests/Tests.hs view
@@ -1,7 +1,8 @@+{-# LANGUAGE CPP #-} module Main where -import Test.Framework (defaultMain, testGroup, Test)-import Test.Framework.Providers.QuickCheck2 (testProperty)+import Test.Tasty (defaultMain, testGroup)+import Test.Tasty.QuickCheck import Test.QuickCheck.Monadic (monadicIO, run) @@ -34,11 +35,12 @@ closeFd g -tests :: [Test]-tests =+tests = testGroup "unix-memory" [ testProperty "page-size" $ sysconfPageSize > 0 && sysconfPageSize < (2^(20::Int)) , testGroup "anonymous" $ runTestWithMapping withDummyMapping+#ifdef __APPLE__ , testGroup "fd" $ runTestWithMapping withDevZeroMapping+#endif ] where runTestWithMapping mapF = [ testProperty "mmap-munmap" $ monadicIO $ run $ mapF $ \_ -> return True
unix-memory.cabal view
@@ -1,5 +1,5 @@ Name: unix-memory-Version: 0.1.1+Version: 0.1.2 Synopsis: Unix memory syscalls Description: unix memory syscalls (mmap, munmap, madvise, msync, mlock) License: BSD3@@ -25,11 +25,10 @@ Main-is: Tests.hs Build-Depends: base >= 3 && < 5 , mtl- , QuickCheck >= 2- , HUnit- , test-framework- , test-framework-quickcheck2- , test-framework-hunit+ , tasty+ , tasty-hunit+ , tasty-quickcheck+ , QuickCheck , unix , unix-memory ghc-options: -Wall -fno-warn-orphans -fno-warn-missing-signatures