#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "misc/util/abc_global.h"
#include "zutil.h"
#include "crc32.h"
Go to the source code of this file.
|
| local unsigned long gf2_matrix_times | OF ((unsigned long *mat, unsigned long vec)) |
| |
| local void gf2_matrix_square | OF ((unsigned long *square, unsigned long *mat)) |
| |
| local uLong | crc32_combine_ (uLong crc1, uLong crc2, z_off64_t len2) |
| |
| ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START const unsigned long FAR *ZEXPORT | get_crc_table () |
| |
| unsigned long ZEXPORT | crc32 (unsigned long crc, const unsigned char FAR *buf, uInt len) |
| |
| local unsigned long | gf2_matrix_times (unsigned long *mat, unsigned long vec) |
| |
| local void | gf2_matrix_square (unsigned long *square, unsigned long *mat) |
| |
| uLong ZEXPORT | crc32_combine (uLong crc1, uLong crc2, z_off_t len2) |
| |
| uLong ZEXPORT | crc32_combine64 (uLong crc1, uLong crc2, z_off64_t len2) |
| |
◆ DO1
| #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) |
◆ DO8
◆ GF2_DIM
| #define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ |
◆ local
◆ TBLS
◆ crc32()
Definition at line 230 of file crc32.c.
231{
232 if (buf ==
Z_NULL)
return 0UL;
233
234#ifdef DYNAMIC_CRC_TABLE
235 if (crc_table_empty)
236 make_crc_table();
237#endif
238
239#ifdef BYFOUR
240 if (sizeof(void *) == sizeof(ptrdiff_t)) {
241 u4 endian;
242
243 endian = 1;
244 if (*((unsigned char *)(&endian)))
245 return crc32_little(crc, buf, len);
246 else
247 return crc32_big(crc, buf, len);
248 }
249#endif
250 crc = crc ^ 0xffffffffUL;
251 while (len >= 8) {
253 len -= 8;
254 }
255 if (len) do {
257 } while (--len);
258 return crc ^ 0xffffffffUL;
259}
◆ crc32_combine()
Definition at line 421 of file crc32.c.
422{
424}
local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2)
◆ crc32_combine64()
◆ crc32_combine_()
Definition at line 368 of file crc32.c.
369{
370 int n;
371 unsigned long row;
374
375
376 if (len2 <= 0)
377 return crc1;
378
379
380 odd[0] = 0xedb88320UL;
381 row = 1;
382 for (n = 1; n <
GF2_DIM; n++) {
383 odd[n] = row;
384 row <<= 1;
385 }
386
387
389
390
392
393
394
395 do {
396
398 if (len2 & 1)
400 len2 >>= 1;
401
402
403 if (len2 == 0)
404 break;
405
406
408 if (len2 & 1)
410 len2 >>= 1;
411
412
413 } while (len2 != 0);
414
415
416 crc1 ^= crc2;
417 return crc1;
418}
local unsigned long gf2_matrix_times(unsigned long *mat, unsigned long vec)
local void gf2_matrix_square(unsigned long *square, unsigned long *mat)
◆ get_crc_table()
Definition at line 216 of file crc32.c.
217{
218#ifdef DYNAMIC_CRC_TABLE
219 if (crc_table_empty)
220 make_crc_table();
221#endif
223}
ABC_NAMESPACE_HEADER_START local const unsigned long FAR crc_table[TBLS][256]
◆ gf2_matrix_square()
| local void gf2_matrix_square |
( |
unsigned long * | square, |
|
|
unsigned long * | mat ) |
◆ gf2_matrix_times()
| local unsigned long gf2_matrix_times |
( |
unsigned long * | mat, |
|
|
unsigned long | vec ) |
Definition at line 344 of file crc32.c.
345{
346 unsigned long sum;
347
348 sum = 0;
349 while (vec) {
350 if (vec & 1)
351 sum ^= *mat;
352 vec >>= 1;
353 mat++;
354 }
355 return sum;
356}
◆ OF() [1/2]
◆ OF() [2/2]