diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-05 08:53:38 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-05 08:55:25 +0200 |
| commit | fd5ddb3db9f50411ca579d84f225f265ca35b56a (patch) | |
| tree | b659112cc0e2abd6c7edb08b0938c0d2de4ca066 /src/utils | |
| parent | c9e2d6466e42d6b779ac9ffa7c5ee9a9c7558df8 (diff) | |
| download | nissy-core-fd5ddb3db9f50411ca579d84f225f265ca35b56a.tar.gz nissy-core-fd5ddb3db9f50411ca579d84f225f265ca35b56a.zip | |
Rename constants from _underscore to CAPS
Diffstat (limited to '')
| -rw-r--r-- | src/utils/constants.h | 526 | ||||
| -rw-r--r-- | src/utils/dbg_log.h | 8 | ||||
| -rw-r--r-- | src/utils/math.h | 52 |
3 files changed, 291 insertions, 295 deletions
diff --git a/src/utils/constants.h b/src/utils/constants.h index 34b4f00..6d0683e 100644 --- a/src/utils/constants.h +++ b/src/utils/constants.h | |||
| @@ -1,19 +1,15 @@ | |||
| 1 | #define _bit_u8(i) (UINT8_C(1) << (uint8_t)(i)) | 1 | #define UINT32_BIT(i) (UINT32_C(1) << (uint32_t)(i)) |
| 2 | #define _bit_u32(i) (UINT32_C(1) << (uint32_t)(i)) | ||
| 3 | #define _bit_u64(i) (UINT64_C(1) << (uint64_t)(i)) | ||
| 4 | 2 | ||
| 5 | #define _max_factorial INT64_C(12) | 3 | #define FACTORIAL_MAX INT64_C(12) |
| 6 | 4 | ||
| 7 | #define _2p11 INT64_C(2048) | 5 | #define POW_2_11 INT64_C(2048) |
| 8 | #define _2p12 INT64_C(4096) | 6 | #define POW_3_7 INT64_C(2187) |
| 9 | #define _3p7 INT64_C(2187) | 7 | #define FACT_12 INT64_C(479001600) |
| 10 | #define _3p8 INT64_C(6561) | 8 | #define FACT_8 INT64_C(40320) |
| 11 | #define _12f INT64_C(479001600) | 9 | #define COMB_12_4 INT64_C(495) |
| 12 | #define _8f INT64_C(40320) | 10 | #define COMB_8_4 INT64_C(70) |
| 13 | #define _12c4 INT64_C(495) | ||
| 14 | #define _8c4 INT64_C(70) | ||
| 15 | 11 | ||
| 16 | _static int64_t binomial[12][12] = { | 12 | STATIC int64_t binomial[12][12] = { |
| 17 | {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | 13 | {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
| 18 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | 14 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
| 19 | {1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | 15 | {1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
| @@ -28,275 +24,275 @@ _static int64_t binomial[12][12] = { | |||
| 28 | {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1}, | 24 | {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1}, |
| 29 | }; | 25 | }; |
| 30 | 26 | ||
| 31 | #define _move_U UINT8_C(0) | 27 | #define MOVE_U UINT8_C(0) |
| 32 | #define _move_U2 UINT8_C(1) | 28 | #define MOVE_U2 UINT8_C(1) |
| 33 | #define _move_U3 UINT8_C(2) | 29 | #define MOVE_U3 UINT8_C(2) |
| 34 | #define _move_D UINT8_C(3) | 30 | #define MOVE_D UINT8_C(3) |
| 35 | #define _move_D2 UINT8_C(4) | 31 | #define MOVE_D2 UINT8_C(4) |
| 36 | #define _move_D3 UINT8_C(5) | 32 | #define MOVE_D3 UINT8_C(5) |
| 37 | #define _move_R UINT8_C(6) | 33 | #define MOVE_R UINT8_C(6) |
| 38 | #define _move_R2 UINT8_C(7) | 34 | #define MOVE_R2 UINT8_C(7) |
| 39 | #define _move_R3 UINT8_C(8) | 35 | #define MOVE_R3 UINT8_C(8) |
| 40 | #define _move_L UINT8_C(9) | 36 | #define MOVE_L UINT8_C(9) |
| 41 | #define _move_L2 UINT8_C(10) | 37 | #define MOVE_L2 UINT8_C(10) |
| 42 | #define _move_L3 UINT8_C(11) | 38 | #define MOVE_L3 UINT8_C(11) |
| 43 | #define _move_F UINT8_C(12) | 39 | #define MOVE_F UINT8_C(12) |
| 44 | #define _move_F2 UINT8_C(13) | 40 | #define MOVE_F2 UINT8_C(13) |
| 45 | #define _move_F3 UINT8_C(14) | 41 | #define MOVE_F3 UINT8_C(14) |
| 46 | #define _move_B UINT8_C(15) | 42 | #define MOVE_B UINT8_C(15) |
| 47 | #define _move_B2 UINT8_C(16) | 43 | #define MOVE_B2 UINT8_C(16) |
| 48 | #define _move_B3 UINT8_C(17) | 44 | #define MOVE_B3 UINT8_C(17) |
| 49 | 45 | ||
| 50 | #define _trans_UFr UINT8_C(0) | 46 | #define TRANS_UFr UINT8_C(0) |
| 51 | #define _trans_ULr UINT8_C(1) | 47 | #define TRANS_ULr UINT8_C(1) |
| 52 | #define _trans_UBr UINT8_C(2) | 48 | #define TRANS_UBr UINT8_C(2) |
| 53 | #define _trans_URr UINT8_C(3) | 49 | #define TRANS_URr UINT8_C(3) |
| 54 | #define _trans_DFr UINT8_C(4) | 50 | #define TRANS_DFr UINT8_C(4) |
| 55 | #define _trans_DLr UINT8_C(5) | 51 | #define TRANS_DLr UINT8_C(5) |
| 56 | #define _trans_DBr UINT8_C(6) | 52 | #define TRANS_DBr UINT8_C(6) |
| 57 | #define _trans_DRr UINT8_C(7) | 53 | #define TRANS_DRr UINT8_C(7) |
| 58 | #define _trans_RUr UINT8_C(8) | 54 | #define TRANS_RUr UINT8_C(8) |
| 59 | #define _trans_RFr UINT8_C(9) | 55 | #define TRANS_RFr UINT8_C(9) |
| 60 | #define _trans_RDr UINT8_C(10) | 56 | #define TRANS_RDr UINT8_C(10) |
| 61 | #define _trans_RBr UINT8_C(11) | 57 | #define TRANS_RBr UINT8_C(11) |
| 62 | #define _trans_LUr UINT8_C(12) | 58 | #define TRANS_LUr UINT8_C(12) |
| 63 | #define _trans_LFr UINT8_C(13) | 59 | #define TRANS_LFr UINT8_C(13) |
| 64 | #define _trans_LDr UINT8_C(14) | 60 | #define TRANS_LDr UINT8_C(14) |
| 65 | #define _trans_LBr UINT8_C(15) | 61 | #define TRANS_LBr UINT8_C(15) |
| 66 | #define _trans_FUr UINT8_C(16) | 62 | #define TRANS_FUr UINT8_C(16) |
| 67 | #define _trans_FRr UINT8_C(17) | 63 | #define TRANS_FRr UINT8_C(17) |
| 68 | #define _trans_FDr UINT8_C(18) | 64 | #define TRANS_FDr UINT8_C(18) |
| 69 | #define _trans_FLr UINT8_C(19) | 65 | #define TRANS_FLr UINT8_C(19) |
| 70 | #define _trans_BUr UINT8_C(20) | 66 | #define TRANS_BUr UINT8_C(20) |
| 71 | #define _trans_BRr UINT8_C(21) | 67 | #define TRANS_BRr UINT8_C(21) |
| 72 | #define _trans_BDr UINT8_C(22) | 68 | #define TRANS_BDr UINT8_C(22) |
| 73 | #define _trans_BLr UINT8_C(23) | 69 | #define TRANS_BLr UINT8_C(23) |
| 74 | 70 | ||
| 75 | #define _trans_UFm UINT8_C(24) | 71 | #define TRANS_UFm UINT8_C(24) |
| 76 | #define _trans_ULm UINT8_C(25) | 72 | #define TRANS_ULm UINT8_C(25) |
| 77 | #define _trans_UBm UINT8_C(26) | 73 | #define TRANS_UBm UINT8_C(26) |
| 78 | #define _trans_URm UINT8_C(27) | 74 | #define TRANS_URm UINT8_C(27) |
| 79 | #define _trans_DFm UINT8_C(28) | 75 | #define TRANS_DFm UINT8_C(28) |
| 80 | #define _trans_DLm UINT8_C(29) | 76 | #define TRANS_DLm UINT8_C(29) |
| 81 | #define _trans_DBm UINT8_C(30) | 77 | #define TRANS_DBm UINT8_C(30) |
| 82 | #define _trans_DRm UINT8_C(31) | 78 | #define TRANS_DRm UINT8_C(31) |
| 83 | #define _trans_RUm UINT8_C(32) | 79 | #define TRANS_RUm UINT8_C(32) |
| 84 | #define _trans_RFm UINT8_C(33) | 80 | #define TRANS_RFm UINT8_C(33) |
| 85 | #define _trans_RDm UINT8_C(34) | 81 | #define TRANS_RDm UINT8_C(34) |
| 86 | #define _trans_RBm UINT8_C(35) | 82 | #define TRANS_RBm UINT8_C(35) |
| 87 | #define _trans_LUm UINT8_C(36) | 83 | #define TRANS_LUm UINT8_C(36) |
| 88 | #define _trans_LFm UINT8_C(37) | 84 | #define TRANS_LFm UINT8_C(37) |
| 89 | #define _trans_LDm UINT8_C(38) | 85 | #define TRANS_LDm UINT8_C(38) |
| 90 | #define _trans_LBm UINT8_C(39) | 86 | #define TRANS_LBm UINT8_C(39) |
| 91 | #define _trans_FUm UINT8_C(40) | 87 | #define TRANS_FUm UINT8_C(40) |
| 92 | #define _trans_FRm UINT8_C(41) | 88 | #define TRANS_FRm UINT8_C(41) |
| 93 | #define _trans_FDm UINT8_C(42) | 89 | #define TRANS_FDm UINT8_C(42) |
| 94 | #define _trans_FLm UINT8_C(43) | 90 | #define TRANS_FLm UINT8_C(43) |
| 95 | #define _trans_BUm UINT8_C(44) | 91 | #define TRANS_BUm UINT8_C(44) |
| 96 | #define _trans_BRm UINT8_C(45) | 92 | #define TRANS_BRm UINT8_C(45) |
| 97 | #define _trans_BDm UINT8_C(46) | 93 | #define TRANS_BDm UINT8_C(46) |
| 98 | #define _trans_BLm UINT8_C(47) | 94 | #define TRANS_BLm UINT8_C(47) |
| 99 | 95 | ||
| 100 | #define _mm_normal UINT32_C(0x00) | 96 | #define MM_NORMAL UINT32_C(0x00) |
| 101 | #define _mm_inverse UINT32_C(0x01) | 97 | #define MM_INVERSE UINT32_C(0x01) |
| 102 | #define _mm_inversebranch UINT32_C(0x03) | 98 | #define MM_INVERSEBRANCH UINT32_C(0x03) |
| 103 | #define _mm_normalbranch UINT32_C(0x02) | 99 | #define MM_NORMALBRANCH UINT32_C(0x02) |
| 104 | #define _mm_allmoves UINT32_C(0x3FFFF) | 100 | #define MM_ALLMOVES UINT32_C(0x3FFFF) |
| 105 | #define _mm_nohalfturns UINT32_C(0x2DB6D) | 101 | #define MM_NOHALFTURNS UINT32_C(0x2DB6D) |
| 106 | 102 | ||
| 107 | #define _c_ufr UINT8_C(0) | 103 | #define CORNER_UFR UINT8_C(0) |
| 108 | #define _c_ubl UINT8_C(1) | 104 | #define CORNER_UBL UINT8_C(1) |
| 109 | #define _c_dfl UINT8_C(2) | 105 | #define CORNER_DFL UINT8_C(2) |
| 110 | #define _c_dbr UINT8_C(3) | 106 | #define CORNER_DBR UINT8_C(3) |
| 111 | #define _c_ufl UINT8_C(4) | 107 | #define CORNER_UFL UINT8_C(4) |
| 112 | #define _c_ubr UINT8_C(5) | 108 | #define CORNER_UBR UINT8_C(5) |
| 113 | #define _c_dfr UINT8_C(6) | 109 | #define CORNER_DFR UINT8_C(6) |
| 114 | #define _c_dbl UINT8_C(7) | 110 | #define CORNER_DBL UINT8_C(7) |
| 115 | 111 | ||
| 116 | #define _e_uf UINT8_C(0) | 112 | #define EDGE_UF UINT8_C(0) |
| 117 | #define _e_ub UINT8_C(1) | 113 | #define EDGE_UB UINT8_C(1) |
| 118 | #define _e_db UINT8_C(2) | 114 | #define EDGE_DB UINT8_C(2) |
| 119 | #define _e_df UINT8_C(3) | 115 | #define EDGE_DF UINT8_C(3) |
| 120 | #define _e_ur UINT8_C(4) | 116 | #define EDGE_UR UINT8_C(4) |
| 121 | #define _e_ul UINT8_C(5) | 117 | #define EDGE_UL UINT8_C(5) |
| 122 | #define _e_dl UINT8_C(6) | 118 | #define EDGE_DL UINT8_C(6) |
| 123 | #define _e_dr UINT8_C(7) | 119 | #define EDGE_DR UINT8_C(7) |
| 124 | #define _e_fr UINT8_C(8) | 120 | #define EDGE_FR UINT8_C(8) |
| 125 | #define _e_fl UINT8_C(9) | 121 | #define EDGE_FL UINT8_C(9) |
| 126 | #define _e_bl UINT8_C(10) | 122 | #define EDGE_BL UINT8_C(10) |
| 127 | #define _e_br UINT8_C(11) | 123 | #define EDGE_BR UINT8_C(11) |
| 128 | 124 | ||
| 129 | #define _eoshift UINT8_C(4) | 125 | #define EOSHIFT UINT8_C(4) |
| 130 | #define _coshift UINT8_C(5) | 126 | #define COSHIFT UINT8_C(5) |
| 131 | 127 | ||
| 132 | #define _pbits UINT8_C(0xF) | 128 | #define PBITS UINT8_C(0xF) |
| 133 | #define _esepbit1 UINT8_C(0x4) | 129 | #define ESEPBIT_1 UINT8_C(0x4) |
| 134 | #define _esepbit2 UINT8_C(0x8) | 130 | #define ESEPBIT_2 UINT8_C(0x8) |
| 135 | #define _csepbit UINT8_C(0x4) | 131 | #define CSEPBIT UINT8_C(0x4) |
| 136 | #define _eobit UINT8_C(0x10) | 132 | #define EOBIT UINT8_C(0x10) |
| 137 | #define _cobits UINT8_C(0xF0) | 133 | #define COBITS UINT8_C(0xF0) |
| 138 | #define _cobits2 UINT8_C(0x60) | 134 | #define COBITS_2 UINT8_C(0x60) |
| 139 | #define _ctwist_cw UINT8_C(0x20) | 135 | #define CTWIST_CW UINT8_C(0x20) |
| 140 | #define _ctwist_ccw UINT8_C(0x40) | 136 | #define CTWIST_CCW UINT8_C(0x40) |
| 141 | #define _eflip UINT8_C(0x10) | 137 | #define EFLIP UINT8_C(0x10) |
| 142 | #define _error UINT8_C(0xFF) | 138 | #define UINT8_ERROR UINT8_C(0xFF) |
| 143 | 139 | ||
| 144 | _static const char *cornerstr[] = { | 140 | STATIC const char *cornerstr[] = { |
| 145 | [_c_ufr] = "UFR", | 141 | [CORNER_UFR] = "UFR", |
| 146 | [_c_ubl] = "UBL", | 142 | [CORNER_UBL] = "UBL", |
| 147 | [_c_dfl] = "DFL", | 143 | [CORNER_DFL] = "DFL", |
| 148 | [_c_dbr] = "DBR", | 144 | [CORNER_DBR] = "DBR", |
| 149 | [_c_ufl] = "UFL", | 145 | [CORNER_UFL] = "UFL", |
| 150 | [_c_ubr] = "UBR", | 146 | [CORNER_UBR] = "UBR", |
| 151 | [_c_dfr] = "DFR", | 147 | [CORNER_DFR] = "DFR", |
| 152 | [_c_dbl] = "DBL" | 148 | [CORNER_DBL] = "DBL" |
| 153 | }; | 149 | }; |
| 154 | 150 | ||
| 155 | _static const char *cornerstralt[] = { | 151 | STATIC const char *cornerstralt[] = { |
| 156 | [_c_ufr] = "URF", | 152 | [CORNER_UFR] = "URF", |
| 157 | [_c_ubl] = "ULB", | 153 | [CORNER_UBL] = "ULB", |
| 158 | [_c_dfl] = "DLF", | 154 | [CORNER_DFL] = "DLF", |
| 159 | [_c_dbr] = "DRB", | 155 | [CORNER_DBR] = "DRB", |
| 160 | [_c_ufl] = "ULF", | 156 | [CORNER_UFL] = "ULF", |
| 161 | [_c_ubr] = "URB", | 157 | [CORNER_UBR] = "URB", |
| 162 | [_c_dfr] = "DRF", | 158 | [CORNER_DFR] = "DRF", |
| 163 | [_c_dbl] = "DLB" | 159 | [CORNER_DBL] = "DLB" |
| 164 | }; | 160 | }; |
| 165 | 161 | ||
| 166 | _static const char *edgestr[] = { | 162 | STATIC const char *edgestr[] = { |
| 167 | [_e_uf] = "UF", | 163 | [EDGE_UF] = "UF", |
| 168 | [_e_ub] = "UB", | 164 | [EDGE_UB] = "UB", |
| 169 | [_e_db] = "DB", | 165 | [EDGE_DB] = "DB", |
| 170 | [_e_df] = "DF", | 166 | [EDGE_DF] = "DF", |
| 171 | [_e_ur] = "UR", | 167 | [EDGE_UR] = "UR", |
| 172 | [_e_ul] = "UL", | 168 | [EDGE_UL] = "UL", |
| 173 | [_e_dl] = "DL", | 169 | [EDGE_DL] = "DL", |
| 174 | [_e_dr] = "DR", | 170 | [EDGE_DR] = "DR", |
| 175 | [_e_fr] = "FR", | 171 | [EDGE_FR] = "FR", |
| 176 | [_e_fl] = "FL", | 172 | [EDGE_FL] = "FL", |
| 177 | [_e_bl] = "BL", | 173 | [EDGE_BL] = "BL", |
| 178 | [_e_br] = "BR" | 174 | [EDGE_BR] = "BR" |
| 179 | }; | 175 | }; |
| 180 | 176 | ||
| 181 | _static const char *movestr[] = { | 177 | STATIC const char *movestr[] = { |
| 182 | [_move_U] = "U", | 178 | [MOVE_U] = "U", |
| 183 | [_move_U2] = "U2", | 179 | [MOVE_U2] = "U2", |
| 184 | [_move_U3] = "U'", | 180 | [MOVE_U3] = "U'", |
| 185 | [_move_D] = "D", | 181 | [MOVE_D] = "D", |
| 186 | [_move_D2] = "D2", | 182 | [MOVE_D2] = "D2", |
| 187 | [_move_D3] = "D'", | 183 | [MOVE_D3] = "D'", |
| 188 | [_move_R] = "R", | 184 | [MOVE_R] = "R", |
| 189 | [_move_R2] = "R2", | 185 | [MOVE_R2] = "R2", |
| 190 | [_move_R3] = "R'", | 186 | [MOVE_R3] = "R'", |
| 191 | [_move_L] = "L", | 187 | [MOVE_L] = "L", |
| 192 | [_move_L2] = "L2", | 188 | [MOVE_L2] = "L2", |
| 193 | [_move_L3] = "L'", | 189 | [MOVE_L3] = "L'", |
| 194 | [_move_F] = "F", | 190 | [MOVE_F] = "F", |
| 195 | [_move_F2] = "F2", | 191 | [MOVE_F2] = "F2", |
| 196 | [_move_F3] = "F'", | 192 | [MOVE_F3] = "F'", |
| 197 | [_move_B] = "B", | 193 | [MOVE_B] = "B", |
| 198 | [_move_B2] = "B2", | 194 | [MOVE_B2] = "B2", |
| 199 | [_move_B3] = "B'", | 195 | [MOVE_B3] = "B'", |
| 200 | }; | 196 | }; |
| 201 | 197 | ||
| 202 | _static const char *transstr[] = { | 198 | STATIC const char *transstr[] = { |
| 203 | [_trans_UFr] = "rotation UF", | 199 | [TRANS_UFr] = "rotation UF", |
| 204 | [_trans_UFm] = "mirrored UF", | 200 | [TRANS_UFm] = "mirrored UF", |
| 205 | [_trans_ULr] = "rotation UL", | 201 | [TRANS_ULr] = "rotation UL", |
| 206 | [_trans_ULm] = "mirrored UL", | 202 | [TRANS_ULm] = "mirrored UL", |
| 207 | [_trans_UBr] = "rotation UB", | 203 | [TRANS_UBr] = "rotation UB", |
| 208 | [_trans_UBm] = "mirrored UB", | 204 | [TRANS_UBm] = "mirrored UB", |
| 209 | [_trans_URr] = "rotation UR", | 205 | [TRANS_URr] = "rotation UR", |
| 210 | [_trans_URm] = "mirrored UR", | 206 | [TRANS_URm] = "mirrored UR", |
| 211 | [_trans_DFr] = "rotation DF", | 207 | [TRANS_DFr] = "rotation DF", |
| 212 | [_trans_DFm] = "mirrored DF", | 208 | [TRANS_DFm] = "mirrored DF", |
| 213 | [_trans_DLr] = "rotation DL", | 209 | [TRANS_DLr] = "rotation DL", |
| 214 | [_trans_DLm] = "mirrored DL", | 210 | [TRANS_DLm] = "mirrored DL", |
| 215 | [_trans_DBr] = "rotation DB", | 211 | [TRANS_DBr] = "rotation DB", |
| 216 | [_trans_DBm] = "mirrored DB", | 212 | [TRANS_DBm] = "mirrored DB", |
| 217 | [_trans_DRr] = "rotation DR", | 213 | [TRANS_DRr] = "rotation DR", |
| 218 | [_trans_DRm] = "mirrored DR", | 214 | [TRANS_DRm] = "mirrored DR", |
| 219 | [_trans_RUr] = "rotation RU", | 215 | [TRANS_RUr] = "rotation RU", |
| 220 | [_trans_RUm] = "mirrored RU", | 216 | [TRANS_RUm] = "mirrored RU", |
| 221 | [_trans_RFr] = "rotation RF", | 217 | [TRANS_RFr] = "rotation RF", |
| 222 | [_trans_RFm] = "mirrored RF", | 218 | [TRANS_RFm] = "mirrored RF", |
| 223 | [_trans_RDr] = "rotation RD", | 219 | [TRANS_RDr] = "rotation RD", |
| 224 | [_trans_RDm] = "mirrored RD", | 220 | [TRANS_RDm] = "mirrored RD", |
| 225 | [_trans_RBr] = "rotation RB", | 221 | [TRANS_RBr] = "rotation RB", |
| 226 | [_trans_RBm] = "mirrored RB", | 222 | [TRANS_RBm] = "mirrored RB", |
| 227 | [_trans_LUr] = "rotation LU", | 223 | [TRANS_LUr] = "rotation LU", |
| 228 | [_trans_LUm] = "mirrored LU", | 224 | [TRANS_LUm] = "mirrored LU", |
| 229 | [_trans_LFr] = "rotation LF", | 225 | [TRANS_LFr] = "rotation LF", |
| 230 | [_trans_LFm] = "mirrored LF", | 226 | [TRANS_LFm] = "mirrored LF", |
| 231 | [_trans_LDr] = "rotation LD", | 227 | [TRANS_LDr] = "rotation LD", |
| 232 | [_trans_LDm] = "mirrored LD", | 228 | [TRANS_LDm] = "mirrored LD", |
| 233 | [_trans_LBr] = "rotation LB", | 229 | [TRANS_LBr] = "rotation LB", |
| 234 | [_trans_LBm] = "mirrored LB", | 230 | [TRANS_LBm] = "mirrored LB", |
| 235 | [_trans_FUr] = "rotation FU", | 231 | [TRANS_FUr] = "rotation FU", |
| 236 | [_trans_FUm] = "mirrored FU", | 232 | [TRANS_FUm] = "mirrored FU", |
| 237 | [_trans_FRr] = "rotation FR", | 233 | [TRANS_FRr] = "rotation FR", |
| 238 | [_trans_FRm] = "mirrored FR", | 234 | [TRANS_FRm] = "mirrored FR", |
| 239 | [_trans_FDr] = "rotation FD", | 235 | [TRANS_FDr] = "rotation FD", |
| 240 | [_trans_FDm] = "mirrored FD", | 236 | [TRANS_FDm] = "mirrored FD", |
| 241 | [_trans_FLr] = "rotation FL", | 237 | [TRANS_FLr] = "rotation FL", |
| 242 | [_trans_FLm] = "mirrored FL", | 238 | [TRANS_FLm] = "mirrored FL", |
| 243 | [_trans_BUr] = "rotation BU", | 239 | [TRANS_BUr] = "rotation BU", |
| 244 | [_trans_BUm] = "mirrored BU", | 240 | [TRANS_BUm] = "mirrored BU", |
| 245 | [_trans_BRr] = "rotation BR", | 241 | [TRANS_BRr] = "rotation BR", |
| 246 | [_trans_BRm] = "mirrored BR", | 242 | [TRANS_BRm] = "mirrored BR", |
| 247 | [_trans_BDr] = "rotation BD", | 243 | [TRANS_BDr] = "rotation BD", |
| 248 | [_trans_BDm] = "mirrored BD", | 244 | [TRANS_BDm] = "mirrored BD", |
| 249 | [_trans_BLr] = "rotation BL", | 245 | [TRANS_BLr] = "rotation BL", |
| 250 | [_trans_BLm] = "mirrored BL", | 246 | [TRANS_BLm] = "mirrored BL", |
| 251 | }; | 247 | }; |
| 252 | 248 | ||
| 253 | static uint8_t inverse_trans_table[48] = { | 249 | static uint8_t inverse_trans_table[48] = { |
| 254 | [_trans_UFr] = _trans_UFr, | 250 | [TRANS_UFr] = TRANS_UFr, |
| 255 | [_trans_UFm] = _trans_UFm, | 251 | [TRANS_UFm] = TRANS_UFm, |
| 256 | [_trans_ULr] = _trans_URr, | 252 | [TRANS_ULr] = TRANS_URr, |
| 257 | [_trans_ULm] = _trans_ULm, | 253 | [TRANS_ULm] = TRANS_ULm, |
| 258 | [_trans_UBr] = _trans_UBr, | 254 | [TRANS_UBr] = TRANS_UBr, |
| 259 | [_trans_UBm] = _trans_UBm, | 255 | [TRANS_UBm] = TRANS_UBm, |
| 260 | [_trans_URr] = _trans_ULr, | 256 | [TRANS_URr] = TRANS_ULr, |
| 261 | [_trans_URm] = _trans_URm, | 257 | [TRANS_URm] = TRANS_URm, |
| 262 | [_trans_DFr] = _trans_DFr, | 258 | [TRANS_DFr] = TRANS_DFr, |
| 263 | [_trans_DFm] = _trans_DFm, | 259 | [TRANS_DFm] = TRANS_DFm, |
| 264 | [_trans_DLr] = _trans_DLr, | 260 | [TRANS_DLr] = TRANS_DLr, |
| 265 | [_trans_DLm] = _trans_DRm, | 261 | [TRANS_DLm] = TRANS_DRm, |
| 266 | [_trans_DBr] = _trans_DBr, | 262 | [TRANS_DBr] = TRANS_DBr, |
| 267 | [_trans_DBm] = _trans_DBm, | 263 | [TRANS_DBm] = TRANS_DBm, |
| 268 | [_trans_DRr] = _trans_DRr, | 264 | [TRANS_DRr] = TRANS_DRr, |
| 269 | [_trans_DRm] = _trans_DLm, | 265 | [TRANS_DRm] = TRANS_DLm, |
| 270 | [_trans_RUr] = _trans_FRr, | 266 | [TRANS_RUr] = TRANS_FRr, |
| 271 | [_trans_RUm] = _trans_FLm, | 267 | [TRANS_RUm] = TRANS_FLm, |
| 272 | [_trans_RFr] = _trans_LFr, | 268 | [TRANS_RFr] = TRANS_LFr, |
| 273 | [_trans_RFm] = _trans_RFm, | 269 | [TRANS_RFm] = TRANS_RFm, |
| 274 | [_trans_RDr] = _trans_BLr, | 270 | [TRANS_RDr] = TRANS_BLr, |
| 275 | [_trans_RDm] = _trans_BRm, | 271 | [TRANS_RDm] = TRANS_BRm, |
| 276 | [_trans_RBr] = _trans_RBr, | 272 | [TRANS_RBr] = TRANS_RBr, |
| 277 | [_trans_RBm] = _trans_LBm, | 273 | [TRANS_RBm] = TRANS_LBm, |
| 278 | [_trans_LUr] = _trans_FLr, | 274 | [TRANS_LUr] = TRANS_FLr, |
| 279 | [_trans_LUm] = _trans_FRm, | 275 | [TRANS_LUm] = TRANS_FRm, |
| 280 | [_trans_LFr] = _trans_RFr, | 276 | [TRANS_LFr] = TRANS_RFr, |
| 281 | [_trans_LFm] = _trans_LFm, | 277 | [TRANS_LFm] = TRANS_LFm, |
| 282 | [_trans_LDr] = _trans_BRr, | 278 | [TRANS_LDr] = TRANS_BRr, |
| 283 | [_trans_LDm] = _trans_BLm, | 279 | [TRANS_LDm] = TRANS_BLm, |
| 284 | [_trans_LBr] = _trans_LBr, | 280 | [TRANS_LBr] = TRANS_LBr, |
| 285 | [_trans_LBm] = _trans_RBm, | 281 | [TRANS_LBm] = TRANS_RBm, |
| 286 | [_trans_FUr] = _trans_FUr, | 282 | [TRANS_FUr] = TRANS_FUr, |
| 287 | [_trans_FUm] = _trans_FUm, | 283 | [TRANS_FUm] = TRANS_FUm, |
| 288 | [_trans_FRr] = _trans_RUr, | 284 | [TRANS_FRr] = TRANS_RUr, |
| 289 | [_trans_FRm] = _trans_LUm, | 285 | [TRANS_FRm] = TRANS_LUm, |
| 290 | [_trans_FDr] = _trans_BUr, | 286 | [TRANS_FDr] = TRANS_BUr, |
| 291 | [_trans_FDm] = _trans_BUm, | 287 | [TRANS_FDm] = TRANS_BUm, |
| 292 | [_trans_FLr] = _trans_LUr, | 288 | [TRANS_FLr] = TRANS_LUr, |
| 293 | [_trans_FLm] = _trans_RUm, | 289 | [TRANS_FLm] = TRANS_RUm, |
| 294 | [_trans_BUr] = _trans_FDr, | 290 | [TRANS_BUr] = TRANS_FDr, |
| 295 | [_trans_BUm] = _trans_FDm, | 291 | [TRANS_BUm] = TRANS_FDm, |
| 296 | [_trans_BRr] = _trans_LDr, | 292 | [TRANS_BRr] = TRANS_LDr, |
| 297 | [_trans_BRm] = _trans_RDm, | 293 | [TRANS_BRm] = TRANS_RDm, |
| 298 | [_trans_BDr] = _trans_BDr, | 294 | [TRANS_BDr] = TRANS_BDr, |
| 299 | [_trans_BDm] = _trans_BDm, | 295 | [TRANS_BDm] = TRANS_BDm, |
| 300 | [_trans_BLr] = _trans_RDr, | 296 | [TRANS_BLr] = TRANS_RDr, |
| 301 | [_trans_BLm] = _trans_LDm, | 297 | [TRANS_BLm] = TRANS_LDm, |
| 302 | }; | 298 | }; |
diff --git a/src/utils/dbg_log.h b/src/utils/dbg_log.h index 427eceb..f9b1d8a 100644 --- a/src/utils/dbg_log.h +++ b/src/utils/dbg_log.h | |||
| @@ -3,14 +3,14 @@ void (*nissy_log)(const char *, ...); | |||
| 3 | #define LOG(...) if (nissy_log != NULL) nissy_log(__VA_ARGS__); | 3 | #define LOG(...) if (nissy_log != NULL) nissy_log(__VA_ARGS__); |
| 4 | 4 | ||
| 5 | #ifdef DEBUG | 5 | #ifdef DEBUG |
| 6 | #define _static | 6 | #define STATIC |
| 7 | #define _static_inline | 7 | #define STATIC_INLINE |
| 8 | #define DBG_WARN(condition, ...) if (!(condition)) LOG(__VA_ARGS__); | 8 | #define DBG_WARN(condition, ...) if (!(condition)) LOG(__VA_ARGS__); |
| 9 | #define DBG_ASSERT(condition, retval, ...) \ | 9 | #define DBG_ASSERT(condition, retval, ...) \ |
| 10 | if (!(condition)) { LOG(__VA_ARGS__); return retval; } | 10 | if (!(condition)) { LOG(__VA_ARGS__); return retval; } |
| 11 | #else | 11 | #else |
| 12 | #define _static static | 12 | #define STATIC static |
| 13 | #define _static_inline static inline | 13 | #define STATIC_INLINE static inline |
| 14 | #define DBG_WARN(condition, ...) | 14 | #define DBG_WARN(condition, ...) |
| 15 | #define DBG_ASSERT(condition, retval, ...) | 15 | #define DBG_ASSERT(condition, retval, ...) |
| 16 | #endif | 16 | #endif |
diff --git a/src/utils/math.h b/src/utils/math.h index a361808..e6c2589 100644 --- a/src/utils/math.h +++ b/src/utils/math.h | |||
| @@ -3,22 +3,22 @@ | |||
| 3 | #define _max(x, y) ((x) > (y) ? (x) : (y)) | 3 | #define _max(x, y) ((x) > (y) ? (x) : (y)) |
| 4 | #define _div_round_up(n, d) (((n) + (d) - 1) / (d)) | 4 | #define _div_round_up(n, d) (((n) + (d) - 1) / (d)) |
| 5 | 5 | ||
| 6 | _static int64_t factorial(int64_t); | 6 | STATIC int64_t factorial(int64_t); |
| 7 | _static bool isperm(uint8_t *, int64_t); | 7 | STATIC bool isperm(uint8_t *, int64_t); |
| 8 | _static int64_t permtoindex(uint8_t *, int64_t); | 8 | STATIC int64_t permtoindex(uint8_t *, int64_t); |
| 9 | _static void indextoperm(int64_t, int64_t, uint8_t *); | 9 | STATIC void indextoperm(int64_t, int64_t, uint8_t *); |
| 10 | _static int permsign(uint8_t *, int64_t); | 10 | STATIC int permsign(uint8_t *, int64_t); |
| 11 | _static int64_t digitstosumzero(uint8_t *, uint8_t, uint8_t); | 11 | STATIC int64_t digitstosumzero(uint8_t *, uint8_t, uint8_t); |
| 12 | _static void sumzerotodigits(int64_t, uint8_t, uint8_t, uint8_t *); | 12 | STATIC void sumzerotodigits(int64_t, uint8_t, uint8_t, uint8_t *); |
| 13 | 13 | ||
| 14 | _static int64_t | 14 | STATIC int64_t |
| 15 | factorial(int64_t n) | 15 | factorial(int64_t n) |
| 16 | { | 16 | { |
| 17 | int64_t i, ret; | 17 | int64_t i, ret; |
| 18 | 18 | ||
| 19 | if (n > _max_factorial) { | 19 | if (n > FACTORIAL_MAX) { |
| 20 | LOG("Error: won't compute factorial for n=%" PRId64 " because" | 20 | LOG("Error: won't compute factorial for n=%" PRId64 " because" |
| 21 | " it is larger than %" PRId64 "\n", n, _max_factorial); | 21 | " it is larger than %" PRId64 "\n", n, FACTORIAL_MAX); |
| 22 | return -1; | 22 | return -1; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| @@ -31,15 +31,15 @@ factorial(int64_t n) | |||
| 31 | return ret; | 31 | return ret; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | _static bool | 34 | STATIC bool |
| 35 | isperm(uint8_t *a, int64_t n) | 35 | isperm(uint8_t *a, int64_t n) |
| 36 | { | 36 | { |
| 37 | int64_t i; | 37 | int64_t i; |
| 38 | bool aux[_max_factorial+1]; | 38 | bool aux[FACTORIAL_MAX+1]; |
| 39 | 39 | ||
| 40 | if (n > _max_factorial) { | 40 | if (n > FACTORIAL_MAX) { |
| 41 | LOG("Error: won't compute 'isperm()' for n=%" PRId64 " because" | 41 | LOG("Error: won't compute 'isperm()' for n=%" PRId64 " because" |
| 42 | " it is larger than %" PRId64 "\n", n, _max_factorial); | 42 | " it is larger than %" PRId64 "\n", n, FACTORIAL_MAX); |
| 43 | return false; | 43 | return false; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| @@ -59,15 +59,15 @@ isperm(uint8_t *a, int64_t n) | |||
| 59 | return true; | 59 | return true; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | _static int64_t | 62 | STATIC int64_t |
| 63 | permtoindex(uint8_t *a, int64_t n) | 63 | permtoindex(uint8_t *a, int64_t n) |
| 64 | { | 64 | { |
| 65 | int64_t i, j, c, ret; | 65 | int64_t i, j, c, ret; |
| 66 | 66 | ||
| 67 | if (n > _max_factorial) { | 67 | if (n > FACTORIAL_MAX) { |
| 68 | LOG("Error: won't compute 'permtoindex()' for n=%" PRId64 | 68 | LOG("Error: won't compute 'permtoindex()' for n=%" PRId64 |
| 69 | " because it is larger than %" PRId64 "\n", | 69 | " because it is larger than %" PRId64 "\n", |
| 70 | n, _max_factorial); | 70 | n, FACTORIAL_MAX); |
| 71 | return -1; | 71 | return -1; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| @@ -83,16 +83,16 @@ permtoindex(uint8_t *a, int64_t n) | |||
| 83 | return ret; | 83 | return ret; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | _static void | 86 | STATIC void |
| 87 | indextoperm(int64_t p, int64_t n, uint8_t *r) | 87 | indextoperm(int64_t p, int64_t n, uint8_t *r) |
| 88 | { | 88 | { |
| 89 | int64_t i, j, c; | 89 | int64_t i, j, c; |
| 90 | uint8_t a[_max_factorial+1]; | 90 | uint8_t a[FACTORIAL_MAX+1]; |
| 91 | 91 | ||
| 92 | if (n > _max_factorial) { | 92 | if (n > FACTORIAL_MAX) { |
| 93 | LOG("Error: won't compute 'permtoindex()' for n=%" PRId64 | 93 | LOG("Error: won't compute 'permtoindex()' for n=%" PRId64 |
| 94 | " because it is larger than %" PRId64 "\n", | 94 | " because it is larger than %" PRId64 "\n", |
| 95 | n, _max_factorial); | 95 | n, FACTORIAL_MAX); |
| 96 | goto indextoperm_error; | 96 | goto indextoperm_error; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| @@ -115,10 +115,10 @@ indextoperm(int64_t p, int64_t n, uint8_t *r) | |||
| 115 | return; | 115 | return; |
| 116 | 116 | ||
| 117 | indextoperm_error: | 117 | indextoperm_error: |
| 118 | memset(r, _error, n); | 118 | memset(r, UINT8_ERROR, n); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | _static int | 121 | STATIC int |
| 122 | permsign(uint8_t *a, int64_t n) | 122 | permsign(uint8_t *a, int64_t n) |
| 123 | { | 123 | { |
| 124 | int i, j; | 124 | int i, j; |
| @@ -131,7 +131,7 @@ permsign(uint8_t *a, int64_t n) | |||
| 131 | return ret % 2; | 131 | return ret % 2; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | _static int64_t | 134 | STATIC int64_t |
| 135 | digitstosumzero(uint8_t *a, uint8_t n, uint8_t b) | 135 | digitstosumzero(uint8_t *a, uint8_t n, uint8_t b) |
| 136 | { | 136 | { |
| 137 | int64_t ret, p; | 137 | int64_t ret, p; |
| @@ -161,7 +161,7 @@ digitstosumzero(uint8_t *a, uint8_t n, uint8_t b) | |||
| 161 | return ret; | 161 | return ret; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | _static void | 164 | STATIC void |
| 165 | sumzerotodigits(int64_t d, uint8_t n, uint8_t b, uint8_t *a) | 165 | sumzerotodigits(int64_t d, uint8_t n, uint8_t b, uint8_t *a) |
| 166 | { | 166 | { |
| 167 | uint8_t sum; | 167 | uint8_t sum; |
| @@ -182,5 +182,5 @@ sumzerotodigits(int64_t d, uint8_t n, uint8_t b, uint8_t *a) | |||
| 182 | return; | 182 | return; |
| 183 | 183 | ||
| 184 | digitstosumzero_error: | 184 | digitstosumzero_error: |
| 185 | memset(a, _error, n); | 185 | memset(a, UINT8_ERROR, n); |
| 186 | } | 186 | } |
