aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord
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 /src/solvers/coord
parent0d4fa9ebbfcadfff4baf8fc3cd32a63dcfd7dd43 (diff)
downloadnissy-core-c-portability.tar.gz
nissy-core-c-portability.zip
Fix integer conversions in code, tests and some toolsc-portability
Diffstat (limited to 'src/solvers/coord')
-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
4 files changed, 30 insertions, 25 deletions
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

Generated with cgit - Back to sebastiano.tronto.net