Skip to content

Commit 6987dba

Browse files
authored
Merge branch 'develop' into feature-detection2
2 parents f769d66 + f109772 commit 6987dba

File tree

7 files changed

+42
-31
lines changed

7 files changed

+42
-31
lines changed

demo/test.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ static int test_mp_invmod(void)
665665

666666
}
667667

668+
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
668669
static int test_mp_set_double(void)
669670
{
670671
int i;
@@ -675,7 +676,6 @@ static int test_mp_set_double(void)
675676
}
676677

677678
/* test mp_get_double/mp_set_double */
678-
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
679679
if (mp_set_double(&a, +1.0/0.0) != MP_VAL) {
680680
printf("\nmp_set_double should return MP_VAL for +inf");
681681
goto LBL_ERR;
@@ -713,7 +713,6 @@ static int test_mp_set_double(void)
713713
goto LBL_ERR;
714714
}
715715
}
716-
#endif
717716

718717
mp_clear_multi(&a, &b, NULL);
719718
return EXIT_SUCCESS;
@@ -722,6 +721,7 @@ static int test_mp_set_double(void)
722721
return EXIT_FAILURE;
723722

724723
}
724+
#endif
725725

726726
static int test_mp_get_u32(void)
727727
{
@@ -2156,7 +2156,9 @@ int unit_tests(int argc, char **argv)
21562156
T(mp_read_radix),
21572157
T(mp_reduce_2k),
21582158
T(mp_reduce_2k_l),
2159+
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
21592160
T(mp_set_double),
2161+
#endif
21602162
T(mp_signed_rsh),
21612163
T(mp_sqrt),
21622164
T(mp_sqrtmod_prime),

generate_def.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

helper.pl

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,26 @@ sub update_dep
437437
}
438438

