-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | POSIX shared memory
--
@package shared-memory
@version 0.1.0.0
-- | Provides mmap: mapping files into memory.
module MMAP
-- | Exception thrown when mmap fails.
data MmapException
MmapException :: MmapException
-- | Exception thrown when munmap fails.
data MunmapException
MunmapException :: CSize -> Ptr () -> MunmapException
munmapExceptionSize :: MunmapException -> CSize
munmapExceptionPtr :: MunmapException -> Ptr ()
-- | mmap - map files or devices into memory.
--
-- The returned memory should be freed with c_munmap after use.
--
-- This is the raw C function, and its return value must be checked
-- according to man mmap.
--
-- See mmap for a variant that turns bad return values into
-- exceptions.
c_mmap :: Ptr () -> CSize -> ProtOption -> MmapFlags -> Fd -> COff -> IO (Ptr ())
-- | munmap - unmap mmap'ed memory.
--
-- This is the raw C function, and its return value must be checked
-- according to man mmap.
--
-- See munmap for a variant that turns bad return values into
-- exceptions.
c_munmap :: Ptr () -> CSize -> IO CInt
-- | Convenience around c_mmap, throwing a MmapException on a
-- negative return value.
mmap :: Ptr () -> CSize -> ProtOption -> MmapFlags -> Fd -> COff -> IO (Ptr ())
-- | Convenience around c_munmap, throwing a MunmapException
-- on a negative return value.
munmap :: Ptr () -> CSize -> IO ()
-- | Describes the desired memory protection of the mapping (and must not
-- conflict with the open mode of the file).
--
-- Can be combined using the Monoid instance `(<>)`.
newtype ProtOption
ProtOption :: CInt -> ProtOption
unProtOption :: ProtOption -> CInt
-- | Pages may be executed.
protExec :: ProtOption
-- | Pages may be read.
protRead :: ProtOption
-- | Pages may be written.
protWrite :: ProtOption
-- | Pages may not be accessed.
protNone :: ProtOption
-- | Determines whether updates to the mapping are visible to other
-- processes mapping the same region, and whether updates are carried
-- through to the underlying file.
--
-- This behavior is determined by including exactly one of
-- mapShared and mapPrivate.
newtype MmapSharedFlag
MmapSharedFlag :: CInt -> MmapSharedFlag
unMmapSharedFlag :: MmapSharedFlag -> CInt
-- | Share this mapping. Updates to the mapping are visible to other
-- processes that map the file, and are carried through to the underlying
-- file. The file may not actually be updated until msync(2) or
-- munmap() is called..
mapShared :: MmapSharedFlag
-- | Create a private copy-on-write mapping. Updates to the mapping are not
-- visible to other processes mapping the same file, and are not carried
-- through to the underlying file. It is unspecified whether changes made
-- to the file after the mmap() call are visible in the mapped
-- region.
mapPrivate :: MmapSharedFlag
-- | And MmapSharedFlag with one or more MmapOptionalFlags.
newtype MmapOptionalFlag
MmapOptionalFlag :: CInt -> MmapOptionalFlag
unMmapOptionalFlag :: MmapOptionalFlag -> CInt
-- | See man mmap for a description.
map32Bit :: MmapOptionalFlag
-- | See man mmap for a description.
mapAnonymous :: MmapOptionalFlag
-- | See man mmap for a description.
mapDenywrite :: MmapOptionalFlag
-- | See man mmap for a description.
mapFile :: MmapOptionalFlag
-- | See man mmap for a description.
mapFixed :: MmapOptionalFlag
-- | See man mmap for a description.
mapHugetlb :: MmapOptionalFlag
-- | See man mmap for a description.
mapLocked :: MmapOptionalFlag
-- | See man mmap for a description.
mapNonblock :: MmapOptionalFlag
-- | See man mmap for a description.
mapNoreserve :: MmapOptionalFlag
-- | See man mmap for a description.
mapStack :: MmapOptionalFlag
-- | An MmapSharedFlag with one or more MmapOptionalFlags.
newtype MmapFlags
MmapFlags :: CInt -> MmapFlags
unMmapFlags :: MmapFlags -> CInt
-- | Create MmapFlags to be passed to c_mmap from an
-- MmapSharedFlag and one or more MmapOptionalFlags
-- (combine them via `(<>)`, mempty for none).
mkMmapFlags :: MmapSharedFlag -> MmapOptionalFlag -> MmapFlags
instance Typeable MmapException
instance Typeable MunmapException
instance Eq MmapException
instance Ord MmapException
instance Show MmapException
instance Eq MunmapException
instance Ord MunmapException
instance Show MunmapException
instance Eq ProtOption
instance Show ProtOption
instance Ord ProtOption
instance Eq MmapSharedFlag
instance Show MmapSharedFlag
instance Ord MmapSharedFlag
instance Eq MmapOptionalFlag
instance Show MmapOptionalFlag
instance Ord MmapOptionalFlag
instance Eq MmapFlags
instance Show MmapFlags
instance Ord MmapFlags
instance Monoid MmapOptionalFlag
instance Monoid ProtOption
instance Exception MunmapException
instance Exception MmapException
-- | Provides shared memory for IPC (Inter Process Communication).
module SharedMemory
-- | openSharedMemory shmemPath size openFlags openFileMode:
-- Creates a shared memory file using shm_open at
-- shmemPath of size bytes, returning the created
-- Fd and ForeignPtr pointing to the mmap'ed
-- memory.
--
-- The Fd can be used to resize the shared memory region.
--
-- When the returned ForeignPtr is garbage collected, the memory
-- is munmap'ed, but the Fd remains open until it is
-- closed or garbage collected.
--
-- Closing the Fd will not invalidate the returned
-- ForeignPtr.
openSharedMemory :: String -> CSize -> ShmOpenFlags -> FileMode -> IO (ForeignPtr (), Fd)