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/solve.h | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/solvers/h48/solve.h') 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 ) -- cgit v1.3