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/utils/constants.h | 526 +++++++++++++++++++++++++------------------------- src/utils/dbg_log.h | 8 +- src/utils/math.h | 54 +++--- 3 files changed, 292 insertions(+), 296 deletions(-) (limited to 'src/utils') 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 @@ -#define _bit_u8(i) (UINT8_C(1) << (uint8_t)(i)) -#define _bit_u32(i) (UINT32_C(1) << (uint32_t)(i)) -#define _bit_u64(i) (UINT64_C(1) << (uint64_t)(i)) +#define UINT32_BIT(i) (UINT32_C(1) << (uint32_t)(i)) -#define _max_factorial INT64_C(12) +#define FACTORIAL_MAX INT64_C(12) -#define _2p11 INT64_C(2048) -#define _2p12 INT64_C(4096) -#define _3p7 INT64_C(2187) -#define _3p8 INT64_C(6561) -#define _12f INT64_C(479001600) -#define _8f INT64_C(40320) -#define _12c4 INT64_C(495) -#define _8c4 INT64_C(70) +#define POW_2_11 INT64_C(2048) +#define POW_3_7 INT64_C(2187) +#define FACT_12 INT64_C(479001600) +#define FACT_8 INT64_C(40320) +#define COMB_12_4 INT64_C(495) +#define COMB_8_4 INT64_C(70) -_static int64_t binomial[12][12] = { +STATIC int64_t binomial[12][12] = { {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -28,275 +24,275 @@ _static int64_t binomial[12][12] = { {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1}, }; -#define _move_U UINT8_C(0) -#define _move_U2 UINT8_C(1) -#define _move_U3 UINT8_C(2) -#define _move_D UINT8_C(3) -#define _move_D2 UINT8_C(4) -#define _move_D3 UINT8_C(5) -#define _move_R UINT8_C(6) -#define _move_R2 UINT8_C(7) -#define _move_R3 UINT8_C(8) -#define _move_L UINT8_C(9) -#define _move_L2 UINT8_C(10) -#define _move_L3 UINT8_C(11) -#define _move_F UINT8_C(12) -#define _move_F2 UINT8_C(13) -#define _move_F3 UINT8_C(14) -#define _move_B UINT8_C(15) -#define _move_B2 UINT8_C(16) -#define _move_B3 UINT8_C(17) +#define MOVE_U UINT8_C(0) +#define MOVE_U2 UINT8_C(1) +#define MOVE_U3 UINT8_C(2) +#define MOVE_D UINT8_C(3) +#define MOVE_D2 UINT8_C(4) +#define MOVE_D3 UINT8_C(5) +#define MOVE_R UINT8_C(6) +#define MOVE_R2 UINT8_C(7) +#define MOVE_R3 UINT8_C(8) +#define MOVE_L UINT8_C(9) +#define MOVE_L2 UINT8_C(10) +#define MOVE_L3 UINT8_C(11) +#define MOVE_F UINT8_C(12) +#define MOVE_F2 UINT8_C(13) +#define MOVE_F3 UINT8_C(14) +#define MOVE_B UINT8_C(15) +#define MOVE_B2 UINT8_C(16) +#define MOVE_B3 UINT8_C(17) -#define _trans_UFr UINT8_C(0) -#define _trans_ULr UINT8_C(1) -#define _trans_UBr UINT8_C(2) -#define _trans_URr UINT8_C(3) -#define _trans_DFr UINT8_C(4) -#define _trans_DLr UINT8_C(5) -#define _trans_DBr UINT8_C(6) -#define _trans_DRr UINT8_C(7) -#define _trans_RUr UINT8_C(8) -#define _trans_RFr UINT8_C(9) -#define _trans_RDr UINT8_C(10) -#define _trans_RBr UINT8_C(11) -#define _trans_LUr UINT8_C(12) -#define _trans_LFr UINT8_C(13) -#define _trans_LDr UINT8_C(14) -#define _trans_LBr UINT8_C(15) -#define _trans_FUr UINT8_C(16) -#define _trans_FRr UINT8_C(17) -#define _trans_FDr UINT8_C(18) -#define _trans_FLr UINT8_C(19) -#define _trans_BUr UINT8_C(20) -#define _trans_BRr UINT8_C(21) -#define _trans_BDr UINT8_C(22) -#define _trans_BLr UINT8_C(23) +#define TRANS_UFr UINT8_C(0) +#define TRANS_ULr UINT8_C(1) +#define TRANS_UBr UINT8_C(2) +#define TRANS_URr UINT8_C(3) +#define TRANS_DFr UINT8_C(4) +#define TRANS_DLr UINT8_C(5) +#define TRANS_DBr UINT8_C(6) +#define TRANS_DRr UINT8_C(7) +#define TRANS_RUr UINT8_C(8) +#define TRANS_RFr UINT8_C(9) +#define TRANS_RDr UINT8_C(10) +#define TRANS_RBr UINT8_C(11) +#define TRANS_LUr UINT8_C(12) +#define TRANS_LFr UINT8_C(13) +#define TRANS_LDr UINT8_C(14) +#define TRANS_LBr UINT8_C(15) +#define TRANS_FUr UINT8_C(16) +#define TRANS_FRr UINT8_C(17) +#define TRANS_FDr UINT8_C(18) +#define TRANS_FLr UINT8_C(19) +#define TRANS_BUr UINT8_C(20) +#define TRANS_BRr UINT8_C(21) +#define TRANS_BDr UINT8_C(22) +#define TRANS_BLr UINT8_C(23) -#define _trans_UFm UINT8_C(24) -#define _trans_ULm UINT8_C(25) -#define _trans_UBm UINT8_C(26) -#define _trans_URm UINT8_C(27) -#define _trans_DFm UINT8_C(28) -#define _trans_DLm UINT8_C(29) -#define _trans_DBm UINT8_C(30) -#define _trans_DRm UINT8_C(31) -#define _trans_RUm UINT8_C(32) -#define _trans_RFm UINT8_C(33) -#define _trans_RDm UINT8_C(34) -#define _trans_RBm UINT8_C(35) -#define _trans_LUm UINT8_C(36) -#define _trans_LFm UINT8_C(37) -#define _trans_LDm UINT8_C(38) -#define _trans_LBm UINT8_C(39) -#define _trans_FUm UINT8_C(40) -#define _trans_FRm UINT8_C(41) -#define _trans_FDm UINT8_C(42) -#define _trans_FLm UINT8_C(43) -#define _trans_BUm UINT8_C(44) -#define _trans_BRm UINT8_C(45) -#define _trans_BDm UINT8_C(46) -#define _trans_BLm UINT8_C(47) +#define TRANS_UFm UINT8_C(24) +#define TRANS_ULm UINT8_C(25) +#define TRANS_UBm UINT8_C(26) +#define TRANS_URm UINT8_C(27) +#define TRANS_DFm UINT8_C(28) +#define TRANS_DLm UINT8_C(29) +#define TRANS_DBm UINT8_C(30) +#define TRANS_DRm UINT8_C(31) +#define TRANS_RUm UINT8_C(32) +#define TRANS_RFm UINT8_C(33) +#define TRANS_RDm UINT8_C(34) +#define TRANS_RBm UINT8_C(35) +#define TRANS_LUm UINT8_C(36) +#define TRANS_LFm UINT8_C(37) +#define TRANS_LDm UINT8_C(38) +#define TRANS_LBm UINT8_C(39) +#define TRANS_FUm UINT8_C(40) +#define TRANS_FRm UINT8_C(41) +#define TRANS_FDm UINT8_C(42) +#define TRANS_FLm UINT8_C(43) +#define TRANS_BUm UINT8_C(44) +#define TRANS_BRm UINT8_C(45) +#define TRANS_BDm UINT8_C(46) +#define TRANS_BLm UINT8_C(47) -#define _mm_normal UINT32_C(0x00) -#define _mm_inverse UINT32_C(0x01) -#define _mm_inversebranch UINT32_C(0x03) -#define _mm_normalbranch UINT32_C(0x02) -#define _mm_allmoves UINT32_C(0x3FFFF) -#define _mm_nohalfturns UINT32_C(0x2DB6D) +#define MM_NORMAL UINT32_C(0x00) +#define MM_INVERSE UINT32_C(0x01) +#define MM_INVERSEBRANCH UINT32_C(0x03) +#define MM_NORMALBRANCH UINT32_C(0x02) +#define MM_ALLMOVES UINT32_C(0x3FFFF) +#define MM_NOHALFTURNS UINT32_C(0x2DB6D) -#define _c_ufr UINT8_C(0) -#define _c_ubl UINT8_C(1) -#define _c_dfl UINT8_C(2) -#define _c_dbr UINT8_C(3) -#define _c_ufl UINT8_C(4) -#define _c_ubr UINT8_C(5) -#define _c_dfr UINT8_C(6) -#define _c_dbl UINT8_C(7) +#define CORNER_UFR UINT8_C(0) +#define CORNER_UBL UINT8_C(1) +#define CORNER_DFL UINT8_C(2) +#define CORNER_DBR UINT8_C(3) +#define CORNER_UFL UINT8_C(4) +#define CORNER_UBR UINT8_C(5) +#define CORNER_DFR UINT8_C(6) +#define CORNER_DBL UINT8_C(7) -#define _e_uf UINT8_C(0) -#define _e_ub UINT8_C(1) -#define _e_db UINT8_C(2) -#define _e_df UINT8_C(3) -#define _e_ur UINT8_C(4) -#define _e_ul UINT8_C(5) -#define _e_dl UINT8_C(6) -#define _e_dr UINT8_C(7) -#define _e_fr UINT8_C(8) -#define _e_fl UINT8_C(9) -#define _e_bl UINT8_C(10) -#define _e_br UINT8_C(11) +#define EDGE_UF UINT8_C(0) +#define EDGE_UB UINT8_C(1) +#define EDGE_DB UINT8_C(2) +#define EDGE_DF UINT8_C(3) +#define EDGE_UR UINT8_C(4) +#define EDGE_UL UINT8_C(5) +#define EDGE_DL UINT8_C(6) +#define EDGE_DR UINT8_C(7) +#define EDGE_FR UINT8_C(8) +#define EDGE_FL UINT8_C(9) +#define EDGE_BL UINT8_C(10) +#define EDGE_BR UINT8_C(11) -#define _eoshift UINT8_C(4) -#define _coshift UINT8_C(5) +#define EOSHIFT UINT8_C(4) +#define COSHIFT UINT8_C(5) -#define _pbits UINT8_C(0xF) -#define _esepbit1 UINT8_C(0x4) -#define _esepbit2 UINT8_C(0x8) -#define _csepbit UINT8_C(0x4) -#define _eobit UINT8_C(0x10) -#define _cobits UINT8_C(0xF0) -#define _cobits2 UINT8_C(0x60) -#define _ctwist_cw UINT8_C(0x20) -#define _ctwist_ccw UINT8_C(0x40) -#define _eflip UINT8_C(0x10) -#define _error UINT8_C(0xFF) +#define PBITS UINT8_C(0xF) +#define ESEPBIT_1 UINT8_C(0x4) +#define ESEPBIT_2 UINT8_C(0x8) +#define CSEPBIT UINT8_C(0x4) +#define EOBIT UINT8_C(0x10) +#define COBITS UINT8_C(0xF0) +#define COBITS_2 UINT8_C(0x60) +#define CTWIST_CW UINT8_C(0x20) +#define CTWIST_CCW UINT8_C(0x40) +#define EFLIP UINT8_C(0x10) +#define UINT8_ERROR UINT8_C(0xFF) -_static const char *cornerstr[] = { - [_c_ufr] = "UFR", - [_c_ubl] = "UBL", - [_c_dfl] = "DFL", - [_c_dbr] = "DBR", - [_c_ufl] = "UFL", - [_c_ubr] = "UBR", - [_c_dfr] = "DFR", - [_c_dbl] = "DBL" +STATIC const char *cornerstr[] = { + [CORNER_UFR] = "UFR", + [CORNER_UBL] = "UBL", + [CORNER_DFL] = "DFL", + [CORNER_DBR] = "DBR", + [CORNER_UFL] = "UFL", + [CORNER_UBR] = "UBR", + [CORNER_DFR] = "DFR", + [CORNER_DBL] = "DBL" }; -_static const char *cornerstralt[] = { - [_c_ufr] = "URF", - [_c_ubl] = "ULB", - [_c_dfl] = "DLF", - [_c_dbr] = "DRB", - [_c_ufl] = "ULF", - [_c_ubr] = "URB", - [_c_dfr] = "DRF", - [_c_dbl] = "DLB" +STATIC const char *cornerstralt[] = { + [CORNER_UFR] = "URF", + [CORNER_UBL] = "ULB", + [CORNER_DFL] = "DLF", + [CORNER_DBR] = "DRB", + [CORNER_UFL] = "ULF", + [CORNER_UBR] = "URB", + [CORNER_DFR] = "DRF", + [CORNER_DBL] = "DLB" }; -_static const char *edgestr[] = { - [_e_uf] = "UF", - [_e_ub] = "UB", - [_e_db] = "DB", - [_e_df] = "DF", - [_e_ur] = "UR", - [_e_ul] = "UL", - [_e_dl] = "DL", - [_e_dr] = "DR", - [_e_fr] = "FR", - [_e_fl] = "FL", - [_e_bl] = "BL", - [_e_br] = "BR" +STATIC const char *edgestr[] = { + [EDGE_UF] = "UF", + [EDGE_UB] = "UB", + [EDGE_DB] = "DB", + [EDGE_DF] = "DF", + [EDGE_UR] = "UR", + [EDGE_UL] = "UL", + [EDGE_DL] = "DL", + [EDGE_DR] = "DR", + [EDGE_FR] = "FR", + [EDGE_FL] = "FL", + [EDGE_BL] = "BL", + [EDGE_BR] = "BR" }; -_static const char *movestr[] = { - [_move_U] = "U", - [_move_U2] = "U2", - [_move_U3] = "U'", - [_move_D] = "D", - [_move_D2] = "D2", - [_move_D3] = "D'", - [_move_R] = "R", - [_move_R2] = "R2", - [_move_R3] = "R'", - [_move_L] = "L", - [_move_L2] = "L2", - [_move_L3] = "L'", - [_move_F] = "F", - [_move_F2] = "F2", - [_move_F3] = "F'", - [_move_B] = "B", - [_move_B2] = "B2", - [_move_B3] = "B'", +STATIC const char *movestr[] = { + [MOVE_U] = "U", + [MOVE_U2] = "U2", + [MOVE_U3] = "U'", + [MOVE_D] = "D", + [MOVE_D2] = "D2", + [MOVE_D3] = "D'", + [MOVE_R] = "R", + [MOVE_R2] = "R2", + [MOVE_R3] = "R'", + [MOVE_L] = "L", + [MOVE_L2] = "L2", + [MOVE_L3] = "L'", + [MOVE_F] = "F", + [MOVE_F2] = "F2", + [MOVE_F3] = "F'", + [MOVE_B] = "B", + [MOVE_B2] = "B2", + [MOVE_B3] = "B'", }; -_static const char *transstr[] = { - [_trans_UFr] = "rotation UF", - [_trans_UFm] = "mirrored UF", - [_trans_ULr] = "rotation UL", - [_trans_ULm] = "mirrored UL", - [_trans_UBr] = "rotation UB", - [_trans_UBm] = "mirrored UB", - [_trans_URr] = "rotation UR", - [_trans_URm] = "mirrored UR", - [_trans_DFr] = "rotation DF", - [_trans_DFm] = "mirrored DF", - [_trans_DLr] = "rotation DL", - [_trans_DLm] = "mirrored DL", - [_trans_DBr] = "rotation DB", - [_trans_DBm] = "mirrored DB", - [_trans_DRr] = "rotation DR", - [_trans_DRm] = "mirrored DR", - [_trans_RUr] = "rotation RU", - [_trans_RUm] = "mirrored RU", - [_trans_RFr] = "rotation RF", - [_trans_RFm] = "mirrored RF", - [_trans_RDr] = "rotation RD", - [_trans_RDm] = "mirrored RD", - [_trans_RBr] = "rotation RB", - [_trans_RBm] = "mirrored RB", - [_trans_LUr] = "rotation LU", - [_trans_LUm] = "mirrored LU", - [_trans_LFr] = "rotation LF", - [_trans_LFm] = "mirrored LF", - [_trans_LDr] = "rotation LD", - [_trans_LDm] = "mirrored LD", - [_trans_LBr] = "rotation LB", - [_trans_LBm] = "mirrored LB", - [_trans_FUr] = "rotation FU", - [_trans_FUm] = "mirrored FU", - [_trans_FRr] = "rotation FR", - [_trans_FRm] = "mirrored FR", - [_trans_FDr] = "rotation FD", - [_trans_FDm] = "mirrored FD", - [_trans_FLr] = "rotation FL", - [_trans_FLm] = "mirrored FL", - [_trans_BUr] = "rotation BU", - [_trans_BUm] = "mirrored BU", - [_trans_BRr] = "rotation BR", - [_trans_BRm] = "mirrored BR", - [_trans_BDr] = "rotation BD", - [_trans_BDm] = "mirrored BD", - [_trans_BLr] = "rotation BL", - [_trans_BLm] = "mirrored BL", +STATIC const char *transstr[] = { + [TRANS_UFr] = "rotation UF", + [TRANS_UFm] = "mirrored UF", + [TRANS_ULr] = "rotation UL", + [TRANS_ULm] = "mirrored UL", + [TRANS_UBr] = "rotation UB", + [TRANS_UBm] = "mirrored UB", + [TRANS_URr] = "rotation UR", + [TRANS_URm] = "mirrored UR", + [TRANS_DFr] = "rotation DF", + [TRANS_DFm] = "mirrored DF", + [TRANS_DLr] = "rotation DL", + [TRANS_DLm] = "mirrored DL", + [TRANS_DBr] = "rotation DB", + [TRANS_DBm] = "mirrored DB", + [TRANS_DRr] = "rotation DR", + [TRANS_DRm] = "mirrored DR", + [TRANS_RUr] = "rotation RU", + [TRANS_RUm] = "mirrored RU", + [TRANS_RFr] = "rotation RF", + [TRANS_RFm] = "mirrored RF", + [TRANS_RDr] = "rotation RD", + [TRANS_RDm] = "mirrored RD", + [TRANS_RBr] = "rotation RB", + [TRANS_RBm] = "mirrored RB", + [TRANS_LUr] = "rotation LU", + [TRANS_LUm] = "mirrored LU", + [TRANS_LFr] = "rotation LF", + [TRANS_LFm] = "mirrored LF", + [TRANS_LDr] = "rotation LD", + [TRANS_LDm] = "mirrored LD", + [TRANS_LBr] = "rotation LB", + [TRANS_LBm] = "mirrored LB", + [TRANS_FUr] = "rotation FU", + [TRANS_FUm] = "mirrored FU", + [TRANS_FRr] = "rotation FR", + [TRANS_FRm] = "mirrored FR", + [TRANS_FDr] = "rotation FD", + [TRANS_FDm] = "mirrored FD", + [TRANS_FLr] = "rotation FL", + [TRANS_FLm] = "mirrored FL", + [TRANS_BUr] = "rotation BU", + [TRANS_BUm] = "mirrored BU", + [TRANS_BRr] = "rotation BR", + [TRANS_BRm] = "mirrored BR", + [TRANS_BDr] = "rotation BD", + [TRANS_BDm] = "mirrored BD", + [TRANS_BLr] = "rotation BL", + [TRANS_BLm] = "mirrored BL", }; static uint8_t inverse_trans_table[48] = { - [_trans_UFr] = _trans_UFr, - [_trans_UFm] = _trans_UFm, - [_trans_ULr] = _trans_URr, - [_trans_ULm] = _trans_ULm, - [_trans_UBr] = _trans_UBr, - [_trans_UBm] = _trans_UBm, - [_trans_URr] = _trans_ULr, - [_trans_URm] = _trans_URm, - [_trans_DFr] = _trans_DFr, - [_trans_DFm] = _trans_DFm, - [_trans_DLr] = _trans_DLr, - [_trans_DLm] = _trans_DRm, - [_trans_DBr] = _trans_DBr, - [_trans_DBm] = _trans_DBm, - [_trans_DRr] = _trans_DRr, - [_trans_DRm] = _trans_DLm, - [_trans_RUr] = _trans_FRr, - [_trans_RUm] = _trans_FLm, - [_trans_RFr] = _trans_LFr, - [_trans_RFm] = _trans_RFm, - [_trans_RDr] = _trans_BLr, - [_trans_RDm] = _trans_BRm, - [_trans_RBr] = _trans_RBr, - [_trans_RBm] = _trans_LBm, - [_trans_LUr] = _trans_FLr, - [_trans_LUm] = _trans_FRm, - [_trans_LFr] = _trans_RFr, - [_trans_LFm] = _trans_LFm, - [_trans_LDr] = _trans_BRr, - [_trans_LDm] = _trans_BLm, - [_trans_LBr] = _trans_LBr, - [_trans_LBm] = _trans_RBm, - [_trans_FUr] = _trans_FUr, - [_trans_FUm] = _trans_FUm, - [_trans_FRr] = _trans_RUr, - [_trans_FRm] = _trans_LUm, - [_trans_FDr] = _trans_BUr, - [_trans_FDm] = _trans_BUm, - [_trans_FLr] = _trans_LUr, - [_trans_FLm] = _trans_RUm, - [_trans_BUr] = _trans_FDr, - [_trans_BUm] = _trans_FDm, - [_trans_BRr] = _trans_LDr, - [_trans_BRm] = _trans_RDm, - [_trans_BDr] = _trans_BDr, - [_trans_BDm] = _trans_BDm, - [_trans_BLr] = _trans_RDr, - [_trans_BLm] = _trans_LDm, + [TRANS_UFr] = TRANS_UFr, + [TRANS_UFm] = TRANS_UFm, + [TRANS_ULr] = TRANS_URr, + [TRANS_ULm] = TRANS_ULm, + [TRANS_UBr] = TRANS_UBr, + [TRANS_UBm] = TRANS_UBm, + [TRANS_URr] = TRANS_ULr, + [TRANS_URm] = TRANS_URm, + [TRANS_DFr] = TRANS_DFr, + [TRANS_DFm] = TRANS_DFm, + [TRANS_DLr] = TRANS_DLr, + [TRANS_DLm] = TRANS_DRm, + [TRANS_DBr] = TRANS_DBr, + [TRANS_DBm] = TRANS_DBm, + [TRANS_DRr] = TRANS_DRr, + [TRANS_DRm] = TRANS_DLm, + [TRANS_RUr] = TRANS_FRr, + [TRANS_RUm] = TRANS_FLm, + [TRANS_RFr] = TRANS_LFr, + [TRANS_RFm] = TRANS_RFm, + [TRANS_RDr] = TRANS_BLr, + [TRANS_RDm] = TRANS_BRm, + [TRANS_RBr] = TRANS_RBr, + [TRANS_RBm] = TRANS_LBm, + [TRANS_LUr] = TRANS_FLr, + [TRANS_LUm] = TRANS_FRm, + [TRANS_LFr] = TRANS_RFr, + [TRANS_LFm] = TRANS_LFm, + [TRANS_LDr] = TRANS_BRr, + [TRANS_LDm] = TRANS_BLm, + [TRANS_LBr] = TRANS_LBr, + [TRANS_LBm] = TRANS_RBm, + [TRANS_FUr] = TRANS_FUr, + [TRANS_FUm] = TRANS_FUm, + [TRANS_FRr] = TRANS_RUr, + [TRANS_FRm] = TRANS_LUm, + [TRANS_FDr] = TRANS_BUr, + [TRANS_FDm] = TRANS_BUm, + [TRANS_FLr] = TRANS_LUr, + [TRANS_FLm] = TRANS_RUm, + [TRANS_BUr] = TRANS_FDr, + [TRANS_BUm] = TRANS_FDm, + [TRANS_BRr] = TRANS_LDr, + [TRANS_BRm] = TRANS_RDm, + [TRANS_BDr] = TRANS_BDr, + [TRANS_BDm] = TRANS_BDm, + [TRANS_BLr] = TRANS_RDr, + [TRANS_BLm] = TRANS_LDm, }; 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 *, ...); #define LOG(...) if (nissy_log != NULL) nissy_log(__VA_ARGS__); #ifdef DEBUG -#define _static -#define _static_inline +#define STATIC +#define STATIC_INLINE #define DBG_WARN(condition, ...) if (!(condition)) LOG(__VA_ARGS__); #define DBG_ASSERT(condition, retval, ...) \ if (!(condition)) { LOG(__VA_ARGS__); return retval; } #else -#define _static static -#define _static_inline static inline +#define STATIC static +#define STATIC_INLINE static inline #define DBG_WARN(condition, ...) #define DBG_ASSERT(condition, retval, ...) #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 @@ #define _max(x, y) ((x) > (y) ? (x) : (y)) #define _div_round_up(n, d) (((n) + (d) - 1) / (d)) -_static int64_t factorial(int64_t); -_static bool isperm(uint8_t *, int64_t); -_static int64_t permtoindex(uint8_t *, int64_t); -_static void indextoperm(int64_t, int64_t, uint8_t *); -_static int permsign(uint8_t *, int64_t); -_static int64_t digitstosumzero(uint8_t *, uint8_t, uint8_t); -_static void sumzerotodigits(int64_t, uint8_t, uint8_t, uint8_t *); - -_static int64_t +STATIC int64_t factorial(int64_t); +STATIC bool isperm(uint8_t *, int64_t); +STATIC int64_t permtoindex(uint8_t *, int64_t); +STATIC void indextoperm(int64_t, int64_t, uint8_t *); +STATIC int permsign(uint8_t *, int64_t); +STATIC int64_t digitstosumzero(uint8_t *, uint8_t, uint8_t); +STATIC void sumzerotodigits(int64_t, uint8_t, uint8_t, uint8_t *); + +STATIC int64_t factorial(int64_t n) { int64_t i, ret; - if (n > _max_factorial) { + if (n > FACTORIAL_MAX) { LOG("Error: won't compute factorial for n=%" PRId64 " because" - " it is larger than %" PRId64 "\n", n, _max_factorial); + " it is larger than %" PRId64 "\n", n, FACTORIAL_MAX); return -1; } @@ -31,15 +31,15 @@ factorial(int64_t n) return ret; } -_static bool +STATIC bool isperm(uint8_t *a, int64_t n) { int64_t i; - bool aux[_max_factorial+1]; + bool aux[FACTORIAL_MAX+1]; - if (n > _max_factorial) { + if (n > FACTORIAL_MAX) { LOG("Error: won't compute 'isperm()' for n=%" PRId64 " because" - " it is larger than %" PRId64 "\n", n, _max_factorial); + " it is larger than %" PRId64 "\n", n, FACTORIAL_MAX); return false; } @@ -59,15 +59,15 @@ isperm(uint8_t *a, int64_t n) return true; } -_static int64_t +STATIC int64_t permtoindex(uint8_t *a, int64_t n) { int64_t i, j, c, ret; - if (n > _max_factorial) { + if (n > FACTORIAL_MAX) { LOG("Error: won't compute 'permtoindex()' for n=%" PRId64 " because it is larger than %" PRId64 "\n", - n, _max_factorial); + n, FACTORIAL_MAX); return -1; } @@ -83,16 +83,16 @@ permtoindex(uint8_t *a, int64_t n) return ret; } -_static void +STATIC void indextoperm(int64_t p, int64_t n, uint8_t *r) { int64_t i, j, c; - uint8_t a[_max_factorial+1]; + uint8_t a[FACTORIAL_MAX+1]; - if (n > _max_factorial) { + if (n > FACTORIAL_MAX) { LOG("Error: won't compute 'permtoindex()' for n=%" PRId64 " because it is larger than %" PRId64 "\n", - n, _max_factorial); + n, FACTORIAL_MAX); goto indextoperm_error; } @@ -115,10 +115,10 @@ indextoperm(int64_t p, int64_t n, uint8_t *r) return; indextoperm_error: - memset(r, _error, n); + memset(r, UINT8_ERROR, n); } -_static int +STATIC int permsign(uint8_t *a, int64_t n) { int i, j; @@ -131,7 +131,7 @@ permsign(uint8_t *a, int64_t n) return ret % 2; } -_static int64_t +STATIC int64_t digitstosumzero(uint8_t *a, uint8_t n, uint8_t b) { int64_t ret, p; @@ -161,7 +161,7 @@ digitstosumzero(uint8_t *a, uint8_t n, uint8_t b) return ret; } -_static void +STATIC void sumzerotodigits(int64_t d, uint8_t n, uint8_t b, uint8_t *a) { uint8_t sum; @@ -182,5 +182,5 @@ sumzerotodigits(int64_t d, uint8_t n, uint8_t b, uint8_t *a) return; digitstosumzero_error: - memset(a, _error, n); + memset(a, UINT8_ERROR, n); } -- cgit v1.3