aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-08 15:16:21 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-08 15:16:21 +0200
commite4f356b9592599ad91aac34bf2265c9bcdfbb81f (patch)
tree5a95908f9cb9cf5ad7d7802661e1d0c3bc2a0e3a /tools
parentc5a6ff0443fc9e5e890fe72cb13ea78d4fe2bbcb (diff)
downloadnissy-core-e4f356b9592599ad91aac34bf2265c9bcdfbb81f.tar.gz
nissy-core-e4f356b9592599ad91aac34bf2265c9bcdfbb81f.zip
Some minor changes to the interface.
- Simplified logger to accept only a string, not a variadic list of args like printf(). This can still use some improvement, but now it is easier to use from other languages. - Fixed some misuses of the logger (wrong types etc) - Renamed some constants - Fixed some typos in comments.
Diffstat (limited to 'tools')
-rw-r--r--tools/000_gendata/gendata.c2
-rw-r--r--tools/100_checkdata/checkdata.c2
-rw-r--r--tools/300_solve_small/solve_small.c2
-rw-r--r--tools/301_solve_file/solve_file.c2
-rw-r--r--tools/302_solve_multisol/solve_multisol.c2
-rw-r--r--tools/400_solvetest/solve_test.c2
-rw-r--r--tools/nissy_extra.h3
-rw-r--r--tools/tool.h30
8 files changed, 18 insertions, 27 deletions
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c
index 51c2f47..f2ac1a0 100644
--- a/tools/000_gendata/gendata.c
+++ b/tools/000_gendata/gendata.c
@@ -8,7 +8,7 @@ static void
8run(void) { 8run(void) {
9 int64_t size; 9 int64_t size;
10 bool consistent, expected; 10 bool consistent, expected;
11 char *buf, filename[1024], dataid[NISSY_DATAID_SIZE]; 11 char *buf, filename[1024], dataid[NISSY_SIZE_DATAID];
12 12
13 size = generatetable(solver, &buf, dataid); 13 size = generatetable(solver, &buf, dataid);
14 switch (size) { 14 switch (size) {
diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c
index 8bc308c..5b3db2c 100644
--- a/tools/100_checkdata/checkdata.c
+++ b/tools/100_checkdata/checkdata.c
@@ -6,7 +6,7 @@ char *solver, *filename;
6static void 6static void
7run(void) { 7run(void) {
8 long long int size, result; 8 long long int size, result;
9 char *buf, dataid[NISSY_DATAID_SIZE]; 9 char *buf, dataid[NISSY_SIZE_DATAID];
10 FILE *f; 10 FILE *f;
11 11
12 size = nissy_solverinfo(solver, dataid); 12 size = nissy_solverinfo(solver, dataid);
diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c
index 6a1f7b5..bec8add 100644
--- a/tools/300_solve_small/solve_small.c
+++ b/tools/300_solve_small/solve_small.c
@@ -46,7 +46,7 @@ void run(void) {
46} 46}
47 47
48int main(int argc, char **argv) { 48int main(int argc, char **argv) {
49 char filename[255], dataid[NISSY_DATAID_SIZE]; 49 char filename[255], dataid[NISSY_SIZE_DATAID];
50 50
51 if (argc < 2) { 51 if (argc < 2) {
52 printf("Error: not enough arguments. " 52 printf("Error: not enough arguments. "
diff --git a/tools/301_solve_file/solve_file.c b/tools/301_solve_file/solve_file.c
index cefc608..a772e95 100644
--- a/tools/301_solve_file/solve_file.c
+++ b/tools/301_solve_file/solve_file.c
@@ -33,7 +33,7 @@ void run(void) {
33} 33}
34 34
35int main(int argc, char **argv) { 35int main(int argc, char **argv) {
36 char filename[255], dataid[NISSY_DATAID_SIZE], *scrfilename; 36 char filename[255], dataid[NISSY_SIZE_DATAID], *scrfilename;
37 FILE *scrfile; 37 FILE *scrfile;
38 38
39 if (argc < 3) { 39 if (argc < 3) {
diff --git a/tools/302_solve_multisol/solve_multisol.c b/tools/302_solve_multisol/solve_multisol.c
index c6ab685..e933a94 100644
--- a/tools/302_solve_multisol/solve_multisol.c
+++ b/tools/302_solve_multisol/solve_multisol.c
@@ -39,7 +39,7 @@ void run(void) {
39} 39}
40 40
41int main(int argc, char **argv) { 41int main(int argc, char **argv) {
42 char filename[255], dataid[NISSY_DATAID_SIZE]; 42 char filename[255], dataid[NISSY_SIZE_DATAID];
43 43
44 if (argc < 3) { 44 if (argc < 3) {
45 printf("Error: not enough arguments. " 45 printf("Error: not enough arguments. "
diff --git a/tools/400_solvetest/solve_test.c b/tools/400_solvetest/solve_test.c
index a98be26..e881030 100644
--- a/tools/400_solvetest/solve_test.c
+++ b/tools/400_solvetest/solve_test.c
@@ -94,7 +94,7 @@ void run(void) {
94} 94}
95 95
96int main(int argc, char **argv) { 96int main(int argc, char **argv) {
97 char filename[255], dataid[NISSY_DATAID_SIZE]; 97 char filename[255], dataid[NISSY_SIZE_DATAID];
98 98
99 if (argc < 2) { 99 if (argc < 2) {
100 printf("Error: not enough arguments. " 100 printf("Error: not enough arguments. "
diff --git a/tools/nissy_extra.h b/tools/nissy_extra.h
index 1600681..3e9c9ab 100644
--- a/tools/nissy_extra.h
+++ b/tools/nissy_extra.h
@@ -11,6 +11,5 @@ for testing purposes only.
11 11
12size_t gendata_h48_derive(uint8_t, const void *, void *); 12size_t gendata_h48_derive(uint8_t, const void *, void *);
13int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); 13int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]);
14long long int nissy_datainfo( 14long long int nissy_datainfo(uint64_t, const char *, void (*)(const char *));
15 uint64_t, const char *, void (*)(const char *, ...));
16long long int nissy_derivedata(const char *, const void *, void *); 15long long int nissy_derivedata(const char *, const void *, void *);
diff --git a/tools/tool.h b/tools/tool.h
index b65f33a..51301c6 100644
--- a/tools/tool.h
+++ b/tools/tool.h
@@ -9,12 +9,12 @@
9#include "../src/nissy.h" 9#include "../src/nissy.h"
10#include "nissy_extra.h" 10#include "nissy_extra.h"
11 11
12static void log_stderr(const char *, ...); 12static void log_stderr(const char *);
13static void log_stdout(const char *, ...); 13static void log_stdout(const char *);
14static double timerun(void (*)(void)); 14static double timerun(void (*)(void));
15static void writetable(const char *, int64_t, const char *); 15static void writetable(const char *, int64_t, const char *);
16static long long int generatetable(const char *, char **, 16static long long int generatetable(const char *, char **,
17 char [static NISSY_DATAID_SIZE]); 17 char [static NISSY_SIZE_DATAID]);
18static long long int derivetable( 18static long long int derivetable(
19 const char *, const char *, const char *, char **); 19 const char *, const char *, const char *, char **);
20static int getdata(const char *, char **, const char *); 20static int getdata(const char *, char **, const char *);
@@ -23,23 +23,15 @@ static void derivedata_run(
23 const char *, const char *, const char *, const char *); 23 const char *, const char *, const char *, const char *);
24 24
25static void 25static void
26log_stderr(const char *str, ...) 26log_stderr(const char *str)
27{ 27{
28 va_list args; 28 fprintf(stderr, "%s", str);
29
30 va_start(args, str);
31 vfprintf(stderr, str, args);
32 va_end(args);
33} 29}
34 30
35static void 31static void
36write_stdout(const char *str, ...) 32write_stdout(const char *str)
37{ 33{
38 va_list args; 34 fprintf(stdout, "%s", str);
39
40 va_start(args, str);
41 vfprintf(stdout, str, args);
42 va_end(args);
43} 35}
44 36
45static double 37static double
@@ -90,7 +82,7 @@ static long long int
90generatetable( 82generatetable(
91 const char *solver, 83 const char *solver,
92 char **buf, 84 char **buf,
93 char dataid[static NISSY_DATAID_SIZE] 85 char dataid[static NISSY_SIZE_DATAID]
94) 86)
95{ 87{
96 long long int size, gensize; 88 long long int size, gensize;
@@ -125,7 +117,7 @@ derivetable(
125{ 117{
126 uint8_t h, k; 118 uint8_t h, k;
127 long long int size, gensize; 119 long long int size, gensize;
128 char *fulltable, dataid[NISSY_DATAID_SIZE]; 120 char *fulltable, dataid[NISSY_SIZE_DATAID];
129 121
130 if (getdata(solver_large, &fulltable, filename_large) != 0) { 122 if (getdata(solver_large, &fulltable, filename_large) != 0) {
131 printf("Error reading full table.\n"); 123 printf("Error reading full table.\n");
@@ -169,7 +161,7 @@ getdata(
169) { 161) {
170 long long int size, sizeread; 162 long long int size, sizeread;
171 FILE *f; 163 FILE *f;
172 char dataid[NISSY_DATAID_SIZE]; 164 char dataid[NISSY_SIZE_DATAID];
173 165
174 if ((f = fopen(filename, "rb")) == NULL) { 166 if ((f = fopen(filename, "rb")) == NULL) {
175 printf("Table file not found, generating it.\n"); 167 printf("Table file not found, generating it.\n");
@@ -209,7 +201,7 @@ gendata_run(
209 uint64_t expected[static 21] 201 uint64_t expected[static 21]
210) { 202) {
211 long long int size; 203 long long int size;
212 char *buf, filename[1024], dataid[NISSY_DATAID_SIZE]; 204 char *buf, filename[1024], dataid[NISSY_SIZE_DATAID];
213 205
214 size = generatetable(solver, &buf, dataid); 206 size = generatetable(solver, &buf, dataid);
215 sprintf(filename, "tables/%s", dataid); 207 sprintf(filename, "tables/%s", dataid);

Generated with cgit - Back to sebastiano.tronto.net