aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/solutions.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-04-06 15:55:33 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-04-06 15:55:33 +0200
commitfc41f7917531693680b5baf71ffe38c47333fe84 (patch)
treea6e62232e05e7779034c5f9d1bf743b6f1c198e3 /src/solvers/solutions.h
parentfe534f1497da6447153064d7bba00243000f803b (diff)
downloadnissy-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.h82
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 @@
1STATIC void solution_moves_reset(solution_moves_t [static 1]); 1STATIC void solution_moves_reset(solution_moves_t [NON_NULL]);
2STATIC void solution_moves_transform(solution_moves_t [static 1], size_t, 2STATIC void solution_moves_transform(solution_moves_t [NON_NULL], size_t,
3 uint8_t); 3 uint8_t);
4STATIC void solution_moves_reorient(solution_moves_t [static 1], uint8_t); 4STATIC void solution_moves_reorient(solution_moves_t [NON_NULL], uint8_t);
5STATIC bool solution_list_init(solution_list_t [static 1], size_t, char *); 5STATIC bool solution_list_init(solution_list_t [NON_NULL], size_t, char *);
6STATIC bool solution_moves_equal( 6STATIC 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]);
8STATIC bool last_solution_is_duplicate(const solution_list_t [static 1]); 8STATIC bool last_solution_is_duplicate(const solution_list_t [NON_NULL]);
9STATIC bool appendchar(solution_list_t [static 1], char); 9STATIC bool appendchar(solution_list_t [NON_NULL], char);
10STATIC bool appendnormal( 10STATIC 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]);
12STATIC bool appendinverse( 12STATIC 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]);
14STATIC void appendsolution_dfs(const solution_moves_t [static 1], size_t, 14STATIC 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]);
18STATIC int64_t appendsolution(const solution_moves_t [static 1], 18STATIC 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]);
21STATIC bool solutions_done(const solution_list_t [static 1], 21STATIC 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
24STATIC void 24STATIC void
25solution_moves_reset(solution_moves_t sol[static 1]) 25solution_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
31STATIC void 31STATIC void
32solution_moves_transform(solution_moves_t moves[static 1], size_t z, uint8_t t) 32solution_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
43STATIC void 43STATIC void
44solution_moves_reorient(solution_moves_t moves[static 1], uint8_t or) 44solution_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
57STATIC bool 57STATIC bool
58solution_list_init(solution_list_t sols[static 1], size_t n, char *buf) 58solution_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
73STATIC bool 73STATIC bool
74solution_moves_equal( 74solution_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
95STATIC bool 95STATIC bool
96last_solution_is_duplicate(const solution_list_t l[static 1]) 96last_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
121STATIC bool 121STATIC bool
122appendchar(solution_list_t solutions[static 1], char c) 122appendchar(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
132STATIC bool 132STATIC bool
133appendnormal( 133appendnormal(
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
151STATIC bool 151STATIC bool
152appendinverse( 152appendinverse(
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
173STATIC void 173STATIC void
174appendsolution_dfs( 174appendsolution_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
277STATIC int64_t 277STATIC int64_t
278appendsolution( 278appendsolution(
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
330STATIC bool 330STATIC bool
331solutions_done( 331solutions_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{

Generated with cgit - Back to sebastiano.tronto.net