crc32_table.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 NO_CRC32_TABLE
  17. #elif defined(HAVE_ARM64_CRC32) \
  18. && !defined(WORDS_BIGENDIAN) \
  19. && defined(__ARM_FEATURE_CRC32)
  20. # define NO_CRC32_TABLE
  21. #endif
  22. #if !defined(HAVE_ENCODERS) && defined(NO_CRC32_TABLE)
  23. // No table needed. Use a typedef to avoid an empty translation unit.
  24. typedef void lzma_crc32_dummy;
  25. #else
  26. // Having the declaration here silences clang -Wmissing-variable-declarations.
  27. extern const uint32_t lzma_crc32_table[8][256];
  28. # ifdef WORDS_BIGENDIAN
  29. # error #include "crc32_table_be.h"
  30. # else
  31. # include "crc32_table_le.h"
  32. # endif
  33. #endif