Skip to content

Commit

Permalink
Revert "expose new Word operation to swap endianness for Word{16,32,64}"
Browse files Browse the repository at this point in the history
This reverts commit 3ef0f91.
  • Loading branch information
Simon Peyton Jones committed Jun 11, 2013
1 parent a123775 commit 2f8c5bf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
18 changes: 0 additions & 18 deletions Data/Word.hs
Expand Up @@ -22,9 +22,6 @@ module Data.Word
Word,
Word8, Word16, Word32, Word64,

-- * byte swapping
byteSwap16, byteSwap32, byteSwap64,

-- * Notes

-- $notes
Expand All @@ -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
Expand Down
18 changes: 1 addition & 17 deletions GHC/Word.hs
Expand Up @@ -23,10 +23,7 @@
module GHC.Word (
Word(..), Word8(..), Word16(..), Word32(..), Word64(..),
uncheckedShiftL64#,
uncheckedShiftRL64#,
byteSwap16,
byteSwap32,
byteSwap64
uncheckedShiftRL64#
) where

import Data.Bits
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
------------------------------------------------------------------------
Expand Down Expand Up @@ -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

0 comments on commit 2f8c5bf

Please sign in to comment.