crc32_table.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SPDX-License-Identifier: 0BSD
  2. ///////////////////////////////////////////////////////////////////////////////
  3. //
  4. /// \file crc32_table.c
  5. /// \brief Precalculated CRC32 table with correct endianness
  6. //
  7. // Author: Lasse Collin
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #include "common.h"
  11. // FIXME: Compared to crc_common.h this has to check for __x86_64__ too
  12. // so that in 32-bit builds crc32_x86.S won't break due to a missing table.
  13. #if defined(HAVE_USABLE_CLMUL) && ((defined(__x86_64__) && defined(__SSSE3__) \
  14. && defined(__SSE4_1__) && defined(__PCLMUL__)) \
  15. || (defined(__e2k__) && __iset__ >= 6))
  16. # define X86_CLMUL_NO_TABLE 1
  17. #endif
  18. #if defined(HAVE_ARM64_CRC32) \
  19. && !defined(WORDS_BIGENDIAN) \
  20. && defined(__ARM_FEATURE_CRC32)
  21. # define ARM64_CRC32_NO_TABLE 1
  22. #endif
  23. #if !defined(HAVE_ENCODERS) && (defined(X86_CLMUL_NO_TABLE) \
  24. || defined(ARM64_CRC32_NO_TABLE_))
  25. // No table needed. Use a typedef to avoid an empty translation unit.
  26. typedef void lzma_crc32_dummy;
  27. #else
  28. // Having the declaration here silences clang -Wmissing-variable-declarations.
  29. extern const uint32_t lzma_crc32_table[8][256];
  30. # ifdef WORDS_BIGENDIAN
  31. # error #include "crc32_table_be.h"
  32. # else
  33. # include "crc32_table_le.h"
  34. # endif
  35. #endif