diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-05-19 17:45:14 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-05-19 17:45:14 +0200 |
| commit | 62d87e063318cc4c842b1b2d8c184f48aeaf6659 (patch) | |
| tree | 832bf338232c477975bea69f7370ca13f350fb07 /tools | |
| parent | 8b94d135429a9f3253cc7f25a1453b412065c4a0 (diff) | |
| download | nissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.tar.gz nissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.zip | |
Refactored checkdata
Relevant changes include:
- Changed the signature of nissy_checkdata().
- Removed expected_distribution.h from tools; this data is now included
in each solver's src/ code.
- Removed distribution check for cocsep; may add back later.
Diffstat (limited to '')
| -rw-r--r-- | tools/000_gendata/gendata.c | 21 | ||||
| -rw-r--r-- | tools/001_derive_h48/derive_h48.c | 40 | ||||
| -rw-r--r-- | tools/100_checkdata/checkdata.c | 10 | ||||
| -rw-r--r-- | tools/expected_distributions.h | 267 | ||||
| -rw-r--r-- | tools/nissy_extra.h | 14 | ||||
| -rw-r--r-- | tools/tool.h | 86 |
6 files changed, 9 insertions, 429 deletions
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c index 66c4864..f2da890 100644 --- a/tools/000_gendata/gendata.c +++ b/tools/000_gendata/gendata.c | |||
| @@ -1,13 +1,10 @@ | |||
| 1 | #include "../tool.h" | 1 | #include "../tool.h" |
| 2 | #include "../expected_distributions.h" | ||
| 3 | 2 | ||
| 4 | char *solver; | 3 | char *solver; |
| 5 | uint64_t *expected; | ||
| 6 | 4 | ||
| 7 | static void | 5 | static void |
| 8 | run(void) { | 6 | run(void) { |
| 9 | int64_t size; | 7 | int64_t size; |
| 10 | bool consistent, expected; | ||
| 11 | char filename[1024], dataid[NISSY_SIZE_DATAID]; | 8 | char filename[1024], dataid[NISSY_SIZE_DATAID]; |
| 12 | unsigned char *buf; | 9 | unsigned char *buf; |
| 13 | 10 | ||
| @@ -18,20 +15,14 @@ run(void) { | |||
| 18 | case -2: | 15 | case -2: |
| 19 | goto gendata_run_finish; | 16 | goto gendata_run_finish; |
| 20 | default: | 17 | default: |
| 21 | nissy_datainfo(size, buf); | 18 | if (nissy_checkdata(solver, size, buf) == NISSY_OK) { |
| 22 | consistent = nissy_checkdata(size, buf) == 0; | ||
| 23 | expected = check_distribution(solver, size, buf); | ||
| 24 | if (consistent && expected) { | ||
| 25 | printf("\n"); | 19 | printf("\n"); |
| 26 | printf("Generated %" PRId64 " bytes.\n", size); | 20 | printf("Generated %" PRId64 " bytes.\n", size); |
| 27 | sprintf(filename, "tables/%s", dataid); | 21 | sprintf(filename, "tables/%s", dataid); |
| 28 | writetable(buf, size, filename); | 22 | writetable(buf, size, filename); |
| 23 | } else { | ||
| 24 | printf("Error: table generated incorrectly!\n"); | ||
| 29 | } | 25 | } |
| 30 | if (!consistent) | ||
| 31 | printf("Error: table is not consistent with info" | ||
| 32 | " (nissy_checkdata() failed)\n"); | ||
| 33 | if (!expected) | ||
| 34 | printf("Error: distribution is not as expected\n"); | ||
| 35 | break; | 26 | break; |
| 36 | } | 27 | } |
| 37 | 28 | ||
| @@ -40,8 +31,6 @@ gendata_run_finish: | |||
| 40 | } | 31 | } |
| 41 | 32 | ||
| 42 | int main(int argc, char **argv) { | 33 | int main(int argc, char **argv) { |
| 43 | uint8_t h, k; | ||
| 44 | |||
| 45 | if (argc < 2) { | 34 | if (argc < 2) { |
| 46 | printf("Error: not enough arguments. " | 35 | printf("Error: not enough arguments. " |
| 47 | "A solver must be given.\n"); | 36 | "A solver must be given.\n"); |
| @@ -49,11 +38,7 @@ int main(int argc, char **argv) { | |||
| 49 | } | 38 | } |
| 50 | 39 | ||
| 51 | solver = argv[1]; | 40 | solver = argv[1]; |
| 52 | parse_h48_hk(solver, &h, &k); | ||
| 53 | expected = expected_h48[h][k]; | ||
| 54 | |||
| 55 | nissy_setlogger(log_stderr, NULL); | 41 | nissy_setlogger(log_stderr, NULL); |
| 56 | |||
| 57 | timerun(run); | 42 | timerun(run); |
| 58 | 43 | ||
| 59 | return 0; | 44 | return 0; |
diff --git a/tools/001_derive_h48/derive_h48.c b/tools/001_derive_h48/derive_h48.c deleted file mode 100644 index e8db207..0000000 --- a/tools/001_derive_h48/derive_h48.c +++ /dev/null | |||
| @@ -1,40 +0,0 @@ | |||
| 1 | /* | ||
| 2 | This tool is specific to the H48 solver. It can be used to derive small | ||
| 3 | intermediate tables from larger tables, including the full h11 table. | ||
| 4 | |||
| 5 | When using k=2, the base values for the tables may differ. If you want | ||
| 6 | to change this value, for example for generating a table with base = 9 | ||
| 7 | from the h11 table with base = 10, you must re-generate the large table | ||
| 8 | with the correct base value. The easiest way to do so is to manually | ||
| 9 | edit the base value in the source code and recompile. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include "../tool.h" | ||
| 13 | |||
| 14 | char *solver_large, *solver_small, *filename_large, *filename_small; | ||
| 15 | |||
| 16 | void run(void) { | ||
| 17 | derivedata_run(solver_large, solver_small, filename_large, filename_small); | ||
| 18 | } | ||
| 19 | |||
| 20 | int main(int argc, char **argv) { | ||
| 21 | if (argc < 5) { | ||
| 22 | printf("Error: not enough arguments. Required:\n" | ||
| 23 | "1. Solver name for large table\n" | ||
| 24 | "2. Solver name for derived table\n" | ||
| 25 | "3. Filename containing large table\n" | ||
| 26 | "4. Filename for saving derived table\n"); | ||
| 27 | return 1; | ||
| 28 | } | ||
| 29 | |||
| 30 | solver_large = argv[1]; | ||
| 31 | solver_small = argv[2]; | ||
| 32 | filename_large = argv[3]; | ||
| 33 | filename_small = argv[4]; | ||
| 34 | |||
| 35 | nissy_setlogger(log_stderr, NULL); | ||
| 36 | |||
| 37 | timerun(run); | ||
| 38 | |||
| 39 | return 0; | ||
| 40 | } | ||
diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c index c284aa4..3a3c098 100644 --- a/tools/100_checkdata/checkdata.c +++ b/tools/100_checkdata/checkdata.c | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | #include "../tool.h" | 1 | #include "../tool.h" |
| 2 | #include "../expected_distributions.h" | ||
| 3 | 2 | ||
| 4 | char *solver, *filename; | 3 | char *solver, *filename; |
| 5 | 4 | ||
| 6 | static void | 5 | static void |
| 7 | run(void) { | 6 | run(void) { |
| 8 | long long int size, sizeread, result; | 7 | bool result; |
| 8 | long long int size, sizeread; | ||
| 9 | char dataid[NISSY_SIZE_DATAID]; | 9 | char dataid[NISSY_SIZE_DATAID]; |
| 10 | unsigned char *buf; | 10 | unsigned char *buf; |
| 11 | FILE *f; | 11 | FILE *f; |
| @@ -25,10 +25,12 @@ run(void) { | |||
| 25 | buf = malloc(size); | 25 | buf = malloc(size); |
| 26 | sizeread = fread(buf, size, 1, f); | 26 | sizeread = fread(buf, size, 1, f); |
| 27 | fclose(f); | 27 | fclose(f); |
| 28 | result = sizeread == 1 && nissy_checkdata(size, buf); | 28 | if (sizeread != 1) |
| 29 | printf("File has unexpected size\n"); | ||
| 30 | result = sizeread == 1 && nissy_checkdata(solver, size, buf) == NISSY_OK; | ||
| 29 | free(buf); | 31 | free(buf); |
| 30 | 32 | ||
| 31 | printf("checkdata %s\n", result == 0 ? "succeeded" : "failed"); | 33 | printf("checkdata %s\n", result ? "succeeded" : "failed"); |
| 32 | 34 | ||
| 33 | /* TODO: cross-check with expected distributions? */ | 35 | /* TODO: cross-check with expected distributions? */ |
| 34 | } | 36 | } |
diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h deleted file mode 100644 index 1193fb3..0000000 --- a/tools/expected_distributions.h +++ /dev/null | |||
| @@ -1,267 +0,0 @@ | |||
| 1 | uint64_t expected_cocsep[21] = { | ||
| 2 | [0] = 1, | ||
| 3 | [1] = 6, | ||
| 4 | [2] = 63, | ||
| 5 | [3] = 468, | ||
| 6 | [4] = 3068, | ||
| 7 | [5] = 15438, | ||
| 8 | [6] = 53814, | ||
| 9 | [7] = 71352, | ||
| 10 | [8] = 8784, | ||
| 11 | [9] = 96 | ||
| 12 | }; | ||
| 13 | |||
| 14 | uint64_t expected_h48[12][9][21] = { | ||
| 15 | [0] = { | ||
| 16 | [2] = { | ||
| 17 | [0] = 5473562, | ||
| 18 | [1] = 34776317, | ||
| 19 | [2] = 68566704, | ||
| 20 | [3] = 8750867, | ||
| 21 | }, | ||
| 22 | [4] = { | ||
| 23 | [0] = 1, | ||
| 24 | [1] = 1, | ||
| 25 | [2] = 4, | ||
| 26 | [3] = 34, | ||
| 27 | [4] = 331, | ||
| 28 | [5] = 3612, | ||
| 29 | [6] = 41605, | ||
| 30 | [7] = 474128, | ||
| 31 | [8] = 4953846, | ||
| 32 | [9] = 34776317, | ||
| 33 | [10] = 68566704, | ||
| 34 | [11] = 8749194, | ||
| 35 | [12] = 1673, | ||
| 36 | }, | ||
| 37 | }, | ||
| 38 | [1] = { | ||
| 39 | [2] = { | ||
| 40 | [0] = 6012079, | ||
| 41 | [1] = 45822302, | ||
| 42 | [2] = 142018732, | ||
| 43 | [3] = 41281787, | ||
| 44 | }, | ||
| 45 | }, | ||
| 46 | [2] = { | ||
| 47 | [2] = { | ||
| 48 | [0] = 6391286, | ||
| 49 | [1] = 55494785, | ||
| 50 | [2] = 252389935, | ||
| 51 | [3] = 155993794, | ||
| 52 | }, | ||
| 53 | }, | ||
| 54 | [3] = { | ||
| 55 | [2] = { | ||
| 56 | [0] = 6686828, | ||
| 57 | [1] = 63867852, | ||
| 58 | [2] = 392789689, | ||
| 59 | [3] = 477195231, | ||
| 60 | }, | ||
| 61 | }, | ||
| 62 | [4] = { | ||
| 63 | [2] = { | ||
| 64 | [0] = 77147213, | ||
| 65 | [1] = 543379415, | ||
| 66 | [2] = 1139570251, | ||
| 67 | [3] = 120982321, | ||
| 68 | }, | ||
| 69 | }, | ||
| 70 | [5] = { | ||
| 71 | [2] = { | ||
| 72 | [0] = 82471284, | ||
| 73 | [1] = 687850732, | ||
| 74 | [2] = 2345840746, | ||
| 75 | [3] = 645995638, | ||
| 76 | }, | ||
| 77 | }, | ||
| 78 | [6] = { | ||
| 79 | [2] = { | ||
| 80 | [0] = 85941099, | ||
| 81 | [1] = 804752968, | ||
| 82 | [2] = 4077248182, | ||
| 83 | [3] = 2556374551, | ||
| 84 | }, | ||
| 85 | }, | ||
| 86 | [7] = { | ||
| 87 | [2] = { | ||
| 88 | [0] = 88529761, | ||
| 89 | [1] = 897323475, | ||
| 90 | [2] = 6126260791, | ||
| 91 | [3] = 7936519573, | ||
| 92 | }, | ||
| 93 | }, | ||
| 94 | [8] = { | ||
| 95 | [2] = { | ||
| 96 | [0] = 1051579940, | ||
| 97 | [1] = 8136021316, | ||
| 98 | [2] = 19024479822, | ||
| 99 | [3] = 18851861220, | ||
| 100 | }, | ||
| 101 | }, | ||
| 102 | [9] = { | ||
| 103 | [2] = { | ||
| 104 | [0] = 1102038189, | ||
| 105 | [1] = 9888265242, | ||
| 106 | [2] = 38299375805, | ||
| 107 | [3] = 10904855164, | ||
| 108 | }, | ||
| 109 | }, | ||
| 110 | [10] = { | ||
| 111 | [2] = { | ||
| 112 | [0] = 1133240039, | ||
| 113 | [1] = 11196285614, | ||
| 114 | [2] = 64164702961, | ||
| 115 | [3] = 43894840186, | ||
| 116 | }, | ||
| 117 | }, | ||
| 118 | [11] = { | ||
| 119 | [2] = { | ||
| 120 | [0] = 1150763161, | ||
| 121 | [1] = 12045845660, | ||
| 122 | [2] = 91163433330, | ||
| 123 | [3] = 136418095449, | ||
| 124 | }, | ||
| 125 | }, | ||
| 126 | }; | ||
| 127 | |||
| 128 | uint64_t expected_eo[21] = { | ||
| 129 | [0] = 1, | ||
| 130 | [1] = 2, | ||
| 131 | [2] = 25, | ||
| 132 | [3] = 202, | ||
| 133 | [4] = 620, | ||
| 134 | [5] = 900, | ||
| 135 | [6] = 285, | ||
| 136 | [7] = 13, | ||
| 137 | }; | ||
| 138 | |||
| 139 | uint64_t expected_dr[21] = { | ||
| 140 | [0] = 1, | ||
| 141 | [1] = 1, | ||
| 142 | [2] = 5, | ||
| 143 | [3] = 44, | ||
| 144 | [4] = 487, | ||
| 145 | [5] = 5841, | ||
| 146 | [6] = 68364, | ||
| 147 | [7] = 776568, | ||
| 148 | [8] = 7950748, | ||
| 149 | [9] = 52098876, | ||
| 150 | [10] = 76236234, | ||
| 151 | [11] = 3771112, | ||
| 152 | [12] = 129, | ||
| 153 | }; | ||
| 154 | |||
| 155 | uint64_t expected_dreo[21] = { | ||
| 156 | [0] = 1, | ||
| 157 | [1] = 1, | ||
| 158 | [2] = 4, | ||
| 159 | [3] = 22, | ||
| 160 | [4] = 160, | ||
| 161 | [5] = 1286, | ||
| 162 | [6] = 8550, | ||
| 163 | [7] = 42152, | ||
| 164 | [8] = 90748, | ||
| 165 | [9] = 33466, | ||
| 166 | [10] = 757, | ||
| 167 | }; | ||
| 168 | |||
| 169 | static bool | ||
| 170 | distribution_equal(const uint64_t *expected, const uint64_t *actual, int n) | ||
| 171 | { | ||
| 172 | bool equal; | ||
| 173 | int i; | ||
| 174 | |||
| 175 | for (i = 0, equal = true; i <= n; i++) { | ||
| 176 | if (expected[i] != actual[i]) { | ||
| 177 | equal = false; | ||
| 178 | printf("Wrong value for %d: expected %" PRIu64 | ||
| 179 | ", actual %" PRIu64 "\n", | ||
| 180 | i, expected[i], actual[i]); | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | return equal; | ||
| 185 | } | ||
| 186 | |||
| 187 | STATIC bool | ||
| 188 | check_table(uint64_t *exp, tableinfo_t *info) | ||
| 189 | { | ||
| 190 | if (!distribution_equal(exp, info->distribution, info->maxvalue)) { | ||
| 191 | printf("ERROR! Distribution is incorrect\n"); | ||
| 192 | return false; | ||
| 193 | } | ||
| 194 | |||
| 195 | printf("Distribution is correct\n"); | ||
| 196 | return true; | ||
| 197 | } | ||
| 198 | |||
| 199 | static bool | ||
| 200 | check_cocsep(size_t data_size, const unsigned char *data) | ||
| 201 | { | ||
| 202 | tableinfo_t info; | ||
| 203 | |||
| 204 | readtableinfo(data_size, data, &info); | ||
| 205 | return distribution_equal( | ||
| 206 | expected_cocsep, info.distribution, info.maxvalue); | ||
| 207 | } | ||
| 208 | |||
| 209 | static bool | ||
| 210 | unknown_h48(uint8_t h, uint8_t k) | ||
| 211 | { | ||
| 212 | if (k != 2 && k != 4) | ||
| 213 | return true; | ||
| 214 | |||
| 215 | if (k == 4 && h != 0) | ||
| 216 | return true; | ||
| 217 | |||
| 218 | return k == 2 && h > 7; | ||
| 219 | } | ||
| 220 | |||
| 221 | STATIC bool | ||
| 222 | check_distribution( | ||
| 223 | const char *solver, | ||
| 224 | size_t data_size, | ||
| 225 | const unsigned char *data | ||
| 226 | ) | ||
| 227 | { | ||
| 228 | const char *str; | ||
| 229 | tableinfo_t info = {0}; | ||
| 230 | |||
| 231 | if (!strncmp(solver, "h48", 3)) { | ||
| 232 | readtableinfo(data_size, data, &info); | ||
| 233 | if (!distribution_equal( | ||
| 234 | expected_cocsep, info.distribution, info.maxvalue)) { | ||
| 235 | printf("ERROR! cocsep distribution is incorrect\n"); | ||
| 236 | return false; | ||
| 237 | } | ||
| 238 | printf("cocsep distribution is correct\n"); | ||
| 239 | |||
| 240 | readtableinfo_n(data_size, data, 2, &info); | ||
| 241 | if (unknown_h48(info.h48h, info.bits)) | ||
| 242 | goto check_distribution_unknown; | ||
| 243 | |||
| 244 | return check_table(expected_h48[info.h48h][info.bits], &info); | ||
| 245 | } | ||
| 246 | |||
| 247 | if (!strncmp(solver, "coord_", 6)) { | ||
| 248 | readtableinfo(data_size, data, &info); | ||
| 249 | if (!strncmp(info.solver, "coord helper table for ", 23)) | ||
| 250 | readtableinfo_n(data_size, data, 2, &info); | ||
| 251 | |||
| 252 | str = info.solver + 22; /* "coordinate solver for COORD" */ | ||
| 253 | if (!strcmp(str, "EO")) { | ||
| 254 | return check_table(expected_eo, &info); | ||
| 255 | } else if (!strcmp(str, "DR")) { | ||
| 256 | return check_table(expected_dr, &info); | ||
| 257 | } else if (!strcmp(str, "DREO")) { | ||
| 258 | return check_table(expected_dreo, &info); | ||
| 259 | } else { | ||
| 260 | goto check_distribution_unknown; | ||
| 261 | } | ||
| 262 | } | ||
| 263 | |||
| 264 | check_distribution_unknown: | ||
| 265 | printf("Distribution unknown, not checked\n"); | ||
| 266 | return true; | ||
| 267 | } | ||
diff --git a/tools/nissy_extra.h b/tools/nissy_extra.h deleted file mode 100644 index 9a7df50..0000000 --- a/tools/nissy_extra.h +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | /* | ||
| 2 | This header file exposes certain functions that are meant to be used | ||
| 3 | for testing purposes only. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #define STATIC static | ||
| 7 | #define LOG printf | ||
| 8 | |||
| 9 | #include "../src/solvers/tables_types_macros.h" | ||
| 10 | #include "../src/solvers/tables.h" | ||
| 11 | |||
| 12 | size_t gendata_h48_derive(uint8_t, const unsigned char *, unsigned char *); | ||
| 13 | long long parse_h48_hk(const char *, uint8_t [static 1], uint8_t [static 1]); | ||
| 14 | long long int nissy_datainfo(uint64_t, const unsigned char *); | ||
diff --git a/tools/tool.h b/tools/tool.h index 225f789..9c55d2b 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -7,19 +7,14 @@ | |||
| 7 | #include <string.h> | 7 | #include <string.h> |
| 8 | 8 | ||
| 9 | #include "../src/nissy.h" | 9 | #include "../src/nissy.h" |
| 10 | #include "nissy_extra.h" | ||
| 11 | 10 | ||
| 12 | static void log_stderr(const char *, void *); | 11 | static void log_stderr(const char *, void *); |
| 13 | static double timerun(void (*)(void)); | 12 | static double timerun(void (*)(void)); |
| 14 | static void writetable(const unsigned char *, int64_t, const char *); | 13 | static void writetable(const unsigned char *, int64_t, const char *); |
| 15 | static long long int generatetable(const char *, unsigned char **, | 14 | static long long int generatetable(const char *, unsigned char **, |
| 16 | char [static NISSY_SIZE_DATAID]); | 15 | char [static NISSY_SIZE_DATAID]); |
| 17 | static long long int derivetable( | ||
| 18 | const char *, const char *, const char *, unsigned char **); | ||
| 19 | static int getdata(const char *, unsigned char **, const char *); | 16 | static int getdata(const char *, unsigned char **, const char *); |
| 20 | static void gendata_run(const char *, uint64_t[static 21]); | 17 | static void gendata_run(const char *, uint64_t[static 21]); |
| 21 | static void derivedata_run( | ||
| 22 | const char *, const char *, const char *, const char *); | ||
| 23 | 18 | ||
| 24 | static void | 19 | static void |
| 25 | log_stderr(const char *str, void *unused) | 20 | log_stderr(const char *str, void *unused) |
| @@ -100,53 +95,6 @@ generatetable( | |||
| 100 | return gensize; | 95 | return gensize; |
| 101 | } | 96 | } |
| 102 | 97 | ||
| 103 | static long long int | ||
| 104 | derivetable( | ||
| 105 | const char *solver_large, | ||
| 106 | const char *solver_small, | ||
| 107 | const char *filename_large, | ||
| 108 | unsigned char **buf | ||
| 109 | ) | ||
| 110 | { | ||
| 111 | uint8_t h, k; | ||
| 112 | long long int size, gensize; | ||
| 113 | char dataid[NISSY_SIZE_DATAID]; | ||
| 114 | unsigned char *fulltable; | ||
| 115 | |||
| 116 | if (getdata(solver_large, &fulltable, filename_large) != 0) { | ||
| 117 | printf("Error reading full table.\n"); | ||
| 118 | gensize = -1; | ||
| 119 | goto derivetable_error_nofree; | ||
| 120 | } | ||
| 121 | |||
| 122 | size = nissy_solverinfo(solver_small, dataid); | ||
| 123 | if (size == -1) { | ||
| 124 | printf("Error getting table size.\n"); | ||
| 125 | gensize = -2; | ||
| 126 | goto derivetable_error; | ||
| 127 | } | ||
| 128 | |||
| 129 | if (parse_h48_hk(solver_small, &h, &k) != NISSY_OK) { | ||
| 130 | gensize = -3; | ||
| 131 | goto derivetable_error; | ||
| 132 | } | ||
| 133 | |||
| 134 | *buf = malloc(size); | ||
| 135 | gensize = gendata_h48_derive(h, fulltable, *buf); | ||
| 136 | |||
| 137 | if (gensize != size) { | ||
| 138 | printf("Error deriving table\n"); | ||
| 139 | gensize = -4; | ||
| 140 | goto derivetable_error; | ||
| 141 | } | ||
| 142 | |||
| 143 | derivetable_error: | ||
| 144 | free(fulltable); | ||
| 145 | |||
| 146 | derivetable_error_nofree: | ||
| 147 | return gensize; | ||
| 148 | } | ||
| 149 | |||
| 150 | static int | 98 | static int |
| 151 | getdata( | 99 | getdata( |
| 152 | const char *solver, | 100 | const char *solver, |
| @@ -206,8 +154,6 @@ gendata_run( | |||
| 206 | case -2: | 154 | case -2: |
| 207 | goto gendata_run_finish; | 155 | goto gendata_run_finish; |
| 208 | default: | 156 | default: |
| 209 | nissy_datainfo(size, buf); | ||
| 210 | printf("\n"); | ||
| 211 | printf("Succesfully generated %lld bytes. " | 157 | printf("Succesfully generated %lld bytes. " |
| 212 | "See above for details on the tables.\n", size); | 158 | "See above for details on the tables.\n", size); |
| 213 | 159 | ||
| @@ -219,35 +165,3 @@ gendata_run( | |||
| 219 | gendata_run_finish: | 165 | gendata_run_finish: |
| 220 | free(buf); | 166 | free(buf); |
| 221 | } | 167 | } |
| 222 | |||
| 223 | static void | ||
| 224 | derivedata_run( | ||
| 225 | const char *solver_large, | ||
| 226 | const char *solver_small, | ||
| 227 | const char *filename_large, | ||
| 228 | const char *filename_small | ||
| 229 | ) | ||
| 230 | { | ||
| 231 | long long int size; | ||
| 232 | unsigned char *buf; | ||
| 233 | |||
| 234 | buf = NULL; | ||
| 235 | size = derivetable(solver_large, solver_small, filename_large, &buf); | ||
| 236 | switch (size) { | ||
| 237 | case -1: | ||
| 238 | return; | ||
| 239 | case -2: | ||
| 240 | goto derivedata_run_finish; | ||
| 241 | default: | ||
| 242 | nissy_datainfo(size, buf); | ||
| 243 | printf("\n"); | ||
| 244 | printf("Succesfully generated %lld bytes. " | ||
| 245 | "See above for details on the tables.\n", size); | ||
| 246 | |||
| 247 | writetable(buf, size, filename_small); | ||
| 248 | break; | ||
| 249 | } | ||
| 250 | |||
| 251 | derivedata_run_finish: | ||
| 252 | free(buf); | ||
| 253 | } | ||
