crc32defs.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * There are multiple 16-bit CRC polynomials in common use, but this is
  3. * *the* standard CRC-32 polynomial, first popularized by Ethernet.
  4. * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
  5. */
  6. #define CRCPOLY_LE 0xedb88320
  7. #define CRCPOLY_BE 0x04c11db7
  8. /* How many bits at a time to use. Requires a table of 4<<CRC_xx_BITS bytes. */
  9. /* For less performance-sensitive, use 4 */
  10. #ifndef CRC_LE_BITS
  11. # define CRC_LE_BITS 8
  12. #endif
  13. #ifndef CRC_BE_BITS
  14. # define CRC_BE_BITS 8
  15. #endif
  16. /*
  17. * Little-endian CRC computation. Used with serial bit streams sent
  18. * lsbit-first. Be sure to use cpu_to_le32() to append the computed CRC.
  19. */
  20. #if CRC_LE_BITS > 8 || CRC_LE_BITS < 1 || CRC_LE_BITS & CRC_LE_BITS-1
  21. # error CRC_LE_BITS must be a power of 2 between 1 and 8
  22. #endif
  23. /*
  24. * Big-endian CRC computation. Used with serial bit streams sent
  25. * msbit-first. Be sure to use cpu_to_be32() to append the computed CRC.
  26. */
  27. #if CRC_BE_BITS > 8 || CRC_BE_BITS < 1 || CRC_BE_BITS & CRC_BE_BITS-1
  28. # error CRC_BE_BITS must be a power of 2 between 1 and 8
  29. #endif