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

mercurial at gmplib.org mercurial at gmplib.org
Mon Mar 18 07:31:58 CET 2013


details:   /var/hg/gmp/rev/e59e2a196595
changeset: 15594:e59e2a196595
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon Mar 18 07:31:24 2013 +0100
description:
doc/gmp.texi (--enable-fat): No quote in concept index.

details:   /var/hg/gmp/rev/3bbbb95f00e2
changeset: 15595:3bbbb95f00e2
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon Mar 18 07:31:44 2013 +0100
description:
wap.c: Reduce the number of variables.

details:   /var/hg/gmp/rev/90486ce1defe
changeset: 15596:90486ce1defe
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon Mar 18 07:31:52 2013 +0100
description:
ChangeLog

diffstat:

 ChangeLog    |   6 ++++++
 doc/gmp.texi |  25 ++++++++++++++++++++++---
 mpf/swap.c   |  38 +++++++++++++++++---------------------
 3 files changed, 45 insertions(+), 24 deletions(-)

diffs (125 lines):

diff -r e49a084a7ec6 -r 90486ce1defe ChangeLog
--- a/ChangeLog	Sun Mar 17 19:14:51 2013 +0100
+++ b/ChangeLog	Mon Mar 18 07:31:52 2013 +0100
@@ -1,3 +1,9 @@
+2013-03-18 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* doc/gmp.texi (--enable-fat): No quote in concept index.
+
+	* mpf/swap.c: Reduce the number of variables.
+
 2012-03-17  Marc Glisse  <marc.glisse at inria.fr>
 
 	* tests/cxx/t-do-exceptions-work-at-all-with-this-compiler.cc: New file.
diff -r e49a084a7ec6 -r 90486ce1defe doc/gmp.texi
--- a/doc/gmp.texi	Sun Mar 17 19:14:51 2013 +0100
+++ b/doc/gmp.texi	Mon Mar 18 07:31:52 2013 +0100
@@ -866,7 +866,7 @@
 
 @item Fat binary, @option{--enable-fat}
 @cindex Fat binary
- at cindex @option{--enable-fat}
+ at cindex @code{--enable-fat}
 Using @option{--enable-fat} selects a ``fat binary'' build on x86, where
 optimized low level subroutines are chosen at runtime according to the CPU
 detected.  This means more code, but gives good performance on all x86 chips.
@@ -3045,7 +3045,8 @@
 
 @deftypefun int mpz_set_str (mpz_t @var{rop}, char *@var{str}, int @var{base})
 Set the value of @var{rop} from @var{str}, a null-terminated C string in base
- at var{base}.  White space is allowed in the string, and is simply ignored.
+ at var{base}.  White space is allowed at the beginning, and at the end of the
+string, or between digits, and is simply ignored.
 
 The @var{base} may vary from 2 to 62, or if @var{base} is 0, then the leading
 characters are used: @code{0x} and @code{0X} for hexadecimal, @code{0b} and
@@ -3988,7 +3989,15 @@
 @code{short} and @code{int} are always stored in 8 bytes (and with
 @code{sizeof} indicating that) but use only 32 or 46 bits.  The @var{nails}
 feature can account for this, by passing for instance
- at code{8*sizeof(int)-INT_BIT}.
+ at code{8*sizeof(int)-INT_BIT}.  The supported way to set an @code{mpz_t}
+variable with a value in the @code{mpn} format, follows.
+
+ at example
+mp_limb_t *xp;
+mp_size_t  xn;
+/* Initialize @var{z} and @var{xp, xn} */
+mpz_import (z, xn, -1, sizeof(mp_limb_t), 0, GMP_NAIL_BITS, xp);
+ at end example
 @end deftypefun
 
 @deftypefun {void *} mpz_export (void *@var{rop}, size_t *@var{countp}, int @var{order}, size_t @var{size}, int @var{endian}, size_t @var{nails}, mpz_t @var{op})
@@ -4032,6 +4041,16 @@
 count = (mpz_sizeinbase (z, 2) + numb-1) / numb;
 p = malloc (count * size);
 @end example
+
+The supported way to extract the absolute value of an @code{mpz_t} variable
+into the @code{mpn} format, follows.
+
+ at example
+mp_limb_t *xp;
+mp_size_t  xn;
+/* Initialize @var{z} */
+xp = mpz_export (NULL, &xn, -1, sizeof(mp_limb_t), 0, GMP_NAIL_BITS, z);
+ at end example
 @end deftypefun
 
 
diff -r e49a084a7ec6 -r 90486ce1defe mpf/swap.c
--- a/mpf/swap.c	Sun Mar 17 19:14:51 2013 +0100
+++ b/mpf/swap.c	Mon Mar 18 07:31:52 2013 +0100
@@ -1,6 +1,6 @@
 /* mpf_swap (U, V) -- Swap U and V.
 
-Copyright 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1997, 1998, 2000, 2001, 2013 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -23,28 +23,24 @@
 void
 mpf_swap (mpf_ptr u, mpf_ptr v) __GMP_NOTHROW
 {
-  mp_ptr up, vp;
-  mp_size_t usize, vsize;
-  mp_size_t uprec, vprec;
-  mp_exp_t  uexp, vexp;
+  mp_ptr tptr;
+  mp_size_t tprec;
+  mp_size_t tsiz;
+  mp_exp_t  texp;
 
-  uprec = u->_mp_prec;
-  vprec = v->_mp_prec;
-  v->_mp_prec = uprec;
-  u->_mp_prec = vprec;
+  tprec = PREC(u);
+  PREC(u) = PREC(v);
+  PREC(v) = tprec;
 
-  usize = u->_mp_size;
-  vsize = v->_mp_size;
-  v->_mp_size = usize;
-  u->_mp_size = vsize;
+  tsiz = SIZ(u);
+  SIZ(u) = SIZ(v);
+  SIZ(v) = tsiz;
 
-  uexp = u->_mp_exp;
-  vexp = v->_mp_exp;
-  v->_mp_exp = uexp;
-  u->_mp_exp = vexp;
+  texp = EXP(u);
+  EXP(u) = EXP(v);
+  EXP(v) = texp;
 
-  up = u->_mp_d;
-  vp = v->_mp_d;
-  v->_mp_d = up;
-  u->_mp_d = vp;
+  tptr = PTR(u);
+  PTR(u) = PTR(v);
+  PTR(v) = tptr;
 }


More information about the gmp-commit mailing list