From e6be287bbfa6beda038ec8b085300c5dc9c2ecd8 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 4 Apr 2026 12:02:56 +0200 Subject: Use macro for [static N] --- src/arch/avx2.h | 10 ++--- src/arch/common.h | 14 +++---- src/arch/neon.h | 10 ++--- src/arch/portable.h | 10 ++--- src/core/cube.h | 4 +- src/core/moves.h | 22 +++++------ src/core/transform.h | 12 +++--- src/nissy.c | 30 +++++++-------- src/nissy.h | 33 ++++++++++------ src/solvers/coord/common.h | 30 +++++++-------- src/solvers/coord/gendata.h | 32 ++++++++-------- src/solvers/coord/htr.h | 4 +- src/solvers/coord/multisolve.h | 20 +++++----- src/solvers/coord/solve.h | 24 ++++++------ 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 | 16 ++++---- src/solvers/h48/gendata_eoesep.h | 54 +++++++++++++------------- src/solvers/h48/gendata_h48.h | 32 ++++++++-------- src/solvers/h48/map.h | 28 +++++++------- src/solvers/h48/solve.h | 60 ++++++++++++++--------------- src/solvers/h48/utils.h | 8 ++-- src/solvers/solutions.h | 78 +++++++++++++++++++------------------- src/solvers/tables.h | 24 ++++++------ src/utils/compilers.h | 17 +++++++-- src/utils/wrapthread.h | 4 +- 30 files changed, 319 insertions(+), 297 deletions(-) (limited to 'src') diff --git a/src/arch/avx2.h b/src/arch/avx2.h index b80b0fb..7d8deef 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h @@ -35,7 +35,7 @@ popcount_u32(uint32_t x) } STATIC void -pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) +pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) { uint8_t aux[32]; @@ -161,7 +161,7 @@ coord_co(cube_t c) } STATIC_INLINE void -copy_co(cube_t cube[static 1], cube_t co) +copy_co(cube_t cube[NON_NULL], cube_t co) { cube_t coclean; @@ -268,19 +268,19 @@ invcoord_esep(uint64_t esep) } STATIC_INLINE void -copy_corners(cube_t dest[static 1], cube_t src) +copy_corners(cube_t dest[NON_NULL], cube_t src) { *dest = _mm256_blend_epi32(*dest, src, 0x0F); } STATIC_INLINE void -copy_edges(cube_t dest[static 1], cube_t src) +copy_edges(cube_t dest[NON_NULL], cube_t src) { *dest = _mm256_blend_epi32(*dest, src, 0xF0); } STATIC_INLINE void -set_eo(cube_t cube[static 1], uint64_t eo) +set_eo(cube_t cube[NON_NULL], uint64_t eo) { uint64_t eo12, eotop, eobot; __m256i veo; diff --git a/src/arch/common.h b/src/arch/common.h index 4412562..2a83fbf 100644 --- a/src/arch/common.h +++ b/src/arch/common.h @@ -14,7 +14,7 @@ STATIC_INLINE int popcount_u32(uint32_t); -STATIC void pieces(cube_t [static 1], uint8_t [static 8], uint8_t [static 12]); +STATIC void pieces(cube_t [NON_NULL], uint8_t [SIZE(8)], uint8_t [SIZE(12)]); STATIC_INLINE bool equal(cube_t, cube_t); STATIC_INLINE cube_t invertco(cube_t); STATIC_INLINE cube_t compose_edges(cube_t, cube_t); @@ -34,12 +34,12 @@ STATIC_INLINE cube_t invcoord_epudsep(uint64_t); STATIC_INLINE bool is_eo_even(cube_t); -STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); -STATIC_INLINE void copy_co(cube_t [static 1], cube_t); -STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); -STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); +STATIC_INLINE void copy_corners(cube_t [NON_NULL], cube_t); +STATIC_INLINE void copy_co(cube_t [NON_NULL], cube_t); +STATIC_INLINE void copy_edges(cube_t [NON_NULL], cube_t); +STATIC_INLINE void set_eo(cube_t [NON_NULL], uint64_t); -STATIC_INLINE void invcoord_esep_array(uint64_t, uint64_t, uint8_t[static 12]); +STATIC_INLINE void invcoord_esep_array(uint64_t, uint64_t, uint8_t[SIZE(12)]); STATIC_INLINE cube_t invcoord_eoesep(uint64_t); STATIC_INLINE uint64_t coord_epudsep_array(const uint8_t [8]); STATIC_INLINE void invcoord_epudsep_array(uint64_t, uint8_t [8]); @@ -52,7 +52,7 @@ STATIC_INLINE uint64_t coord_epe(cube_t); STATIC_INLINE cube_t invcoord_epe(uint64_t); STATIC_INLINE void -invcoord_esep_array(uint64_t set1, uint64_t set2, uint8_t mem[static 12]) +invcoord_esep_array(uint64_t set1, uint64_t set2, uint8_t mem[SIZE(12)]) { uint64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; uint8_t slice[3] = {0}; diff --git a/src/arch/neon.h b/src/arch/neon.h index f997813..1157938 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h @@ -48,7 +48,7 @@ popcount_u32(uint32_t x) } STATIC void -pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) +pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) { // First 8 bytes of the corner vector are copied from the c array vst1_u8(c, cube->corner); @@ -233,7 +233,7 @@ coord_co(cube_t c) } STATIC_INLINE void -copy_co(cube_t cube[static 1], cube_t co) +copy_co(cube_t cube[NON_NULL], cube_t co) { uint8x8_t coclean; @@ -329,19 +329,19 @@ coord_esep(cube_t c) } STATIC_INLINE void -copy_corners(cube_t dst[static 1], cube_t src) +copy_corners(cube_t dst[NON_NULL], cube_t src) { dst->corner = src.corner; } STATIC_INLINE void -copy_edges(cube_t dst[static 1], cube_t src) +copy_edges(cube_t dst[NON_NULL], cube_t src) { dst->edge = src.edge; } STATIC_INLINE void -set_eo(cube_t cube[static 1], uint64_t eo) +set_eo(cube_t cube[NON_NULL], uint64_t eo) { // Temp array to store the NEON vector uint8_t mem[16]; diff --git a/src/arch/portable.h b/src/arch/portable.h index 4b66fb6..311d427 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h @@ -35,7 +35,7 @@ popcount_u32(uint32_t x) } STATIC void -pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) +pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) { memcpy(c, cube->corner, 8); memcpy(e, cube->edge, 12); @@ -155,7 +155,7 @@ inverse(cube_t cube) } STATIC_INLINE void -copy_co(cube_t cube[static 1], cube_t co) +copy_co(cube_t cube[NON_NULL], cube_t co) { uint8_t c; size_t i; @@ -280,19 +280,19 @@ invcoord_esep(uint64_t esep) } STATIC_INLINE void -copy_corners(cube_t dest[static 1], cube_t src) +copy_corners(cube_t dest[NON_NULL], cube_t src) { memcpy(&dest->corner, src.corner, sizeof(src.corner)); } STATIC_INLINE void -copy_edges(cube_t dest[static 1], cube_t src) +copy_edges(cube_t dest[NON_NULL], cube_t src) { memcpy(&dest->edge, src.edge, sizeof(src.edge)); } STATIC_INLINE void -set_eo(cube_t cube[static 1], uint64_t eo) +set_eo(cube_t cube[NON_NULL], uint64_t eo) { uint8_t i, sum, flip; diff --git a/src/core/cube.h b/src/core/cube.h index 9e79dda..f52c15e 100644 --- a/src/core/cube.h +++ b/src/core/cube.h @@ -1,6 +1,6 @@ STATIC bool cube_true(cube_t); -STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); +STATIC cube_t cubefromarray(uint8_t [SIZE(8)], uint8_t [SIZE(12)]); STATIC bool isconsistent(oriented_cube_t); STATIC bool issolvable(oriented_cube_t); STATIC bool issolved(oriented_cube_t); @@ -29,7 +29,7 @@ cube_true(cube_t cube) } STATIC cube_t -cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) +cubefromarray(uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) { return STATIC_CUBE( c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], diff --git a/src/core/moves.h b/src/core/moves.h index 6169c6e..c162c1d 100644 --- a/src/core/moves.h +++ b/src/core/moves.h @@ -4,15 +4,15 @@ STATIC uint8_t readmove(char); STATIC int64_t readmoves(const char *, size_t, size_t, size_t *, size_t *, uint8_t *, uint8_t *); -STATIC int64_t readmoves_struct(const char *, moves_struct_t [static 1]); +STATIC int64_t readmoves_struct(const char *, moves_struct_t [NON_NULL]); STATIC int64_t countmoves(const char *); STATIC bool moves_struct_equal( - const moves_struct_t [static 1], const moves_struct_t [static 1]); + const moves_struct_t [NON_NULL], const moves_struct_t [NON_NULL]); STATIC long long comparemoves(const char *, const char *); STATIC uint8_t readmodifier(char); STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *); STATIC int64_t writemoves_struct( - const moves_struct_t [static 1], size_t, char *); + const moves_struct_t [NON_NULL], size_t, char *); STATIC_INLINE bool allowednextmove(uint8_t, uint8_t); STATIC bool allowedmoves(size_t, const uint8_t *); @@ -36,9 +36,9 @@ STATIC bool are_lastmoves_singlecw(size_t, const uint8_t*); STATIC int64_t move_variations(const char *, const char *, size_t, char *); STATIC int64_t move_variations_lastqt( - const moves_struct_t [static 1], size_t, char *); + const moves_struct_t [NON_NULL], size_t, char *); STATIC int64_t move_variations_unniss( - const moves_struct_t [static 1], size_t, char *); + const moves_struct_t [NON_NULL], size_t, char *); #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ RET_ERROR, ARG_ACTION) \ @@ -167,7 +167,7 @@ readmoves( } STATIC int64_t -readmoves_struct(const char *moves, moves_struct_t ret[static 1]) +readmoves_struct(const char *moves, moves_struct_t ret[NON_NULL]) { return readmoves(moves, NISSY_SIZE_MOVES, NISSY_SIZE_MOVES, &ret->nnormal, &ret->ninverse, ret->normal, ret->inverse); @@ -190,8 +190,8 @@ countmoves(const char *buf) STATIC bool moves_struct_equal( - const moves_struct_t ms1[static 1], - const moves_struct_t ms2[static 1] + const moves_struct_t ms1[NON_NULL], + const moves_struct_t ms2[NON_NULL] ) { size_t i; @@ -281,7 +281,7 @@ writemoves_error: STATIC int64_t writemoves_struct( - const moves_struct_t moves[static 1], + const moves_struct_t moves[NON_NULL], size_t buf_size, char *buf ) @@ -612,7 +612,7 @@ move_variations( STATIC int64_t move_variations_lastqt( - const moves_struct_t s[static 1], + const moves_struct_t s[NON_NULL], size_t result_size, char *result ) @@ -686,7 +686,7 @@ lastqt_error: STATIC int64_t move_variations_unniss( - const moves_struct_t s[static 1], + const moves_struct_t s[NON_NULL], size_t result_size, char *result ) diff --git a/src/core/transform.h b/src/core/transform.h index f19c44f..206449b 100644 --- a/src/core/transform.h +++ b/src/core/transform.h @@ -17,9 +17,9 @@ invertco(compose(compose(TRANS_CUBE_ ## T, c), \ TRANS_CUBE_ ## T ## _INVERSE)) -STATIC uint8_t readtrans(const char [static NISSY_SIZE_TRANSFORMATION]); -STATIC uint8_t readrotation(const char [static 2]); -STATIC void writetrans(uint8_t, char [static NISSY_SIZE_TRANSFORMATION]); +STATIC uint8_t readtrans(const char [SIZE(NISSY_SIZE_TRANSFORMATION)]); +STATIC uint8_t readrotation(const char [SIZE(2)]); +STATIC void writetrans(uint8_t, char [SIZE(NISSY_SIZE_TRANSFORMATION)]); STATIC cube_t transform_edges(cube_t, uint8_t); STATIC cube_t transform_corners(cube_t, uint8_t); @@ -29,7 +29,7 @@ STATIC_INLINE uint8_t inverse_trans(uint8_t); STATIC uint64_t symmetry_mask(cube_t); STATIC uint8_t -readtrans(const char buf[static NISSY_SIZE_TRANSFORMATION]) +readtrans(const char buf[SIZE(NISSY_SIZE_TRANSFORMATION)]) { uint8_t t; @@ -41,7 +41,7 @@ readtrans(const char buf[static NISSY_SIZE_TRANSFORMATION]) } STATIC uint8_t -readrotation(const char buf[static 2]) +readrotation(const char buf[SIZE(2)]) { char trans_str[NISSY_SIZE_TRANSFORMATION]; @@ -53,7 +53,7 @@ readrotation(const char buf[static 2]) } STATIC void -writetrans(uint8_t t, char buf[static NISSY_SIZE_TRANSFORMATION]) +writetrans(uint8_t t, char buf[SIZE(NISSY_SIZE_TRANSFORMATION)]) { if (t >= 48) memcpy(buf, "error trans", 11); diff --git a/src/nissy.c b/src/nissy.c index 594bdc4..b9f2565 100644 --- a/src/nissy.c +++ b/src/nissy.c @@ -12,8 +12,8 @@ #include "core/core.h" #include "solvers/solvers.h" -STATIC long long write_result(oriented_cube_t, char [static NISSY_SIZE_CUBE]); -STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); +STATIC long long write_result(oriented_cube_t, char [SIZE(NISSY_SIZE_CUBE)]); +STATIC long long nissy_dataid(const char *, char [SIZE(NISSY_SIZE_DATAID)]); STATIC long long nissy_gendata_unsafe( const char *, unsigned long long, unsigned char *); @@ -28,7 +28,7 @@ struct { }; STATIC long long -write_result(oriented_cube_t cube, char result[static NISSY_SIZE_CUBE]) +write_result(oriented_cube_t cube, char result[SIZE(NISSY_SIZE_CUBE)]) { writecube(cube, NISSY_SIZE_CUBE, result); @@ -42,8 +42,8 @@ write_result(oriented_cube_t cube, char result[static NISSY_SIZE_CUBE]) long long nissy_inverse( - const char cube[static NISSY_SIZE_CUBE], - char result[static NISSY_SIZE_CUBE] + const char cube[], + char result[] ) { oriented_cube_t c, res; @@ -77,9 +77,9 @@ nissy_inverse_error: long long nissy_applymoves( - const char cube[static NISSY_SIZE_CUBE], + const char cube[], const char *moves, - char result[static NISSY_SIZE_CUBE] + char result[] ) { oriented_cube_t c, res; @@ -116,9 +116,9 @@ nissy_applymoves_error: long long nissy_applytrans( - const char cube[static NISSY_SIZE_CUBE], - const char transformation[static NISSY_SIZE_TRANSFORMATION], - char result[static NISSY_SIZE_CUBE] + const char cube[], + const char transformation[], + char result[] ) { oriented_cube_t c, res; @@ -181,7 +181,7 @@ nissy_getcube( long long co, long long orient, const char *options, - char result[static NISSY_SIZE_CUBE] + char result[] ) { int i; @@ -210,7 +210,7 @@ nissy_getcube( } STATIC long long -nissy_dataid(const char *solver, char dataid[static NISSY_SIZE_DATAID]) +nissy_dataid(const char *solver, char dataid[SIZE(NISSY_SIZE_DATAID)]) { solver_dispatch_t dispatch; @@ -226,7 +226,7 @@ nissy_dataid(const char *solver, char dataid[static NISSY_SIZE_DATAID]) long long nissy_solverinfo( const char *solver, - char dataid[static NISSY_SIZE_DATAID] + char dataid[] ) { long long err; @@ -295,7 +295,7 @@ nissy_checkdata( long long nissy_solve( - const char cube[static NISSY_SIZE_CUBE], + const char cube[], const char *solver, unsigned nissflag, unsigned minmoves, @@ -307,7 +307,7 @@ nissy_solve( const unsigned char *data, unsigned sols_size, char *sols, - long long stats[static NISSY_SIZE_SOLVE_STATS], + long long stats[], int (*poll_status)(void *), void *poll_status_data ) diff --git a/src/nissy.h b/src/nissy.h index c85072a..c7edf88 100644 --- a/src/nissy.h +++ b/src/nissy.h @@ -149,7 +149,9 @@ Compute the inverse of the given cube. Parameters: cube - The cube to be inverted. + Required size: NISSY_SIZE_CUBE. result - The return parameter for the resulting cube. + Required size: NISSY_SIZE_CUBE. Return values: NISSY_OK - The cube was inverted succesfully. @@ -161,8 +163,8 @@ Return values: */ long long nissy_inverse( - const char cube[static NISSY_SIZE_CUBE], - char result[static NISSY_SIZE_CUBE] + const char cube[], /* NISSY_SIZE_CUBE */ + char result[] /* NISSY_SIZE_CUBE */ ); /* @@ -170,8 +172,10 @@ Apply the given sequence of moves on the given cube. Parameters: cube - The cube to move. + Required size: NISSY_SIZE_CUBE. moves - The moves to apply to the cube. Must be a NULL-terminated string. result - The return parameter for the resulting cube. + Required size: NISSY_SIZE_CUBE. Return values: NISSY_OK - The moves were applied succesfully. @@ -184,9 +188,9 @@ Return values: */ long long nissy_applymoves( - const char cube[static NISSY_SIZE_CUBE], + const char cube[], /* NISSY_SIZE_CUBE */ const char *moves, - char result[static NISSY_SIZE_CUBE] + char result[] /* NISSY_SIZE_CUBE */ ); /* @@ -194,8 +198,11 @@ Apply the single given transformation to the given cube. Parameters: cube - The cube to be transformed. + Required size: NISSY_SIZE_CUBE. transformation - The transformation in "(rotation|mirrored) __" format. + Required size: NISSY_SIZE_TRANSFORMATION. result - The return parameter for the resulting cube. + Required size: NISSY_SIZE_CUBE. Return values: NISSY_OK - The transformation was performed succesfully. @@ -206,9 +213,9 @@ Return values: */ long long nissy_applytrans( - const char cube[static NISSY_SIZE_CUBE], - const char transformation[static NISSY_SIZE_TRANSFORMATION], - char result[static NISSY_SIZE_CUBE] + const char cube[], /* NISSY_SIZE_CUBE */ + const char transformation[], /* NISSY_SIZE_TRANSFORMATION */ + char result[] /* NISSY_SIZE_CUBE */ ); /* @@ -256,6 +263,7 @@ Parameters: orient - The orientation of the cube, 0 <= orient < 24 options - Other options. result - The return parameter for the resulting cube. + Required size: NISSY_SIZE_CUBE. Return values: NISSY_OK - The cube was generated succesfully. @@ -270,7 +278,7 @@ nissy_getcube( long long co, long long orient, const char *options, - char result[static NISSY_SIZE_CUBE] + char result[] /* NISSY_SIZE_CUBE */ ); /* @@ -283,6 +291,7 @@ Parameters: solvers may use equivalent data. This identifier can be used e.g. as a filename or database key to save and retrieve the correct data for each solver, without duplication. + Required size: NISSY_SIZE_DATAID. Return values: NISSY_ERROR_INVALID_SOLVER - The given solver is not known. @@ -293,7 +302,7 @@ Return values: long long nissy_solverinfo( const char *solver, - char dataid[static NISSY_SIZE_DATAID] + char dataid[] /* NISSY_SIZE_DATAID */ ); /* @@ -350,6 +359,7 @@ Solve the given cube using the given solver and options. Parameters: cube - The cube to solver. + Required size: NISSY_SIZE_CUBE. solver - The name of the solver. See doc/solvers.md for a list. nissflag - The flags for NISS (linear, inverse, mixed, or combinations; see the constants at the top of this file). @@ -370,6 +380,7 @@ Parameters: separated by a '\n' (newline) and a '\0' (NULL character) terminates the list. stats - An array to store some statistics about the solve. + Required size: NISSY_SIZE_SOLVE_STATS. poll_status - A callback function that should return the current requested status for the solver (e.g. run, stop, pause, resume; see the constants at the top of this file). The @@ -391,7 +402,7 @@ Return values: */ long long nissy_solve( - const char cube[static NISSY_SIZE_CUBE], + const char cube[], /* NISSY_SIZE_CUBE */ const char *solver, unsigned nissflag, unsigned minmoves, @@ -403,7 +414,7 @@ nissy_solve( const unsigned char *data, unsigned sols_size, char *sols, - long long stats[static NISSY_SIZE_SOLVE_STATS], + long long stats[], /* NISSY_SIZE_SOLVE_STATS */ int (*poll_status)(void *), void *poll_status_data ); diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index d154636..593641f 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,7 +73,7 @@ coord_isnasty_generic( STATIC size_t coord_gendata_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], unsigned char *data ) { @@ -144,21 +144,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 +192,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..f803044 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,7 +141,7 @@ 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 ) @@ -204,7 +204,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 +238,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, @@ -276,7 +276,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, @@ -331,7 +331,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 +341,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..28f03bb 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,7 +69,7 @@ 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; @@ -141,7 +141,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 ) @@ -171,7 +171,7 @@ solve_multicoord_dispatch( 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..fcdb06e 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,7 +147,7 @@ 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; @@ -258,7 +258,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 ) @@ -288,7 +288,7 @@ solve_coord_dispatch( 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..17568ea 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,7 +79,7 @@ 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; uint32_t cc, class, ttrep, depth, olddepth, tinv; @@ -135,7 +135,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 +144,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 +154,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..271e877 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]; @@ -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,8 +135,8 @@ 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; @@ -164,8 +164,8 @@ 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; @@ -196,8 +196,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 +227,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 +251,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 +270,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..283c472 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 @@ -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..295ef88 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 ) @@ -120,7 +120,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 +139,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 +152,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 +252,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 +276,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 +299,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; @@ -450,10 +450,10 @@ 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; @@ -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..d181eab 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 " @@ -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..f1f0c58 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h @@ -1,35 +1,35 @@ -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 [static 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; @@ -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], + const solution_settings_t settings[NON_NULL], + solution_list_t list[NON_NULL], solution_moves_t tsol[static NTRANS * SOLUTION_MAXLEN], - int64_t r[static 1] + 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..8211ab3 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,7 +138,7 @@ 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; diff --git a/src/utils/compilers.h b/src/utils/compilers.h index a7d6df5..1b175bb 100644 --- a/src/utils/compilers.h +++ b/src/utils/compilers.h @@ -1,13 +1,24 @@ #if defined(__GNUC__) -#define unused __attribute__((unused)) +#define UNUSED __attribute__((unused)) +#define SIZE(x) static (x) +#define NON_NULL SIZE(1) #elif defined(__clang__) -#define unused __attribute__((unused)) +#define UNUSED __attribute__((unused)) +#define SIZE(x) static (x) +#define NON_NULL SIZE(1) #else -#define unused +/* +For example MSVC, which is not fully C11 compliant (e.g. it does not support +a[static N] notation for array parameters). +*/ + +#define UNUSED +#define SIZE(x) +#define NON_NULL #endif diff --git a/src/utils/wrapthread.h b/src/utils/wrapthread.h index 4ac72a6..9578293 100644 --- a/src/utils/wrapthread.h +++ b/src/utils/wrapthread.h @@ -61,8 +61,8 @@ #define wrapthread_return_t int #define wrapthread_return_val 0 - #define wrapthread_define_var_thread_t(x) unused char x - #define wrapthread_define_var_mutex_t(x) unused char x + #define wrapthread_define_var_thread_t(x) UNUSED char x + #define wrapthread_define_var_mutex_t(x) UNUSED char x #define wrapthread_define_struct_thread_t(x) char x #define wrapthread_define_struct_mutex_t(x) char x -- cgit v1.3