Foreign.LibFFI

libffi-0.2.1: A binding to libffi

Safe Haskell | None
Language | Haskell2010

Foreign.LibFFI

Description

This is the only module that normal users should need to import.

As an example, allocate 1GB of memory, zero it, and crash:

    import System.Posix.DynamicLinker
    import Foreign.Ptr
    import Foreign.LibFFI

    main = do
        malloc <- dlsym Default "malloc"
        memset <- dlsym Default "memset"
        p <- callFFI malloc (retPtr retVoid) [argCSize (2^30)]
        callFFI memset (retPtr retVoid) [argPtr p, argCInt 0, argCSize (2^30)]
        callFFI memset (retPtr retVoid) [argPtr nullPtr, argCInt 0, argCSize 1]

# Documentation

data Arg #

data RetType a #

#### Instances

Instances details

Functor RetType # |
Instance details Defined in Foreign.LibFFI.Base Methods fmap :: (a -> b) -> RetType a -> RetType b # (<$) :: a -> RetType b -> RetType a #

callFFI :: FunPtr a -> RetType b -> [Arg] -> IO b #

withRetType :: (a -> IO b) -> RetType a -> RetType b #

module Foreign.LibFFI.Types