[Gmp-commit] /var/hg/gmp: 4 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Fri Nov 13 06:13:57 UTC 2015
details: /var/hg/gmp/rev/c9a76d279fcb
changeset: 16960:c9a76d279fcb
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Fri Nov 13 07:10:11 2015 +0100
description:
mpz/set.c: Use MPZ_NEWALLOC.
details: /var/hg/gmp/rev/2f151e3d0905
changeset: 16961:2f151e3d0905
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Fri Nov 13 07:11:17 2015 +0100
description:
Copyright year.
details: /var/hg/gmp/rev/09144eb19b65
changeset: 16962:09144eb19b65
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Fri Nov 13 07:11:40 2015 +0100
description:
mini-gmp/mini-gmp.c: Lazy allocation for mpz_t
details: /var/hg/gmp/rev/c1ae4ee719a1
changeset: 16963:c1ae4ee719a1
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Fri Nov 13 07:13:46 2015 +0100
description:
ChangeLog
diffstat:
ChangeLog | 5 +++++
mini-gmp/mini-gmp.c | 30 ++++++++++++++++++------------
mpz/2fac_ui.c | 2 +-
mpz/aors_ui.h | 4 ++--
mpz/bin_ui.c | 2 +-
mpz/bin_uiui.c | 2 +-
mpz/cdiv_qr_ui.c | 4 ++--
mpz/cdiv_r_ui.c | 4 ++--
mpz/com.c | 4 ++--
mpz/fac_ui.c | 3 ++-
mpz/fdiv_qr_ui.c | 4 ++--
mpz/fdiv_r_ui.c | 4 ++--
mpz/fib2_ui.c | 2 +-
mpz/fib_ui.c | 2 +-
mpz/gcd.c | 4 ++--
mpz/gcd_ui.c | 2 +-
mpz/gcdext.c | 4 ++--
mpz/init.c | 3 ++-
mpz/iset_d.c | 2 +-
mpz/lucnum2_ui.c | 2 +-
mpz/lucnum_ui.c | 2 +-
mpz/mfac_uiui.c | 2 +-
mpz/mul.c | 4 ++--
mpz/n_pow_ui.c | 2 +-
mpz/oddfac_1.c | 2 +-
mpz/powm.c | 4 ++--
mpz/powm_sec.c | 4 ++--
mpz/powm_ui.c | 4 ++--
mpz/primorial_ui.c | 2 +-
mpz/realloc.c | 3 ++-
mpz/realloc2.c | 2 +-
mpz/set.c | 4 ++--
mpz/set_si.c | 3 ++-
mpz/set_ui.c | 4 ++--
mpz/tdiv_qr_ui.c | 4 ++--
mpz/tdiv_r_ui.c | 4 ++--
mpz/ui_sub.c | 2 +-
rand/randlc2x.c | 2 +-
38 files changed, 79 insertions(+), 64 deletions(-)
diffs (truncated from 573 to 300 lines):
diff -r cdf45e583489 -r c1ae4ee719a1 ChangeLog
--- a/ChangeLog Thu Nov 12 12:31:28 2015 +0100
+++ b/ChangeLog Fri Nov 13 07:13:46 2015 +0100
@@ -1,3 +1,8 @@
+2015-11-13 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * mini-gmp/mini-gmp.c: Lazy allocation for mpz_t.
+ * mpz/set.c: Use MPZ_NEWALLOC.
+
2015-11-12 Marc Glisse <marc.glisse at inria.fr>
* gmpxx.h (__gmp_fibonacci_function): New class.
diff -r cdf45e583489 -r c1ae4ee719a1 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mini-gmp/mini-gmp.c Fri Nov 13 07:13:46 2015 +0100
@@ -1383,9 +1383,11 @@
void
mpz_init (mpz_t r)
{
- r->_mp_alloc = 1;
+ static const mp_limb_t dummy_limb = 0xc1a0;
+
+ r->_mp_alloc = 0;
r->_mp_size = 0;
- r->_mp_d = gmp_xalloc_limbs (1);
+ r->_mp_d = (mp_ptr) &dummy_limb;
}
/* The utility of this function is a bit limited, since many functions
@@ -1406,7 +1408,8 @@
void
mpz_clear (mpz_t r)
{
- gmp_free (r->_mp_d);
+ if (r->_mp_alloc)
+ gmp_free (r->_mp_d);
}
static mp_ptr
@@ -1414,7 +1417,10 @@
{
size = GMP_MAX (size, 1);
- r->_mp_d = gmp_xrealloc_limbs (r->_mp_d, size);
+ if (r->_mp_alloc)
+ r->_mp_d = gmp_xrealloc_limbs (r->_mp_d, size);
+ else
+ r->_mp_d = gmp_xalloc_limbs (size);
r->_mp_alloc = size;
if (GMP_ABS (r->_mp_size) > size)
@@ -1437,7 +1443,7 @@
else /* (x < 0) */
{
r->_mp_size = -1;
- r->_mp_d[0] = GMP_NEG_CAST (unsigned long int, x);
+ MPZ_REALLOC (r, 1)[0] = GMP_NEG_CAST (unsigned long int, x);
}
}
@@ -1447,7 +1453,7 @@
if (x > 0)
{
r->_mp_size = 1;
- r->_mp_d[0] = x;
+ MPZ_REALLOC (r, 1)[0] = x;
}
else
r->_mp_size = 0;
@@ -1848,7 +1854,7 @@
an = GMP_ABS (a->_mp_size);
if (an == 0)
{
- r->_mp_d[0] = b;
+ MPZ_REALLOC (r, 1)[0] = b;
return b > 0;
}
@@ -1867,14 +1873,15 @@
mpz_abs_sub_ui (mpz_t r, const mpz_t a, unsigned long b)
{
mp_size_t an = GMP_ABS (a->_mp_size);
- mp_ptr rp = MPZ_REALLOC (r, an);
+ mp_ptr rp;
if (an == 0)
{
- rp[0] = b;
+ MPZ_REALLOC (r, 1)[0] = b;
return -(b > 0);
}
- else if (an == 1 && a->_mp_d[0] < b)
+ rp = MPZ_REALLOC (r, an);
+ if (an == 1 && a->_mp_d[0] < b)
{
rp[0] = b - a->_mp_d[0];
return -1;
@@ -2345,7 +2352,6 @@
if (qn <= 0)
qn = 0;
-
else
{
qp = MPZ_REALLOC (q, qn);
@@ -2547,7 +2553,7 @@
if (r)
{
- r->_mp_d[0] = rl;
+ MPZ_REALLOC (r, 1)[0] = rl;
r->_mp_size = rs;
}
if (q)
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/2fac_ui.c
--- a/mpz/2fac_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/2fac_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -2,7 +2,7 @@
Contributed to the GNU project by Marco Bodrato.
-Copyright 2012 Free Software Foundation, Inc.
+Copyright 2012, 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/aors_ui.h
--- a/mpz/aors_ui.h Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/aors_ui.h Fri Nov 13 07:13:46 2015 +0100
@@ -1,8 +1,8 @@
/* mpz_add_ui, mpz_sub_ui -- Add or subtract an mpz_t and an unsigned
one-word integer.
-Copyright 1991, 1993, 1994, 1996, 1999-2002, 2004, 2012, 2013 Free Software
-Foundation, Inc.
+Copyright 1991, 1993, 1994, 1996, 1999-2002, 2004, 2012, 2013, 2015
+Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/bin_ui.c
--- a/mpz/bin_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/bin_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,6 +1,6 @@
/* mpz_bin_ui - compute n over k.
-Copyright 1998-2002, 2012, 2013 Free Software Foundation, Inc.
+Copyright 1998-2002, 2012, 2013, 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/bin_uiui.c
--- a/mpz/bin_uiui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/bin_uiui.c Fri Nov 13 07:13:46 2015 +0100
@@ -2,7 +2,7 @@
Contributed to the GNU project by Torbjorn Granlund and Marco Bodrato.
-Copyright 2010-2012 Free Software Foundation, Inc.
+Copyright 2010-2012, 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/cdiv_qr_ui.c
--- a/mpz/cdiv_qr_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/cdiv_qr_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -3,8 +3,8 @@
always fit into the return type, the negative of the true remainder is
returned.
-Copyright 1994-1996, 1999, 2001, 2002, 2004, 2012 Free Software Foundation,
-Inc.
+Copyright 1994-1996, 1999, 2001, 2002, 2004, 2012, 2015 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/cdiv_r_ui.c
--- a/mpz/cdiv_r_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/cdiv_r_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -3,8 +3,8 @@
always fit into the return type, the negative of the true remainder is
returned.
-Copyright 1994-1996, 2001, 2002, 2004, 2005, 2012 Free Software Foundation,
-Inc.
+Copyright 1994-1996, 2001, 2002, 2004, 2005, 2012, 2015 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/com.c
--- a/mpz/com.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/com.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,8 +1,8 @@
/* mpz_com(mpz_ptr dst, mpz_ptr src) -- Assign the bit-complemented value of
SRC to DST.
-Copyright 1991, 1993, 1994, 1996, 2001, 2003, 2012 Free Software Foundation,
-Inc.
+Copyright 1991, 1993, 1994, 1996, 2001, 2003, 2012, 2015 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/fac_ui.c
--- a/mpz/fac_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/fac_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -2,7 +2,8 @@
Contributed to the GNU project by Marco Bodrato.
-Copyright 1991, 1993-1995, 2000-2003, 2011, 2012 Free Software Foundation, Inc.
+Copyright 1991, 1993-1995, 2000-2003, 2011, 2012, 2015 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/fdiv_qr_ui.c
--- a/mpz/fdiv_qr_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/fdiv_qr_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,8 +1,8 @@
/* mpz_fdiv_qr_ui -- Division rounding the quotient towards -infinity.
The remainder gets the same sign as the denominator.
-Copyright 1994-1996, 1999, 2001, 2002, 2004, 2012 Free Software Foundation,
-Inc.
+Copyright 1994-1996, 1999, 2001, 2002, 2004, 2012, 2015 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/fdiv_r_ui.c
--- a/mpz/fdiv_r_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/fdiv_r_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,8 +1,8 @@
/* mpz_fdiv_r_ui -- Division rounding the quotient towards -infinity.
The remainder gets the same sign as the denominator.
-Copyright 1994-1996, 2001, 2002, 2004, 2005, 2012 Free Software Foundation,
-Inc.
+Copyright 1994-1996, 2001, 2002, 2004, 2005, 2012, 2015 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/fib2_ui.c
--- a/mpz/fib2_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/fib2_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,6 +1,6 @@
/* mpz_fib2_ui -- calculate Fibonacci numbers.
-Copyright 2001, 2012, 2014 Free Software Foundation, Inc.
+Copyright 2001, 2012, 2014, 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/fib_ui.c
--- a/mpz/fib_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/fib_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,6 +1,6 @@
/* mpz_fib_ui -- calculate Fibonacci numbers.
-Copyright 2000-2002, 2005, 2012, 2014 Free Software Foundation, Inc.
+Copyright 2000-2002, 2005, 2012, 2014, 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/gcd.c
--- a/mpz/gcd.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/gcd.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,7 +1,7 @@
/* mpz/gcd.c: Calculate the greatest common divisor of two integers.
-Copyright 1991, 1993, 1994, 1996, 2000-2002, 2005, 2010 Free Software
-Foundation, Inc.
+Copyright 1991, 1993, 1994, 1996, 2000-2002, 2005, 2010, 2015 Free
+Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/gcd_ui.c
--- a/mpz/gcd_ui.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/gcd_ui.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,6 +1,6 @@
/* mpz_gcd_ui -- Calculate the greatest common divisor of two integers.
-Copyright 1994, 1996, 1999-2004 Free Software Foundation, Inc.
+Copyright 1994, 1996, 1999-2004, 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff -r cdf45e583489 -r c1ae4ee719a1 mpz/gcdext.c
--- a/mpz/gcdext.c Thu Nov 12 12:31:28 2015 +0100
+++ b/mpz/gcdext.c Fri Nov 13 07:13:46 2015 +0100
@@ -1,8 +1,8 @@
/* mpz_gcdext(g, s, t, a, b) -- Set G to gcd(a, b), and S and T such that
g = as + bt.
-Copyright 1991, 1993-1997, 2000, 2001, 2005, 2011, 2012 Free Software
More information about the gmp-commit
mailing list