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/coord/common.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/coord/common.h')
| -rw-r--r-- | src/solvers/coord/common.h | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index d154636..3a62e85 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h | |||
| @@ -1,16 +1,16 @@ | |||
| 1 | STATIC uint64_t coord_coord_generic( | 1 | STATIC uint64_t coord_coord_generic( |
| 2 | const coord_t [static 1], cube_t, const unsigned char *); | 2 | const coord_t [NON_NULL], cube_t, const unsigned char *); |
| 3 | STATIC cube_t coord_cube_generic( | 3 | STATIC cube_t coord_cube_generic( |
| 4 | const coord_t [static 1], uint64_t, const unsigned char *); | 4 | const coord_t [NON_NULL], uint64_t, const unsigned char *); |
| 5 | STATIC bool coord_isnasty_generic( | 5 | STATIC bool coord_isnasty_generic( |
| 6 | const coord_t [static 1], uint64_t, const unsigned char *); | 6 | const coord_t [NON_NULL], uint64_t, const unsigned char *); |
| 7 | STATIC size_t coord_gendata_generic(const coord_t [static 1], unsigned char *); | 7 | STATIC size_t coord_gendata_generic(const coord_t [NON_NULL], unsigned char *); |
| 8 | 8 | ||
| 9 | STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]); | 9 | STATIC bool solution_lastqt_cw(const solution_moves_t [NON_NULL]); |
| 10 | STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *, | 10 | STATIC bool coord_can_switch(const coord_t [NON_NULL], const unsigned char *, |
| 11 | size_t, const uint8_t *); | 11 | size_t, const uint8_t *); |
| 12 | STATIC bool coord_is_solved( | 12 | STATIC bool coord_is_solved( |
| 13 | const coord_t [static 1], uint64_t, const unsigned char *); | 13 | const coord_t [NON_NULL], uint64_t, const unsigned char *); |
| 14 | 14 | ||
| 15 | STATIC cube_t coordinate_merge_ce(cube_t, cube_t); | 15 | STATIC cube_t coordinate_merge_ce(cube_t, cube_t); |
| 16 | STATIC cube_t coordinate_merge_ec(cube_t, cube_t); | 16 | STATIC cube_t coordinate_merge_ec(cube_t, cube_t); |
| @@ -18,7 +18,7 @@ STATIC cube_t coordinate_merge_cpco(cube_t, cube_t); | |||
| 18 | 18 | ||
| 19 | STATIC uint64_t | 19 | STATIC uint64_t |
| 20 | coord_coord_generic( | 20 | coord_coord_generic( |
| 21 | const coord_t coord[static 1], | 21 | const coord_t coord[NON_NULL], |
| 22 | cube_t c, | 22 | cube_t c, |
| 23 | const unsigned char *data | 23 | const unsigned char *data |
| 24 | ) | 24 | ) |
| @@ -36,7 +36,7 @@ coord_coord_generic( | |||
| 36 | 36 | ||
| 37 | STATIC cube_t | 37 | STATIC cube_t |
| 38 | coord_cube_generic( | 38 | coord_cube_generic( |
| 39 | const coord_t coord[static 1], | 39 | const coord_t coord[NON_NULL], |
| 40 | uint64_t i, | 40 | uint64_t i, |
| 41 | const unsigned char *data | 41 | const unsigned char *data |
| 42 | ) | 42 | ) |
| @@ -54,7 +54,7 @@ coord_cube_generic( | |||
| 54 | 54 | ||
| 55 | STATIC bool | 55 | STATIC bool |
| 56 | coord_isnasty_generic( | 56 | coord_isnasty_generic( |
| 57 | const coord_t coord[static 1], | 57 | const coord_t coord[NON_NULL], |
| 58 | uint64_t i, | 58 | uint64_t i, |
| 59 | const unsigned char *data | 59 | const unsigned char *data |
| 60 | ) | 60 | ) |
| @@ -73,11 +73,12 @@ coord_isnasty_generic( | |||
| 73 | 73 | ||
| 74 | STATIC size_t | 74 | STATIC size_t |
| 75 | coord_gendata_generic( | 75 | coord_gendata_generic( |
| 76 | const coord_t coord[static 1], | 76 | const coord_t coord[NON_NULL], |
| 77 | unsigned char *data | 77 | unsigned char *data |
| 78 | ) | 78 | ) |
| 79 | { | 79 | { |
| 80 | uint64_t i, j, n, t, nasty; | 80 | uint64_t i, j, n, nasty; |
| 81 | uint8_t t; | ||
| 81 | unsigned char *datanoinfo; | 82 | unsigned char *datanoinfo; |
| 82 | uint32_t *classttrep, *rep; | 83 | uint32_t *classttrep, *rep; |
| 83 | size_t coord_datasize; | 84 | size_t coord_datasize; |
| @@ -122,16 +123,17 @@ coord_gendata_generic( | |||
| 122 | } | 123 | } |
| 123 | 124 | ||
| 124 | for (t = 0; t < NTRANS; t++) { | 125 | for (t = 0; t < NTRANS; t++) { |
| 125 | if (!((UINT64_C(1) << t) & coord->trans_mask)) | 126 | if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) |
| 126 | continue; | 127 | continue; |
| 127 | 128 | ||
| 128 | j = coord->sym.coord(transform(c, t)); | 129 | j = coord->sym.coord(transform(c, t)); |
| 129 | classttrep[j] = | 130 | classttrep[j] = (uint32_t)( |
| 130 | (n << COORD_CLASS_SHIFT) | | 131 | (n << COORD_CLASS_SHIFT) | |
| 131 | (nasty << COORD_ISNASTY_SHIFT) | | 132 | (nasty << COORD_ISNASTY_SHIFT) | |
| 132 | (inverse_trans(t) << COORD_TTREP_SHIFT); | 133 | (inverse_trans(t) << COORD_TTREP_SHIFT) |
| 134 | ); | ||
| 133 | } | 135 | } |
| 134 | rep[n++] = i; | 136 | rep[n++] = (uint32_t)i; |
| 135 | } | 137 | } |
| 136 | 138 | ||
| 137 | writetableinfo(&info, coord_datasize, data); | 139 | writetableinfo(&info, coord_datasize, data); |
| @@ -144,21 +146,21 @@ coord_gendata_generic( | |||
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | STATIC bool | 148 | STATIC bool |
| 147 | solution_lastqt_cw(const solution_moves_t s[static 1]) | 149 | solution_lastqt_cw(const solution_moves_t s[NON_NULL]) |
| 148 | { | 150 | { |
| 149 | return are_lastmoves_singlecw(s->nmoves, s->moves) && | 151 | return are_lastmoves_singlecw(s->nmoves, s->moves) && |
| 150 | are_lastmoves_singlecw(s->npremoves, s->premoves); | 152 | are_lastmoves_singlecw(s->npremoves, s->premoves); |
| 151 | } | 153 | } |
| 152 | 154 | ||
| 153 | STATIC bool | 155 | STATIC bool |
| 154 | solution_always_valid(const solution_moves_t s[static 1]) | 156 | solution_always_valid(const solution_moves_t s[NON_NULL]) |
| 155 | { | 157 | { |
| 156 | return true; | 158 | return true; |
| 157 | } | 159 | } |
| 158 | 160 | ||
| 159 | STATIC bool | 161 | STATIC bool |
| 160 | coord_can_switch( | 162 | coord_can_switch( |
| 161 | const coord_t coord[static 1], | 163 | const coord_t coord[NON_NULL], |
| 162 | const unsigned char *data, | 164 | const unsigned char *data, |
| 163 | size_t n, | 165 | size_t n, |
| 164 | const uint8_t *moves | 166 | const uint8_t *moves |
| @@ -192,7 +194,7 @@ coord_can_switch( | |||
| 192 | 194 | ||
| 193 | STATIC bool | 195 | STATIC bool |
| 194 | coord_is_solved( | 196 | coord_is_solved( |
| 195 | const coord_t coord[static 1], | 197 | const coord_t coord[NON_NULL], |
| 196 | uint64_t i, | 198 | uint64_t i, |
| 197 | const unsigned char *data | 199 | const unsigned char *data |
| 198 | ) | 200 | ) |
