|
52 | 52 | namespace abc::exorcism {
|
53 | 53 |
|
54 | 54 | ////////////////////////////////////////////////////////////////////////
|
55 |
| -/// MACRO DEFINITIONS /// |
| 55 | +/// CONSTANT DEFINITIONS /// |
56 | 56 | ////////////////////////////////////////////////////////////////////////
|
57 | 57 |
|
58 |
| -// the number of bits per integer (can be 16, 32, 64 - tested for 32) |
59 |
| -#define BPI 32 |
60 |
| -#define BPIMASK 31 |
61 |
| -#define LOGBPI 5 |
| 58 | +// the number of bits per integer |
| 59 | +constexpr int BPI = 32; |
| 60 | +constexpr int BPIMASK = 31; |
| 61 | +constexpr int LOGBPI = 5; |
62 | 62 |
|
63 | 63 | // the maximum number of input variables
|
64 |
| -#define MAXVARS 1000 |
| 64 | +constexpr int MAXVARS = 1000; |
65 | 65 |
|
66 | 66 | // the number of cubes that are allocated additionally
|
67 |
| -#define ADDITIONAL_CUBES 33 |
| 67 | +constexpr int ADDITIONAL_CUBES = 33; |
68 | 68 |
|
69 | 69 | // the factor showing how many cube pairs will be allocated
|
70 |
| -#define CUBE_PAIR_FACTOR 20 |
| 70 | +constexpr int CUBE_PAIR_FACTOR = 20; |
71 | 71 | // the following number of cube pairs are allocated:
|
72 | 72 | // nCubesAlloc/CUBE_PAIR_FACTOR
|
73 | 73 |
|
74 |
| -#if BPI == 64 |
75 |
| -#define DIFFERENT 0x5555555555555555 |
76 |
| -#define BIT_COUNT(w) (BitCount[(w)&0xffff] + BitCount[((w)>>16)&0xffff] + BitCount[((w)>>32)&0xffff] + BitCount[(w)>>48]) |
77 |
| -#elif BPI == 32 |
78 |
| -#define DIFFERENT 0x55555555 |
79 |
| -#define BIT_COUNT(w) (BitCount[(w)&0xffff] + BitCount[(w)>>16]) |
80 |
| -#else |
81 |
| -#define DIFFERENT 0x5555 |
82 |
| -#define BIT_COUNT(w) (BitCount[(w)]) |
83 |
| -#endif |
| 74 | +constexpr int DIFFERENT = 0x55555555; |
84 | 75 |
|
| 76 | +extern unsigned char BitCount[0x10000]; |
85 | 77 |
|
86 |
| -#define VarWord(element) ((element)>>LOGBPI) |
87 |
| -#define VarBit(element) ((element)&BPIMASK) |
| 78 | +static inline int BIT_COUNT(int w) { |
| 79 | + return BitCount[(w)&0xffff] + BitCount[(w)>>16]; |
| 80 | +} |
88 | 81 |
|
89 |
| -#define TICKS_TO_SECONDS(time) ((float)(time)/(float)(CLOCKS_PER_SEC)) |
| 82 | +static inline int VarWord(int element) { |
| 83 | + return element >> LOGBPI; |
| 84 | +} |
| 85 | +static inline int VarBit(int element) { |
| 86 | + return element & BPIMASK; |
| 87 | +} |
| 88 | + |
| 89 | +static inline int TICKS_TO_SECONDS(abctime time) { |
| 90 | + return (float)(time)/(float)(CLOCKS_PER_SEC); |
| 91 | +} |
90 | 92 |
|
91 | 93 | ////////////////////////////////////////////////////////////////////////
|
92 | 94 | /// CUBE COVER and CUBE typedefs ///
|
|
0 commit comments