{-# LANGUAGE CPP #-}
-- |
-- Module      : System.Arch
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : unknown
--
module System.Arch
    ( Arch(..)
    , getSystemArch
    ) where

-- | List of all cpu architecture
data Arch = X86
          | X86_64
          | PPC
          | PPC64
          | Sparc
          | Arm
          | Mips
          | SH
          | IA64
          | S390
          | Alpha
          | Hppa
          | Rs6000
          | M68K
          | VAX
          deriving (Int -> Arch -> ShowS
[Arch] -> ShowS
Arch -> String
(Int -> Arch -> ShowS)
-> (Arch -> String) -> ([Arch] -> ShowS) -> Show Arch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Arch -> ShowS
showsPrec :: Int -> Arch -> ShowS
$cshow :: Arch -> String
show :: Arch -> String
$cshowList :: [Arch] -> ShowS
showList :: [Arch] -> ShowS
Show,Arch -> Arch -> Bool
(Arch -> Arch -> Bool) -> (Arch -> Arch -> Bool) -> Eq Arch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Arch -> Arch -> Bool
== :: Arch -> Arch -> Bool
$c/= :: Arch -> Arch -> Bool
/= :: Arch -> Arch -> Bool
Eq)

-- | Return the system's cpu architecture
getSystemArch :: Arch
#if defined(ARCH_X86)
getSystemArch = X86
#elif defined(ARCH_X86_64)
getSystemArch :: Arch
getSystemArch = Arch
X86_64
#elif defined(ARCH_PPC)
getSystemArch = PPC
#elif defined(ARCH_PPC64)
getSystemArch = PPC64
#elif defined(ARCH_SPARC)
getSystemArch = Sparc
#elif defined(ARCH_ARM)
getSystemArch = Arm
#elif defined(ARCH_MIPS)
getSystemArch = Mips
#elif defined(ARCH_SH)
getSystemArch = SH
#elif defined(ARCH_IA64)
getSystemArch = IA64
#elif defined(ARCH_S390)
getSystemArch = S390
#elif defined(ARCH_ALPHA)
getSystemArch = Alpha
#elif defined(ARCH_HPPA)
getSystemArch = Hppa
#elif defined(ARCH_RS6000)
getSystemArch = Rs6000
#elif defined(ARCH_M68K)
getSystemArch = M68K
#elif defined(ARCH_VAX)
getSystemArch = VAX
#else
getSystemArch = undefined
#endif