crc32c.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * \file crc32c.h
  3. * Functions and types for CRC checks.
  4. *
  5. * Generated on Wed Nov 7 16:14:52 2012,
  6. * by pycrc v0.7.11, http://www.tty1.net/pycrc/
  7. * using the configuration:
  8. * Width = 32
  9. * Poly = 0x1edc6f41
  10. * XorIn = 0xffffffff
  11. * ReflectIn = True
  12. * XorOut = 0xffffffff
  13. * ReflectOut = True
  14. * Algorithm = table-driven
  15. *****************************************************************************/
  16. #ifndef __CRC32C_H__
  17. #define __CRC32C_H__
  18. #include <stdlib.h>
  19. #include <stdint.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /**
  24. * The definition of the used algorithm.
  25. *****************************************************************************/
  26. #define CRC_ALGO_TABLE_DRIVEN 1
  27. /**
  28. * The type of the CRC values.
  29. *
  30. * This type must be big enough to contain at least 32 bits.
  31. *****************************************************************************/
  32. typedef uint32_t crc_t;
  33. /**
  34. * Reflect all bits of a \a data word of \a data_len bytes.
  35. *
  36. * \param data The data word to be reflected.
  37. * \param data_len The width of \a data expressed in number of bits.
  38. * \return The reflected data.
  39. *****************************************************************************/
  40. crc_t crc_reflect(crc_t data, size_t data_len);
  41. /**
  42. * Calculate the initial crc value.
  43. *
  44. * \return The initial crc value.
  45. *****************************************************************************/
  46. static inline crc_t crc_init(void)
  47. {
  48. return 0xffffffff;
  49. }
  50. /**
  51. * Update the crc value with new data.
  52. *
  53. * \param crc The current crc value.
  54. * \param data Pointer to a buffer of \a data_len bytes.
  55. * \param data_len Number of bytes in the \a data buffer.
  56. * \return The updated crc value.
  57. *****************************************************************************/
  58. crc_t crc_update(crc_t crc, const unsigned char *data, size_t data_len);
  59. /**
  60. * Calculate the final crc value.
  61. *
  62. * \param crc The current crc value.
  63. * \return The final crc value.
  64. *****************************************************************************/
  65. static inline crc_t crc_finalize(crc_t crc)
  66. {
  67. return crc ^ 0xffffffff;
  68. }
  69. #ifdef __cplusplus
  70. } /* closing brace for extern "C" */
  71. #endif
  72. #endif /* __CRC32C_H__ */