aboutsummaryrefslogtreecommitdiff
path: root/tools/tool.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-19 17:45:14 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-19 17:45:14 +0200
commit62d87e063318cc4c842b1b2d8c184f48aeaf6659 (patch)
tree832bf338232c477975bea69f7370ca13f350fb07 /tools/tool.h
parent8b94d135429a9f3253cc7f25a1453b412065c4a0 (diff)
downloadnissy-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.h86
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
12static void log_stderr(const char *, void *); 11static void log_stderr(const char *, void *);
13static double timerun(void (*)(void)); 12static double timerun(void (*)(void));
14static void writetable(const unsigned char *, int64_t, const char *); 13static void writetable(const unsigned char *, int64_t, const char *);
15static long long int generatetable(const char *, unsigned char **, 14static long long int generatetable(const char *, unsigned char **,
16 char [static NISSY_SIZE_DATAID]); 15 char [static NISSY_SIZE_DATAID]);
17static long long int derivetable(
18 const char *, const char *, const char *, unsigned char **);
19static int getdata(const char *, unsigned char **, const char *); 16static int getdata(const char *, unsigned char **, const char *);
20static void gendata_run(const char *, uint64_t[static 21]); 17static void gendata_run(const char *, uint64_t[static 21]);
21static void derivedata_run(
22 const char *, const char *, const char *, const char *);
23 18
24static void 19static void
25log_stderr(const char *str, void *unused) 20log_stderr(const char *str, void *unused)
@@ -100,53 +95,6 @@ generatetable(
100 return gensize; 95 return gensize;
101} 96}
102 97
103static long long int
104derivetable(
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
143derivetable_error:
144 free(fulltable);
145
146derivetable_error_nofree:
147 return gensize;
148}
149
150static int 98static int
151getdata( 99getdata(
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(
219gendata_run_finish: 165gendata_run_finish:
220 free(buf); 166 free(buf);
221} 167}
222
223static void
224derivedata_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
251derivedata_run_finish:
252 free(buf);
253}

Generated with cgit - Back to sebastiano.tronto.net