crc32c.h 915 B

123456789101112131415161718192021222324252627282930
  1. #ifndef CRC32C_H
  2. #define CRC32C_H
  3. #ifndef CRC32C_STATIC
  4. #ifdef CRC32C_EXPORTS
  5. #define CRC32C_API __declspec(dllexport)
  6. #else
  7. #define CRC32C_API __declspec(dllimport)
  8. #endif
  9. #else
  10. #define CRC32C_API
  11. #endif
  12. #include <stdint.h>
  13. /*
  14. Computes CRC-32C (Castagnoli) checksum. Uses Intel's CRC32 instruction if it is available.
  15. Otherwise it uses a very fast software fallback.
  16. */
  17. extern "C" CRC32C_API uint32_t crc32c_append(
  18. uint32_t crc, // Initial CRC value. Typically it's 0.
  19. // You can supply non-trivial initial value here.
  20. // Initial value can be used to chain CRC from multiple buffers.
  21. const uint8_t *input, // Data to be put through the CRC algorithm.
  22. size_t length); // Length of the data in the input buffer.
  23. extern "C" CRC32C_API void crc32c_unittest();
  24. #endif