packages/integer-gmp.git
3 years agoFix GMP v4 compatibility. master
Austin Seipp [Wed, 26 Feb 2014 22:18:20 +0000 (16:18 -0600)] 
Fix GMP v4 compatibility.

We had started relying on GMP 5.x (for usage of mpz_powm_sec), but this
is pretty painful on RHEL-esque targets, which still use GMP 4.x.

In the mean time while we're still supporting this, it's easier to just
fallback to mpz_powm when _sec is unavailable, and emit a WARNING for
using the primitive.

This also installs a header, HsIntegerGmp.h, which clients could use for
a fallback.

As a side note, this will probably also help Debian oldstable users who
might have outdated GMP versions (which I believe is the cause for #8666.)

Reviewed-by: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Austin Seipp <austin@well-typed.com>
3 years agoFix negation of `divMod`/`quotRem` results (fixes #8726)
Herbert Valerio Riedel [Sun, 2 Feb 2014 11:18:20 +0000 (12:18 +0100)] 
Fix negation of `divMod`/`quotRem` results (fixes #8726)

High-level pseudo code of what the code was supposed to implement:

    quotRem' :: Integer -> Integer -> (Integer,Integer)
    quotRem' a b@(S# _)
      | b < 0     = negFst . uncurry quotRem' . negSnd $ (a,b)
      | otherwise = quotRemUI a (fromIntegral (abs b))

    divMod' :: Integer -> Integer -> (Integer,Integer)
    divMod' a b@(S# _)
      | b < 0      = negSnd . uncurry divMod' . negBoth $ (a,b)
      | otherwise  = divModUI a (fromIntegral b)

    negFst  (q,r) = (-q,r)
    negSnd  (q,r) = ( q,-r)
    negBoth (q,r) = (-q,-r)

    -- quotRemUI and divModUI represent GMP's `mpz_{f,t}div_qr_ui()`
    quotRemUI, divModUI :: Integer -> Word -> (Integer,Integer)

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoFix a popular typo
Gabor Greif [Sat, 1 Feb 2014 20:16:55 +0000 (21:16 +0100)] 
Fix a popular typo

Herbert, this is a merge candidate to the 7.8 branch

3 years agoAdd Hackage-supported `changelog.md`
Herbert Valerio Riedel [Sat, 1 Feb 2014 10:46:33 +0000 (11:46 +0100)] 
Add Hackage-supported `changelog.md`

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoImprove documentation of `integer-gmp`
Herbert Valerio Riedel [Fri, 31 Jan 2014 17:37:28 +0000 (18:37 +0100)] 
Improve documentation of `integer-gmp`

Among other things, this unhides `GHC.Integer` and re-groups the export list.
Moreover, the internal representation of `Integer` is explained a bit more,
and `/Since: 0.5.1.0/` annotations have been added.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoDont use big/small-int primops on IL32P64 (i.e. Win/x86_64) for now
Herbert Valerio Riedel [Thu, 16 Jan 2014 21:56:37 +0000 (22:56 +0100)] 
Dont use big/small-int primops on IL32P64 (i.e. Win/x86_64) for now

This is due to `mpz_*()` functions having @long@ arguments which are
32bit on IL32P64, whereas `Int#` and `Word#` are 64bit wide, causing all
sorts of malfunction due to truncation.

This affects mostly the new big/small-int primops introduced in the
course of #8647, so when `SIZEOF_W != SIZEOF_LONG` we simply fall back
to using the big/big-int primops. big/small primops implemented via the
low-level `mpn_*()` GMP operations are not affected, as those use
`mp_limb_t` arguments.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoIntroduce new SIZEOF_MP_LIMB_T derived constant
Herbert Valerio Riedel [Thu, 16 Jan 2014 20:39:06 +0000 (21:39 +0100)] 
Introduce new SIZEOF_MP_LIMB_T derived constant

This allows to simplify code in `float.c` and to encode the
"sizeof(mp_limb_t) != sizeof(W_)" assumption as a compile-time
assertion.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoUse correct package id for `stg_INTLIKE_closure` import
Herbert Valerio Riedel [Tue, 14 Jan 2014 11:47:46 +0000 (12:47 +0100)] 
Use correct package id for `stg_INTLIKE_closure` import

I'm a bit surprised though this didn't cause linkage errors

(the incorrect import statement was introduced in 7bdcadda7e)

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoFix in-tree GMP build (#8497) on OS X Mavericks
Kazu Yamamoto [Tue, 14 Jan 2014 04:06:03 +0000 (22:06 -0600)] 
Fix in-tree GMP build (#8497) on OS X Mavericks

Signed-off-by: Austin Seipp <austin@well-typed.com>
3 years agoWrap `gmpz_fdiv_{q,r,qr}_ui` to optimize `div`/`mod`
Herbert Valerio Riedel [Mon, 13 Jan 2014 15:13:40 +0000 (16:13 +0100)] 
Wrap `gmpz_fdiv_{q,r,qr}_ui` to optimize `div`/`mod`

This is similiar to what has been done in [af2ba9c8/integer-gmp] for
`gmpz_tdiv_{q,r,qr}_ui` (re #8647); However, the gain is more modest
here, as performance-conscious code tends to use `quot`/`rem` rather
than `div`/`mod`:

     Program    Size    Allocs   Runtime   Elapsed  TotalMem
 -------------------------------------------------------------
   primetest   +0.3%     -2.4%      0.06      0.06     +0.0%
         rsa   +0.2%     -3.3%      0.02      0.02     +0.0%

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoAllocate initial 1-limb mpz_t on the Stack and introduce MPZ# type
Herbert Valerio Riedel [Wed, 8 Jan 2014 23:19:31 +0000 (00:19 +0100)] 
Allocate initial 1-limb mpz_t on the Stack and introduce MPZ# type

We now allocate a 1-limb mpz_t on the stack instead of doing a more
expensive heap-allocation (especially if the heap-allocated copy becomes
garbage right away); this addresses #8647.

In order to delay heap allocations of 1-limb `ByteArray#`s instead of
the previous `(# Int#, ByteArray# #)` pair, a 3-tuple
`(# Int#, ByteArray#, Word# #)` is returned now. This tuple is given the
type-synonym `MPZ#`.

This 3-tuple representation uses either the 1st and the 2nd element, or
the 1st and the 3rd element to represent the limb(s) (NB: undefined
`ByteArray#` elements must not be accessed as they don't point to a
proper `ByteArray#`, see also `DUMMY_BYTE_ARR`); more specifically, the
following encoding is used (where `⊥` means undefined/unused):

 -  (#  0#, ⊥, 0## #) -> value = 0
 -  (#  1#, ⊥, w   #) -> value = w
 -  (# -1#, ⊥, w   #) -> value = -w
 -  (#  s#, d, 0## #) -> value = J# s d

The `mpzToInteger` helper takes care of converting `MPZ#` into an
`Integer`, and allocating a 1-limb `ByteArray#` in case the
value (`w`/`-w`) doesn't fit the `S# Int#` representation).

The following nofib benchmarks benefit from this optimization:

        Program      Size    Allocs   Runtime   Elapsed  TotalMem
 ------------------------------------------------------------------
     bernouilli     +0.2%     -5.2%      0.12      0.12     +0.0%
         gamteb     +0.2%     -1.7%      0.03      0.03     +0.0%
          kahan     +0.3%    -13.2%      0.17      0.17     +0.0%
         mandel     +0.2%    -24.6%      0.04      0.04     +0.0%
          power     +0.2%     -2.6%     -2.0%     -2.0%     -8.3%
      primetest     +0.1%    -17.3%      0.06      0.06     +0.0%
            rsa     +0.2%    -18.5%      0.02      0.02     +0.0%
            scs     +0.1%     -2.9%     -0.1%     -0.1%     +0.0%
         sphere     +0.3%     -0.8%      0.03      0.03     +0.0%
         symalg     +0.2%     -3.1%      0.01      0.01     +0.0%
 ------------------------------------------------------------------
            Min     +0.1%    -24.6%     -4.6%     -4.6%     -8.3%
            Max     +0.3%     +0.0%     +5.9%     +5.9%     +4.5%
 Geometric Mean     +0.2%     -1.0%     +0.2%     +0.2%     -0.0%

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoDrop redundant formal parameter from TAKE1_UL1_RET2
Herbert Valerio Riedel [Fri, 10 Jan 2014 23:51:29 +0000 (00:51 +0100)] 
Drop redundant formal parameter from TAKE1_UL1_RET2

This fixes the actual cause for #8661, i.e. a mismatch between the
actual arity of the Cmm implementation and the arity declared in the
foreign import statement.

This also reverts [a3878d17/integer-gmp] as the workaround isn't needed
anymore.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoFollow-up to a3878d17
Herbert Valerio Riedel [Fri, 10 Jan 2014 10:32:59 +0000 (11:32 +0100)] 
Follow-up to a3878d17

Forgot to add this chunk to the commit [a3878d17/integer-gmp]

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoTemporary disable `mpz_gmpz_tdiv_qr_ui` to workaround #8661
Herbert Valerio Riedel [Fri, 10 Jan 2014 10:00:23 +0000 (11:00 +0100)] 
Temporary disable `mpz_gmpz_tdiv_qr_ui` to workaround #8661

I still need to investigated, but for some reason not yet obvious to me,
commit [af2ba9c8/integer-gmp] (re #8647) seems to have triggered #8661
on linux/32

This commit disables the use of the `quotRemIntegerWord#` primop on
32bit (which seems to trigger the issue).

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoManually float out `int2Integer# INT_MINBOUND`
Herbert Valerio Riedel [Wed, 8 Jan 2014 22:39:01 +0000 (23:39 +0100)] 
Manually float out `int2Integer# INT_MINBOUND`

This avoids allocating this special value over and over again every
time it's needed, and therefore this addresses #8647.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoWrap `gmpz_tdiv_{q,r,qr}_ui` to optimize `quot`/`rem`
Herbert Valerio Riedel [Wed, 8 Jan 2014 21:45:13 +0000 (22:45 +0100)] 
Wrap `gmpz_tdiv_{q,r,qr}_ui` to optimize `quot`/`rem`

This is useful as `quot`/`rem` are often used with small-int divisors,
like when computing the digits of an `Integer`. This optimization
reduces allocations in the following `nofib` benchmarks:

      Program        Size    Allocs   Runtime   Elapsed  TotalMem
   -----------------------------------------------------------------
        power       +0.3%     -0.8%     -1.2%     -1.2%     +0.0%
    primetest       +0.3%     -3.9%      0.07      0.07     +0.0%
          rsa       +0.3%     -4.0%      0.02      0.02     +0.0%
       symalg       +0.2%     -1.4%      0.01      0.01     +0.0%

This addresses #8647

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoHackishly fix parallel build failure with in-tree GMP
Austin Seipp [Tue, 7 Jan 2014 09:52:38 +0000 (03:52 -0600)] 
Hackishly fix parallel build failure with in-tree GMP

See the comments and #8102. The basic gist of it seems to be that the
build system follows an implied rule from somewhere to directly build a
C file, which doesn't have a dependency on the in-tree gmp.h that we
build. As a result, the C file compilation races against the GMP build,
causing an error.

This is a pretty unsatisfactory hack, but for Windows and OS X machines
where we more often build in-tree GMPs, it's quite important.

Authored-by: Kazu Yamamoto <kazu@iij.ad.jp>
Signed-off-by: Austin Seipp <austin@well-typed.com>
3 years agoAdd new `mpz_{sub,add}_ui`-based primop (re #8647)
Herbert Valerio Riedel [Fri, 3 Jan 2014 21:36:04 +0000 (22:36 +0100)] 
Add new `mpz_{sub,add}_ui`-based primop (re #8647)

This adds `{plus,minus}IntegerInt#` which help to reduce temporary
allocations in `plusInteger` and `minusInteger`.

This and the previous commit introducing `timesIntegerInt#` (i.e. baeeef7af6e)
result in reduced allocations for the following nofib benchmarks on Linux/amd64:

         Program      Size    Allocs   Runtime   Elapsed  TotalMem
  ------------------------------------------------------------------
      bernouilli     +0.0%     -4.2%      0.12      0.12     +0.0%
           kahan     +0.1%    -12.6%      0.17      0.17     +0.0%
        pidigits     +0.0%     -0.5%     -4.7%     -4.5%     +0.0%
           power     +0.0%     -2.7%     +3.1%     +3.1%     +9.1%
       primetest     +0.0%     -4.2%      0.07      0.07     +0.0%
             rsa     +0.0%     -4.1%      0.02      0.02     +0.0%
             scs     +0.0%     -2.6%     -0.8%     -0.7%     +0.0%
  ------------------------------------------------------------------
             Min     +0.0%    -12.6%     -4.7%     -4.5%     -5.0%
             Max     +0.1%     +0.2%     +3.1%     +3.1%     +9.1%
  Geometric Mean     +0.1%     -0.3%     -0.0%     +0.0%     +0.1%
  ------------------------------------------------------------------

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoAdd new `mpz_mul_si`-based primop (re #8647)
Herbert Valerio Riedel [Thu, 2 Jan 2014 08:31:50 +0000 (09:31 +0100)] 
Add new `mpz_mul_si`-based primop (re #8647)

This primop helps reducing allocation by being able to pass one `S#`
argument directly to the GMP multiplication primitive without needing to
promote (and thus allocate a `ByteArray#` as well) the `J#` first.

This benefits a few nofib benchmarks wrt to allocations (having most
impact on `kahan` resulting in about 10% less allocations)

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoRefactor C-- wrappers to use macros for mpz_t access
Herbert Valerio Riedel [Sat, 4 Jan 2014 07:42:01 +0000 (08:42 +0100)] 
Refactor C-- wrappers to use macros for mpz_t access

This factors out the recurring task of converting mpz_t structures
to/from Int#/ByteArrays# pairs and makes the code more readable.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoRefactor `stgReallocForGMP` to use `memcpy`
Herbert Valerio Riedel [Fri, 3 Jan 2014 21:58:32 +0000 (22:58 +0100)] 
Refactor `stgReallocForGMP` to use `memcpy`

GCC is able to generate better code when using `memcpy` instead of
manually copying bytes in a loop. Otoh, `stgAllocForGMP` is typically
called for enlarging initial single-limb structures (see also #8647 for
more information) and so this minor optimization won't be very visible
in measurements.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoMake use of `quotRemInt#` primop in `quotRemInteger`
Herbert Valerio Riedel [Fri, 3 Jan 2014 21:42:33 +0000 (22:42 +0100)] 
Make use of `quotRemInt#` primop in `quotRemInteger`

Otoh, `divModInt#` is not a proper primop (it's implemented as wrapper
around `quotRemInt#` in `GHC.Base`), so we can't do the same for
`divModInteger` yet.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoRefactor and comment the smartJ# changes (re Trac #8638)
Simon Peyton Jones [Fri, 3 Jan 2014 16:13:19 +0000 (16:13 +0000)] 
Refactor and comment the smartJ# changes (re Trac #8638)

3 years agoTry harder to demote results from `J#` to `S#` (re #8638)
Herbert Valerio Riedel [Mon, 30 Dec 2013 15:05:20 +0000 (16:05 +0100)] 
Try harder to demote results from `J#` to `S#` (re #8638)

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
3 years agoUpdate Autoconf tests for recent GMP version
Herbert Valerio Riedel [Sun, 24 Nov 2013 16:53:58 +0000 (17:53 +0100)] 
Update Autoconf tests for recent GMP version

This should improve the check for a suitable installed GMP version, to
implicitly check if GMP provides __gmpz_powm_sec() which has been added
in GMP version 5.0.0 and switch to the in-tree GMP 5.0.3 source otherwise.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoImprove Haddock documentation
Herbert Valerio Riedel [Thu, 7 Nov 2013 23:36:16 +0000 (00:36 +0100)] 
Improve Haddock documentation

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoOptimize order of pattern matches for export operations
Herbert Valerio Riedel [Thu, 7 Nov 2013 22:52:46 +0000 (23:52 +0100)] 
Optimize order of pattern matches for export operations

These are supposed to be called with `J#`-kind `Integer`s, so check that
constructor first.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoAdd `Addr#` based `{import,export}Integer` variants
Herbert Valerio Riedel [Thu, 7 Nov 2013 21:23:36 +0000 (22:23 +0100)] 
Add `Addr#` based `{import,export}Integer` variants

These follow closely the existing implementations for
`importIntegerFromByteArray` and `exportIntegerToMutableByteArray`.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoRename `{import,export}Integer`
Herbert Valerio Riedel [Thu, 7 Nov 2013 20:40:57 +0000 (21:40 +0100)] 
Rename `{import,export}Integer`

This renames to more verbose names which include the type these
operations import/export from/to:

 - `importIntegerFromByteArray`, and
 - `exportIntegerToMutableByteArray`.

This follows the naming convention used for other primitive operations,
such as the recently added `copyMutableByteArrayToAddr` operation.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoClean-up Cmm of import/export primitives
Herbert Valerio Riedel [Tue, 5 Nov 2013 20:26:17 +0000 (21:26 +0100)] 
Clean-up Cmm of import/export primitives

This is a follow-up to e94799c9 fixing the Cmm implementation of the
primops based on suggestions by Duncan Coutts.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoAdd primitives to write/read Integers to/from bytearrays
Herbert Valerio Riedel [Tue, 5 Nov 2013 11:08:00 +0000 (12:08 +0100)] 
Add primitives to write/read Integers to/from bytearrays

This adds the following new (internal) primitives

{{{#!hs
sizeInBaseInteger :: Integer -> Int# -> Word#

exportInteger :: Integer -> MutableByteArray# s -> Word# -> Int#
                 -> State# s -> (# State# s, Word# #)

importInteger :: ByteArray# -> Word# -> Word# -> Int# -> Integer
}}}

The import/export primitives support selecting most/least significant
byte first order as well as using an offset into the byte-arrays.

See Haddock comments for more details.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoExpose two GMP primality operations
Herbert Valerio Riedel [Mon, 28 Oct 2013 19:13:35 +0000 (20:13 +0100)] 
Expose two GMP primality operations

This exposes `mpz_probab_prime_p()` and `mpz_nextprime()` as
`testPrimeInteger` and `nextPrimeInteger` respectively and is especially
useful for cryptographic algorithms such as RSA.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoAdd side-channel attack resilient `powModSecInteger`
Herbert Valerio Riedel [Sun, 27 Oct 2013 22:14:11 +0000 (23:14 +0100)] 
Add side-channel attack resilient `powModSecInteger`

This is a follow-up to 97c101b7363f84d925a600acb56a9fa3a997ea0d which
introduced the "ordinary" `powModInteger` operation.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoAdd overlooked files created by `configure` to `extra-tmp-files`
Herbert Valerio Riedel [Thu, 24 Oct 2013 20:13:15 +0000 (22:13 +0200)] 
Add overlooked files created by `configure` to `extra-tmp-files`

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoRefactor & modernize `.cabal` to `cabal-version>=1.10`
Herbert Valerio Riedel [Thu, 24 Oct 2013 12:50:50 +0000 (14:50 +0200)] 
Refactor & modernize `.cabal` to `cabal-version>=1.10`

This sets a sensible cabal category (i.e. `Numerical`), extends
`extra-tmp-{files,files}` to make this package self-contained, updates
the bug-report URL, and cleans up the `{-# LANGUAGE #-}` pragma usage in
the source code.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoAdd aux files `config.{guess,sub}` and `install-sh`
Herbert Valerio Riedel [Thu, 24 Oct 2013 12:42:36 +0000 (14:42 +0200)] 
Add aux files `config.{guess,sub}` and `install-sh`

These files are taken from GNU automake 1.13.3

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoExpose GMP's `mpz_gcdext()` as internal primitive
Herbert Valerio Riedel [Sun, 29 Sep 2013 16:25:07 +0000 (18:25 +0200)] 
Expose GMP's `mpz_gcdext()` as internal primitive

The extended GCD computation is useful to have for implementing
algorithms such as the chinese reminder theorem.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoExpose new internal exponentiation primitives
Herbert Valerio Riedel [Sun, 29 Sep 2013 08:05:05 +0000 (10:05 +0200)] 
Expose new internal exponentiation primitives

This exposes the GMP functions `mpz_pow_ui()`, `mpz_powm()`, and
`mpz_invert()` as `powInteger`, `powModInteger`, and `recipModInteger`
respectively in the module `GHC.Integer.GMP.Internals`.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
4 years agoFollow changes in comparison primops (see #6135)
Jan Stolarek [Mon, 16 Sep 2013 14:16:41 +0000 (15:16 +0100)] 
Follow changes in comparison primops (see #6135)

4 years agoUpdate Git repo URL in `.cabal` file
Herbert Valerio Riedel [Wed, 11 Sep 2013 13:15:01 +0000 (15:15 +0200)] 
Update Git repo URL in `.cabal` file

4 years agoComments only
Jan Stolarek [Mon, 19 Aug 2013 14:46:22 +0000 (15:46 +0100)] 
Comments only

Link to documentation of library on the wiki

4 years agoComparison primops return Int# (Fixes #6135)
Jan Stolarek [Sun, 14 Apr 2013 10:31:44 +0000 (12:31 +0200)] 
Comparison primops return Int# (Fixes #6135)

For a deatiled discussion of this changes please visit the wiki page:
http://hackage.haskell.org/trac/ghc/wiki/PrimBool

4 years agoFollow GHC build system changes
Ian Lynagh [Tue, 2 Jul 2013 23:13:41 +0000 (00:13 +0100)] 
Follow GHC build system changes

4 years agoRun "sh ./configure" rather than "sh configure"; part of #7992
Ian Lynagh [Sat, 22 Jun 2013 15:52:09 +0000 (16:52 +0100)] 
Run "sh ./configure" rather than "sh configure"; part of #7992

This fixes a bug with how configure re-execs itself.

4 years agoHandle dependencies for .cmm files properly
Ian Lynagh [Thu, 9 May 2013 19:47:02 +0000 (20:47 +0100)] 
Handle dependencies for .cmm files properly

4 years agoFix build when gmp isn't installed
Ian Lynagh [Sun, 28 Apr 2013 16:12:57 +0000 (17:12 +0100)] 
Fix build when gmp isn't installed

4 years agoBuild system refactoring
Ian Lynagh [Sat, 20 Apr 2013 13:16:27 +0000 (14:16 +0100)] 
Build system refactoring

4 years agointeger-gmp: mpn_gcd_1 allocate one Word on stack instead of 'sizeof (__mpz_struct)'
Sergei Trofimovich [Wed, 13 Mar 2013 20:41:21 +0000 (23:41 +0300)] 
integer-gmp: mpn_gcd_1 allocate one Word on stack instead of 'sizeof (__mpz_struct)'

gmp.h defines 'mpn_gcd_1' as following:
    mp_limb_t mpn_gcd_1 (mp_srcptr /* aka 'mp_limb_t *'  */, mp_size_t, mp_limb_t);

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agoFollow changes in GHC's build system
Ian Lynagh [Fri, 1 Mar 2013 23:24:44 +0000 (23:24 +0000)] 
Follow changes in GHC's build system

4 years agoFix GMP_PREFER_FRAMEWORK
Ian Lynagh [Sat, 9 Feb 2013 21:56:25 +0000 (21:56 +0000)] 
Fix GMP_PREFER_FRAMEWORK

It doesn't look like the old code could have worked

4 years agoNever try to use the system gmp on Windows
Ian Lynagh [Sat, 9 Feb 2013 21:55:20 +0000 (21:55 +0000)] 
Never try to use the system gmp on Windows

Apparently building on Windows failed when there is a system gmp
available.

4 years agoRevert "integer-gmp: improve cross-compiling support GmpDerivedConstants.h"
Simon Marlow [Sat, 26 Jan 2013 08:02:42 +0000 (08:02 +0000)] 
Revert "integer-gmp: improve cross-compiling support GmpDerivedConstants.h"

This reverts commit 860f2fa9a1f1ca4f8d94388723687f90d122ae81.

People reported problems with it on the mailing list, so reverting
until we can figure out the cause.

4 years agointeger-gmp: improve cross-compiling support GmpDerivedConstants.h
Sergei Trofimovich [Wed, 23 Jan 2013 22:36:21 +0000 (01:36 +0300)] 
integer-gmp: improve cross-compiling support GmpDerivedConstants.h

Before the patch GmpDerivedConstants.h was generated
by running mkGmpDerivedConstants on target.

Now it's generated only with help of autoconf macros.
Tested on --target=ia64-unknown-linux-gnu.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agoFix configure when we don't have a gmp library
Ian Lynagh [Tue, 1 Jan 2013 18:41:51 +0000 (18:41 +0000)] 
Fix configure when we don't have a gmp library

4 years agoProvide a way for OS X users to indicate a preference for the GMP framework
Ian Lynagh [Tue, 1 Jan 2013 17:01:00 +0000 (17:01 +0000)] 
Provide a way for OS X users to indicate a preference for the GMP framework

We used to always use the framework if it existed. Now the make variable
GMP_PREFER_FRAMEWORK can be used to control whether the library or the
framework is preferred.

Fixes #7466.

4 years agozap obsolete FIXME, fix typos
Gabor Greif [Fri, 14 Dec 2012 09:23:26 +0000 (10:23 +0100)] 
zap obsolete FIXME, fix typos

4 years agoBump version number following new policy
Ian Lynagh [Fri, 30 Nov 2012 16:40:49 +0000 (16:40 +0000)] 
Bump version number following new policy

We now keep the HEAD version numbers as values which would be suitable
for immediate release.

4 years agoAdd comment to .cabal file saying what GHC 7.6.1 shipped with
Ian Lynagh [Fri, 30 Nov 2012 16:00:08 +0000 (16:00 +0000)] 
Add comment to .cabal file saying what GHC 7.6.1 shipped with

5 years agofix type mismatch in result of integer_cmm_testBitIntegerzh
Simon Marlow [Mon, 22 Oct 2012 14:39:39 +0000 (15:39 +0100)] 
fix type mismatch in result of integer_cmm_testBitIntegerzh

5 years agoAdapt to new Cmm syntax
Simon Marlow [Wed, 3 Oct 2012 13:02:26 +0000 (14:02 +0100)] 
Adapt to new Cmm syntax

5 years agoFix building on Windows
Ian Lynagh [Tue, 7 Aug 2012 13:18:13 +0000 (14:18 +0100)] 
Fix building on Windows

5 years agoDefine testBitInteger; part of #3489
Ian Lynagh [Sun, 5 Aug 2012 14:55:32 +0000 (15:55 +0100)] 
Define testBitInteger; part of #3489

Based on a patch from pumpkingod@gmail.com

5 years agoWhitespace only: Line some things up better
Ian Lynagh [Sun, 5 Aug 2012 13:51:19 +0000 (14:51 +0100)] 
Whitespace only: Line some things up better

5 years agoMerge branch 'master' of darcs.haskell.org:/srv/darcs//packages/integer-gmp
Ian Lynagh [Thu, 19 Jul 2012 19:39:53 +0000 (20:39 +0100)] 
Merge branch 'master' of darcs.haskell.org:/srv/darcs//packages/integer-gmp

5 years agoBump version to 0.5.0.0 ghc-7.6 ghc-7.6.1-release ghc-7.6.2-release ghc-7.6.3-release integer-gmp-0.5.0.0-release
Paolo Capriotti [Tue, 10 Jul 2012 11:09:40 +0000 (12:09 +0100)] 
Bump version to 0.5.0.0

5 years agoSimplify how gcd @ Int is implemented
Ian Lynagh [Wed, 18 Jul 2012 14:34:18 +0000 (15:34 +0100)] 
Simplify how gcd @ Int is implemented

5 years agoMove some rules into PrelRules
Ian Lynagh [Wed, 18 Jul 2012 14:15:16 +0000 (15:15 +0100)] 
Move some rules into PrelRules

5 years agoAdd another gcdInteger rule
Ian Lynagh [Fri, 13 Jul 2012 19:04:51 +0000 (20:04 +0100)] 
Add another gcdInteger rule

This one is better when the result is converted to an Int

5 years agoTweak RULEs; fixes #7041
Ian Lynagh [Fri, 13 Jul 2012 18:51:08 +0000 (19:51 +0100)] 
Tweak RULEs; fixes #7041

In particular, the gcd rule now uses smallInteger rather than S#, which
means that it actually fires.

Also fixed a bug when the result is minBound :: Int.

5 years agoAdd missing imports.
Paolo Capriotti [Wed, 27 Jun 2012 17:59:33 +0000 (18:59 +0100)] 
Add missing imports.

5 years agoUse CLong, not CInt, for mp_bitcnt_t value; fixes #5965
Ian Lynagh [Wed, 20 Jun 2012 13:28:36 +0000 (14:28 +0100)] 
Use CLong, not CInt, for mp_bitcnt_t value; fixes #5965

The GMP docs say:

    Counts of bits of a multi-precision number are represented in the C
    type mp_bitcnt_t. Currently this is always an unsigned long, but on
    some systems it will be an unsigned long long in the future.

5 years agoAdd divInteger and modInteger functions
Ian Lynagh [Tue, 19 Jun 2012 18:33:43 +0000 (19:33 +0100)] 
Add divInteger and modInteger functions

Now that divModInteger isn't inlined, we were getting allocations for
both results even if we're just going to throw one away.

5 years agoUse divInt#/modInt# from ghc-prim
Ian Lynagh [Tue, 19 Jun 2012 18:21:42 +0000 (19:21 +0100)] 
Use divInt#/modInt# from ghc-prim

5 years agoFix compilation under LLVM backend. (#5965)
David Terei [Wed, 28 Mar 2012 18:22:21 +0000 (11:22 -0700)] 
Fix compilation under LLVM backend. (#5965)

Recent change means ul is truncate to an int, not a long anymore.

5 years agoFix building libgmp on cygwin
Ian Lynagh [Fri, 16 Mar 2012 01:00:30 +0000 (01:00 +0000)] 
Fix building libgmp on cygwin

5 years agoWin64 fix
Ian Lynagh [Thu, 15 Mar 2012 17:08:26 +0000 (17:08 +0000)] 
Win64 fix

5 years agoUpdate .gitignore.
Paolo Capriotti [Tue, 6 Mar 2012 10:57:34 +0000 (10:57 +0000)] 
Update .gitignore.

5 years agoUpdated to a newer version of gmp; fixes #5810
Ian Lynagh [Fri, 3 Feb 2012 17:03:21 +0000 (17:03 +0000)] 
Updated to a newer version of gmp; fixes #5810

I didn't diagnose the problem, but with the newer GMP the problem seems
fixed. There are a couple of things that look like candidates for the
bug:
* A few minor bugs related to portability fixed.
* A bug in division code possibly causing incorrect computation was fixed.

5 years agoAdd some rules; fixes #5767
Ian Lynagh [Thu, 26 Jan 2012 13:58:04 +0000 (13:58 +0000)] 
Add some rules; fixes #5767

We now have rules for
    integerToInt    (smallInteger    x) = x
    integerToWord   (wordToInteger   x) = x
    integerToInt64  (int64ToInteger  x) = x
    integerToWord64 (word64ToInteger x) = x

5 years agoUse the mingw touch program on Windows
Ian Lynagh [Fri, 2 Dec 2011 14:48:16 +0000 (14:48 +0000)] 
Use the mingw touch program on Windows

5 years agoTrack changes to the way we reference CCCS in GHC (was: W_[CCCS], now: CCCS)
Simon Marlow [Thu, 1 Dec 2011 12:18:43 +0000 (12:18 +0000)] 
Track changes to the way we reference CCCS in GHC (was: W_[CCCS], now: CCCS)

5 years agoupdate to track changes to CCCS in the RTS
Simon Marlow [Tue, 29 Nov 2011 09:37:23 +0000 (09:37 +0000)] 
update to track changes to CCCS in the RTS

6 years agoFollow GHC build system change to the way we call rm
Ian Lynagh [Sat, 19 Nov 2011 01:33:41 +0000 (01:33 +0000)] 
Follow GHC build system change to the way we call rm

6 years agoEliminate intermediate overflow for encodeFloat, fixes #5524
Daniel Fischer [Sat, 1 Oct 2011 11:59:55 +0000 (13:59 +0200)] 
Eliminate intermediate overflow for encodeFloat, fixes #5524

6 years agoUntabify cbits/float.c
Daniel Fischer [Fri, 30 Sep 2011 22:40:46 +0000 (00:40 +0200)] 
Untabify cbits/float.c

6 years agoDefine mkInteger
Ian Lynagh [Sat, 17 Sep 2011 17:20:41 +0000 (18:20 +0100)] 
Define mkInteger

Now used by GHC to generate Integer literals.

6 years agoExport GMP-only functions from the Internals module
Ian Lynagh [Tue, 13 Sep 2011 19:20:05 +0000 (20:20 +0100)] 
Export GMP-only functions from the Internals module

6 years agoNOINLINE a couple more functions
Ian Lynagh [Tue, 13 Sep 2011 18:48:38 +0000 (19:48 +0100)] 
NOINLINE a couple more functions

We don't need them to be inlined at all, following changes in how
GHC handles Integers.

6 years agoDon't export gcdInteger, lcmInteger from GHC.Integer
Ian Lynagh [Tue, 13 Sep 2011 17:29:20 +0000 (18:29 +0100)] 
Don't export gcdInteger, lcmInteger from GHC.Integer

integer-simple doesn't export them

6 years agoFollow ghc-prim changes
Ian Lynagh [Fri, 26 Aug 2011 20:38:26 +0000 (21:38 +0100)] 
Follow ghc-prim changes

6 years agoExport Integer(..) from GHC.Integer.GMP.Internals again; fixes #5419
Ian Lynagh [Thu, 25 Aug 2011 10:18:07 +0000 (11:18 +0100)] 
Export Integer(..) from GHC.Integer.GMP.Internals again; fixes #5419

The GMP primitives are now in GHC.Integer.GMP.Prim instead.

6 years agoRemove old darcs boring file
David Terei [Wed, 10 Aug 2011 19:31:38 +0000 (12:31 -0700)] 
Remove old darcs boring file

6 years agoThis should finally fix #5293 by fixing two bugs in GMP's configuration setup
Manuel M T Chakravarty [Thu, 4 Aug 2011 14:17:14 +0000 (00:17 +1000)] 
This should finally fix #5293 by fixing two bugs in GMP's configuration setup

* GMP uses m4 scripts to pre-process hand coded assembly routines
* These didn't properly account for OS X/i86_64 always using PIC

6 years agoEliminate orphan instances
Ian Lynagh [Sat, 30 Jul 2011 19:31:16 +0000 (20:31 +0100)] 
Eliminate orphan instances

The type and implementation are now in the same module, so the orphan
instances are no longer orphaned.

6 years agoNo need to export Integer from GHC.Integer.GMP.Internals
Ian Lynagh [Sat, 30 Jul 2011 18:42:15 +0000 (19:42 +0100)] 
No need to export Integer from GHC.Integer.GMP.Internals

This caused an odd dependency in the module hierarchy.

6 years agoUpgrade gmp, 4.2.4 -> 5.0.2
Ian Lynagh [Wed, 27 Jul 2011 14:28:08 +0000 (15:28 +0100)] 
Upgrade gmp, 4.2.4 -> 5.0.2

6 years agoDon't inline most integer operations
Ian Lynagh [Sat, 23 Jul 2011 16:56:40 +0000 (17:56 +0100)] 
Don't inline most integer operations

We get lots of code, and the simplifier generally can't do much with
it. We'll instead use builtin rules to do constant folding where
possible.

6 years agoRename toInt# -> integerToInt for consistency
Ian Lynagh [Sat, 23 Jul 2011 12:31:07 +0000 (13:31 +0100)] 
Rename toInt# -> integerToInt for consistency

6 years agoFix build following modules moving around
Ian Lynagh [Fri, 22 Jul 2011 18:18:39 +0000 (19:18 +0100)] 
Fix build following modules moving around

6 years agoEq and Ord instances are now in the integer package, not base
Ian Lynagh [Fri, 22 Jul 2011 18:09:46 +0000 (19:09 +0100)] 
Eq and Ord instances are now in the integer package, not base