xref: /freebsd/contrib/xz/src/liblzma/check/crc64_table.c (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 // SPDX-License-Identifier: 0BSD
2 
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 /// \file       crc64_table.c
6 /// \brief      Precalculated CRC64 table with correct endianness
7 //
8 //  Author:     Lasse Collin
9 //
10 ///////////////////////////////////////////////////////////////////////////////
11 
12 #include "common.h"
13 
14 
15 // FIXME: Compared to crc_common.h this has to check for __x86_64__ too
16 // so that in 32-bit builds crc64_x86.S won't break due to a missing table.
17 #if defined(HAVE_USABLE_CLMUL) && ((defined(__x86_64__) && defined(__SSSE3__) \
18 			&& defined(__SSE4_1__) && defined(__PCLMUL__)) \
19 		|| (defined(__e2k__) && __iset__ >= 6))
20 #	define X86_CLMUL_NO_TABLE 1
21 #endif
22 
23 
24 #ifdef X86_CLMUL_NO_TABLE
25 // No table needed. Use a typedef to avoid an empty translation unit.
26 typedef void lzma_crc64_dummy;
27 
28 #else
29 // Having the declaration here silences clang -Wmissing-variable-declarations.
30 extern const uint64_t lzma_crc64_table[4][256];
31 
32 #	if defined(WORDS_BIGENDIAN)
33 #		include "crc64_table_be.h"
34 #	else
35 #		include "crc64_table_le.h"
36 #	endif
37 #endif
38