{-# LANGUAGE ForeignFunctionInterface #-}
module Raaz.Core.CpuSupports
( sse, sse2, sse3
, sse4_1, sse4_2
, avx, avx2
) where
import Foreign.C
import System.IO.Unsafe(unsafePerformIO)
foreign import ccall unsafe "raaz_supports_sse"
c_sse :: IO CInt
foreign import ccall unsafe "raaz_supports_sse2"
c_sse2 :: IO CInt
foreign import ccall unsafe "raaz_supports_sse3"
c_sse3 :: IO CInt
foreign import ccall unsafe "raaz_supports_sse4_1"
c_sse4_1 :: IO CInt
foreign import ccall unsafe "raaz_supports_sse4_2"
c_sse4_2 :: IO CInt
foreign import ccall unsafe "raaz_supports_avx"
c_avx :: IO CInt
foreign import ccall unsafe "raaz_supports_avx2"
c_avx2 :: IO CInt
{-# NOINLINE gccBuiltInToBool #-}
gccBuiltInToBool :: IO CInt -> Bool
gccBuiltInToBool :: IO CInt -> Bool
gccBuiltInToBool = IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> (IO CInt -> IO Bool) -> IO CInt -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CInt -> Bool) -> IO CInt -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (CInt -> CInt -> Bool
forall a. Ord a => a -> a -> Bool
>CInt
0)
sse :: Bool
sse :: Bool
sse = IO CInt -> Bool
gccBuiltInToBool IO CInt
c_sse
sse2 :: Bool
sse2 :: Bool
sse2 = IO CInt -> Bool
gccBuiltInToBool IO CInt
c_sse2
sse3 :: Bool
sse3 :: Bool
sse3 = IO CInt -> Bool
gccBuiltInToBool IO CInt
c_sse3
sse4_1 :: Bool
sse4_1 :: Bool
sse4_1 = IO CInt -> Bool
gccBuiltInToBool IO CInt
c_sse4_1
sse4_2 :: Bool
sse4_2 :: Bool
sse4_2 = IO CInt -> Bool
gccBuiltInToBool IO CInt
c_sse4_2
avx :: Bool
avx :: Bool
avx = IO CInt -> Bool
gccBuiltInToBool IO CInt
c_avx
avx2 :: Bool
avx2 :: Bool
avx2 = IO CInt -> Bool
gccBuiltInToBool IO CInt
c_avx2