-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | POSIX shared memory -- -- POSIX shared memory library. @package shared-memory @version 0.2.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 GHC.Classes.Ord MMAP.MmapFlags instance GHC.Show.Show MMAP.MmapFlags instance GHC.Classes.Eq MMAP.MmapFlags instance GHC.Classes.Ord MMAP.MmapOptionalFlag instance GHC.Show.Show MMAP.MmapOptionalFlag instance GHC.Classes.Eq MMAP.MmapOptionalFlag instance GHC.Classes.Ord MMAP.MmapSharedFlag instance GHC.Show.Show MMAP.MmapSharedFlag instance GHC.Classes.Eq MMAP.MmapSharedFlag instance GHC.Classes.Ord MMAP.ProtOption instance GHC.Show.Show MMAP.ProtOption instance GHC.Classes.Eq MMAP.ProtOption instance GHC.Show.Show MMAP.MunmapException instance GHC.Classes.Ord MMAP.MunmapException instance GHC.Classes.Eq MMAP.MunmapException instance GHC.Show.Show MMAP.MmapException instance GHC.Classes.Ord MMAP.MmapException instance GHC.Classes.Eq MMAP.MmapException instance GHC.Base.Monoid MMAP.MmapOptionalFlag instance GHC.Base.Semigroup MMAP.MmapOptionalFlag instance GHC.Base.Monoid MMAP.ProtOption instance GHC.Base.Semigroup MMAP.ProtOption instance GHC.Exception.Type.Exception MMAP.MunmapException instance GHC.Exception.Type.Exception MMAP.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)