[Gmp-commit] /var/hg/gmp: Made mpn_cnd_swap public.

mercurial at gmplib.org mercurial at gmplib.org
Sun Feb 8 08:53:22 UTC 2015


details:   /var/hg/gmp/rev/0f8d54477a96
changeset: 16555:0f8d54477a96
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Sun Feb 08 08:18:00 2015 +0100
description:
Made mpn_cnd_swap public.

diffstat:

 ChangeLog                |  10 +++++++++
 configure.ac             |   2 +-
 gmp-h.in                 |   3 ++
 mpn/generic/cnd_swap.c   |  51 ++++++++++++++++++++++++++++++++++++++++++++++++
 mpn/generic/sec_invert.c |  17 ----------------
 5 files changed, 65 insertions(+), 18 deletions(-)

diffs (124 lines):

diff -r 2483c36be4be -r 0f8d54477a96 ChangeLog
--- a/ChangeLog	Mon Jan 19 20:23:58 2015 +0100
+++ b/ChangeLog	Sun Feb 08 08:18:00 2015 +0100
@@ -1,3 +1,13 @@
+2015-02-08  Niels Möller  <nisse at lysator.liu.se>
+
+	* doc/gmp.texi (Low-level Functions): Document mpn_cnd_swap.
+
+	* mpn/generic/cnd_swap.c (mpn_cnd_swap): New file, moved function
+	here. Also changed cnd argument type from int to mp_limb_t.
+	* mpn/generic/sec_invert.c (mpn_cnd_swap): Old location.
+	* configure.ac: Added cnd_swap.
+	* gmp-h.in (mpn_cnd_swap): Added prototype.
+
 2015-01-19  Torbjörn Granlund  <torbjorng at google.com>
 
 	* configure.ac (arm): Provide architecture specific configs in addition
diff -r 2483c36be4be -r 0f8d54477a96 configure.ac
--- a/configure.ac	Mon Jan 19 20:23:58 2015 +0100
+++ b/configure.ac	Sun Feb 08 08:18:00 2015 +0100
@@ -2825,7 +2825,7 @@
   add_n_sub_n addaddmul_1msb0"
 
 gmp_mpn_functions="$extra_functions					   \
-  add add_1 add_n sub sub_1 sub_n cnd_add_n cnd_sub_n neg com		   \
+  add add_1 add_n sub sub_1 sub_n cnd_add_n cnd_sub_n cnd_swap neg com	   \
   mul_1 addmul_1 submul_1						   \
   add_err1_n add_err2_n add_err3_n sub_err1_n sub_err2_n sub_err3_n	   \
   lshift rshift dive_1 diveby3 divis divrem divrem_1 divrem_2		   \
diff -r 2483c36be4be -r 0f8d54477a96 gmp-h.in
--- a/gmp-h.in	Mon Jan 19 20:23:58 2015 +0100
+++ b/gmp-h.in	Sun Feb 08 08:18:00 2015 +0100
@@ -1643,6 +1643,9 @@
 #define mpn_sec_sub_1_itch __MPN(sec_sub_1_itch)
 __GMP_DECLSPEC mp_size_t mpn_sec_sub_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;
 
+#define mpn_cnd_swap  __MPN(cnd_swap)
+__GMP_DECLSPEC void mpn_cnd_swap (mp_limb_t, volatile mp_limb_t *, volatile mp_limb_t *, mp_size_t);
+
 #define mpn_sec_mul __MPN(sec_mul)
 __GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);
 #define mpn_sec_mul_itch __MPN(sec_mul_itch)
diff -r 2483c36be4be -r 0f8d54477a96 mpn/generic/cnd_swap.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/generic/cnd_swap.c	Sun Feb 08 08:18:00 2015 +0100
@@ -0,0 +1,51 @@
+/* mpn_cnd_swap
+
+   Contributed to the GNU project by Niels Möller
+
+Copyright 2013, 2015 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of either:
+
+  * the GNU Lesser General Public License as published by the Free
+    Software Foundation; either version 3 of the License, or (at your
+    option) any later version.
+
+or
+
+  * the GNU General Public License as published by the Free Software
+    Foundation; either version 2 of the License, or (at your option) any
+    later version.
+
+or both in parallel, as here.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received copies of the GNU General Public License and the
+GNU Lesser General Public License along with the GNU MP Library.  If not,
+see https://www.gnu.org/licenses/.  */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+void
+mpn_cnd_swap (mp_limb_t cnd, volatile mp_limb_t *ap, volatile mp_limb_t *bp,
+	      mp_size_t n)
+{
+  volatile mp_limb_t mask = - (mp_limb_t) (cnd != 0);
+  mp_size_t i;
+  for (i = 0; i < n; i++)
+    {
+      mp_limb_t a, b, t;
+      a = ap[i];
+      b = bp[i];
+      t = (a ^ b) & mask;
+      ap[i] = a ^ t;
+      bp[i] = b ^ t;
+    }
+}
diff -r 2483c36be4be -r 0f8d54477a96 mpn/generic/sec_invert.c
--- a/mpn/generic/sec_invert.c	Mon Jan 19 20:23:58 2015 +0100
+++ b/mpn/generic/sec_invert.c	Sun Feb 08 08:18:00 2015 +0100
@@ -52,23 +52,6 @@
   mpn_cnd_sub_n (cnd, rp, ap, scratch, n);
 }
 
-static void
-mpn_cnd_swap (int cnd, volatile mp_limb_t *ap, volatile mp_limb_t *bp,
-	      mp_size_t n)
-{
-  volatile mp_limb_t mask = - (mp_limb_t) (cnd != 0);
-  mp_size_t i;
-  for (i = 0; i < n; i++)
-    {
-      mp_limb_t a, b, t;
-      a = ap[i];
-      b = bp[i];
-      t = (a ^ b) & mask;
-      ap[i] = a ^ t;
-      bp[i] = b ^ t;
-    }
-}
-
 static int
 mpn_sec_eq_ui (mp_srcptr ap, mp_size_t n, mp_limb_t b)
 {


More information about the gmp-commit mailing list