add prefix to cutoff variables
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
diff --git a/demo/mtest_opponent.c b/demo/mtest_opponent.c
index e77fec9..827c3f5 100644
--- a/demo/mtest_opponent.c
+++ b/demo/mtest_opponent.c
@@ -37,8 +37,8 @@ static int mtest_opponent(void)
#ifndef MP_FIXED_CUTOFFS
/* force KARA and TOOM to enable despite cutoffs */
- KARATSUBA_SQR_CUTOFF = KARATSUBA_MUL_CUTOFF = 8;
- TOOM_SQR_CUTOFF = TOOM_MUL_CUTOFF = 16;
+ MP_KARATSUBA_SQR_CUTOFF = MP_KARATSUBA_MUL_CUTOFF = 8;
+ MP_TOOM_SQR_CUTOFF = MP_TOOM_MUL_CUTOFF = 16;
#endif
for (;;) {
diff --git a/demo/test.c b/demo/test.c
index 0f0152a..41c4182 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -2199,12 +2199,12 @@ static int test_s_mp_toom_mul(void)
goto LBL_ERR;
}
- tc_cutoff = TOOM_MUL_CUTOFF;
- TOOM_MUL_CUTOFF = INT_MAX;
+ tc_cutoff = MP_TOOM_MUL_CUTOFF;
+ MP_TOOM_MUL_CUTOFF = INT_MAX;
if ((err = mp_mul(&a, &b, &c)) != MP_OKAY) {
goto LBL_ERR;
}
- TOOM_MUL_CUTOFF = tc_cutoff;
+ MP_TOOM_MUL_CUTOFF = tc_cutoff;
if ((err = mp_mul(&a, &b, &d)) != MP_OKAY) {
goto LBL_ERR;
}
diff --git a/demo/timing.c b/demo/timing.c
index 47775da..a421f8d 100644
--- a/demo/timing.c
+++ b/demo/timing.c
@@ -234,18 +234,18 @@ int main(int argc, char **argv)
if (should_test("mulsqr", argc, argv) != 0) {
/* do mult/square twice, first without karatsuba and second with */
- old_kara_m = KARATSUBA_MUL_CUTOFF;
- old_kara_s = KARATSUBA_SQR_CUTOFF;
+ old_kara_m = MP_KARATSUBA_MUL_CUTOFF;
+ old_kara_s = MP_KARATSUBA_SQR_CUTOFF;
/* currently toom-cook cut-off is too high to kick in, so we just use the karatsuba values */
old_toom_m = old_kara_m;
old_toom_s = old_kara_s;
for (ix = 0; ix < 3; ix++) {
printf("With%s Karatsuba, With%s Toom\n", (ix == 1) ? "" : "out", (ix == 2) ? "" : "out");
- KARATSUBA_MUL_CUTOFF = (ix == 1) ? old_kara_m : 9999;
- KARATSUBA_SQR_CUTOFF = (ix == 1) ? old_kara_s : 9999;
- TOOM_MUL_CUTOFF = (ix == 2) ? old_toom_m : 9999;
- TOOM_SQR_CUTOFF = (ix == 2) ? old_toom_s : 9999;
+ MP_KARATSUBA_MUL_CUTOFF = (ix == 1) ? old_kara_m : 9999;
+ MP_KARATSUBA_SQR_CUTOFF = (ix == 1) ? old_kara_s : 9999;
+ MP_TOOM_MUL_CUTOFF = (ix == 2) ? old_toom_m : 9999;
+ MP_TOOM_SQR_CUTOFF = (ix == 2) ? old_toom_s : 9999;
log = FOPEN((ix == 0) ? "logs/mult.log" : (ix == 1) ? "logs/mult_kara.log" : "logs/mult_toom.log", "w");
for (cnt = 4; cnt <= (10240 / MP_DIGIT_BIT); cnt += 2) {
diff --git a/etc/tune.c b/etc/tune.c
index e6850c6..be78ce3 100644
--- a/etc/tune.c
+++ b/etc/tune.c
@@ -256,18 +256,18 @@ const struct cutoffs max_cutoffs =
static void set_cutoffs(const struct cutoffs *c)
{
- KARATSUBA_MUL_CUTOFF = c->KARATSUBA_MUL;
- KARATSUBA_SQR_CUTOFF = c->KARATSUBA_SQR;
- TOOM_MUL_CUTOFF = c->TOOM_MUL;
- TOOM_SQR_CUTOFF = c->TOOM_SQR;
+ MP_KARATSUBA_MUL_CUTOFF = c->KARATSUBA_MUL;
+ MP_KARATSUBA_SQR_CUTOFF = c->KARATSUBA_SQR;
+ MP_TOOM_MUL_CUTOFF = c->TOOM_MUL;
+ MP_TOOM_SQR_CUTOFF = c->TOOM_SQR;
}
static void get_cutoffs(struct cutoffs *c)
{
- c->KARATSUBA_MUL = KARATSUBA_MUL_CUTOFF;
- c->KARATSUBA_SQR = KARATSUBA_SQR_CUTOFF;
- c->TOOM_MUL = TOOM_MUL_CUTOFF;
- c->TOOM_SQR = TOOM_SQR_CUTOFF;
+ c->KARATSUBA_MUL = MP_KARATSUBA_MUL_CUTOFF;
+ c->KARATSUBA_SQR = MP_KARATSUBA_SQR_CUTOFF;
+ c->TOOM_MUL = MP_TOOM_MUL_CUTOFF;
+ c->TOOM_SQR = MP_TOOM_SQR_CUTOFF;
}
@@ -414,13 +414,13 @@ int main(int argc, char **argv)
s_usage(argv[0]);
}
str = argv[opt];
- KARATSUBA_MUL_CUTOFF = (int)s_strtol(str, &endptr, "[1/4] No value for KARATSUBA_MUL_CUTOFF given");
+ MP_KARATSUBA_MUL_CUTOFF = (int)s_strtol(str, &endptr, "[1/4] No value for MP_KARATSUBA_MUL_CUTOFF given");
str = endptr + 1;
- KARATSUBA_SQR_CUTOFF = (int)s_strtol(str, &endptr, "[2/4] No value for KARATSUBA_SQR_CUTOFF given");
+ MP_KARATSUBA_SQR_CUTOFF = (int)s_strtol(str, &endptr, "[2/4] No value for MP_KARATSUBA_SQR_CUTOFF given");
str = endptr + 1;
- TOOM_MUL_CUTOFF = (int)s_strtol(str, &endptr, "[3/4] No value for TOOM_MUL_CUTOFF given");
+ MP_TOOM_MUL_CUTOFF = (int)s_strtol(str, &endptr, "[3/4] No value for MP_TOOM_MUL_CUTOFF given");
str = endptr + 1;
- TOOM_SQR_CUTOFF = (int)s_strtol(str, &endptr, "[4/4] No value for TOOM_SQR_CUTOFF given");
+ MP_TOOM_SQR_CUTOFF = (int)s_strtol(str, &endptr, "[4/4] No value for MP_TOOM_SQR_CUTOFF given");
break;
case 'h':
s_exit_code = EXIT_SUCCESS;
@@ -448,7 +448,7 @@ int main(int argc, char **argv)
int *cutoff, *update;
uint64_t (*fn)(int size);
} test[] = {
-#define T_MUL_SQR(n, o, f) { #n, &o##_CUTOFF, &(updated.o), MP_HAS(S_MP_##o) ? f : NULL }
+#define T_MUL_SQR(n, o, f) { #n, &MP_##o##_CUTOFF, &(updated.o), MP_HAS(S_MP_##o) ? f : NULL }
/*
The influence of the Comba multiplication cannot be
eradicated programmatically. It depends on the size
@@ -526,15 +526,15 @@ int main(int argc, char **argv)
set_cutoffs(&orig);
if (args.terse == 1) {
printf("%d %d %d %d\n",
- KARATSUBA_MUL_CUTOFF,
- KARATSUBA_SQR_CUTOFF,
- TOOM_MUL_CUTOFF,
- TOOM_SQR_CUTOFF);
+ MP_KARATSUBA_MUL_CUTOFF,
+ MP_KARATSUBA_SQR_CUTOFF,
+ MP_TOOM_MUL_CUTOFF,
+ MP_TOOM_SQR_CUTOFF);
} else {
- printf("KARATSUBA_MUL_CUTOFF = %d\n", KARATSUBA_MUL_CUTOFF);
- printf("KARATSUBA_SQR_CUTOFF = %d\n", KARATSUBA_SQR_CUTOFF);
- printf("TOOM_MUL_CUTOFF = %d\n", TOOM_MUL_CUTOFF);
- printf("TOOM_SQR_CUTOFF = %d\n", TOOM_SQR_CUTOFF);
+ printf("KARATSUBA_MUL_CUTOFF = %d\n", MP_KARATSUBA_MUL_CUTOFF);
+ printf("KARATSUBA_SQR_CUTOFF = %d\n", MP_KARATSUBA_SQR_CUTOFF);
+ printf("TOOM_MUL_CUTOFF = %d\n", MP_TOOM_MUL_CUTOFF);
+ printf("TOOM_SQR_CUTOFF = %d\n", MP_TOOM_SQR_CUTOFF);
}
}
}
diff --git a/mp_cutoffs.c b/mp_cutoffs.c
index 5593b55..46b04ef 100644
--- a/mp_cutoffs.c
+++ b/mp_cutoffs.c
@@ -5,10 +5,10 @@
#ifndef MP_FIXED_CUTOFFS
#include "tommath_cutoffs.h"
-int KARATSUBA_MUL_CUTOFF = MP_DEFAULT_KARATSUBA_MUL_CUTOFF,
- KARATSUBA_SQR_CUTOFF = MP_DEFAULT_KARATSUBA_SQR_CUTOFF,
- TOOM_MUL_CUTOFF = MP_DEFAULT_TOOM_MUL_CUTOFF,
- TOOM_SQR_CUTOFF = MP_DEFAULT_TOOM_SQR_CUTOFF;
+int MP_KARATSUBA_MUL_CUTOFF = MP_DEFAULT_KARATSUBA_MUL_CUTOFF,
+ MP_KARATSUBA_SQR_CUTOFF = MP_DEFAULT_KARATSUBA_SQR_CUTOFF,
+ MP_TOOM_MUL_CUTOFF = MP_DEFAULT_TOOM_MUL_CUTOFF,
+ MP_TOOM_SQR_CUTOFF = MP_DEFAULT_TOOM_SQR_CUTOFF;
#endif
#endif
diff --git a/tommath.h b/tommath.h
index f415a7f..b741674 100644
--- a/tommath.h
+++ b/tommath.h
@@ -122,10 +122,10 @@ typedef enum {
#ifndef MP_FIXED_CUTOFFS
extern int
-KARATSUBA_MUL_CUTOFF,
-KARATSUBA_SQR_CUTOFF,
-TOOM_MUL_CUTOFF,
-TOOM_SQR_CUTOFF;
+MP_KARATSUBA_MUL_CUTOFF,
+MP_KARATSUBA_SQR_CUTOFF,
+MP_TOOM_MUL_CUTOFF,
+MP_TOOM_SQR_CUTOFF;
#endif
/* define this to use lower memory usage routines (exptmods mostly) */
diff --git a/tommath_private.h b/tommath_private.h
index b18663b..f1211a1 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -116,11 +116,6 @@ do { \
# define MP_KARATSUBA_SQR_CUTOFF MP_DEFAULT_KARATSUBA_SQR_CUTOFF
# define MP_TOOM_MUL_CUTOFF MP_DEFAULT_TOOM_MUL_CUTOFF
# define MP_TOOM_SQR_CUTOFF MP_DEFAULT_TOOM_SQR_CUTOFF
-#else
-# define MP_KARATSUBA_MUL_CUTOFF KARATSUBA_MUL_CUTOFF
-# define MP_KARATSUBA_SQR_CUTOFF KARATSUBA_SQR_CUTOFF
-# define MP_TOOM_MUL_CUTOFF TOOM_MUL_CUTOFF
-# define MP_TOOM_SQR_CUTOFF TOOM_SQR_CUTOFF
#endif
/* define heap macros */