========================================================================= */
(crc1, crc2, len2)
| 394 | |
| 395 | /* ========================================================================= */ |
| 396 | local uLong crc32_combine_(crc1, crc2, len2) |
| 397 | uLong crc1; |
| 398 | uLong crc2; |
| 399 | z_off64_t len2; |
| 400 | { |
| 401 | int n; |
| 402 | unsigned long row; |
| 403 | unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ |
| 404 | unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ |
| 405 | |
| 406 | /* degenerate case (also disallow negative lengths) */ |
| 407 | if (len2 <= 0) |
| 408 | return crc1; |
| 409 | |
| 410 | /* put operator for one zero bit in odd */ |
| 411 | odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ |
| 412 | row = 1; |
| 413 | for (n = 1; n < GF2_DIM; n++) |
| 414 | { |
| 415 | odd[n] = row; |
| 416 | row <<= 1; |
| 417 | } |
| 418 | |
| 419 | /* put operator for two zero bits in even */ |
| 420 | gf2_matrix_square(even, odd); |
| 421 | |
| 422 | /* put operator for four zero bits in odd */ |
| 423 | gf2_matrix_square(odd, even); |
| 424 | |
| 425 | /* apply len2 zeros to crc1 (first square will put the operator for one |
| 426 | zero byte, eight zero bits, in even) */ |
| 427 | do |
| 428 | { |
| 429 | /* apply zeros operator for this bit of len2 */ |
| 430 | gf2_matrix_square(even, odd); |
| 431 | if (len2 & 1) |
| 432 | crc1 = gf2_matrix_times(even, crc1); |
| 433 | len2 >>= 1; |
| 434 | |
| 435 | /* if no more bits set, then done */ |
| 436 | if (len2 == 0) |
| 437 | break; |
| 438 | |
| 439 | /* another iteration of the loop with odd and even swapped */ |
| 440 | gf2_matrix_square(odd, even); |
| 441 | if (len2 & 1) |
| 442 | crc1 = gf2_matrix_times(odd, crc1); |
| 443 | len2 >>= 1; |
| 444 | |
| 445 | /* if no more bits set, then done */ |
| 446 | } |
| 447 | while (len2 != 0); |
| 448 | |
| 449 | /* return combined crc */ |
| 450 | crc1 ^= crc2; |
| 451 | return crc1; |
| 452 | } |
| 453 |
no test coverage detected