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