Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

301 lines
14 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Generic CRC functions
  4. //
  5. //=============================================================================//
  6. #include "tier0/platform.h"
  7. #include "commonmacros.h"
  8. #include "tier1/checksum_crc.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. #define CRC32_INIT_VALUE 0xFFFFFFFFUL
  12. #define CRC32_XOR_VALUE 0xFFFFFFFFUL
  13. #define NUM_BYTES 256
  14. static const CRC32_t pulCRCTable[NUM_BYTES] =
  15. {
  16. 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
  17. 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
  18. 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
  19. 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
  20. 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
  21. 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
  22. 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
  23. 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
  24. 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
  25. 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
  26. 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
  27. 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
  28. 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
  29. 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
  30. 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
  31. 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
  32. 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
  33. 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
  34. 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
  35. 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
  36. 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
  37. 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
  38. 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
  39. 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
  40. 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
  41. 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
  42. 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
  43. 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
  44. 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
  45. 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
  46. 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
  47. 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
  48. 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
  49. 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
  50. 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
  51. 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
  52. 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
  53. 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
  54. 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
  55. 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
  56. 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
  57. 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
  58. 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
  59. 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
  60. 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
  61. 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
  62. 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
  63. 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
  64. 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
  65. 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
  66. 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
  67. 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
  68. 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
  69. 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
  70. 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
  71. 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
  72. 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
  73. 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
  74. 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
  75. 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
  76. 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
  77. 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
  78. 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
  79. 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
  80. };
  81. void CRC32_Init(CRC32_t *pulCRC)
  82. {
  83. *pulCRC = CRC32_INIT_VALUE;
  84. }
  85. void CRC32_Final(CRC32_t *pulCRC)
  86. {
  87. *pulCRC ^= CRC32_XOR_VALUE;
  88. }
  89. CRC32_t CRC32_GetTableEntry( unsigned int slot )
  90. {
  91. return pulCRCTable[(unsigned char)slot];
  92. }
  93. void CRC32_ProcessBuffer(CRC32_t *pulCRC, const void *pBuffer, int nBuffer)
  94. {
  95. CRC32_t ulCrc = *pulCRC;
  96. unsigned char *pb = (unsigned char *)pBuffer;
  97. unsigned int nFront;
  98. int nMain;
  99. JustAfew:
  100. switch (nBuffer)
  101. {
  102. case 7:
  103. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  104. case 6:
  105. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  106. case 5:
  107. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  108. case 4:
  109. ulCrc ^= LittleLong( *(CRC32_t *)pb );
  110. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  111. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  112. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  113. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  114. *pulCRC = ulCrc;
  115. return;
  116. case 3:
  117. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  118. case 2:
  119. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  120. case 1:
  121. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  122. case 0:
  123. *pulCRC = ulCrc;
  124. return;
  125. }
  126. // We may need to do some alignment work up front, and at the end, so that
  127. // the main loop is aligned and only has to worry about 8 byte at a time.
  128. //
  129. // The low-order two bits of pb and nBuffer in total control the
  130. // upfront work.
  131. //
  132. nFront = ((uintp)pb) & 3;
  133. nBuffer -= nFront;
  134. switch (nFront)
  135. {
  136. case 3:
  137. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  138. case 2:
  139. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  140. case 1:
  141. ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8);
  142. }
  143. nMain = nBuffer >> 3;
  144. while (nMain--)
  145. {
  146. ulCrc ^= LittleLong( *(CRC32_t *)pb );
  147. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  148. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  149. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  150. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  151. ulCrc ^= LittleLong( *(CRC32_t *)(pb + 4) );
  152. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  153. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  154. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  155. ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8);
  156. pb += 8;
  157. }
  158. nBuffer &= 7;
  159. goto JustAfew;
  160. }
  161. //-----------------------------------------------------------------------------
  162. // CRC64
  163. //-----------------------------------------------------------------------------
  164. #define CRC64_INIT_VALUE 0xFFFFFFFFFFFFFFFFULL
  165. #define CRC64_XOR_VALUE 0xFFFFFFFFFFFFFFFFULL
  166. #define NUM_CRC64_TABLE_ENTRIES 256
  167. static const CRC64_t pCRC64Table[ NUM_CRC64_TABLE_ENTRIES ] =
  168. {
  169. /*
  170. // Uncomment this to generate and print this table.
  171. // The value 0x95AC9329AC4BC9B5ULL comes from "An Improved 64-bit Cyclic Redundancy Check for Protein Sequences" David T. Jones
  172. for ( int i = 0; i < 256; i++ )
  173. {
  174. CRC64_t part = i;
  175. for (int b = 0; b < 8; b++)
  176. {
  177. if (part & 1)
  178. part = (part >> 1) ^ 0x95AC9329AC4BC9B5ULL;
  179. else
  180. part >>= 1;
  181. }
  182. if ( i % 4 == 0 )
  183. Msg( "\n" );
  184. Msg( "0x%016llXULL, ", part );
  185. }
  186. */
  187. 0x0000000000000000ULL, 0x7AD870C830358979ULL, 0xF5B0E190606B12F2ULL, 0x8F689158505E9B8BULL,
  188. 0xC038E5739841B68FULL, 0xBAE095BBA8743FF6ULL, 0x358804E3F82AA47DULL, 0x4F50742BC81F2D04ULL,
  189. 0xAB28ECB46814FE75ULL, 0xD1F09C7C5821770CULL, 0x5E980D24087FEC87ULL, 0x24407DEC384A65FEULL,
  190. 0x6B1009C7F05548FAULL, 0x11C8790FC060C183ULL, 0x9EA0E857903E5A08ULL, 0xE478989FA00BD371ULL,
  191. 0x7D08FF3B88BE6F81ULL, 0x07D08FF3B88BE6F8ULL, 0x88B81EABE8D57D73ULL, 0xF2606E63D8E0F40AULL,
  192. 0xBD301A4810FFD90EULL, 0xC7E86A8020CA5077ULL, 0x4880FBD87094CBFCULL, 0x32588B1040A14285ULL,
  193. 0xD620138FE0AA91F4ULL, 0xACF86347D09F188DULL, 0x2390F21F80C18306ULL, 0x594882D7B0F40A7FULL,
  194. 0x1618F6FC78EB277BULL, 0x6CC0863448DEAE02ULL, 0xE3A8176C18803589ULL, 0x997067A428B5BCF0ULL,
  195. 0xFA11FE77117CDF02ULL, 0x80C98EBF2149567BULL, 0x0FA11FE77117CDF0ULL, 0x75796F2F41224489ULL,
  196. 0x3A291B04893D698DULL, 0x40F16BCCB908E0F4ULL, 0xCF99FA94E9567B7FULL, 0xB5418A5CD963F206ULL,
  197. 0x513912C379682177ULL, 0x2BE1620B495DA80EULL, 0xA489F35319033385ULL, 0xDE51839B2936BAFCULL,
  198. 0x9101F7B0E12997F8ULL, 0xEBD98778D11C1E81ULL, 0x64B116208142850AULL, 0x1E6966E8B1770C73ULL,
  199. 0x8719014C99C2B083ULL, 0xFDC17184A9F739FAULL, 0x72A9E0DCF9A9A271ULL, 0x08719014C99C2B08ULL,
  200. 0x4721E43F0183060CULL, 0x3DF994F731B68F75ULL, 0xB29105AF61E814FEULL, 0xC849756751DD9D87ULL,
  201. 0x2C31EDF8F1D64EF6ULL, 0x56E99D30C1E3C78FULL, 0xD9810C6891BD5C04ULL, 0xA3597CA0A188D57DULL,
  202. 0xEC09088B6997F879ULL, 0x96D1784359A27100ULL, 0x19B9E91B09FCEA8BULL, 0x636199D339C963F2ULL,
  203. 0xDF7ADABD7A6E2D6FULL, 0xA5A2AA754A5BA416ULL, 0x2ACA3B2D1A053F9DULL, 0x50124BE52A30B6E4ULL,
  204. 0x1F423FCEE22F9BE0ULL, 0x659A4F06D21A1299ULL, 0xEAF2DE5E82448912ULL, 0x902AAE96B271006BULL,
  205. 0x74523609127AD31AULL, 0x0E8A46C1224F5A63ULL, 0x81E2D7997211C1E8ULL, 0xFB3AA75142244891ULL,
  206. 0xB46AD37A8A3B6595ULL, 0xCEB2A3B2BA0EECECULL, 0x41DA32EAEA507767ULL, 0x3B024222DA65FE1EULL,
  207. 0xA2722586F2D042EEULL, 0xD8AA554EC2E5CB97ULL, 0x57C2C41692BB501CULL, 0x2D1AB4DEA28ED965ULL,
  208. 0x624AC0F56A91F461ULL, 0x1892B03D5AA47D18ULL, 0x97FA21650AFAE693ULL, 0xED2251AD3ACF6FEAULL,
  209. 0x095AC9329AC4BC9BULL, 0x7382B9FAAAF135E2ULL, 0xFCEA28A2FAAFAE69ULL, 0x8632586ACA9A2710ULL,
  210. 0xC9622C4102850A14ULL, 0xB3BA5C8932B0836DULL, 0x3CD2CDD162EE18E6ULL, 0x460ABD1952DB919FULL,
  211. 0x256B24CA6B12F26DULL, 0x5FB354025B277B14ULL, 0xD0DBC55A0B79E09FULL, 0xAA03B5923B4C69E6ULL,
  212. 0xE553C1B9F35344E2ULL, 0x9F8BB171C366CD9BULL, 0x10E3202993385610ULL, 0x6A3B50E1A30DDF69ULL,
  213. 0x8E43C87E03060C18ULL, 0xF49BB8B633338561ULL, 0x7BF329EE636D1EEAULL, 0x012B592653589793ULL,
  214. 0x4E7B2D0D9B47BA97ULL, 0x34A35DC5AB7233EEULL, 0xBBCBCC9DFB2CA865ULL, 0xC113BC55CB19211CULL,
  215. 0x5863DBF1E3AC9DECULL, 0x22BBAB39D3991495ULL, 0xADD33A6183C78F1EULL, 0xD70B4AA9B3F20667ULL,
  216. 0x985B3E827BED2B63ULL, 0xE2834E4A4BD8A21AULL, 0x6DEBDF121B863991ULL, 0x1733AFDA2BB3B0E8ULL,
  217. 0xF34B37458BB86399ULL, 0x8993478DBB8DEAE0ULL, 0x06FBD6D5EBD3716BULL, 0x7C23A61DDBE6F812ULL,
  218. 0x3373D23613F9D516ULL, 0x49ABA2FE23CC5C6FULL, 0xC6C333A67392C7E4ULL, 0xBC1B436E43A74E9DULL,
  219. 0x95AC9329AC4BC9B5ULL, 0xEF74E3E19C7E40CCULL, 0x601C72B9CC20DB47ULL, 0x1AC40271FC15523EULL,
  220. 0x5594765A340A7F3AULL, 0x2F4C0692043FF643ULL, 0xA02497CA54616DC8ULL, 0xDAFCE7026454E4B1ULL,
  221. 0x3E847F9DC45F37C0ULL, 0x445C0F55F46ABEB9ULL, 0xCB349E0DA4342532ULL, 0xB1ECEEC59401AC4BULL,
  222. 0xFEBC9AEE5C1E814FULL, 0x8464EA266C2B0836ULL, 0x0B0C7B7E3C7593BDULL, 0x71D40BB60C401AC4ULL,
  223. 0xE8A46C1224F5A634ULL, 0x927C1CDA14C02F4DULL, 0x1D148D82449EB4C6ULL, 0x67CCFD4A74AB3DBFULL,
  224. 0x289C8961BCB410BBULL, 0x5244F9A98C8199C2ULL, 0xDD2C68F1DCDF0249ULL, 0xA7F41839ECEA8B30ULL,
  225. 0x438C80A64CE15841ULL, 0x3954F06E7CD4D138ULL, 0xB63C61362C8A4AB3ULL, 0xCCE411FE1CBFC3CAULL,
  226. 0x83B465D5D4A0EECEULL, 0xF96C151DE49567B7ULL, 0x76048445B4CBFC3CULL, 0x0CDCF48D84FE7545ULL,
  227. 0x6FBD6D5EBD3716B7ULL, 0x15651D968D029FCEULL, 0x9A0D8CCEDD5C0445ULL, 0xE0D5FC06ED698D3CULL,
  228. 0xAF85882D2576A038ULL, 0xD55DF8E515432941ULL, 0x5A3569BD451DB2CAULL, 0x20ED197575283BB3ULL,
  229. 0xC49581EAD523E8C2ULL, 0xBE4DF122E51661BBULL, 0x3125607AB548FA30ULL, 0x4BFD10B2857D7349ULL,
  230. 0x04AD64994D625E4DULL, 0x7E7514517D57D734ULL, 0xF11D85092D094CBFULL, 0x8BC5F5C11D3CC5C6ULL,
  231. 0x12B5926535897936ULL, 0x686DE2AD05BCF04FULL, 0xE70573F555E26BC4ULL, 0x9DDD033D65D7E2BDULL,
  232. 0xD28D7716ADC8CFB9ULL, 0xA85507DE9DFD46C0ULL, 0x273D9686CDA3DD4BULL, 0x5DE5E64EFD965432ULL,
  233. 0xB99D7ED15D9D8743ULL, 0xC3450E196DA80E3AULL, 0x4C2D9F413DF695B1ULL, 0x36F5EF890DC31CC8ULL,
  234. 0x79A59BA2C5DC31CCULL, 0x037DEB6AF5E9B8B5ULL, 0x8C157A32A5B7233EULL, 0xF6CD0AFA9582AA47ULL,
  235. 0x4AD64994D625E4DAULL, 0x300E395CE6106DA3ULL, 0xBF66A804B64EF628ULL, 0xC5BED8CC867B7F51ULL,
  236. 0x8AEEACE74E645255ULL, 0xF036DC2F7E51DB2CULL, 0x7F5E4D772E0F40A7ULL, 0x05863DBF1E3AC9DEULL,
  237. 0xE1FEA520BE311AAFULL, 0x9B26D5E88E0493D6ULL, 0x144E44B0DE5A085DULL, 0x6E963478EE6F8124ULL,
  238. 0x21C640532670AC20ULL, 0x5B1E309B16452559ULL, 0xD476A1C3461BBED2ULL, 0xAEAED10B762E37ABULL,
  239. 0x37DEB6AF5E9B8B5BULL, 0x4D06C6676EAE0222ULL, 0xC26E573F3EF099A9ULL, 0xB8B627F70EC510D0ULL,
  240. 0xF7E653DCC6DA3DD4ULL, 0x8D3E2314F6EFB4ADULL, 0x0256B24CA6B12F26ULL, 0x788EC2849684A65FULL,
  241. 0x9CF65A1B368F752EULL, 0xE62E2AD306BAFC57ULL, 0x6946BB8B56E467DCULL, 0x139ECB4366D1EEA5ULL,
  242. 0x5CCEBF68AECEC3A1ULL, 0x2616CFA09EFB4AD8ULL, 0xA97E5EF8CEA5D153ULL, 0xD3A62E30FE90582AULL,
  243. 0xB0C7B7E3C7593BD8ULL, 0xCA1FC72BF76CB2A1ULL, 0x45775673A732292AULL, 0x3FAF26BB9707A053ULL,
  244. 0x70FF52905F188D57ULL, 0x0A2722586F2D042EULL, 0x854FB3003F739FA5ULL, 0xFF97C3C80F4616DCULL,
  245. 0x1BEF5B57AF4DC5ADULL, 0x61372B9F9F784CD4ULL, 0xEE5FBAC7CF26D75FULL, 0x9487CA0FFF135E26ULL,
  246. 0xDBD7BE24370C7322ULL, 0xA10FCEEC0739FA5BULL, 0x2E675FB4576761D0ULL, 0x54BF2F7C6752E8A9ULL,
  247. 0xCDCF48D84FE75459ULL, 0xB71738107FD2DD20ULL, 0x387FA9482F8C46ABULL, 0x42A7D9801FB9CFD2ULL,
  248. 0x0DF7ADABD7A6E2D6ULL, 0x772FDD63E7936BAFULL, 0xF8474C3BB7CDF024ULL, 0x829F3CF387F8795DULL,
  249. 0x66E7A46C27F3AA2CULL, 0x1C3FD4A417C62355ULL, 0x935745FC4798B8DEULL, 0xE98F353477AD31A7ULL,
  250. 0xA6DF411FBFB21CA3ULL, 0xDC0731D78F8795DAULL, 0x536FA08FDFD90E51ULL, 0x29B7D047EFEC8728ULL
  251. };
  252. void CRC64_Init( CRC64_t *pCRC )
  253. {
  254. *pCRC = CRC64_INIT_VALUE;
  255. }
  256. void CRC64_ProcessBuffer( CRC64_t *pCRC, const void *p, int len )
  257. {
  258. uint8 *pBytes = (uint8*)p;
  259. CRC64_t nCRC = *pCRC;
  260. while ( len > 0 )
  261. {
  262. nCRC = pCRC64Table[ ( nCRC ^ (*pBytes) ) & 0xff ] ^ ( nCRC >> 8 );
  263. pBytes++;
  264. len--;
  265. }
  266. *pCRC = nCRC;
  267. }
  268. void CRC64_Final( CRC64_t *pCRC )
  269. {
  270. *pCRC ^= CRC64_XOR_VALUE;
  271. }