aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-03-25 18:35:47 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-03-25 18:35:47 +0100
commit56048d13b73ec6e6a9c59d62e82f41e69a3994bd (patch)
tree49fc5d50e739a399897425756c08a73ba5924ddb /src
parent0f4931c8de298b0f97aba1757c9538f48adb30c6 (diff)
downloadnissy-core-56048d13b73ec6e6a9c59d62e82f41e69a3994bd.tar.gz
nissy-core-56048d13b73ec6e6a9c59d62e82f41e69a3994bd.zip
More safety with pointers using VLA function parameters
Diffstat (limited to '')
-rw-r--r--src/arch/avx2.h8
-rw-r--r--src/arch/common.h8
-rw-r--r--src/arch/neon.h8
-rw-r--r--src/arch/portable.h8
-rw-r--r--src/core/cube.h2
-rw-r--r--src/nissy.c6
-rw-r--r--src/solvers/coord/gendata.h32
-rw-r--r--src/solvers/coord/utils.h3
-rw-r--r--src/solvers/h48/coordinate.h21
-rw-r--r--src/solvers/h48/coordinate_types_macros.h (renamed from src/solvers/h48/coordinate_macros.h)0
-rw-r--r--src/solvers/h48/gendata_cocsep.h39
-rw-r--r--src/solvers/h48/gendata_eoesep.h17
-rw-r--r--src/solvers/h48/gendata_h48.h61
-rw-r--r--src/solvers/h48/gendata_types_macros.h2
-rw-r--r--src/solvers/h48/h48.h4
-rw-r--r--src/solvers/h48/map.h31
-rw-r--r--src/solvers/h48/solve.h18
-rw-r--r--src/solvers/tables.h49
18 files changed, 170 insertions, 147 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index b6ff510..ebcf84f 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -23,7 +23,7 @@ popcount_u32(uint32_t x)
23} 23}
24 24
25STATIC void 25STATIC void
26pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 26pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12])
27{ 27{
28 uint8_t aux[32]; 28 uint8_t aux[32];
29 29
@@ -252,19 +252,19 @@ coord_esep(cube_t c)
252} 252}
253 253
254STATIC_INLINE void 254STATIC_INLINE void
255copy_corners(cube_t *dest, cube_t src) 255copy_corners(cube_t dest[static 1], cube_t src)
256{ 256{
257 *dest = _mm256_blend_epi32(*dest, src, 0x0F); 257 *dest = _mm256_blend_epi32(*dest, src, 0x0F);
258} 258}
259 259
260STATIC_INLINE void 260STATIC_INLINE void
261copy_edges(cube_t *dest, cube_t src) 261copy_edges(cube_t dest[static 1], cube_t src)
262{ 262{
263 *dest = _mm256_blend_epi32(*dest, src, 0xF0); 263 *dest = _mm256_blend_epi32(*dest, src, 0xF0);
264} 264}
265 265
266STATIC_INLINE void 266STATIC_INLINE void
267set_eo(cube_t *cube, int64_t eo) 267set_eo(cube_t cube[static 1], int64_t eo)
268{ 268{
269 int64_t eo12, eotop, eobot; 269 int64_t eo12, eotop, eobot;
270 __m256i veo; 270 __m256i veo;
diff --git a/src/arch/common.h b/src/arch/common.h
index 52e0fc7..5c1efde 100644
--- a/src/arch/common.h
+++ b/src/arch/common.h
@@ -1,6 +1,6 @@
1STATIC_INLINE int popcount_u32(uint32_t); 1STATIC_INLINE int popcount_u32(uint32_t);
2 2
3STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); 3STATIC void pieces(cube_t [static 1], uint8_t [static 8], uint8_t [static 12]);
4STATIC_INLINE bool equal(cube_t, cube_t); 4STATIC_INLINE bool equal(cube_t, cube_t);
5STATIC_INLINE cube_t invertco(cube_t); 5STATIC_INLINE cube_t invertco(cube_t);
6STATIC_INLINE cube_t compose_edges(cube_t, cube_t); 6STATIC_INLINE cube_t compose_edges(cube_t, cube_t);
@@ -14,9 +14,9 @@ STATIC_INLINE int64_t coord_cocsep(cube_t);
14STATIC_INLINE int64_t coord_eo(cube_t); 14STATIC_INLINE int64_t coord_eo(cube_t);
15STATIC_INLINE int64_t coord_esep(cube_t); 15STATIC_INLINE int64_t coord_esep(cube_t);
16 16
17STATIC_INLINE void copy_corners(cube_t *, cube_t); 17STATIC_INLINE void copy_corners(cube_t [static 1], cube_t);
18STATIC_INLINE void copy_edges(cube_t *, cube_t); 18STATIC_INLINE void copy_edges(cube_t [static 1], cube_t);
19STATIC_INLINE void set_eo(cube_t *, int64_t); 19STATIC_INLINE void set_eo(cube_t [static 1], int64_t);
20STATIC_INLINE cube_t invcoord_esep(int64_t); 20STATIC_INLINE cube_t invcoord_esep(int64_t);
21 21
22STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); 22STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]);
diff --git a/src/arch/neon.h b/src/arch/neon.h
index 19f6f9d..d5f5f8b 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -39,7 +39,7 @@ popcount_u32(uint32_t x)
39} 39}
40 40
41STATIC void 41STATIC void
42pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 42pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12])
43{ 43{
44 // First 8 bytes of the corner vector are copied from the c array 44 // First 8 bytes of the corner vector are copied from the c array
45 vst1_u8(c, cube->corner); 45 vst1_u8(c, cube->corner);
@@ -287,19 +287,19 @@ coord_esep(cube_t c)
287} 287}
288 288
289STATIC_INLINE void 289STATIC_INLINE void
290copy_corners(cube_t *dst, cube_t src) 290copy_corners(cube_t dst[static 1], cube_t src)
291{ 291{
292 dst->corner = src.corner; 292 dst->corner = src.corner;
293} 293}
294 294
295STATIC_INLINE void 295STATIC_INLINE void
296copy_edges(cube_t *dst, cube_t src) 296copy_edges(cube_t dst[static 1], cube_t src)
297{ 297{
298 dst->edge = src.edge; 298 dst->edge = src.edge;
299} 299}
300 300
301STATIC_INLINE void 301STATIC_INLINE void
302set_eo(cube_t *cube, int64_t eo) 302set_eo(cube_t cube[static 1], int64_t eo)
303{ 303{
304 // Temp array to store the NEON vector 304 // Temp array to store the NEON vector
305 uint8_t mem[16]; 305 uint8_t mem[16];
diff --git a/src/arch/portable.h b/src/arch/portable.h
index b8c5211..4ac5fe7 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -22,7 +22,7 @@ popcount_u32(uint32_t x)
22} 22}
23 23
24STATIC void 24STATIC void
25pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 25pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12])
26{ 26{
27 memcpy(c, cube->corner, 8); 27 memcpy(c, cube->corner, 8);
28 memcpy(e, cube->edge, 12); 28 memcpy(e, cube->edge, 12);
@@ -227,19 +227,19 @@ coord_esep(cube_t c)
227} 227}
228 228
229STATIC_INLINE void 229STATIC_INLINE void
230copy_corners(cube_t *dest, cube_t src) 230copy_corners(cube_t dest[static 1], cube_t src)
231{ 231{
232 memcpy(&dest->corner, src.corner, sizeof(src.corner)); 232 memcpy(&dest->corner, src.corner, sizeof(src.corner));
233} 233}
234 234
235STATIC_INLINE void 235STATIC_INLINE void
236copy_edges(cube_t *dest, cube_t src) 236copy_edges(cube_t dest[static 1], cube_t src)
237{ 237{
238 memcpy(&dest->edge, src.edge, sizeof(src.edge)); 238 memcpy(&dest->edge, src.edge, sizeof(src.edge));
239} 239}
240 240
241STATIC_INLINE void 241STATIC_INLINE void
242set_eo(cube_t *cube, int64_t eo) 242set_eo(cube_t cube[static 1], int64_t eo)
243{ 243{
244 uint8_t i, sum, flip; 244 uint8_t i, sum, flip;
245 245
diff --git a/src/core/cube.h b/src/core/cube.h
index ab5f181..7a68fb2 100644
--- a/src/core/cube.h
+++ b/src/core/cube.h
@@ -1,4 +1,4 @@
1STATIC cube_t solvecube(void); 1STATIC cube_t solvedcube(void);
2STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); 2STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]);
3STATIC bool isconsistent(cube_t); 3STATIC bool isconsistent(cube_t);
4STATIC bool issolvable(cube_t); 4STATIC bool issolvable(cube_t);
diff --git a/src/nissy.c b/src/nissy.c
index 431362d..e8a6550 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -14,7 +14,7 @@
14 14
15long long parse_h48_solver( 15long long parse_h48_solver(
16 const char *, uint8_t [static 1], uint8_t [static 1]); 16 const char *, uint8_t [static 1], uint8_t [static 1]);
17STATIC bool checkdata(const char *, const tableinfo_t *); 17STATIC bool checkdata(const char *, const tableinfo_t [static 1]);
18STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], 18STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN],
19 const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); 19 const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t);
20STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); 20STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]);
@@ -66,11 +66,11 @@ parse_h48_solver_error:
66} 66}
67 67
68STATIC bool 68STATIC bool
69checkdata(const char *buf, const tableinfo_t *info) 69checkdata(const char *buf, const tableinfo_t info[static 1])
70{ 70{
71 uint64_t distr[INFO_DISTRIBUTION_LEN]; 71 uint64_t distr[INFO_DISTRIBUTION_LEN];
72 72
73 if (info == NULL || my_strnlen(info->solver, INFO_SOLVER_STRLEN) 73 if (my_strnlen(info->solver, INFO_SOLVER_STRLEN)
74 == INFO_SOLVER_STRLEN) { 74 == INFO_SOLVER_STRLEN) {
75 LOG("checkdata: error reading table info\n"); 75 LOG("checkdata: error reading table info\n");
76 return false; 76 return false;
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h
index 5819608..ca058b0 100644
--- a/src/solvers/coord/gendata.h
+++ b/src/solvers/coord/gendata.h
@@ -1,10 +1,13 @@
1STATIC size_t gendata_coord(const coord_t *, void *); 1STATIC size_t gendata_coord(const coord_t [static 1], void *);
2STATIC int64_t gendata_coord_dispatch(const char *, void *); 2STATIC int64_t gendata_coord_dispatch(const char *, void *);
3STATIC tableinfo_t genptable_coord(const coord_t *, const void *, uint8_t *); 3STATIC tableinfo_t genptable_coord(
4 const coord_t [static 1], const void *, uint8_t *);
4STATIC void getdistribution_coord( 5STATIC void getdistribution_coord(
5 const uint8_t *, const char *, uint64_t [static INFO_DISTRIBUTION_LEN]); 6 const uint8_t *, const char *, uint64_t [static INFO_DISTRIBUTION_LEN]);
6STATIC uint8_t get_coord_pval(const coord_t *, const uint8_t *, uint64_t); 7STATIC uint8_t get_coord_pval(
7STATIC void set_coord_pval(const coord_t *, uint8_t *, uint64_t, uint8_t); 8 const coord_t [static 1], const uint8_t *, uint64_t);
9STATIC void set_coord_pval(
10 const coord_t [static 1], uint8_t *, uint64_t, uint8_t);
8 11
9STATIC int64_t 12STATIC int64_t
10gendata_coord_dispatch(const char *coordstr, void *buf) 13gendata_coord_dispatch(const char *coordstr, void *buf)
@@ -22,7 +25,7 @@ gendata_coord_dispatch(const char *coordstr, void *buf)
22} 25}
23 26
24STATIC size_t 27STATIC size_t
25gendata_coord(const coord_t *coord, void *buf) 28gendata_coord(const coord_t coord[static 1], void *buf)
26{ 29{
27 uint64_t coord_dsize, tablesize, ninfo; 30 uint64_t coord_dsize, tablesize, ninfo;
28 void *pruningbuf, *coord_data; 31 void *pruningbuf, *coord_data;
@@ -72,7 +75,11 @@ gendata_coord_return_size:
72} 75}
73 76
74STATIC tableinfo_t 77STATIC tableinfo_t
75genptable_coord(const coord_t *coord, const void *data, uint8_t *table) 78genptable_coord(
79 const coord_t coord[static 1],
80 const void *data,
81 uint8_t *table
82)
76{ 83{
77 uint64_t tablesize, i, j, d, tot; 84 uint64_t tablesize, i, j, d, tot;
78 tableinfo_t info; 85 tableinfo_t info;
@@ -147,13 +154,22 @@ getdistribution_coord(
147} 154}
148 155
149STATIC uint8_t 156STATIC uint8_t
150get_coord_pval(const coord_t *coord, const uint8_t *table, uint64_t i) 157get_coord_pval(
158 const coord_t coord[static 1],
159 const uint8_t *table,
160 uint64_t i
161)
151{ 162{
152 return (table[COORD_INDEX(i)] & COORD_MASK(i)) >> COORD_SHIFT(i); 163 return (table[COORD_INDEX(i)] & COORD_MASK(i)) >> COORD_SHIFT(i);
153} 164}
154 165
155STATIC void 166STATIC void
156set_coord_pval(const coord_t *coord, uint8_t *table, uint64_t i, uint8_t val) 167set_coord_pval(
168 const coord_t coord[static 1],
169 uint8_t *table,
170 uint64_t i,
171 uint8_t val
172)
157{ 173{
158 table[COORD_INDEX(i)] = (table[COORD_INDEX(i)] & (~COORD_MASK(i))) 174 table[COORD_INDEX(i)] = (table[COORD_INDEX(i)] & (~COORD_MASK(i)))
159 | (val << COORD_SHIFT(i)); 175 | (val << COORD_SHIFT(i));
diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h
index ab4aded..e9d0595 100644
--- a/src/solvers/coord/utils.h
+++ b/src/solvers/coord/utils.h
@@ -1,6 +1,7 @@
1STATIC coord_t *parse_coord(size_t n, const char [n]); 1STATIC coord_t *parse_coord(size_t n, const char [n]);
2STATIC uint8_t parse_axis(size_t n, const char [n]); 2STATIC uint8_t parse_axis(size_t n, const char [n]);
3STATIC void parse_coord_and_axis(size_t n, const char [n], coord_t **, uint8_t *); 3STATIC void parse_coord_and_axis(
4 size_t n, const char [n], coord_t **, uint8_t *);
4STATIC int64_t dataid_coord(const char *, char [static NISSY_DATAID_SIZE]); 5STATIC int64_t dataid_coord(const char *, char [static NISSY_DATAID_SIZE]);
5 6
6STATIC coord_t * 7STATIC coord_t *
diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h
index 6caac2a..eb08fd8 100644
--- a/src/solvers/h48/coordinate.h
+++ b/src/solvers/h48/coordinate.h
@@ -1,12 +1,15 @@
1/* Macros defined in a separate file for easier testing */ 1STATIC_INLINE int64_t coord_h48(
2#include "coordinate_macros.h" 2 cube_t, const uint32_t [static COCSEP_TABLESIZE], uint8_t);
3
4STATIC_INLINE int64_t coord_h48(cube_t, const uint32_t *, uint8_t);
5STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); 3STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t);
6STATIC_INLINE cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); 4STATIC_INLINE cube_t invcoord_h48(
5 int64_t, const cube_t [static COCSEP_CLASSES], uint8_t);
7 6
8STATIC_INLINE int64_t 7STATIC_INLINE int64_t
9coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) 8coord_h48(
9 cube_t c,
10 const uint32_t cocsepdata[static COCSEP_TABLESIZE],
11 uint8_t h
12)
10{ 13{
11 int64_t cocsep, coclass; 14 int64_t cocsep, coclass;
12 uint32_t data; 15 uint32_t data;
@@ -42,7 +45,11 @@ the given value, because it works up to symmetry. This means that the
42returned cube is a transformed cube of one that gives the correct value. 45returned cube is a transformed cube of one that gives the correct value.
43*/ 46*/
44STATIC_INLINE cube_t 47STATIC_INLINE cube_t
45invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) 48invcoord_h48(
49 int64_t i,
50 const cube_t crep[static COCSEP_CLASSES],
51 uint8_t h
52)
46{ 53{
47 cube_t ret; 54 cube_t ret;
48 int64_t hh, coclass, ee, esep, eo; 55 int64_t hh, coclass, ee, esep, eo;
diff --git a/src/solvers/h48/coordinate_macros.h b/src/solvers/h48/coordinate_types_macros.h
index 04462d6..04462d6 100644
--- a/src/solvers/h48/coordinate_macros.h
+++ b/src/solvers/h48/coordinate_types_macros.h
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h
index bf67962..cda1608 100644
--- a/src/solvers/h48/gendata_cocsep.h
+++ b/src/solvers/h48/gendata_cocsep.h
@@ -1,11 +1,15 @@
1STATIC_INLINE bool gendata_cocsep_get_visited(const uint8_t *, int64_t);
2STATIC_INLINE void gendata_cocsep_set_visited(uint8_t *, int64_t);
3
4STATIC size_t gendata_cocsep(char *, uint64_t *, cube_t *); 1STATIC size_t gendata_cocsep(char *, uint64_t *, cube_t *);
5STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); 2STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]);
6STATIC void getdistribution_cocsep(const uint32_t *, uint64_t [static 21]); 3STATIC void getdistribution_cocsep(
4 const uint32_t [static COCSEP_TABLESIZE], uint64_t [static 21]);
5
6STATIC_INLINE bool gendata_cocsep_get_visited(
7 const uint8_t [static COCSEP_VISITEDSIZE], int64_t);
8STATIC_INLINE void gendata_cocsep_set_visited(
9 uint8_t [static COCSEP_VISITEDSIZE], int64_t);
7 10
8STATIC_INLINE int8_t get_h48_cdata(cube_t, const uint32_t *, uint32_t *); 11STATIC_INLINE int8_t get_h48_cdata(
12 cube_t, const uint32_t [static COCSEP_TABLESIZE], uint32_t *);
9 13
10STATIC size_t 14STATIC size_t
11gendata_cocsep( 15gendata_cocsep(
@@ -78,7 +82,7 @@ gendata_cocsep_return_size:
78} 82}
79 83
80STATIC uint32_t 84STATIC uint32_t
81gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) 85gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1])
82{ 86{
83 uint8_t m; 87 uint8_t m;
84 uint32_t cc, class, ttrep, depth, olddepth, tinv; 88 uint32_t cc, class, ttrep, depth, olddepth, tinv;
@@ -133,7 +137,10 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t *arg)
133} 137}
134 138
135STATIC void 139STATIC void
136getdistribution_cocsep(const uint32_t *table, uint64_t distr[static 21]) 140getdistribution_cocsep(
141 const uint32_t table[static COCSEP_TABLESIZE],
142 uint64_t distr[static 21]
143)
137{ 144{
138 size_t i; 145 size_t i;
139 146
@@ -144,19 +151,29 @@ getdistribution_cocsep(const uint32_t *table, uint64_t distr[static 21])
144} 151}
145 152
146STATIC_INLINE bool 153STATIC_INLINE bool
147gendata_cocsep_get_visited(const uint8_t *a, int64_t i) 154gendata_cocsep_get_visited(
155 const uint8_t a[static COCSEP_VISITEDSIZE],
156 int64_t i
157)
148{ 158{
149 return a[VISITED_IND(i)] & VISITED_MASK(i); 159 return a[VISITED_IND(i)] & VISITED_MASK(i);
150} 160}
151 161
152STATIC_INLINE void 162STATIC_INLINE void
153gendata_cocsep_set_visited(uint8_t *a, int64_t i) 163gendata_cocsep_set_visited(
164 uint8_t a[static COCSEP_VISITEDSIZE],
165 int64_t i
166)
154{ 167{
155 a[VISITED_IND(i)] |= VISITED_MASK(i); 168 a[VISITED_IND(i)] |= VISITED_MASK(i);
156} 169}
157 170
158STATIC_INLINE int8_t 171STATIC_INLINE int8_t
159get_h48_cdata(cube_t cube, const uint32_t *cocsepdata, uint32_t *cdata) 172get_h48_cdata(
173 cube_t cube,
174 const uint32_t cocsepdata[static COCSEP_TABLESIZE],
175 uint32_t *cdata
176)
160{ 177{
161 int64_t coord; 178 int64_t coord;
162 179
diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h
index d887209..4bf5a84 100644
--- a/src/solvers/h48/gendata_eoesep.h
+++ b/src/solvers/h48/gendata_eoesep.h
@@ -12,9 +12,11 @@ STATIC uint32_t gendata_eoesep_marksim(int64_t, uint8_t,
12 uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); 12 uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]);
13STATIC bool gendata_eoesep_next(cube_t, uint8_t, 13STATIC bool gendata_eoesep_next(cube_t, uint8_t,
14 uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); 14 uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]);
15STATIC uint8_t get_eoesep_pval(const uint8_t *, int64_t); 15STATIC uint8_t get_eoesep_pval(
16 const uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], int64_t);
16STATIC uint8_t get_eoesep_pval_cube(const void *, cube_t); 17STATIC uint8_t get_eoesep_pval_cube(const void *, cube_t);
17STATIC void set_eoesep_pval(uint8_t *, int64_t, uint8_t); 18STATIC void set_eoesep_pval(
19 uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], int64_t, uint8_t);
18 20
19STATIC int64_t 21STATIC int64_t
20coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX]) 22coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX])
@@ -247,7 +249,10 @@ gendata_eoesep_next(
247} 249}
248 250
249STATIC uint8_t 251STATIC uint8_t
250get_eoesep_pval(const uint8_t *table, int64_t i) 252get_eoesep_pval(
253 const uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)],
254 int64_t i
255)
251{ 256{
252 return (table[EOESEP_INDEX(i)] & EOESEP_MASK(i)) >> EOESEP_SHIFT(i); 257 return (table[EOESEP_INDEX(i)] & EOESEP_MASK(i)) >> EOESEP_SHIFT(i);
253} 258}
@@ -267,7 +272,11 @@ get_eoesep_pval_cube(const void *data, cube_t c)
267} 272}
268 273
269STATIC void 274STATIC void
270set_eoesep_pval(uint8_t *table, int64_t i, uint8_t val) 275set_eoesep_pval(
276 uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)],
277 int64_t i,
278 uint8_t val
279)
271{ 280{
272 table[EOESEP_INDEX(i)] = (table[EOESEP_INDEX(i)] & (~EOESEP_MASK(i))) 281 table[EOESEP_INDEX(i)] = (table[EOESEP_INDEX(i)] & (~EOESEP_MASK(i)))
273 | (val << EOESEP_SHIFT(i)); 282 | (val << EOESEP_SHIFT(i));
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 2d9a9f7..959264d 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -1,17 +1,17 @@
1STATIC uint64_t gendata_h48short(gendata_h48short_arg_t *); 1STATIC uint64_t genddfggta_h48short(gendata_h48short_arg_t [static 1]);
2STATIC int64_t gendata_h48(gendata_h48_arg_t *); 2STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]);
3STATIC void gendata_h48h0k4(gendata_h48_arg_t *); 3STATIC void gendata_h48h0k4(gendata_h48_arg_t [static 1]);
4STATIC void gendata_h48k2(gendata_h48_arg_t *); 4STATIC void gendata_h48k2(gendata_h48_arg_t [static 1]);
5STATIC void gendata_h48k2_realcoord(gendata_h48_arg_t *);
6 5
7STATIC void * gendata_h48h0k4_runthread(void *); 6STATIC void * gendata_h48h0k4_runthread(void *);
8STATIC void * gendata_h48k2_runthread(void *); 7STATIC void * gendata_h48k2_runthread(void *);
9 8
10STATIC_INLINE void gendata_h48_mark_atomic(gendata_h48_mark_t *); 9STATIC_INLINE void gendata_h48_mark_atomic(gendata_h48_mark_t [static 1]);
11STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t *); 10STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [static 1]);
12STATIC_INLINE bool gendata_h48k2_dfs_stop(cube_t, int8_t, h48k2_dfs_arg_t *); 11STATIC_INLINE bool gendata_h48k2_dfs_stop(
13STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); 12 cube_t, int8_t, h48k2_dfs_arg_t [static 1]);
14STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *); 13STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t [static 1]);
14STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t [static 1]);
15STATIC void getdistribution_h48(const uint8_t *, 15STATIC void getdistribution_h48(const uint8_t *,
16 uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t); 16 uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t);
17 17
@@ -28,7 +28,7 @@ STATIC_INLINE void set_h48_pval_atomic(
28size_t gendata_h48_derive(uint8_t, const void *, void *); 28size_t gendata_h48_derive(uint8_t, const void *, void *);
29 29
30STATIC uint64_t 30STATIC uint64_t
31gendata_h48short(gendata_h48short_arg_t *arg) 31gendata_h48short(gendata_h48short_arg_t arg[static 1])
32{ 32{
33 uint8_t i, m; 33 uint8_t i, m;
34 int64_t coord; 34 int64_t coord;
@@ -62,7 +62,7 @@ gendata_h48short(gendata_h48short_arg_t *arg)
62} 62}
63 63
64STATIC int64_t 64STATIC int64_t
65gendata_h48(gendata_h48_arg_t *arg) 65gendata_h48(gendata_h48_arg_t arg[static 1])
66{ 66{
67 uint64_t size, cocsepsize, h48size, fallbacksize, fallback2size, of; 67 uint64_t size, cocsepsize, h48size, fallbacksize, fallback2size, of;
68 long long r; 68 long long r;
@@ -70,11 +70,6 @@ gendata_h48(gendata_h48_arg_t *arg)
70 tableinfo_t cocsepinfo, h48info, fallbackinfo; 70 tableinfo_t cocsepinfo, h48info, fallbackinfo;
71 gendata_h48_arg_t arg_h0k4; 71 gendata_h48_arg_t arg_h0k4;
72 72
73 if (arg == NULL) {
74 LOG("Error computing H48 data: arg is NULL.\n");
75 return NISSY_ERROR_UNKNOWN;
76 }
77
78 cocsepsize = COCSEP_FULLSIZE; 73 cocsepsize = COCSEP_FULLSIZE;
79 h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k); 74 h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k);
80 fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0; 75 fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0;
@@ -107,8 +102,6 @@ gendata_h48(gendata_h48_arg_t *arg)
107 102
108 if (arg->h == 0 && arg->k == 4) { 103 if (arg->h == 0 && arg->k == 4) {
109 gendata_h48h0k4(arg); 104 gendata_h48h0k4(arg);
110 } else if ((arg->h == 0 || arg->h == 11) && arg->k == 2) {
111 gendata_h48k2_realcoord(arg);
112 } else if (arg->k == 2) { 105 } else if (arg->k == 2) {
113 gendata_h48k2(arg); 106 gendata_h48k2(arg);
114 } else { 107 } else {
@@ -189,7 +182,7 @@ gendata_h48(gendata_h48_arg_t *arg)
189} 182}
190 183
191STATIC void 184STATIC void
192gendata_h48h0k4(gendata_h48_arg_t *arg) 185gendata_h48h0k4(gendata_h48_arg_t arg[static 1])
193{ 186{
194 _Atomic uint8_t *table; 187 _Atomic uint8_t *table;
195 uint8_t val; 188 uint8_t val;
@@ -325,7 +318,7 @@ gendata_h48h0k4_runthread(void *arg)
325} 318}
326 319
327STATIC void 320STATIC void
328gendata_h48k2(gendata_h48_arg_t *arg) 321gendata_h48k2(gendata_h48_arg_t arg[static 1])
329{ 322{
330 static const uint8_t shortdepth = 8; 323 static const uint8_t shortdepth = 8;
331 static const uint64_t capacity = 10000019; 324 static const uint64_t capacity = 10000019;
@@ -483,7 +476,7 @@ gendata_h48k2_runthread(void *arg)
483} 476}
484 477
485STATIC void 478STATIC void
486gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) 479gendata_h48k2_dfs(h48k2_dfs_arg_t arg[static 1])
487{ 480{
488 int8_t d; 481 int8_t d;
489 uint8_t m[4]; 482 uint8_t m[4];
@@ -562,7 +555,7 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg)
562} 555}
563 556
564STATIC_INLINE void 557STATIC_INLINE void
565gendata_h48_mark_atomic(gendata_h48_mark_t *arg) 558gendata_h48_mark_atomic(gendata_h48_mark_t arg[static 1])
566{ 559{
567 uint8_t oldval, newval; 560 uint8_t oldval, newval;
568 int64_t coord, mutex; 561 int64_t coord, mutex;
@@ -582,7 +575,7 @@ gendata_h48_mark_atomic(gendata_h48_mark_t *arg)
582} 575}
583 576
584STATIC_INLINE void 577STATIC_INLINE void
585gendata_h48_mark(gendata_h48_mark_t *arg) 578gendata_h48_mark(gendata_h48_mark_t arg[static 1])
586{ 579{
587 uint8_t oldval, newval; 580 uint8_t oldval, newval;
588 int64_t coord, mutex; 581 int64_t coord, mutex;
@@ -599,7 +592,7 @@ gendata_h48_mark(gendata_h48_mark_t *arg)
599} 592}
600 593
601STATIC_INLINE bool 594STATIC_INLINE bool
602gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) 595gendata_h48k2_dfs_stop(cube_t cube, int8_t d, h48k2_dfs_arg_t arg[static 1])
603{ 596{
604 uint64_t val; 597 uint64_t val;
605 int64_t coord, mutex; 598 int64_t coord, mutex;
@@ -613,7 +606,7 @@ gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg)
613 pthread_mutex_lock(arg->table_mutex[mutex]); 606 pthread_mutex_lock(arg->table_mutex[mutex]);
614 oldval = get_h48_pval(arg->table, coord, arg->k); 607 oldval = get_h48_pval(arg->table, coord, arg->k);
615 pthread_mutex_unlock(arg->table_mutex[mutex]); 608 pthread_mutex_unlock(arg->table_mutex[mutex]);
616 return oldval <= depth; 609 return oldval <= d;
617 } else { 610 } else {
618 /* With 0 < k < 11 we do not have a "real coordinate". 611 /* With 0 < k < 11 we do not have a "real coordinate".
619 The best we can do is checking if we backtracked to 612 The best we can do is checking if we backtracked to
@@ -624,22 +617,8 @@ gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg)
624 } 617 }
625} 618}
626 619
627STATIC void
628gendata_h48k2_realcoord(gendata_h48_arg_t *arg)
629{
630 /* TODO */
631 gendata_h48k2(arg);
632}
633
634STATIC void *
635gendata_h48k2_realcoord_runthread(void *arg)
636{
637 /* TODO */
638 return NULL;
639}
640
641STATIC tableinfo_t 620STATIC tableinfo_t
642makeinfo_h48k2(gendata_h48_arg_t *arg) 621makeinfo_h48k2(gendata_h48_arg_t arg[static 1])
643{ 622{
644 tableinfo_t info; 623 tableinfo_t info;
645 624
diff --git a/src/solvers/h48/gendata_types_macros.h b/src/solvers/h48/gendata_types_macros.h
index ec6576a..11940d8 100644
--- a/src/solvers/h48/gendata_types_macros.h
+++ b/src/solvers/h48/gendata_types_macros.h
@@ -33,7 +33,7 @@
33/* 33/*
34TODO: This loop over similar h48 coordinates can be improved by only 34TODO: This loop over similar h48 coordinates can be improved by only
35transforming edges, but we need to compose transformations (i.e. conjugate 35transforming edges, but we need to compose transformations (i.e. conjugate
36_t by _ttrep). 36VAR_T by VAR_TTREP).
37*/ 37*/
38#define FOREACH_H48SIM(ARG_CUBE, ARG_COCSEPDATA, ARG_SELFSIM, ARG_ACTION) \ 38#define FOREACH_H48SIM(ARG_CUBE, ARG_COCSEPDATA, ARG_SELFSIM, ARG_ACTION) \
39 int64_t VAR_COCSEP = coord_cocsep(ARG_CUBE); \ 39 int64_t VAR_COCSEP = coord_cocsep(ARG_CUBE); \
diff --git a/src/solvers/h48/h48.h b/src/solvers/h48/h48.h
index d5a67ef..0cfa773 100644
--- a/src/solvers/h48/h48.h
+++ b/src/solvers/h48/h48.h
@@ -1,6 +1,8 @@
1#include "coordinate_types_macros.h"
2#include "map_types_macros.h"
3#include "gendata_types_macros.h"
1#include "coordinate.h" 4#include "coordinate.h"
2#include "map.h" 5#include "map.h"
3#include "gendata_types_macros.h"
4#include "gendata_cocsep.h" 6#include "gendata_cocsep.h"
5#include "gendata_eoesep.h" 7#include "gendata_eoesep.h"
6#include "gendata_h48.h" 8#include "gendata_h48.h"
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h
index e6903ce..7718794 100644
--- a/src/solvers/h48/map.h
+++ b/src/solvers/h48/map.h
@@ -1,16 +1,13 @@
1/* Type definitions and macros are in a separate file for easier testing */ 1STATIC void h48map_create(h48map_t [static 1], uint64_t, uint64_t);
2#include "map_types_macros.h" 2STATIC void h48map_clear(h48map_t [static 1]);
3 3STATIC void h48map_destroy(h48map_t [static 1]);
4STATIC void h48map_create(h48map_t *, uint64_t, uint64_t); 4STATIC uint64_t h48map_lookup(h48map_t [static 1], uint64_t);
5STATIC void h48map_clear(h48map_t *); 5STATIC void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t);
6STATIC void h48map_destroy(h48map_t *); 6STATIC uint64_t h48map_value(h48map_t [static 1], uint64_t);
7STATIC uint64_t h48map_lookup(h48map_t *, uint64_t); 7STATIC kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]);
8STATIC void h48map_insertmin(h48map_t *, uint64_t, uint64_t);
9STATIC uint64_t h48map_value(h48map_t *, uint64_t);
10STATIC kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *);
11 8
12STATIC void 9STATIC void
13h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) 10h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer)
14{ 11{
15 map->capacity = capacity; 12 map->capacity = capacity;
16 map->randomizer = randomizer; 13 map->randomizer = randomizer;
@@ -20,20 +17,20 @@ h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer)
20} 17}
21 18
22STATIC void 19STATIC void
23h48map_clear(h48map_t *map) 20h48map_clear(h48map_t map[static 1])
24{ 21{
25 memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); 22 memset(map->table, 0xFF, map->capacity * sizeof(uint64_t));
26 map->n = 0; 23 map->n = 0;
27} 24}
28 25
29STATIC void 26STATIC void
30h48map_destroy(h48map_t *map) 27h48map_destroy(h48map_t map[static 1])
31{ 28{
32 free(map->table); 29 free(map->table);
33} 30}
34 31
35STATIC_INLINE uint64_t 32STATIC_INLINE uint64_t
36h48map_lookup(h48map_t *map, uint64_t x) 33h48map_lookup(h48map_t map[static 1], uint64_t x)
37{ 34{
38 uint64_t hash, i; 35 uint64_t hash, i;
39 36
@@ -47,7 +44,7 @@ h48map_lookup(h48map_t *map, uint64_t x)
47} 44}
48 45
49STATIC_INLINE void 46STATIC_INLINE void
50h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val) 47h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val)
51{ 48{
52 uint64_t i, oldval, min; 49 uint64_t i, oldval, min;
53 50
@@ -60,13 +57,13 @@ h48map_insertmin(h48map_t *map, uint64_t key, uint64_t val)
60} 57}
61 58
62STATIC_INLINE uint64_t 59STATIC_INLINE uint64_t
63h48map_value(h48map_t *map, uint64_t key) 60h48map_value(h48map_t map[static 1], uint64_t key)
64{ 61{
65 return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; 62 return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT;
66} 63}
67 64
68STATIC kvpair_t 65STATIC kvpair_t
69h48map_nextkvpair(h48map_t *map, uint64_t *p) 66h48map_nextkvpair(h48map_t map[static 1], uint64_t p[static 1])
70{ 67{
71 kvpair_t kv; 68 kvpair_t kv;
72 uint64_t pair; 69 uint64_t pair;
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
index dbd15bb..dcec5a4 100644
--- a/src/solvers/h48/solve.h
+++ b/src/solvers/h48/solve.h
@@ -46,18 +46,18 @@ typedef struct {
46 int8_t *shortest_sol; 46 int8_t *shortest_sol;
47} dfsarg_solve_h48_maketasks_t; 47} dfsarg_solve_h48_maketasks_t;
48 48
49STATIC_INLINE bool solve_h48_stop(dfsarg_solve_h48_t *); 49STATIC_INLINE bool solve_h48_stop(dfsarg_solve_h48_t [static 1]);
50STATIC int64_t solve_h48_maketasks( 50STATIC int64_t solve_h48_maketasks(
51 dfsarg_solve_h48_t *, dfsarg_solve_h48_maketasks_t *, 51 dfsarg_solve_h48_t [static 1], dfsarg_solve_h48_maketasks_t [static 1],
52 solve_h48_task_t [static STARTING_CUBES], int *); 52 solve_h48_task_t [static STARTING_CUBES], int [static 1]);
53STATIC void *solve_h48_runthread(void *); 53STATIC void *solve_h48_runthread(void *);
54STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t *); 54STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t [static 1]);
55STATIC int64_t solve_h48(cube_t, int8_t, int8_t, uint64_t, int8_t, int8_t, 55STATIC int64_t solve_h48(cube_t, int8_t, int8_t, uint64_t, int8_t, int8_t,
56 uint64_t, const void *, size_t n, char [n], 56 uint64_t, const void *, size_t n, char [n],
57 long long [static NISSY_SIZE_SOLVE_STATS]); 57 long long [static NISSY_SIZE_SOLVE_STATS]);
58 58
59STATIC_INLINE bool 59STATIC_INLINE bool
60solve_h48_stop(dfsarg_solve_h48_t *arg) 60solve_h48_stop(dfsarg_solve_h48_t arg[static 1])
61{ 61{
62 uint32_t data, data_inv; 62 uint32_t data, data_inv;
63 int64_t coord; 63 int64_t coord;
@@ -145,7 +145,7 @@ solve_h48_stop(dfsarg_solve_h48_t *arg)
145} 145}
146 146
147STATIC int64_t 147STATIC int64_t
148solve_h48_dfs(dfsarg_solve_h48_t *arg) 148solve_h48_dfs(dfsarg_solve_h48_t arg[static 1])
149{ 149{
150 int64_t ret, n; 150 int64_t ret, n;
151 uint8_t m, nm, lbn, lbi; 151 uint8_t m, nm, lbn, lbi;
@@ -261,10 +261,10 @@ solve_h48_runthread(void *arg)
261 261
262STATIC int64_t 262STATIC int64_t
263solve_h48_maketasks( 263solve_h48_maketasks(
264 dfsarg_solve_h48_t *solve_arg, 264 dfsarg_solve_h48_t solve_arg[static 1],
265 dfsarg_solve_h48_maketasks_t *maketasks_arg, 265 dfsarg_solve_h48_maketasks_t maketasks_arg[static 1],
266 solve_h48_task_t tasks[static STARTING_CUBES], 266 solve_h48_task_t tasks[static STARTING_CUBES],
267 int *ntasks 267 int ntasks[static 1]
268) 268)
269{ 269{
270 int r; 270 int r;
diff --git a/src/solvers/tables.h b/src/solvers/tables.h
index 65e7606..db888b5 100644
--- a/src/solvers/tables.h
+++ b/src/solvers/tables.h
@@ -1,11 +1,13 @@
1STATIC uint64_t read_unaligned_u64(const char *); 1STATIC uint64_t read_unaligned_u64(const char [static sizeof(uint64_t)]);
2STATIC void write_unaligned_u64(char *, uint64_t); 2STATIC void write_unaligned_u64(char [static sizeof(uint64_t)], uint64_t);
3STATIC int64_t readtableinfo(uint64_t, const char *, tableinfo_t *); 3STATIC int64_t readtableinfo(size_t n, const char [n], tableinfo_t [static 1]);
4STATIC int64_t readtableinfo_n(uint64_t, const char *, uint8_t, tableinfo_t *); 4STATIC int64_t readtableinfo_n(
5STATIC int64_t writetableinfo(const tableinfo_t *, uint64_t, char *); 5 size_t n, const char [n], uint8_t, tableinfo_t [static 1]);
6STATIC int64_t writetableinfo(
7 const tableinfo_t [static 1], size_t n, char [n]);
6 8
7STATIC uint64_t 9STATIC uint64_t
8read_unaligned_u64(const char *buf) 10read_unaligned_u64(const char buf[static sizeof(uint64_t)])
9{ 11{
10 uint64_t ret; 12 uint64_t ret;
11 13
@@ -15,13 +17,17 @@ read_unaligned_u64(const char *buf)
15} 17}
16 18
17STATIC void 19STATIC void
18write_unaligned_u64(char *buf, uint64_t x) 20write_unaligned_u64(char buf[static sizeof(uint64_t)], uint64_t x)
19{ 21{
20 memcpy(buf, &x, sizeof(uint64_t)); 22 memcpy(buf, &x, sizeof(uint64_t));
21} 23}
22 24
23STATIC int64_t 25STATIC int64_t
24readtableinfo(uint64_t buf_size, const char *buf, tableinfo_t *info) 26readtableinfo(
27 size_t buf_size,
28 const char buf[buf_size],
29 tableinfo_t info[static 1]
30)
25{ 31{
26 size_t i; 32 size_t i;
27 33
@@ -37,11 +43,6 @@ readtableinfo(uint64_t buf_size, const char *buf, tableinfo_t *info)
37 return NISSY_ERROR_BUFFER_SIZE; 43 return NISSY_ERROR_BUFFER_SIZE;
38 } 44 }
39 45
40 if (info == NULL) {
41 LOG("Error reading table info: info struct is NULL\n");
42 return NISSY_ERROR_UNKNOWN;
43 }
44
45 for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) 46 for (i = 0; i < INFO_DISTRIBUTION_LEN; i++)
46 info->distribution[i] = read_unaligned_u64(OFFSET(buf, 47 info->distribution[i] = read_unaligned_u64(OFFSET(buf,
47 INFO_OFFSET_DISTRIBUTION + i * sizeof(uint64_t))); 48 INFO_OFFSET_DISTRIBUTION + i * sizeof(uint64_t)));
@@ -67,10 +68,10 @@ readtableinfo(uint64_t buf_size, const char *buf, tableinfo_t *info)
67 68
68STATIC int64_t 69STATIC int64_t
69readtableinfo_n( 70readtableinfo_n(
70 uint64_t buf_size, 71 size_t buf_size,
71 const char *buf, 72 const char buf[buf_size],
72 uint8_t n, 73 uint8_t n,
73 tableinfo_t *info 74 tableinfo_t info[static 1]
74) 75)
75{ 76{
76 int64_t ret; 77 int64_t ret;
@@ -83,22 +84,16 @@ readtableinfo_n(
83} 84}
84 85
85STATIC int64_t 86STATIC int64_t
86writetableinfo(const tableinfo_t *info, uint64_t data_size, char *buf) 87writetableinfo(
88 const tableinfo_t info[static 1],
89 size_t data_size,
90 char buf[data_size]
91)
87{ 92{
88 size_t i; 93 size_t i;
89 bool end; 94 bool end;
90 char *c; 95 char *c;
91 96
92 if (buf == NULL) {
93 LOG("Error writing table: buffer is NULL\n");
94 return NISSY_ERROR_NULL_POINTER;
95 }
96
97 if (info == NULL) {
98 LOG("Error writing table info: provided info is NULL\n");
99 return NISSY_ERROR_UNKNOWN;
100 }
101
102 if (data_size < info->fullsize) { 97 if (data_size < info->fullsize) {
103 LOG("Error writing table: buffer size is too small " 98 LOG("Error writing table: buffer size is too small "
104 "(given %" PRId64 " but table requires %" PRId64 ")\n", 99 "(given %" PRId64 " but table requires %" PRId64 ")\n",

Generated with cgit - Back to sebastiano.tronto.net