Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
libs/checksumm.h@3:f151d08d335c, 2014-03-02 (annotated)
- Committer:
- Bigcheese
- Date:
- Sun Mar 02 06:33:08 2014 +0000
- Revision:
- 3:f151d08d335c
- Parent:
- 2:1df0b61d3b5a
Bunch of stuff. Need to locally merge in updated USB changes.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Michael J. Spencer |
2:1df0b61d3b5a | 1 | /* |
Michael J. Spencer |
2:1df0b61d3b5a | 2 | This file is part of Smoothie (http://smoothieware.org/) |
Michael J. Spencer |
2:1df0b61d3b5a | 3 | The motion control part is heavily based on Grbl (https://github.com/simen/grbl) |
Michael J. Spencer |
2:1df0b61d3b5a | 4 | |
Michael J. Spencer |
2:1df0b61d3b5a | 5 | Smoothie is free software: you can redistribute it and/or modify it under |
Michael J. Spencer |
2:1df0b61d3b5a | 6 | the terms of the GNU General Public License as published by the Free |
Michael J. Spencer |
2:1df0b61d3b5a | 7 | Software Foundation, either version 3 of the License, or (at your option) |
Michael J. Spencer |
2:1df0b61d3b5a | 8 | any later version. |
Michael J. Spencer |
2:1df0b61d3b5a | 9 | |
Michael J. Spencer |
2:1df0b61d3b5a | 10 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY |
Michael J. Spencer |
2:1df0b61d3b5a | 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
Michael J. Spencer |
2:1df0b61d3b5a | 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
Michael J. Spencer |
2:1df0b61d3b5a | 13 | details. |
Michael J. Spencer |
2:1df0b61d3b5a | 14 | |
Michael J. Spencer |
2:1df0b61d3b5a | 15 | You should have received a copy of the GNU General Public License along |
Michael J. Spencer |
2:1df0b61d3b5a | 16 | with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
Michael J. Spencer |
2:1df0b61d3b5a | 17 | */ |
Michael J. Spencer |
2:1df0b61d3b5a | 18 | /* Calculates Fletcher Checksum at compile time using recursive macros. */ |
Michael J. Spencer |
2:1df0b61d3b5a | 19 | #ifndef _CHECKSUM_MACRO_H_ |
Michael J. Spencer |
2:1df0b61d3b5a | 20 | #define _CHECKSUM_MACRO_H_ |
Michael J. Spencer |
2:1df0b61d3b5a | 21 | |
Michael J. Spencer |
2:1df0b61d3b5a | 22 | /* There are two compile time checksumming approaches in this file. One uses |
Michael J. Spencer |
2:1df0b61d3b5a | 23 | the C preprocessor and the other uses new C++11 features. They should both |
Michael J. Spencer |
2:1df0b61d3b5a | 24 | do the same thing but my current compiler, GCC 4.7, doesn't always do the |
Michael J. Spencer |
2:1df0b61d3b5a | 25 | constant folding for the C++ approach and this causes code bloat. The C |
Michael J. Spencer |
2:1df0b61d3b5a | 26 | preprocessor approach can currently generate the exact same code in |
Michael J. Spencer |
2:1df0b61d3b5a | 27 | Checked/Release builds as the old method of pre-calculating checksums by |
Michael J. Spencer |
2:1df0b61d3b5a | 28 | hand and pasting them into the code. |
Michael J. Spencer |
2:1df0b61d3b5a | 29 | |
Michael J. Spencer |
2:1df0b61d3b5a | 30 | Keeping both versions here: the active C version and the C++ version |
Michael J. Spencer |
2:1df0b61d3b5a | 31 | that we should switch to later if newer compilers do the required constant |
Michael J. Spencer |
2:1df0b61d3b5a | 32 | folding (maybe there are optimization flags to help here.) |
Michael J. Spencer |
2:1df0b61d3b5a | 33 | */ |
Michael J. Spencer |
2:1df0b61d3b5a | 34 | #ifdef CHECKSUM_USE_CPP |
Michael J. Spencer |
2:1df0b61d3b5a | 35 | |
Michael J. Spencer |
2:1df0b61d3b5a | 36 | #include <type_traits> |
Michael J. Spencer |
2:1df0b61d3b5a | 37 | |
Michael J. Spencer |
2:1df0b61d3b5a | 38 | /* Cool C++11 approach contributed by bgamari on #smoothieware IRC channel. |
Michael J. Spencer |
2:1df0b61d3b5a | 39 | * Unfortunately this will have to wait until after we switch to GCC 4.7. |
Michael J. Spencer |
2:1df0b61d3b5a | 40 | */ |
Michael J. Spencer |
2:1df0b61d3b5a | 41 | constexpr uint16_t checksum(const char* s, size_t n, size_t i, uint16_t sum1, uint16_t sum2) { |
Michael J. Spencer |
2:1df0b61d3b5a | 42 | return (i <= n) ? checksum(s, n, i+1, (sum1 + s[i]) % 255, (sum2 + sum1) % 255) : ((sum2 << 8) | sum1); |
Michael J. Spencer |
2:1df0b61d3b5a | 43 | } |
Michael J. Spencer |
2:1df0b61d3b5a | 44 | |
Michael J. Spencer |
2:1df0b61d3b5a | 45 | constexpr uint16_t operator "" _checksum(const char* s, size_t n) { |
Michael J. Spencer |
2:1df0b61d3b5a | 46 | return checksum(s, n, 0, 0, 0); |
Michael J. Spencer |
2:1df0b61d3b5a | 47 | } |
Michael J. Spencer |
2:1df0b61d3b5a | 48 | |
Michael J. Spencer |
2:1df0b61d3b5a | 49 | #define CHECKSUM(X) std::integral_constant<uint16_t, X##_checksum>::value |
Michael J. Spencer |
2:1df0b61d3b5a | 50 | |
Michael J. Spencer |
2:1df0b61d3b5a | 51 | #else /* !CHECKSUM_USE_CPP */ |
Michael J. Spencer |
2:1df0b61d3b5a | 52 | |
Michael J. Spencer |
2:1df0b61d3b5a | 53 | /* Adam Green's old and crusty C approach. */ |
Michael J. Spencer |
2:1df0b61d3b5a | 54 | /* Recursively define SUM1, the basic checksum % 255 */ |
Michael J. Spencer |
2:1df0b61d3b5a | 55 | #define SUM1_1(X) ((X)[0] % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 56 | #define SUM1_2(X) ((SUM1_1(X) + (X)[1]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 57 | #define SUM1_3(X) ((SUM1_2(X) + (X)[2]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 58 | #define SUM1_4(X) ((SUM1_3(X) + (X)[3]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 59 | #define SUM1_5(X) ((SUM1_4(X) + (X)[4]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 60 | #define SUM1_6(X) ((SUM1_5(X) + (X)[5]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 61 | #define SUM1_7(X) ((SUM1_6(X) + (X)[6]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 62 | #define SUM1_8(X) ((SUM1_7(X) + (X)[7]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 63 | #define SUM1_9(X) ((SUM1_8(X) + (X)[8]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 64 | #define SUM1_10(X) ((SUM1_9(X) + (X)[9]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 65 | #define SUM1_11(X) ((SUM1_10(X) + (X)[10]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 66 | #define SUM1_12(X) ((SUM1_11(X) + (X)[11]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 67 | #define SUM1_13(X) ((SUM1_12(X) + (X)[12]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 68 | #define SUM1_14(X) ((SUM1_13(X) + (X)[13]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 69 | #define SUM1_15(X) ((SUM1_14(X) + (X)[14]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 70 | #define SUM1_16(X) ((SUM1_15(X) + (X)[15]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 71 | #define SUM1_17(X) ((SUM1_16(X) + (X)[16]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 72 | #define SUM1_18(X) ((SUM1_17(X) + (X)[17]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 73 | #define SUM1_19(X) ((SUM1_18(X) + (X)[18]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 74 | #define SUM1_20(X) ((SUM1_19(X) + (X)[19]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 75 | #define SUM1_21(X) ((SUM1_20(X) + (X)[20]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 76 | #define SUM1_22(X) ((SUM1_21(X) + (X)[21]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 77 | #define SUM1_23(X) ((SUM1_22(X) + (X)[22]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 78 | #define SUM1_24(X) ((SUM1_23(X) + (X)[23]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 79 | #define SUM1_25(X) ((SUM1_24(X) + (X)[24]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 80 | #define SUM1_26(X) ((SUM1_25(X) + (X)[25]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 81 | #define SUM1_27(X) ((SUM1_26(X) + (X)[26]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 82 | #define SUM1_28(X) ((SUM1_27(X) + (X)[27]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 83 | #define SUM1_29(X) ((SUM1_28(X) + (X)[28]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 84 | #define SUM1_30(X) ((SUM1_29(X) + (X)[29]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 85 | #define SUM1_31(X) ((SUM1_30(X) + (X)[30]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 86 | #define SUM1_32(X) ((SUM1_31(X) + (X)[31]) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 87 | |
Michael J. Spencer |
2:1df0b61d3b5a | 88 | /* Recursively define SUM2, the sum of SUM1s % 255 */ |
Michael J. Spencer |
2:1df0b61d3b5a | 89 | #define SUM2_1(X) (SUM1_1(X) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 90 | #define SUM2_2(X) ((SUM2_1(X) + SUM1_2(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 91 | #define SUM2_3(X) ((SUM2_2(X) + SUM1_3(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 92 | #define SUM2_4(X) ((SUM2_3(X) + SUM1_4(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 93 | #define SUM2_5(X) ((SUM2_4(X) + SUM1_5(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 94 | #define SUM2_6(X) ((SUM2_5(X) + SUM1_6(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 95 | #define SUM2_7(X) ((SUM2_6(X) + SUM1_7(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 96 | #define SUM2_8(X) ((SUM2_7(X) + SUM1_8(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 97 | #define SUM2_9(X) ((SUM2_8(X) + SUM1_9(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 98 | #define SUM2_10(X) ((SUM2_9(X) + SUM1_10(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 99 | #define SUM2_11(X) ((SUM2_10(X) + SUM1_11(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 100 | #define SUM2_12(X) ((SUM2_11(X) + SUM1_12(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 101 | #define SUM2_13(X) ((SUM2_12(X) + SUM1_13(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 102 | #define SUM2_14(X) ((SUM2_13(X) + SUM1_14(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 103 | #define SUM2_15(X) ((SUM2_14(X) + SUM1_15(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 104 | #define SUM2_16(X) ((SUM2_15(X) + SUM1_16(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 105 | #define SUM2_17(X) ((SUM2_16(X) + SUM1_17(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 106 | #define SUM2_18(X) ((SUM2_17(X) + SUM1_18(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 107 | #define SUM2_19(X) ((SUM2_18(X) + SUM1_19(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 108 | #define SUM2_20(X) ((SUM2_19(X) + SUM1_20(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 109 | #define SUM2_21(X) ((SUM2_20(X) + SUM1_21(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 110 | #define SUM2_22(X) ((SUM2_21(X) + SUM1_22(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 111 | #define SUM2_23(X) ((SUM2_22(X) + SUM1_23(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 112 | #define SUM2_24(X) ((SUM2_23(X) + SUM1_24(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 113 | #define SUM2_25(X) ((SUM2_24(X) + SUM1_25(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 114 | #define SUM2_26(X) ((SUM2_25(X) + SUM1_26(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 115 | #define SUM2_27(X) ((SUM2_26(X) + SUM1_27(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 116 | #define SUM2_28(X) ((SUM2_27(X) + SUM1_28(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 117 | #define SUM2_29(X) ((SUM2_28(X) + SUM1_29(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 118 | #define SUM2_30(X) ((SUM2_29(X) + SUM1_30(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 119 | #define SUM2_31(X) ((SUM2_30(X) + SUM1_31(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 120 | #define SUM2_32(X) ((SUM2_31(X) + SUM1_32(X)) % 255) |
Michael J. Spencer |
2:1df0b61d3b5a | 121 | |
Michael J. Spencer |
2:1df0b61d3b5a | 122 | /* Define overall checksum as 16-bit combination of SUM1 in lower 8-bits and SUM2 in upper 8-bits. */ |
Michael J. Spencer |
2:1df0b61d3b5a | 123 | #define CHECKSUM_(SUM1,SUM2) (SUM1) | (SUM2 << 8) |
Michael J. Spencer |
2:1df0b61d3b5a | 124 | #define CHECKSUM_1(X) CHECKSUM_(SUM1_1(X),SUM2_1(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 125 | #define CHECKSUM_2(X) CHECKSUM_(SUM1_2(X),SUM2_2(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 126 | #define CHECKSUM_3(X) CHECKSUM_(SUM1_3(X),SUM2_3(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 127 | #define CHECKSUM_4(X) CHECKSUM_(SUM1_4(X),SUM2_4(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 128 | #define CHECKSUM_5(X) CHECKSUM_(SUM1_5(X),SUM2_5(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 129 | #define CHECKSUM_6(X) CHECKSUM_(SUM1_6(X),SUM2_6(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 130 | #define CHECKSUM_7(X) CHECKSUM_(SUM1_7(X),SUM2_7(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 131 | #define CHECKSUM_8(X) CHECKSUM_(SUM1_8(X),SUM2_8(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 132 | #define CHECKSUM_9(X) CHECKSUM_(SUM1_9(X),SUM2_9(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 133 | #define CHECKSUM_10(X) CHECKSUM_(SUM1_10(X),SUM2_10(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 134 | #define CHECKSUM_11(X) CHECKSUM_(SUM1_11(X),SUM2_11(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 135 | #define CHECKSUM_12(X) CHECKSUM_(SUM1_12(X),SUM2_12(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 136 | #define CHECKSUM_13(X) CHECKSUM_(SUM1_13(X),SUM2_13(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 137 | #define CHECKSUM_14(X) CHECKSUM_(SUM1_14(X),SUM2_14(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 138 | #define CHECKSUM_15(X) CHECKSUM_(SUM1_15(X),SUM2_15(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 139 | #define CHECKSUM_16(X) CHECKSUM_(SUM1_16(X),SUM2_16(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 140 | #define CHECKSUM_17(X) CHECKSUM_(SUM1_17(X),SUM2_17(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 141 | #define CHECKSUM_18(X) CHECKSUM_(SUM1_18(X),SUM2_18(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 142 | #define CHECKSUM_19(X) CHECKSUM_(SUM1_19(X),SUM2_19(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 143 | #define CHECKSUM_20(X) CHECKSUM_(SUM1_20(X),SUM2_20(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 144 | #define CHECKSUM_21(X) CHECKSUM_(SUM1_21(X),SUM2_21(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 145 | #define CHECKSUM_22(X) CHECKSUM_(SUM1_22(X),SUM2_22(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 146 | #define CHECKSUM_23(X) CHECKSUM_(SUM1_23(X),SUM2_23(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 147 | #define CHECKSUM_24(X) CHECKSUM_(SUM1_24(X),SUM2_24(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 148 | #define CHECKSUM_25(X) CHECKSUM_(SUM1_25(X),SUM2_25(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 149 | #define CHECKSUM_26(X) CHECKSUM_(SUM1_26(X),SUM2_26(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 150 | #define CHECKSUM_27(X) CHECKSUM_(SUM1_27(X),SUM2_27(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 151 | #define CHECKSUM_28(X) CHECKSUM_(SUM1_28(X),SUM2_28(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 152 | #define CHECKSUM_29(X) CHECKSUM_(SUM1_29(X),SUM2_29(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 153 | #define CHECKSUM_30(X) CHECKSUM_(SUM1_30(X),SUM2_30(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 154 | #define CHECKSUM_31(X) CHECKSUM_(SUM1_31(X),SUM2_31(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 155 | #define CHECKSUM_32(X) CHECKSUM_(SUM1_32(X),SUM2_32(X)) |
Michael J. Spencer |
2:1df0b61d3b5a | 156 | |
Michael J. Spencer |
2:1df0b61d3b5a | 157 | #ifdef DEBUG |
Michael J. Spencer |
2:1df0b61d3b5a | 158 | |
Michael J. Spencer |
2:1df0b61d3b5a | 159 | #include <utils.h> |
Michael J. Spencer |
2:1df0b61d3b5a | 160 | #define CHECKSUM(X) get_checksum(X) |
Michael J. Spencer |
2:1df0b61d3b5a | 161 | |
Michael J. Spencer |
2:1df0b61d3b5a | 162 | #else /* !DEBUG */ |
Michael J. Spencer |
2:1df0b61d3b5a | 163 | |
Michael J. Spencer |
2:1df0b61d3b5a | 164 | #define CHECKSUM(X) (sizeof(X) == 0 ? 0 : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 165 | sizeof(X) == 1 ? 0 : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 166 | sizeof(X) == 2 ? CHECKSUM_1(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 167 | sizeof(X) == 3 ? CHECKSUM_2(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 168 | sizeof(X) == 4 ? CHECKSUM_3(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 169 | sizeof(X) == 5 ? CHECKSUM_4(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 170 | sizeof(X) == 6 ? CHECKSUM_5(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 171 | sizeof(X) == 7 ? CHECKSUM_6(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 172 | sizeof(X) == 8 ? CHECKSUM_7(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 173 | sizeof(X) == 9 ? CHECKSUM_8(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 174 | sizeof(X) == 10 ? CHECKSUM_9(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 175 | sizeof(X) == 11 ? CHECKSUM_10(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 176 | sizeof(X) == 12 ? CHECKSUM_11(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 177 | sizeof(X) == 13 ? CHECKSUM_12(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 178 | sizeof(X) == 14 ? CHECKSUM_13(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 179 | sizeof(X) == 15 ? CHECKSUM_14(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 180 | sizeof(X) == 16 ? CHECKSUM_15(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 181 | sizeof(X) == 17 ? CHECKSUM_16(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 182 | sizeof(X) == 18 ? CHECKSUM_17(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 183 | sizeof(X) == 19 ? CHECKSUM_18(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 184 | sizeof(X) == 20 ? CHECKSUM_19(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 185 | sizeof(X) == 21 ? CHECKSUM_20(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 186 | sizeof(X) == 22 ? CHECKSUM_21(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 187 | sizeof(X) == 23 ? CHECKSUM_22(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 188 | sizeof(X) == 24 ? CHECKSUM_23(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 189 | sizeof(X) == 25 ? CHECKSUM_24(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 190 | sizeof(X) == 26 ? CHECKSUM_25(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 191 | sizeof(X) == 27 ? CHECKSUM_26(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 192 | sizeof(X) == 28 ? CHECKSUM_27(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 193 | sizeof(X) == 29 ? CHECKSUM_28(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 194 | sizeof(X) == 30 ? CHECKSUM_29(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 195 | sizeof(X) == 31 ? CHECKSUM_30(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 196 | sizeof(X) == 32 ? CHECKSUM_31(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 197 | sizeof(X) == 33 ? CHECKSUM_32(X) : \ |
Michael J. Spencer |
2:1df0b61d3b5a | 198 | 0xFFFF) |
Michael J. Spencer |
2:1df0b61d3b5a | 199 | #endif /* DEBUG */ |
Michael J. Spencer |
2:1df0b61d3b5a | 200 | #endif /* CHECKSUM_USE_CPP */ |
Michael J. Spencer |
2:1df0b61d3b5a | 201 | |
Michael J. Spencer |
2:1df0b61d3b5a | 202 | #endif /* _CHECKSUM_MACRO_H_ */ |