dynamic-linker-template-0.1.0.0: Automatically derive dynamic linking methods from a data type.

Safe HaskellNone

System.Posix.DynamicLinker.Template

Synopsis

Documentation

makeDynamicLinkerSource

Arguments

:: Name

Name of the data type

-> Callconv

Calling convention: CCall or StdCall

-> Name

Name of the function used to transform symbol names

-> Q [Dec] 

Generate dynamic linking FFI methods for each field in the first parameter

data DL

Flags for dlsym. Notice that Next might not be available on your particular platform!

Instances

id :: a -> a

Identity function.

data FunPtr a

A value of type FunPtr a is a pointer to a function callable from foreign code. The type a will normally be a foreign type, a function type with zero or more arguments where

A value of type FunPtr a may be a pointer to a foreign function, either returned by another foreign function or imported with a a static address import like

 foreign import ccall "stdlib.h &free"
   p_free :: FunPtr (Ptr a -> IO ())

or a pointer to a Haskell function created using a wrapper stub declared to produce a FunPtr of the correct type. For example:

 type Compare = Int -> Int -> Bool
 foreign import ccall "wrapper"
   mkCompare :: Compare -> IO (FunPtr Compare)

Calls to wrapper stubs like mkCompare allocate storage, which should be released with freeHaskellFunPtr when no longer required.

To convert FunPtr values to corresponding Haskell functions, one can define a dynamic stub for the specific foreign type, e.g.

 type IntFunction = CInt -> IO ()
 foreign import ccall "dynamic" 
   mkFun :: FunPtr IntFunction -> IntFunction

Instances

Eq (FunPtr a) 
Ord (FunPtr a) 
Show (FunPtr a)