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