diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f852491..f1dbc230 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,34 @@ if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") list(APPEND LTM_C_FLAGS -no-undefined) endif() +#----------------------------------------------------------------------------- +# Check for floating point intrinsics +#----------------------------------------------------------------------------- + +# TODO: add checks to mp_[gs]et_double if this works well +include(CheckTypeSize) +CHECK_TYPE_SIZE("float" FLOAT_SIZE) +CHECK_TYPE_SIZE("double" DOUBLE_SIZE) +CHECK_TYPE_SIZE("long double" LONG_DOUBLE_SIZE) + +# Do we have anything even vaguely resembling floating points at all? +if(FLOAT_SIZE GREATER 0) + list(APPEND LTM_C_FLAGS -DLTM_HAVE_FLOAT_TYPE) + # float.h may or may not exist, even with floats avaibl + list(APPEND LTM_C_FLAGS -DLTM_FLOAT_SIZE=${FLOAT_SIZE}) +endif() + +if(DOUBLE_SIZE GREATER 0) + list(APPEND LTM_C_FLAGS -DLTM_HAVE_DOUBLE_TYPE) + list(APPEND LTM_C_FLAGS -DLTM_DOUBLE_SIZE=${DOUBLE_SIZE}) +endif() + +if(LONG_DOUBLE_SIZE GREATER 0) + list(APPEND LTM_C_FLAGS -DLTM_HAVE_LONG_DOUBLE_TYPE) + list(APPEND LTM_C_FLAGS -DLTM_LONG_DOUBLE_SIZE=${LONG_DOUBLE_SIZE}) +endif() + + # TODO: coverage (lgcov) # If the user set the environment variables at generate-time, append them diff --git a/demo/test.c b/demo/test.c index 939fcc0e..d2176c16 100644 --- a/demo/test.c +++ b/demo/test.c @@ -2426,6 +2426,234 @@ static int test_mp_pack_unpack(void) return EXIT_FAILURE; } +#ifndef MP_NO_FILE + +#define LTM_TEST_BUFSIZ 4096 +#include +static int test_mp_fprintf(void) +{ + FILE *test_file = NULL; + + char line_buffer[LTM_TEST_BUFSIZ] = {0}; + int i; + bool write_only = false; + size_t slen = 0; + int characters_printed = 0; + char *fgets_return; + + const char *test_values[2] = { + "4DDCFDE0D20EF8663B34D19F829FDD", + "-51D9769BDAE5B38121F2A31D881E5F" + }; + + const char *test_strings[] = { +#ifdef LTM_HAVE_FLOAT_TYPE + "START 0x0000007b 123.123 -424986725583297217766029037085924959 0x4DDCFDE0D20EF8663B34D19F829FDD END\n", +#endif + "START -0b10100011101100101110110100110111101101011100101101100111000000100100001111100101010001100011101100010000001111001011111 END\n", + "START @ -KTbsczhbiu4XygCTY1vV @ END\n", +#if (MP_DIGIT_BIT == 60) + "START 0x63b34d19f829fdd,0x4ddcfde0d20ef86 END\n", +#elif (MP_DIGIT_BIT == 31) + "START 0x1f829fdd,0x4c7669a3,0x3483be1,0x26ee7ef END\n", +#elif (MP_DIGIT_BIT == 28) + "START 0xf829fdd,0x3b34d19,0x20ef866,0xdcfde0d,0x4d END\n", +#elif (MP_DIGIT_BIT == 15) + "START 0x1fdd,0x3f05,0x5346,0x31d9,0x6f86,0x1a41,0x3f78,0x26ee END\n", +#else + "undefined limb size\n", +#endif + + +#if (MP_DIGIT_BIT == 60) + "START 0x000000000000063b34d19f829fdd END\n" +#elif (MP_DIGIT_BIT == 31) + "START 0x000000000000000000001f829fdd END\n" +#elif (MP_DIGIT_BIT == 28) + "START 0x000000000000000000000f829fdd END\n" +#elif (MP_DIGIT_BIT == 15) + "START 0x0000000000000000000000001fdd END\n" +#else + "undefined limb size\n" +#endif + }; + + mp_int p, q; + int n; + /* Only stream printing available, no mp_sprintf or the like. File needs a path for repeated truncating */ + test_file = fopen("ltm_testing_mp_fprintf_88a43603fcfc2f7e7c6646cd4b89180a", "w+"); + if (test_file == NULL) { + /* use logfile instead to have at least sth. in case of an error */ + test_file = stdout; + write_only = true; + } + + DOR(mp_init_multi(&p, &q, NULL)); + + DO(mp_read_radix(&p, test_values[0], 16)); + DO(mp_read_radix(&q, test_values[1], 16)); + + /* No loop here, too much hassle */ + i = 0; + /* Defined by CMake and is not in any of the generic Makefiles */ +#ifdef LTM_HAVE_FLOAT_TYPE + characters_printed = mp_fprintf(test_file, "START %#010x %12.12g %10Zd %#10Zx END\n",123,123.123,&q,&p,&q); + slen = strlen(test_strings[i]); + if ((characters_printed - (int)slen) != 0) { + fprintf(stderr, "0 test_mp_fprintf: failed to print o:%zu t:%d\n", slen, characters_printed); + goto LBL_ERR; + } + if (!write_only) { + rewind(test_file); + fgets_return = fgets(line_buffer, LTM_TEST_BUFSIZ, test_file); + if (fgets_return == NULL) { + fprintf(stderr, "1 test_mp_fprintf: failed to read from file\n"); + goto LBL_ERR; + } + if (strcmp(line_buffer, test_strings[i]) != 0) { + fprintf(stderr, "test_mp_fprintf: file content is not equal to test string #%d\n",i); + goto LBL_ERR; + } + } + i++; + /* Clear file content */ + test_file = freopen("ltm_testing_mp_fprintf_88a43603fcfc2f7e7c6646cd4b89180a","w+", test_file); + if (test_file == NULL) { + /* use logfile instead to have at least sth. in case of an error */ + test_file = stdout; + write_only = true; + } +#endif + + characters_printed = mp_fprintf(test_file, "START %#Zb END\n",&q); + slen = strlen(test_strings[i]); + if ((characters_printed - (int)slen) != 0) { + fprintf(stderr, "1 test_mp_fprintf: failed to print o:%zu t:%d\n", slen, characters_printed); + goto LBL_ERR; + } + if (!write_only) { + rewind(test_file); + fgets_return = fgets(line_buffer, LTM_TEST_BUFSIZ, test_file); + if (fgets_return == NULL) { + fprintf(stderr, "test_mp_fprintf: failed to read from file\n"); + goto LBL_ERR; + } + if (strcmp(line_buffer, test_strings[i]) != 0) { + fprintf(stderr, "test_mp_fprintf: file content is not equal to test string #%d\n",i); + goto LBL_ERR; + } + } + i++; + /* Clear file content */ + test_file = freopen("ltm_testing_mp_fprintf_88a43603fcfc2f7e7c6646cd4b89180a","w+", test_file); + if (test_file == NULL) { + /* use logfile instead to have at least sth. in case of an error */ + test_file = stdout; + write_only = true; + } + + characters_printed = mp_fprintf(test_file, "START @ %#Z@ @ END\n",&q); + slen = strlen(test_strings[i]); + if ((characters_printed - (int)slen) != 0) { + fprintf(stderr, "1 test_mp_fprintf: failed to print o:%zu t:%d\n", slen, characters_printed); + goto LBL_ERR; + } + if (!write_only) { + rewind(test_file); + fgets_return = fgets(line_buffer, LTM_TEST_BUFSIZ, test_file); + if (fgets_return == NULL) { + fprintf(stderr, "test_mp_fprintf: failed to read from file\n"); + goto LBL_ERR; + } + if (strcmp(line_buffer, test_strings[i]) != 0) { + fprintf(stderr, "test_mp_fprintf: file content is not equal to test string #%d\n",i); + goto LBL_ERR; + } + } + i++; + /* Clear file content */ + test_file = freopen("ltm_testing_mp_fprintf_88a43603fcfc2f7e7c6646cd4b89180a","w+", test_file); + if (test_file == NULL) { + /* use logfile instead to have at least sth. in case of an error */ + test_file = stdout; + write_only = true; + } + + /* TODO: add entries for the smaller mp_digits */ + characters_printed = mp_fprintf(test_file,"START %#Nx END\n",&p); + slen = strlen(test_strings[i]); + if ((characters_printed - (int)slen) != 0) { + fprintf(stderr, "2 test_mp_fprintf: failed to print o:%zu t:%d\n", slen, characters_printed); + goto LBL_ERR; + } + if (!write_only) { + rewind(test_file); + fgets_return = fgets(line_buffer, LTM_TEST_BUFSIZ, test_file); + if (fgets_return == NULL) { + fprintf(stderr, "test_mp_fprintf: failed to read from file\n"); + goto LBL_ERR; + } + if (strcmp(line_buffer, test_strings[i]) != 0) { + fprintf(stderr, "test_mp_fprintf: file content is not equal to test string #%d\n",i); + goto LBL_ERR; + } + } + i++; + /* Clear file content */ + test_file = freopen("ltm_testing_mp_fprintf_88a43603fcfc2f7e7c6646cd4b89180a","w+", test_file); + if (test_file == NULL) { + /* use logfile instead to have at least sth. in case of an error */ + test_file = stdout; + write_only = true; + } + + characters_printed = mp_fprintf(test_file,"START %0#30Mx END\n",p.dp[0]); + slen = strlen(test_strings[i]); + if ((characters_printed - (int)slen) != 0) { + fprintf(stderr, "3 test_mp_fprintf: failed to print o:%zu t:%d\n", slen, characters_printed); + goto LBL_ERR; + } + if (!write_only) { + rewind(test_file); + fgets_return = fgets(line_buffer, LTM_TEST_BUFSIZ, test_file); + if (fgets_return == NULL) { + fprintf(stderr, "test_mp_fprintf: failed to read from file\n"); + goto LBL_ERR; + } + if (strcmp(line_buffer, test_strings[i]) != 0) { + fprintf(stderr, "test_mp_fprintf: file content is not equal to test string #%d\n",i); + goto LBL_ERR; + } + } + + /* It's more or less implementation defined but must be the same. */ + characters_printed = mp_fprintf(stdout,"START %p END\n",&p); + i = fprintf(stdout,"START %p END\n",&p); + if ((characters_printed - i) != 0) { + fprintf(stderr, "test_mp_fprintf: failed to print pointer\n"); + goto LBL_ERR; + } + + characters_printed = mp_fprintf(stdout,"START %n END\n",&n); + if (n != 6) { + fprintf(stderr, "test_mp_fprintf: failed to count 6 characters properly\n"); + goto LBL_ERR; + } + + mp_clear_multi(&p, &q, NULL); + fclose(test_file); + if (remove("ltm_testing_mp_fprintf_88a43603fcfc2f7e7c6646cd4b89180a") != 0) { + fprintf(stderr, "Could not delete file ltm_testing_mp_fprintf_88a43603fcfc2f7e7c6646cd4b89180a\n"); + } + return EXIT_SUCCESS; +LBL_ERR: + mp_clear_multi(&p, &q, NULL); + fclose(test_file); + /* We don't delete the testfile in case of error, conrtent might be helpful. */ + return EXIT_FAILURE; +} +#endif + #ifndef LTM_TEST_DYNAMIC #define ONLY_PUBLIC_API_C #endif @@ -2453,6 +2681,7 @@ static int unit_tests(int argc, char **argv) T1(mp_dr_reduce, MP_DR_REDUCE), T2(mp_pack_unpack,MP_PACK, MP_UNPACK), T2(mp_fread_fwrite, MP_FREAD, MP_FWRITE), + T1(mp_fprintf, S_MP_FPRINTF), T1(mp_get_u32, MP_GET_I32), T1(mp_get_u64, MP_GET_I64), T1(mp_get_ul, MP_GET_L), diff --git a/doc/bn.tex b/doc/bn.tex index 711ad0e5..e89e6256 100644 --- a/doc/bn.tex +++ b/doc/bn.tex @@ -2414,12 +2414,52 @@ \subsection{To ASCII} The result is \emph{always} either exact or too large but it is \emph{never} too small. -If \texttt{MP\_NO\_FILE} is not defined a function to write to a file is also available. +If \texttt{MP\_NO\_FILE} is not defined several functions to write to a file are also available. \index{mp\_fwrite} \begin{alltt} mp_err mp_fwrite(const mp_int *a, int radix, FILE *stream); \end{alltt} +The function \texttt{mp\_fwrite} writes the radix \texttt{radix} representation of \texttt{a} +to the file stream \texttt{stream}. + + +\index{mp\_fprintf} +\begin{alltt} +int mp_fprintf(FILE *stream, const char *format, ...); +\end{alltt} + +\index{mp\_printf} +\begin{alltt} +int mp_fprintf(FILE *stream, const char *format, ...); +\end{alltt} + +The functions \texttt{mp\_fprintf} and \texttt{mp\_printf} behave like \texttt{(f)printf} with +the additional type modifiers \texttt{Z} for a big integer, \texttt{M} for a single limb, and +\texttt{N} for a comma separated list of the raw limb-array of an \texttt{mp\_int} in the order +it comes in. + +Most of the functions of \texttt{printf} are implemented except thousands-separators for big +integers because they are locale dependent and zero-padding for big integers is also missing. + +If there is no floating point available (the check for type \texttt{float} failed) trying to +print one fails silently\footnot{The compiler should have complained in the first place, though.}. + +If there is no type \texttt{long double} available the modifier \texttt{L} will silently +print a \texttt{double} instead. + +If there is no type \texttt{double} available either, the modifier \texttt{L} will silently +print a \texttt{float} instead. + +If there is no type \texttt{double} available when printing without the modifier \texttt{L} +this function will silently print a \texttt{float} instead. + +It is quite useful for debugging to have a binary representation of the big integers and their +innards, so the type modifier \texttt{b} had been added to print all of \texttt{Z, M, N} with +zeros and ones only. + +Printing the big integer in base-64 is done with \texttt{%Z@}. + \subsection{From ASCII} \index{mp\_read\_radix} diff --git a/libtommath_VS2008.vcproj b/libtommath_VS2008.vcproj index 13158a09..72edfc34 100644 --- a/libtommath_VS2008.vcproj +++ b/libtommath_VS2008.vcproj @@ -428,6 +428,10 @@ RelativePath="mp_exteuclid.c" > + + @@ -644,6 +648,10 @@ RelativePath="mp_prime_strong_lucas_selfridge.c" > + + @@ -840,6 +848,10 @@ RelativePath="s_mp_fp_log_d.c" > + + diff --git a/makefile b/makefile index b2cb16a3..202a3377 100644 --- a/makefile +++ b/makefile @@ -29,27 +29,27 @@ LCOV_ARGS=--directory . OBJECTS=mp_2expt.o mp_abs.o mp_add.o mp_add_d.o mp_addmod.o mp_and.o mp_clamp.o mp_clear.o mp_clear_multi.o \ mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count_bits.o mp_cutoffs.o \ mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \ -mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \ -mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_mag_u32.o \ -mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o \ -mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o \ -mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o mp_mod.o mp_mod_2d.o \ -mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o \ -mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \ -mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \ -mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \ -mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \ -mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \ -mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \ -mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o mp_sqrt.o \ -mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \ -mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o s_mp_div_recursive.o \ -s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o s_mp_fp_log_d.o \ -s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \ -s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \ -s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o \ -s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o \ -s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o +mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fprintf.o mp_fread.o \ +mp_from_sbin.o mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o \ +mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o \ +mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o \ +mp_init_u64.o mp_init_ul.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o \ +mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o \ +mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o \ +mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o \ +mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o \ +mp_printf.o mp_radix_size.o mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o \ +mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o \ +mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o \ +mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o \ +mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o \ +mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \ +s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o \ +s_mp_fp_log_d.o s_mp_fprintf.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o \ +s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \ +s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o \ +s_mp_radix_map.o s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \ +s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o #END_INS diff --git a/makefile.mingw b/makefile.mingw index 532747be..363ea643 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -31,27 +31,27 @@ LIBMAIN_D =libtommath.dll OBJECTS=mp_2expt.o mp_abs.o mp_add.o mp_add_d.o mp_addmod.o mp_and.o mp_clamp.o mp_clear.o mp_clear_multi.o \ mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count_bits.o mp_cutoffs.o \ mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \ -mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \ -mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_mag_u32.o \ -mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o \ -mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o \ -mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o mp_mod.o mp_mod_2d.o \ -mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o \ -mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \ -mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \ -mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \ -mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \ -mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \ -mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \ -mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o mp_sqrt.o \ -mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \ -mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o s_mp_div_recursive.o \ -s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o s_mp_fp_log_d.o \ -s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \ -s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \ -s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o \ -s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o \ -s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o +mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fprintf.o mp_fread.o \ +mp_from_sbin.o mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o \ +mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o \ +mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o \ +mp_init_u64.o mp_init_ul.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o \ +mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o \ +mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o \ +mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o \ +mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o \ +mp_printf.o mp_radix_size.o mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o \ +mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o \ +mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o \ +mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o \ +mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o \ +mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \ +s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o \ +s_mp_fp_log_d.o s_mp_fprintf.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o \ +s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \ +s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o \ +s_mp_radix_map.o s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \ +s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o HEADERS_PUB=tommath.h HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB) diff --git a/makefile.msvc b/makefile.msvc index 5d128549..aa9da864 100644 --- a/makefile.msvc +++ b/makefile.msvc @@ -27,27 +27,27 @@ LIBMAIN_D = tommath.dll OBJECTS=mp_2expt.obj mp_abs.obj mp_add.obj mp_add_d.obj mp_addmod.obj mp_and.obj mp_clamp.obj mp_clear.obj mp_clear_multi.obj \ mp_cmp.obj mp_cmp_d.obj mp_cmp_mag.obj mp_cnt_lsb.obj mp_complement.obj mp_copy.obj mp_count_bits.obj mp_cutoffs.obj \ mp_div.obj mp_div_2.obj mp_div_2d.obj mp_div_d.obj mp_dr_is_modulus.obj mp_dr_reduce.obj mp_dr_setup.obj \ -mp_error_to_string.obj mp_exch.obj mp_expt_n.obj mp_exptmod.obj mp_exteuclid.obj mp_fread.obj mp_from_sbin.obj \ -mp_from_ubin.obj mp_fwrite.obj mp_gcd.obj mp_get_double.obj mp_get_i32.obj mp_get_i64.obj mp_get_l.obj mp_get_mag_u32.obj \ -mp_get_mag_u64.obj mp_get_mag_ul.obj mp_grow.obj mp_hash.obj mp_init.obj mp_init_copy.obj mp_init_i32.obj mp_init_i64.obj \ -mp_init_l.obj mp_init_multi.obj mp_init_set.obj mp_init_size.obj mp_init_u32.obj mp_init_u64.obj mp_init_ul.obj \ -mp_invmod.obj mp_is_square.obj mp_kronecker.obj mp_lcm.obj mp_log.obj mp_log_n.obj mp_lshd.obj mp_mod.obj mp_mod_2d.obj \ -mp_montgomery_calc_normalization.obj mp_montgomery_reduce.obj mp_montgomery_setup.obj mp_mul.obj mp_mul_2.obj \ -mp_mul_2d.obj mp_mul_d.obj mp_mulmod.obj mp_neg.obj mp_or.obj mp_pack.obj mp_pack_count.obj mp_prime_fermat.obj \ -mp_prime_frobenius_underwood.obj mp_prime_is_prime.obj mp_prime_miller_rabin.obj mp_prime_next_prime.obj \ -mp_prime_rabin_miller_trials.obj mp_prime_rand.obj mp_prime_strong_lucas_selfridge.obj mp_radix_size.obj \ -mp_radix_size_overestimate.obj mp_rand.obj mp_rand_source.obj mp_read_radix.obj mp_reduce.obj mp_reduce_2k.obj \ -mp_reduce_2k_l.obj mp_reduce_2k_setup.obj mp_reduce_2k_setup_l.obj mp_reduce_is_2k.obj mp_reduce_is_2k_l.obj \ -mp_reduce_setup.obj mp_root_n.obj mp_rshd.obj mp_sbin_size.obj mp_set.obj mp_set_double.obj mp_set_i32.obj mp_set_i64.obj \ -mp_set_l.obj mp_set_u32.obj mp_set_u64.obj mp_set_ul.obj mp_shrink.obj mp_signed_rsh.obj mp_sqrmod.obj mp_sqrt.obj \ -mp_sqrtmod_prime.obj mp_sub.obj mp_sub_d.obj mp_submod.obj mp_to_radix.obj mp_to_sbin.obj mp_to_ubin.obj mp_ubin_size.obj \ -mp_unpack.obj mp_xor.obj mp_zero.obj s_mp_add.obj s_mp_copy_digs.obj s_mp_div_3.obj s_mp_div_recursive.obj \ -s_mp_div_school.obj s_mp_div_small.obj s_mp_exptmod.obj s_mp_exptmod_fast.obj s_mp_fp_log.obj s_mp_fp_log_d.obj \ -s_mp_get_bit.obj s_mp_invmod.obj s_mp_invmod_odd.obj s_mp_log_2expt.obj s_mp_montgomery_reduce_comba.obj s_mp_mul.obj \ -s_mp_mul_balance.obj s_mp_mul_comba.obj s_mp_mul_high.obj s_mp_mul_high_comba.obj s_mp_mul_karatsuba.obj \ -s_mp_mul_toom.obj s_mp_prime_is_divisible.obj s_mp_prime_tab.obj s_mp_radix_map.obj \ -s_mp_radix_size_overestimate.obj s_mp_rand_platform.obj s_mp_sqr.obj s_mp_sqr_comba.obj s_mp_sqr_karatsuba.obj \ -s_mp_sqr_toom.obj s_mp_sub.obj s_mp_zero_buf.obj s_mp_zero_digs.obj +mp_error_to_string.obj mp_exch.obj mp_expt_n.obj mp_exptmod.obj mp_exteuclid.obj mp_fprintf.obj mp_fread.obj \ +mp_from_sbin.obj mp_from_ubin.obj mp_fwrite.obj mp_gcd.obj mp_get_double.obj mp_get_i32.obj mp_get_i64.obj mp_get_l.obj \ +mp_get_mag_u32.obj mp_get_mag_u64.obj mp_get_mag_ul.obj mp_grow.obj mp_hash.obj mp_init.obj mp_init_copy.obj \ +mp_init_i32.obj mp_init_i64.obj mp_init_l.obj mp_init_multi.obj mp_init_set.obj mp_init_size.obj mp_init_u32.obj \ +mp_init_u64.obj mp_init_ul.obj mp_invmod.obj mp_is_square.obj mp_kronecker.obj mp_lcm.obj mp_log.obj mp_log_n.obj mp_lshd.obj \ +mp_mod.obj mp_mod_2d.obj mp_montgomery_calc_normalization.obj mp_montgomery_reduce.obj mp_montgomery_setup.obj \ +mp_mul.obj mp_mul_2.obj mp_mul_2d.obj mp_mul_d.obj mp_mulmod.obj mp_neg.obj mp_or.obj mp_pack.obj mp_pack_count.obj \ +mp_prime_fermat.obj mp_prime_frobenius_underwood.obj mp_prime_is_prime.obj mp_prime_miller_rabin.obj \ +mp_prime_next_prime.obj mp_prime_rabin_miller_trials.obj mp_prime_rand.obj mp_prime_strong_lucas_selfridge.obj \ +mp_printf.obj mp_radix_size.obj mp_radix_size_overestimate.obj mp_rand.obj mp_rand_source.obj mp_read_radix.obj \ +mp_reduce.obj mp_reduce_2k.obj mp_reduce_2k_l.obj mp_reduce_2k_setup.obj mp_reduce_2k_setup_l.obj mp_reduce_is_2k.obj \ +mp_reduce_is_2k_l.obj mp_reduce_setup.obj mp_root_n.obj mp_rshd.obj mp_sbin_size.obj mp_set.obj mp_set_double.obj \ +mp_set_i32.obj mp_set_i64.obj mp_set_l.obj mp_set_u32.obj mp_set_u64.obj mp_set_ul.obj mp_shrink.obj mp_signed_rsh.obj \ +mp_sqrmod.obj mp_sqrt.obj mp_sqrtmod_prime.obj mp_sub.obj mp_sub_d.obj mp_submod.obj mp_to_radix.obj mp_to_sbin.obj \ +mp_to_ubin.obj mp_ubin_size.obj mp_unpack.obj mp_xor.obj mp_zero.obj s_mp_add.obj s_mp_copy_digs.obj s_mp_div_3.obj \ +s_mp_div_recursive.obj s_mp_div_school.obj s_mp_div_small.obj s_mp_exptmod.obj s_mp_exptmod_fast.obj s_mp_fp_log.obj \ +s_mp_fp_log_d.obj s_mp_fprintf.obj s_mp_get_bit.obj s_mp_invmod.obj s_mp_invmod_odd.obj s_mp_log_2expt.obj \ +s_mp_montgomery_reduce_comba.obj s_mp_mul.obj s_mp_mul_balance.obj s_mp_mul_comba.obj s_mp_mul_high.obj \ +s_mp_mul_high_comba.obj s_mp_mul_karatsuba.obj s_mp_mul_toom.obj s_mp_prime_is_divisible.obj s_mp_prime_tab.obj \ +s_mp_radix_map.obj s_mp_radix_size_overestimate.obj s_mp_rand_platform.obj s_mp_sqr.obj s_mp_sqr_comba.obj \ +s_mp_sqr_karatsuba.obj s_mp_sqr_toom.obj s_mp_sub.obj s_mp_zero_buf.obj s_mp_zero_digs.obj HEADERS_PUB=tommath.h HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB) diff --git a/makefile.shared b/makefile.shared index fe077fc8..3cba5bda 100644 --- a/makefile.shared +++ b/makefile.shared @@ -26,27 +26,27 @@ LCOV_ARGS=--directory .libs --directory . OBJECTS=mp_2expt.o mp_abs.o mp_add.o mp_add_d.o mp_addmod.o mp_and.o mp_clamp.o mp_clear.o mp_clear_multi.o \ mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count_bits.o mp_cutoffs.o \ mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \ -mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \ -mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_mag_u32.o \ -mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o \ -mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o \ -mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o mp_mod.o mp_mod_2d.o \ -mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o \ -mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \ -mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \ -mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \ -mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \ -mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \ -mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \ -mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o mp_sqrt.o \ -mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \ -mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o s_mp_div_recursive.o \ -s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o s_mp_fp_log_d.o \ -s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \ -s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \ -s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o \ -s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o \ -s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o +mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fprintf.o mp_fread.o \ +mp_from_sbin.o mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o \ +mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o \ +mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o \ +mp_init_u64.o mp_init_ul.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o \ +mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o \ +mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o \ +mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o \ +mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o \ +mp_printf.o mp_radix_size.o mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o \ +mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o \ +mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o \ +mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o \ +mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o \ +mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \ +s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o \ +s_mp_fp_log_d.o s_mp_fprintf.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o \ +s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \ +s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o \ +s_mp_radix_map.o s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \ +s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o #END_INS diff --git a/makefile.unix b/makefile.unix index 9fe939f0..cbe6fa29 100644 --- a/makefile.unix +++ b/makefile.unix @@ -32,27 +32,27 @@ LIBMAIN_S = libtommath.a OBJECTS=mp_2expt.o mp_abs.o mp_add.o mp_add_d.o mp_addmod.o mp_and.o mp_clamp.o mp_clear.o mp_clear_multi.o \ mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count_bits.o mp_cutoffs.o \ mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \ -mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \ -mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_mag_u32.o \ -mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o \ -mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o \ -mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o mp_mod.o mp_mod_2d.o \ -mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o \ -mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \ -mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \ -mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \ -mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \ -mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \ -mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \ -mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o mp_sqrt.o \ -mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \ -mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o s_mp_div_recursive.o \ -s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o s_mp_fp_log_d.o \ -s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \ -s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \ -s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o \ -s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o \ -s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o +mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fprintf.o mp_fread.o \ +mp_from_sbin.o mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o \ +mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o \ +mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o \ +mp_init_u64.o mp_init_ul.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o \ +mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o \ +mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o \ +mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o \ +mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o \ +mp_printf.o mp_radix_size.o mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o \ +mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o \ +mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o \ +mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o \ +mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o \ +mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \ +s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o \ +s_mp_fp_log_d.o s_mp_fprintf.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o \ +s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \ +s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o \ +s_mp_radix_map.o s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \ +s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o HEADERS_PUB=tommath.h diff --git a/mp_fprintf.c b/mp_fprintf.c new file mode 100644 index 00000000..700414f9 --- /dev/null +++ b/mp_fprintf.c @@ -0,0 +1,21 @@ +#include "tommath_private.h" +#ifdef MP_FPRINTF_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis */ +/* SPDX-License-Identifier: Unlicense */ + +#ifndef MP_NO_FILE +#include +int mp_fprintf(FILE *stream, const char *format, ...) +{ + int written = 0; + + va_list args; + va_start(args, format); + written = s_mp_fprintf(stream, format, args); + va_end(args); + + return written; + +} +#endif +#endif diff --git a/mp_printf.c b/mp_printf.c new file mode 100644 index 00000000..7e7200fd --- /dev/null +++ b/mp_printf.c @@ -0,0 +1,20 @@ +#include "tommath_private.h" +#ifdef MP_PRINTF_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis */ +/* SPDX-License-Identifier: Unlicense */ + +#ifndef MP_NO_FILE +#include +int mp_printf(const char *format, ...) +{ + int written = 0; + + va_list args; + va_start(args, format); + written = s_mp_fprintf(stdout, format, args); + va_end(args); + + return written; +} +#endif +#endif diff --git a/s_mp_fprintf.c b/s_mp_fprintf.c new file mode 100644 index 00000000..227d832c --- /dev/null +++ b/s_mp_fprintf.c @@ -0,0 +1,507 @@ +#include "tommath_private.h" +#ifdef S_MP_FPRINTF_C +/* LibTomMath, multiple-precision integer library -- Tom St Denis */ +/* SPDX-License-Identifier: Unlicense */ + +#ifndef MP_NO_FILE +#include +#include +#include + + +/* Step to the next character, throw error if there is none */ +#define LTM_NEXT_ERROR(x) do{(x)++;if(*(x) == '\0'){goto LTM_ERR;}}while(0) +/* Step to the next character, got to end if there is none */ +#define LTM_NEXT(x) do{(x)++;if(*(x) == '\0')break;}while(0) + +/* The size of the string "%..." is not very large */ +#define LTM_PRINTF_VARIABLE_BUFSIZ 32 + +static void s_mp_str_reverse(char *s, int len) +{ + int x = 0, y = len - 1; + char t; + + while (x < y) { + t = s[x]; + s[x] = s[y]; + s[y] = t; + x++; + y--; + } +} + +static int s_mp_print_mp_digit_binary(mp_digit number, bool prefix, char *buffer) +{ + mp_digit cp, digit; + int i = 0; + + cp = number; + while (cp != 0) { + digit = cp % 2; + cp /= 2; + buffer[i++] = (digit == 1) ? '1' : '0'; + } + + if (prefix) { + buffer[i++] = 'b'; + buffer[i++] = '0'; + } + + s_mp_str_reverse(buffer, i); + return i; +} + +static int s_mp_print_bigint(const mp_int *N, const char *format, int base, bool prefix, FILE *stream) +{ + mp_err err; + char *buf, *start_buf; + size_t size, written; + int chars_printed = 0; + mp_sign sign = MP_ZPOS; + mp_int _N; + + if ((err = mp_radix_size_overestimate(N, base, &size)) != MP_OKAY) { + return -1; + } + + if (prefix) { + size += 3; + } + + if ((err = mp_init_copy(&_N, N)) != MP_OKAY) { + return -1; + } + + if (mp_isneg(N)) { + _N.sign = MP_ZPOS; + sign = MP_NEG; + } + + buf = MP_MALLOC(size); + if (buf == NULL) { + goto LTM_ERR; + } + + start_buf = buf; + + if (sign == MP_NEG) { + *buf++ = '-'; + } + + /* TODO: upper case/lower case? But that means a rewrite of mp_to_radix() */ + if (prefix) { + *buf++ = '0'; + switch (base) { + case 2: + *buf++ = 'b'; + break; + case 8: + *buf++ = 'o'; + break; + case 16: + *buf++ = 'x'; + break; + } + } + + if ((err = mp_to_radix(&_N, buf, size, &written, base)) == MP_OKAY) { + written--; + } else { + MP_FREE(start_buf, size); + goto LTM_ERR; + } + + chars_printed = fprintf(stream, format, start_buf); + + MP_FREE(start_buf, size); + mp_clear(&_N); + return chars_printed; +LTM_ERR: + mp_clear(&_N); + return -1; +} + +/* Largest mp_digit has 64 bit but only 60 are used, so 65 seem to be a safe value here. */ +#define LTM_BASE2_BUFSIZ 65 +static int s_mp_print_limb(const mp_digit d, const char *format, int base, bool prefix, FILE *stream) +{ + char format_buf[LTM_PRINTF_VARIABLE_BUFSIZ] = {0}; + char base2_buffer[LTM_BASE2_BUFSIZ] = {0}; + char *f; + size_t slen; + + f = &format_buf[0]; + + /* assuming conversion character to be the last */ + slen = strlen(format); + + /* strlen("llu") = 3 plus the trailing '\0' makes four */ + if (slen >= (LTM_PRINTF_VARIABLE_BUFSIZ - 5)) { + return -1; + } + /* For some reason clang complains when strncat is used */ + f = strcat(f, format); + f[slen-1] = '\0'; + + if (base == 2) { + /* length not used here, fprintf(3) takes care of that */ + (void)s_mp_print_mp_digit_binary(d, prefix, &base2_buffer[0]); + f = strcat(f, "s"); + return fprintf(stream, f, base2_buffer); + } else { +#if defined(MP_16BIT) + switch (base) { + case 8: + f = strcat(f, PRIo16); + break; + case 10: + f = strcat(f, PRIu16); + break; + case 16: + f = strcat(f, PRIx16); + break; + } +#elif defined(MP_64BIT) + switch (base) { + case 8: +/* +its defined in the local inttype.h as +# if __WORDSIZE == 64 +# define __PRI64_PREFIX "l" +# define __PRIPTR_PREFIX "l" +# else +# define __PRI64_PREFIX "ll" +# define __PRIPTR_PREFIX +# endif + + ... + +# define PRIo64 __PRI64_PREFIX "o" + +*/ + f = strcat(f, PRIo64); + break; + case 10: + f = strcat(f, PRIu64); + break; + case 16: + f = strcat(f, PRIx64); + break; + } +#else + switch (base) { + case 8: + f = strcat(f, PRIo32); + break; + case 10: + f = strcat(f, PRIu32); + break; + case 16: + f = strcat(f, PRIx32); + break; + } +#endif + } + return fprintf(stream, f, d); +} + + +/* format is for the individual limb */ +static int s_mp_print_limb_array(mp_int *n, const char *format, int base, bool prefix, FILE *stream) +{ + int i; + int chars_printed = 0; + + for (i = 0; i < n->used; i++) { + chars_printed += s_mp_print_limb(n->dp[i], format, base, prefix, stream); + if (i < (n->used - 1)) { + fputc(',', stream); + chars_printed++; + } + } + + return chars_printed; +} + +int s_mp_fprintf(FILE *stream, const char *format, va_list args) +{ + int printed_characters = 0; + /* TODO: enum? preprocessor?*/ + bool is_extra_short = false; + bool is_short = false; + bool is_long = false; + bool is_long_long = false; + + int modifier = 0; + bool print_prefix = false; + int base; + + char format_out[LTM_PRINTF_VARIABLE_BUFSIZ] = {0}; + int format_out_index = 0; + const char *conversion_modifiers = "aAbcdeEfFgGimnopsuxX@"; + + /* Assuming ASCII input and a properly terminated string at "format" */ + while (*format != '\0') { + if (*format == '%') { + /* TODO: use s_mp_zero_buf(void *mem, size_t size) in production */ + s_mp_zero_buf(format_out, (size_t)LTM_PRINTF_VARIABLE_BUFSIZ); + format_out_index = 0; + modifier = 0; + is_extra_short = false; + is_short = false; + is_long = false; + is_long_long = false; + print_prefix = false; + + format_out[format_out_index++] = *format; + /* Probably the most infamous last words: "Can't happen!" */ + if (format_out_index >= LTM_PRINTF_VARIABLE_BUFSIZ) { + return -1; + } + LTM_NEXT_ERROR(format); + /* Keeping it simple */ + if (*format == '%') { + fputc('%', stream); + printed_characters++; + break; + } + while (strchr(conversion_modifiers, *format) == NULL) { + switch (*format) { + case 'h': + if (!is_short) { + is_short = true; + } else { + is_short = false; + is_extra_short = true; + } + modifier = 'h'; + break; + case 'l': + if (!is_long) { + is_long = true; + } else { + is_long = false; + is_long_long = true; + } + modifier = 'l'; + break; + case '#': + print_prefix = true; + break; + case 'j': + case 't': + case 'z': + case 'Z': + case 'N': + case 'M': + modifier = *format; + break; + } + format_out[format_out_index++] = *format; + if (format_out_index >= LTM_PRINTF_VARIABLE_BUFSIZ) { + return -1; + } + LTM_NEXT_ERROR(format); + } + + if (strchr(conversion_modifiers, *format) != NULL) { + format_out[format_out_index++] = *format; + if (format_out_index >= LTM_PRINTF_VARIABLE_BUFSIZ) { + return -1; + } + switch (*format) { + /* TODO: Ii _is_ expensive without hardware support. Offer manual switch-off? */ +#ifdef LTM_HAVE_FLOAT_TYPE + case 'a': + case 'A': + case 'f': + case 'F': + case 'g': + case 'G': + case 'e': + case 'E': +#ifndef LTM_HAVE_DOUBLE_TYPE + printed_characters += fprintf(stream, format_out, va_arg(args, float)); +#else + if (modifier == 'L') { + /* TODO: make a note in the docs! */ +#ifdef LTM_HAVE_LONG_DOUBLE_TYPE + printed_characters += fprintf(stream, format_out, va_arg(args, long double)); +#elif (defined LTM_HAVE_DOUBLE_TYPE) + printed_characters += fprintf(stream, format_out, va_arg(args, double)); +#else + printed_characters += fprintf(stream, format_out, va_arg(args, float)); +#endif /* LTM_HAVE_LONG_DOUBLE_TYPE */ + } else { +#ifdef LTM_HAVE_DOUBLE_TYPE + printed_characters += fprintf(stream, format_out, va_arg(args, double)); +#else + printed_characters += fprintf(stream, format_out, va_arg(args, float)); +#endif /* LTM_HAVE_DOUBLE_TYPE */ + } +#endif /* LTM_HAVE_DOUBLE_TYPE */ + break; +#endif /* LTM_HAVE_FLOAT_TYPE */ + case 'd': + case 'i': + if (modifier != 0) { + switch (modifier) { + case 'h': + if (is_extra_short) { + printed_characters += fprintf(stream, format_out, (signed char)va_arg(args, int)); + } else { + printed_characters += fprintf(stream, format_out, (short)va_arg(args, int)); + } + break; + case 'l': + if (is_long_long) { + printed_characters += fprintf(stream, format_out, va_arg(args, long long)); + } else { + printed_characters += fprintf(stream, format_out, va_arg(args, long)); + } + break; + case 'j': + printed_characters += fprintf(stream, format_out, va_arg(args, intmax_t)); + break; + case 't': + printed_characters += fprintf(stream, format_out, va_arg(args, ptrdiff_t)); + break; + /* Beware: 'Z' (ASCII 0x5a) is an old version of 'z' (ASCII 0x7a)! */ + case 'Z': + format_out[format_out_index - 2] = 's'; + format_out[format_out_index - 1] = '\0'; + printed_characters += s_mp_print_bigint(va_arg(args, mp_int *), format_out, 10, false, stream); + break; + /* It seems a bit brutal, but the limbs _are_ unsigned. */ + case 'M': + case 'N': + return -1; + } + } else { + printed_characters += fprintf(stream, format_out, va_arg(args, int)); + } + break; + case 'B': + case 'b': + if (modifier == 'Z') { + format_out[format_out_index - 2] = 's'; + format_out[format_out_index - 1] = '\0'; + printed_characters += s_mp_print_bigint(va_arg(args, mp_int *), format_out, 2, print_prefix, stream); + } else if (modifier == 'M') { + format_out[format_out_index - 2] = *format; + format_out[format_out_index - 1] = '\0'; +#ifdef MP_16BIT + printed_characters += s_mp_print_limb((mp_digit)va_arg(args, unsigned int), format_out, 2, print_prefix, stream); +#else + printed_characters += s_mp_print_limb(va_arg(args, mp_digit), format_out, 2, print_prefix, stream); +#endif + } else if (modifier == 'N') { + format_out[format_out_index - 2] = *format; + format_out[format_out_index - 1] = '\0'; + printed_characters += s_mp_print_limb_array(va_arg(args, mp_int *), format_out, 2, print_prefix, stream); + } else { + /* + For big integer related numbers only, but feel free to add the rest, + it is not _that_ complicated, just tedious. + Use a bigint in the meantime, or a mp_digit ("%Mb") if its size and unsignedness + is not a problem. + */ + /* s_mp_print_integer_binary(, MP_SIGNED, print_prefix, uppercase, &buffer); */ + return -1; + } + break; + case 'o': + case 'u': + case 'x': + case 'X': + if (modifier != 0) { + if (*format == 'o') { + base = 8; + } else if ((*format == 'x') || (*format == 'X')) { + base = 16; + } else { + base = 10; + } + /* TODO: this is basically a copy of the signed version */ + switch (modifier) { + case 'h': + if (is_extra_short) { + printed_characters += fprintf(stream, format_out, (unsigned char)va_arg(args, int)); + } else { + printed_characters += fprintf(stream, format_out, (unsigned short)va_arg(args, int)); + } + break; + case 'l': + if (is_long_long) { + printed_characters += fprintf(stream, format_out, va_arg(args, unsigned long long)); + } else { + printed_characters += fprintf(stream, format_out, va_arg(args, unsigned long)); + } + break; + case 'z': + printed_characters += fprintf(stream, format_out, va_arg(args, size_t)); + break; + case 'j': + printed_characters += fprintf(stream, format_out, va_arg(args, uintmax_t)); + break; + /** If you actually have an unsigned version: please send the authors a short note + case 't': printed_characters += fprintf(stream, format_out, va_arg(args, ptrdiff_t)); + break; + */ + case 'Z': + format_out[format_out_index - 2] = 's'; + format_out[format_out_index - 1] = '\0'; + printed_characters += s_mp_print_bigint(va_arg(args, mp_int *), format_out, base, print_prefix, stream); + break; + case 'M': + format_out[format_out_index - 2] = *format; + format_out[format_out_index - 1] = '\0'; +#ifdef MP_16BIT + printed_characters += s_mp_print_limb((mp_digit)va_arg(args, unsigned int), format_out, base, print_prefix, stream); +#else + printed_characters += s_mp_print_limb(va_arg(args, mp_digit), format_out, base, print_prefix, stream); +#endif + break; + case 'N': + format_out[format_out_index - 2] = *format; + format_out[format_out_index - 1] = '\0'; + printed_characters += s_mp_print_limb_array(va_arg(args, mp_int *), format_out, base, print_prefix, stream); + break; + + } + } else { + printed_characters += fprintf(stream, format_out, va_arg(args, unsigned int)); + } + break; + case '@': + if (modifier == 'Z') { + format_out[format_out_index - 2] = 's'; + format_out[format_out_index - 1] = '\0'; + printed_characters += s_mp_print_bigint(va_arg(args, mp_int *), format_out, 64, false, stream); + } else { + /* Just assume it is an actual @, to be printed verbatim */ + fputc(*format, stream); + printed_characters++; + } + break; + case 'p': + printed_characters += fprintf(stream, format_out, va_arg(args, void *)); + break; + case 'n': + *va_arg(args, int *) = printed_characters; + break; + } + } + } else { + fputc(*format, stream); + printed_characters++; + } + LTM_NEXT(format); + } + return printed_characters; +LTM_ERR: + return -1; +} +#endif /* MP_NO_FILE */ +#endif diff --git a/sources.cmake b/sources.cmake index bbb2aeab..43acf0bb 100644 --- a/sources.cmake +++ b/sources.cmake @@ -31,6 +31,7 @@ mp_exch.c mp_expt_n.c mp_exptmod.c mp_exteuclid.c +mp_fprintf.c mp_fread.c mp_from_sbin.c mp_from_ubin.c @@ -85,6 +86,7 @@ mp_prime_next_prime.c mp_prime_rabin_miller_trials.c mp_prime_rand.c mp_prime_strong_lucas_selfridge.c +mp_printf.c mp_radix_size.c mp_radix_size_overestimate.c mp_rand.c @@ -134,6 +136,7 @@ s_mp_exptmod.c s_mp_exptmod_fast.c s_mp_fp_log.c s_mp_fp_log_d.c +s_mp_fprintf.c s_mp_get_bit.c s_mp_invmod.c s_mp_invmod_odd.c diff --git a/tommath.def b/tommath.def index 86f34872..7415912c 100644 --- a/tommath.def +++ b/tommath.def @@ -34,6 +34,7 @@ EXPORTS mp_expt_n mp_exptmod mp_exteuclid + mp_fprintf mp_fread mp_from_sbin mp_from_ubin @@ -88,6 +89,7 @@ EXPORTS mp_prime_rabin_miller_trials mp_prime_rand mp_prime_strong_lucas_selfridge + mp_printf mp_radix_size mp_radix_size_overestimate mp_rand diff --git a/tommath.h b/tommath.h index 7994b6e1..f0461116 100644 --- a/tommath.h +++ b/tommath.h @@ -585,6 +585,8 @@ mp_err mp_radix_size_overestimate(const mp_int *a, const int radix, size_t *size #ifndef MP_NO_FILE mp_err mp_fread(mp_int *a, int radix, FILE *stream) MP_WUR; mp_err mp_fwrite(const mp_int *a, int radix, FILE *stream) MP_WUR; +int mp_fprintf(FILE *stream, const char *format, ...); +int mp_printf(const char *format, ...); #endif #define mp_to_binary(M, S, N) mp_to_radix((M), (S), (N), NULL, 2) diff --git a/tommath_class.h b/tommath_class.h index e08bc5f3..28a306fc 100644 --- a/tommath_class.h +++ b/tommath_class.h @@ -40,6 +40,7 @@ # define MP_EXPT_N_C # define MP_EXPTMOD_C # define MP_EXTEUCLID_C +# define MP_FPRINTF_C # define MP_FREAD_C # define MP_FROM_SBIN_C # define MP_FROM_UBIN_C @@ -94,6 +95,7 @@ # define MP_PRIME_RABIN_MILLER_TRIALS_C # define MP_PRIME_RAND_C # define MP_PRIME_STRONG_LUCAS_SELFRIDGE_C +# define MP_PRINTF_C # define MP_RADIX_SIZE_C # define MP_RADIX_SIZE_OVERESTIMATE_C # define MP_RAND_C @@ -143,6 +145,7 @@ # define S_MP_EXPTMOD_FAST_C # define S_MP_FP_LOG_C # define S_MP_FP_LOG_D_C +# define S_MP_FPRINTF_C # define S_MP_GET_BIT_C # define S_MP_INVMOD_C # define S_MP_INVMOD_ODD_C @@ -325,6 +328,10 @@ # define MP_SUB_C #endif +#if defined(MP_FPRINTF_C) +# define S_MP_FPRINTF_C +#endif + #if defined(MP_FREAD_C) # define MP_ADD_D_C # define MP_MUL_D_C @@ -714,6 +721,10 @@ # define S_MP_GET_BIT_C #endif +#if defined(MP_PRINTF_C) +# define S_MP_FPRINTF_C +#endif + #if defined(MP_RADIX_SIZE_C) # define MP_LOG_N_C #endif @@ -1095,6 +1106,19 @@ # define S_MP_FP_LOG_FRACTION_D_C #endif +#if defined(S_MP_FPRINTF_C) +# define MP_CLEAR_C +# define MP_INIT_COPY_C +# define MP_RADIX_SIZE_OVERESTIMATE_C +# define MP_TO_RADIX_C +# define S_MP_PRINT_BIGINT_C +# define S_MP_PRINT_LIMB_ARRAY_C +# define S_MP_PRINT_LIMB_C +# define S_MP_PRINT_MP_DIGIT_BINARY_C +# define S_MP_STR_REVERSE_C +# define S_MP_ZERO_BUF_C +#endif + #if defined(S_MP_GET_BIT_C) #endif diff --git a/tommath_private.h b/tommath_private.h index d88d263f..4197981e 100644 --- a/tommath_private.h +++ b/tommath_private.h @@ -229,8 +229,9 @@ MP_PRIVATE mp_err s_mp_radix_size_overestimate(const mp_int *a, const int radix, MP_PRIVATE mp_err s_mp_fp_log(const mp_int *a, mp_int *c) MP_WUR; MP_PRIVATE mp_err s_mp_fp_log_d(const mp_int *a, mp_word *c) MP_WUR; - - +#ifndef MP_NO_FILE +MP_PRIVATE int s_mp_fprintf(FILE *stream, const char *format, va_list args); +#endif #define MP_RADIX_MAP_REVERSE_SIZE 80u extern MP_PRIVATE const char s_mp_radix_map[];