From 78823b2c7c5e3a2e52e30c35367662d74bca001b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Tue, 12 Sep 2017 22:38:34 +0200
Subject: [PATCH] Avoid redefining mpn_zero_p when building with mini-gmp.

---
 ChangeLog             |  8 ++++++++
 testsuite/testutils.h | 19 ++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 96fd6a3e..b9f597a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-09-12  Niels Möller  <nisse@lysator.liu.se>
+
+	* testsuite/testutils.h (mpn_zero_p): Avoid redefining mpn_zero_p
+	when building with mini-gmp. Since the mini-gmp update, this
+	function is defined by mini-gmp, causing link errors if nettle is
+	configured with --enable-mini-gmp --disable-shared. Reported by
+	Tim Rühsen.
+
 2017-09-09  Daiki Ueno  <dueno@redhat.com>
 
 	* testsuite/ecc-mul-g-test.c (test_main): Fixed mpn_cmp call.
diff --git a/testsuite/testutils.h b/testsuite/testutils.h
index 7c44772b..caab4034 100644
--- a/testsuite/testutils.h
+++ b/testsuite/testutils.h
@@ -163,13 +163,6 @@ test_armor(const struct nettle_armor *armor,
            const char *ascii);
 
 #if WITH_HOGWEED
-#ifndef mpn_zero_p
-int
-mpn_zero_p (mp_srcptr ap, mp_size_t n);
-#endif
-
-void
-mpn_out_str (FILE *f, int base, const mp_limb_t *xp, mp_size_t xn);
 
 #if NETTLE_USE_MINI_GMP
 typedef struct knuth_lfib_ctx gmp_randstate_t[1];
@@ -180,8 +173,20 @@ void mpz_urandomb (mpz_t r, struct knuth_lfib_ctx *ctx, mp_bitcnt_t bits);
 /* This is cheating */
 #define mpz_rrandomb mpz_urandomb
 
+/* mini-gmp defines this function (in the GMP library, it was added in
+   gmp in version 6.1.0). */
+#define mpn_zero_p mpn_zero_p
+
 #endif /* NETTLE_USE_MINI_GMP */
 
+#ifndef mpn_zero_p
+int
+mpn_zero_p (mp_srcptr ap, mp_size_t n);
+#endif
+
+void
+mpn_out_str (FILE *f, int base, const mp_limb_t *xp, mp_size_t xn);
+
 mp_limb_t *
 xalloc_limbs (mp_size_t n);
 
-- 
GitLab