aboutsummaryrefslogtreecommitdiff
path: root/src/arch
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/arch
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/arch')
-rw-r--r--src/arch/avx2.h12
-rw-r--r--src/arch/common.h14
-rw-r--r--src/arch/neon.h10
-rw-r--r--src/arch/portable.h10
4 files changed, 23 insertions, 23 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index 15ce02a..801419e 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -37,11 +37,11 @@ popcount_u32(uint32_t x)
37STATIC_INLINE int 37STATIC_INLINE int
38popcount_u64(uint64_t x) 38popcount_u64(uint64_t x)
39{ 39{
40 return _mm_popcnt_u64(x); 40 return (int)_mm_popcnt_u64(x);
41} 41}
42 42
43STATIC void 43STATIC void
44pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) 44pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)])
45{ 45{
46 uint8_t aux[32]; 46 uint8_t aux[32];
47 47
@@ -167,7 +167,7 @@ coord_co(cube_t c)
167} 167}
168 168
169STATIC_INLINE void 169STATIC_INLINE void
170copy_co(cube_t cube[static 1], cube_t co) 170copy_co(cube_t cube[NON_NULL], cube_t co)
171{ 171{
172 cube_t coclean; 172 cube_t coclean;
173 173
@@ -274,19 +274,19 @@ invcoord_esep(uint64_t esep)
274} 274}
275 275
276STATIC_INLINE void 276STATIC_INLINE void
277copy_corners(cube_t dest[static 1], cube_t src) 277copy_corners(cube_t dest[NON_NULL], cube_t src)
278{ 278{
279 *dest = _mm256_blend_epi32(*dest, src, 0x0F); 279 *dest = _mm256_blend_epi32(*dest, src, 0x0F);
280} 280}
281 281
282STATIC_INLINE void 282STATIC_INLINE void
283copy_edges(cube_t dest[static 1], cube_t src) 283copy_edges(cube_t dest[NON_NULL], cube_t src)
284{ 284{
285 *dest = _mm256_blend_epi32(*dest, src, 0xF0); 285 *dest = _mm256_blend_epi32(*dest, src, 0xF0);
286} 286}
287 287
288STATIC_INLINE void 288STATIC_INLINE void
289set_eo(cube_t cube[static 1], uint64_t eo) 289set_eo(cube_t cube[NON_NULL], uint64_t eo)
290{ 290{
291 uint64_t eo12, eotop, eobot; 291 uint64_t eo12, eotop, eobot;
292 __m256i veo; 292 __m256i veo;
diff --git a/src/arch/common.h b/src/arch/common.h
index 2b95fe3..a7c4a3b 100644
--- a/src/arch/common.h
+++ b/src/arch/common.h
@@ -15,7 +15,7 @@
15STATIC_INLINE int popcount_u32(uint32_t); 15STATIC_INLINE int popcount_u32(uint32_t);
16STATIC_INLINE int popcount_u64(uint64_t); 16STATIC_INLINE int popcount_u64(uint64_t);
17 17
18STATIC void pieces(cube_t [static 1], uint8_t [static 8], uint8_t [static 12]); 18STATIC void pieces(cube_t [NON_NULL], uint8_t [SIZE(8)], uint8_t [SIZE(12)]);
19STATIC_INLINE bool equal(cube_t, cube_t); 19STATIC_INLINE bool equal(cube_t, cube_t);
20STATIC_INLINE cube_t invertco(cube_t); 20STATIC_INLINE cube_t invertco(cube_t);
21STATIC_INLINE cube_t compose_edges(cube_t, cube_t); 21STATIC_INLINE cube_t compose_edges(cube_t, cube_t);
@@ -35,12 +35,12 @@ STATIC_INLINE cube_t invcoord_epudsep(uint64_t);
35 35
36STATIC_INLINE bool is_eo_even(cube_t); 36STATIC_INLINE bool is_eo_even(cube_t);
37 37
38STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); 38STATIC_INLINE void copy_corners(cube_t [NON_NULL], cube_t);
39STATIC_INLINE void copy_co(cube_t [static 1], cube_t); 39STATIC_INLINE void copy_co(cube_t [NON_NULL], cube_t);
40STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); 40STATIC_INLINE void copy_edges(cube_t [NON_NULL], cube_t);
41STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); 41STATIC_INLINE void set_eo(cube_t [NON_NULL], uint64_t);
42 42
43STATIC_INLINE void invcoord_esep_array(uint64_t, uint64_t, uint8_t[static 12]); 43STATIC_INLINE void invcoord_esep_array(uint64_t, uint64_t, uint8_t[SIZE(12)]);
44STATIC_INLINE cube_t invcoord_eoesep(uint64_t); 44STATIC_INLINE cube_t invcoord_eoesep(uint64_t);
45STATIC_INLINE uint64_t coord_epudsep_array(const uint8_t [8]); 45STATIC_INLINE uint64_t coord_epudsep_array(const uint8_t [8]);
46STATIC_INLINE void invcoord_epudsep_array(uint64_t, uint8_t [8]); 46STATIC_INLINE void invcoord_epudsep_array(uint64_t, uint8_t [8]);
@@ -53,7 +53,7 @@ STATIC_INLINE uint64_t coord_epe(cube_t);
53STATIC_INLINE cube_t invcoord_epe(uint64_t); 53STATIC_INLINE cube_t invcoord_epe(uint64_t);
54 54
55STATIC_INLINE void 55STATIC_INLINE void
56invcoord_esep_array(uint64_t set1, uint64_t set2, uint8_t mem[static 12]) 56invcoord_esep_array(uint64_t set1, uint64_t set2, uint8_t mem[SIZE(12)])
57{ 57{
58 uint64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; 58 uint64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1;
59 uint8_t slice[3] = {0}; 59 uint8_t slice[3] = {0};
diff --git a/src/arch/neon.h b/src/arch/neon.h
index 725e589..501b722 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -59,7 +59,7 @@ popcount_u64(uint64_t x)
59} 59}
60 60
61STATIC void 61STATIC void
62pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) 62pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)])
63{ 63{
64 // First 8 bytes of the corner vector are copied from the c array 64 // First 8 bytes of the corner vector are copied from the c array
65 vst1_u8(c, cube->corner); 65 vst1_u8(c, cube->corner);
@@ -244,7 +244,7 @@ coord_co(cube_t c)
244} 244}
245 245
246STATIC_INLINE void 246STATIC_INLINE void
247copy_co(cube_t cube[static 1], cube_t co) 247copy_co(cube_t cube[NON_NULL], cube_t co)
248{ 248{
249 uint8x8_t coclean; 249 uint8x8_t coclean;
250 250
@@ -340,19 +340,19 @@ coord_esep(cube_t c)
340} 340}
341 341
342STATIC_INLINE void 342STATIC_INLINE void
343copy_corners(cube_t dst[static 1], cube_t src) 343copy_corners(cube_t dst[NON_NULL], cube_t src)
344{ 344{
345 dst->corner = src.corner; 345 dst->corner = src.corner;
346} 346}
347 347
348STATIC_INLINE void 348STATIC_INLINE void
349copy_edges(cube_t dst[static 1], cube_t src) 349copy_edges(cube_t dst[NON_NULL], cube_t src)
350{ 350{
351 dst->edge = src.edge; 351 dst->edge = src.edge;
352} 352}
353 353
354STATIC_INLINE void 354STATIC_INLINE void
355set_eo(cube_t cube[static 1], uint64_t eo) 355set_eo(cube_t cube[NON_NULL], uint64_t eo)
356{ 356{
357 // Temp array to store the NEON vector 357 // Temp array to store the NEON vector
358 uint8_t mem[16]; 358 uint8_t mem[16];
diff --git a/src/arch/portable.h b/src/arch/portable.h
index 162ed1a..f1491f0 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -46,7 +46,7 @@ popcount_u64(uint64_t x)
46} 46}
47 47
48STATIC void 48STATIC void
49pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) 49pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)])
50{ 50{
51 memcpy(c, cube->corner, 8); 51 memcpy(c, cube->corner, 8);
52 memcpy(e, cube->edge, 12); 52 memcpy(e, cube->edge, 12);
@@ -166,7 +166,7 @@ inverse(cube_t cube)
166} 166}
167 167
168STATIC_INLINE void 168STATIC_INLINE void
169copy_co(cube_t cube[static 1], cube_t co) 169copy_co(cube_t cube[NON_NULL], cube_t co)
170{ 170{
171 uint8_t c; 171 uint8_t c;
172 size_t i; 172 size_t i;
@@ -291,19 +291,19 @@ invcoord_esep(uint64_t esep)
291} 291}
292 292
293STATIC_INLINE void 293STATIC_INLINE void
294copy_corners(cube_t dest[static 1], cube_t src) 294copy_corners(cube_t dest[NON_NULL], cube_t src)
295{ 295{
296 memcpy(&dest->corner, src.corner, sizeof(src.corner)); 296 memcpy(&dest->corner, src.corner, sizeof(src.corner));
297} 297}
298 298
299STATIC_INLINE void 299STATIC_INLINE void
300copy_edges(cube_t dest[static 1], cube_t src) 300copy_edges(cube_t dest[NON_NULL], cube_t src)
301{ 301{
302 memcpy(&dest->edge, src.edge, sizeof(src.edge)); 302 memcpy(&dest->edge, src.edge, sizeof(src.edge));
303} 303}
304 304
305STATIC_INLINE void 305STATIC_INLINE void
306set_eo(cube_t cube[static 1], uint64_t eo) 306set_eo(cube_t cube[NON_NULL], uint64_t eo)
307{ 307{
308 uint8_t i, sum, flip; 308 uint8_t i, sum, flip;
309 309

Generated with cgit - Back to sebastiano.tronto.net