Skip to content

Commit 3035e22

Browse files
authored
Merge pull request #434 from libtom/simplifications
Simplifications
2 parents 2d3262a + 80176de commit 3035e22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1245
-1514
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ matrix:
144144
# clang for x86-64 architecture (64-bit longs and 64-bit pointers)
145145
- env: SANITIZER=1 CONV_WARNINGS=relaxed BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind'
146146
- env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind'
147+
- env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_USE_MEMOPS --with-m64 --with-travis-valgrind'
147148
- env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --c89 --with-m64 --with-travis-valgrind'
148149
- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind --cflags=-DMP_PREC=MP_MIN_PREC'
149150
- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-6.0 --with-m64 --with-travis-valgrind'

demo/mtest_opponent.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ static int mtest_opponent(void)
3737

3838
#ifndef MP_FIXED_CUTOFFS
3939
/* force KARA and TOOM to enable despite cutoffs */
40-
MP_KARATSUBA_SQR_CUTOFF = MP_KARATSUBA_MUL_CUTOFF = 8;
41-
MP_TOOM_SQR_CUTOFF = MP_TOOM_MUL_CUTOFF = 16;
40+
MP_SQR_KARATSUBA_CUTOFF = MP_MUL_KARATSUBA_CUTOFF = 8;
41+
MP_SQR_TOOM_CUTOFF = MP_MUL_TOOM_CUTOFF = 16;
4242
#endif
4343

4444
for (;;) {

demo/test.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ static int test_mp_root_u32(void)
18661866
return EXIT_FAILURE;
18671867
}
18681868

1869-
static int test_s_mp_balance_mul(void)
1869+
static int test_s_mp_mul_balance(void)
18701870
{
18711871
mp_int a, b, c;
18721872

@@ -1881,7 +1881,7 @@ static int test_s_mp_balance_mul(void)
18811881
DO(mp_read_radix(&a, na, 64));
18821882
DO(mp_read_radix(&b, nb, 64));
18831883

1884-
DO(s_mp_balance_mul(&a, &b, &c));
1884+
DO(s_mp_mul_balance(&a, &b, &c));
18851885

18861886
DO(mp_read_radix(&b, nc, 64));
18871887

@@ -1896,18 +1896,18 @@ static int test_s_mp_balance_mul(void)
18961896
return EXIT_FAILURE;
18971897
}
18981898

