From 54ea6dc32dd0be72df4d198a9db23afa0938b55e Mon Sep 17 00:00:00 2001 From: Emil Karlson Date: Thu, 29 Dec 2011 05:24:55 +0200 Subject: [PATCH] Fix ContextProperties to proper type. Conflicts: System/OpenCL/Wrappers/Context.hs System/OpenCL/Wrappers/Types.hs --- System/OpenCL/Wrappers/Context.hs | 10 +++++----- System/OpenCL/Wrappers/Raw.hs | 2 +- System/OpenCL/Wrappers/Types.hs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/System/OpenCL/Wrappers/Context.hs b/System/OpenCL/Wrappers/Context.hs index d6233d7..f7dc414 100644 --- a/System/OpenCL/Wrappers/Context.hs +++ b/System/OpenCL/Wrappers/Context.hs @@ -10,19 +10,19 @@ where import System.OpenCL.Wrappers.Types import System.OpenCL.Wrappers.Utils import System.OpenCL.Wrappers.Raw -import Foreign.Ptr(Ptr, nullPtr, nullFunPtr) +import Foreign.Ptr(Ptr, nullPtr, nullFunPtr,ptrToIntPtr) import Foreign.Marshal.Array(withArray) clCreateContext :: [ContextProperties] -> [DeviceID] -> Maybe ContextCallback -> Ptr () -> IO Context -clCreateContext properties devices pfn_notify user_dat = - withArrayNull0 nullPtr properties $ \propertiesP -> withArray devices $ \devicesP -> do +clCreateContext props devices pfn_notify user_dat = + withArrayNull0 (ContextProperties$ptrToIntPtr nullPtr) props $ \propertiesP -> withArray devices $ \devicesP -> do fptr <- maybe (return nullFunPtr) wrapContextCallback pfn_notify - wrapErrorResult $ raw_clCreateContext propertiesP (fromIntegral devicesN) devicesP fptr user_dat + wrapErrorResult $ raw_clCreateContext propertiesP (fromIntegral devicesN) devicesP fptr user_dat where devicesN = length devices clCreateContextFromType :: [ContextProperties] -> DeviceType -> Maybe ContextCallback -> Ptr () -> IO Context -clCreateContextFromType properties (DeviceType device_type) pfn_notify user_data = withArrayNull0 nullPtr properties $ \propertiesP -> do +clCreateContextFromType props (DeviceType device_type) pfn_notify user_data = withArrayNull0(ContextProperties$ptrToIntPtr nullPtr) props $ \propertiesP -> do fptr <- maybe (return nullFunPtr) wrapContextCallback pfn_notify wrapErrorResult $ raw_clCreateContextFromType propertiesP device_type fptr user_data diff --git a/System/OpenCL/Wrappers/Raw.hs b/System/OpenCL/Wrappers/Raw.hs index d716d0f..1d83659 100644 --- a/System/OpenCL/Wrappers/Raw.hs +++ b/System/OpenCL/Wrappers/Raw.hs @@ -88,7 +88,7 @@ foreign import ccall "clRetainCommandQueue" raw_clRetainCommandQueue :: CommandQ foreign import ccall "clReleaseCommandQueue" raw_clReleaseCommandQueue :: CommandQueue -> IO CLint foreign import ccall "clGetCommandQueueInfo" raw_clGetCommandQueueInfo :: CommandQueue -> CLuint -> CLsizei -> Ptr () -> Ptr CLsizei -> IO CLint foreign import ccall "clSetCommandQueueProperty" raw_clSetCommandQueueProperty :: CommandQueue -> CLbitfield -> CLbool -> Ptr CLbitfield -> IO CLint -foreign import ccall "clCreateContext" raw_clCreateContext :: Ptr (Ptr CLint) -> CLuint -> Ptr DeviceID -> FunPtr ContextCallback -> Ptr () -> Ptr CLint -> IO Context +foreign import ccall "clCreateContext" raw_clCreateContext :: Ptr ContextProperties -> CLuint -> Ptr DeviceID -> FunPtr ContextCallback -> Ptr () -> Ptr CLint -> IO Context foreign import ccall "clCreateContextFromType" raw_clCreateContextFromType :: Ptr ContextProperties -> CLbitfield -> FunPtr ContextCallback -> Ptr a -> Ptr CLint -> IO Context foreign import ccall "clRetainContext" raw_clRetainContext :: Context -> IO CLint foreign import ccall "clReleaseContext" raw_clReleaseContext :: Context -> IO CLint diff --git a/System/OpenCL/Wrappers/Types.hs b/System/OpenCL/Wrappers/Types.hs index 250d202..02e5e5b 100644 --- a/System/OpenCL/Wrappers/Types.hs +++ b/System/OpenCL/Wrappers/Types.hs @@ -20,7 +20,6 @@ data Eventc = Eventc data Samplerc = Samplerc data ImageFormatc = ImageFormatc -type ContextProperties = Ptr CLint type PlatformID = Ptr PlatformIDc type DeviceID = Ptr DeviceIDc type Context = Ptr Contextc @@ -42,6 +41,8 @@ type ImageFormatp = Ptr ImageFormat type ImageFormat = (ChannelOrder,ChannelType) type ImageDims = (CLsizei,CLsizei,CLsizei) +newtype ContextProperties = ContextProperties IntPtr + deriving (Eq,Storable,Show) newtype ChannelOrder = ChannelOrder CLuint deriving (Eq,Show) newtype ChannelType = ChannelType CLuint @@ -603,9 +604,8 @@ clContextDevices = ContextInfo 0x1081 clContextProperties :: ContextInfo clContextProperties = ContextInfo 0x1082 -clContextPlatform :: ContextInfo -clContextPlatform = ContextInfo 0x1084 - +clContextPlatform :: ContextProperties +clContextPlatform = ContextProperties 0x1084 clKernelFunctionName :: KernelInfo