-- GENERATED by C->Haskell Compiler, version 0.28.2 Switcheroo, 1 April 2016 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Foreign/CUDA/Runtime/Utils.chs" #-}
{-# LANGUAGE ForeignFunctionInterface #-}
--------------------------------------------------------------------------------
-- |
-- Module    : Foreign.CUDA.Runtime.Utils
-- Copyright : [2009..2017] Trevor L. McDonell
-- License   : BSD
--
-- Utility functions
--
--------------------------------------------------------------------------------

module Foreign.CUDA.Runtime.Utils (

  runtimeVersion,
  driverVersion,

) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Ptr as C2HSImp





{-# LINE 20 "src/Foreign/CUDA/Runtime/Utils.chs" #-}


-- Friends
import Foreign.CUDA.Runtime.Error
import Foreign.CUDA.Internal.C2HS

-- System
import Foreign
import Foreign.C


-- |
-- Return the version number of the installed CUDA driver
--
{-# INLINEABLE runtimeVersion #-}
runtimeVersion :: IO Int
runtimeVersion =  resultIfOk =<< cudaRuntimeGetVersion

{-# INLINE cudaRuntimeGetVersion #-}
cudaRuntimeGetVersion :: IO ((Status), (Int))
cudaRuntimeGetVersion =
  alloca $ \a1' -> 
  cudaRuntimeGetVersion'_ a1' >>= \res ->
  let {res' = cToEnum res} in
  peekIntConv  a1'>>= \a1'' -> 
  return (res', a1'')

{-# LINE 40 "src/Foreign/CUDA/Runtime/Utils.chs" #-}



-- |
-- Return the version number of the installed CUDA runtime
--
{-# INLINEABLE driverVersion #-}
driverVersion :: IO Int
driverVersion =  resultIfOk =<< cudaDriverGetVersion

{-# INLINE cudaDriverGetVersion #-}
cudaDriverGetVersion :: IO ((Status), (Int))
cudaDriverGetVersion =
  alloca $ \a1' -> 
  cudaDriverGetVersion'_ a1' >>= \res ->
  let {res' = cToEnum res} in
  peekIntConv  a1'>>= \a1'' -> 
  return (res', a1'')

{-# LINE 52 "src/Foreign/CUDA/Runtime/Utils.chs" #-}



foreign import ccall unsafe "Foreign/CUDA/Runtime/Utils.chs.h cudaRuntimeGetVersion"
  cudaRuntimeGetVersion'_ :: ((C2HSImp.Ptr C2HSImp.CInt) -> (IO C2HSImp.CInt))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Utils.chs.h cudaDriverGetVersion"
  cudaDriverGetVersion'_ :: ((C2HSImp.Ptr C2HSImp.CInt) -> (IO C2HSImp.CInt))