unsigned int lzo_crc32(unsigned int c, const unsigned char* buf, unsigned int len) { unsigned int crc; #undef table #if 1 # define table lzo_crc32_table #else const unsigned int * table = lzo_crc32_table; #endif if (buf == 0) return 0; crc = (c & LZO_UINT32_C(0xffffffff)) ^ LZO_UINT32_C(0xffffffff); if (len >= 16) do { LZO_DO16(buf,0); buf += 16; len -= 16; } while (len >= 16); if (len != 0) do { LZO_DO1(buf,0); buf += 1; len -= 1; } while (len > 0); return crc ^ LZO_UINT32_C(0xffffffff); #undef table }
lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len) { lzo_uint32 crc; #undef table #if 1 # define table lzo_crc32_table #else const lzo_uint32 * table = lzo_crc32_table; #endif if (buf == NULL) return 0; crc = (c & LZO_UINT32_C(0xffffffff)) ^ LZO_UINT32_C(0xffffffff); if (len >= 16) do { LZO_DO16(buf,0); buf += 16; len -= 16; } while (len >= 16); if (len != 0) do { LZO_DO1(buf,0); buf += 1; len -= 1; } while (len > 0); return crc ^ LZO_UINT32_C(0xffffffff); #undef table }
// We are really paranoid here - LZO should either fail // at startup or not at all. // // Because of inlining much of these functions evaluates to nothing. // // And while many of the tests seem highly obvious and redundant they are // here to catch compiler/optimizer bugs. Yes, these do exist. ************************************************************************/ #if !defined(__LZO_IN_MINILZO) #define LZO_WANT_ACC_CHK_CH 1 #undef LZOCHK_ASSERT #include "lzo_supp.h" LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) #if !(__LZO_UINTPTR_T_IS_POINTER) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) #endif LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) #endif #undef LZOCHK_ASSERT /*********************************************************************** // ************************************************************************/