iFixes to FP_MAX_BITS_ECC calculation. Alignment check against digit_bits is based on max ecc bits times two. If alignment check fails we add a digit_bit to make sure we have enough room.

This commit is contained in:
David Garske
2016-05-10 12:20:39 -07:00
parent d71d0f2cb4
commit 2fb4506922

View File

@@ -114,18 +114,18 @@ typedef struct {
/* determine max bits required for ECC math */ /* determine max bits required for ECC math */
#ifndef FP_MAX_BITS_ECC #ifndef FP_MAX_BITS_ECC
/* check alignment */ /* check alignment */
#if (MAX_ECC_BITS % CHAR_BIT) == 0 #if ((MAX_ECC_BITS * 2) % DIGIT_BIT) == 0
/* max bits is double */ /* max bits is double */
#define FP_MAX_BITS_ECC (MAX_ECC_BITS * 2) #define FP_MAX_BITS_ECC (MAX_ECC_BITS * 2)
#else #else
/* max bits is doubled, plus one digit of fudge then 8-bit aligned */ /* max bits is doubled, plus one digit of fudge */
#define FP_MAX_BITS_ECC (((MAX_ECC_BITS * 2) + DIGIT_BIT) & ~(CHAR_BIT-1)) #define FP_MAX_BITS_ECC ((MAX_ECC_BITS * 2) + DIGIT_BIT)
#endif
#else
/* verify alignment */
#if FP_MAX_BITS_ECC % CHAR_BIT
#error FP_MAX_BITS_ECC must be a multiple of CHAR_BIT
#endif #endif
#endif
/* verify alignment */
#if FP_MAX_BITS_ECC % CHAR_BIT
#error FP_MAX_BITS_ECC must be a multiple of CHAR_BIT
#endif #endif
/* determine buffer size */ /* determine buffer size */