From fc41f7917531693680b5baf71ffe38c47333fe84 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 6 Apr 2026 15:55:33 +0200 Subject: 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. --- src/solvers/coord/common.h | 42 +++++++++---------- src/solvers/coord/gendata.h | 51 +++++++++++++----------- src/solvers/coord/htr.h | 4 +- src/solvers/coord/multisolve.h | 32 +++++++-------- src/solvers/coord/solve.h | 36 ++++++++--------- src/solvers/coord/types_macros.h | 4 +- src/solvers/coord/utils.h | 4 +- src/solvers/dispatch.h | 4 +- src/solvers/distribution.h | 14 +++---- src/solvers/h48/coordinate.h | 8 ++-- src/solvers/h48/distribution_h48.h | 6 +-- src/solvers/h48/gendata_cocsep.h | 21 +++++----- src/solvers/h48/gendata_eoesep.h | 62 ++++++++++++++-------------- src/solvers/h48/gendata_h48.h | 36 ++++++++--------- src/solvers/h48/map.h | 28 ++++++------- src/solvers/h48/solve.h | 68 +++++++++++++++---------------- src/solvers/h48/utils.h | 10 ++--- src/solvers/solutions.h | 82 +++++++++++++++++++------------------- src/solvers/tables.h | 26 ++++++------ 19 files changed, 272 insertions(+), 266 deletions(-) (limited to 'src/solvers') diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index d154636..3a62e85 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h @@ -1,16 +1,16 @@ STATIC uint64_t coord_coord_generic( - const coord_t [static 1], cube_t, const unsigned char *); + const coord_t [NON_NULL], cube_t, const unsigned char *); STATIC cube_t coord_cube_generic( - const coord_t [static 1], uint64_t, const unsigned char *); + const coord_t [NON_NULL], uint64_t, const unsigned char *); STATIC bool coord_isnasty_generic( - const coord_t [static 1], uint64_t, const unsigned char *); -STATIC size_t coord_gendata_generic(const coord_t [static 1], unsigned char *); + const coord_t [NON_NULL], uint64_t, const unsigned char *); +STATIC size_t coord_gendata_generic(const coord_t [NON_NULL], unsigned char *); -STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]); -STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *, +STATIC bool solution_lastqt_cw(const solution_moves_t [NON_NULL]); +STATIC bool coord_can_switch(const coord_t [NON_NULL], const unsigned char *, size_t, const uint8_t *); STATIC bool coord_is_solved( - const coord_t [static 1], uint64_t, const unsigned char *); + const coord_t [NON_NULL], uint64_t, const unsigned char *); STATIC cube_t coordinate_merge_ce(cube_t, cube_t); STATIC cube_t coordinate_merge_ec(cube_t, cube_t); @@ -18,7 +18,7 @@ STATIC cube_t coordinate_merge_cpco(cube_t, cube_t); STATIC uint64_t coord_coord_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], cube_t c, const unsigned char *data ) @@ -36,7 +36,7 @@ coord_coord_generic( STATIC cube_t coord_cube_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], uint64_t i, const unsigned char *data ) @@ -54,7 +54,7 @@ coord_cube_generic( STATIC bool coord_isnasty_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], uint64_t i, const unsigned char *data ) @@ -73,11 +73,12 @@ coord_isnasty_generic( STATIC size_t coord_gendata_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], unsigned char *data ) { - uint64_t i, j, n, t, nasty; + uint64_t i, j, n, nasty; + uint8_t t; unsigned char *datanoinfo; uint32_t *classttrep, *rep; size_t coord_datasize; @@ -122,16 +123,17 @@ coord_gendata_generic( } for (t = 0; t < NTRANS; t++) { - if (!((UINT64_C(1) << t) & coord->trans_mask)) + if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) continue; j = coord->sym.coord(transform(c, t)); - classttrep[j] = + classttrep[j] = (uint32_t)( (n << COORD_CLASS_SHIFT) | (nasty << COORD_ISNASTY_SHIFT) | - (inverse_trans(t) << COORD_TTREP_SHIFT); + (inverse_trans(t) << COORD_TTREP_SHIFT) + ); } - rep[n++] = i; + rep[n++] = (uint32_t)i; } writetableinfo(&info, coord_datasize, data); @@ -144,21 +146,21 @@ coord_gendata_generic( } STATIC bool -solution_lastqt_cw(const solution_moves_t s[static 1]) +solution_lastqt_cw(const solution_moves_t s[NON_NULL]) { return are_lastmoves_singlecw(s->nmoves, s->moves) && are_lastmoves_singlecw(s->npremoves, s->premoves); } STATIC bool -solution_always_valid(const solution_moves_t s[static 1]) +solution_always_valid(const solution_moves_t s[NON_NULL]) { return true; } STATIC bool coord_can_switch( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], const unsigned char *data, size_t n, const uint8_t *moves @@ -192,7 +194,7 @@ coord_can_switch( STATIC bool coord_is_solved( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], uint64_t i, const unsigned char *data ) 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 @@ -STATIC size_t gendata_coord(const coord_t [static 1], unsigned char *); +STATIC size_t gendata_coord(const coord_t [NON_NULL], unsigned char *); STATIC size_t gendata_multicoord( - const multicoord_t [static 1], unsigned char *); + const multicoord_t [NON_NULL], unsigned char *); STATIC long long gendata_coord_dispatch(const char *, unsigned long long, unsigned char *); STATIC tableinfo_t genptable_coord( - const coord_t [static 1], const unsigned char *, unsigned char *); + const coord_t [NON_NULL], const unsigned char *, unsigned char *); STATIC uint64_t genptable_coord_init_solved( - const coord_t [static 1], const unsigned char *, unsigned char *); + const coord_t [NON_NULL], const unsigned char *, unsigned char *); STATIC bool switch_to_fromnew(uint64_t, uint64_t, uint64_t); -STATIC uint64_t genptable_coord_fillneighbors(const coord_t [static 1], +STATIC uint64_t genptable_coord_fillneighbors(const coord_t [NON_NULL], const unsigned char *, uint64_t, uint8_t, unsigned char *); -STATIC uint64_t genptable_coord_fillfromnew(const coord_t [static 1], +STATIC uint64_t genptable_coord_fillfromnew(const coord_t [NON_NULL], const unsigned char *, uint64_t, uint8_t, unsigned char *); STATIC uint8_t get_coord_pval( - const coord_t [static 1], const unsigned char *, uint64_t); + const coord_t [NON_NULL], const unsigned char *, uint64_t); STATIC void set_coord_pval( - const coord_t [static 1], unsigned char *, uint64_t, uint8_t); + const coord_t [NON_NULL], unsigned char *, uint64_t, uint8_t); STATIC long long gendata_coord_dispatch( @@ -40,7 +40,7 @@ gendata_coord_dispatch( } STATIC size_t -gendata_coord(const coord_t coord[static 1], unsigned char *buf) +gendata_coord(const coord_t coord[NON_NULL], unsigned char *buf) { uint64_t coord_dsize, tablesize, ninfo; unsigned char *pruningbuf, *coord_data; @@ -96,7 +96,7 @@ gendata_coord_error: } STATIC size_t -gendata_multicoord(const multicoord_t mcoord[static 1], unsigned char *buf) +gendata_multicoord(const multicoord_t mcoord[NON_NULL], unsigned char *buf) { unsigned char *b; size_t i, s, ret; @@ -141,12 +141,13 @@ gendata_multicoord(const multicoord_t mcoord[static 1], unsigned char *buf) STATIC tableinfo_t genptable_coord( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], const unsigned char *data, unsigned char *table ) { - uint64_t tablesize, i, d, tot, t, nm; + uint64_t tablesize, i, tot, t, nm; + uint8_t d; tableinfo_t info; tablesize = DIV_ROUND_UP(coord->max, 2); @@ -170,7 +171,7 @@ genptable_coord( tot = info.distribution[0] = genptable_coord_init_solved(coord, data, table); - nm = popcount_u32(coord->moves_mask_gendata); + nm = popcount_u64(coord->moves_mask_gendata); for (d = 1; tot < coord->max && d < 15; d++) { t = 0; if (switch_to_fromnew(tot, coord->max, nm)) { @@ -204,7 +205,7 @@ genptable_coord( STATIC uint64_t genptable_coord_init_solved( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], const unsigned char *coord_data, unsigned char *table ) @@ -238,7 +239,7 @@ switch_to_fromnew(uint64_t done, uint64_t max, uint64_t nm) STATIC uint64_t genptable_coord_fillneighbors( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], const unsigned char *data, uint64_t i, uint8_t d, @@ -247,20 +248,21 @@ genptable_coord_fillneighbors( { bool isnasty; uint8_t m; - uint64_t ii, j, t, tot; + uint64_t ii, j, tot; + uint8_t t; cube_t c, moved; c = coord->cube(i, data); tot = 0; for (m = 0; m < NMOVES; m++) { - if (!((UINT32_C(1) << (uint32_t)m) & + if (!((UINT64_C(1) << (uint64_t)m) & coord->moves_mask_gendata)) continue; moved = move(c, m); ii = coord->coord(moved, data); isnasty = coord->isnasty(ii, data); for (t = 0; t < NTRANS && (t == 0 || isnasty); t++) { - if (!((UINT64_C(1) << t) & coord->trans_mask)) + if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) continue; j = coord->coord(transform(moved, t), data); @@ -276,7 +278,7 @@ genptable_coord_fillneighbors( STATIC uint64_t genptable_coord_fillfromnew( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], const unsigned char *data, uint64_t i, uint8_t d, @@ -285,14 +287,15 @@ genptable_coord_fillfromnew( { bool found; uint8_t m; - uint64_t tot, t, ii, j, nsim, sim[NTRANS]; + uint64_t tot, j, ii, nsim, sim[NTRANS]; + uint8_t t; cube_t c; tot = 0; c = coord->cube(i, data); for (t = 0, nsim = 0; t < NTRANS; t++) { - if (!((UINT64_C(1) << t) & coord->trans_mask)) + if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) continue; ii = coord->coord(transform(c, t), data); @@ -305,7 +308,7 @@ genptable_coord_fillfromnew( for (j = 0, found = false; j < nsim && !found; j++) { c = coord->cube(sim[j], data); for (m = 0; m < NMOVES; m++) { - if (!((UINT32_C(1) << (uint32_t)m) & + if (!((UINT64_C(1) << (uint64_t)m) & coord->moves_mask_gendata)) continue; ii = coord->coord(move(c, m), data); @@ -331,7 +334,7 @@ genptable_coord_fillfromnew( STATIC uint8_t get_coord_pval( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], const unsigned char *table, uint64_t i ) @@ -341,7 +344,7 @@ get_coord_pval( STATIC void set_coord_pval( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], unsigned char *table, uint64_t i, uint8_t val diff --git a/src/solvers/coord/htr.h b/src/solvers/coord/htr.h index cfd451b..602625b 100644 --- a/src/solvers/coord/htr.h +++ b/src/solvers/coord/htr.h @@ -4,7 +4,7 @@ STATIC bool coordinate_htr_isnasty(uint64_t, const unsigned char *); STATIC size_t coordinate_htr_gendata(unsigned char *); STATIC bool htr_checkmoves(bool *, uint8_t, const uint8_t *); -STATIC bool htr_solution_prune(const solution_moves_t [static 1]); +STATIC bool htr_solution_prune(const solution_moves_t [NON_NULL]); STATIC bool is_cp_htr(uint64_t, const unsigned char *); STATIC coord_t coordinate_htr = { @@ -97,7 +97,7 @@ htr_checkmoves(bool *f, uint8_t n, const uint8_t *moves) } STATIC bool -htr_solution_prune(const solution_moves_t s[static 1]) +htr_solution_prune(const solution_moves_t s[NON_NULL]) { bool f; diff --git a/src/solvers/coord/multisolve.h b/src/solvers/coord/multisolve.h index a45bd6a..efd287d 100644 --- a/src/solvers/coord/multisolve.h +++ b/src/solvers/coord/multisolve.h @@ -16,20 +16,20 @@ typedef struct { const unsigned char *ptable[MAX_MULTICOORD_NCOORDS]; } dfsarg_solve_multicoord_t; -STATIC int64_t solve_multicoord(oriented_cube_t, multicoord_t [static 1], +STATIC int64_t solve_multicoord(oriented_cube_t, multicoord_t [NON_NULL], uint8_t, uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, const unsigned char *, size_t, char *, int (*)(void *), void *); STATIC long long solve_multicoord_dispatch(oriented_cube_t, const char *, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, const unsigned char *, unsigned, char *, - long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); + long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); STATIC bool multicoord_solution_admissible( - const dfsarg_solve_multicoord_t [static 1]); -STATIC bool multicoord_dfs_stop(const dfsarg_solve_multicoord_t [static 1]); -STATIC int64_t solve_multicoord_dfs(dfsarg_solve_multicoord_t [static 1]); + const dfsarg_solve_multicoord_t [NON_NULL]); +STATIC bool multicoord_dfs_stop(const dfsarg_solve_multicoord_t [NON_NULL]); +STATIC int64_t solve_multicoord_dfs(dfsarg_solve_multicoord_t [NON_NULL]); STATIC bool -multicoord_solution_admissible(const dfsarg_solve_multicoord_t arg[static 1]) +multicoord_solution_admissible(const dfsarg_solve_multicoord_t arg[NON_NULL]) { uint8_t n, i; const coord_t *c; @@ -49,7 +49,7 @@ multicoord_solution_admissible(const dfsarg_solve_multicoord_t arg[static 1]) } STATIC bool -multicoord_dfs_stop(const dfsarg_solve_multicoord_t arg[static 1]) +multicoord_dfs_stop(const dfsarg_solve_multicoord_t arg[NON_NULL]) { uint8_t pval, i; uint64_t cval; @@ -69,11 +69,10 @@ multicoord_dfs_stop(const dfsarg_solve_multicoord_t arg[static 1]) } STATIC int64_t -solve_multicoord_dfs(dfsarg_solve_multicoord_t arg[static 1]) +solve_multicoord_dfs(dfsarg_solve_multicoord_t arg[NON_NULL]) { uint8_t m, l, i; - uint32_t mm; - uint64_t coord; + uint64_t mm, coord; int64_t n, ret; const coord_t *c; cube_t backup_cube, backup_inverse; @@ -108,7 +107,7 @@ solve_multicoord_dfs_notsolved: arg->solution_moves->nmoves++; for (m = 0; m < NMOVES; m++) { - if (!(mm & (UINT32_C(1) << (uint32_t)m))) + if (!(mm & (UINT64_C(1) << (uint64_t)m))) continue; arg->solution_moves->moves[l] = m; @@ -141,7 +140,7 @@ solve_multicoord_dispatch( const unsigned char *data, unsigned solutions_size, char *sols, - long long stats[static NISSY_SIZE_SOLVE_STATS], + long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], int (*poll_status)(void *), void *poll_status_data ) @@ -163,15 +162,16 @@ solve_multicoord_dispatch( return NISSY_ERROR_INVALID_SOLVER; } - return solve_multicoord(oc, mcoord, trans, minmoves, - maxmoves, maxsolutions, optimal, threads, data_size, data, - solutions_size, sols, poll_status, poll_status_data); + return solve_multicoord(oc, mcoord, trans, (uint8_t)minmoves, + (uint8_t)maxmoves, (uint8_t)maxsolutions, (uint8_t)optimal, + (uint8_t)threads, data_size, data, solutions_size, sols, + poll_status, poll_status_data); } STATIC int64_t solve_multicoord( oriented_cube_t oc, - multicoord_t mcoord [static 1], + multicoord_t mcoord [NON_NULL], uint8_t trans, uint8_t minmoves, uint8_t maxmoves, diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index 9ea6d1a..6bb9af2 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h @@ -13,20 +13,20 @@ typedef struct { const unsigned char *ptable; } dfsarg_solve_coord_t; -STATIC int64_t solve_coord(oriented_cube_t, coord_t [static 1], uint8_t, +STATIC int64_t solve_coord(oriented_cube_t, coord_t [NON_NULL], uint8_t, uint8_t, uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, const unsigned char *, size_t, char *, int (*)(void *), void *); STATIC long long solve_coord_dispatch(oriented_cube_t, const char *, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, const unsigned char *, unsigned, char *, - long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); -STATIC bool coord_solution_admissible(const dfsarg_solve_coord_t [static 1]); -STATIC bool coord_continue_onnormal(const dfsarg_solve_coord_t [static 1]); -STATIC bool coord_continue_oninverse(const dfsarg_solve_coord_t [static 1]); -STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t [static 1]); + long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); +STATIC bool coord_solution_admissible(const dfsarg_solve_coord_t [NON_NULL]); +STATIC bool coord_continue_onnormal(const dfsarg_solve_coord_t [NON_NULL]); +STATIC bool coord_continue_oninverse(const dfsarg_solve_coord_t [NON_NULL]); +STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t [NON_NULL]); STATIC bool -coord_solution_admissible(const dfsarg_solve_coord_t arg[static 1]) +coord_solution_admissible(const dfsarg_solve_coord_t arg[NON_NULL]) { uint8_t n; @@ -39,7 +39,7 @@ coord_solution_admissible(const dfsarg_solve_coord_t arg[static 1]) } STATIC bool -coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1]) +coord_continue_onnormal(const dfsarg_solve_coord_t arg[NON_NULL]) { uint8_t flag, nn, ni, swbound_n, swbound_i, pval; uint64_t coord; @@ -93,7 +93,7 @@ coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1]) } STATIC bool -coord_continue_oninverse(const dfsarg_solve_coord_t arg[static 1]) +coord_continue_oninverse(const dfsarg_solve_coord_t arg[NON_NULL]) { uint8_t flag, nn, ni, swbound_n, swbound_i, pval; uint64_t coord; @@ -147,12 +147,11 @@ coord_continue_oninverse(const dfsarg_solve_coord_t arg[static 1]) } STATIC int64_t -solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) +solve_coord_dfs(dfsarg_solve_coord_t arg[NON_NULL]) { bool lastbackup; uint8_t m, l, nnbackup, nibackup, nmoves; - uint32_t mm; - uint64_t coord; + uint64_t mm, coord; int64_t n, ret; cube_t backup_cube, backup_inverse; @@ -190,7 +189,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) arg->lastisnormal = true; for (m = 0; m < NMOVES; m++) { - if (!(mm & (UINT32_C(1) << (uint32_t)m))) + if (!(mm & (UINT64_C(1) << (uint64_t)m))) continue; arg->solution_moves->moves[l] = m; @@ -221,7 +220,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) arg->lastisnormal = false; for (m = 0; m < NMOVES; m++) { - if (!(mm & (UINT32_C(1) << (uint32_t)m))) + if (!(mm & (UINT64_C(1) << (uint64_t)m))) continue; arg->solution_moves->premoves[l] = m; @@ -258,7 +257,7 @@ solve_coord_dispatch( const unsigned char *data, unsigned solutions_size, char *sols, - long long stats[static NISSY_SIZE_SOLVE_STATS], + long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], int (*poll_status)(void *), void *poll_status_data ) @@ -280,15 +279,16 @@ solve_coord_dispatch( return NISSY_ERROR_INVALID_SOLVER; } - return solve_coord(oc, coord, trans, nissflag, minmoves, maxmoves, - maxsolutions, optimal, threads, data_size, data, + return solve_coord(oc, coord, trans, (uint8_t)nissflag, + (uint8_t)minmoves, (uint8_t)maxmoves, (uint8_t)maxsolutions, + (uint8_t)optimal, (uint8_t)threads, data_size, data, solutions_size, sols, poll_status, poll_status_data); } STATIC int64_t solve_coord( oriented_cube_t oc, - coord_t coord [static 1], + coord_t coord [NON_NULL], uint8_t trans, uint8_t nissflag, uint8_t minmoves, diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h index b75fab8..81db9d4 100644 --- a/src/solvers/coord/types_macros.h +++ b/src/solvers/coord/types_macros.h @@ -27,8 +27,8 @@ typedef struct { uint64_t moves_mask_gendata; uint64_t moves_mask_solve; uint64_t trans_mask; - bool (*is_admissible)(const solution_moves_t[static 1]); - bool (*solution_prune)(const solution_moves_t[static 1]); + bool (*is_admissible)(const solution_moves_t[NON_NULL]); + bool (*solution_prune)(const solution_moves_t[NON_NULL]); bool (*is_solvable)(cube_t); /* if is_solved is null, coord == 0 is used */ bool (*is_solved)(uint64_t, const unsigned char *); diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h index c8a9338..0062587 100644 --- a/src/solvers/coord/utils.h +++ b/src/solvers/coord/utils.h @@ -2,7 +2,7 @@ STATIC coord_t *parse_coord(size_t, const char *); STATIC multicoord_t *parse_multicoord(size_t, const char *); STATIC void parse_coord_and_trans( const char *, coord_t **, multicoord_t **, uint8_t *); -STATIC long long dataid_coord(const char *, char [static NISSY_SIZE_DATAID]); +STATIC long long dataid_coord(const char *, char [SIZE(NISSY_SIZE_DATAID)]); STATIC coord_t * parse_coord(size_t n, const char *coord) @@ -60,7 +60,7 @@ parse_coord_and_trans( } STATIC long long -dataid_coord(const char *ca, char dataid[static NISSY_SIZE_DATAID]) +dataid_coord(const char *ca, char dataid[SIZE(NISSY_SIZE_DATAID)]) { coord_t *c; multicoord_t *mc; diff --git a/src/solvers/dispatch.h b/src/solvers/dispatch.h index 3184a28..810247f 100644 --- a/src/solvers/dispatch.h +++ b/src/solvers/dispatch.h @@ -1,7 +1,7 @@ typedef struct { const char *solvername; const char *prefix; - long long (*dataid)(const char *, char [static NISSY_SIZE_DATAID]); + long long (*dataid)(const char *, char [SIZE(NISSY_SIZE_DATAID)]); long long (*gendata)( const char *, unsigned long long, unsigned char *); long long (*checkdata)( @@ -9,7 +9,7 @@ typedef struct { long long (*solve)(oriented_cube_t, const char *, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, const unsigned char *, unsigned, char *, - long long [static NISSY_SIZE_SOLVE_STATS], + long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); } solver_dispatch_t; diff --git a/src/solvers/distribution.h b/src/solvers/distribution.h index 78b9b5e..a996e3db 100644 --- a/src/solvers/distribution.h +++ b/src/solvers/distribution.h @@ -12,9 +12,9 @@ typedef struct { STATIC wrapthread_return_t getdistribution_runthread(void *); STATIC void getdistribution(const unsigned char *, - uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); -STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], - const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); + uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], const tableinfo_t [NON_NULL]); +STATIC bool distribution_equal(const uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], + const uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], uint8_t); STATIC wrapthread_return_t getdistribution_runthread(void *arg) @@ -39,8 +39,8 @@ getdistribution_runthread(void *arg) STATIC void getdistribution( const unsigned char *table, - uint64_t distr[static INFO_DISTRIBUTION_LEN], - const tableinfo_t info[static 1] + uint64_t distr[SIZE(INFO_DISTRIBUTION_LEN)], + const tableinfo_t info[NON_NULL] ) { getdistribution_data_t targ[THREADS]; wrapthread_define_var_thread_t(thread[THREADS]); @@ -80,8 +80,8 @@ getdistribution( STATIC bool distribution_equal( - const uint64_t expected[static INFO_DISTRIBUTION_LEN], - const uint64_t actual[static INFO_DISTRIBUTION_LEN], + const uint64_t expected[SIZE(INFO_DISTRIBUTION_LEN)], + const uint64_t actual[SIZE(INFO_DISTRIBUTION_LEN)], uint8_t maxvalue ) { diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h index a7f0087..695efc3 100644 --- a/src/solvers/h48/coordinate.h +++ b/src/solvers/h48/coordinate.h @@ -1,13 +1,13 @@ STATIC_INLINE uint64_t coord_h48( - cube_t, const uint32_t [static COCSEP_TABLESIZE], uint8_t); + cube_t, const uint32_t [SIZE(COCSEP_TABLESIZE)], uint8_t); STATIC_INLINE uint64_t coord_h48_edges(cube_t, uint64_t, uint8_t, uint8_t); STATIC_INLINE cube_t invcoord_h48( - uint64_t, const cube_t [static COCSEP_CLASSES], uint8_t); + uint64_t, const cube_t [SIZE(COCSEP_CLASSES)], uint8_t); STATIC_INLINE uint64_t coord_h48( cube_t c, - const uint32_t cocsepdata[static COCSEP_TABLESIZE], + const uint32_t cocsepdata[SIZE(COCSEP_TABLESIZE)], uint8_t h ) { @@ -47,7 +47,7 @@ returned cube is a transformed cube of one that gives the correct value. STATIC_INLINE cube_t invcoord_h48( uint64_t i, - const cube_t crep[static COCSEP_CLASSES], + const cube_t crep[SIZE(COCSEP_CLASSES)], uint8_t h ) { diff --git a/src/solvers/h48/distribution_h48.h b/src/solvers/h48/distribution_h48.h index 80c946e..2cb50aa 100644 --- a/src/solvers/h48/distribution_h48.h +++ b/src/solvers/h48/distribution_h48.h @@ -6,7 +6,7 @@ to have some duplication than to make these functions needlessly generic. STATIC wrapthread_return_t getdistribution_h48_runthread(void *); STATIC void getdistribution_h48(const unsigned char *, - uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); + uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], const tableinfo_t [NON_NULL]); STATIC wrapthread_return_t getdistribution_h48_runthread(void *arg) @@ -39,8 +39,8 @@ getdistribution_h48_runthread(void *arg) STATIC void getdistribution_h48( const unsigned char *table, - uint64_t distr[static INFO_DISTRIBUTION_LEN], - const tableinfo_t info[static 1] + uint64_t distr[SIZE(INFO_DISTRIBUTION_LEN)], + const tableinfo_t info[NON_NULL] ) { getdistribution_data_t targ[THREADS]; wrapthread_define_var_thread_t(thread[THREADS]); diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index db7ac95..f83207b 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h @@ -1,13 +1,13 @@ STATIC size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); -STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]); +STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [NON_NULL]); STATIC_INLINE bool gendata_cocsep_get_visited( - const uint8_t [static COCSEP_VISITEDSIZE], uint64_t); + const uint8_t [SIZE(COCSEP_VISITEDSIZE)], uint64_t); STATIC_INLINE void gendata_cocsep_set_visited( - uint8_t [static COCSEP_VISITEDSIZE], uint64_t); + uint8_t [SIZE(COCSEP_VISITEDSIZE)], uint64_t); STATIC_INLINE int8_t get_h48_cdata( - cube_t, const uint32_t [static COCSEP_TABLESIZE], uint32_t *); + cube_t, const uint32_t [SIZE(COCSEP_TABLESIZE)], uint32_t *); STATIC size_t gendata_cocsep( @@ -79,11 +79,10 @@ gendata_cocsep_return_size: } STATIC uint32_t -gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) +gendata_cocsep_dfs(cocsep_dfs_arg_t arg[NON_NULL]) { - uint8_t m; + uint8_t m, t; uint32_t cc, class, ttrep, depth, olddepth, tinv; - uint64_t t; uint64_t i, j; cube_t d; cocsep_dfs_arg_t nextarg; @@ -105,7 +104,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) d = transform_corners(arg->cube, t); j = coord_cocsep(d); if (i == j && arg->selfsim != NULL) - arg->selfsim[*arg->n] |= UINT64_C(1) << t; + arg->selfsim[*arg->n] |= UINT64_C(1) << (uint64_t)t; if (COCLASS(arg->buf32[j]) != UINT32_C(0xFFFF)) continue; gendata_cocsep_set_visited(arg->visited, j); @@ -135,7 +134,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) STATIC_INLINE bool gendata_cocsep_get_visited( - const uint8_t a[static COCSEP_VISITEDSIZE], + const uint8_t a[SIZE(COCSEP_VISITEDSIZE)], uint64_t i ) { @@ -144,7 +143,7 @@ gendata_cocsep_get_visited( STATIC_INLINE void gendata_cocsep_set_visited( - uint8_t a[static COCSEP_VISITEDSIZE], + uint8_t a[SIZE(COCSEP_VISITEDSIZE)], uint64_t i ) { @@ -154,7 +153,7 @@ gendata_cocsep_set_visited( STATIC_INLINE int8_t get_h48_cdata( cube_t cube, - const uint32_t cocsepdata[static COCSEP_TABLESIZE], + const uint32_t cocsepdata[SIZE(COCSEP_TABLESIZE)], uint32_t *cdata ) { diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h index e9a2794..81bbd43 100644 --- a/src/solvers/h48/gendata_eoesep.h +++ b/src/solvers/h48/gendata_eoesep.h @@ -1,25 +1,25 @@ -STATIC uint64_t coord_eoesep_sym(cube_t, const uint32_t [static ESEP_MAX]); +STATIC uint64_t coord_eoesep_sym(cube_t, const uint32_t [SIZE(ESEP_MAX)]); STATIC size_t gendata_esep_classes( - uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); + uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); STATIC size_t gendata_eoesep(unsigned char *, uint8_t); -STATIC uint32_t gendata_eoesep_bfs(uint8_t, uint8_t [static EOESEP_BUF], - uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); -STATIC uint32_t gendata_eoesep_fromnew(uint8_t, uint8_t [static EOESEP_BUF], - uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); -STATIC uint32_t gendata_eoesep_fromdone(uint8_t, uint8_t [static EOESEP_BUF], - uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); +STATIC uint32_t gendata_eoesep_bfs(uint8_t, uint8_t [SIZE(EOESEP_BUF)], + uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); +STATIC uint32_t gendata_eoesep_fromnew(uint8_t, uint8_t [SIZE(EOESEP_BUF)], + uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); +STATIC uint32_t gendata_eoesep_fromdone(uint8_t, uint8_t [SIZE(EOESEP_BUF)], + uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); STATIC uint32_t gendata_eoesep_marksim(uint64_t, uint8_t, - uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); + uint8_t [SIZE(EOESEP_BUF)], uint32_t [SIZE(ESEP_MAX)]); STATIC bool gendata_eoesep_next(cube_t, uint8_t, - uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); + uint8_t [SIZE(EOESEP_BUF)], uint32_t [SIZE(ESEP_MAX)]); STATIC uint8_t get_eoesep_pval( - const uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], uint64_t); + const uint8_t [SIZE(DIV_ROUND_UP(EOESEP_TABLESIZE, 2))], uint64_t); STATIC uint8_t get_eoesep_pval_cube(const unsigned char *, cube_t); STATIC void set_eoesep_pval( - uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], uint64_t, uint8_t); + uint8_t [SIZE(DIV_ROUND_UP(EOESEP_TABLESIZE, 2))], uint64_t, uint8_t); STATIC uint64_t -coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX]) +coord_eoesep_sym(cube_t c, const uint32_t esep_classes[SIZE(ESEP_MAX)]) { uint8_t ttrep; uint32_t edata, class; @@ -36,8 +36,8 @@ coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX]) STATIC size_t gendata_esep_classes( - uint32_t esep_classes[static ESEP_MAX], - uint16_t rep[static ESEP_CLASSES] + uint32_t esep_classes[SIZE(ESEP_MAX)], + uint16_t rep[SIZE(ESEP_CLASSES)] ) { bool visited[ESEP_MAX]; @@ -59,7 +59,7 @@ gendata_esep_classes( esep_classes[j] = cl | ti; visited[j] = true; } - rep[class] = i; + rep[class] = (uint16_t)i; class++; } @@ -121,8 +121,8 @@ STATIC uint32_t gendata_eoesep_bfs( uint8_t d, uint8_t buf8[EOESEP_BUF], - uint32_t esep_classes[static ESEP_MAX], - uint16_t rep[static ESEP_CLASSES] + uint32_t esep_classes[SIZE(ESEP_MAX)], + uint16_t rep[SIZE(ESEP_CLASSES)] ) { if (d < 9) @@ -135,12 +135,13 @@ STATIC uint32_t gendata_eoesep_fromdone( uint8_t d, uint8_t buf8[EOESEP_BUF], - uint32_t esep_classes[static ESEP_MAX], - uint16_t rep[static ESEP_CLASSES] + uint32_t esep_classes[SIZE(ESEP_MAX)], + uint16_t rep[SIZE(ESEP_CLASSES)] ) { uint8_t pval; - uint64_t i, esep, eo, coord, done; + uint32_t done; + uint64_t i, esep, eo, coord; done = 0; for (i = 0; i < ESEP_CLASSES; i++) { @@ -164,12 +165,13 @@ STATIC uint32_t gendata_eoesep_fromnew( uint8_t d, uint8_t buf8[EOESEP_BUF], - uint32_t esep_classes[static ESEP_MAX], - uint16_t rep[static ESEP_CLASSES] + uint32_t esep_classes[SIZE(ESEP_MAX)], + uint16_t rep[SIZE(ESEP_CLASSES)] ) { uint8_t pval; - uint64_t i, esep, eo, coord, done; + uint32_t done; + uint64_t i, esep, eo, coord; cube_t c; done = 0; @@ -196,8 +198,8 @@ STATIC uint32_t gendata_eoesep_marksim( uint64_t i, uint8_t d, - uint8_t buf8[static EOESEP_BUF], - uint32_t esep_classes[static ESEP_MAX] + uint8_t buf8[SIZE(EOESEP_BUF)], + uint32_t esep_classes[SIZE(ESEP_MAX)] ) { uint8_t t, m, pval; @@ -227,8 +229,8 @@ STATIC bool gendata_eoesep_next( cube_t c, uint8_t d, - uint8_t buf8[static EOESEP_BUF], - uint32_t esep_classes[static ESEP_MAX] + uint8_t buf8[SIZE(EOESEP_BUF)], + uint32_t esep_classes[SIZE(ESEP_MAX)] ) { uint8_t m, t, pval; @@ -251,7 +253,7 @@ gendata_eoesep_next( STATIC uint8_t get_eoesep_pval( - const uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], + const uint8_t table[SIZE(DIV_ROUND_UP(EOESEP_TABLESIZE, 2))], uint64_t i ) { @@ -270,7 +272,7 @@ get_eoesep_pval_cube(const unsigned char *data, cube_t c) STATIC void set_eoesep_pval( - uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], + uint8_t table[SIZE(DIV_ROUND_UP(EOESEP_TABLESIZE, 2))], uint64_t i, uint8_t val ) diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index b37bcfb..53b1fad 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h @@ -1,15 +1,15 @@ STATIC long long gendata_h48_dispatch( const char *, unsigned long long, unsigned char *); -STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); -STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]); -STATIC void gendata_h48_maintable(gendata_h48_arg_t [static 1]); +STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [NON_NULL]); +STATIC int64_t gendata_h48(gendata_h48_arg_t [NON_NULL]); +STATIC void gendata_h48_maintable(gendata_h48_arg_t [NON_NULL]); STATIC wrapthread_return_t gendata_h48_runthread(void *); -STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [static 1]); +STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [NON_NULL]); STATIC_INLINE bool gendata_h48_dfs_stop( - cube_t, int8_t, h48_dfs_arg_t [static 1]); -STATIC void gendata_h48_dfs(h48_dfs_arg_t [static 1]); -STATIC tableinfo_t makeinfo_h48(gendata_h48_arg_t [static 1]); + cube_t, int8_t, h48_dfs_arg_t [NON_NULL]); +STATIC void gendata_h48_dfs(h48_dfs_arg_t [NON_NULL]); +STATIC tableinfo_t makeinfo_h48(gendata_h48_arg_t [NON_NULL]); STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); STATIC const unsigned char *get_h48data_constptr(const unsigned char *); @@ -19,7 +19,7 @@ STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t); STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t); STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t); STATIC_INLINE uint8_t get_h48_pval_and_min( - const unsigned char *, uint64_t, uint8_t [static 1]); + const unsigned char *, uint64_t, uint8_t [NON_NULL]); STATIC long long gendata_h48_dispatch( @@ -43,7 +43,7 @@ gendata_h48_dispatch( } STATIC uint64_t -gendata_h48short(gendata_h48short_arg_t arg[static 1]) +gendata_h48short(gendata_h48short_arg_t arg[NON_NULL]) { uint8_t i, m; uint64_t coord; @@ -77,7 +77,7 @@ gendata_h48short(gendata_h48short_arg_t arg[static 1]) } STATIC int64_t -gendata_h48(gendata_h48_arg_t arg[static 1]) +gendata_h48(gendata_h48_arg_t arg[NON_NULL]) { uint64_t size, cocsepsize, h48size, eoesepsize; long long r; @@ -149,7 +149,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) } STATIC void -gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) +gendata_h48_maintable(gendata_h48_arg_t arg[NON_NULL]) { /* * A good base value for the h48 tables have few positions with value @@ -264,7 +264,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) velocity = count; /* We plan to log 10 times */ - sleeptime = (100*(nshort-velocity)) / velocity; + sleeptime = (int)((100*(nshort-velocity)) / velocity); done = count; while (nshort - done > (velocity * sleeptime) / 1000) { @@ -320,7 +320,7 @@ gendata_h48_runthread(void *arg) mutex = H48_LINE(coord) % CHUNKS; wrapthread_mutex_lock(dfsarg->table_mutex[mutex]); set_h48_pval(dfsarg->table, coordext, 0); - set_h48_pvalmin(dfsarg->table, coordmin, kv.val); + set_h48_pvalmin(dfsarg->table, coordmin, (uint8_t)kv.val); wrapthread_mutex_unlock(dfsarg->table_mutex[mutex]); } else { dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); @@ -332,7 +332,7 @@ gendata_h48_runthread(void *arg) } STATIC void -gendata_h48_dfs(h48_dfs_arg_t arg[static 1]) +gendata_h48_dfs(h48_dfs_arg_t arg[NON_NULL]) { int8_t d; uint8_t m[4]; @@ -411,7 +411,7 @@ gendata_h48_dfs(h48_dfs_arg_t arg[static 1]) } STATIC_INLINE void -gendata_h48_mark(gendata_h48_mark_t arg[static 1]) +gendata_h48_mark(gendata_h48_mark_t arg[NON_NULL]) { uint8_t oldval, newval, v; uint64_t coord, coordext, coordmin; @@ -435,7 +435,7 @@ gendata_h48_mark(gendata_h48_mark_t arg[static 1]) } STATIC_INLINE bool -gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[static 1]) +gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[NON_NULL]) { uint64_t val; uint64_t coord, coordext; @@ -463,7 +463,7 @@ gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[static 1]) } STATIC tableinfo_t -makeinfo_h48(gendata_h48_arg_t arg[static 1]) +makeinfo_h48(gendata_h48_arg_t arg[NON_NULL]) { tableinfo_t info; @@ -533,7 +533,7 @@ STATIC_INLINE uint8_t get_h48_pval_and_min( const unsigned char *table, uint64_t coord_noext, - uint8_t pval_min[static 1] + uint8_t pval_min[NON_NULL] ) { uint64_t iext, imin; diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index b603ee3..c9cfb06 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h @@ -1,13 +1,13 @@ -STATIC void h48map_create(h48map_t [static 1], uint64_t, uint64_t); -STATIC void h48map_clear(h48map_t [static 1]); -STATIC void h48map_destroy(h48map_t [static 1]); -STATIC uint64_t h48map_lookup(h48map_t [static 1], uint64_t); -STATIC void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t); -STATIC uint64_t h48map_value(h48map_t [static 1], uint64_t); -STATIC kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); +STATIC void h48map_create(h48map_t [NON_NULL], uint64_t, uint64_t); +STATIC void h48map_clear(h48map_t [NON_NULL]); +STATIC void h48map_destroy(h48map_t [NON_NULL]); +STATIC uint64_t h48map_lookup(h48map_t [NON_NULL], uint64_t); +STATIC void h48map_insertmin(h48map_t [NON_NULL], uint64_t, uint64_t); +STATIC uint64_t h48map_value(h48map_t [NON_NULL], uint64_t); +STATIC kvpair_t h48map_nextkvpair(h48map_t [NON_NULL], uint64_t [NON_NULL]); STATIC void -h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) +h48map_create(h48map_t map[NON_NULL], uint64_t capacity, uint64_t randomizer) { map->capacity = capacity; map->randomizer = randomizer; @@ -17,20 +17,20 @@ h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) } STATIC void -h48map_clear(h48map_t map[static 1]) +h48map_clear(h48map_t map[NON_NULL]) { memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); map->n = 0; } STATIC void -h48map_destroy(h48map_t map[static 1]) +h48map_destroy(h48map_t map[NON_NULL]) { free(map->table); } STATIC_INLINE uint64_t -h48map_lookup(h48map_t map[static 1], uint64_t x) +h48map_lookup(h48map_t map[NON_NULL], uint64_t x) { uint64_t hash, i; @@ -44,7 +44,7 @@ h48map_lookup(h48map_t map[static 1], uint64_t x) } STATIC_INLINE void -h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) +h48map_insertmin(h48map_t map[NON_NULL], uint64_t key, uint64_t val) { uint64_t i, oldval, min; @@ -57,13 +57,13 @@ h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) } STATIC_INLINE uint64_t -h48map_value(h48map_t map[static 1], uint64_t key) +h48map_value(h48map_t map[NON_NULL], uint64_t key) { return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; } STATIC kvpair_t -h48map_nextkvpair(h48map_t map[static 1], uint64_t p[static 1]) +h48map_nextkvpair(h48map_t map[NON_NULL], uint64_t p[NON_NULL]) { kvpair_t kv; uint64_t pair; diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 4fd0aea..ebc5208 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h @@ -64,27 +64,27 @@ typedef struct { STATIC long long solve_h48_dispatch(oriented_cube_t, const char *, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, const unsigned char *, unsigned, char *, - long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); -STATIC_INLINE void h48_prune_pipeline(dfsarg_solve_h48_t [static 1], - h48_prune_t [static NMOVES], uint8_t, bool); + long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); +STATIC_INLINE void h48_prune_pipeline(dfsarg_solve_h48_t [NON_NULL], + h48_prune_t [SIZE(NMOVES)], uint8_t, bool); STATIC_INLINE uint8_t h48_prune_lookup( - uint64_t, cube_t, dfsarg_solve_h48_t [static 1]); + uint64_t, cube_t, dfsarg_solve_h48_t [NON_NULL]); STATIC_INLINE uint8_t h48_prune_lookup_nocoord( - cube_t, dfsarg_solve_h48_t [static 1]); -STATIC_INLINE void h48_prune_restore_normal(const h48_prune_t [static 1], - dfsarg_solve_h48_t [static 1], uint8_t); -STATIC_INLINE void h48_prune_restore_inverse(const h48_prune_t [static 1], - dfsarg_solve_h48_t [static 1], uint8_t); + cube_t, dfsarg_solve_h48_t [NON_NULL]); +STATIC_INLINE void h48_prune_restore_normal(const h48_prune_t [NON_NULL], + dfsarg_solve_h48_t [NON_NULL], uint8_t); +STATIC_INLINE void h48_prune_restore_inverse(const h48_prune_t [NON_NULL], + dfsarg_solve_h48_t [NON_NULL], uint8_t); STATIC int64_t solve_h48_maketasks( - dfsarg_solve_h48_t [static 1], dfsarg_solve_h48_maketasks_t [static 1], - solve_h48_task_t [static H48_STARTING_CUBES], int [static 1]); + dfsarg_solve_h48_t [NON_NULL], dfsarg_solve_h48_maketasks_t [NON_NULL], + solve_h48_task_t [SIZE(H48_STARTING_CUBES)], int [NON_NULL]); STATIC wrapthread_return_t solve_h48_runthread(void *); -STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t [static 1]); -STATIC void solve_h48_log_solutions(solution_list_t [static 1], size_t); +STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t [NON_NULL]); +STATIC void solve_h48_log_solutions(solution_list_t [NON_NULL], size_t); STATIC int solve_h48_compare_tasks(const void *, const void *); STATIC int64_t solve_h48(oriented_cube_t, uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, const unsigned char *, size_t, char *, - long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); + long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); STATIC long long solve_h48_dispatch( oriented_cube_t oc, @@ -99,7 +99,7 @@ STATIC long long solve_h48_dispatch( const unsigned char *data, unsigned sols_size, char *sols, - long long stats[static NISSY_SIZE_SOLVE_STATS], + long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], int (*poll_status)(void *), void *poll_status_data ) @@ -111,7 +111,8 @@ STATIC long long solve_h48_dispatch( if (err != NISSY_OK) return err; - return solve_h48(oc, minmoves, maxmoves, maxsols, optimal, threads, + return solve_h48(oc, (uint8_t)minmoves, (uint8_t)maxmoves, + (uint8_t)maxsols, (uint8_t)optimal, (uint8_t)threads, data_size, data, sols_size, sols, stats, poll_status, poll_status_data); } @@ -120,7 +121,7 @@ STATIC_INLINE uint8_t h48_prune_lookup( uint64_t coord, cube_t cube, - dfsarg_solve_h48_t arg[static 1] + dfsarg_solve_h48_t arg[NON_NULL] ) { uint8_t p, pmin, pe; @@ -139,7 +140,7 @@ h48_prune_lookup( STATIC_INLINE uint8_t h48_prune_lookup_nocoord( cube_t cube, - dfsarg_solve_h48_t arg[static 1] + dfsarg_solve_h48_t arg[NON_NULL] ) { uint32_t cdata; @@ -152,8 +153,8 @@ h48_prune_lookup_nocoord( STATIC_INLINE void h48_prune_pipeline( - dfsarg_solve_h48_t arg[static 1], - h48_prune_t prune[static NMOVES], + dfsarg_solve_h48_t arg[NON_NULL], + h48_prune_t prune[SIZE(NMOVES)], uint8_t target, bool normal ) @@ -252,8 +253,8 @@ h48_prune_pipeline( STATIC_INLINE void h48_prune_restore_normal( - const h48_prune_t prune[static 1], - dfsarg_solve_h48_t arg[static 1], + const h48_prune_t prune[NON_NULL], + dfsarg_solve_h48_t arg[NON_NULL], uint8_t target ) { @@ -276,8 +277,8 @@ h48_prune_restore_normal( STATIC_INLINE void h48_prune_restore_inverse( - const h48_prune_t prune[static 1], - dfsarg_solve_h48_t arg[static 1], + const h48_prune_t prune[NON_NULL], + dfsarg_solve_h48_t arg[NON_NULL], uint8_t target ) { @@ -299,7 +300,7 @@ h48_prune_restore_inverse( } STATIC int64_t -solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) +solve_h48_dfs(dfsarg_solve_h48_t arg[NON_NULL]) { int64_t ret, n; uint8_t m, nm, nn, ni, target; @@ -343,7 +344,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) backup_inverse = arg->inverse; ret = 0; - if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) { + if (popcount_u64(mm_normal) <= popcount_u64(mm_inverse)) { h48_prune_pipeline(arg, prune, target, true); arg->solution_moves->nmoves++; for (m = 0; m < NMOVES; m++) { @@ -450,14 +451,13 @@ solve_h48_runthread_end: STATIC int64_t solve_h48_maketasks( - dfsarg_solve_h48_t solve_arg[static 1], - dfsarg_solve_h48_maketasks_t mtarg[static 1], - solve_h48_task_t tasks[static H48_STARTING_CUBES], - int ntasks[static 1] + dfsarg_solve_h48_t solve_arg[NON_NULL], + dfsarg_solve_h48_maketasks_t mtarg[NON_NULL], + solve_h48_task_t tasks[SIZE(H48_STARTING_CUBES)], + int ntasks[NON_NULL] ) { - int r; - int64_t appret; + int64_t r, appret; uint8_t m, t; uint64_t mm; cube_t backup_cube; @@ -524,7 +524,7 @@ solve_h48_maketasks( } STATIC void -solve_h48_log_solutions(solution_list_t s[static 1], size_t e) +solve_h48_log_solutions(solution_list_t s[NON_NULL], size_t e) { size_t i; char b; @@ -561,7 +561,7 @@ solve_h48( const unsigned char *data, size_t solutions_size, char *solutions, - long long stats[static NISSY_SIZE_SOLVE_STATS], + long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], int (*poll_status)(void *), void *poll_status_data ) diff --git a/src/solvers/h48/utils.h b/src/solvers/h48/utils.h index 27fb2e5..6d91108 100644 --- a/src/solvers/h48/utils.h +++ b/src/solvers/h48/utils.h @@ -4,11 +4,11 @@ #define H48_HMAX UINT8_C(7) #endif -long long parse_h48h(const char *, uint8_t [static 1]); -STATIC long long dataid_h48(const char *, char [static NISSY_SIZE_DATAID]); +long long parse_h48h(const char *, uint8_t [NON_NULL]); +STATIC long long dataid_h48(const char *, char [SIZE(NISSY_SIZE_DATAID)]); long long -parse_h48h(const char *buf, uint8_t h[static 1]) +parse_h48h(const char *buf, uint8_t h[NON_NULL]) { char format_error_msg[100]; sprintf(format_error_msg, "[H48] Error parsing H48 solver: must be in " @@ -29,7 +29,7 @@ parse_h48h(const char *buf, uint8_t h[static 1]) goto parse_h48h_error; } - *h = atoi(buf); + *h = (uint8_t)atoi(buf); if (*h > H48_HMAX) { LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be " "at most %" PRIu8 ")\n", *h, H48_HMAX); @@ -51,7 +51,7 @@ parse_h48h_error: } STATIC long long -dataid_h48(const char *str, char buf[static NISSY_SIZE_DATAID]) +dataid_h48(const char *str, char buf[SIZE(NISSY_SIZE_DATAID)]) { uint8_t h; long long err; diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index 8817348..b7a848b 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h @@ -1,39 +1,39 @@ -STATIC void solution_moves_reset(solution_moves_t [static 1]); -STATIC void solution_moves_transform(solution_moves_t [static 1], size_t, +STATIC void solution_moves_reset(solution_moves_t [NON_NULL]); +STATIC void solution_moves_transform(solution_moves_t [NON_NULL], size_t, uint8_t); -STATIC void solution_moves_reorient(solution_moves_t [static 1], uint8_t); -STATIC bool solution_list_init(solution_list_t [static 1], size_t, char *); +STATIC void solution_moves_reorient(solution_moves_t [NON_NULL], uint8_t); +STATIC bool solution_list_init(solution_list_t [NON_NULL], size_t, char *); STATIC bool solution_moves_equal( - const solution_moves_t [static 1], const solution_moves_t [static 1]); -STATIC bool last_solution_is_duplicate(const solution_list_t [static 1]); -STATIC bool appendchar(solution_list_t [static 1], char); + const solution_moves_t [NON_NULL], const solution_moves_t [NON_NULL]); +STATIC bool last_solution_is_duplicate(const solution_list_t [NON_NULL]); +STATIC bool appendchar(solution_list_t [NON_NULL], char); STATIC bool appendnormal( - const solution_moves_t [static 1], solution_list_t [static 1]); + const solution_moves_t [NON_NULL], solution_list_t [NON_NULL]); STATIC bool appendinverse( - const solution_moves_t [static 1], solution_list_t [static 1]); -STATIC void appendsolution_dfs(const solution_moves_t [static 1], size_t, - const uint64_t *, size_t, uint8_t *, const solution_settings_t [static 1], - solution_list_t [static 1], - solution_moves_t [static NTRANS * SOLUTION_MAXLEN], int64_t [static 1]); -STATIC int64_t appendsolution(const solution_moves_t [static 1], - size_t, const uint64_t *, const solution_settings_t [static 1], - solution_list_t [static 1]); -STATIC bool solutions_done(const solution_list_t [static 1], - const solution_settings_t [static 1], int8_t depth); + const solution_moves_t [NON_NULL], solution_list_t [NON_NULL]); +STATIC void appendsolution_dfs(const solution_moves_t [NON_NULL], size_t, + const uint64_t *, size_t, uint8_t *, const solution_settings_t [NON_NULL], + solution_list_t [NON_NULL], + solution_moves_t [SIZE(NTRANS * SOLUTION_MAXLEN)], int64_t [NON_NULL]); +STATIC int64_t appendsolution(const solution_moves_t [NON_NULL], + size_t, const uint64_t *, const solution_settings_t [NON_NULL], + solution_list_t [NON_NULL]); +STATIC bool solutions_done(const solution_list_t [NON_NULL], + const solution_settings_t [NON_NULL], int8_t depth); STATIC void -solution_moves_reset(solution_moves_t sol[static 1]) +solution_moves_reset(solution_moves_t sol[NON_NULL]) { sol->nmoves = 0; sol->npremoves = 0; } STATIC void -solution_moves_transform(solution_moves_t moves[static 1], size_t z, uint8_t t) +solution_moves_transform(solution_moves_t moves[NON_NULL], size_t z, uint8_t t) { uint8_t i; - for (i = z; i < moves->nmoves; i++) + for (i = (uint8_t)z; i < moves->nmoves; i++) moves->moves[i] = transform_move(moves->moves[i], t); for (i = 0; i < moves->npremoves; i++) @@ -41,7 +41,7 @@ solution_moves_transform(solution_moves_t moves[static 1], size_t z, uint8_t t) } STATIC void -solution_moves_reorient(solution_moves_t moves[static 1], uint8_t or) +solution_moves_reorient(solution_moves_t moves[NON_NULL], uint8_t or) { uint8_t i; @@ -55,7 +55,7 @@ solution_moves_reorient(solution_moves_t moves[static 1], uint8_t or) } STATIC bool -solution_list_init(solution_list_t sols[static 1], size_t n, char *buf) +solution_list_init(solution_list_t sols[NON_NULL], size_t n, char *buf) { if (n == 0) return false; @@ -72,8 +72,8 @@ solution_list_init(solution_list_t sols[static 1], size_t n, char *buf) STATIC bool solution_moves_equal( - const solution_moves_t a[static 1], - const solution_moves_t b[static 1] + const solution_moves_t a[NON_NULL], + const solution_moves_t b[NON_NULL] ) { uint8_t i; @@ -93,7 +93,7 @@ solution_moves_equal( } STATIC bool -last_solution_is_duplicate(const solution_list_t l[static 1]) +last_solution_is_duplicate(const solution_list_t l[NON_NULL]) { size_t i, j; @@ -119,7 +119,7 @@ last_solution_is_duplicate(const solution_list_t l[static 1]) } STATIC bool -appendchar(solution_list_t solutions[static 1], char c) +appendchar(solution_list_t solutions[NON_NULL], char c) { if (solutions->size <= solutions->used) return false; @@ -131,8 +131,8 @@ appendchar(solution_list_t solutions[static 1], char c) STATIC bool appendnormal( - const solution_moves_t moves[static 1], - solution_list_t list[static 1] + const solution_moves_t moves[NON_NULL], + solution_list_t list[NON_NULL] ) { int64_t strl; @@ -150,8 +150,8 @@ appendnormal( STATIC bool appendinverse( - const solution_moves_t moves[static 1], - solution_list_t list[static 1] + const solution_moves_t moves[NON_NULL], + solution_list_t list[NON_NULL] ) { int64_t strl; @@ -172,15 +172,15 @@ appendinverse( STATIC void appendsolution_dfs( - const solution_moves_t moves[static 1], + const solution_moves_t moves[NON_NULL], size_t ntmask, const uint64_t *tmask, size_t itm, uint8_t *tt, - const solution_settings_t settings[static 1], - solution_list_t list[static 1], - solution_moves_t tsol[static NTRANS * SOLUTION_MAXLEN], - int64_t r[static 1] + const solution_settings_t settings[NON_NULL], + solution_list_t list[NON_NULL], + solution_moves_t tsol[SIZE(NTRANS * SOLUTION_MAXLEN)], + int64_t r[NON_NULL] ) { /* @@ -276,11 +276,11 @@ appendsolution_dfs_error_buffer: STATIC int64_t appendsolution( - const solution_moves_t moves[static 1], + const solution_moves_t moves[NON_NULL], size_t ntmask, const uint64_t *tmask, - const solution_settings_t settings[static 1], - solution_list_t list[static 1] + const solution_settings_t settings[NON_NULL], + solution_list_t list[NON_NULL] ) { int64_t r; @@ -329,8 +329,8 @@ appendsolution_error_solution_length: STATIC bool solutions_done( - const solution_list_t list[static 1], - const solution_settings_t settings[static 1], + const solution_list_t list[NON_NULL], + const solution_settings_t settings[NON_NULL], int8_t depth ) { diff --git a/src/solvers/tables.h b/src/solvers/tables.h index b7a1079..3db1d1e 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h @@ -1,17 +1,17 @@ STATIC uint64_t read_unaligned_u64( - const unsigned char [static sizeof(uint64_t)]); + const unsigned char [SIZE(sizeof(uint64_t))]); STATIC void write_unaligned_u64( - unsigned char [static sizeof(uint64_t)], uint64_t); + unsigned char [SIZE(sizeof(uint64_t))], uint64_t); STATIC int64_t readtableinfo( - size_t, const unsigned char *, tableinfo_t [static 1]); + size_t, const unsigned char *, tableinfo_t [NON_NULL]); STATIC int64_t readtableinfo_n( - size_t, const unsigned char *, uint8_t, tableinfo_t [static 1]); + size_t, const unsigned char *, uint8_t, tableinfo_t [NON_NULL]); STATIC int64_t writetableinfo( - const tableinfo_t [static 1], size_t, unsigned char *); -STATIC void append_name(tableinfo_t [static 1], const char *); + const tableinfo_t [NON_NULL], size_t, unsigned char *); +STATIC void append_name(tableinfo_t [NON_NULL], const char *); STATIC uint64_t -read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) +read_unaligned_u64(const unsigned char buf[SIZE(sizeof(uint64_t))]) { uint64_t ret; @@ -21,7 +21,7 @@ read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) } STATIC void -write_unaligned_u64(unsigned char buf[static sizeof(uint64_t)], uint64_t x) +write_unaligned_u64(unsigned char buf[SIZE(sizeof(uint64_t))], uint64_t x) { memcpy(buf, &x, sizeof(uint64_t)); } @@ -30,7 +30,7 @@ STATIC int64_t readtableinfo( size_t buf_size, const unsigned char *buf, - tableinfo_t info[static 1] + tableinfo_t info[NON_NULL] ) { size_t i; @@ -75,7 +75,7 @@ readtableinfo_n( size_t buf_size, const unsigned char *buf, uint8_t n, - tableinfo_t info[static 1] + tableinfo_t info[NON_NULL] ) { int64_t ret; @@ -89,7 +89,7 @@ readtableinfo_n( STATIC int64_t writetableinfo( - const tableinfo_t info[static 1], + const tableinfo_t info[NON_NULL], size_t data_size, unsigned char *buf ) @@ -138,9 +138,9 @@ writetableinfo( } STATIC void -append_name(tableinfo_t info[static 1], const char *str) +append_name(tableinfo_t info[NON_NULL], const char *str) { - int i, j; + size_t i, j; for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++) info->solver[j] = str[i]; -- cgit v1.3