Commit 50f0bd750e79dc24541dc82220b1a96f9a08e135

Steffen Jaeckel 2019-05-24T12:30:29

Merge pull request #290 from libtom/private-mp-prec MP_PREC is an internal macro, it should be defined in tommath_private.h

diff --git a/tommath.h b/tommath.h
index a420f5b..70bda2f 100644
--- a/tommath.h
+++ b/tommath.h
@@ -161,12 +161,13 @@ TOOM_SQR_CUTOFF;
 /* default precision */
 #ifndef MP_PREC
 #   ifndef MP_LOW_MEM
-#      define MP_PREC 32        /* default digits of precision */
+#      define PRIVATE_MP_PREC 32        /* default digits of precision */
 #   elif defined(MP_8BIT)
-#      define MP_PREC 16        /* default digits of precision */
+#      define PRIVATE_MP_PREC 16        /* default digits of precision */
 #   else
-#      define MP_PREC 8         /* default digits of precision */
+#      define PRIVATE_MP_PREC 8         /* default digits of precision */
 #   endif
+#   define MP_PREC (MP_DEPRECATED_PRAGMA("MP_PREC is an internal macro") PRIVATE_MP_PREC)
 #endif
 
 /* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
diff --git a/tommath_private.h b/tommath_private.h
index 4df0a32..a8bae40 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -140,10 +140,6 @@ extern void *MP_CALLOC(size_t nmemb, size_t size);
 extern void MP_FREE(void *mem, size_t size);
 #endif
 
-/* TODO: Remove PRIVATE_MP_WARRAY as soon as deprecated MP_WARRAY is removed from tommath.h */
-#undef MP_WARRAY
-#define MP_WARRAY PRIVATE_MP_WARRAY
-
 /* TODO: Remove private_mp_word as soon as deprecated mp_word is removed from tommath. */
 #undef mp_word
 typedef private_mp_word mp_word;
@@ -162,6 +158,16 @@ typedef private_mp_word mp_word;
 #define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
 #define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
 
+/* TODO: Remove PRIVATE_MP_WARRAY as soon as deprecated MP_WARRAY is removed from tommath.h */
+#undef MP_WARRAY
+#define MP_WARRAY PRIVATE_MP_WARRAY
+
+/* TODO: Remove PRIVATE_MP_PREC as soon as deprecated MP_PREC is removed from tommath.h */
+#ifdef PRIVATE_MP_PREC
+#   undef MP_PREC
+#   define MP_PREC PRIVATE_MP_PREC
+#endif
+
 /* Minimum number of available digits in mp_int, MP_PREC >= MP_MIN_PREC */
 #define MP_MIN_PREC ((((CHAR_BIT * (int)sizeof(long long)) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)