Mercurial > vba-linux
annotate src/win32/7zip/7z/C/7zCrc.c @ 6:458a4f18f3cd
working on lua generation
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:48:33 -0600 |
parents | f9f4f1b99eed |
children |
rev | line source |
---|---|
rlm@1 | 1 /* 7zCrc.c -- CRC32 calculation |
rlm@1 | 2 2008-08-05 |
rlm@1 | 3 Igor Pavlov |
rlm@1 | 4 Public domain */ |
rlm@1 | 5 |
rlm@1 | 6 #include "7zCrc.h" |
rlm@1 | 7 |
rlm@1 | 8 #define kCrcPoly 0xEDB88320 |
rlm@1 | 9 UInt32 g_CrcTable[256]; |
rlm@1 | 10 |
rlm@1 | 11 void MY_FAST_CALL CrcGenerateTable(void) |
rlm@1 | 12 { |
rlm@1 | 13 UInt32 i; |
rlm@1 | 14 for (i = 0; i < 256; i++) |
rlm@1 | 15 { |
rlm@1 | 16 UInt32 r = i; |
rlm@1 | 17 int j; |
rlm@1 | 18 for (j = 0; j < 8; j++) |
rlm@1 | 19 r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); |
rlm@1 | 20 g_CrcTable[i] = r; |
rlm@1 | 21 } |
rlm@1 | 22 } |
rlm@1 | 23 |
rlm@1 | 24 UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size) |
rlm@1 | 25 { |
rlm@1 | 26 const Byte *p = (const Byte *)data; |
rlm@1 | 27 for (; size > 0 ; size--, p++) |
rlm@1 | 28 v = CRC_UPDATE_BYTE(v, *p); |
rlm@1 | 29 return v; |
rlm@1 | 30 } |
rlm@1 | 31 |
rlm@1 | 32 UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size) |
rlm@1 | 33 { |
rlm@1 | 34 return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF; |
rlm@1 | 35 } |