Commit 9d697d468636437e0d5b17a88c08c5a724a1f1de

Steffen Jaeckel 2014-12-10T19:01:12

fix compilation with MP_8BIT or MP_16BIT

diff --git a/tommath.h b/tommath.h
index bccd9d9..8af8af2 100644
--- a/tommath.h
+++ b/tommath.h
@@ -63,12 +63,14 @@ extern "C" {
 #ifdef MP_8BIT
    typedef unsigned char      mp_digit;
    typedef unsigned short     mp_word;
+#define MP_SIZEOF_MP_DIGIT 1
 #ifdef DIGIT_BIT
 #error You must not define DIGIT_BIT when using MP_8BIT
 #endif
 #elif defined(MP_16BIT)
    typedef unsigned short     mp_digit;
    typedef unsigned int       mp_word;
+#define MP_SIZEOF_MP_DIGIT 2
 #ifdef DIGIT_BIT
 #error You must not define DIGIT_BIT when using MP_16BIT
 #endif
@@ -130,7 +132,7 @@ extern "C" {
 
 /* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
 #ifndef DIGIT_BIT
-   #define DIGIT_BIT     ((int)((CHAR_BIT * sizeof(mp_digit) - 1)))  /* bits per digit */
+   #define DIGIT_BIT     (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1))  /* bits per digit */
    typedef unsigned long mp_min_u32;
 #else
    typedef mp_digit mp_min_u32;