Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

compile with ghc 6.12.3 #5

Open
wants to merge 1 commit into from

2 participants

@markwright

Please review it very carefully and let me know where its broken so I can fix it. I can rebase the pull request to fix it. Currently it makes it compile but I have little confidence that its correct.

@phonohawk
Owner

Thanks, I'll have a look at it. Let me take some time for that.

@phonohawk phonohawk commented on the diff
OpenSSL/EVP/Internal.hsc
((5 lines not shown))
mask_ $ do
withForeignPtr ctx _cipher_ctx_init
addForeignPtrFinalizer _cipher_ctx_cleanup ctx
return $ CipherCtx ctx
+#else
+ block $ do
+ withForeignPtr ctx _cipher_ctx_init
+ addForeignPtrFinalizer _cipher_ctx_cleanup ctx
+ unblock $ return $ CipherCtx ctx
@phonohawk Owner

Do we really need 'unblock' in the last line?

return $ CipherCtx ctx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@phonohawk phonohawk commented on the diff
OpenSSL/EVP/Internal.hsc
((5 lines not shown))
mask_ $ do
withForeignPtr ctx _md_ctx_init
addForeignPtrFinalizer _md_ctx_cleanup ctx
return $ DigestCtx ctx
+#else
+ block $ do
+ withForeignPtr ctx _md_ctx_init
+ addForeignPtrFinalizer _md_ctx_cleanup ctx
+ unblock $ return $ DigestCtx ctx
@phonohawk Owner

Likewise.

return $ DigestCtx ctx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@phonohawk phonohawk commented on the diff
OpenSSL/EVP/Internal.hsc
((5 lines not shown))
createPKey f = mask $ \restore -> do
ptr <- _pkey_new >>= failIfNull
(restore $ f ptr >> return ()) `onException` _pkey_free' ptr
wrapPKeyPtr ptr
+#else
+createPKey f = block $ do
+ ptr <- _pkey_new >>= failIfNull
+ (f ptr >> return ()) `onException` _pkey_free' ptr
+ unblock $ wrapPKeyPtr ptr
@phonohawk Owner

Shouldn't this be something like this?

createPKey f = block $ do
  ptr <- _pkey_new >>= failIfNull
  (unblock $ f ptr >> return ()) `onException` _pkey_free' ptr
  wrapPKeyPtr ptr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@phonohawk
Owner

I reviewed your patch and found some changes that don't look identical to the original code.
Could you take a look at them?
(Sorry for being late.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 27, 2011
  1. @markwright

    Compiles with ghc 6.12.3

    markwright authored
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 1 deletion.
  1. +23 −1 OpenSSL/EVP/Internal.hsc
View
24 OpenSSL/EVP/Internal.hsc
@@ -50,11 +50,12 @@ import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
import qualified Data.ByteString.Lazy.Internal as L8
import Control.Applicative ((<$>))
-import Control.Exception (mask, mask_, bracket_, onException)
import Foreign.C.Types (CChar)
#if __GLASGOW_HASKELL__ >= 703
+import Control.Exception (mask, mask_, bracket_, onException)
import Foreign.C.Types (CInt(..), CUInt(..), CSize(..))
#else
+import Control.Exception (block, unblock, bracket_, onException)
import Foreign.C.Types (CInt, CUInt, CSize)
#endif
import Foreign.Ptr (Ptr, castPtr, FunPtr)
@@ -104,10 +105,17 @@ foreign import ccall unsafe "HsOpenSSL_EVP_CIPHER_CTX_block_size"
newCipherCtx :: IO CipherCtx
newCipherCtx = do
ctx <- mallocForeignPtrBytes (#size EVP_CIPHER_CTX)
+#if __GLASGOW_HASKELL__ >= 703
mask_ $ do
withForeignPtr ctx _cipher_ctx_init
addForeignPtrFinalizer _cipher_ctx_cleanup ctx
return $ CipherCtx ctx
+#else
+ block $ do
+ withForeignPtr ctx _cipher_ctx_init
+ addForeignPtrFinalizer _cipher_ctx_cleanup ctx
+ unblock $ return $ CipherCtx ctx
@phonohawk Owner

Do we really need 'unblock' in the last line?

return $ CipherCtx ctx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+#endif
withCipherCtxPtr :: CipherCtx -> (Ptr EVP_CIPHER_CTX -> IO a) -> IO a
withCipherCtxPtr (CipherCtx ctx) = withForeignPtr ctx
@@ -186,10 +194,17 @@ foreign import ccall unsafe "&EVP_MD_CTX_cleanup"
newDigestCtx :: IO DigestCtx
newDigestCtx = do
ctx <- mallocForeignPtrBytes (#size EVP_MD_CTX)
+#if __GLASGOW_HASKELL__ >= 703
mask_ $ do
withForeignPtr ctx _md_ctx_init
addForeignPtrFinalizer _md_ctx_cleanup ctx
return $ DigestCtx ctx
+#else
+ block $ do
+ withForeignPtr ctx _md_ctx_init
+ addForeignPtrFinalizer _md_ctx_cleanup ctx
+ unblock $ return $ DigestCtx ctx
@phonohawk Owner

Likewise.

return $ DigestCtx ctx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+#endif
withDigestCtxPtr :: DigestCtx -> (Ptr EVP_MD_CTX -> IO a) -> IO a
withDigestCtxPtr (DigestCtx ctx) = withForeignPtr ctx
@@ -286,10 +301,17 @@ wrapPKeyPtr :: Ptr EVP_PKEY -> IO VaguePKey
wrapPKeyPtr = fmap VaguePKey . newForeignPtr _pkey_free
createPKey :: (Ptr EVP_PKEY -> IO a) -> IO VaguePKey
+#if __GLASGOW_HASKELL__ >= 703
createPKey f = mask $ \restore -> do
ptr <- _pkey_new >>= failIfNull
(restore $ f ptr >> return ()) `onException` _pkey_free' ptr
wrapPKeyPtr ptr
+#else
+createPKey f = block $ do
+ ptr <- _pkey_new >>= failIfNull
+ (f ptr >> return ()) `onException` _pkey_free' ptr
+ unblock $ wrapPKeyPtr ptr
@phonohawk Owner

Shouldn't this be something like this?

createPKey f = block $ do
  ptr <- _pkey_new >>= failIfNull
  (unblock $ f ptr >> return ()) `onException` _pkey_free' ptr
  wrapPKeyPtr ptr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+#endif
withPKeyPtr :: VaguePKey -> (Ptr EVP_PKEY -> IO a) -> IO a
withPKeyPtr (VaguePKey pkey) = withForeignPtr pkey
Something went wrong with that request. Please try again.