From fd5ddb3db9f50411ca579d84f225f265ca35b56a Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 5 Sep 2024 08:53:38 +0200 Subject: Rename constants from _underscore to CAPS --- src/arch/portable.h | 80 ++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'src/arch/portable.h') diff --git a/src/arch/portable.h b/src/arch/portable.h index f6e5301..fdadb02 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h @@ -9,14 +9,14 @@ #define solved static_cube( \ 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) -_static void +STATIC void pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) { memcpy(c, cube->corner, 8); memcpy(e, cube->edge, 12); } -_static_inline bool +STATIC_INLINE bool equal(cube_t c1, cube_t c2) { uint8_t i; @@ -31,7 +31,7 @@ equal(cube_t c1, cube_t c2) return ret; } -_static_inline cube_t +STATIC_INLINE cube_t invertco(cube_t c) { uint8_t i, piece, orien; @@ -40,44 +40,44 @@ invertco(cube_t c) ret = c; for (i = 0; i < 8; i++) { piece = c.corner[i]; - orien = ((piece << 1) | (piece >> 1)) & _cobits2; - ret.corner[i] = (piece & _pbits) | orien; + orien = ((piece << 1) | (piece >> 1)) & COBITS_2; + ret.corner[i] = (piece & PBITS) | orien; } return ret; } -_static_inline void +STATIC_INLINE void compose_edges_inplace(cube_t c1, cube_t c2, cube_t *ret) { uint8_t i, piece1, piece2, p, orien; for (i = 0; i < 12; i++) { piece2 = c2.edge[i]; - p = piece2 & _pbits; + p = piece2 & PBITS; piece1 = c1.edge[p]; - orien = (piece2 ^ piece1) & _eobit; - ret->edge[i] = (piece1 & _pbits) | orien; + orien = (piece2 ^ piece1) & EOBIT; + ret->edge[i] = (piece1 & PBITS) | orien; } } -_static_inline void +STATIC_INLINE void compose_corners_inplace(cube_t c1, cube_t c2, cube_t *ret) { uint8_t i, piece1, piece2, p, orien, aux, auy; for (i = 0; i < 8; i++) { piece2 = c2.corner[i]; - p = piece2 & _pbits; + p = piece2 & PBITS; piece1 = c1.corner[p]; - aux = (piece2 & _cobits) + (piece1 & _cobits); - auy = (aux + _ctwist_cw) >> 2; - orien = (aux + auy) & _cobits2; - ret->corner[i] = (piece1 & _pbits) | orien; + aux = (piece2 & COBITS) + (piece1 & COBITS); + auy = (aux + CTWIST_CW) >> 2; + orien = (aux + auy) & COBITS_2; + ret->corner[i] = (piece1 & PBITS) | orien; } } -_static_inline cube_t +STATIC_INLINE cube_t compose_edges(cube_t c1, cube_t c2) { cube_t ret = zero; @@ -87,7 +87,7 @@ compose_edges(cube_t c1, cube_t c2) return ret; } -_static_inline cube_t +STATIC_INLINE cube_t compose_corners(cube_t c1, cube_t c2) { cube_t ret = zero; @@ -97,7 +97,7 @@ compose_corners(cube_t c1, cube_t c2) return ret; } -_static_inline cube_t +STATIC_INLINE cube_t compose(cube_t c1, cube_t c2) { cube_t ret = zero; @@ -116,27 +116,27 @@ inverse(cube_t cube) for (i = 0; i < 12; i++) { piece = cube.edge[i]; - orien = piece & _eobit; - ret.edge[piece & _pbits] = i | orien; + orien = piece & EOBIT; + ret.edge[piece & PBITS] = i | orien; } for (i = 0; i < 8; i++) { piece = cube.corner[i]; - orien = ((piece << 1) | (piece >> 1)) & _cobits2; - ret.corner[piece & _pbits] = i | orien; + orien = ((piece << 1) | (piece >> 1)) & COBITS_2; + ret.corner[piece & PBITS] = i | orien; } return ret; } -_static_inline int64_t +STATIC_INLINE int64_t coord_co(cube_t c) { int i, p; int64_t ret; for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) - ret += p * (c.corner[i] >> _coshift); + ret += p * (c.corner[i] >> COSHIFT); return ret; } @@ -148,32 +148,32 @@ Ignoring the last bit, we have a value up to 2^7, but not all values are possible. Encoding this as a number from 0 to C(8,4) would save about 40% of space, but we are not going to use this coordinate in large tables. */ -_static_inline int64_t +STATIC_INLINE int64_t coord_csep(cube_t c) { int i, p; int64_t ret; for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) - ret += p * ((c.corner[i] & _csepbit) >> 2); + ret += p * ((c.corner[i] & CSEPBIT) >> 2); return ret; } -_static_inline int64_t +STATIC_INLINE int64_t coord_cocsep(cube_t c) { return (coord_co(c) << 7) + coord_csep(c); } -_static_inline int64_t +STATIC_INLINE int64_t coord_eo(cube_t c) { int i, p; int64_t ret; for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2) - ret += p * (c.edge[i] >> _eoshift); + ret += p * (c.edge[i] >> EOSHIFT); return ret; } @@ -182,24 +182,24 @@ coord_eo(cube_t c) We encode the edge separation as a number from 0 to C(12,4)*C(8,4). It can be seen as the composition of two "subset index" coordinates. */ -_static_inline int64_t +STATIC_INLINE int64_t coord_esep(cube_t c) { int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { /* Simple version: - if (c.edge[i] & _esepbit2) { + if (c.edge[i] & ESEPBIT_2) { ret1 += binomial[11-i][k--]; } else { - if (c.edge[i] & _esepbit1) + if (c.edge[i] & ESEPBIT_1) ret2 += binomial[7-j][l--]; j++; } */ - bit1 = (c.edge[i] & _esepbit1) >> 2; - bit2 = (c.edge[i] & _esepbit2) >> 3; + bit1 = (c.edge[i] & ESEPBIT_1) >> 2; + bit2 = (c.edge[i] & ESEPBIT_2) >> 3; is1 = (1 - bit2) * bit1; ret1 += bit2 * binomial[11-i][k]; @@ -214,19 +214,19 @@ coord_esep(cube_t c) return ret1 * 70 + ret2; } -_static_inline void +STATIC_INLINE void copy_corners(cube_t *dest, cube_t src) { memcpy(&dest->corner, src.corner, sizeof(src.corner)); } -_static_inline void +STATIC_INLINE void copy_edges(cube_t *dest, cube_t src) { memcpy(&dest->edge, src.edge, sizeof(src.edge)); } -_static_inline void +STATIC_INLINE void set_eo(cube_t *cube, int64_t eo) { uint8_t i, sum, flip; @@ -234,12 +234,12 @@ set_eo(cube_t *cube, int64_t eo) for (sum = 0, i = 1; i < 12; i++, eo >>= 1) { flip = eo % 2; sum += flip; - cube->edge[i] = (cube->edge[i] & ~_eobit) | (_eobit * flip); + cube->edge[i] = (cube->edge[i] & ~EOBIT) | (EOBIT * flip); } - cube->edge[0] = (cube->edge[0] & ~_eobit) | (_eobit * (sum % 2)); + cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); } -_static_inline cube_t +STATIC_INLINE cube_t invcoord_esep(int64_t esep) { cube_t ret; -- cgit v1.3