From 56048d13b73ec6e6a9c59d62e82f41e69a3994bd Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 25 Mar 2025 18:35:47 +0100 Subject: More safety with pointers using VLA function parameters --- src/arch/avx2.h | 8 ++++---- src/arch/common.h | 8 ++++---- src/arch/neon.h | 8 ++++---- src/arch/portable.h | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/arch') diff --git a/src/arch/avx2.h b/src/arch/avx2.h index b6ff510..ebcf84f 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h @@ -23,7 +23,7 @@ popcount_u32(uint32_t x) } STATIC void -pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) +pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) { uint8_t aux[32]; @@ -252,19 +252,19 @@ coord_esep(cube_t c) } STATIC_INLINE void -copy_corners(cube_t *dest, cube_t src) +copy_corners(cube_t dest[static 1], cube_t src) { *dest = _mm256_blend_epi32(*dest, src, 0x0F); } STATIC_INLINE void -copy_edges(cube_t *dest, cube_t src) +copy_edges(cube_t dest[static 1], cube_t src) { *dest = _mm256_blend_epi32(*dest, src, 0xF0); } STATIC_INLINE void -set_eo(cube_t *cube, int64_t eo) +set_eo(cube_t cube[static 1], int64_t eo) { int64_t eo12, eotop, eobot; __m256i veo; diff --git a/src/arch/common.h b/src/arch/common.h index 52e0fc7..5c1efde 100644 --- a/src/arch/common.h +++ b/src/arch/common.h @@ -1,6 +1,6 @@ STATIC_INLINE int popcount_u32(uint32_t); -STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); +STATIC void pieces(cube_t [static 1], uint8_t [static 8], uint8_t [static 12]); STATIC_INLINE bool equal(cube_t, cube_t); STATIC_INLINE cube_t invertco(cube_t); STATIC_INLINE cube_t compose_edges(cube_t, cube_t); @@ -14,9 +14,9 @@ STATIC_INLINE int64_t coord_cocsep(cube_t); STATIC_INLINE int64_t coord_eo(cube_t); STATIC_INLINE int64_t coord_esep(cube_t); -STATIC_INLINE void copy_corners(cube_t *, cube_t); -STATIC_INLINE void copy_edges(cube_t *, cube_t); -STATIC_INLINE void set_eo(cube_t *, int64_t); +STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); +STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); +STATIC_INLINE void set_eo(cube_t [static 1], int64_t); STATIC_INLINE cube_t invcoord_esep(int64_t); STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); diff --git a/src/arch/neon.h b/src/arch/neon.h index 19f6f9d..d5f5f8b 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h @@ -39,7 +39,7 @@ popcount_u32(uint32_t x) } STATIC void -pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) +pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) { // First 8 bytes of the corner vector are copied from the c array vst1_u8(c, cube->corner); @@ -287,19 +287,19 @@ coord_esep(cube_t c) } STATIC_INLINE void -copy_corners(cube_t *dst, cube_t src) +copy_corners(cube_t dst[static 1], cube_t src) { dst->corner = src.corner; } STATIC_INLINE void -copy_edges(cube_t *dst, cube_t src) +copy_edges(cube_t dst[static 1], cube_t src) { dst->edge = src.edge; } STATIC_INLINE void -set_eo(cube_t *cube, int64_t eo) +set_eo(cube_t cube[static 1], int64_t eo) { // Temp array to store the NEON vector uint8_t mem[16]; diff --git a/src/arch/portable.h b/src/arch/portable.h index b8c5211..4ac5fe7 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h @@ -22,7 +22,7 @@ popcount_u32(uint32_t x) } STATIC void -pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) +pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) { memcpy(c, cube->corner, 8); memcpy(e, cube->edge, 12); @@ -227,19 +227,19 @@ coord_esep(cube_t c) } STATIC_INLINE void -copy_corners(cube_t *dest, cube_t src) +copy_corners(cube_t dest[static 1], cube_t src) { memcpy(&dest->corner, src.corner, sizeof(src.corner)); } STATIC_INLINE void -copy_edges(cube_t *dest, cube_t src) +copy_edges(cube_t dest[static 1], cube_t src) { memcpy(&dest->edge, src.edge, sizeof(src.edge)); } STATIC_INLINE void -set_eo(cube_t *cube, int64_t eo) +set_eo(cube_t cube[static 1], int64_t eo) { uint8_t i, sum, flip; -- cgit v1.3