From 7832cb74240ba06a23a981c20db3c5da8324828a Mon Sep 17 00:00:00 2001 From: Clark Gaebel Date: Sat, 10 Mar 2012 22:47:13 -0500 Subject: Added back some safety. --- lib/Numeric/GSL/Integration.hs | 12 ++++++------ lib/Numeric/GSL/Internal.hs | 10 +++++----- lib/Numeric/GSL/Minimization.hs | 4 ++-- lib/Numeric/GSL/ODE.hs | 2 +- lib/Numeric/GSL/Root.hs | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/Numeric/GSL/Integration.hs b/lib/Numeric/GSL/Integration.hs index b1e7930..defbf80 100644 --- a/lib/Numeric/GSL/Integration.hs +++ b/lib/Numeric/GSL/Integration.hs @@ -32,7 +32,7 @@ import System.IO.Unsafe(unsafePerformIO) {- | conversion of Haskell functions into function pointers that can be used in the C side -} -foreign import ccall unsafe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) +foreign import ccall safe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) -------------------------------------------------------------------- {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: @@ -63,7 +63,7 @@ integrateQAGS prec n f a b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qags" +foreign import ccall safe "gsl-aux.h integrate_qags" c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -94,7 +94,7 @@ integrateQNG prec f a b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qng" +foreign import ccall safe "gsl-aux.h integrate_qng" c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> Ptr Double -> Ptr Double -> IO CInt @@ -126,7 +126,7 @@ integrateQAGI prec n f = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qagi" +foreign import ccall safe "gsl-aux.h integrate_qagi" c_integrate_qagi :: FunPtr (Double-> Ptr() -> Double) -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -159,7 +159,7 @@ integrateQAGIU prec n f a = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qagiu" +foreign import ccall safe "gsl-aux.h integrate_qagiu" c_integrate_qagiu :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -192,7 +192,7 @@ integrateQAGIL prec n f b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qagil" +foreign import ccall safe "gsl-aux.h integrate_qagil" c_integrate_qagil :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt diff --git a/lib/Numeric/GSL/Internal.hs b/lib/Numeric/GSL/Internal.hs index 4267b38..84417ce 100644 --- a/lib/Numeric/GSL/Internal.hs +++ b/lib/Numeric/GSL/Internal.hs @@ -26,14 +26,14 @@ iv f n p = f (createV (fromIntegral n) copy "iv") where return 0 -- | conversion of Haskell functions into function pointers that can be used in the C side -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkVecfun :: (CInt -> Ptr Double -> Double) -> IO( FunPtr (CInt -> Ptr Double -> Double)) -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkVecVecfun :: TVV -> IO (FunPtr TVV) -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkDoubleVecVecfun :: (Double -> TVV) -> IO (FunPtr (Double -> TVV)) aux_vTov :: (Vector Double -> Vector Double) -> TVV @@ -46,10 +46,10 @@ aux_vTov f n p nr r = g where g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) return 0 -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkVecMatfun :: TVM -> IO (FunPtr TVM) -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkDoubleVecMatfun :: (Double -> TVM) -> IO (FunPtr (Double -> TVM)) aux_vTom :: (Vector Double -> Matrix Double) -> TVM diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs index 21ac8a1..af85135 100644 --- a/lib/Numeric/GSL/Minimization.hs +++ b/lib/Numeric/GSL/Minimization.hs @@ -122,7 +122,7 @@ minimizeV method eps maxit szv f xiv = unsafePerformIO $ do return (sol, path) -foreign import ccall unsafe "gsl-aux.h minimize" +foreign import ccall safe "gsl-aux.h minimize" c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM ---------------------------------------------------------------------------------- @@ -179,7 +179,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do freeHaskellFunPtr dfp return (sol,path) -foreign import ccall unsafe "gsl-aux.h minimizeD" +foreign import ccall safe "gsl-aux.h minimizeD" c_minimizeD :: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> FunPtr TVV diff --git a/lib/Numeric/GSL/ODE.hs b/lib/Numeric/GSL/ODE.hs index 797ba3f..4d2beed 100644 --- a/lib/Numeric/GSL/ODE.hs +++ b/lib/Numeric/GSL/ODE.hs @@ -91,7 +91,7 @@ odeSolveV method h epsAbs epsRel f mbjac xiv ts = unsafePerformIO $ do freeHaskellFunPtr fp return sol -foreign import ccall unsafe "ode" +foreign import ccall safe "ode" ode_c :: CInt -> Double -> Double -> Double -> FunPtr (Double -> TVV) -> FunPtr (Double -> TVM) -> TVVM ------------------------------------------------------- diff --git a/lib/Numeric/GSL/Root.hs b/lib/Numeric/GSL/Root.hs index 4128846..cd2982a 100644 --- a/lib/Numeric/GSL/Root.hs +++ b/lib/Numeric/GSL/Root.hs @@ -91,7 +91,7 @@ rootGen m f xi epsabs maxit = unsafePerformIO $ do return (take n $ drop 1 sol, path) -foreign import ccall unsafe "root" +foreign import ccall safe "root" c_root:: CInt -> FunPtr TVV -> Double -> CInt -> TVM ------------------------------------------------------------------------- @@ -130,7 +130,7 @@ rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do return (take n $ drop 1 sol, path) -foreign import ccall unsafe "rootj" +foreign import ccall safe "rootj" c_rootj:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> CInt -> TVM ------------------------------------------------------- -- cgit v1.2.3