Commit 121973fc6ba03cf3e83d2d679fba0ff6eb01986b

Steffen Jaeckel 2019-10-23T18:20:22

Merge pull request #399 from libtom/private-mp-word remove private_mp_word

diff --git a/etc/pprime.c b/etc/pprime.c
index 50be809..411e446 100644
--- a/etc/pprime.c
+++ b/etc/pprime.c
@@ -8,9 +8,6 @@
 #include <time.h>
 #include "tommath.h"
 
-/* TODO: Remove private_mp_word as soon as deprecated mp_word is removed from tommath. */
-typedef private_mp_word mp_word;
-
 static int   n_prime;
 static FILE *primes;
 
diff --git a/tommath.h b/tommath.h
index 9421c6d..f415a7f 100644
--- a/tommath.h
+++ b/tommath.h
@@ -51,21 +51,14 @@ extern "C" {
  * [any size beyond that is ok provided it doesn't overflow the data type]
  */
 
-
 #if defined(MP_16BIT)
 typedef uint16_t             mp_digit;
-typedef uint32_t             private_mp_word;
 #   define MP_DIGIT_BIT 15
 #elif defined(MP_64BIT)
-/* for GCC only on supported platforms */
 typedef uint64_t mp_digit;
-#if defined(__GNUC__)
-typedef unsigned long        private_mp_word __attribute__((mode(TI)));
-#endif
 #   define MP_DIGIT_BIT 60
 #else
 typedef uint32_t             mp_digit;
-typedef uint64_t             private_mp_word;
 #   ifdef MP_31BIT
 /*
  * This is an extension that uses 31-bit digits.
diff --git a/tommath_private.h b/tommath_private.h
index e37def4..b18663b 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -148,9 +148,6 @@ extern void MP_FREE(void *mem, size_t size);
 #define MP__STRINGIZE(x) ""#x""
 #define MP_HAS(x)        (sizeof(MP_STRINGIZE(x##_C)) == 1u)
 
-/* TODO: Remove private_mp_word as soon as deprecated mp_word is removed from tommath. */
-typedef private_mp_word mp_word;
-
 #define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
 #define MP_MAX(x, y) (((x) > (y)) ? (x) : (y))
 
@@ -167,6 +164,15 @@ typedef private_mp_word mp_word;
 
 #define MP_WARRAY (1 << ((MP_SIZEOF_BITS(mp_word) - (2 * MP_DIGIT_BIT)) + 1))
 
+#if defined(MP_16BIT)
+typedef uint32_t mp_word;
+#elif defined(MP_64BIT)
+typedef unsigned long mp_word __attribute__((mode(TI)));
+#else
+typedef uint64_t mp_word;
+#endif
+
+MP_STATIC_ASSERT(correct_word_size, sizeof(mp_word) == 2 * sizeof(mp_digit))
 
 /* default precision */
 #ifndef MP_PREC