{-# LANGUAGE CPP #-}
module Flat.Endian
(
toBE32
, toBE64
, toBE16
, isBigEndian
) where
#include "MachDeps.h"
import Data.Word (Word16, Word32, Word64, byteSwap16, byteSwap32,
byteSwap64)
isBigEndian :: Bool
isBigEndian :: Bool
isBigEndian =
#if defined(WORDS_BIGENDIAN) || defined(ETA_VERSION)
True
#else
Bool
False
#endif
toBE64 :: Word64 -> Word64
#if defined(WORDS_BIGENDIAN) || defined(ETA_VERSION)
toBE64 = id
#else
toBE64 :: Word64 -> Word64
toBE64 = Word64 -> Word64
byteSwap64
#endif
toBE32 :: Word32 -> Word32
#if defined(WORDS_BIGENDIAN) || defined(ETA_VERSION)
toBE32 = id
#else
toBE32 :: Word32 -> Word32
toBE32 = Word32 -> Word32
byteSwap32
#endif
toBE16 :: Word16 -> Word16
#if defined(WORDS_BIGENDIAN) || defined(ETA_VERSION)
toBE16 = id
#else
toBE16 :: Word16 -> Word16
toBE16 = Word16 -> Word16
byteSwap16
#endif