diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
| commit | fc41f7917531693680b5baf71ffe38c47333fe84 (patch) | |
| tree | a6e62232e05e7779034c5f9d1bf743b6f1c198e3 /src/solvers/coord/gendata.h | |
| parent | fe534f1497da6447153064d7bba00243000f803b (diff) | |
| download | nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.tar.gz nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.zip | |
Make the project build with Microsoft's broken C compiler.
MSVC is not fully C11-compliant, even when compiling with /std:c11.
Some changes were needed to make the codebase compatible. Notably, the
notation a[static N] and a[n] for function parameters of array type is
not supported, so that had to be hidden behind a macro. Atomic types
are also an experimental feature, apparently, but at least they work
with the correct compiler flag.
One thing that MSVC does well, however, is warning on integer conversions
on /W4 level. I am not sure if Clang and GCC have something similar,
so I took this chance to fix some of these.
Diffstat (limited to 'src/solvers/coord/gendata.h')
| -rw-r--r-- | src/solvers/coord/gendata.h | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h index cbc8774..edf6ce6 100644 --- a/src/solvers/coord/gendata.h +++ b/src/solvers/coord/gendata.h | |||
| @@ -1,21 +1,21 @@ | |||
| 1 | STATIC size_t gendata_coord(const coord_t [static 1], unsigned char *); | 1 | STATIC size_t gendata_coord(const coord_t [NON_NULL], unsigned char *); |
| 2 | STATIC size_t gendata_multicoord( | 2 | STATIC size_t gendata_multicoord( |
| 3 | const multicoord_t [static 1], unsigned char *); | 3 | const multicoord_t [NON_NULL], unsigned char *); |
| 4 | STATIC long long gendata_coord_dispatch(const char *, unsigned long long, | 4 | STATIC long long gendata_coord_dispatch(const char *, unsigned long long, |
| 5 | unsigned char *); | 5 | unsigned char *); |
| 6 | STATIC tableinfo_t genptable_coord( | 6 | STATIC tableinfo_t genptable_coord( |
| 7 | const coord_t [static 1], const unsigned char *, unsigned char *); | 7 | const coord_t [NON_NULL], const unsigned char *, unsigned char *); |
| 8 | STATIC uint64_t genptable_coord_init_solved( | 8 | STATIC uint64_t genptable_coord_init_solved( |
| 9 | const coord_t [static 1], const unsigned char *, unsigned char *); | 9 | const coord_t [NON_NULL], const unsigned char *, unsigned char *); |
| 10 | STATIC bool switch_to_fromnew(uint64_t, uint64_t, uint64_t); | 10 | STATIC bool switch_to_fromnew(uint64_t, uint64_t, uint64_t); |
| 11 | STATIC uint64_t genptable_coord_fillneighbors(const coord_t [static 1], | 11 | STATIC uint64_t genptable_coord_fillneighbors(const coord_t [NON_NULL], |
| 12 | const unsigned char *, uint64_t, uint8_t, unsigned char *); | 12 | const unsigned char *, uint64_t, uint8_t, unsigned char *); |
| 13 | STATIC uint64_t genptable_coord_fillfromnew(const coord_t [static 1], | 13 | STATIC uint64_t genptable_coord_fillfromnew(const coord_t [NON_NULL], |
| 14 | const unsigned char *, uint64_t, uint8_t, unsigned char *); | 14 | const unsigned char *, uint64_t, uint8_t, unsigned char *); |
| 15 | STATIC uint8_t get_coord_pval( | 15 | STATIC uint8_t get_coord_pval( |
| 16 | const coord_t [static 1], const unsigned char *, uint64_t); | 16 | const coord_t [NON_NULL], const unsigned char *, uint64_t); |
| 17 | STATIC void set_coord_pval( | 17 | STATIC void set_coord_pval( |
| 18 | const coord_t [static 1], unsigned char *, uint64_t, uint8_t); | 18 | const coord_t [NON_NULL], unsigned char *, uint64_t, uint8_t); |
| 19 | 19 | ||
| 20 | STATIC long long | 20 | STATIC long long |
| 21 | gendata_coord_dispatch( | 21 | gendata_coord_dispatch( |
| @@ -40,7 +40,7 @@ gendata_coord_dispatch( | |||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | STATIC size_t | 42 | STATIC size_t |
| 43 | gendata_coord(const coord_t coord[static 1], unsigned char *buf) | 43 | gendata_coord(const coord_t coord[NON_NULL], unsigned char *buf) |
| 44 | { | 44 | { |
| 45 | uint64_t coord_dsize, tablesize, ninfo; | 45 | uint64_t coord_dsize, tablesize, ninfo; |
| 46 | unsigned char *pruningbuf, *coord_data; | 46 | unsigned char *pruningbuf, *coord_data; |
| @@ -96,7 +96,7 @@ gendata_coord_error: | |||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | STATIC size_t | 98 | STATIC size_t |
| 99 | gendata_multicoord(const multicoord_t mcoord[static 1], unsigned char *buf) | 99 | gendata_multicoord(const multicoord_t mcoord[NON_NULL], unsigned char *buf) |
| 100 | { | 100 | { |
| 101 | unsigned char *b; | 101 | unsigned char *b; |
| 102 | size_t i, s, ret; | 102 | size_t i, s, ret; |
| @@ -141,12 +141,13 @@ gendata_multicoord(const multicoord_t mcoord[static 1], unsigned char *buf) | |||
| 141 | 141 | ||
| 142 | STATIC tableinfo_t | 142 | STATIC tableinfo_t |
| 143 | genptable_coord( | 143 | genptable_coord( |
| 144 | const coord_t coord[static 1], | 144 | const coord_t coord[NON_NULL], |
| 145 | const unsigned char *data, | 145 | const unsigned char *data, |
| 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)) { |
| @@ -204,7 +205,7 @@ genptable_coord( | |||
| 204 | 205 | ||
| 205 | STATIC uint64_t | 206 | STATIC uint64_t |
| 206 | genptable_coord_init_solved( | 207 | genptable_coord_init_solved( |
| 207 | const coord_t coord[static 1], | 208 | const coord_t coord[NON_NULL], |
| 208 | const unsigned char *coord_data, | 209 | const unsigned char *coord_data, |
| 209 | unsigned char *table | 210 | unsigned char *table |
| 210 | ) | 211 | ) |
| @@ -238,7 +239,7 @@ switch_to_fromnew(uint64_t done, uint64_t max, uint64_t nm) | |||
| 238 | 239 | ||
| 239 | STATIC uint64_t | 240 | STATIC uint64_t |
| 240 | genptable_coord_fillneighbors( | 241 | genptable_coord_fillneighbors( |
| 241 | const coord_t coord[static 1], | 242 | const coord_t coord[NON_NULL], |
| 242 | const unsigned char *data, | 243 | const unsigned char *data, |
| 243 | uint64_t i, | 244 | uint64_t i, |
| 244 | uint8_t d, | 245 | uint8_t d, |
| @@ -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); |
| @@ -276,7 +278,7 @@ genptable_coord_fillneighbors( | |||
| 276 | 278 | ||
| 277 | STATIC uint64_t | 279 | STATIC uint64_t |
| 278 | genptable_coord_fillfromnew( | 280 | genptable_coord_fillfromnew( |
| 279 | const coord_t coord[static 1], | 281 | const coord_t coord[NON_NULL], |
| 280 | const unsigned char *data, | 282 | const unsigned char *data, |
| 281 | uint64_t i, | 283 | uint64_t i, |
| 282 | uint8_t d, | 284 | uint8_t d, |
| @@ -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); |
| @@ -331,7 +334,7 @@ genptable_coord_fillfromnew( | |||
| 331 | 334 | ||
| 332 | STATIC uint8_t | 335 | STATIC uint8_t |
| 333 | get_coord_pval( | 336 | get_coord_pval( |
| 334 | const coord_t coord[static 1], | 337 | const coord_t coord[NON_NULL], |
| 335 | const unsigned char *table, | 338 | const unsigned char *table, |
| 336 | uint64_t i | 339 | uint64_t i |
| 337 | ) | 340 | ) |
| @@ -341,7 +344,7 @@ get_coord_pval( | |||
| 341 | 344 | ||
| 342 | STATIC void | 345 | STATIC void |
| 343 | set_coord_pval( | 346 | set_coord_pval( |
| 344 | const coord_t coord[static 1], | 347 | const coord_t coord[NON_NULL], |
| 345 | unsigned char *table, | 348 | unsigned char *table, |
| 346 | uint64_t i, | 349 | uint64_t i, |
| 347 | uint8_t val | 350 | uint8_t val |