439439
sub generate_def {
440-
system("sh", "generate_def.sh");
440+
my @files = split /\n/, `git ls-files`;
441+
@files = grep(/\.c/, @files);
442+
@files = map { my $x = $_; $x =~ s/^bn_|\.c$//g; $x; } @files;
443+
@files = grep(!/mp_radix_smap/, @files);
444+
445+
@files = grep(!/conversion/, @files);
446+
push(@files, qw(mp_set_i32 mp_set_i64 mp_set_u32 mp_set_u64 mp_set_int mp_set_long mp_set_long_long mp_get_i32 mp_get_i64 mp_get_mag32 mp_get_mag64 mp_get_int mp_get_long mp_get_long_long mp_init_i32 mp_init_i64 mp_init_u32 mp_init_u64 mp_init_set_int));
447+
448+
my $files = join("\n ", sort(grep(/^mp_/, @files)));
449+
write_file "tommath.def", "; libtommath
450+
;
451+
; Use this command to produce a 32-bit .lib file, for use in any MSVC version
452+
; lib -machine:X86 -name:libtommath.dll -def:tommath.def -out:tommath.lib
453+
; Use this command to produce a 64-bit .lib file, for use in any MSVC version
454+
; lib -machine:X64 -name:libtommath.dll -def:tommath.def -out:tommath.lib
455+
;
456+
EXPORTS
457+
$files
458+
";
459+
return 0;
441460
}
442461

443462
sub die_usage {
@@ -446,7 +465,7 @@ sub die_usage {
446465
$0 -o OR $0 --check-comments
447466
$0 -m OR $0 --check-makefiles
448467
$0 -a OR $0 --check-all
449-
$0 -u OR $0 --update-makefiles
468+
$0 -u OR $0 --update-files
450469
MARKER
451470
}
452471

@@ -455,7 +474,7 @@ sub die_usage {
455474
"m|check-makefiles" => \my $check_makefiles,
456475
"d|check-doc" => \my $check_doc,
457476
"a|check-all" => \my $check_all,
458-
"u|update-makefiles" => \my $update_makefiles,
477+
"u|update-files" => \my $update_files,
459478
"h|help" => \my $help
460479
) or die_usage;
461480

@@ -464,9 +483,9 @@ sub die_usage {
464483
$failure ||= check_comments() if $check_all || $check_comments;
465484
$failure ||= check_doc() if $check_doc; # temporarily excluded from --check-all
466485
$failure ||= process_makefiles(0) if $check_all || $check_makefiles;
467-
$failure ||= process_makefiles(1) if $update_makefiles;
468-
$failure ||= update_dep() if $update_makefiles;
469-
$failure ||= generate_def() if $update_makefiles;
486+
$failure ||= process_makefiles(1) if $update_files;
487+
$failure ||= update_dep() if $update_files;
488+
$failure ||= generate_def() if $update_files;
470489

471490
die_usage unless defined $failure;
472491
exit $failure ? 1 : 0;

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ zipup: clean astyle new_file manual poster docs
149149
gpg -b -a ltm-$(VERSION).zip
150150

151151
new_file:
152-
perl helper.pl --update-makefiles
152+
perl helper.pl --update-files
153153

154154
perlcritic:
155155
perlcritic *.pl doc/*.pl

makefile.msvc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PREFIX = c:\devel
1414
CFLAGS = /Ox
1515

1616
#Compilation flags
17-
LTM_CFLAGS = /nologo /I./ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /W3 $(CFLAGS)
17+
LTM_CFLAGS = /nologo /I./ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D__STDC_WANT_SECURE_LIB__=0 /Wall /wd4146 /wd4127 /wd4710 /wd4711 /wd4820 $(CFLAGS)
1818
LTM_LDFLAGS = advapi32.lib
1919

2020
#Libraries to be created (this makefile builds only static libraries)
@@ -60,7 +60,7 @@ $(OBJECTS): $(HEADERS)
6060
.c.obj:
6161
$(CC) $(LTM_CFLAGS) /c $< /Fo$@
6262

63-
#Create tomcrypt.lib
63+
#Create tommath.lib
6464
$(LIBMAIN_S): $(OBJECTS)
6565
lib /out:$(LIBMAIN_S) $(OBJECTS)
6666

testme.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ if [[ "$CHECK_FORMAT" == "1" ]]
295295
then
296296
make astyle
297297
_check_git "make astyle"
298-
perl helper.pl --update-makefiles
299-
_check_git "helper.pl --update-makefiles"
298+
perl helper.pl --update-files
299+
_check_git "helper.pl --update-files"
300300
perl helper.pl --check-all
301301
_check_git "helper.pl --check-all"
302302
exit $?

tommath.def

100755100644
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ EXPORTS
2323
mp_copy
2424
mp_count_bits
2525
mp_decr
26+
mp_div
2627
mp_div_2
2728
mp_div_2d
2829
mp_div_3
29-
mp_div
3030
mp_div_d
3131
mp_dr_is_modulus
3232
mp_dr_reduce
@@ -63,25 +63,25 @@ EXPORTS
6363
mp_init_u32
6464
mp_init_u64
6565
mp_invmod
66+
mp_is_square
6667
mp_iseven
6768
mp_isodd
68-
mp_is_square
6969
mp_kronecker
7070
mp_lcm
7171
mp_lshd
72-
mp_mod_2d
7372
mp_mod
73+
mp_mod_2d
7474
mp_mod_d
7575
mp_montgomery_calc_normalization
7676
mp_montgomery_reduce
7777
mp_montgomery_setup
78+
mp_mul
7879
mp_mul_2
7980
mp_mul_2d
80-
mp_mul
8181
mp_mul_d
8282
mp_mulmod
83-
mp_neg
8483
mp_n_root
84+
mp_neg
8585
mp_or
8686
mp_prime_fermat
8787
mp_prime_frobenius_underwood
@@ -93,15 +93,14 @@ EXPORTS
9393
mp_prime_strong_lucas_selfridge
9494
mp_radix_size
9595
mp_rand
96-
mp_rand_digit
9796
mp_read_radix
9897
mp_read_signed_bin
9998
mp_read_unsigned_bin
99+
mp_reduce
100100
mp_reduce_2k
101101
mp_reduce_2k_l
102102
mp_reduce_2k_setup
103103
mp_reduce_2k_setup_l
104-
mp_reduce
105104
mp_reduce_is_2k
106105
mp_reduce_is_2k_l
107106
mp_reduce_setup
@@ -125,12 +124,12 @@ EXPORTS
125124
mp_sub
126125
mp_sub_d
127126
mp_submod
128-
mp_toradix
129-
mp_toradix_n
130127
mp_to_signed_bin
131128
mp_to_signed_bin_n
132129
mp_to_unsigned_bin
133130
mp_to_unsigned_bin_n
131+
mp_toradix
132+
mp_toradix_n
134133
mp_unsigned_bin_size
135134
mp_xor
136135
mp_zero

0 commit comments

Comments
 (0)