Skip to content

Commit fbc0829

Browse files
committed
Better interoperability between MSVC and mingw-w64, 2
1 parent 3d51fe1 commit fbc0829

File tree

4 files changed

+147
-3
lines changed

4 files changed

+147
-3
lines changed

generate_def.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
echo "; libtommath" >tommath.def
2+
echo ";" >>tommath.def
3+
echo "; Use this command to produce a 32-bit .lib file, for use in any MSVC version" >>tommath.def
4+
echo "; lib -machine:X86 -name:libtommath.dll -def:tommath.def -out:tommath.lib" >>tommath.def
5+
echo "; Use this command to produce a 64-bit .lib file, for use in any MSVC version" >>tommath.def
6+
echo "; lib -machine:X64 -name:libtommath.dll -def:tommath.def -out:tommath.lib" >>tommath.def
7+
echo ";" >>tommath.def
8+
echo "EXPORTS" >>tommath.def
9+
git ls-files|grep bn_mp_|grep \\.c|grep -v 'mp_toom'|grep -v 'mp_kara'|grep -v '_fast'|grep -v '_slow'|grep -v '_smap'|sed -e 's/bn_mp_rand/bn_mp_rand\nbn_mp_rand_digit/'|sort|sed -e 's/bn_/ /g'|sed -e 's/\.c//g'>>tommath.def

makefile.mingw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LDFLAGS =
2121

2222
#Compilation flags
2323
LTM_CFLAGS = -I. $(CFLAGS)
24-
LTM_LDFLAGS = $(LDFLAGS)
24+
LTM_LDFLAGS = $(LDFLAGS) -static-libgcc
2525

2626
#Libraries to be created
2727
LIBMAIN_S =libtommath.a

tommath.def

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
; libtommath
2+
;
3+
; Use this command to produce a 32-bit .lib file, for use in any MSVC version
4+
; lib -machine:X86 -name:libtommath.dll -def:tommath.def -out:tommath.lib
5+
; Use this command to produce a 64-bit .lib file, for use in any MSVC version
6+
; lib -machine:X64 -name:libtommath.dll -def:tommath.def -out:tommath.lib
7+
;
8+
EXPORTS
9+
mp_2expt
10+
mp_abs
11+
mp_add
12+
mp_add_d
13+
mp_addmod
14+
mp_and
15+
mp_balance_mul
16+
mp_clamp
17+
mp_clear
18+
mp_clear_multi
19+
mp_cmp
20+
mp_cmp_d
21+
mp_cmp_mag
22+
mp_cnt_lsb
23+
mp_complement
24+
mp_copy
25+
mp_count_bits
26+
mp_decr
27+
mp_div
28+
mp_div_2
29+
mp_div_2d
30+
mp_div_3
31+
mp_div_d
32+
mp_dr_is_modulus
33+
mp_dr_reduce
34+
mp_dr_setup
35+
mp_error_to_string
36+
mp_exch
37+
mp_export
38+
mp_expt_d
39+
mp_expt_d_ex
40+
mp_exptmod
41+
mp_exteuclid
42+
mp_fread
43+
mp_fwrite
44+
mp_gcd
45+
mp_get_bit
46+
mp_get_double
47+
mp_get_int
48+
mp_get_long
49+
mp_get_long_long
50+
mp_grow
51+
mp_ilogb
52+
mp_import
53+
mp_incr
54+
mp_init
55+
mp_init_copy
56+
mp_init_multi
57+
mp_init_set
58+
mp_init_set_int
59+
mp_init_size
60+
mp_invmod
61+
mp_is_square
62+
mp_iseven
63+
mp_isodd
64+
mp_jacobi
65+
mp_kronecker
66+
mp_lcm
67+
mp_lshd
68+
mp_mod
69+
mp_mod_2d
70+
mp_mod_d
71+
mp_montgomery_calc_normalization
72+
mp_montgomery_reduce
73+
mp_montgomery_setup
74+
mp_mul
75+
mp_mul_2
76+
mp_mul_2d
77+
mp_mul_d
78+
mp_mulmod
79+
mp_n_root
80+
mp_n_root_ex
81+
mp_neg
82+
mp_or
83+
mp_prime_fermat
84+
mp_prime_frobenius_underwood
85+
mp_prime_is_divisible
86+
mp_prime_is_prime
87+
mp_prime_miller_rabin
88+
mp_prime_next_prime
89+
mp_prime_rabin_miller_trials
90+
mp_prime_random_ex
91+
mp_prime_strong_lucas_selfridge
92+
mp_radix_size
93+
mp_rand
94+
mp_rand_digit
95+
mp_read_radix
96+
mp_read_signed_bin
97+
mp_read_unsigned_bin
98+
mp_reduce
99+
mp_reduce_2k
100+
mp_reduce_2k_l
101+
mp_reduce_2k_setup
102+
mp_reduce_2k_setup_l
103+
mp_reduce_is_2k
104+
mp_reduce_is_2k_l
105+
mp_reduce_setup
106+
mp_rshd
107+
mp_set
108+
mp_set_double
109+
mp_set_int
110+
mp_set_long
111+
mp_set_long_long
112+
mp_shrink
113+
mp_signed_bin_size
114+
mp_sqr
115+
mp_sqrmod
116+
mp_sqrt
117+
mp_sqrtmod_prime
118+
mp_sub
119+
mp_sub_d
120+
mp_submod
121+
mp_tc_and
122+
mp_tc_div_2d
123+
mp_tc_or
124+
mp_tc_xor
125+
mp_to_signed_bin
126+
mp_to_signed_bin_n
127+
mp_to_unsigned_bin
128+
mp_to_unsigned_bin_n
129+
mp_toradix
130+
mp_toradix_n
131+
mp_unsigned_bin_size
132+
mp_xor
133+
mp_zero

tommath.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern "C" {
1919
#endif
2020

2121
/* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */
22-
#if defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)
22+
#if (defined(_MSC_VER) || defined(__LLP64__) || defined(__e2k__) || defined(__LCC__)) && !defined(MP_64BIT)
2323
# define MP_32BIT
2424
#endif
2525

@@ -30,7 +30,7 @@ extern "C" {
3030
defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \
3131
defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \
3232
defined(__LP64__) || defined(_LP64) || defined(__64BIT__)
33-
# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
33+
# if !(defined(MP_64BIT) || defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
3434
# if defined(__GNUC__)
3535
/* we support 128bit integers only via: __attribute__((mode(TI))) */
3636
# define MP_64BIT
@@ -66,7 +66,9 @@ typedef uint32_t mp_word;
6666
#elif defined(MP_64BIT)
6767
/* for GCC only on supported platforms */
6868
typedef uint64_t mp_digit;
69+
#if defined(__GNUC__)
6970
typedef unsigned long mp_word __attribute__((mode(TI)));
71+
#endif
7072
# define DIGIT_BIT 60
7173
#else
7274
/* this is the default case, 28-bit digits */

0 commit comments

Comments
 (0)