diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
| commit | fc41f7917531693680b5baf71ffe38c47333fe84 (patch) | |
| tree | a6e62232e05e7779034c5f9d1bf743b6f1c198e3 /src/solvers/solutions.h | |
| parent | fe534f1497da6447153064d7bba00243000f803b (diff) | |
| download | nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.tar.gz nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.zip | |
Make the project build with Microsoft's broken C compiler.
MSVC is not fully C11-compliant, even when compiling with /std:c11.
Some changes were needed to make the codebase compatible. Notably, the
notation a[static N] and a[n] for function parameters of array type is
not supported, so that had to be hidden behind a macro. Atomic types
are also an experimental feature, apparently, but at least they work
with the correct compiler flag.
One thing that MSVC does well, however, is warning on integer conversions
on /W4 level. I am not sure if Clang and GCC have something similar,
so I took this chance to fix some of these.
Diffstat (limited to 'src/solvers/solutions.h')
| -rw-r--r-- | src/solvers/solutions.h | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index 8817348..b7a848b 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h | |||
| @@ -1,39 +1,39 @@ | |||
| 1 | STATIC void solution_moves_reset(solution_moves_t [static 1]); | 1 | STATIC void solution_moves_reset(solution_moves_t [NON_NULL]); |
| 2 | STATIC void solution_moves_transform(solution_moves_t [static 1], size_t, | 2 | STATIC void solution_moves_transform(solution_moves_t [NON_NULL], size_t, |
| 3 | uint8_t); | 3 | uint8_t); |
| 4 | STATIC void solution_moves_reorient(solution_moves_t [static 1], uint8_t); | 4 | STATIC void solution_moves_reorient(solution_moves_t [NON_NULL], uint8_t); |
| 5 | STATIC bool solution_list_init(solution_list_t [static 1], size_t, char *); | 5 | STATIC bool solution_list_init(solution_list_t [NON_NULL], size_t, char *); |
| 6 | STATIC bool solution_moves_equal( | 6 | STATIC bool solution_moves_equal( |
| 7 | const solution_moves_t [static 1], const solution_moves_t [static 1]); | 7 | const solution_moves_t [NON_NULL], const solution_moves_t [NON_NULL]); |
| 8 | STATIC bool last_solution_is_duplicate(const solution_list_t [static 1]); | 8 | STATIC bool last_solution_is_duplicate(const solution_list_t [NON_NULL]); |
| 9 | STATIC bool appendchar(solution_list_t [static 1], char); | 9 | STATIC bool appendchar(solution_list_t [NON_NULL], char); |
| 10 | STATIC bool appendnormal( | 10 | STATIC bool appendnormal( |
| 11 | const solution_moves_t [static 1], solution_list_t [static 1]); | 11 | const solution_moves_t [NON_NULL], solution_list_t [NON_NULL]); |
| 12 | STATIC bool appendinverse( | 12 | STATIC bool appendinverse( |
| 13 | const solution_moves_t [static 1], solution_list_t [static 1]); | 13 | const solution_moves_t [NON_NULL], solution_list_t [NON_NULL]); |
| 14 | STATIC void appendsolution_dfs(const solution_moves_t [static 1], size_t, | 14 | STATIC void appendsolution_dfs(const solution_moves_t [NON_NULL], size_t, |
| 15 | const uint64_t *, size_t, uint8_t *, const solution_settings_t [static 1], | 15 | const uint64_t *, size_t, uint8_t *, const solution_settings_t [NON_NULL], |
| 16 | solution_list_t [static 1], | 16 | solution_list_t [NON_NULL], |
| 17 | solution_moves_t [static NTRANS * SOLUTION_MAXLEN], int64_t [static 1]); | 17 | solution_moves_t [SIZE(NTRANS * SOLUTION_MAXLEN)], int64_t [NON_NULL]); |
| 18 | STATIC int64_t appendsolution(const solution_moves_t [static 1], | 18 | STATIC int64_t appendsolution(const solution_moves_t [NON_NULL], |
| 19 | size_t, const uint64_t *, const solution_settings_t [static 1], | 19 | size_t, const uint64_t *, const solution_settings_t [NON_NULL], |
| 20 | solution_list_t [static 1]); | 20 | solution_list_t [NON_NULL]); |
| 21 | STATIC bool solutions_done(const solution_list_t [static 1], | 21 | STATIC bool solutions_done(const solution_list_t [NON_NULL], |
| 22 | const solution_settings_t [static 1], int8_t depth); | 22 | const solution_settings_t [NON_NULL], int8_t depth); |
| 23 | 23 | ||
| 24 | STATIC void | 24 | STATIC void |
| 25 | solution_moves_reset(solution_moves_t sol[static 1]) | 25 | solution_moves_reset(solution_moves_t sol[NON_NULL]) |
| 26 | { | 26 | { |
| 27 | sol->nmoves = 0; | 27 | sol->nmoves = 0; |
| 28 | sol->npremoves = 0; | 28 | sol->npremoves = 0; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | STATIC void | 31 | STATIC void |
| 32 | solution_moves_transform(solution_moves_t moves[static 1], size_t z, uint8_t t) | 32 | solution_moves_transform(solution_moves_t moves[NON_NULL], size_t z, uint8_t t) |
| 33 | { | 33 | { |
| 34 | uint8_t i; | 34 | uint8_t i; |
| 35 | 35 | ||
| 36 | for (i = z; i < moves->nmoves; i++) | 36 | for (i = (uint8_t)z; i < moves->nmoves; i++) |
| 37 | moves->moves[i] = transform_move(moves->moves[i], t); | 37 | moves->moves[i] = transform_move(moves->moves[i], t); |
| 38 | 38 | ||
| 39 | for (i = 0; i < moves->npremoves; i++) | 39 | for (i = 0; i < moves->npremoves; i++) |
| @@ -41,7 +41,7 @@ solution_moves_transform(solution_moves_t moves[static 1], size_t z, uint8_t t) | |||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | STATIC void | 43 | STATIC void |
| 44 | solution_moves_reorient(solution_moves_t moves[static 1], uint8_t or) | 44 | solution_moves_reorient(solution_moves_t moves[NON_NULL], uint8_t or) |
| 45 | { | 45 | { |
| 46 | uint8_t i; | 46 | uint8_t i; |
| 47 | 47 | ||
| @@ -55,7 +55,7 @@ solution_moves_reorient(solution_moves_t moves[static 1], uint8_t or) | |||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | STATIC bool | 57 | STATIC bool |
| 58 | solution_list_init(solution_list_t sols[static 1], size_t n, char *buf) | 58 | solution_list_init(solution_list_t sols[NON_NULL], size_t n, char *buf) |
| 59 | { | 59 | { |
| 60 | if (n == 0) | 60 | if (n == 0) |
| 61 | return false; | 61 | return false; |
| @@ -72,8 +72,8 @@ solution_list_init(solution_list_t sols[static 1], size_t n, char *buf) | |||
| 72 | 72 | ||
| 73 | STATIC bool | 73 | STATIC bool |
| 74 | solution_moves_equal( | 74 | solution_moves_equal( |
| 75 | const solution_moves_t a[static 1], | 75 | const solution_moves_t a[NON_NULL], |
| 76 | const solution_moves_t b[static 1] | 76 | const solution_moves_t b[NON_NULL] |
| 77 | ) | 77 | ) |
| 78 | { | 78 | { |
| 79 | uint8_t i; | 79 | uint8_t i; |
| @@ -93,7 +93,7 @@ solution_moves_equal( | |||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | STATIC bool | 95 | STATIC bool |
| 96 | last_solution_is_duplicate(const solution_list_t l[static 1]) | 96 | last_solution_is_duplicate(const solution_list_t l[NON_NULL]) |
| 97 | { | 97 | { |
| 98 | size_t i, j; | 98 | size_t i, j; |
| 99 | 99 | ||
| @@ -119,7 +119,7 @@ last_solution_is_duplicate(const solution_list_t l[static 1]) | |||
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | STATIC bool | 121 | STATIC bool |
| 122 | appendchar(solution_list_t solutions[static 1], char c) | 122 | appendchar(solution_list_t solutions[NON_NULL], char c) |
| 123 | { | 123 | { |
| 124 | if (solutions->size <= solutions->used) | 124 | if (solutions->size <= solutions->used) |
| 125 | return false; | 125 | return false; |
| @@ -131,8 +131,8 @@ appendchar(solution_list_t solutions[static 1], char c) | |||
| 131 | 131 | ||
| 132 | STATIC bool | 132 | STATIC bool |
| 133 | appendnormal( | 133 | appendnormal( |
| 134 | const solution_moves_t moves[static 1], | 134 | const solution_moves_t moves[NON_NULL], |
| 135 | solution_list_t list[static 1] | 135 | solution_list_t list[NON_NULL] |
| 136 | ) | 136 | ) |
| 137 | { | 137 | { |
| 138 | int64_t strl; | 138 | int64_t strl; |
| @@ -150,8 +150,8 @@ appendnormal( | |||
| 150 | 150 | ||
| 151 | STATIC bool | 151 | STATIC bool |
| 152 | appendinverse( | 152 | appendinverse( |
| 153 | const solution_moves_t moves[static 1], | 153 | const solution_moves_t moves[NON_NULL], |
| 154 | solution_list_t list[static 1] | 154 | solution_list_t list[NON_NULL] |
| 155 | ) | 155 | ) |
| 156 | { | 156 | { |
| 157 | int64_t strl; | 157 | int64_t strl; |
| @@ -172,15 +172,15 @@ appendinverse( | |||
| 172 | 172 | ||
| 173 | STATIC void | 173 | STATIC void |
| 174 | appendsolution_dfs( | 174 | appendsolution_dfs( |
| 175 | const solution_moves_t moves[static 1], | 175 | const solution_moves_t moves[NON_NULL], |
| 176 | size_t ntmask, | 176 | size_t ntmask, |
| 177 | const uint64_t *tmask, | 177 | const uint64_t *tmask, |
| 178 | size_t itm, | 178 | size_t itm, |
| 179 | uint8_t *tt, | 179 | uint8_t *tt, |
| 180 | const solution_settings_t settings[static 1], | 180 | const solution_settings_t settings[NON_NULL], |
| 181 | solution_list_t list[static 1], | 181 | solution_list_t list[NON_NULL], |
| 182 | solution_moves_t tsol[static NTRANS * SOLUTION_MAXLEN], | 182 | solution_moves_t tsol[SIZE(NTRANS * SOLUTION_MAXLEN)], |
| 183 | int64_t r[static 1] | 183 | int64_t r[NON_NULL] |
| 184 | ) | 184 | ) |
| 185 | { | 185 | { |
| 186 | /* | 186 | /* |
| @@ -276,11 +276,11 @@ appendsolution_dfs_error_buffer: | |||
| 276 | 276 | ||
| 277 | STATIC int64_t | 277 | STATIC int64_t |
| 278 | appendsolution( | 278 | appendsolution( |
| 279 | const solution_moves_t moves[static 1], | 279 | const solution_moves_t moves[NON_NULL], |
| 280 | size_t ntmask, | 280 | size_t ntmask, |
| 281 | const uint64_t *tmask, | 281 | const uint64_t *tmask, |
| 282 | const solution_settings_t settings[static 1], | 282 | const solution_settings_t settings[NON_NULL], |
| 283 | solution_list_t list[static 1] | 283 | solution_list_t list[NON_NULL] |
| 284 | ) | 284 | ) |
| 285 | { | 285 | { |
| 286 | int64_t r; | 286 | int64_t r; |
| @@ -329,8 +329,8 @@ appendsolution_error_solution_length: | |||
| 329 | 329 | ||
| 330 | STATIC bool | 330 | STATIC bool |
| 331 | solutions_done( | 331 | solutions_done( |
| 332 | const solution_list_t list[static 1], | 332 | const solution_list_t list[NON_NULL], |
| 333 | const solution_settings_t settings[static 1], | 333 | const solution_settings_t settings[NON_NULL], |
| 334 | int8_t depth | 334 | int8_t depth |
| 335 | ) | 335 | ) |
| 336 | { | 336 | { |
