aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-04-06 14:48:54 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2026-04-06 14:48:54 +0100
commita1ad0db8a6d829eddf1478cee44ae976bbcd325f (patch)
treea6e62232e05e7779034c5f9d1bf743b6f1c198e3
parent0d4fa9ebbfcadfff4baf8fc3cd32a63dcfd7dd43 (diff)
downloadnissy-core-a1ad0db8a6d829eddf1478cee44ae976bbcd325f.tar.gz
nissy-core-a1ad0db8a6d829eddf1478cee44ae976bbcd325f.zip
Fix integer conversions in code, tests and some toolsc-portability
Diffstat (limited to '')
-rw-r--r--build.bat6
-rw-r--r--src/arch/avx2.h2
-rw-r--r--src/core/moves.h8
-rw-r--r--src/core/transform.h5
-rw-r--r--src/nissy.c2
-rw-r--r--src/solvers/coord/common.h12
-rw-r--r--src/solvers/coord/gendata.h19
-rw-r--r--src/solvers/coord/multisolve.h12
-rw-r--r--src/solvers/coord/solve.h12
-rw-r--r--src/solvers/h48/gendata_cocsep.h5
-rw-r--r--src/solvers/h48/gendata_eoesep.h8
-rw-r--r--src/solvers/h48/gendata_h48.h4
-rw-r--r--src/solvers/h48/solve.h8
-rw-r--r--src/solvers/h48/utils.h2
-rw-r--r--src/solvers/solutions.h2
-rw-r--r--src/solvers/tables.h2
-rw-r--r--src/utils/math.h6
-rw-r--r--test/010_math_permtoindex/permtoindex_tests.c2
-rw-r--r--test/012_math_permsign/permsign_tests.c2
-rw-r--r--test/013_math_digitstosumzero/digitstosumzero_tests.c4
-rw-r--r--test/014_math_sumzerotodigits/sumzerotodigits.c4
-rw-r--r--test/090_allowedmoves/allowedmoves_tests.c4
-rw-r--r--test/114_cocsep_ttrep/cocsep_ttrep_tests.c4
-rw-r--r--test/122_gendata_h48short/gendata_h48short_tests.c2
-rw-r--r--test/131_coorddata_dr/coorddata_dr.c6
-rw-r--r--test/132_coorddata_dreo/coorddata_dreo.c6
-rw-r--r--test/133_coordata_drfinnoe/coorddata_drfinnoe.c6
-rw-r--r--test/140_appendsolution/appendsolution_tests.c8
-rw-r--r--tools/solvetest.h2
29 files changed, 86 insertions, 79 deletions
diff --git a/build.bat b/build.bat
index d5a3bca..3459f6e 100644
--- a/build.bat
+++ b/build.bat
@@ -49,14 +49,14 @@ exit /b 1
49 SET CXX=cl 49 SET CXX=cl
50 50
51 SET DFLAGS=/Zi /DDEBUG 51 SET DFLAGS=/Zi /DDEBUG
52 SET WARNINGS=/W2 /wd4505 /wd4996 52 SET WARNINGS=/W4 /wd4100 /wd4324 /wd4505 /wd4996
53 SET VARIABLES=/DTHREADS=%THREADS% /D%ARCH% 53 SET VARIABLES=/DTHREADS=%THREADS% /D%ARCH%
54 SET OFLAGS=/O2 54 SET OFLAGS=/O2
55 55
56 if %DEBUG%==1 (SET ODFLAGS=%DFLAGS%) else (SET ODFLAGS=%OFLAGS%) 56 if %DEBUG%==1 (SET ODFLAGS=%DFLAGS%) else (SET ODFLAGS=%OFLAGS%)
57 if "%ARCH%"=="AVX2" (SET ARCHOPTS=/arch:AVX2) else (SET ARCHOPTS=) 57 if "%ARCH%"=="AVX2" (SET ARCHOPTS=/arch:AVX2) else (SET ARCHOPTS=)
58 58
59 SET CFLAGS=/std:c11 /experimental:c11atomics %ARCHOPTS% %WARNINGS% %VARIABLES% 59 SET CFLAGS=/std:c11 /experimental:c11atomics /nologo %ARCHOPTS% %WARNINGS% %VARIABLES%
60 SET LFLAGS=/F 16777216 60 SET LFLAGS=/F 16777216
61 61
62 SET CC_NISSY=%CC% %CFLAGS% %ODFLAGS% /c src\nissy.c 62 SET CC_NISSY=%CC% %CFLAGS% %ODFLAGS% /c src\nissy.c
@@ -64,7 +64,7 @@ exit /b 1
64 SET CC_PYTHON=%CC% %CFLAGS% %LFLAGS% /I"%PYINCLUDE%" /LD /Fe:python\nissy.pyd python\nissy_module.c nissy.obj /link /LIBPATH:"%PYLIBS%" python3.lib 64 SET CC_PYTHON=%CC% %CFLAGS% %LFLAGS% /I"%PYINCLUDE%" /LD /Fe:python\nissy.pyd python\nissy_module.c nissy.obj /link /LIBPATH:"%PYLIBS%" python3.lib
65 SET CC_TEST=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% /Fe:runtest.exe nissy.obj 65 SET CC_TEST=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% /Fe:runtest.exe nissy.obj
66 SET CC_TOOL=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% /Fe:runtool.exe nissy.obj 66 SET CC_TOOL=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% /Fe:runtool.exe nissy.obj
67 SET CC_CXX=%CXX% /EHsc %ARCHOPTS% %ODFLAGS% %LFLAGS% /std:c++20 /Fe:runcpp.exe nissy_c.obj cpp\nissy.cpp 67 SET CC_CXX=%CXX% /EHsc /nologo %ARCHOPTS% %ODFLAGS% %LFLAGS% /std:c++20 /Fe:runcpp.exe nissy_c.obj cpp\nissy.cpp
68goto :compiler_done 68goto :compiler_done
69 69
70:set_clang 70:set_clang
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index 21a6f3b..801419e 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -37,7 +37,7 @@ popcount_u32(uint32_t x)
37STATIC_INLINE int 37STATIC_INLINE int
38popcount_u64(uint64_t x) 38popcount_u64(uint64_t x)
39{ 39{
40 return _mm_popcnt_u64(x); 40 return (int)_mm_popcnt_u64(x);
41} 41}
42 42
43STATIC void 43STATIC void
diff --git a/src/core/moves.h b/src/core/moves.h
index c162c1d..9f1f7cc 100644
--- a/src/core/moves.h
+++ b/src/core/moves.h
@@ -623,10 +623,10 @@ move_variations_lastqt(
623 size_t u; 623 size_t u;
624 moves_struct_t ss; 624 moves_struct_t ss;
625 625
626 in1 = s->nnormal-1; 626 in1 = (uint8_t)(s->nnormal-1);
627 in2 = s->nnormal-2; 627 in2 = (uint8_t)(s->nnormal-2);
628 ii1 = s->ninverse-1; 628 ii1 = (uint8_t)(s->ninverse-1);
629 ii2 = s->ninverse-2; 629 ii2 = (uint8_t)(s->ninverse-2);
630 630
631 n1 = in1 >= 0 ? s->normal[in1] : UINT8_ERROR; 631 n1 = in1 >= 0 ? s->normal[in1] : UINT8_ERROR;
632 n2 = in2 >= 0 ? s->normal[in2] : UINT8_ERROR; 632 n2 = in2 >= 0 ? s->normal[in2] : UINT8_ERROR;
diff --git a/src/core/transform.h b/src/core/transform.h
index 206449b..af4634e 100644
--- a/src/core/transform.h
+++ b/src/core/transform.h
@@ -407,12 +407,13 @@ inverse_trans(uint8_t t)
407STATIC uint64_t 407STATIC uint64_t
408symmetry_mask(cube_t cube) 408symmetry_mask(cube_t cube)
409{ 409{
410 uint64_t t, ret; 410 uint64_t ret;
411 uint8_t t;
411 cube_t transformed; 412 cube_t transformed;
412 413
413 for (t = 0, ret = 0; t < NTRANS; t++) { 414 for (t = 0, ret = 0; t < NTRANS; t++) {
414 transformed = transform(cube, t); 415 transformed = transform(cube, t);
415 ret |= ((uint64_t)equal(cube, transformed)) << t; 416 ret |= ((uint64_t)equal(cube, transformed)) << (uint64_t)t;
416 } 417 }
417 418
418 return ret; 419 return ret;
diff --git a/src/nissy.c b/src/nissy.c
index b9f2565..0811861 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -197,7 +197,7 @@ nissy_getcube(
197 getcube_options[i].fix(&ep, &eo, &cp, &co, &orient); 197 getcube_options[i].fix(&ep, &eo, &cp, &co, &orient);
198 198
199 oc.cube = getcube(ep, eo, cp, co); 199 oc.cube = getcube(ep, eo, cp, co);
200 oc.orientation = orient; 200 oc.orientation = (uint8_t)orient;
201 201
202 if (!isconsistent(oc)) { 202 if (!isconsistent(oc)) {
203 LOG("[getcube] Error: could not get cube with ep=%lld, " 203 LOG("[getcube] Error: could not get cube with ep=%lld, "
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h
index 593641f..3a62e85 100644
--- a/src/solvers/coord/common.h
+++ b/src/solvers/coord/common.h
@@ -77,7 +77,8 @@ coord_gendata_generic(
77 unsigned char *data 77 unsigned char *data
78) 78)
79{ 79{
80 uint64_t i, j, n, t, nasty; 80 uint64_t i, j, n, nasty;
81 uint8_t t;
81 unsigned char *datanoinfo; 82 unsigned char *datanoinfo;
82 uint32_t *classttrep, *rep; 83 uint32_t *classttrep, *rep;
83 size_t coord_datasize; 84 size_t coord_datasize;
@@ -122,16 +123,17 @@ coord_gendata_generic(
122 } 123 }
123 124
124 for (t = 0; t < NTRANS; t++) { 125 for (t = 0; t < NTRANS; t++) {
125 if (!((UINT64_C(1) << t) & coord->trans_mask)) 126 if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask))
126 continue; 127 continue;
127 128
128 j = coord->sym.coord(transform(c, t)); 129 j = coord->sym.coord(transform(c, t));
129 classttrep[j] = 130 classttrep[j] = (uint32_t)(
130 (n << COORD_CLASS_SHIFT) | 131 (n << COORD_CLASS_SHIFT) |
131 (nasty << COORD_ISNASTY_SHIFT) | 132 (nasty << COORD_ISNASTY_SHIFT) |
132 (inverse_trans(t) << COORD_TTREP_SHIFT); 133 (inverse_trans(t) << COORD_TTREP_SHIFT)
134 );
133 } 135 }
134 rep[n++] = i; 136 rep[n++] = (uint32_t)i;
135 } 137 }
136 138
137 writetableinfo(&info, coord_datasize, data); 139 writetableinfo(&info, coord_datasize, data);
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h
index f803044..edf6ce6 100644
--- a/src/solvers/coord/gendata.h
+++ b/src/solvers/coord/gendata.h
@@ -146,7 +146,8 @@ genptable_coord(
146 unsigned char *table 146 unsigned char *table
147) 147)
148{ 148{
149 uint64_t tablesize, i, d, tot, t, nm; 149 uint64_t tablesize, i, tot, t, nm;
150 uint8_t d;
150 tableinfo_t info; 151 tableinfo_t info;
151 152
152 tablesize = DIV_ROUND_UP(coord->max, 2); 153 tablesize = DIV_ROUND_UP(coord->max, 2);
@@ -170,7 +171,7 @@ genptable_coord(
170 171
171 tot = info.distribution[0] = 172 tot = info.distribution[0] =
172 genptable_coord_init_solved(coord, data, table); 173 genptable_coord_init_solved(coord, data, table);
173 nm = popcount_u32(coord->moves_mask_gendata); 174 nm = popcount_u64(coord->moves_mask_gendata);
174 for (d = 1; tot < coord->max && d < 15; d++) { 175 for (d = 1; tot < coord->max && d < 15; d++) {
175 t = 0; 176 t = 0;
176 if (switch_to_fromnew(tot, coord->max, nm)) { 177 if (switch_to_fromnew(tot, coord->max, nm)) {
@@ -247,20 +248,21 @@ genptable_coord_fillneighbors(
247{ 248{
248 bool isnasty; 249 bool isnasty;
249 uint8_t m; 250 uint8_t m;
250 uint64_t ii, j, t, tot; 251 uint64_t ii, j, tot;
252 uint8_t t;
251 cube_t c, moved; 253 cube_t c, moved;
252 254
253 c = coord->cube(i, data); 255 c = coord->cube(i, data);
254 tot = 0; 256 tot = 0;
255 for (m = 0; m < NMOVES; m++) { 257 for (m = 0; m < NMOVES; m++) {
256 if (!((UINT32_C(1) << (uint32_t)m) & 258 if (!((UINT64_C(1) << (uint64_t)m) &
257 coord->moves_mask_gendata)) 259 coord->moves_mask_gendata))
258 continue; 260 continue;
259 moved = move(c, m); 261 moved = move(c, m);
260 ii = coord->coord(moved, data); 262 ii = coord->coord(moved, data);
261 isnasty = coord->isnasty(ii, data); 263 isnasty = coord->isnasty(ii, data);
262 for (t = 0; t < NTRANS && (t == 0 || isnasty); t++) { 264 for (t = 0; t < NTRANS && (t == 0 || isnasty); t++) {
263 if (!((UINT64_C(1) << t) & coord->trans_mask)) 265 if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask))
264 continue; 266 continue;
265 267
266 j = coord->coord(transform(moved, t), data); 268 j = coord->coord(transform(moved, t), data);
@@ -285,14 +287,15 @@ genptable_coord_fillfromnew(
285{ 287{
286 bool found; 288 bool found;
287 uint8_t m; 289 uint8_t m;
288 uint64_t tot, t, ii, j, nsim, sim[NTRANS]; 290 uint64_t tot, j, ii, nsim, sim[NTRANS];
291 uint8_t t;
289 cube_t c; 292 cube_t c;
290 293
291 tot = 0; 294 tot = 0;
292 c = coord->cube(i, data); 295 c = coord->cube(i, data);
293 296
294 for (t = 0, nsim = 0; t < NTRANS; t++) { 297 for (t = 0, nsim = 0; t < NTRANS; t++) {
295 if (!((UINT64_C(1) << t) & coord->trans_mask)) 298 if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask))
296 continue; 299 continue;
297 300
298 ii = coord->coord(transform(c, t), data); 301 ii = coord->coord(transform(c, t), data);
@@ -305,7 +308,7 @@ genptable_coord_fillfromnew(
305 for (j = 0, found = false; j < nsim && !found; j++) { 308 for (j = 0, found = false; j < nsim && !found; j++) {
306 c = coord->cube(sim[j], data); 309 c = coord->cube(sim[j], data);
307 for (m = 0; m < NMOVES; m++) { 310 for (m = 0; m < NMOVES; m++) {
308 if (!((UINT32_C(1) << (uint32_t)m) & 311 if (!((UINT64_C(1) << (uint64_t)m) &
309 coord->moves_mask_gendata)) 312 coord->moves_mask_gendata))
310 continue; 313 continue;
311 ii = coord->coord(move(c, m), data); 314 ii = coord->coord(move(c, m), data);
diff --git a/src/solvers/coord/multisolve.h b/src/solvers/coord/multisolve.h
index 28f03bb..efd287d 100644
--- a/src/solvers/coord/multisolve.h
+++ b/src/solvers/coord/multisolve.h
@@ -72,8 +72,7 @@ STATIC int64_t
72solve_multicoord_dfs(dfsarg_solve_multicoord_t arg[NON_NULL]) 72solve_multicoord_dfs(dfsarg_solve_multicoord_t arg[NON_NULL])
73{ 73{
74 uint8_t m, l, i; 74 uint8_t m, l, i;
75 uint32_t mm; 75 uint64_t mm, coord;
76 uint64_t coord;
77 int64_t n, ret; 76 int64_t n, ret;
78 const coord_t *c; 77 const coord_t *c;
79 cube_t backup_cube, backup_inverse; 78 cube_t backup_cube, backup_inverse;
@@ -108,7 +107,7 @@ solve_multicoord_dfs_notsolved:
108 arg->solution_moves->nmoves++; 107 arg->solution_moves->nmoves++;
109 108
110 for (m = 0; m < NMOVES; m++) { 109 for (m = 0; m < NMOVES; m++) {
111 if (!(mm & (UINT32_C(1) << (uint32_t)m))) 110 if (!(mm & (UINT64_C(1) << (uint64_t)m)))
112 continue; 111 continue;
113 112
114 arg->solution_moves->moves[l] = m; 113 arg->solution_moves->moves[l] = m;
@@ -163,9 +162,10 @@ solve_multicoord_dispatch(
163 return NISSY_ERROR_INVALID_SOLVER; 162 return NISSY_ERROR_INVALID_SOLVER;
164 } 163 }
165 164
166 return solve_multicoord(oc, mcoord, trans, minmoves, 165 return solve_multicoord(oc, mcoord, trans, (uint8_t)minmoves,
167 maxmoves, maxsolutions, optimal, threads, data_size, data, 166 (uint8_t)maxmoves, (uint8_t)maxsolutions, (uint8_t)optimal,
168 solutions_size, sols, poll_status, poll_status_data); 167 (uint8_t)threads, data_size, data, solutions_size, sols,
168 poll_status, poll_status_data);
169} 169}
170 170
171STATIC int64_t 171STATIC int64_t
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h
index fcdb06e..6bb9af2 100644
--- a/src/solvers/coord/solve.h
+++ b/src/solvers/coord/solve.h
@@ -151,8 +151,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[NON_NULL])
151{ 151{
152 bool lastbackup; 152 bool lastbackup;
153 uint8_t m, l, nnbackup, nibackup, nmoves; 153 uint8_t m, l, nnbackup, nibackup, nmoves;
154 uint32_t mm; 154 uint64_t mm, coord;
155 uint64_t coord;
156 int64_t n, ret; 155 int64_t n, ret;
157 cube_t backup_cube, backup_inverse; 156 cube_t backup_cube, backup_inverse;
158 157
@@ -190,7 +189,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[NON_NULL])
190 arg->lastisnormal = true; 189 arg->lastisnormal = true;
191 190
192 for (m = 0; m < NMOVES; m++) { 191 for (m = 0; m < NMOVES; m++) {
193 if (!(mm & (UINT32_C(1) << (uint32_t)m))) 192 if (!(mm & (UINT64_C(1) << (uint64_t)m)))
194 continue; 193 continue;
195 194
196 arg->solution_moves->moves[l] = m; 195 arg->solution_moves->moves[l] = m;
@@ -221,7 +220,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[NON_NULL])
221 arg->lastisnormal = false; 220 arg->lastisnormal = false;
222 221
223 for (m = 0; m < NMOVES; m++) { 222 for (m = 0; m < NMOVES; m++) {
224 if (!(mm & (UINT32_C(1) << (uint32_t)m))) 223 if (!(mm & (UINT64_C(1) << (uint64_t)m)))
225 continue; 224 continue;
226 225
227 arg->solution_moves->premoves[l] = m; 226 arg->solution_moves->premoves[l] = m;
@@ -280,8 +279,9 @@ solve_coord_dispatch(
280 return NISSY_ERROR_INVALID_SOLVER; 279 return NISSY_ERROR_INVALID_SOLVER;
281 } 280 }
282 281
283 return solve_coord(oc, coord, trans, nissflag, minmoves, maxmoves, 282 return solve_coord(oc, coord, trans, (uint8_t)nissflag,
284 maxsolutions, optimal, threads, data_size, data, 283 (uint8_t)minmoves, (uint8_t)maxmoves, (uint8_t)maxsolutions,
284 (uint8_t)optimal, (uint8_t)threads, data_size, data,
285 solutions_size, sols, poll_status, poll_status_data); 285 solutions_size, sols, poll_status, poll_status_data);
286} 286}
287 287
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h
index 17568ea..f83207b 100644
--- a/src/solvers/h48/gendata_cocsep.h
+++ b/src/solvers/h48/gendata_cocsep.h
@@ -81,9 +81,8 @@ gendata_cocsep_return_size:
81STATIC uint32_t 81STATIC uint32_t
82gendata_cocsep_dfs(cocsep_dfs_arg_t arg[NON_NULL]) 82gendata_cocsep_dfs(cocsep_dfs_arg_t arg[NON_NULL])
83{ 83{
84 uint8_t m; 84 uint8_t m, t;
85 uint32_t cc, class, ttrep, depth, olddepth, tinv; 85 uint32_t cc, class, ttrep, depth, olddepth, tinv;
86 uint64_t t;
87 uint64_t i, j; 86 uint64_t i, j;
88 cube_t d; 87 cube_t d;
89 cocsep_dfs_arg_t nextarg; 88 cocsep_dfs_arg_t nextarg;
@@ -105,7 +104,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t arg[NON_NULL])
105 d = transform_corners(arg->cube, t); 104 d = transform_corners(arg->cube, t);
106 j = coord_cocsep(d); 105 j = coord_cocsep(d);
107 if (i == j && arg->selfsim != NULL) 106 if (i == j && arg->selfsim != NULL)
108 arg->selfsim[*arg->n] |= UINT64_C(1) << t; 107 arg->selfsim[*arg->n] |= UINT64_C(1) << (uint64_t)t;
109 if (COCLASS(arg->buf32[j]) != UINT32_C(0xFFFF)) 108 if (COCLASS(arg->buf32[j]) != UINT32_C(0xFFFF))
110 continue; 109 continue;
111 gendata_cocsep_set_visited(arg->visited, j); 110 gendata_cocsep_set_visited(arg->visited, j);
diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h
index 271e877..81bbd43 100644
--- a/src/solvers/h48/gendata_eoesep.h
+++ b/src/solvers/h48/gendata_eoesep.h
@@ -59,7 +59,7 @@ gendata_esep_classes(
59 esep_classes[j] = cl | ti; 59 esep_classes[j] = cl | ti;
60 visited[j] = true; 60 visited[j] = true;
61 } 61 }
62 rep[class] = i; 62 rep[class] = (uint16_t)i;
63 class++; 63 class++;
64 } 64 }
65 65
@@ -140,7 +140,8 @@ gendata_eoesep_fromdone(
140) 140)
141{ 141{
142 uint8_t pval; 142 uint8_t pval;
143 uint64_t i, esep, eo, coord, done; 143 uint32_t done;
144 uint64_t i, esep, eo, coord;
144 145
145 done = 0; 146 done = 0;
146 for (i = 0; i < ESEP_CLASSES; i++) { 147 for (i = 0; i < ESEP_CLASSES; i++) {
@@ -169,7 +170,8 @@ gendata_eoesep_fromnew(
169) 170)
170{ 171{
171 uint8_t pval; 172 uint8_t pval;
172 uint64_t i, esep, eo, coord, done; 173 uint32_t done;
174 uint64_t i, esep, eo, coord;
173 cube_t c; 175 cube_t c;
174 176
175 done = 0; 177 done = 0;
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 283c472..53b1fad 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -264,7 +264,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[NON_NULL])
264 velocity = count; 264 velocity = count;
265 265
266 /* We plan to log 10 times */ 266 /* We plan to log 10 times */
267 sleeptime = (100*(nshort-velocity)) / velocity; 267 sleeptime = (int)((100*(nshort-velocity)) / velocity);
268 268
269 done = count; 269 done = count;
270 while (nshort - done > (velocity * sleeptime) / 1000) { 270 while (nshort - done > (velocity * sleeptime) / 1000) {
@@ -320,7 +320,7 @@ gendata_h48_runthread(void *arg)
320 mutex = H48_LINE(coord) % CHUNKS; 320 mutex = H48_LINE(coord) % CHUNKS;
321 wrapthread_mutex_lock(dfsarg->table_mutex[mutex]); 321 wrapthread_mutex_lock(dfsarg->table_mutex[mutex]);
322 set_h48_pval(dfsarg->table, coordext, 0); 322 set_h48_pval(dfsarg->table, coordext, 0);
323 set_h48_pvalmin(dfsarg->table, coordmin, kv.val); 323 set_h48_pvalmin(dfsarg->table, coordmin, (uint8_t)kv.val);
324 wrapthread_mutex_unlock(dfsarg->table_mutex[mutex]); 324 wrapthread_mutex_unlock(dfsarg->table_mutex[mutex]);
325 } else { 325 } else {
326 dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); 326 dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11);
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
index 295ef88..ebc5208 100644
--- a/src/solvers/h48/solve.h
+++ b/src/solvers/h48/solve.h
@@ -111,7 +111,8 @@ STATIC long long solve_h48_dispatch(
111 if (err != NISSY_OK) 111 if (err != NISSY_OK)
112 return err; 112 return err;
113 113
114 return solve_h48(oc, minmoves, maxmoves, maxsols, optimal, threads, 114 return solve_h48(oc, (uint8_t)minmoves, (uint8_t)maxmoves,
115 (uint8_t)maxsols, (uint8_t)optimal, (uint8_t)threads,
115 data_size, data, sols_size, sols, stats, 116 data_size, data, sols_size, sols, stats,
116 poll_status, poll_status_data); 117 poll_status, poll_status_data);
117} 118}
@@ -343,7 +344,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[NON_NULL])
343 backup_inverse = arg->inverse; 344 backup_inverse = arg->inverse;
344 345
345 ret = 0; 346 ret = 0;
346 if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) { 347 if (popcount_u64(mm_normal) <= popcount_u64(mm_inverse)) {
347 h48_prune_pipeline(arg, prune, target, true); 348 h48_prune_pipeline(arg, prune, target, true);
348 arg->solution_moves->nmoves++; 349 arg->solution_moves->nmoves++;
349 for (m = 0; m < NMOVES; m++) { 350 for (m = 0; m < NMOVES; m++) {
@@ -456,8 +457,7 @@ solve_h48_maketasks(
456 int ntasks[NON_NULL] 457 int ntasks[NON_NULL]
457) 458)
458{ 459{
459 int r; 460 int64_t r, appret;
460 int64_t appret;
461 uint8_t m, t; 461 uint8_t m, t;
462 uint64_t mm; 462 uint64_t mm;
463 cube_t backup_cube; 463 cube_t backup_cube;
diff --git a/src/solvers/h48/utils.h b/src/solvers/h48/utils.h
index d181eab..6d91108 100644
--- a/src/solvers/h48/utils.h
+++ b/src/solvers/h48/utils.h
@@ -29,7 +29,7 @@ parse_h48h(const char *buf, uint8_t h[NON_NULL])
29 goto parse_h48h_error; 29 goto parse_h48h_error;
30 } 30 }
31 31
32 *h = atoi(buf); 32 *h = (uint8_t)atoi(buf);
33 if (*h > H48_HMAX) { 33 if (*h > H48_HMAX) {
34 LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be " 34 LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be "
35 "at most %" PRIu8 ")\n", *h, H48_HMAX); 35 "at most %" PRIu8 ")\n", *h, H48_HMAX);
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h
index beedc64..b7a848b 100644
--- a/src/solvers/solutions.h
+++ b/src/solvers/solutions.h
@@ -33,7 +33,7 @@ solution_moves_transform(solution_moves_t moves[NON_NULL], size_t z, uint8_t t)
33{ 33{
34 uint8_t i; 34 uint8_t i;
35 35
36 for (i = z; i < moves->nmoves; i++) 36 for (i = (uint8_t)z; i < moves->nmoves; i++)
37 moves->moves[i] = transform_move(moves->moves[i], t); 37 moves->moves[i] = transform_move(moves->moves[i], t);
38 38
39 for (i = 0; i < moves->npremoves; i++) 39 for (i = 0; i < moves->npremoves; i++)
diff --git a/src/solvers/tables.h b/src/solvers/tables.h
index 8211ab3..3db1d1e 100644
--- a/src/solvers/tables.h
+++ b/src/solvers/tables.h
@@ -140,7 +140,7 @@ writetableinfo(
140STATIC void 140STATIC void
141append_name(tableinfo_t info[NON_NULL], const char *str) 141append_name(tableinfo_t info[NON_NULL], const char *str)
142{ 142{
143 int i, j; 143 size_t i, j;
144 144
145 for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++) 145 for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++)
146 info->solver[j] = str[i]; 146 info->solver[j] = str[i];
diff --git a/src/utils/math.h b/src/utils/math.h
index f2176b6..0c56861 100644
--- a/src/utils/math.h
+++ b/src/utils/math.h
@@ -73,10 +73,10 @@ indextoperm(uint64_t p, size_t n, uint8_t *r)
73 73
74 /* Find k-th unused number */ 74 /* Find k-th unused number */
75 for (j = 0, c = 0; c <= k; j++) 75 for (j = 0, c = 0; c <= k; j++)
76 c += 1 - ((used & (1<<j)) >> j); 76 c += UINT64_C(1) - ((used & (UINT64_C(1)<<j)) >> j);
77 77
78 r[i] = j-1; 78 r[i] = (uint8_t)(j-1);
79 used |= 1 << (j-1); 79 used |= UINT64_C(1) << (j-1);
80 p %= factorial[n-i-1]; 80 p %= factorial[n-i-1];
81 } 81 }
82 82
diff --git a/test/010_math_permtoindex/permtoindex_tests.c b/test/010_math_permtoindex/permtoindex_tests.c
index 383150d..2a7ecf3 100644
--- a/test/010_math_permtoindex/permtoindex_tests.c
+++ b/test/010_math_permtoindex/permtoindex_tests.c
@@ -11,7 +11,7 @@ void run(void) {
11 n = atoll(str); 11 n = atoll(str);
12 for (i = 0; i < n; i++) { 12 for (i = 0; i < n; i++) {
13 fgets(str, STRLENMAX, stdin); 13 fgets(str, STRLENMAX, stdin);
14 a[i] = atoi(str); 14 a[i] = (uint8_t)atoi(str);
15 } 15 }
16 16
17 p = permtoindex(n, a); 17 p = permtoindex(n, a);
diff --git a/test/012_math_permsign/permsign_tests.c b/test/012_math_permsign/permsign_tests.c
index 8c652b5..f5a52d0 100644
--- a/test/012_math_permsign/permsign_tests.c
+++ b/test/012_math_permsign/permsign_tests.c
@@ -13,7 +13,7 @@ void run(void) {
13 13
14 for (i = 0; i < n; i++) { 14 for (i = 0; i < n; i++) {
15 fgets(str, STRLENMAX, stdin); 15 fgets(str, STRLENMAX, stdin);
16 a[i] = atoi(str); 16 a[i] = (uint8_t)atoi(str);
17 } 17 }
18 18
19 p = permsign(n, a); 19 p = permsign(n, a);
diff --git a/test/013_math_digitstosumzero/digitstosumzero_tests.c b/test/013_math_digitstosumzero/digitstosumzero_tests.c
index ced466a..8df1848 100644
--- a/test/013_math_digitstosumzero/digitstosumzero_tests.c
+++ b/test/013_math_digitstosumzero/digitstosumzero_tests.c
@@ -11,10 +11,10 @@ void run(void) {
11 fgets(str, STRLENMAX, stdin); 11 fgets(str, STRLENMAX, stdin);
12 n = atoi(str); 12 n = atoi(str);
13 fgets(str, STRLENMAX, stdin); 13 fgets(str, STRLENMAX, stdin);
14 b = atoi(str); 14 b = (uint8_t)atoi(str);
15 for (i = 0; i < n; i++) { 15 for (i = 0; i < n; i++) {
16 fgets(str, STRLENMAX, stdin); 16 fgets(str, STRLENMAX, stdin);
17 a[i] = atoi(str); 17 a[i] = (uint8_t)atoi(str);
18 } 18 }
19 19
20 p = digitstosumzero(n, a, b); 20 p = digitstosumzero(n, a, b);
diff --git a/test/014_math_sumzerotodigits/sumzerotodigits.c b/test/014_math_sumzerotodigits/sumzerotodigits.c
index 401d157..256ca5a 100644
--- a/test/014_math_sumzerotodigits/sumzerotodigits.c
+++ b/test/014_math_sumzerotodigits/sumzerotodigits.c
@@ -8,9 +8,9 @@ void run(void) {
8 uint64_t d; 8 uint64_t d;
9 9
10 fgets(str, STRLENMAX, stdin); 10 fgets(str, STRLENMAX, stdin);
11 n = atoi(str); 11 n = (uint8_t)atoi(str);
12 fgets(str, STRLENMAX, stdin); 12 fgets(str, STRLENMAX, stdin);
13 b = atoi(str); 13 b = (uint8_t)atoi(str);
14 fgets(str, STRLENMAX, stdin); 14 fgets(str, STRLENMAX, stdin);
15 d = atoll(str); 15 d = atoll(str);
16 16
diff --git a/test/090_allowedmoves/allowedmoves_tests.c b/test/090_allowedmoves/allowedmoves_tests.c
index 6bc0e33..cff8303 100644
--- a/test/090_allowedmoves/allowedmoves_tests.c
+++ b/test/090_allowedmoves/allowedmoves_tests.c
@@ -13,8 +13,8 @@ static char *moves[] = {
13 13
14void run(void) { 14void run(void) {
15 char movestr[STRLENMAX]; 15 char movestr[STRLENMAX];
16 uint8_t m[100]; 16 uint8_t j, m[100];
17 int n, i, j; 17 int n, i;
18 18
19 fgets(movestr, STRLENMAX, stdin); 19 fgets(movestr, STRLENMAX, stdin);
20 n = atoi(movestr); 20 n = atoi(movestr);
diff --git a/test/114_cocsep_ttrep/cocsep_ttrep_tests.c b/test/114_cocsep_ttrep/cocsep_ttrep_tests.c
index c5c1bb5..936dac3 100644
--- a/test/114_cocsep_ttrep/cocsep_ttrep_tests.c
+++ b/test/114_cocsep_ttrep/cocsep_ttrep_tests.c
@@ -6,9 +6,9 @@ uint64_t coord_cocsep(cube_t);
6size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); 6size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *);
7 7
8void run(void) { 8void run(void) {
9 uint8_t t; 9 uint8_t t, tt;
10 unsigned char buf[2000000]; 10 unsigned char buf[2000000];
11 uint32_t *cocsepdata, tt; 11 uint32_t *cocsepdata;
12 uint64_t i, selfsim[COCSEP_CLASSES]; 12 uint64_t i, selfsim[COCSEP_CLASSES];
13 uint64_t j, k, l; 13 uint64_t j, k, l;
14 cube_t rep[COCSEP_CLASSES], c, d; 14 cube_t rep[COCSEP_CLASSES], c, d;
diff --git a/test/122_gendata_h48short/gendata_h48short_tests.c b/test/122_gendata_h48short/gendata_h48short_tests.c
index efd378b..0996f8c 100644
--- a/test/122_gendata_h48short/gendata_h48short_tests.c
+++ b/test/122_gendata_h48short/gendata_h48short_tests.c
@@ -34,7 +34,7 @@ void run(void) {
34 34
35 capacity = readl(); 35 capacity = readl();
36 randomizer = readl(); 36 randomizer = readl();
37 arg.maxdepth = readl(); 37 arg.maxdepth = (uint8_t)readl();
38 arg.crep = crep; 38 arg.crep = crep;
39 arg.selfsim = selfsim; 39 arg.selfsim = selfsim;
40 arg.map = &map; 40 arg.map = &map;
diff --git a/test/131_coorddata_dr/coorddata_dr.c b/test/131_coorddata_dr/coorddata_dr.c
index d8ac94a..d262fe3 100644
--- a/test/131_coorddata_dr/coorddata_dr.c
+++ b/test/131_coorddata_dr/coorddata_dr.c
@@ -11,7 +11,7 @@ size_t coordinate_dr_gendata(unsigned char *);
11 11
12void run(void) { 12void run(void) {
13 bool found; 13 bool found;
14 uint64_t t; 14 uint8_t t;
15 char str[STRLENMAX]; 15 char str[STRLENMAX];
16 unsigned char *data; 16 unsigned char *data;
17 size_t size; 17 size_t size;
@@ -33,8 +33,8 @@ void run(void) {
33 goto cleanup; 33 goto cleanup;
34 } 34 }
35 35
36 for (t = 0, found = false; t < 48; t++) { 36 for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) {
37 if (!((UINT64_C(1) << t) & TGROUP)) 37 if (!((UINT64_C(1) << (uint8_t)t) & TGROUP))
38 continue; 38 continue;
39 39
40 coord2 = coordinate_dr_coord(transform(cube, t), data); 40 coord2 = coordinate_dr_coord(transform(cube, t), data);
diff --git a/test/132_coorddata_dreo/coorddata_dreo.c b/test/132_coorddata_dreo/coorddata_dreo.c
index 2b99b7f..50294ff 100644
--- a/test/132_coorddata_dreo/coorddata_dreo.c
+++ b/test/132_coorddata_dreo/coorddata_dreo.c
@@ -11,7 +11,7 @@ size_t coordinate_dreo_gendata(unsigned char *);
11 11
12void run(void) { 12void run(void) {
13 bool found; 13 bool found;
14 uint64_t t; 14 uint8_t t;
15 char str[STRLENMAX]; 15 char str[STRLENMAX];
16 unsigned char *data; 16 unsigned char *data;
17 size_t size; 17 size_t size;
@@ -33,8 +33,8 @@ void run(void) {
33 goto cleanup; 33 goto cleanup;
34 } 34 }
35 35
36 for (t = 0, found = false; t < 48; t++) { 36 for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) {
37 if (!((UINT64_C(1) << t) & TGROUP)) 37 if (!((UINT64_C(1) << (uint64_t)t) & TGROUP))
38 continue; 38 continue;
39 39
40 coord2 = coordinate_dreo_coord(transform(cube, t), data); 40 coord2 = coordinate_dreo_coord(transform(cube, t), data);
diff --git a/test/133_coordata_drfinnoe/coorddata_drfinnoe.c b/test/133_coordata_drfinnoe/coorddata_drfinnoe.c
index 11ae9f7..7d19361 100644
--- a/test/133_coordata_drfinnoe/coorddata_drfinnoe.c
+++ b/test/133_coordata_drfinnoe/coorddata_drfinnoe.c
@@ -10,7 +10,7 @@ size_t coordinate_drfinnoe_gendata(unsigned char *);
10 10
11void run(void) { 11void run(void) {
12 bool found; 12 bool found;
13 uint64_t t; 13 uint8_t t;
14 char str[STRLENMAX]; 14 char str[STRLENMAX];
15 unsigned char *data; 15 unsigned char *data;
16 size_t size; 16 size_t size;
@@ -32,8 +32,8 @@ void run(void) {
32 goto cleanup; 32 goto cleanup;
33 } 33 }
34 34
35 for (t = 0, found = false; t < 48; t++) { 35 for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) {
36 if (!((UINT64_C(1) << t) & TGROUP)) 36 if (!((UINT64_C(1) << (uint64_t)t) & TGROUP))
37 continue; 37 continue;
38 38
39 coord2 = coordinate_drfinnoe_coord(transform(cube, t), data); 39 coord2 = coordinate_drfinnoe_coord(transform(cube, t), data);
diff --git a/test/140_appendsolution/appendsolution_tests.c b/test/140_appendsolution/appendsolution_tests.c
index 9f9e9f4..3f4fb15 100644
--- a/test/140_appendsolution/appendsolution_tests.c
+++ b/test/140_appendsolution/appendsolution_tests.c
@@ -39,7 +39,7 @@ void run(void) {
39 .unniss = false, 39 .unniss = false,
40 .maxmoves = 20, 40 .maxmoves = 20,
41 .maxsolutions = 100, 41 .maxsolutions = 100,
42 .optimal = -1, 42 .optimal = 0,
43 }; 43 };
44 44
45 fgets(str, STRLENMAX, stdin); 45 fgets(str, STRLENMAX, stdin);
@@ -48,8 +48,8 @@ void run(void) {
48 printf("Test error reading moves\n"); 48 printf("Test error reading moves\n");
49 return; 49 return;
50 } 50 }
51 moves.nmoves = nm; 51 moves.nmoves = (uint8_t)nm;
52 moves.npremoves = np; 52 moves.npremoves = (uint8_t)np;
53 fgets(str, STRLENMAX, stdin); 53 fgets(str, STRLENMAX, stdin);
54 settings.unniss = (bool)atoi(str); 54 settings.unniss = (bool)atoi(str);
55 55
@@ -64,7 +64,7 @@ void run(void) {
64 } 64 }
65 } 65 }
66 fgets(str, STRLENMAX, stdin); 66 fgets(str, STRLENMAX, stdin);
67 settings.orientation = atoi(str); 67 settings.orientation = (uint8_t)atoi(str);
68 68
69 appendsolution(&moves, nnt, tmask, &settings, &list); 69 appendsolution(&moves, nnt, tmask, &settings, &list);
70 70
diff --git a/tools/solvetest.h b/tools/solvetest.h
index 3c9badc..8c93d21 100644
--- a/tools/solvetest.h
+++ b/tools/solvetest.h
@@ -130,7 +130,7 @@ int main(int argc, char **argv) {
130 printf("Using user-specified solver %s\n", solver); 130 printf("Using user-specified solver %s\n", solver);
131 } 131 }
132 132
133 srand(time(NULL)); 133 srand((unsigned)time(NULL));
134 nissy_setlogger(log_stderr, NULL); 134 nissy_setlogger(log_stderr, NULL);
135 135
136 size = nissy_solverinfo(solver, dataid); 136 size = nissy_solverinfo(solver, dataid);

Generated with cgit - Back to sebastiano.tronto.net