| ... | @@ -1,31 +1,19 @@ | ... | @@ -1,31 +1,19 @@ |
| 1 | //! This file is auto-generated by tools/update_crc_catalog.zig. | 1 | //! This file is maintained with the help of tools/update_crc_catalog.zig. |
| 2 | | 2 | |
| 3 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | const impl = @import("crc/impl.zig"); | | |
| 5 | | 4 | |
| 6 | pub const Crc = impl.Crc; | 5 | pub const Crc32Iscsi = if (builtin.cpu.hasAll(.x86, &.{ .@"64bit", .crc32 })) |
| 7 | pub const Polynomial = impl.Polynomial; | 6 | @import("crc/Crc32c.zig") |
| 8 | pub const Crc32WithPoly = impl.Crc32WithPoly; | 7 | else |
| 9 | pub const Crc32SmallWithPoly = impl.Crc32SmallWithPoly; | 8 | Generic(u32, .{ |
| 10 | | | |
| 11 | pub const Crc32 = Crc32IsoHdlc; | | |
| 12 | | | |
| 13 | test { | | |
| 14 | _ = @import("crc/test.zig"); | | |
| 15 | } | | |
| 16 | | | |
| 17 | pub const Crc32Iscsi = switch (builtin.cpu.hasAll(.x86, &.{ .@"64bit", .crc32 })) { | | |
| 18 | true => @import("crc/Crc32c.zig"), | | |
| 19 | else => Crc(u32, .{ | | |
| 20 | .polynomial = 0x1edc6f41, | 9 | .polynomial = 0x1edc6f41, |
| 21 | .initial = 0xffffffff, | 10 | .initial = 0xffffffff, |
| 22 | .reflect_input = true, | 11 | .reflect_input = true, |
| 23 | .reflect_output = true, | 12 | .reflect_output = true, |
| 24 | .xor_output = 0xffffffff, | 13 | .xor_output = 0xffffffff, |
| 25 | }), | 14 | }); |
| 26 | }; | | |
| 27 | | 15 | |
| 28 | pub const Crc3Gsm = Crc(u3, .{ | 16 | pub const Crc3Gsm = Generic(u3, .{ |
| 29 | .polynomial = 0x3, | 17 | .polynomial = 0x3, |
| 30 | .initial = 0x0, | 18 | .initial = 0x0, |
| 31 | .reflect_input = false, | 19 | .reflect_input = false, |
| ... | @@ -33,7 +21,7 @@ pub const Crc3Gsm = Crc(u3, .{ | ... | @@ -33,7 +21,7 @@ pub const Crc3Gsm = Crc(u3, .{ |
| 33 | .xor_output = 0x7, | 21 | .xor_output = 0x7, |
| 34 | }); | 22 | }); |
| 35 | | 23 | |
| 36 | pub const Crc3Rohc = Crc(u3, .{ | 24 | pub const Crc3Rohc = Generic(u3, .{ |
| 37 | .polynomial = 0x3, | 25 | .polynomial = 0x3, |
| 38 | .initial = 0x7, | 26 | .initial = 0x7, |
| 39 | .reflect_input = true, | 27 | .reflect_input = true, |
| ... | @@ -41,7 +29,7 @@ pub const Crc3Rohc = Crc(u3, .{ | ... | @@ -41,7 +29,7 @@ pub const Crc3Rohc = Crc(u3, .{ |
| 41 | .xor_output = 0x0, | 29 | .xor_output = 0x0, |
| 42 | }); | 30 | }); |
| 43 | | 31 | |
| 44 | pub const Crc4G704 = Crc(u4, .{ | 32 | pub const Crc4G704 = Generic(u4, .{ |
| 45 | .polynomial = 0x3, | 33 | .polynomial = 0x3, |
| 46 | .initial = 0x0, | 34 | .initial = 0x0, |
| 47 | .reflect_input = true, | 35 | .reflect_input = true, |
| ... | @@ -49,7 +37,7 @@ pub const Crc4G704 = Crc(u4, .{ | ... | @@ -49,7 +37,7 @@ pub const Crc4G704 = Crc(u4, .{ |
| 49 | .xor_output = 0x0, | 37 | .xor_output = 0x0, |
| 50 | }); | 38 | }); |
| 51 | | 39 | |
| 52 | pub const Crc4Interlaken = Crc(u4, .{ | 40 | pub const Crc4Interlaken = Generic(u4, .{ |
| 53 | .polynomial = 0x3, | 41 | .polynomial = 0x3, |
| 54 | .initial = 0xf, | 42 | .initial = 0xf, |
| 55 | .reflect_input = false, | 43 | .reflect_input = false, |
| ... | @@ -57,7 +45,7 @@ pub const Crc4Interlaken = Crc(u4, .{ | ... | @@ -57,7 +45,7 @@ pub const Crc4Interlaken = Crc(u4, .{ |
| 57 | .xor_output = 0xf, | 45 | .xor_output = 0xf, |
| 58 | }); | 46 | }); |
| 59 | | 47 | |
| 60 | pub const Crc5EpcC1g2 = Crc(u5, .{ | 48 | pub const Crc5EpcC1g2 = Generic(u5, .{ |
| 61 | .polynomial = 0x09, | 49 | .polynomial = 0x09, |
| 62 | .initial = 0x09, | 50 | .initial = 0x09, |
| 63 | .reflect_input = false, | 51 | .reflect_input = false, |
| ... | @@ -65,7 +53,7 @@ pub const Crc5EpcC1g2 = Crc(u5, .{ | ... | @@ -65,7 +53,7 @@ pub const Crc5EpcC1g2 = Crc(u5, .{ |
| 65 | .xor_output = 0x00, | 53 | .xor_output = 0x00, |
| 66 | }); | 54 | }); |
| 67 | | 55 | |
| 68 | pub const Crc5G704 = Crc(u5, .{ | 56 | pub const Crc5G704 = Generic(u5, .{ |
| 69 | .polynomial = 0x15, | 57 | .polynomial = 0x15, |
| 70 | .initial = 0x00, | 58 | .initial = 0x00, |
| 71 | .reflect_input = true, | 59 | .reflect_input = true, |
| ... | @@ -73,7 +61,7 @@ pub const Crc5G704 = Crc(u5, .{ | ... | @@ -73,7 +61,7 @@ pub const Crc5G704 = Crc(u5, .{ |
| 73 | .xor_output = 0x00, | 61 | .xor_output = 0x00, |
| 74 | }); | 62 | }); |
| 75 | | 63 | |
| 76 | pub const Crc5Usb = Crc(u5, .{ | 64 | pub const Crc5Usb = Generic(u5, .{ |
| 77 | .polynomial = 0x05, | 65 | .polynomial = 0x05, |
| 78 | .initial = 0x1f, | 66 | .initial = 0x1f, |
| 79 | .reflect_input = true, | 67 | .reflect_input = true, |
| ... | @@ -81,7 +69,7 @@ pub const Crc5Usb = Crc(u5, .{ | ... | @@ -81,7 +69,7 @@ pub const Crc5Usb = Crc(u5, .{ |
| 81 | .xor_output = 0x1f, | 69 | .xor_output = 0x1f, |
| 82 | }); | 70 | }); |
| 83 | | 71 | |
| 84 | pub const Crc6Cdma2000A = Crc(u6, .{ | 72 | pub const Crc6Cdma2000A = Generic(u6, .{ |
| 85 | .polynomial = 0x27, | 73 | .polynomial = 0x27, |
| 86 | .initial = 0x3f, | 74 | .initial = 0x3f, |
| 87 | .reflect_input = false, | 75 | .reflect_input = false, |
| ... | @@ -89,7 +77,7 @@ pub const Crc6Cdma2000A = Crc(u6, .{ | ... | @@ -89,7 +77,7 @@ pub const Crc6Cdma2000A = Crc(u6, .{ |
| 89 | .xor_output = 0x00, | 77 | .xor_output = 0x00, |
| 90 | }); | 78 | }); |
| 91 | | 79 | |
| 92 | pub const Crc6Cdma2000B = Crc(u6, .{ | 80 | pub const Crc6Cdma2000B = Generic(u6, .{ |
| 93 | .polynomial = 0x07, | 81 | .polynomial = 0x07, |
| 94 | .initial = 0x3f, | 82 | .initial = 0x3f, |
| 95 | .reflect_input = false, | 83 | .reflect_input = false, |
| ... | @@ -97,7 +85,7 @@ pub const Crc6Cdma2000B = Crc(u6, .{ | ... | @@ -97,7 +85,7 @@ pub const Crc6Cdma2000B = Crc(u6, .{ |
| 97 | .xor_output = 0x00, | 85 | .xor_output = 0x00, |
| 98 | }); | 86 | }); |
| 99 | | 87 | |
| 100 | pub const Crc6Darc = Crc(u6, .{ | 88 | pub const Crc6Darc = Generic(u6, .{ |
| 101 | .polynomial = 0x19, | 89 | .polynomial = 0x19, |
| 102 | .initial = 0x00, | 90 | .initial = 0x00, |
| 103 | .reflect_input = true, | 91 | .reflect_input = true, |
| ... | @@ -105,7 +93,7 @@ pub const Crc6Darc = Crc(u6, .{ | ... | @@ -105,7 +93,7 @@ pub const Crc6Darc = Crc(u6, .{ |
| 105 | .xor_output = 0x00, | 93 | .xor_output = 0x00, |
| 106 | }); | 94 | }); |
| 107 | | 95 | |
| 108 | pub const Crc6G704 = Crc(u6, .{ | 96 | pub const Crc6G704 = Generic(u6, .{ |
| 109 | .polynomial = 0x03, | 97 | .polynomial = 0x03, |
| 110 | .initial = 0x00, | 98 | .initial = 0x00, |
| 111 | .reflect_input = true, | 99 | .reflect_input = true, |
| ... | @@ -113,7 +101,7 @@ pub const Crc6G704 = Crc(u6, .{ | ... | @@ -113,7 +101,7 @@ pub const Crc6G704 = Crc(u6, .{ |
| 113 | .xor_output = 0x00, | 101 | .xor_output = 0x00, |
| 114 | }); | 102 | }); |
| 115 | | 103 | |
| 116 | pub const Crc6Gsm = Crc(u6, .{ | 104 | pub const Crc6Gsm = Generic(u6, .{ |
| 117 | .polynomial = 0x2f, | 105 | .polynomial = 0x2f, |
| 118 | .initial = 0x00, | 106 | .initial = 0x00, |
| 119 | .reflect_input = false, | 107 | .reflect_input = false, |
| ... | @@ -121,7 +109,7 @@ pub const Crc6Gsm = Crc(u6, .{ | ... | @@ -121,7 +109,7 @@ pub const Crc6Gsm = Crc(u6, .{ |
| 121 | .xor_output = 0x3f, | 109 | .xor_output = 0x3f, |
| 122 | }); | 110 | }); |
| 123 | | 111 | |
| 124 | pub const Crc7Mmc = Crc(u7, .{ | 112 | pub const Crc7Mmc = Generic(u7, .{ |
| 125 | .polynomial = 0x09, | 113 | .polynomial = 0x09, |
| 126 | .initial = 0x00, | 114 | .initial = 0x00, |
| 127 | .reflect_input = false, | 115 | .reflect_input = false, |
| ... | @@ -129,7 +117,7 @@ pub const Crc7Mmc = Crc(u7, .{ | ... | @@ -129,7 +117,7 @@ pub const Crc7Mmc = Crc(u7, .{ |
| 129 | .xor_output = 0x00, | 117 | .xor_output = 0x00, |
| 130 | }); | 118 | }); |
| 131 | | 119 | |
| 132 | pub const Crc7Rohc = Crc(u7, .{ | 120 | pub const Crc7Rohc = Generic(u7, .{ |
| 133 | .polynomial = 0x4f, | 121 | .polynomial = 0x4f, |
| 134 | .initial = 0x7f, | 122 | .initial = 0x7f, |
| 135 | .reflect_input = true, | 123 | .reflect_input = true, |
| ... | @@ -137,7 +125,7 @@ pub const Crc7Rohc = Crc(u7, .{ | ... | @@ -137,7 +125,7 @@ pub const Crc7Rohc = Crc(u7, .{ |
| 137 | .xor_output = 0x00, | 125 | .xor_output = 0x00, |
| 138 | }); | 126 | }); |
| 139 | | 127 | |
| 140 | pub const Crc7Umts = Crc(u7, .{ | 128 | pub const Crc7Umts = Generic(u7, .{ |
| 141 | .polynomial = 0x45, | 129 | .polynomial = 0x45, |
| 142 | .initial = 0x00, | 130 | .initial = 0x00, |
| 143 | .reflect_input = false, | 131 | .reflect_input = false, |
| ... | @@ -145,7 +133,7 @@ pub const Crc7Umts = Crc(u7, .{ | ... | @@ -145,7 +133,7 @@ pub const Crc7Umts = Crc(u7, .{ |
| 145 | .xor_output = 0x00, | 133 | .xor_output = 0x00, |
| 146 | }); | 134 | }); |
| 147 | | 135 | |
| 148 | pub const Crc8Autosar = Crc(u8, .{ | 136 | pub const Crc8Autosar = Generic(u8, .{ |
| 149 | .polynomial = 0x2f, | 137 | .polynomial = 0x2f, |
| 150 | .initial = 0xff, | 138 | .initial = 0xff, |
| 151 | .reflect_input = false, | 139 | .reflect_input = false, |
| ... | @@ -153,7 +141,7 @@ pub const Crc8Autosar = Crc(u8, .{ | ... | @@ -153,7 +141,7 @@ pub const Crc8Autosar = Crc(u8, .{ |
| 153 | .xor_output = 0xff, | 141 | .xor_output = 0xff, |
| 154 | }); | 142 | }); |
| 155 | | 143 | |
| 156 | pub const Crc8Bluetooth = Crc(u8, .{ | 144 | pub const Crc8Bluetooth = Generic(u8, .{ |
| 157 | .polynomial = 0xa7, | 145 | .polynomial = 0xa7, |
| 158 | .initial = 0x00, | 146 | .initial = 0x00, |
| 159 | .reflect_input = true, | 147 | .reflect_input = true, |
| ... | @@ -161,7 +149,7 @@ pub const Crc8Bluetooth = Crc(u8, .{ | ... | @@ -161,7 +149,7 @@ pub const Crc8Bluetooth = Crc(u8, .{ |
| 161 | .xor_output = 0x00, | 149 | .xor_output = 0x00, |
| 162 | }); | 150 | }); |
| 163 | | 151 | |
| 164 | pub const Crc8Cdma2000 = Crc(u8, .{ | 152 | pub const Crc8Cdma2000 = Generic(u8, .{ |
| 165 | .polynomial = 0x9b, | 153 | .polynomial = 0x9b, |
| 166 | .initial = 0xff, | 154 | .initial = 0xff, |
| 167 | .reflect_input = false, | 155 | .reflect_input = false, |
| ... | @@ -169,7 +157,7 @@ pub const Crc8Cdma2000 = Crc(u8, .{ | ... | @@ -169,7 +157,7 @@ pub const Crc8Cdma2000 = Crc(u8, .{ |
| 169 | .xor_output = 0x00, | 157 | .xor_output = 0x00, |
| 170 | }); | 158 | }); |
| 171 | | 159 | |
| 172 | pub const Crc8Darc = Crc(u8, .{ | 160 | pub const Crc8Darc = Generic(u8, .{ |
| 173 | .polynomial = 0x39, | 161 | .polynomial = 0x39, |
| 174 | .initial = 0x00, | 162 | .initial = 0x00, |
| 175 | .reflect_input = true, | 163 | .reflect_input = true, |
| ... | @@ -177,7 +165,7 @@ pub const Crc8Darc = Crc(u8, .{ | ... | @@ -177,7 +165,7 @@ pub const Crc8Darc = Crc(u8, .{ |
| 177 | .xor_output = 0x00, | 165 | .xor_output = 0x00, |
| 178 | }); | 166 | }); |
| 179 | | 167 | |
| 180 | pub const Crc8DvbS2 = Crc(u8, .{ | 168 | pub const Crc8DvbS2 = Generic(u8, .{ |
| 181 | .polynomial = 0xd5, | 169 | .polynomial = 0xd5, |
| 182 | .initial = 0x00, | 170 | .initial = 0x00, |
| 183 | .reflect_input = false, | 171 | .reflect_input = false, |
| ... | @@ -185,7 +173,7 @@ pub const Crc8DvbS2 = Crc(u8, .{ | ... | @@ -185,7 +173,7 @@ pub const Crc8DvbS2 = Crc(u8, .{ |
| 185 | .xor_output = 0x00, | 173 | .xor_output = 0x00, |
| 186 | }); | 174 | }); |
| 187 | | 175 | |
| 188 | pub const Crc8GsmA = Crc(u8, .{ | 176 | pub const Crc8GsmA = Generic(u8, .{ |
| 189 | .polynomial = 0x1d, | 177 | .polynomial = 0x1d, |
| 190 | .initial = 0x00, | 178 | .initial = 0x00, |
| 191 | .reflect_input = false, | 179 | .reflect_input = false, |
| ... | @@ -193,7 +181,7 @@ pub const Crc8GsmA = Crc(u8, .{ | ... | @@ -193,7 +181,7 @@ pub const Crc8GsmA = Crc(u8, .{ |
| 193 | .xor_output = 0x00, | 181 | .xor_output = 0x00, |
| 194 | }); | 182 | }); |
| 195 | | 183 | |
| 196 | pub const Crc8GsmB = Crc(u8, .{ | 184 | pub const Crc8GsmB = Generic(u8, .{ |
| 197 | .polynomial = 0x49, | 185 | .polynomial = 0x49, |
| 198 | .initial = 0x00, | 186 | .initial = 0x00, |
| 199 | .reflect_input = false, | 187 | .reflect_input = false, |
| ... | @@ -201,7 +189,7 @@ pub const Crc8GsmB = Crc(u8, .{ | ... | @@ -201,7 +189,7 @@ pub const Crc8GsmB = Crc(u8, .{ |
| 201 | .xor_output = 0xff, | 189 | .xor_output = 0xff, |
| 202 | }); | 190 | }); |
| 203 | | 191 | |
| 204 | pub const Crc8Hitag = Crc(u8, .{ | 192 | pub const Crc8Hitag = Generic(u8, .{ |
| 205 | .polynomial = 0x1d, | 193 | .polynomial = 0x1d, |
| 206 | .initial = 0xff, | 194 | .initial = 0xff, |
| 207 | .reflect_input = false, | 195 | .reflect_input = false, |
| ... | @@ -209,7 +197,7 @@ pub const Crc8Hitag = Crc(u8, .{ | ... | @@ -209,7 +197,7 @@ pub const Crc8Hitag = Crc(u8, .{ |
| 209 | .xor_output = 0x00, | 197 | .xor_output = 0x00, |
| 210 | }); | 198 | }); |
| 211 | | 199 | |
| 212 | pub const Crc8I4321 = Crc(u8, .{ | 200 | pub const Crc8I4321 = Generic(u8, .{ |
| 213 | .polynomial = 0x07, | 201 | .polynomial = 0x07, |
| 214 | .initial = 0x00, | 202 | .initial = 0x00, |
| 215 | .reflect_input = false, | 203 | .reflect_input = false, |
| ... | @@ -217,7 +205,7 @@ pub const Crc8I4321 = Crc(u8, .{ | ... | @@ -217,7 +205,7 @@ pub const Crc8I4321 = Crc(u8, .{ |
| 217 | .xor_output = 0x55, | 205 | .xor_output = 0x55, |
| 218 | }); | 206 | }); |
| 219 | | 207 | |
| 220 | pub const Crc8ICode = Crc(u8, .{ | 208 | pub const Crc8ICode = Generic(u8, .{ |
| 221 | .polynomial = 0x1d, | 209 | .polynomial = 0x1d, |
| 222 | .initial = 0xfd, | 210 | .initial = 0xfd, |
| 223 | .reflect_input = false, | 211 | .reflect_input = false, |
| ... | @@ -225,7 +213,7 @@ pub const Crc8ICode = Crc(u8, .{ | ... | @@ -225,7 +213,7 @@ pub const Crc8ICode = Crc(u8, .{ |
| 225 | .xor_output = 0x00, | 213 | .xor_output = 0x00, |
| 226 | }); | 214 | }); |
| 227 | | 215 | |
| 228 | pub const Crc8Lte = Crc(u8, .{ | 216 | pub const Crc8Lte = Generic(u8, .{ |
| 229 | .polynomial = 0x9b, | 217 | .polynomial = 0x9b, |
| 230 | .initial = 0x00, | 218 | .initial = 0x00, |
| 231 | .reflect_input = false, | 219 | .reflect_input = false, |
| ... | @@ -233,7 +221,7 @@ pub const Crc8Lte = Crc(u8, .{ | ... | @@ -233,7 +221,7 @@ pub const Crc8Lte = Crc(u8, .{ |
| 233 | .xor_output = 0x00, | 221 | .xor_output = 0x00, |
| 234 | }); | 222 | }); |
| 235 | | 223 | |
| 236 | pub const Crc8MaximDow = Crc(u8, .{ | 224 | pub const Crc8MaximDow = Generic(u8, .{ |
| 237 | .polynomial = 0x31, | 225 | .polynomial = 0x31, |
| 238 | .initial = 0x00, | 226 | .initial = 0x00, |
| 239 | .reflect_input = true, | 227 | .reflect_input = true, |
| ... | @@ -241,7 +229,7 @@ pub const Crc8MaximDow = Crc(u8, .{ | ... | @@ -241,7 +229,7 @@ pub const Crc8MaximDow = Crc(u8, .{ |
| 241 | .xor_output = 0x00, | 229 | .xor_output = 0x00, |
| 242 | }); | 230 | }); |
| 243 | | 231 | |
| 244 | pub const Crc8MifareMad = Crc(u8, .{ | 232 | pub const Crc8MifareMad = Generic(u8, .{ |
| 245 | .polynomial = 0x1d, | 233 | .polynomial = 0x1d, |
| 246 | .initial = 0xc7, | 234 | .initial = 0xc7, |
| 247 | .reflect_input = false, | 235 | .reflect_input = false, |
| ... | @@ -249,7 +237,7 @@ pub const Crc8MifareMad = Crc(u8, .{ | ... | @@ -249,7 +237,7 @@ pub const Crc8MifareMad = Crc(u8, .{ |
| 249 | .xor_output = 0x00, | 237 | .xor_output = 0x00, |
| 250 | }); | 238 | }); |
| 251 | | 239 | |
| 252 | pub const Crc8Nrsc5 = Crc(u8, .{ | 240 | pub const Crc8Nrsc5 = Generic(u8, .{ |
| 253 | .polynomial = 0x31, | 241 | .polynomial = 0x31, |
| 254 | .initial = 0xff, | 242 | .initial = 0xff, |
| 255 | .reflect_input = false, | 243 | .reflect_input = false, |
| ... | @@ -257,7 +245,7 @@ pub const Crc8Nrsc5 = Crc(u8, .{ | ... | @@ -257,7 +245,7 @@ pub const Crc8Nrsc5 = Crc(u8, .{ |
| 257 | .xor_output = 0x00, | 245 | .xor_output = 0x00, |
| 258 | }); | 246 | }); |
| 259 | | 247 | |
| 260 | pub const Crc8Opensafety = Crc(u8, .{ | 248 | pub const Crc8Opensafety = Generic(u8, .{ |
| 261 | .polynomial = 0x2f, | 249 | .polynomial = 0x2f, |
| 262 | .initial = 0x00, | 250 | .initial = 0x00, |
| 263 | .reflect_input = false, | 251 | .reflect_input = false, |
| ... | @@ -265,7 +253,7 @@ pub const Crc8Opensafety = Crc(u8, .{ | ... | @@ -265,7 +253,7 @@ pub const Crc8Opensafety = Crc(u8, .{ |
| 265 | .xor_output = 0x00, | 253 | .xor_output = 0x00, |
| 266 | }); | 254 | }); |
| 267 | | 255 | |
| 268 | pub const Crc8Rohc = Crc(u8, .{ | 256 | pub const Crc8Rohc = Generic(u8, .{ |
| 269 | .polynomial = 0x07, | 257 | .polynomial = 0x07, |
| 270 | .initial = 0xff, | 258 | .initial = 0xff, |
| 271 | .reflect_input = true, | 259 | .reflect_input = true, |
| ... | @@ -273,7 +261,7 @@ pub const Crc8Rohc = Crc(u8, .{ | ... | @@ -273,7 +261,7 @@ pub const Crc8Rohc = Crc(u8, .{ |
| 273 | .xor_output = 0x00, | 261 | .xor_output = 0x00, |
| 274 | }); | 262 | }); |
| 275 | | 263 | |
| 276 | pub const Crc8SaeJ1850 = Crc(u8, .{ | 264 | pub const Crc8SaeJ1850 = Generic(u8, .{ |
| 277 | .polynomial = 0x1d, | 265 | .polynomial = 0x1d, |
| 278 | .initial = 0xff, | 266 | .initial = 0xff, |
| 279 | .reflect_input = false, | 267 | .reflect_input = false, |
| ... | @@ -281,7 +269,7 @@ pub const Crc8SaeJ1850 = Crc(u8, .{ | ... | @@ -281,7 +269,7 @@ pub const Crc8SaeJ1850 = Crc(u8, .{ |
| 281 | .xor_output = 0xff, | 269 | .xor_output = 0xff, |
| 282 | }); | 270 | }); |
| 283 | | 271 | |
| 284 | pub const Crc8Smbus = Crc(u8, .{ | 272 | pub const Crc8Smbus = Generic(u8, .{ |
| 285 | .polynomial = 0x07, | 273 | .polynomial = 0x07, |
| 286 | .initial = 0x00, | 274 | .initial = 0x00, |
| 287 | .reflect_input = false, | 275 | .reflect_input = false, |
| ... | @@ -289,7 +277,7 @@ pub const Crc8Smbus = Crc(u8, .{ | ... | @@ -289,7 +277,7 @@ pub const Crc8Smbus = Crc(u8, .{ |
| 289 | .xor_output = 0x00, | 277 | .xor_output = 0x00, |
| 290 | }); | 278 | }); |
| 291 | | 279 | |
| 292 | pub const Crc8Tech3250 = Crc(u8, .{ | 280 | pub const Crc8Tech3250 = Generic(u8, .{ |
| 293 | .polynomial = 0x1d, | 281 | .polynomial = 0x1d, |
| 294 | .initial = 0xff, | 282 | .initial = 0xff, |
| 295 | .reflect_input = true, | 283 | .reflect_input = true, |
| ... | @@ -297,7 +285,7 @@ pub const Crc8Tech3250 = Crc(u8, .{ | ... | @@ -297,7 +285,7 @@ pub const Crc8Tech3250 = Crc(u8, .{ |
| 297 | .xor_output = 0x00, | 285 | .xor_output = 0x00, |
| 298 | }); | 286 | }); |
| 299 | | 287 | |
| 300 | pub const Crc8Wcdma = Crc(u8, .{ | 288 | pub const Crc8Wcdma = Generic(u8, .{ |
| 301 | .polynomial = 0x9b, | 289 | .polynomial = 0x9b, |
| 302 | .initial = 0x00, | 290 | .initial = 0x00, |
| 303 | .reflect_input = true, | 291 | .reflect_input = true, |
| ... | @@ -305,7 +293,7 @@ pub const Crc8Wcdma = Crc(u8, .{ | ... | @@ -305,7 +293,7 @@ pub const Crc8Wcdma = Crc(u8, .{ |
| 305 | .xor_output = 0x00, | 293 | .xor_output = 0x00, |
| 306 | }); | 294 | }); |
| 307 | | 295 | |
| 308 | pub const Crc10Atm = Crc(u10, .{ | 296 | pub const Crc10Atm = Generic(u10, .{ |
| 309 | .polynomial = 0x233, | 297 | .polynomial = 0x233, |
| 310 | .initial = 0x000, | 298 | .initial = 0x000, |
| 311 | .reflect_input = false, | 299 | .reflect_input = false, |
| ... | @@ -313,7 +301,7 @@ pub const Crc10Atm = Crc(u10, .{ | ... | @@ -313,7 +301,7 @@ pub const Crc10Atm = Crc(u10, .{ |
| 313 | .xor_output = 0x000, | 301 | .xor_output = 0x000, |
| 314 | }); | 302 | }); |
| 315 | | 303 | |
| 316 | pub const Crc10Cdma2000 = Crc(u10, .{ | 304 | pub const Crc10Cdma2000 = Generic(u10, .{ |
| 317 | .polynomial = 0x3d9, | 305 | .polynomial = 0x3d9, |
| 318 | .initial = 0x3ff, | 306 | .initial = 0x3ff, |
| 319 | .reflect_input = false, | 307 | .reflect_input = false, |
| ... | @@ -321,7 +309,7 @@ pub const Crc10Cdma2000 = Crc(u10, .{ | ... | @@ -321,7 +309,7 @@ pub const Crc10Cdma2000 = Crc(u10, .{ |
| 321 | .xor_output = 0x000, | 309 | .xor_output = 0x000, |
| 322 | }); | 310 | }); |
| 323 | | 311 | |
| 324 | pub const Crc10Gsm = Crc(u10, .{ | 312 | pub const Crc10Gsm = Generic(u10, .{ |
| 325 | .polynomial = 0x175, | 313 | .polynomial = 0x175, |
| 326 | .initial = 0x000, | 314 | .initial = 0x000, |
| 327 | .reflect_input = false, | 315 | .reflect_input = false, |
| ... | @@ -329,7 +317,7 @@ pub const Crc10Gsm = Crc(u10, .{ | ... | @@ -329,7 +317,7 @@ pub const Crc10Gsm = Crc(u10, .{ |
| 329 | .xor_output = 0x3ff, | 317 | .xor_output = 0x3ff, |
| 330 | }); | 318 | }); |
| 331 | | 319 | |
| 332 | pub const Crc11Flexray = Crc(u11, .{ | 320 | pub const Crc11Flexray = Generic(u11, .{ |
| 333 | .polynomial = 0x385, | 321 | .polynomial = 0x385, |
| 334 | .initial = 0x01a, | 322 | .initial = 0x01a, |
| 335 | .reflect_input = false, | 323 | .reflect_input = false, |
| ... | @@ -337,7 +325,7 @@ pub const Crc11Flexray = Crc(u11, .{ | ... | @@ -337,7 +325,7 @@ pub const Crc11Flexray = Crc(u11, .{ |
| 337 | .xor_output = 0x000, | 325 | .xor_output = 0x000, |
| 338 | }); | 326 | }); |
| 339 | | 327 | |
| 340 | pub const Crc11Umts = Crc(u11, .{ | 328 | pub const Crc11Umts = Generic(u11, .{ |
| 341 | .polynomial = 0x307, | 329 | .polynomial = 0x307, |
| 342 | .initial = 0x000, | 330 | .initial = 0x000, |
| 343 | .reflect_input = false, | 331 | .reflect_input = false, |
| ... | @@ -345,7 +333,7 @@ pub const Crc11Umts = Crc(u11, .{ | ... | @@ -345,7 +333,7 @@ pub const Crc11Umts = Crc(u11, .{ |
| 345 | .xor_output = 0x000, | 333 | .xor_output = 0x000, |
| 346 | }); | 334 | }); |
| 347 | | 335 | |
| 348 | pub const Crc12Cdma2000 = Crc(u12, .{ | 336 | pub const Crc12Cdma2000 = Generic(u12, .{ |
| 349 | .polynomial = 0xf13, | 337 | .polynomial = 0xf13, |
| 350 | .initial = 0xfff, | 338 | .initial = 0xfff, |
| 351 | .reflect_input = false, | 339 | .reflect_input = false, |
| ... | @@ -353,7 +341,7 @@ pub const Crc12Cdma2000 = Crc(u12, .{ | ... | @@ -353,7 +341,7 @@ pub const Crc12Cdma2000 = Crc(u12, .{ |
| 353 | .xor_output = 0x000, | 341 | .xor_output = 0x000, |
| 354 | }); | 342 | }); |
| 355 | | 343 | |
| 356 | pub const Crc12Dect = Crc(u12, .{ | 344 | pub const Crc12Dect = Generic(u12, .{ |
| 357 | .polynomial = 0x80f, | 345 | .polynomial = 0x80f, |
| 358 | .initial = 0x000, | 346 | .initial = 0x000, |
| 359 | .reflect_input = false, | 347 | .reflect_input = false, |
| ... | @@ -361,7 +349,7 @@ pub const Crc12Dect = Crc(u12, .{ | ... | @@ -361,7 +349,7 @@ pub const Crc12Dect = Crc(u12, .{ |
| 361 | .xor_output = 0x000, | 349 | .xor_output = 0x000, |
| 362 | }); | 350 | }); |
| 363 | | 351 | |
| 364 | pub const Crc12Gsm = Crc(u12, .{ | 352 | pub const Crc12Gsm = Generic(u12, .{ |
| 365 | .polynomial = 0xd31, | 353 | .polynomial = 0xd31, |
| 366 | .initial = 0x000, | 354 | .initial = 0x000, |
| 367 | .reflect_input = false, | 355 | .reflect_input = false, |
| ... | @@ -369,7 +357,7 @@ pub const Crc12Gsm = Crc(u12, .{ | ... | @@ -369,7 +357,7 @@ pub const Crc12Gsm = Crc(u12, .{ |
| 369 | .xor_output = 0xfff, | 357 | .xor_output = 0xfff, |
| 370 | }); | 358 | }); |
| 371 | | 359 | |
| 372 | pub const Crc12Umts = Crc(u12, .{ | 360 | pub const Crc12Umts = Generic(u12, .{ |
| 373 | .polynomial = 0x80f, | 361 | .polynomial = 0x80f, |
| 374 | .initial = 0x000, | 362 | .initial = 0x000, |
| 375 | .reflect_input = false, | 363 | .reflect_input = false, |
| ... | @@ -377,7 +365,7 @@ pub const Crc12Umts = Crc(u12, .{ | ... | @@ -377,7 +365,7 @@ pub const Crc12Umts = Crc(u12, .{ |
| 377 | .xor_output = 0x000, | 365 | .xor_output = 0x000, |
| 378 | }); | 366 | }); |
| 379 | | 367 | |
| 380 | pub const Crc13Bbc = Crc(u13, .{ | 368 | pub const Crc13Bbc = Generic(u13, .{ |
| 381 | .polynomial = 0x1cf5, | 369 | .polynomial = 0x1cf5, |
| 382 | .initial = 0x0000, | 370 | .initial = 0x0000, |
| 383 | .reflect_input = false, | 371 | .reflect_input = false, |
| ... | @@ -385,7 +373,7 @@ pub const Crc13Bbc = Crc(u13, .{ | ... | @@ -385,7 +373,7 @@ pub const Crc13Bbc = Crc(u13, .{ |
| 385 | .xor_output = 0x0000, | 373 | .xor_output = 0x0000, |
| 386 | }); | 374 | }); |
| 387 | | 375 | |
| 388 | pub const Crc14Darc = Crc(u14, .{ | 376 | pub const Crc14Darc = Generic(u14, .{ |
| 389 | .polynomial = 0x0805, | 377 | .polynomial = 0x0805, |
| 390 | .initial = 0x0000, | 378 | .initial = 0x0000, |
| 391 | .reflect_input = true, | 379 | .reflect_input = true, |
| ... | @@ -393,7 +381,7 @@ pub const Crc14Darc = Crc(u14, .{ | ... | @@ -393,7 +381,7 @@ pub const Crc14Darc = Crc(u14, .{ |
| 393 | .xor_output = 0x0000, | 381 | .xor_output = 0x0000, |
| 394 | }); | 382 | }); |
| 395 | | 383 | |
| 396 | pub const Crc14Gsm = Crc(u14, .{ | 384 | pub const Crc14Gsm = Generic(u14, .{ |
| 397 | .polynomial = 0x202d, | 385 | .polynomial = 0x202d, |
| 398 | .initial = 0x0000, | 386 | .initial = 0x0000, |
| 399 | .reflect_input = false, | 387 | .reflect_input = false, |
| ... | @@ -401,7 +389,7 @@ pub const Crc14Gsm = Crc(u14, .{ | ... | @@ -401,7 +389,7 @@ pub const Crc14Gsm = Crc(u14, .{ |
| 401 | .xor_output = 0x3fff, | 389 | .xor_output = 0x3fff, |
| 402 | }); | 390 | }); |
| 403 | | 391 | |
| 404 | pub const Crc15Can = Crc(u15, .{ | 392 | pub const Crc15Can = Generic(u15, .{ |
| 405 | .polynomial = 0x4599, | 393 | .polynomial = 0x4599, |
| 406 | .initial = 0x0000, | 394 | .initial = 0x0000, |
| 407 | .reflect_input = false, | 395 | .reflect_input = false, |
| ... | @@ -409,7 +397,7 @@ pub const Crc15Can = Crc(u15, .{ | ... | @@ -409,7 +397,7 @@ pub const Crc15Can = Crc(u15, .{ |
| 409 | .xor_output = 0x0000, | 397 | .xor_output = 0x0000, |
| 410 | }); | 398 | }); |
| 411 | | 399 | |
| 412 | pub const Crc15Mpt1327 = Crc(u15, .{ | 400 | pub const Crc15Mpt1327 = Generic(u15, .{ |
| 413 | .polynomial = 0x6815, | 401 | .polynomial = 0x6815, |
| 414 | .initial = 0x0000, | 402 | .initial = 0x0000, |
| 415 | .reflect_input = false, | 403 | .reflect_input = false, |
| ... | @@ -417,7 +405,7 @@ pub const Crc15Mpt1327 = Crc(u15, .{ | ... | @@ -417,7 +405,7 @@ pub const Crc15Mpt1327 = Crc(u15, .{ |
| 417 | .xor_output = 0x0001, | 405 | .xor_output = 0x0001, |
| 418 | }); | 406 | }); |
| 419 | | 407 | |
| 420 | pub const Crc16Arc = Crc(u16, .{ | 408 | pub const Crc16Arc = Generic(u16, .{ |
| 421 | .polynomial = 0x8005, | 409 | .polynomial = 0x8005, |
| 422 | .initial = 0x0000, | 410 | .initial = 0x0000, |
| 423 | .reflect_input = true, | 411 | .reflect_input = true, |
| ... | @@ -425,7 +413,7 @@ pub const Crc16Arc = Crc(u16, .{ | ... | @@ -425,7 +413,7 @@ pub const Crc16Arc = Crc(u16, .{ |
| 425 | .xor_output = 0x0000, | 413 | .xor_output = 0x0000, |
| 426 | }); | 414 | }); |
| 427 | | 415 | |
| 428 | pub const Crc16Cdma2000 = Crc(u16, .{ | 416 | pub const Crc16Cdma2000 = Generic(u16, .{ |
| 429 | .polynomial = 0xc867, | 417 | .polynomial = 0xc867, |
| 430 | .initial = 0xffff, | 418 | .initial = 0xffff, |
| 431 | .reflect_input = false, | 419 | .reflect_input = false, |
| ... | @@ -433,7 +421,7 @@ pub const Crc16Cdma2000 = Crc(u16, .{ | ... | @@ -433,7 +421,7 @@ pub const Crc16Cdma2000 = Crc(u16, .{ |
| 433 | .xor_output = 0x0000, | 421 | .xor_output = 0x0000, |
| 434 | }); | 422 | }); |
| 435 | | 423 | |
| 436 | pub const Crc16Cms = Crc(u16, .{ | 424 | pub const Crc16Cms = Generic(u16, .{ |
| 437 | .polynomial = 0x8005, | 425 | .polynomial = 0x8005, |
| 438 | .initial = 0xffff, | 426 | .initial = 0xffff, |
| 439 | .reflect_input = false, | 427 | .reflect_input = false, |
| ... | @@ -441,7 +429,7 @@ pub const Crc16Cms = Crc(u16, .{ | ... | @@ -441,7 +429,7 @@ pub const Crc16Cms = Crc(u16, .{ |
| 441 | .xor_output = 0x0000, | 429 | .xor_output = 0x0000, |
| 442 | }); | 430 | }); |
| 443 | | 431 | |
| 444 | pub const Crc16Dds110 = Crc(u16, .{ | 432 | pub const Crc16Dds110 = Generic(u16, .{ |
| 445 | .polynomial = 0x8005, | 433 | .polynomial = 0x8005, |
| 446 | .initial = 0x800d, | 434 | .initial = 0x800d, |
| 447 | .reflect_input = false, | 435 | .reflect_input = false, |
| ... | @@ -449,7 +437,7 @@ pub const Crc16Dds110 = Crc(u16, .{ | ... | @@ -449,7 +437,7 @@ pub const Crc16Dds110 = Crc(u16, .{ |
| 449 | .xor_output = 0x0000, | 437 | .xor_output = 0x0000, |
| 450 | }); | 438 | }); |
| 451 | | 439 | |
| 452 | pub const Crc16DectR = Crc(u16, .{ | 440 | pub const Crc16DectR = Generic(u16, .{ |
| 453 | .polynomial = 0x0589, | 441 | .polynomial = 0x0589, |
| 454 | .initial = 0x0000, | 442 | .initial = 0x0000, |
| 455 | .reflect_input = false, | 443 | .reflect_input = false, |
| ... | @@ -457,7 +445,7 @@ pub const Crc16DectR = Crc(u16, .{ | ... | @@ -457,7 +445,7 @@ pub const Crc16DectR = Crc(u16, .{ |
| 457 | .xor_output = 0x0001, | 445 | .xor_output = 0x0001, |
| 458 | }); | 446 | }); |
| 459 | | 447 | |
| 460 | pub const Crc16DectX = Crc(u16, .{ | 448 | pub const Crc16DectX = Generic(u16, .{ |
| 461 | .polynomial = 0x0589, | 449 | .polynomial = 0x0589, |
| 462 | .initial = 0x0000, | 450 | .initial = 0x0000, |
| 463 | .reflect_input = false, | 451 | .reflect_input = false, |
| ... | @@ -465,7 +453,7 @@ pub const Crc16DectX = Crc(u16, .{ | ... | @@ -465,7 +453,7 @@ pub const Crc16DectX = Crc(u16, .{ |
| 465 | .xor_output = 0x0000, | 453 | .xor_output = 0x0000, |
| 466 | }); | 454 | }); |
| 467 | | 455 | |
| 468 | pub const Crc16Dnp = Crc(u16, .{ | 456 | pub const Crc16Dnp = Generic(u16, .{ |
| 469 | .polynomial = 0x3d65, | 457 | .polynomial = 0x3d65, |
| 470 | .initial = 0x0000, | 458 | .initial = 0x0000, |
| 471 | .reflect_input = true, | 459 | .reflect_input = true, |
| ... | @@ -473,7 +461,7 @@ pub const Crc16Dnp = Crc(u16, .{ | ... | @@ -473,7 +461,7 @@ pub const Crc16Dnp = Crc(u16, .{ |
| 473 | .xor_output = 0xffff, | 461 | .xor_output = 0xffff, |
| 474 | }); | 462 | }); |
| 475 | | 463 | |
| 476 | pub const Crc16En13757 = Crc(u16, .{ | 464 | pub const Crc16En13757 = Generic(u16, .{ |
| 477 | .polynomial = 0x3d65, | 465 | .polynomial = 0x3d65, |
| 478 | .initial = 0x0000, | 466 | .initial = 0x0000, |
| 479 | .reflect_input = false, | 467 | .reflect_input = false, |
| ... | @@ -481,7 +469,7 @@ pub const Crc16En13757 = Crc(u16, .{ | ... | @@ -481,7 +469,7 @@ pub const Crc16En13757 = Crc(u16, .{ |
| 481 | .xor_output = 0xffff, | 469 | .xor_output = 0xffff, |
| 482 | }); | 470 | }); |
| 483 | | 471 | |
| 484 | pub const Crc16Genibus = Crc(u16, .{ | 472 | pub const Crc16Genibus = Generic(u16, .{ |
| 485 | .polynomial = 0x1021, | 473 | .polynomial = 0x1021, |
| 486 | .initial = 0xffff, | 474 | .initial = 0xffff, |
| 487 | .reflect_input = false, | 475 | .reflect_input = false, |
| ... | @@ -489,7 +477,7 @@ pub const Crc16Genibus = Crc(u16, .{ | ... | @@ -489,7 +477,7 @@ pub const Crc16Genibus = Crc(u16, .{ |
| 489 | .xor_output = 0xffff, | 477 | .xor_output = 0xffff, |
| 490 | }); | 478 | }); |
| 491 | | 479 | |
| 492 | pub const Crc16Gsm = Crc(u16, .{ | 480 | pub const Crc16Gsm = Generic(u16, .{ |
| 493 | .polynomial = 0x1021, | 481 | .polynomial = 0x1021, |
| 494 | .initial = 0x0000, | 482 | .initial = 0x0000, |
| 495 | .reflect_input = false, | 483 | .reflect_input = false, |
| ... | @@ -497,7 +485,7 @@ pub const Crc16Gsm = Crc(u16, .{ | ... | @@ -497,7 +485,7 @@ pub const Crc16Gsm = Crc(u16, .{ |
| 497 | .xor_output = 0xffff, | 485 | .xor_output = 0xffff, |
| 498 | }); | 486 | }); |
| 499 | | 487 | |
| 500 | pub const Crc16Ibm3740 = Crc(u16, .{ | 488 | pub const Crc16Ibm3740 = Generic(u16, .{ |
| 501 | .polynomial = 0x1021, | 489 | .polynomial = 0x1021, |
| 502 | .initial = 0xffff, | 490 | .initial = 0xffff, |
| 503 | .reflect_input = false, | 491 | .reflect_input = false, |
| ... | @@ -505,7 +493,7 @@ pub const Crc16Ibm3740 = Crc(u16, .{ | ... | @@ -505,7 +493,7 @@ pub const Crc16Ibm3740 = Crc(u16, .{ |
| 505 | .xor_output = 0x0000, | 493 | .xor_output = 0x0000, |
| 506 | }); | 494 | }); |
| 507 | | 495 | |
| 508 | pub const Crc16IbmSdlc = Crc(u16, .{ | 496 | pub const Crc16IbmSdlc = Generic(u16, .{ |
| 509 | .polynomial = 0x1021, | 497 | .polynomial = 0x1021, |
| 510 | .initial = 0xffff, | 498 | .initial = 0xffff, |
| 511 | .reflect_input = true, | 499 | .reflect_input = true, |
| ... | @@ -513,7 +501,7 @@ pub const Crc16IbmSdlc = Crc(u16, .{ | ... | @@ -513,7 +501,7 @@ pub const Crc16IbmSdlc = Crc(u16, .{ |
| 513 | .xor_output = 0xffff, | 501 | .xor_output = 0xffff, |
| 514 | }); | 502 | }); |
| 515 | | 503 | |
| 516 | pub const Crc16IsoIec144433A = Crc(u16, .{ | 504 | pub const Crc16IsoIec144433A = Generic(u16, .{ |
| 517 | .polynomial = 0x1021, | 505 | .polynomial = 0x1021, |
| 518 | .initial = 0xc6c6, | 506 | .initial = 0xc6c6, |
| 519 | .reflect_input = true, | 507 | .reflect_input = true, |
| ... | @@ -521,7 +509,7 @@ pub const Crc16IsoIec144433A = Crc(u16, .{ | ... | @@ -521,7 +509,7 @@ pub const Crc16IsoIec144433A = Crc(u16, .{ |
| 521 | .xor_output = 0x0000, | 509 | .xor_output = 0x0000, |
| 522 | }); | 510 | }); |
| 523 | | 511 | |
| 524 | pub const Crc16Kermit = Crc(u16, .{ | 512 | pub const Crc16Kermit = Generic(u16, .{ |
| 525 | .polynomial = 0x1021, | 513 | .polynomial = 0x1021, |
| 526 | .initial = 0x0000, | 514 | .initial = 0x0000, |
| 527 | .reflect_input = true, | 515 | .reflect_input = true, |
| ... | @@ -529,7 +517,7 @@ pub const Crc16Kermit = Crc(u16, .{ | ... | @@ -529,7 +517,7 @@ pub const Crc16Kermit = Crc(u16, .{ |
| 529 | .xor_output = 0x0000, | 517 | .xor_output = 0x0000, |
| 530 | }); | 518 | }); |
| 531 | | 519 | |
| 532 | pub const Crc16Lj1200 = Crc(u16, .{ | 520 | pub const Crc16Lj1200 = Generic(u16, .{ |
| 533 | .polynomial = 0x6f63, | 521 | .polynomial = 0x6f63, |
| 534 | .initial = 0x0000, | 522 | .initial = 0x0000, |
| 535 | .reflect_input = false, | 523 | .reflect_input = false, |
| ... | @@ -537,7 +525,7 @@ pub const Crc16Lj1200 = Crc(u16, .{ | ... | @@ -537,7 +525,7 @@ pub const Crc16Lj1200 = Crc(u16, .{ |
| 537 | .xor_output = 0x0000, | 525 | .xor_output = 0x0000, |
| 538 | }); | 526 | }); |
| 539 | | 527 | |
| 540 | pub const Crc16M17 = Crc(u16, .{ | 528 | pub const Crc16M17 = Generic(u16, .{ |
| 541 | .polynomial = 0x5935, | 529 | .polynomial = 0x5935, |
| 542 | .initial = 0xffff, | 530 | .initial = 0xffff, |
| 543 | .reflect_input = false, | 531 | .reflect_input = false, |
| ... | @@ -545,7 +533,7 @@ pub const Crc16M17 = Crc(u16, .{ | ... | @@ -545,7 +533,7 @@ pub const Crc16M17 = Crc(u16, .{ |
| 545 | .xor_output = 0x0000, | 533 | .xor_output = 0x0000, |
| 546 | }); | 534 | }); |
| 547 | | 535 | |
| 548 | pub const Crc16MaximDow = Crc(u16, .{ | 536 | pub const Crc16MaximDow = Generic(u16, .{ |
| 549 | .polynomial = 0x8005, | 537 | .polynomial = 0x8005, |
| 550 | .initial = 0x0000, | 538 | .initial = 0x0000, |
| 551 | .reflect_input = true, | 539 | .reflect_input = true, |
| ... | @@ -553,7 +541,7 @@ pub const Crc16MaximDow = Crc(u16, .{ | ... | @@ -553,7 +541,7 @@ pub const Crc16MaximDow = Crc(u16, .{ |
| 553 | .xor_output = 0xffff, | 541 | .xor_output = 0xffff, |
| 554 | }); | 542 | }); |
| 555 | | 543 | |
| 556 | pub const Crc16Mcrf4xx = Crc(u16, .{ | 544 | pub const Crc16Mcrf4xx = Generic(u16, .{ |
| 557 | .polynomial = 0x1021, | 545 | .polynomial = 0x1021, |
| 558 | .initial = 0xffff, | 546 | .initial = 0xffff, |
| 559 | .reflect_input = true, | 547 | .reflect_input = true, |
| ... | @@ -561,7 +549,7 @@ pub const Crc16Mcrf4xx = Crc(u16, .{ | ... | @@ -561,7 +549,7 @@ pub const Crc16Mcrf4xx = Crc(u16, .{ |
| 561 | .xor_output = 0x0000, | 549 | .xor_output = 0x0000, |
| 562 | }); | 550 | }); |
| 563 | | 551 | |
| 564 | pub const Crc16Modbus = Crc(u16, .{ | 552 | pub const Crc16Modbus = Generic(u16, .{ |
| 565 | .polynomial = 0x8005, | 553 | .polynomial = 0x8005, |
| 566 | .initial = 0xffff, | 554 | .initial = 0xffff, |
| 567 | .reflect_input = true, | 555 | .reflect_input = true, |
| ... | @@ -569,7 +557,7 @@ pub const Crc16Modbus = Crc(u16, .{ | ... | @@ -569,7 +557,7 @@ pub const Crc16Modbus = Crc(u16, .{ |
| 569 | .xor_output = 0x0000, | 557 | .xor_output = 0x0000, |
| 570 | }); | 558 | }); |
| 571 | | 559 | |
| 572 | pub const Crc16Nrsc5 = Crc(u16, .{ | 560 | pub const Crc16Nrsc5 = Generic(u16, .{ |
| 573 | .polynomial = 0x080b, | 561 | .polynomial = 0x080b, |
| 574 | .initial = 0xffff, | 562 | .initial = 0xffff, |
| 575 | .reflect_input = true, | 563 | .reflect_input = true, |
| ... | @@ -577,7 +565,7 @@ pub const Crc16Nrsc5 = Crc(u16, .{ | ... | @@ -577,7 +565,7 @@ pub const Crc16Nrsc5 = Crc(u16, .{ |
| 577 | .xor_output = 0x0000, | 565 | .xor_output = 0x0000, |
| 578 | }); | 566 | }); |
| 579 | | 567 | |
| 580 | pub const Crc16OpensafetyA = Crc(u16, .{ | 568 | pub const Crc16OpensafetyA = Generic(u16, .{ |
| 581 | .polynomial = 0x5935, | 569 | .polynomial = 0x5935, |
| 582 | .initial = 0x0000, | 570 | .initial = 0x0000, |
| 583 | .reflect_input = false, | 571 | .reflect_input = false, |
| ... | @@ -585,7 +573,7 @@ pub const Crc16OpensafetyA = Crc(u16, .{ | ... | @@ -585,7 +573,7 @@ pub const Crc16OpensafetyA = Crc(u16, .{ |
| 585 | .xor_output = 0x0000, | 573 | .xor_output = 0x0000, |
| 586 | }); | 574 | }); |
| 587 | | 575 | |
| 588 | pub const Crc16OpensafetyB = Crc(u16, .{ | 576 | pub const Crc16OpensafetyB = Generic(u16, .{ |
| 589 | .polynomial = 0x755b, | 577 | .polynomial = 0x755b, |
| 590 | .initial = 0x0000, | 578 | .initial = 0x0000, |
| 591 | .reflect_input = false, | 579 | .reflect_input = false, |
| ... | @@ -593,7 +581,7 @@ pub const Crc16OpensafetyB = Crc(u16, .{ | ... | @@ -593,7 +581,7 @@ pub const Crc16OpensafetyB = Crc(u16, .{ |
| 593 | .xor_output = 0x0000, | 581 | .xor_output = 0x0000, |
| 594 | }); | 582 | }); |
| 595 | | 583 | |
| 596 | pub const Crc16Profibus = Crc(u16, .{ | 584 | pub const Crc16Profibus = Generic(u16, .{ |
| 597 | .polynomial = 0x1dcf, | 585 | .polynomial = 0x1dcf, |
| 598 | .initial = 0xffff, | 586 | .initial = 0xffff, |
| 599 | .reflect_input = false, | 587 | .reflect_input = false, |
| ... | @@ -601,7 +589,7 @@ pub const Crc16Profibus = Crc(u16, .{ | ... | @@ -601,7 +589,7 @@ pub const Crc16Profibus = Crc(u16, .{ |
| 601 | .xor_output = 0xffff, | 589 | .xor_output = 0xffff, |
| 602 | }); | 590 | }); |
| 603 | | 591 | |
| 604 | pub const Crc16Riello = Crc(u16, .{ | 592 | pub const Crc16Riello = Generic(u16, .{ |
| 605 | .polynomial = 0x1021, | 593 | .polynomial = 0x1021, |
| 606 | .initial = 0xb2aa, | 594 | .initial = 0xb2aa, |
| 607 | .reflect_input = true, | 595 | .reflect_input = true, |
| ... | @@ -609,7 +597,7 @@ pub const Crc16Riello = Crc(u16, .{ | ... | @@ -609,7 +597,7 @@ pub const Crc16Riello = Crc(u16, .{ |
| 609 | .xor_output = 0x0000, | 597 | .xor_output = 0x0000, |
| 610 | }); | 598 | }); |
| 611 | | 599 | |
| 612 | pub const Crc16SpiFujitsu = Crc(u16, .{ | 600 | pub const Crc16SpiFujitsu = Generic(u16, .{ |
| 613 | .polynomial = 0x1021, | 601 | .polynomial = 0x1021, |
| 614 | .initial = 0x1d0f, | 602 | .initial = 0x1d0f, |
| 615 | .reflect_input = false, | 603 | .reflect_input = false, |
| ... | @@ -617,7 +605,7 @@ pub const Crc16SpiFujitsu = Crc(u16, .{ | ... | @@ -617,7 +605,7 @@ pub const Crc16SpiFujitsu = Crc(u16, .{ |
| 617 | .xor_output = 0x0000, | 605 | .xor_output = 0x0000, |
| 618 | }); | 606 | }); |
| 619 | | 607 | |
| 620 | pub const Crc16T10Dif = Crc(u16, .{ | 608 | pub const Crc16T10Dif = Generic(u16, .{ |
| 621 | .polynomial = 0x8bb7, | 609 | .polynomial = 0x8bb7, |
| 622 | .initial = 0x0000, | 610 | .initial = 0x0000, |
| 623 | .reflect_input = false, | 611 | .reflect_input = false, |
| ... | @@ -625,7 +613,7 @@ pub const Crc16T10Dif = Crc(u16, .{ | ... | @@ -625,7 +613,7 @@ pub const Crc16T10Dif = Crc(u16, .{ |
| 625 | .xor_output = 0x0000, | 613 | .xor_output = 0x0000, |
| 626 | }); | 614 | }); |
| 627 | | 615 | |
| 628 | pub const Crc16Teledisk = Crc(u16, .{ | 616 | pub const Crc16Teledisk = Generic(u16, .{ |
| 629 | .polynomial = 0xa097, | 617 | .polynomial = 0xa097, |
| 630 | .initial = 0x0000, | 618 | .initial = 0x0000, |
| 631 | .reflect_input = false, | 619 | .reflect_input = false, |
| ... | @@ -633,7 +621,7 @@ pub const Crc16Teledisk = Crc(u16, .{ | ... | @@ -633,7 +621,7 @@ pub const Crc16Teledisk = Crc(u16, .{ |
| 633 | .xor_output = 0x0000, | 621 | .xor_output = 0x0000, |
| 634 | }); | 622 | }); |
| 635 | | 623 | |
| 636 | pub const Crc16Tms37157 = Crc(u16, .{ | 624 | pub const Crc16Tms37157 = Generic(u16, .{ |
| 637 | .polynomial = 0x1021, | 625 | .polynomial = 0x1021, |
| 638 | .initial = 0x89ec, | 626 | .initial = 0x89ec, |
| 639 | .reflect_input = true, | 627 | .reflect_input = true, |
| ... | @@ -641,7 +629,7 @@ pub const Crc16Tms37157 = Crc(u16, .{ | ... | @@ -641,7 +629,7 @@ pub const Crc16Tms37157 = Crc(u16, .{ |
| 641 | .xor_output = 0x0000, | 629 | .xor_output = 0x0000, |
| 642 | }); | 630 | }); |
| 643 | | 631 | |
| 644 | pub const Crc16Umts = Crc(u16, .{ | 632 | pub const Crc16Umts = Generic(u16, .{ |
| 645 | .polynomial = 0x8005, | 633 | .polynomial = 0x8005, |
| 646 | .initial = 0x0000, | 634 | .initial = 0x0000, |
| 647 | .reflect_input = false, | 635 | .reflect_input = false, |
| ... | @@ -649,7 +637,7 @@ pub const Crc16Umts = Crc(u16, .{ | ... | @@ -649,7 +637,7 @@ pub const Crc16Umts = Crc(u16, .{ |
| 649 | .xor_output = 0x0000, | 637 | .xor_output = 0x0000, |
| 650 | }); | 638 | }); |
| 651 | | 639 | |
| 652 | pub const Crc16Usb = Crc(u16, .{ | 640 | pub const Crc16Usb = Generic(u16, .{ |
| 653 | .polynomial = 0x8005, | 641 | .polynomial = 0x8005, |
| 654 | .initial = 0xffff, | 642 | .initial = 0xffff, |
| 655 | .reflect_input = true, | 643 | .reflect_input = true, |
| ... | @@ -657,7 +645,7 @@ pub const Crc16Usb = Crc(u16, .{ | ... | @@ -657,7 +645,7 @@ pub const Crc16Usb = Crc(u16, .{ |
| 657 | .xor_output = 0xffff, | 645 | .xor_output = 0xffff, |
| 658 | }); | 646 | }); |
| 659 | | 647 | |
| 660 | pub const Crc16Xmodem = Crc(u16, .{ | 648 | pub const Crc16Xmodem = Generic(u16, .{ |
| 661 | .polynomial = 0x1021, | 649 | .polynomial = 0x1021, |
| 662 | .initial = 0x0000, | 650 | .initial = 0x0000, |
| 663 | .reflect_input = false, | 651 | .reflect_input = false, |
| ... | @@ -665,7 +653,7 @@ pub const Crc16Xmodem = Crc(u16, .{ | ... | @@ -665,7 +653,7 @@ pub const Crc16Xmodem = Crc(u16, .{ |
| 665 | .xor_output = 0x0000, | 653 | .xor_output = 0x0000, |
| 666 | }); | 654 | }); |
| 667 | | 655 | |
| 668 | pub const Crc17CanFd = Crc(u17, .{ | 656 | pub const Crc17CanFd = Generic(u17, .{ |
| 669 | .polynomial = 0x1685b, | 657 | .polynomial = 0x1685b, |
| 670 | .initial = 0x00000, | 658 | .initial = 0x00000, |
| 671 | .reflect_input = false, | 659 | .reflect_input = false, |
| ... | @@ -673,7 +661,7 @@ pub const Crc17CanFd = Crc(u17, .{ | ... | @@ -673,7 +661,7 @@ pub const Crc17CanFd = Crc(u17, .{ |
| 673 | .xor_output = 0x00000, | 661 | .xor_output = 0x00000, |
| 674 | }); | 662 | }); |
| 675 | | 663 | |
| 676 | pub const Crc21CanFd = Crc(u21, .{ | 664 | pub const Crc21CanFd = Generic(u21, .{ |
| 677 | .polynomial = 0x102899, | 665 | .polynomial = 0x102899, |
| 678 | .initial = 0x000000, | 666 | .initial = 0x000000, |
| 679 | .reflect_input = false, | 667 | .reflect_input = false, |
| ... | @@ -681,7 +669,7 @@ pub const Crc21CanFd = Crc(u21, .{ | ... | @@ -681,7 +669,7 @@ pub const Crc21CanFd = Crc(u21, .{ |
| 681 | .xor_output = 0x000000, | 669 | .xor_output = 0x000000, |
| 682 | }); | 670 | }); |
| 683 | | 671 | |
| 684 | pub const Crc24Ble = Crc(u24, .{ | 672 | pub const Crc24Ble = Generic(u24, .{ |
| 685 | .polynomial = 0x00065b, | 673 | .polynomial = 0x00065b, |
| 686 | .initial = 0x555555, | 674 | .initial = 0x555555, |
| 687 | .reflect_input = true, | 675 | .reflect_input = true, |
| ... | @@ -689,7 +677,7 @@ pub const Crc24Ble = Crc(u24, .{ | ... | @@ -689,7 +677,7 @@ pub const Crc24Ble = Crc(u24, .{ |
| 689 | .xor_output = 0x000000, | 677 | .xor_output = 0x000000, |
| 690 | }); | 678 | }); |
| 691 | | 679 | |
| 692 | pub const Crc24FlexrayA = Crc(u24, .{ | 680 | pub const Crc24FlexrayA = Generic(u24, .{ |
| 693 | .polynomial = 0x5d6dcb, | 681 | .polynomial = 0x5d6dcb, |
| 694 | .initial = 0xfedcba, | 682 | .initial = 0xfedcba, |
| 695 | .reflect_input = false, | 683 | .reflect_input = false, |
| ... | @@ -697,7 +685,7 @@ pub const Crc24FlexrayA = Crc(u24, .{ | ... | @@ -697,7 +685,7 @@ pub const Crc24FlexrayA = Crc(u24, .{ |
| 697 | .xor_output = 0x000000, | 685 | .xor_output = 0x000000, |
| 698 | }); | 686 | }); |
| 699 | | 687 | |
| 700 | pub const Crc24FlexrayB = Crc(u24, .{ | 688 | pub const Crc24FlexrayB = Generic(u24, .{ |
| 701 | .polynomial = 0x5d6dcb, | 689 | .polynomial = 0x5d6dcb, |
| 702 | .initial = 0xabcdef, | 690 | .initial = 0xabcdef, |
| 703 | .reflect_input = false, | 691 | .reflect_input = false, |
| ... | @@ -705,7 +693,7 @@ pub const Crc24FlexrayB = Crc(u24, .{ | ... | @@ -705,7 +693,7 @@ pub const Crc24FlexrayB = Crc(u24, .{ |
| 705 | .xor_output = 0x000000, | 693 | .xor_output = 0x000000, |
| 706 | }); | 694 | }); |
| 707 | | 695 | |
| 708 | pub const Crc24Interlaken = Crc(u24, .{ | 696 | pub const Crc24Interlaken = Generic(u24, .{ |
| 709 | .polynomial = 0x328b63, | 697 | .polynomial = 0x328b63, |
| 710 | .initial = 0xffffff, | 698 | .initial = 0xffffff, |
| 711 | .reflect_input = false, | 699 | .reflect_input = false, |
| ... | @@ -713,7 +701,7 @@ pub const Crc24Interlaken = Crc(u24, .{ | ... | @@ -713,7 +701,7 @@ pub const Crc24Interlaken = Crc(u24, .{ |
| 713 | .xor_output = 0xffffff, | 701 | .xor_output = 0xffffff, |
| 714 | }); | 702 | }); |
| 715 | | 703 | |
| 716 | pub const Crc24LteA = Crc(u24, .{ | 704 | pub const Crc24LteA = Generic(u24, .{ |
| 717 | .polynomial = 0x864cfb, | 705 | .polynomial = 0x864cfb, |
| 718 | .initial = 0x000000, | 706 | .initial = 0x000000, |
| 719 | .reflect_input = false, | 707 | .reflect_input = false, |
| ... | @@ -721,7 +709,7 @@ pub const Crc24LteA = Crc(u24, .{ | ... | @@ -721,7 +709,7 @@ pub const Crc24LteA = Crc(u24, .{ |
| 721 | .xor_output = 0x000000, | 709 | .xor_output = 0x000000, |
| 722 | }); | 710 | }); |
| 723 | | 711 | |
| 724 | pub const Crc24LteB = Crc(u24, .{ | 712 | pub const Crc24LteB = Generic(u24, .{ |
| 725 | .polynomial = 0x800063, | 713 | .polynomial = 0x800063, |
| 726 | .initial = 0x000000, | 714 | .initial = 0x000000, |
| 727 | .reflect_input = false, | 715 | .reflect_input = false, |
| ... | @@ -729,7 +717,7 @@ pub const Crc24LteB = Crc(u24, .{ | ... | @@ -729,7 +717,7 @@ pub const Crc24LteB = Crc(u24, .{ |
| 729 | .xor_output = 0x000000, | 717 | .xor_output = 0x000000, |
| 730 | }); | 718 | }); |
| 731 | | 719 | |
| 732 | pub const Crc24Openpgp = Crc(u24, .{ | 720 | pub const Crc24Openpgp = Generic(u24, .{ |
| 733 | .polynomial = 0x864cfb, | 721 | .polynomial = 0x864cfb, |
| 734 | .initial = 0xb704ce, | 722 | .initial = 0xb704ce, |
| 735 | .reflect_input = false, | 723 | .reflect_input = false, |
| ... | @@ -737,7 +725,7 @@ pub const Crc24Openpgp = Crc(u24, .{ | ... | @@ -737,7 +725,7 @@ pub const Crc24Openpgp = Crc(u24, .{ |
| 737 | .xor_output = 0x000000, | 725 | .xor_output = 0x000000, |
| 738 | }); | 726 | }); |
| 739 | | 727 | |
| 740 | pub const Crc24Os9 = Crc(u24, .{ | 728 | pub const Crc24Os9 = Generic(u24, .{ |
| 741 | .polynomial = 0x800063, | 729 | .polynomial = 0x800063, |
| 742 | .initial = 0xffffff, | 730 | .initial = 0xffffff, |
| 743 | .reflect_input = false, | 731 | .reflect_input = false, |
| ... | @@ -745,7 +733,7 @@ pub const Crc24Os9 = Crc(u24, .{ | ... | @@ -745,7 +733,7 @@ pub const Crc24Os9 = Crc(u24, .{ |
| 745 | .xor_output = 0xffffff, | 733 | .xor_output = 0xffffff, |
| 746 | }); | 734 | }); |
| 747 | | 735 | |
| 748 | pub const Crc30Cdma = Crc(u30, .{ | 736 | pub const Crc30Cdma = Generic(u30, .{ |
| 749 | .polynomial = 0x2030b9c7, | 737 | .polynomial = 0x2030b9c7, |
| 750 | .initial = 0x3fffffff, | 738 | .initial = 0x3fffffff, |
| 751 | .reflect_input = false, | 739 | .reflect_input = false, |
| ... | @@ -753,7 +741,7 @@ pub const Crc30Cdma = Crc(u30, .{ | ... | @@ -753,7 +741,7 @@ pub const Crc30Cdma = Crc(u30, .{ |
| 753 | .xor_output = 0x3fffffff, | 741 | .xor_output = 0x3fffffff, |
| 754 | }); | 742 | }); |
| 755 | | 743 | |
| 756 | pub const Crc31Philips = Crc(u31, .{ | 744 | pub const Crc31Philips = Generic(u31, .{ |
| 757 | .polynomial = 0x04c11db7, | 745 | .polynomial = 0x04c11db7, |
| 758 | .initial = 0x7fffffff, | 746 | .initial = 0x7fffffff, |
| 759 | .reflect_input = false, | 747 | .reflect_input = false, |
| ... | @@ -761,7 +749,7 @@ pub const Crc31Philips = Crc(u31, .{ | ... | @@ -761,7 +749,7 @@ pub const Crc31Philips = Crc(u31, .{ |
| 761 | .xor_output = 0x7fffffff, | 749 | .xor_output = 0x7fffffff, |
| 762 | }); | 750 | }); |
| 763 | | 751 | |
| 764 | pub const Crc32Aixm = Crc(u32, .{ | 752 | pub const Crc32Aixm = Generic(u32, .{ |
| 765 | .polynomial = 0x814141ab, | 753 | .polynomial = 0x814141ab, |
| 766 | .initial = 0x00000000, | 754 | .initial = 0x00000000, |
| 767 | .reflect_input = false, | 755 | .reflect_input = false, |
| ... | @@ -769,7 +757,7 @@ pub const Crc32Aixm = Crc(u32, .{ | ... | @@ -769,7 +757,7 @@ pub const Crc32Aixm = Crc(u32, .{ |
| 769 | .xor_output = 0x00000000, | 757 | .xor_output = 0x00000000, |
| 770 | }); | 758 | }); |
| 771 | | 759 | |
| 772 | pub const Crc32Autosar = Crc(u32, .{ | 760 | pub const Crc32Autosar = Generic(u32, .{ |
| 773 | .polynomial = 0xf4acfb13, | 761 | .polynomial = 0xf4acfb13, |
| 774 | .initial = 0xffffffff, | 762 | .initial = 0xffffffff, |
| 775 | .reflect_input = true, | 763 | .reflect_input = true, |
| ... | @@ -777,7 +765,7 @@ pub const Crc32Autosar = Crc(u32, .{ | ... | @@ -777,7 +765,7 @@ pub const Crc32Autosar = Crc(u32, .{ |
| 777 | .xor_output = 0xffffffff, | 765 | .xor_output = 0xffffffff, |
| 778 | }); | 766 | }); |
| 779 | | 767 | |
| 780 | pub const Crc32Base91D = Crc(u32, .{ | 768 | pub const Crc32Base91D = Generic(u32, .{ |
| 781 | .polynomial = 0xa833982b, | 769 | .polynomial = 0xa833982b, |
| 782 | .initial = 0xffffffff, | 770 | .initial = 0xffffffff, |
| 783 | .reflect_input = true, | 771 | .reflect_input = true, |
| ... | @@ -785,7 +773,7 @@ pub const Crc32Base91D = Crc(u32, .{ | ... | @@ -785,7 +773,7 @@ pub const Crc32Base91D = Crc(u32, .{ |
| 785 | .xor_output = 0xffffffff, | 773 | .xor_output = 0xffffffff, |
| 786 | }); | 774 | }); |
| 787 | | 775 | |
| 788 | pub const Crc32Bzip2 = Crc(u32, .{ | 776 | pub const Crc32Bzip2 = Generic(u32, .{ |
| 789 | .polynomial = 0x04c11db7, | 777 | .polynomial = 0x04c11db7, |
| 790 | .initial = 0xffffffff, | 778 | .initial = 0xffffffff, |
| 791 | .reflect_input = false, | 779 | .reflect_input = false, |
| ... | @@ -793,7 +781,7 @@ pub const Crc32Bzip2 = Crc(u32, .{ | ... | @@ -793,7 +781,7 @@ pub const Crc32Bzip2 = Crc(u32, .{ |
| 793 | .xor_output = 0xffffffff, | 781 | .xor_output = 0xffffffff, |
| 794 | }); | 782 | }); |
| 795 | | 783 | |
| 796 | pub const Crc32CdRomEdc = Crc(u32, .{ | 784 | pub const Crc32CdRomEdc = Generic(u32, .{ |
| 797 | .polynomial = 0x8001801b, | 785 | .polynomial = 0x8001801b, |
| 798 | .initial = 0x00000000, | 786 | .initial = 0x00000000, |
| 799 | .reflect_input = true, | 787 | .reflect_input = true, |
| ... | @@ -801,7 +789,7 @@ pub const Crc32CdRomEdc = Crc(u32, .{ | ... | @@ -801,7 +789,7 @@ pub const Crc32CdRomEdc = Crc(u32, .{ |
| 801 | .xor_output = 0x00000000, | 789 | .xor_output = 0x00000000, |
| 802 | }); | 790 | }); |
| 803 | | 791 | |
| 804 | pub const Crc32Cksum = Crc(u32, .{ | 792 | pub const Crc32Cksum = Generic(u32, .{ |
| 805 | .polynomial = 0x04c11db7, | 793 | .polynomial = 0x04c11db7, |
| 806 | .initial = 0x00000000, | 794 | .initial = 0x00000000, |
| 807 | .reflect_input = false, | 795 | .reflect_input = false, |
| ... | @@ -809,7 +797,7 @@ pub const Crc32Cksum = Crc(u32, .{ | ... | @@ -809,7 +797,7 @@ pub const Crc32Cksum = Crc(u32, .{ |
| 809 | .xor_output = 0xffffffff, | 797 | .xor_output = 0xffffffff, |
| 810 | }); | 798 | }); |
| 811 | | 799 | |
| 812 | pub const Crc32IsoHdlc = Crc(u32, .{ | 800 | pub const Crc32IsoHdlc = Generic(u32, .{ |
| 813 | .polynomial = 0x04c11db7, | 801 | .polynomial = 0x04c11db7, |
| 814 | .initial = 0xffffffff, | 802 | .initial = 0xffffffff, |
| 815 | .reflect_input = true, | 803 | .reflect_input = true, |
| ... | @@ -817,7 +805,7 @@ pub const Crc32IsoHdlc = Crc(u32, .{ | ... | @@ -817,7 +805,7 @@ pub const Crc32IsoHdlc = Crc(u32, .{ |
| 817 | .xor_output = 0xffffffff, | 805 | .xor_output = 0xffffffff, |
| 818 | }); | 806 | }); |
| 819 | | 807 | |
| 820 | pub const Crc32Jamcrc = Crc(u32, .{ | 808 | pub const Crc32Jamcrc = Generic(u32, .{ |
| 821 | .polynomial = 0x04c11db7, | 809 | .polynomial = 0x04c11db7, |
| 822 | .initial = 0xffffffff, | 810 | .initial = 0xffffffff, |
| 823 | .reflect_input = true, | 811 | .reflect_input = true, |
| ... | @@ -825,7 +813,7 @@ pub const Crc32Jamcrc = Crc(u32, .{ | ... | @@ -825,7 +813,7 @@ pub const Crc32Jamcrc = Crc(u32, .{ |
| 825 | .xor_output = 0x00000000, | 813 | .xor_output = 0x00000000, |
| 826 | }); | 814 | }); |
| 827 | | 815 | |
| 828 | pub const Crc32Koopman = Crc(u32, .{ | 816 | pub const Crc32Koopman = Generic(u32, .{ |
| 829 | .polynomial = 0x741b8cd7, | 817 | .polynomial = 0x741b8cd7, |
| 830 | .initial = 0xffffffff, | 818 | .initial = 0xffffffff, |
| 831 | .reflect_input = true, | 819 | .reflect_input = true, |
| ... | @@ -833,7 +821,7 @@ pub const Crc32Koopman = Crc(u32, .{ | ... | @@ -833,7 +821,7 @@ pub const Crc32Koopman = Crc(u32, .{ |
| 833 | .xor_output = 0xffffffff, | 821 | .xor_output = 0xffffffff, |
| 834 | }); | 822 | }); |
| 835 | | 823 | |
| 836 | pub const Crc32Mef = Crc(u32, .{ | 824 | pub const Crc32Mef = Generic(u32, .{ |
| 837 | .polynomial = 0x741b8cd7, | 825 | .polynomial = 0x741b8cd7, |
| 838 | .initial = 0xffffffff, | 826 | .initial = 0xffffffff, |
| 839 | .reflect_input = true, | 827 | .reflect_input = true, |
| ... | @@ -841,7 +829,7 @@ pub const Crc32Mef = Crc(u32, .{ | ... | @@ -841,7 +829,7 @@ pub const Crc32Mef = Crc(u32, .{ |
| 841 | .xor_output = 0x00000000, | 829 | .xor_output = 0x00000000, |
| 842 | }); | 830 | }); |
| 843 | | 831 | |
| 844 | pub const Crc32Mpeg2 = Crc(u32, .{ | 832 | pub const Crc32Mpeg2 = Generic(u32, .{ |
| 845 | .polynomial = 0x04c11db7, | 833 | .polynomial = 0x04c11db7, |
| 846 | .initial = 0xffffffff, | 834 | .initial = 0xffffffff, |
| 847 | .reflect_input = false, | 835 | .reflect_input = false, |
| ... | @@ -849,7 +837,7 @@ pub const Crc32Mpeg2 = Crc(u32, .{ | ... | @@ -849,7 +837,7 @@ pub const Crc32Mpeg2 = Crc(u32, .{ |
| 849 | .xor_output = 0x00000000, | 837 | .xor_output = 0x00000000, |
| 850 | }); | 838 | }); |
| 851 | | 839 | |
| 852 | pub const Crc32Xfer = Crc(u32, .{ | 840 | pub const Crc32Xfer = Generic(u32, .{ |
| 853 | .polynomial = 0x000000af, | 841 | .polynomial = 0x000000af, |
| 854 | .initial = 0x00000000, | 842 | .initial = 0x00000000, |
| 855 | .reflect_input = false, | 843 | .reflect_input = false, |
| ... | @@ -857,7 +845,7 @@ pub const Crc32Xfer = Crc(u32, .{ | ... | @@ -857,7 +845,7 @@ pub const Crc32Xfer = Crc(u32, .{ |
| 857 | .xor_output = 0x00000000, | 845 | .xor_output = 0x00000000, |
| 858 | }); | 846 | }); |
| 859 | | 847 | |
| 860 | pub const Crc40Gsm = Crc(u40, .{ | 848 | pub const Crc40Gsm = Generic(u40, .{ |
| 861 | .polynomial = 0x0004820009, | 849 | .polynomial = 0x0004820009, |
| 862 | .initial = 0x0000000000, | 850 | .initial = 0x0000000000, |
| 863 | .reflect_input = false, | 851 | .reflect_input = false, |
| ... | @@ -865,7 +853,7 @@ pub const Crc40Gsm = Crc(u40, .{ | ... | @@ -865,7 +853,7 @@ pub const Crc40Gsm = Crc(u40, .{ |
| 865 | .xor_output = 0xffffffffff, | 853 | .xor_output = 0xffffffffff, |
| 866 | }); | 854 | }); |
| 867 | | 855 | |
| 868 | pub const Crc64Ecma182 = Crc(u64, .{ | 856 | pub const Crc64Ecma182 = Generic(u64, .{ |
| 869 | .polynomial = 0x42f0e1eba9ea3693, | 857 | .polynomial = 0x42f0e1eba9ea3693, |
| 870 | .initial = 0x0000000000000000, | 858 | .initial = 0x0000000000000000, |
| 871 | .reflect_input = false, | 859 | .reflect_input = false, |
| ... | @@ -873,7 +861,7 @@ pub const Crc64Ecma182 = Crc(u64, .{ | ... | @@ -873,7 +861,7 @@ pub const Crc64Ecma182 = Crc(u64, .{ |
| 873 | .xor_output = 0x0000000000000000, | 861 | .xor_output = 0x0000000000000000, |
| 874 | }); | 862 | }); |
| 875 | | 863 | |
| 876 | pub const Crc64GoIso = Crc(u64, .{ | 864 | pub const Crc64GoIso = Generic(u64, .{ |
| 877 | .polynomial = 0x000000000000001b, | 865 | .polynomial = 0x000000000000001b, |
| 878 | .initial = 0xffffffffffffffff, | 866 | .initial = 0xffffffffffffffff, |
| 879 | .reflect_input = true, | 867 | .reflect_input = true, |
| ... | @@ -881,7 +869,7 @@ pub const Crc64GoIso = Crc(u64, .{ | ... | @@ -881,7 +869,7 @@ pub const Crc64GoIso = Crc(u64, .{ |
| 881 | .xor_output = 0xffffffffffffffff, | 869 | .xor_output = 0xffffffffffffffff, |
| 882 | }); | 870 | }); |
| 883 | | 871 | |
| 884 | pub const Crc64Ms = Crc(u64, .{ | 872 | pub const Crc64Ms = Generic(u64, .{ |
| 885 | .polynomial = 0x259c84cba6426349, | 873 | .polynomial = 0x259c84cba6426349, |
| 886 | .initial = 0xffffffffffffffff, | 874 | .initial = 0xffffffffffffffff, |
| 887 | .reflect_input = true, | 875 | .reflect_input = true, |
| ... | @@ -889,7 +877,7 @@ pub const Crc64Ms = Crc(u64, .{ | ... | @@ -889,7 +877,7 @@ pub const Crc64Ms = Crc(u64, .{ |
| 889 | .xor_output = 0x0000000000000000, | 877 | .xor_output = 0x0000000000000000, |
| 890 | }); | 878 | }); |
| 891 | | 879 | |
| 892 | pub const Crc64Redis = Crc(u64, .{ | 880 | pub const Crc64Redis = Generic(u64, .{ |
| 893 | .polynomial = 0xad93d23594c935a9, | 881 | .polynomial = 0xad93d23594c935a9, |
| 894 | .initial = 0x0000000000000000, | 882 | .initial = 0x0000000000000000, |
| 895 | .reflect_input = true, | 883 | .reflect_input = true, |
| ... | @@ -897,7 +885,7 @@ pub const Crc64Redis = Crc(u64, .{ | ... | @@ -897,7 +885,7 @@ pub const Crc64Redis = Crc(u64, .{ |
| 897 | .xor_output = 0x0000000000000000, | 885 | .xor_output = 0x0000000000000000, |
| 898 | }); | 886 | }); |
| 899 | | 887 | |
| 900 | pub const Crc64We = Crc(u64, .{ | 888 | pub const Crc64We = Generic(u64, .{ |
| 901 | .polynomial = 0x42f0e1eba9ea3693, | 889 | .polynomial = 0x42f0e1eba9ea3693, |
| 902 | .initial = 0xffffffffffffffff, | 890 | .initial = 0xffffffffffffffff, |
| 903 | .reflect_input = false, | 891 | .reflect_input = false, |
| ... | @@ -905,7 +893,7 @@ pub const Crc64We = Crc(u64, .{ | ... | @@ -905,7 +893,7 @@ pub const Crc64We = Crc(u64, .{ |
| 905 | .xor_output = 0xffffffffffffffff, | 893 | .xor_output = 0xffffffffffffffff, |
| 906 | }); | 894 | }); |
| 907 | | 895 | |
| 908 | pub const Crc64Xz = Crc(u64, .{ | 896 | pub const Crc64Xz = Generic(u64, .{ |
| 909 | .polynomial = 0x42f0e1eba9ea3693, | 897 | .polynomial = 0x42f0e1eba9ea3693, |
| 910 | .initial = 0xffffffffffffffff, | 898 | .initial = 0xffffffffffffffff, |
| 911 | .reflect_input = true, | 899 | .reflect_input = true, |
| ... | @@ -913,10 +901,109 @@ pub const Crc64Xz = Crc(u64, .{ | ... | @@ -913,10 +901,109 @@ pub const Crc64Xz = Crc(u64, .{ |
| 913 | .xor_output = 0xffffffffffffffff, | 901 | .xor_output = 0xffffffffffffffff, |
| 914 | }); | 902 | }); |
| 915 | | 903 | |
| 916 | pub const Crc82Darc = Crc(u82, .{ | 904 | pub const Crc82Darc = Generic(u82, .{ |
| 917 | .polynomial = 0x0308c0111011401440411, | 905 | .polynomial = 0x0308c0111011401440411, |
| 918 | .initial = 0x000000000000000000000, | 906 | .initial = 0x000000000000000000000, |
| 919 | .reflect_input = true, | 907 | .reflect_input = true, |
| 920 | .reflect_output = true, | 908 | .reflect_output = true, |
| 921 | .xor_output = 0x000000000000000000000, | 909 | .xor_output = 0x000000000000000000000, |
| 922 | }); | 910 | }); |
| | 911 | |
| | 912 | pub fn Algorithm(comptime W: type) type { |
| | 913 | return struct { |
| | 914 | polynomial: W, |
| | 915 | initial: W, |
| | 916 | reflect_input: bool, |
| | 917 | reflect_output: bool, |
| | 918 | xor_output: W, |
| | 919 | }; |
| | 920 | } |
| | 921 | |
| | 922 | pub fn Generic(comptime W: type, comptime algorithm: Algorithm(W)) type { |
| | 923 | return struct { |
| | 924 | const Self = @This(); |
| | 925 | const I = if (@bitSizeOf(W) < 8) u8 else W; |
| | 926 | const lookup_table = blk: { |
| | 927 | @setEvalBranchQuota(2500); |
| | 928 | const poly = reflect(algorithm.polynomial); |
| | 929 | var table: [256]I = undefined; |
| | 930 | for (&table, 0..) |*e, i| { |
| | 931 | var crc: I = i; |
| | 932 | if (algorithm.reflect_input) { |
| | 933 | var j: usize = 0; |
| | 934 | while (j < 8) : (j += 1) { |
| | 935 | crc = (crc >> 1) ^ ((crc & 1) * poly); |
| | 936 | } |
| | 937 | } else { |
| | 938 | crc <<= @bitSizeOf(I) - 8; |
| | 939 | var j: usize = 0; |
| | 940 | while (j < 8) : (j += 1) { |
| | 941 | crc = (crc << 1) ^ (((crc >> (@bitSizeOf(I) - 1)) & 1) * poly); |
| | 942 | } |
| | 943 | } |
| | 944 | e.* = crc; |
| | 945 | } |
| | 946 | break :blk table; |
| | 947 | }; |
| | 948 | |
| | 949 | crc: I, |
| | 950 | |
| | 951 | pub fn init() Self { |
| | 952 | const initial = reflect(algorithm.initial); |
| | 953 | return .{ .crc = initial }; |
| | 954 | } |
| | 955 | |
| | 956 | inline fn tableEntry(index: I) I { |
| | 957 | const short: u8 = @truncate(index); |
| | 958 | return lookup_table[short]; |
| | 959 | } |
| | 960 | |
| | 961 | pub fn update(self: *Self, bytes: []const u8) void { |
| | 962 | var i: usize = 0; |
| | 963 | if (@bitSizeOf(I) <= 8) { |
| | 964 | while (i < bytes.len) : (i += 1) { |
| | 965 | self.crc = tableEntry(self.crc ^ bytes[i]); |
| | 966 | } |
| | 967 | } else if (algorithm.reflect_input) { |
| | 968 | while (i < bytes.len) : (i += 1) { |
| | 969 | const table_index = self.crc ^ bytes[i]; |
| | 970 | self.crc = tableEntry(table_index) ^ (self.crc >> 8); |
| | 971 | } |
| | 972 | } else { |
| | 973 | while (i < bytes.len) : (i += 1) { |
| | 974 | const table_index = (self.crc >> (@bitSizeOf(I) - 8)) ^ bytes[i]; |
| | 975 | self.crc = tableEntry(table_index) ^ (self.crc << 8); |
| | 976 | } |
| | 977 | } |
| | 978 | } |
| | 979 | |
| | 980 | pub fn final(self: Self) W { |
| | 981 | var c = self.crc; |
| | 982 | if (algorithm.reflect_input != algorithm.reflect_output) { |
| | 983 | c = @bitReverse(c); |
| | 984 | } |
| | 985 | if (!algorithm.reflect_output) { |
| | 986 | c >>= @bitSizeOf(I) - @bitSizeOf(W); |
| | 987 | } |
| | 988 | return @intCast(c ^ algorithm.xor_output); |
| | 989 | } |
| | 990 | |
| | 991 | pub fn hash(bytes: []const u8) W { |
| | 992 | var c = Self.init(); |
| | 993 | c.update(bytes); |
| | 994 | return c.final(); |
| | 995 | } |
| | 996 | |
| | 997 | fn reflect(x: I) I { |
| | 998 | const offset = @bitSizeOf(I) - @bitSizeOf(W); |
| | 999 | if (algorithm.reflect_input) |
| | 1000 | return @bitReverse(x) >> offset |
| | 1001 | else |
| | 1002 | return x << offset; |
| | 1003 | } |
| | 1004 | }; |
| | 1005 | } |
| | 1006 | |
| | 1007 | test { |
| | 1008 | _ = @import("crc/test.zig"); |
| | 1009 | } |