summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/ByteOrder.hs
blob: 9639bc5e1c387c489ab44f10f0618557ed2c93d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  GHC.ByteOrder
-- Copyright   :  (c) The University of Glasgow, 1994-2000
-- License     :  see libraries/base/LICENSE
--
-- Maintainer  :  cvs-ghc@haskell.org
-- Stability   :  internal
-- Portability :  non-portable (GHC extensions)
--
-- Target byte ordering.
--
-- @since 4.11.0.0
-----------------------------------------------------------------------------

module GHC.ByteOrder where

-- Required for WORDS_BIGENDIAN
#include <ghcautoconf.h>

import GHC.Generics (Generic)

-- | Byte ordering.
data ByteOrder
    = BigEndian    -- ^ most-significant-byte occurs in lowest address.
    | LittleEndian -- ^ least-significant-byte occurs in lowest address.
    deriving ( Eq      -- ^ @since 4.11.0.0
             , Ord     -- ^ @since 4.11.0.0
             , Bounded -- ^ @since 4.11.0.0
             , Enum    -- ^ @since 4.11.0.0
             , Read    -- ^ @since 4.11.0.0
             , Show    -- ^ @since 4.11.0.0
             , Generic -- ^ @since 4.15.0.0
             )

-- | The byte ordering of the target machine.
targetByteOrder :: ByteOrder
#if defined(WORDS_BIGENDIAN)
targetByteOrder = BigEndian
#else
targetByteOrder = LittleEndian
#endif