[commit: base] master: Revert "expose new Word operation to swap endianness for Word{16, 32, 64}" (2f8c5bf)
Simon Peyton Jones
simonpj at microsoft.com
Wed Jun 12 00:32:39 CEST 2013
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
https://github.com/ghc/packages-base/commit/2f8c5bff9ccb762b34467e069f208f28538cc18e
>---------------------------------------------------------------
commit 2f8c5bff9ccb762b34467e069f208f28538cc18e
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Tue Jun 11 21:50:04 2013 +0100
Revert "expose new Word operation to swap endianness for Word{16,32,64}"
This reverts commit 3ef0f91d4e9a3649581557ec4ba663db4306d7d5.
>---------------------------------------------------------------
Data/Word.hs | 18 ------------------
GHC/Word.hs | 18 +-----------------
2 files changed, 1 insertions(+), 35 deletions(-)
diff --git a/Data/Word.hs b/Data/Word.hs
index c844c4d..39aa1a8 100644
--- a/Data/Word.hs
+++ b/Data/Word.hs
@@ -22,9 +22,6 @@ module Data.Word
Word,
Word8, Word16, Word32, Word64,
- -- * byte swapping
- byteSwap16, byteSwap32, byteSwap64,
-
-- * Notes
-- $notes
@@ -36,21 +33,6 @@ import GHC.Word
#ifdef __HUGS__
import Hugs.Word
-
-byteSwap16 :: Word16 -> Word16
-byteSwap16 w = (w `shift` -8) .|. (w `shift` 8)
-
-byteSwap32 :: Word32 -> Word32
-byteSwap32 w =
- (w `shift` -24) .|. (w `shift` 24)
- .|. ((w `shift` -8) .&. 0xff00) .|. ((w .&. 0xff00) `shift` 8)
-
-byteSwap64 :: Word64 -> Word64
-byteSwap64 w =
- (w `shift` -56) .|. (w `shift` 56)
- .|. ((w `shift` -40) .&. 0xff00) .|. ((w .&. 0xff00) `shift` 40)
- .|. ((w `shift` -24) .&. 0xff0000) .|. ((w .&. 0xff0000) `shift` 24)
- .|. ((w `shift` -8) .&. 0xff000000) .|. ((w .&. 0xff000000) `shift` 8)
#endif
{- $notes
diff --git a/GHC/Word.hs b/GHC/Word.hs
index 3419a24..75957df 100644
--- a/GHC/Word.hs
+++ b/GHC/Word.hs
@@ -23,10 +23,7 @@
module GHC.Word (
Word(..), Word8(..), Word16(..), Word32(..), Word64(..),
uncheckedShiftL64#,
- uncheckedShiftRL64#,
- byteSwap16,
- byteSwap32,
- byteSwap64
+ uncheckedShiftRL64#
) where
import Data.Bits
@@ -303,9 +300,6 @@ instance Bits Word16 where
instance FiniteBits Word16 where
finiteBitSize _ = 16
-byteSwap16 :: Word16 -> Word16
-byteSwap16 (W16# w#) = W16# (byteSwap16# w#)
-
{-# RULES
"fromIntegral/Word8->Word16" fromIntegral = \(W8# x#) -> W16# x#
"fromIntegral/Word16->Word16" fromIntegral = id :: Word16 -> Word16
@@ -530,9 +524,6 @@ instance Read Word32 where
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
#endif
-byteSwap32 :: Word32 -> Word32
-byteSwap32 (W32# w#) = W32# (byteSwap32# w#)
-
------------------------------------------------------------------------
-- type Word64
------------------------------------------------------------------------
@@ -781,10 +772,3 @@ instance Ix Word64 where
instance Read Word64 where
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
-#if WORD_SIZE_IN_BITS < 64
-byteSwap64 :: Word64 -> Word64
-byteSwap64 (W64# w#) = W64# (byteSwap64# w#)
-#else
-byteSwap64 :: Word64 -> Word64
-byteSwap64 (W64# w#) = W64# (byteSwap# w#)
-#endif
More information about the ghc-commits
mailing list