[commit: ghc] master: base: Introduce GHC.ByteOrder (58545fd)
git at git.haskell.org
git at git.haskell.org
Tue Jul 25 01:07:01 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/58545fde018460a2e9d05a8659951acfb277209f/ghc
>---------------------------------------------------------------
commit 58545fde018460a2e9d05a8659951acfb277209f
Author: Ben Gamari <bgamari.foss at gmail.com>
Date: Mon Jul 24 19:54:37 2017 -0400
base: Introduce GHC.ByteOrder
This provides a ByteOrder type as well as a targetByteOrder value, which
indicates the byte ordering used by the target machine. We might also
consider exposing this via Data.Bits if the CLC is so inclined.
Test Plan: Needs test
Reviewers: hvr, RyanGlScott, austin
Reviewed By: hvr, RyanGlScott
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3786
>---------------------------------------------------------------
58545fde018460a2e9d05a8659951acfb277209f
libraries/base/GHC/ByteOrder.hs | 31 +++++++++++++++++++++++++++++++
libraries/base/base.cabal | 1 +
2 files changed, 32 insertions(+)
diff --git a/libraries/base/GHC/ByteOrder.hs b/libraries/base/GHC/ByteOrder.hs
new file mode 100644
index 0000000..eecc56c
--- /dev/null
+++ b/libraries/base/GHC/ByteOrder.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE CPP #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : GHC.ByteOrder
+-- Copyright : (c) The University of Glasgow, 1994-2000
+-- License : see libraries/base/LICENSE
+--
+-- Maintainer : cvs-ghc at haskell.org
+-- Stability : internal
+-- Portability : non-portable (GHC extensions)
+--
+-- Target byte ordering.
+--
+-----------------------------------------------------------------------------
+
+module GHC.ByteOrder where
+
+-- | Byte ordering.
+data ByteOrder
+ = BigEndian -- ^ most-significant-byte occurs in lowest address.
+ | LittleEndian -- ^ least-significant-byte occurs in lowest address.
+ deriving (Eq, Ord, Bounded, Enum, Read, Show)
+
+-- | The byte ordering of the target machine.
+targetByteOrder :: ByteOrder
+#if defined(WORDS_BIGENDIAN)
+targetByteOrder = BigEndian
+#else
+targetByteOrder = LittleEndian
+#endif
diff --git a/libraries/base/base.cabal b/libraries/base/base.cabal
index f00fb87..9429de0 100644
--- a/libraries/base/base.cabal
+++ b/libraries/base/base.cabal
@@ -202,6 +202,7 @@ Library
Foreign.Storable
GHC.Arr
GHC.Base
+ GHC.ByteOrder
GHC.Char
GHC.Conc
GHC.Conc.IO
More information about the ghc-commits
mailing list