2 * Greg Cook, 23/Feb/2019
5 /* CRC RevEng: arbitrary-precision CRC calculator and algorithm finder
6 * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
9 * This file is part of CRC RevEng.
11 * CRC RevEng is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * CRC RevEng is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with CRC RevEng. If not, see <https://www.gnu.org/licenses/>.
39 #if (defined BMPTST) || (BMP_BIT < 32)
40 /* Size in bits of a bmp_t. Not necessarily a power of two. */
43 /* The highest power of two that is strictly less than BMP_BIT.
44 * Initialises the index of a binary search for set bits in a bmp_t.
45 * (Computed correctly for BMP_BIT >= 2)
51 /* Initialise BMP_BIT and BMP_SUB for the local architecture. */
52 bmp_t bmpmax
= ~(bmp_t
) 0;
62 while ((bmpsub
| (bmpsub
- 1)) < bmpbit
- 1)
69 main(int argc
, char *argv
[]) {
70 /* check the compile-time bitmap width is correct, otherwise
71 * searches run forever. */
74 if (BMP_BIT
!= bmpbit
|| BMP_SUB
!= bmpsub
) {
75 fprintf(stderr
, "reveng: configuration fault. Update "
76 "reveng/config.h with these definitions and "
78 "\t#define BMP_BIT %d\n"
79 "\t#define BMP_SUB %d\n",
83 # endif /* BMP_BIT > 0 */
84 /* check the bitmap constant macro */
85 if (~(bmp_t
) 0 != ~BMP_C(0)) {
86 fprintf(stderr
, "reveng: configuration fault. Edit "
87 "the definition of BMP_C() in config.h to "
88 "match BMP_T and recompile.\n");