Thu May 6 14:26:24 PDT 2010 Tim Chevalier * integer-simple changes to allow the library to replace integer-gmp (changing module structure; using foreign calls instead of certain primitives) New patches: [integer-simple changes to allow the library to replace integer-gmp (changing module structure; using foreign calls instead of certain primitives) Tim Chevalier **20100506212624 Ignore-this: 1f30188e5d22786d75db0b4a941e0eed ] { hunk ./GHC/Integer.hs 41 hashInteger, ) where -import GHC.Integer.Type +import GHC.Integer.Simple.Internals import GHC.Bool import GHC.Ordering hunk ./GHC/Integer.hs 146 encodeFloat# :: Word# -> Int# -> Float# decodeFloatInteger :: Float# -> (# Integer, Int# #) +#ifndef SIMPLE_IO decodeFloatInteger f = case decodeFloat_Int# f of (# mant, exp #) -> (# smallInteger mant, exp #) hunk ./GHC/Integer.hs 149 +#else +decodeFloatInteger f = + (# smallInteger (decodeFloat_Int_man f), (decodeFloat_Int_exp f) #) +foreign import ccall "decodeFloat_Int_man" + decodeFloat_Int_man :: Float# -> Int# +foreign import ccall "decodeFloat_Int_exp" + decodeFloat_Int_exp :: Float# -> Int# +#endif -- XXX This could be optimised better, by either (word-size dependent) -- using single 64bit value for the mantissa, or doing the multiplication hunk ./GHC/Integer.hs 162 -- by just building the Digits directly decodeDoubleInteger :: Double# -> (# Integer, Int# #) +#ifndef SIMPLE_IO decodeDoubleInteger d = case decodeDouble_2Int# d of (# mantSign, mantHigh, mantLow, exp #) -> hunk ./GHC/Integer.hs 170 ( (wordToInteger mantHigh `timesInteger` twoToTheThirtytwoInteger) `plusInteger` wordToInteger mantLow), exp #) +#else +decodeDoubleInteger d = + case decodeDouble_2Int_mantSign d of + mantSign -> case decodeDouble_2Int_mantHigh d of + mantHigh -> case decodeDouble_2Int_mantLow d of + mantLow -> case decodeDouble_2Int_exp d of + exp -> (# (smallInteger mantSign) `timesInteger` + ((wordToInteger mantHigh `timesInteger` twoToTheThirtytwoInteger) + `plusInteger` wordToInteger mantLow), + exp #) +foreign import ccall "decodeDouble_2Int_mantSign" + decodeDouble_2Int_mantSign :: Double# -> Int# +foreign import ccall "decodeDouble_2Int_mantHigh" + decodeDouble_2Int_mantHigh :: Double# -> Word# +foreign import ccall "decodeDouble_2Int_mantLow" + decodeDouble_2Int_mantLow :: Double# -> Word# +foreign import ccall "decodeDouble_2Int_exp" + decodeDouble_2Int_exp :: Double# -> Int# +#endif doubleFromInteger :: Integer -> Double# doubleFromInteger Naught = 0.0## hunk ./GHC/Integer/Simple/Internals.hs 5 {-# LANGUAGE NoImplicitPrelude #-} ----------------------------------------------------------------------------- --- | -- Module : GHC.Integer.Simple.Internals -- Copyright : (c) Ian Lynagh 2007-2008 -- License : BSD3 hunk ./GHC/Integer/Simple/Internals.hs 17 -- ----------------------------------------------------------------------------- +#include "MachDeps.h" + module GHC.Integer.Simple.Internals ( hunk ./GHC/Integer/Simple/Internals.hs 20 - module GHC.Integer.Type + Integer(..), + Positive, Positives, + Digits(..), Digit, + List(..) ) where hunk ./GHC/Integer/Simple/Internals.hs 26 -import GHC.Integer.Type +import GHC.Prim +import GHC.Types () + +#if !defined(__HADDOCK__) + +data Integer = Positive !Positive | Negative !Positive | Naught + +------------------------------------------------------------------- +-- The hard work is done on positive numbers + +-- Least significant bit is first + +-- Positive's have the property that they contain at least one Bit, +-- and their last Bit is One. +type Positive = Digits +type Positives = List Positive + +data Digits = Some !Digit !Digits + | None +type Digit = Word# hunk ./GHC/Integer/Simple/Internals.hs 47 +-- XXX Could move [] above us +data List a = Nil | Cons a (List a) +#endif hunk ./integer-simple.cabal 1 -name: integer-simple -version: 0.1.0.0 -license: BSD3 -license-file: LICENSE -maintainer: igloo@earth.li -synopsis: Simple Integer library -description: - This package contains an simple Integer library. -cabal-version: >=1.2 -build-type: Simple - -Library { - build-depends: ghc-prim - exposed-modules: GHC.Integer - GHC.Integer.Simple.Internals - other-modules: GHC.Integer.Type - extensions: CPP, MagicHash, BangPatterns, UnboxedTuples, - ForeignFunctionInterface, UnliftedFFITypes, - NoImplicitPrelude - -- We need to set the package name to integer-simple - -- (without a version number) as it's magic. - ghc-options: -package-name integer-simple -Wall -Werror -} rmfile ./integer-simple.cabal addfile ./integer.cabal hunk ./integer.cabal 1 +name: integer +version: 0.1.0.0 +license: BSD3 +license-file: LICENSE +maintainer: igloo@earth.li +synopsis: Simple Integer library +description: + This package contains an simple Integer library. +cabal-version: >=1.2 +build-type: Simple + +Library { + build-depends: ghc-prim + exposed-modules: GHC.Integer + GHC.Integer.Simple.Internals + other-modules: GHC.Integer.Type + extensions: CPP, MagicHash, BangPatterns, UnboxedTuples, + ForeignFunctionInterface, UnliftedFFITypes, + NoImplicitPrelude + -- We need to set the package name to integer-simple + -- (without a version number) as it's magic. + ghc-options: -package-name integer -Wall -Werror +} } Context: [Pad version to 0.1.0.0 Ian Lynagh **20090920141930] [Add NoImplicitPrelude to the extensions used Ian Lynagh **20090722174729] [Add an import so the deps get sorted out correctly Ian Lynagh **20090722162843] [() is now available, so use that instead of our own Ian Lynagh **20090722161829] [Follow changes in GHC and the other libraries Ian Lynagh **20090722131507] [Fix conversions between Float/Double and simple-integer Ian Lynagh **20080614152452] [Sprinkle on some strictness annotations Ian Lynagh **20080602193146] [Make the Integer type components strict Ian Lynagh **20080602185149] [Avoid the need for infinite Integers when doing bitwise operations Ian Lynagh **20080602184237] [Initial commit Ian Lynagh **20080425024824] Patch bundle hash: eb8d21d2509379eb45e3b71933557cbb68ccf110