summaryrefslogtreecommitdiff
path: root/gmp-glue.h
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2013-04-04 11:07:31 +0200
committerNiels Möller <nisse@lysator.liu.se>2013-04-04 11:07:31 +0200
commit0d039117d988ac5132c86f5fff3206a44db6f98f (patch)
treed3c93535cf39a096195695259e6e1f61762023f4 /gmp-glue.h
parent2d796c6e6807f27d5c1b49dbeb49deaa77c98b86 (diff)
downloadnettle-0d039117d988ac5132c86f5fff3206a44db6f98f.tar.gz
Use mpn_cnd_add_n and mpn_cnd_sub_n when available. Rearrange inclusions of gmp-glue.h.
Diffstat (limited to 'gmp-glue.h')
-rw-r--r--gmp-glue.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/gmp-glue.h b/gmp-glue.h
index e7645716..fcc47d00 100644
--- a/gmp-glue.h
+++ b/gmp-glue.h
@@ -50,6 +50,15 @@
#define gmp_alloc_limbs _nettle_gmp_alloc_limbs
#define gmp_free_limbs _nettle_gmp_free_limbs
+/* Use only in-place operations, so we can fall back to addmul_1/submul_1 */
+#ifdef mpn_cnd_add_n
+# define cnd_add_n(cnd, rp, ap, n) mpn_cnd_add_n ((cnd), (rp), (rp), (ap), (n))
+# define cnd_sub_n(cnd, rp, ap, n) mpn_cnd_sub_n ((cnd), (rp), (rp), (ap), (n))
+#else
+# define cnd_add_n(cnd, rp, ap, n) mpn_addmul_1 ((rp), (ap), (n), (cnd) != 0)
+# define cnd_sub_n(cnd, rp, ap, n) mpn_submul_1 ((rp), (ap), (n), (cnd) != 0)
+#endif
+
/* Some functions for interfacing between mpz and mpn code. Signs of
the mpz numbers are generally ignored. */