-- GENERATED by C->Haskell Compiler, version 0.28.6 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


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

module Foreign.CUDA.Runtime.Utils (

  runtimeVersion,
  driverVersion,
  libraryVersion,

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





{-# LINE 21 "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 41 "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 53 "src/Foreign/CUDA/Runtime/Utils.chs" #-}



-- |
-- Return the version number of the CUDA library (API) that this package was
-- compiled against.
--
{-# INLINEABLE libraryVersion #-}
libraryVersion :: Int
libraryVersion = 10000
{-# LINE 62 "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))