[Pkg-haskell-commits] darcs: haskell-cpu: Ensure that getSystemEndianess is inlineable

Joachim Breitner mail at joachim-breitner.de
Fri Jun 8 11:48:37 UTC 2012


Fri Jun  8 09:04:56 UTC 2012  Joachim Breitner <mail at joachim-breitner.de>
  * Ensure that getSystemEndianess is inlineable 
  Ignore-this: 87925c2d96f84dcae8f6e8490364c980

    M ./changelog +6
    A ./patches/
    A ./patches/make-getSystemEndianness-inlineable
    A ./patches/series

Fri Jun  8 09:04:56 UTC 2012  Joachim Breitner <mail at joachim-breitner.de>
  * Ensure that getSystemEndianess is inlineable 
  Ignore-this: 87925c2d96f84dcae8f6e8490364c980
diff -rN -u old-haskell-cpu//changelog new-haskell-cpu//changelog
--- old-haskell-cpu//changelog	2012-06-08 11:48:37.084829240 +0000
+++ new-haskell-cpu//changelog	2012-06-08 11:48:37.096826673 +0000
@@ -1,3 +1,9 @@
+haskell-cpu (0.1.0-2) UNRELEASED; urgency=low
+
+  * Ensure that getSystemEndianess is inlineable 
+
+ -- Joachim Breitner <nomeata at debian.org>  Fri, 08 Jun 2012 10:34:40 +0200
+
 haskell-cpu (0.1.0-1) unstable; urgency=low
 
   * Initial release.
diff -rN -u old-haskell-cpu//patches/make-getSystemEndianness-inlineable new-haskell-cpu//patches/make-getSystemEndianness-inlineable
--- old-haskell-cpu//patches/make-getSystemEndianness-inlineable	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-cpu//patches/make-getSystemEndianness-inlineable	2012-06-08 11:48:37.100829408 +0000
@@ -0,0 +1,42 @@
+Description: Make getSystemEndianness zero cost
+Author: Joachim Breitner <nomeata at debian.org>
+Bug: https://github.com/vincenthz/hs-cpu/issues/1
+Forwarded: https://github.com/vincenthz/hs-cpu/pull/2
+
+--- haskell-cpu-0.1.0.orig/System/Endian.hs
++++ haskell-cpu-0.1.0/System/Endian.hs
+@@ -21,11 +21,10 @@ module System.Endian
+     , toBE64
+     ) where
+ 
+-import Foreign.Marshal.Alloc
+-import Foreign.Storable
+-import Foreign.Ptr
++#include "MachDeps.h"
++
++import Unsafe.Coerce (unsafeCoerce)
+ import Foreign.C.Types
+-import System.IO.Unsafe (unsafePerformIO)
+ import Data.Word
+ 
+ -- | represent the CPU endianness
+@@ -40,14 +39,11 @@ data Endianness = LittleEndian
+ 
+ -- | return the system endianness
+ getSystemEndianness :: Endianness
+-getSystemEndianness = unsafePerformIO $ alloca $ \p ->
+-    poke p cst >> peek (castPtr p) >>= return . check
+-    where cst :: Word32
+-          cst = 0x01000000
+-          check :: Word8 -> Endianness
+-          check x
+-              | x == 0x01 = BigEndian 
+-              | otherwise = LittleEndian
++#ifdef WORDS_BIGENDIAN
++getSystemEndianness = BigEndian
++#else
++getSystemEndianness = LittleEndian
++#endif
+ 
+ -- | Convert from a big endian 64 bit value to the cpu endianness
+ fromBE64 :: Word64 -> Word64
diff -rN -u old-haskell-cpu//patches/series new-haskell-cpu//patches/series
--- old-haskell-cpu//patches/series	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-cpu//patches/series	2012-06-08 11:48:37.104831294 +0000
@@ -0,0 +1 @@
+make-getSystemEndianness-inlineable





More information about the Pkg-haskell-commits mailing list