From 9d697d468636437e0d5b17a88c08c5a724a1f1de Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 10 Dec 2014 19:01:12 +0100 Subject: [PATCH] fix compilation with MP_8BIT or MP_16BIT --- tommath.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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;