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/tool.h | |
| 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/tool.h | 86 |
1 files changed, 0 insertions, 86 deletions
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 | } | ||
