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/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 +++--- 8 files changed, 120 insertions(+), 119 deletions(-) (limited to 'src/solvers/h48') 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; -- cgit v1.3