1899-
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
1900-
static int test_s_mp_karatsuba_mul(void)
1899+
#define s_mp_mul_full(a, b, c) s_mp_mul(a, b, c, (a)->used + (b)->used + 1)
1900+
static int test_s_mp_mul_karatsuba(void)
19011901
{
19021902
mp_int a, b, c, d;
19031903
int size;
19041904

19051905
DOR(mp_init_multi(&a, &b, &c, &d, NULL));
1906-
for (size = MP_KARATSUBA_MUL_CUTOFF; size < MP_KARATSUBA_MUL_CUTOFF + 20; size++) {
1906+
for (size = MP_MUL_KARATSUBA_CUTOFF; size < MP_MUL_KARATSUBA_CUTOFF + 20; size++) {
19071907
DO(mp_rand(&a, size));
19081908
DO(mp_rand(&b, size));
1909-
DO(s_mp_karatsuba_mul(&a, &b, &c));
1910-
DO(s_mp_mul(&a,&b,&d));
1909+
DO(s_mp_mul_karatsuba(&a, &b, &c));
1910+
DO(s_mp_mul_full(&a,&b,&d));
19111911
if (mp_cmp(&c, &d) != MP_EQ) {
19121912
fprintf(stderr, "Karatsuba multiplication failed at size %d\n", size);
19131913
goto LBL_ERR;
@@ -1921,15 +1921,15 @@ static int test_s_mp_karatsuba_mul(void)
19211921
return EXIT_FAILURE;
19221922
}
19231923

1924-
static int test_s_mp_karatsuba_sqr(void)
1924+
static int test_s_mp_sqr_karatsuba(void)
19251925
{
19261926
mp_int a, b, c;
19271927
int size;
19281928

19291929
DOR(mp_init_multi(&a, &b, &c, NULL));
1930-
for (size = MP_KARATSUBA_SQR_CUTOFF; size < MP_KARATSUBA_SQR_CUTOFF + 20; size++) {
1930+
for (size = MP_SQR_KARATSUBA_CUTOFF; size < MP_SQR_KARATSUBA_CUTOFF + 20; size++) {
19311931
DO(mp_rand(&a, size));
1932-
DO(s_mp_karatsuba_sqr(&a, &b));
1932+
DO(s_mp_sqr_karatsuba(&a, &b));
19331933
DO(s_mp_sqr(&a, &c));
19341934
if (mp_cmp(&b, &c) != MP_EQ) {
19351935
fprintf(stderr, "Karatsuba squaring failed at size %d\n", size);
@@ -1944,7 +1944,7 @@ static int test_s_mp_karatsuba_sqr(void)
19441944
return EXIT_FAILURE;
19451945
}
19461946

1947-
static int test_s_mp_toom_mul(void)
1947+
static int test_s_mp_mul_toom(void)
19481948
{
19491949
mp_int a, b, c, d;
19501950
int size;
@@ -1965,22 +1965,22 @@ static int test_s_mp_toom_mul(void)
19651965
DO(mp_2expt(&c, 99000 - 1000));
19661966
DO(mp_add(&b, &c, &b));
19671967

1968-
tc_cutoff = MP_TOOM_MUL_CUTOFF;
1969-
MP_TOOM_MUL_CUTOFF = INT_MAX;
1968+
tc_cutoff = MP_MUL_TOOM_CUTOFF;
1969+
MP_MUL_TOOM_CUTOFF = INT_MAX;
19701970
DO(mp_mul(&a, &b, &c));
1971-
MP_TOOM_MUL_CUTOFF = tc_cutoff;
1971+
MP_MUL_TOOM_CUTOFF = tc_cutoff;
19721972
DO(mp_mul(&a, &b, &d));
19731973
if (mp_cmp(&c, &d) != MP_EQ) {
19741974
fprintf(stderr, "Toom-Cook 3-way multiplication failed for edgecase f1 * f2\n");
19751975
goto LBL_ERR;
19761976
}
19771977
#endif
19781978

1979-
for (size = MP_TOOM_MUL_CUTOFF; size < MP_TOOM_MUL_CUTOFF + 20; size++) {
1979+
for (size = MP_MUL_TOOM_CUTOFF; size < MP_MUL_TOOM_CUTOFF + 20; size++) {
19801980
DO(mp_rand(&a, size));
19811981
DO(mp_rand(&b, size));
1982-
DO(s_mp_toom_mul(&a, &b, &c));
1983-
DO(s_mp_mul(&a,&b,&d));
1982+
DO(s_mp_mul_toom(&a, &b, &c));
1983+
DO(s_mp_mul_full(&a,&b,&d));
19841984
if (mp_cmp(&c, &d) != MP_EQ) {
19851985
fprintf(stderr, "Toom-Cook 3-way multiplication failed at size %d\n", size);
19861986
goto LBL_ERR;
@@ -1994,15 +1994,15 @@ static int test_s_mp_toom_mul(void)
19941994
return EXIT_FAILURE;
19951995
}
19961996

1997-
static int test_s_mp_toom_sqr(void)
1997+
static int test_s_mp_sqr_toom(void)
19981998
{
19991999
mp_int a, b, c;
20002000
int size;
20012001

20022002
DOR(mp_init_multi(&a, &b, &c, NULL));
2003-
for (size = MP_TOOM_SQR_CUTOFF; size < MP_TOOM_SQR_CUTOFF + 20; size++) {
2003+
for (size = MP_SQR_TOOM_CUTOFF; size < MP_SQR_TOOM_CUTOFF + 20; size++) {
20042004
DO(mp_rand(&a, size));
2005-
DO(s_mp_toom_sqr(&a, &b));
2005+
DO(s_mp_sqr_toom(&a, &b));
20062006
DO(s_mp_sqr(&a, &c));
20072007
if (mp_cmp(&b, &c) != MP_EQ) {
20082008
fprintf(stderr, "Toom-Cook 3-way squaring failed at size %d\n", size);
@@ -2075,7 +2075,7 @@ static int test_s_mp_div_recursive(void)
20752075

20762076
DOR(mp_init_multi(&a, &b, &c_q, &c_r, &d_q, &d_r, NULL));
20772077

2078-
for (size = MP_KARATSUBA_MUL_CUTOFF; size < 3 * MP_KARATSUBA_MUL_CUTOFF; size += 10) {
2078+
for (size = MP_MUL_KARATSUBA_CUTOFF; size < 3 * MP_MUL_KARATSUBA_CUTOFF; size += 10) {
20792079
printf("\rsizes = %d / %d", 10 * size, size);
20802080
/* Relation 10:1 */
20812081
DO(mp_rand(&a, 10 * size));
@@ -2139,7 +2139,7 @@ static int test_s_mp_div_small(void)
21392139
int size;
21402140

21412141
DOR(mp_init_multi(&a, &b, &c_q, &c_r, &d_q, &d_r, NULL));
2142-
for (size = 1; size < MP_KARATSUBA_MUL_CUTOFF; size += 10) {
2142+
for (size = 1; size < MP_MUL_KARATSUBA_CUTOFF; size += 10) {
21432143
printf("\rsizes = %d / %d", 2 * size, size);
21442144
/* Relation 10:1 */
21452145
DO(mp_rand(&a, 2 * size));
@@ -2332,11 +2332,11 @@ static int unit_tests(int argc, char **argv)
23322332
T1(mp_xor, MP_XOR),
23332333
T2(s_mp_div_recursive, S_MP_DIV_RECURSIVE, S_MP_DIV_SCHOOL),
23342334
T2(s_mp_div_small, S_MP_DIV_SMALL, S_MP_DIV_SCHOOL),
2335-
T1(s_mp_balance_mul, S_MP_BALANCE_MUL),
2336-
T1(s_mp_karatsuba_mul, S_MP_KARATSUBA_MUL),
2337-
T1(s_mp_karatsuba_sqr, S_MP_KARATSUBA_SQR),
2338-
T1(s_mp_toom_mul, S_MP_TOOM_MUL),
2339-
T1(s_mp_toom_sqr, S_MP_TOOM_SQR)
2335+
T1(s_mp_mul_balance, S_MP_MUL_BALANCE),
2336+
T1(s_mp_mul_karatsuba, S_MP_MUL_KARATSUBA),
2337+
T1(s_mp_sqr_karatsuba, S_MP_SQR_KARATSUBA),
2338+
T1(s_mp_mul_toom, S_MP_MUL_TOOM),
2339+
T1(s_mp_sqr_toom, S_MP_SQR_TOOM)
23402340
#undef T2
23412341
#undef T1
23422342
};

demo/timing.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,18 @@ int main(int argc, char **argv)
247247

248248
if (should_test("mulsqr", argc, argv) != 0) {
249249
/* do mult/square twice, first without karatsuba and second with */
250-
old_kara_m = MP_KARATSUBA_MUL_CUTOFF;
251-
old_kara_s = MP_KARATSUBA_SQR_CUTOFF;
250+
old_kara_m = MP_MUL_KARATSUBA_CUTOFF;
251+
old_kara_s = MP_SQR_KARATSUBA_CUTOFF;
252252
/* currently toom-cook cut-off is too high to kick in, so we just use the karatsuba values */
253253
old_toom_m = old_kara_m;
254254
old_toom_s = old_kara_s;
255255
for (ix = 0; ix < 3; ix++) {
256256
printf("With%s Karatsuba, With%s Toom\n", (ix == 1) ? "" : "out", (ix == 2) ? "" : "out");
257257

258-
MP_KARATSUBA_MUL_CUTOFF = (ix == 1) ? old_kara_m : 9999;
259-
MP_KARATSUBA_SQR_CUTOFF = (ix == 1) ? old_kara_s : 9999;
260-
MP_TOOM_MUL_CUTOFF = (ix == 2) ? old_toom_m : 9999;
261-
MP_TOOM_SQR_CUTOFF = (ix == 2) ? old_toom_s : 9999;
258+
MP_MUL_KARATSUBA_CUTOFF = (ix == 1) ? old_kara_m : 9999;
259+
MP_SQR_KARATSUBA_CUTOFF = (ix == 1) ? old_kara_s : 9999;
260+
MP_MUL_TOOM_CUTOFF = (ix == 2) ? old_toom_m : 9999;
261+
MP_SQR_TOOM_CUTOFF = (ix == 2) ? old_toom_s : 9999;
262262

263263
log = FOPEN((ix == 0) ? "logs/mult" MP_TIMING_VERSION ".log" : (ix == 1) ? "logs/mult_kara" MP_TIMING_VERSION ".log" :
264264
"logs/mult_toom" MP_TIMING_VERSION ".log", "w");

etc/tune.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int s_number_of_test_loops;
5858
static int s_stabilization_extra;
5959
static int s_offset = 1;
6060

61-
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
61+
#define s_mp_mul_full(a, b, c) s_mp_mul(a, b, c, (a)->used + (b)->used + 1)
6262
static uint64_t s_time_mul(int size)
6363
{
6464
int x;
@@ -87,7 +87,7 @@ static uint64_t s_time_mul(int size)
8787
goto LBL_ERR;
8888
}
8989
if (s_check_result == 1) {
90-
if ((e = s_mp_mul(&a,&b,&d)) != MP_OKAY) {
90+
if ((e = s_mp_mul_full(&a,&b,&d)) != MP_OKAY) {
9191
t1 = UINT64_MAX;
9292
goto LBL_ERR;
9393
}
@@ -247,27 +247,27 @@ static void s_usage(char *s)
247247
}
248248

249249
struct cutoffs {
250-
int KARATSUBA_MUL, KARATSUBA_SQR;
251-
int TOOM_MUL, TOOM_SQR;
250+
int MUL_KARATSUBA, SQR_KARATSUBA;
251+
int MUL_TOOM, SQR_TOOM;
252252
};
253253

254254
const struct cutoffs max_cutoffs =
255255
{ INT_MAX, INT_MAX, INT_MAX, INT_MAX };
256256

257257
static void set_cutoffs(const struct cutoffs *c)
258258
{
259-
MP_KARATSUBA_MUL_CUTOFF = c->KARATSUBA_MUL;
260-
MP_KARATSUBA_SQR_CUTOFF = c->KARATSUBA_SQR;
261-
MP_TOOM_MUL_CUTOFF = c->TOOM_MUL;
262-
MP_TOOM_SQR_CUTOFF = c->TOOM_SQR;
259+
MP_MUL_KARATSUBA_CUTOFF = c->MUL_KARATSUBA;
260+
MP_SQR_KARATSUBA_CUTOFF = c->SQR_KARATSUBA;
261+
MP_MUL_TOOM_CUTOFF = c->MUL_TOOM;
262+
MP_SQR_TOOM_CUTOFF = c->SQR_TOOM;
263263
}
264264

265265
static void get_cutoffs(struct cutoffs *c)
266266
{
267-
c->KARATSUBA_MUL = MP_KARATSUBA_MUL_CUTOFF;
268-
c->KARATSUBA_SQR = MP_KARATSUBA_SQR_CUTOFF;
269-
c->TOOM_MUL = MP_TOOM_MUL_CUTOFF;
270-
c->TOOM_SQR = MP_TOOM_SQR_CUTOFF;
267+
c->MUL_KARATSUBA = MP_MUL_KARATSUBA_CUTOFF;
268+
c->SQR_KARATSUBA = MP_SQR_KARATSUBA_CUTOFF;
269+
c->MUL_TOOM = MP_MUL_TOOM_CUTOFF;
270+
c->SQR_TOOM = MP_SQR_TOOM_CUTOFF;
271271

272272
}
273273

@@ -292,7 +292,7 @@ int main(int argc, char **argv)
292292
s_number_of_test_loops = 64;
293293
s_stabilization_extra = 3;
294294

295-
MP_ZERO_BUFFER(&args, sizeof(args));
295+
s_mp_zero_buf(&args, sizeof(args));
296296

297297
args.testmode = 0;
298298
args.verbose = 0;
@@ -414,13 +414,13 @@ int main(int argc, char **argv)
414414
s_usage(argv[0]);
415415
}
416416
str = argv[opt];
417-
MP_KARATSUBA_MUL_CUTOFF = (int)s_strtol(str, &endptr, "[1/4] No value for MP_KARATSUBA_MUL_CUTOFF given");
417+
MP_MUL_KARATSUBA_CUTOFF = (int)s_strtol(str, &endptr, "[1/4] No value for MP_MUL_KARATSUBA_CUTOFF given");
418418
str = endptr + 1;
419-
MP_KARATSUBA_SQR_CUTOFF = (int)s_strtol(str, &endptr, "[2/4] No value for MP_KARATSUBA_SQR_CUTOFF given");
419+
MP_SQR_KARATSUBA_CUTOFF = (int)s_strtol(str, &endptr, "[2/4] No value for MP_SQR_KARATSUBA_CUTOFF given");
420420
str = endptr + 1;
421-
MP_TOOM_MUL_CUTOFF = (int)s_strtol(str, &endptr, "[3/4] No value for MP_TOOM_MUL_CUTOFF given");
421+
MP_MUL_TOOM_CUTOFF = (int)s_strtol(str, &endptr, "[3/4] No value for MP_MUL_TOOM_CUTOFF given");
422422
str = endptr + 1;
423-
MP_TOOM_SQR_CUTOFF = (int)s_strtol(str, &endptr, "[4/4] No value for MP_TOOM_SQR_CUTOFF given");
423+
MP_SQR_TOOM_CUTOFF = (int)s_strtol(str, &endptr, "[4/4] No value for MP_SQR_TOOM_CUTOFF given");
424424
break;
425425
case 'h':
426426
s_exit_code = EXIT_SUCCESS;
@@ -455,10 +455,10 @@ int main(int argc, char **argv)
455455
of the macro MP_WPARRAY in tommath.h which needs to
456456
be changed manually (to 0 (zero)).
457457
*/
458-
T_MUL_SQR("Karatsuba multiplication", KARATSUBA_MUL, s_time_mul),
459-
T_MUL_SQR("Karatsuba squaring", KARATSUBA_SQR, s_time_sqr),
460-
T_MUL_SQR("Toom-Cook 3-way multiplying", TOOM_MUL, s_time_mul),
461-
T_MUL_SQR("Toom-Cook 3-way squaring", TOOM_SQR, s_time_sqr),
458+
T_MUL_SQR("Karatsuba multiplication", MUL_KARATSUBA, s_time_mul),
459+
T_MUL_SQR("Karatsuba squaring", SQR_KARATSUBA, s_time_sqr),
460+
T_MUL_SQR("Toom-Cook 3-way multiplying", MUL_TOOM, s_time_mul),
461+
T_MUL_SQR("Toom-Cook 3-way squaring", SQR_TOOM, s_time_sqr),
462462
#undef T_MUL_SQR
463463
};
464464
/* Turn all limits from bncore.c to the max */
@@ -473,15 +473,15 @@ int main(int argc, char **argv)
473473
}
474474
if (args.terse == 1) {
475475
printf("%d %d %d %d\n",
476-
updated.KARATSUBA_MUL,
477-
updated.KARATSUBA_SQR,
478-
updated.TOOM_MUL,
479-
updated.TOOM_SQR);
476+
updated.MUL_KARATSUBA,
477+
updated.SQR_KARATSUBA,
478+
updated.MUL_TOOM,
479+
updated.SQR_TOOM);
480480
} else {
481-
printf("KARATSUBA_MUL_CUTOFF = %d\n", updated.KARATSUBA_MUL);
482-
printf("KARATSUBA_SQR_CUTOFF = %d\n", updated.KARATSUBA_SQR);
483-
printf("TOOM_MUL_CUTOFF = %d\n", updated.TOOM_MUL);
484-
printf("TOOM_SQR_CUTOFF = %d\n", updated.TOOM_SQR);
481+
printf("MUL_KARATSUBA_CUTOFF = %d\n", updated.MUL_KARATSUBA);
482+
printf("SQR_KARATSUBA_CUTOFF = %d\n", updated.SQR_KARATSUBA);
483+
printf("MUL_TOOM_CUTOFF = %d\n", updated.MUL_TOOM);
484+
printf("SQR_TOOM_CUTOFF = %d\n", updated.SQR_TOOM);
485485
}
486486

487487
if (args.print == 1) {
@@ -526,15 +526,15 @@ int main(int argc, char **argv)
526526
set_cutoffs(&orig);
527527
if (args.terse == 1) {
528528
printf("%d %d %d %d\n",
529-
MP_KARATSUBA_MUL_CUTOFF,
530-
MP_KARATSUBA_SQR_CUTOFF,
531-
MP_TOOM_MUL_CUTOFF,
532-
MP_TOOM_SQR_CUTOFF);
529+
MP_MUL_KARATSUBA_CUTOFF,
530+
MP_SQR_KARATSUBA_CUTOFF,
531+
MP_MUL_TOOM_CUTOFF,
532+
MP_SQR_TOOM_CUTOFF);
533533
} else {
534-
printf("KARATSUBA_MUL_CUTOFF = %d\n", MP_KARATSUBA_MUL_CUTOFF);
535-
printf("KARATSUBA_SQR_CUTOFF = %d\n", MP_KARATSUBA_SQR_CUTOFF);
536-
printf("TOOM_MUL_CUTOFF = %d\n", MP_TOOM_MUL_CUTOFF);
537-
printf("TOOM_SQR_CUTOFF = %d\n", MP_TOOM_SQR_CUTOFF);
534+
printf("MUL_KARATSUBA_CUTOFF = %d\n", MP_MUL_KARATSUBA_CUTOFF);
535+
printf("SQR_KARATSUBA_CUTOFF = %d\n", MP_SQR_KARATSUBA_CUTOFF);
536+
printf("MUL_TOOM_CUTOFF = %d\n", MP_MUL_TOOM_CUTOFF);
537+
printf("SQR_TOOM_CUTOFF = %d\n", MP_SQR_TOOM_CUTOFF);
538538
}
539539
}
540540
}

etc/tune_it.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,14 @@ i=$(tail -n +2 $FILE_NAME | wc -l)
9393
# our median point will be at $i entries
9494
i=$(( (i / 2) + 1 ))
9595
TMP=$(median $FILE_NAME 1 $i)
96-
echo "#define MP_DEFAULT_KARATSUBA_MUL_CUTOFF $TMP"
97-
echo "#define MP_DEFAULT_KARATSUBA_MUL_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(km) Appending to $TOMMATH_CUTOFFS_H" $?
96+
echo "#define MP_DEFAULT_MUL_KARATSUBA_CUTOFF $TMP"
97+
echo "#define MP_DEFAULT_MUL_KARATSUBA_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(km) Appending to $TOMMATH_CUTOFFS_H" $?
9898
TMP=$(median $FILE_NAME 2 $i)
99-
echo "#define MP_DEFAULT_KARATSUBA_SQR_CUTOFF $TMP"
100-
echo "#define MP_DEFAULT_KARATSUBA_SQR_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(ks) Appending to $TOMMATH_CUTOFFS_H" $?
99+
echo "#define MP_DEFAULT_SQR_KARATSUBA_CUTOFF $TMP"
100+
echo "#define MP_DEFAULT_SQR_KARATSUBA_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(ks) Appending to $TOMMATH_CUTOFFS_H" $?
101101
TMP=$(median $FILE_NAME 3 $i)
102-
echo "#define MP_DEFAULT_TOOM_MUL_CUTOFF $TMP"
103-
echo "#define MP_DEFAULT_TOOM_MUL_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(tc3m) Appending to $TOMMATH_CUTOFFS_H" $?
102+
echo "#define MP_DEFAULT_MUL_TOOM_CUTOFF $TMP"
103+
echo "#define MP_DEFAULT_MUL_TOOM_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(tc3m) Appending to $TOMMATH_CUTOFFS_H" $?
104104
TMP=$(median $FILE_NAME 4 $i)
105-
echo "#define MP_DEFAULT_TOOM_SQR_CUTOFF $TMP"
106-
echo "#define MP_DEFAULT_TOOM_SQR_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(tc3s) Appending to $TOMMATH_CUTOFFS_H" $?
107-
105+
echo "#define MP_DEFAULT_SQR_TOOM_CUTOFF $TMP"
106+
echo "#define MP_DEFAULT_SQR_TOOM_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(tc3s) Appending to $TOMMATH_CUTOFFS_H" $?

helper.pl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ sub check_source {
5757
push @{$troubles->{unwanted_calloc}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bcalloc\s*\(/;
5858
push @{$troubles->{unwanted_free}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bfree\s*\(/;
5959
# and we probably want to also avoid the following
60-
push @{$troubles->{unwanted_memcpy}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemcpy\s*\(/;
61-
push @{$troubles->{unwanted_memset}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemset\s*\(/;
62-
push @{$troubles->{unwanted_memcpy}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemcpy\s*\(/;
60+
push @{$troubles->{unwanted_memcpy}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemcpy\s*\(/ && $file !~ /s_mp_copy_digs.c/;
61+
push @{$troubles->{unwanted_memset}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemset\s*\(/ && $file !~ /s_mp_zero_buf.c/ && $file !~ /s_mp_zero_digs.c/;
6362
push @{$troubles->{unwanted_memmove}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemmove\s*\(/;
6463
push @{$troubles->{unwanted_memcmp}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemcmp\s*\(/;
6564
push @{$troubles->{unwanted_strcmp}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bstrcmp\s*\(/;

0 commit comments

Comments
 (0)