diff --git a/generate_def.sh b/generate_def.sh new file mode 100755 index 000000000..fc8f2fb65 --- /dev/null +++ b/generate_def.sh @@ -0,0 +1,9 @@ +echo "; libtommath" >tommath.def +echo ";" >>tommath.def +echo "; Use this command to produce a 32-bit .lib file, for use in any MSVC version" >>tommath.def +echo "; lib -machine:X86 -name:libtommath.dll -def:tommath.def -out:tommath.lib" >>tommath.def +echo "; Use this command to produce a 64-bit .lib file, for use in any MSVC version" >>tommath.def +echo "; lib -machine:X64 -name:libtommath.dll -def:tommath.def -out:tommath.lib" >>tommath.def +echo ";" >>tommath.def +echo "EXPORTS" >>tommath.def +git ls-files|grep \\.c|sed -e 's/bn_mp_rand/bn_mp_rand\nbn_mp_rand_digit/'|sed -e 's/bn_conversion/bn_mp_set_i32\nbn_mp_set_i64\nbn_mp_set_u32\nbn_mp_set_u64\nbn_mp_set_int\nbn_mp_set_long\nbn_mp_set_long_long\nbn_mp_get_i32\nbn_mp_get_i64\nbn_mp_get_mag32\nbn_mp_get_mag64\nbn_mp_get_int\nbn_mp_get_long\nbn_mp_get_long_long\nbn_mp_init_i32\nbn_mp_init_i64\nbn_mp_init_u32\nbn_mp_init_u64\nbn_mp_init_set_int/'|grep -v bn_mp_radix_smap|grep bn_mp_|sort|sed -e 's/bn_/ /g'|sed -e 's/\.c//g'>>tommath.def diff --git a/helper.pl b/helper.pl index 27e145121..e0baeb064 100755 --- a/helper.pl +++ b/helper.pl @@ -436,6 +436,10 @@ sub update_dep return 0; } +sub generate_def { + system("sh", "generate_def.sh"); +} + sub die_usage { die <<"MARKER"; usage: $0 -s OR $0 --check-source @@ -462,6 +466,7 @@ sub die_usage { $failure ||= process_makefiles(0) if $check_all || $check_makefiles; $failure ||= process_makefiles(1) if $update_makefiles; $failure ||= update_dep() if $update_makefiles; +$failure ||= generate_def() if $update_makefiles; die_usage unless defined $failure; exit $failure ? 1 : 0; diff --git a/makefile.mingw b/makefile.mingw index 05bae1fc5..f46f9301c 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -21,7 +21,7 @@ LDFLAGS = #Compilation flags LTM_CFLAGS = -I. $(CFLAGS) -LTM_LDFLAGS = $(LDFLAGS) +LTM_LDFLAGS = $(LDFLAGS) -static-libgcc #Libraries to be created LIBMAIN_S =libtommath.a diff --git a/tommath.def b/tommath.def new file mode 100755 index 000000000..8258c6516 --- /dev/null +++ b/tommath.def @@ -0,0 +1,136 @@ +; libtommath +; +; Use this command to produce a 32-bit .lib file, for use in any MSVC version +; lib -machine:X86 -name:libtommath.dll -def:tommath.def -out:tommath.lib +; Use this command to produce a 64-bit .lib file, for use in any MSVC version +; lib -machine:X64 -name:libtommath.dll -def:tommath.def -out:tommath.lib +; +EXPORTS + mp_2expt + mp_abs + mp_add + mp_add_d + mp_addmod + mp_and + mp_clamp + mp_clear + mp_clear_multi + mp_cmp + mp_cmp_d + mp_cmp_mag + mp_cnt_lsb + mp_complement + mp_copy + mp_count_bits + mp_decr + mp_div_2 + mp_div_2d + mp_div_3 + mp_div + mp_div_d + mp_dr_is_modulus + mp_dr_reduce + mp_dr_setup + mp_error_to_string + mp_exch + mp_export + mp_expt_d + mp_exptmod + mp_exteuclid + mp_fread + mp_fwrite + mp_gcd + mp_get_double + mp_get_i32 + mp_get_i64 + mp_get_int + mp_get_long + mp_get_long_long + mp_get_mag32 + mp_get_mag64 + mp_grow + mp_ilogb + mp_import + mp_incr + mp_init + mp_init_copy + mp_init_i32 + mp_init_i64 + mp_init_multi + mp_init_set + mp_init_set_int + mp_init_size + mp_init_u32 + mp_init_u64 + mp_invmod + mp_iseven + mp_isodd + mp_is_square + mp_kronecker + mp_lcm + mp_lshd + mp_mod_2d + mp_mod + mp_mod_d + mp_montgomery_calc_normalization + mp_montgomery_reduce + mp_montgomery_setup + mp_mul_2 + mp_mul_2d + mp_mul + mp_mul_d + mp_mulmod + mp_neg + mp_n_root + mp_or + mp_prime_fermat + mp_prime_frobenius_underwood + mp_prime_is_prime + mp_prime_miller_rabin + mp_prime_next_prime + mp_prime_rabin_miller_trials + mp_prime_rand + mp_prime_strong_lucas_selfridge + mp_radix_size + mp_rand + mp_rand_digit + mp_read_radix + mp_read_signed_bin + mp_read_unsigned_bin + mp_reduce_2k + mp_reduce_2k_l + mp_reduce_2k_setup + mp_reduce_2k_setup_l + mp_reduce + mp_reduce_is_2k + mp_reduce_is_2k_l + mp_reduce_setup + mp_rshd + mp_set + mp_set_double + mp_set_i32 + mp_set_i64 + mp_set_int + mp_set_long + mp_set_long_long + mp_set_u32 + mp_set_u64 + mp_shrink + mp_signed_bin_size + mp_signed_rsh + mp_sqr + mp_sqrmod + mp_sqrt + mp_sqrtmod_prime + mp_sub + mp_sub_d + mp_submod + mp_toradix + mp_toradix_n + mp_to_signed_bin + mp_to_signed_bin_n + mp_to_unsigned_bin + mp_to_unsigned_bin_n + mp_unsigned_bin_size + mp_xor + mp_zero diff --git a/tommath.h b/tommath.h index 4fdbd609f..41e93ec46 100644 --- a/tommath.h +++ b/tommath.h @@ -21,7 +21,7 @@ extern "C" { #endif /* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */ -#if defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__) +#if (defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)) && !defined(MP_64BIT) # define MP_32BIT #endif @@ -32,7 +32,7 @@ extern "C" { defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \ defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \ defined(__LP64__) || defined(_LP64) || defined(__64BIT__) -# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) +# if !(defined(MP_64BIT) || defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) # if defined(__GNUC__) && !defined(__hppa) /* we support 128bit integers only via: __attribute__((mode(TI))) */ # define MP_64BIT @@ -67,7 +67,9 @@ typedef uint32_t private_mp_word; #elif defined(MP_64BIT) /* for GCC only on supported platforms */ typedef uint64_t mp_digit; +#if defined(__GNUC__) typedef unsigned long private_mp_word __attribute__((mode(TI))); +#endif # define MP_DIGIT_BIT 60 #else typedef uint32_t mp_digit;