[Gmp-commit] /var/hg/gmp: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Feb 18 10:02:15 UTC 2018


details:   /var/hg/gmp/rev/10b961ef96fd
changeset: 17560:10b961ef96fd
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Feb 18 10:59:38 2018 +0100
description:
tune/Makefile.am: Disallow parallel make (thanks Vincent Lefevre)

details:   /var/hg/gmp/rev/462d09eade1e
changeset: 17561:462d09eade1e
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Feb 18 11:00:49 2018 +0100
description:
mpq/swap.c: Use *_SWAP_* macros.

details:   /var/hg/gmp/rev/f64bf58bf1b9
changeset: 17562:f64bf58bf1b9
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Feb 18 11:02:06 2018 +0100
description:
mpq/cmp_ui.c: One more little shortcut comparing fractions to 1.

diffstat:

 mpq/cmp_ui.c     |  15 +++++++++------
 mpq/swap.c       |  42 +++++++-----------------------------------
 tune/Makefile.am |   3 +++
 3 files changed, 19 insertions(+), 41 deletions(-)

diffs (107 lines):

diff -r 164971d5c8d0 -r f64bf58bf1b9 mpq/cmp_ui.c
--- a/mpq/cmp_ui.c	Sat Feb 10 18:05:32 2018 +0100
+++ b/mpq/cmp_ui.c	Sun Feb 18 11:02:06 2018 +0100
@@ -2,7 +2,8 @@
    negative based on if U > V, U == V, or U < V.  Vn and Vd may have
    common factors.
 
-Copyright 1993, 1994, 1996, 2000-2003, 2005, 2014 Free Software Foundation, Inc.
+Copyright 1993, 1994, 1996, 2000-2003, 2005, 2014, 2018 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -68,11 +69,13 @@
     return -1;
 
   /* NUM1 x DEN2 is either TMP1_SIZE limbs or TMP1_SIZE-1 limbs.
-     Same for NUM1 x DEN1 with respect to TMP2_SIZE.  */
-  if (num1_size > den1_size + 1)
+     Same for NUM2 x DEN1 with respect to TMP2_SIZE.  */
+  /* If frac2 <= 1 (i.e. num2 <= den2), shortcut with a simpler
+     condition: num1 > den1. Here we only test sizes. */
+  if (num1_size > den1_size + (num2 > den2))
     /* NUM1 x DEN2 is surely larger in magnitude than NUM2 x DEN1.  */
     return num1_size;
-  if (den1_size > num1_size + 1)
+  if (den1_size > num1_size + (den2 > num2))
     /* NUM1 x DEN2 is surely smaller in magnitude than NUM2 x DEN1.  */
     return -num1_size;
 
@@ -89,8 +92,8 @@
   tmp2_ptr[den1_size] = cy_limb;
   tmp2_size = den1_size + (cy_limb != 0);
 
-  cc = tmp1_size - tmp2_size != 0
-    ? tmp1_size - tmp2_size : mpn_cmp (tmp1_ptr, tmp2_ptr, tmp1_size);
+  cc = tmp1_size - tmp2_size;
+  cc = cc != 0 ? cc : mpn_cmp (tmp1_ptr, tmp2_ptr, tmp1_size);
   TMP_FREE;
   return cc;
 }
diff -r 164971d5c8d0 -r f64bf58bf1b9 mpq/swap.c
--- a/mpq/swap.c	Sat Feb 10 18:05:32 2018 +0100
+++ b/mpq/swap.c	Sun Feb 18 11:02:06 2018 +0100
@@ -1,6 +1,6 @@
 /* mpq_swap (U, V) -- Swap U and V.
 
-Copyright 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1997, 1998, 2000, 2001, 2018 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -33,38 +33,10 @@
 void
 mpq_swap (mpq_ptr u, mpq_ptr v) __GMP_NOTHROW
 {
-  mp_ptr up, vp;
-  mp_size_t usize, vsize;
-  mp_size_t ualloc, valloc;
-
-  ualloc = ALLOC(NUM(u));
-  valloc = ALLOC(NUM(v));
-  ALLOC(NUM(v)) = ualloc;
-  ALLOC(NUM(u)) = valloc;
-
-  usize = SIZ(NUM(u));
-  vsize = SIZ(NUM(v));
-  SIZ(NUM(v)) = usize;
-  SIZ(NUM(u)) = vsize;
-
-  up = PTR(NUM(u));
-  vp = PTR(NUM(v));
-  PTR(NUM(v)) = up;
-  PTR(NUM(u)) = vp;
-
-
-  ualloc = ALLOC(DEN(u));
-  valloc = ALLOC(DEN(v));
-  ALLOC(DEN(v)) = ualloc;
-  ALLOC(DEN(u)) = valloc;
-
-  usize = SIZ(DEN(u));
-  vsize = SIZ(DEN(v));
-  SIZ(DEN(v)) = usize;
-  SIZ(DEN(u)) = vsize;
-
-  up = PTR(DEN(u));
-  vp = PTR(DEN(v));
-  PTR(DEN(v)) = up;
-  PTR(DEN(u)) = vp;
+  MP_SIZE_T_SWAP (ALLOC(NUM(u)), ALLOC(NUM(v)));
+  MP_SIZE_T_SWAP (ALLOC(DEN(u)), ALLOC(DEN(v)));
+  MP_SIZE_T_SWAP (SIZ(NUM(u)), SIZ(NUM(v)));
+  MP_SIZE_T_SWAP (SIZ(DEN(u)), SIZ(DEN(v)));
+  MP_PTR_SWAP (PTR(NUM(u)), PTR(NUM(v)));
+  MP_PTR_SWAP (PTR(DEN(u)), PTR(DEN(v)));
 }
diff -r 164971d5c8d0 -r f64bf58bf1b9 tune/Makefile.am
--- a/tune/Makefile.am	Sat Feb 10 18:05:32 2018 +0100
+++ b/tune/Makefile.am	Sun Feb 18 11:02:06 2018 +0100
@@ -180,3 +180,6 @@
 	echo "#include \"mpz/fac_ui.c\""             >>fac_ui.c
 
 include ../mpn/Makeasm.am
+
+.NOTPARALLEL:
+


More information about the gmp-commit mailing list