From 41bd4e38da467b22655ca4b81fda22bd3afd6f95 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 5 Apr 2019 20:04:40 -0700 Subject: mpi: use integer math for radix length. * mpi/logtab.h: Regenerated. (s_logv_2): Now table of scaled integers. (MP_LOG_SCALE): New constant. * mpi/make-logtab.txr (scale, type): New variables. Generate integer table with log2 values scaled by the scale factor, rounded up. * mpi/config.h (MP_LOGTAB): Removed. We always use the table. * mpi/mpi.c: Unconditionally include logtab.h. (LOG_V_2): Macro removed. (s_mp_outlen): Rewritten using scaled integer math. Overflow is avoided by splitting the input into a part that is an exact multiple of the scale factor, and a remaining part. Only the remaining part need be multiplied by a value from the table before dividing by the scale factor. --- mpi/mpi-config.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'mpi/mpi-config.h') diff --git a/mpi/mpi-config.h b/mpi/mpi-config.h index ed7a87b6..801eaae7 100644 --- a/mpi/mpi-config.h +++ b/mpi/mpi-config.h @@ -12,10 +12,6 @@ #define MP_NUMTH 1 /* include number theoretic functions? */ #endif -#ifndef MP_LOGTAB -#define MP_LOGTAB 1 /* use table of logs instead of log()? */ -#endif - #ifndef MP_MEMSET #define MP_MEMSET 1 /* use memset() to zero buffers? */ #endif -- cgit v1.2.3