aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/liblzma/check/crc32_fast.c13
-rw-r--r--src/liblzma/check/crc64_fast.c13
-rw-r--r--src/liblzma/check/crc_common.h9
-rw-r--r--src/liblzma/check/crc_x86_clmul.h21
4 files changed, 31 insertions, 25 deletions
diff --git a/src/liblzma/check/crc32_fast.c b/src/liblzma/check/crc32_fast.c
index 6982836a..7157e2f4 100644
--- a/src/liblzma/check/crc32_fast.c
+++ b/src/liblzma/check/crc32_fast.c
@@ -15,7 +15,7 @@
#include "check.h"
#include "crc_common.h"
-#ifdef CRC_CLMUL
+#ifdef CRC_X86_CLMUL
# define BUILDING_CRC32_CLMUL
# include "crc_x86_clmul.h"
#endif
@@ -87,7 +87,7 @@ crc32_generic(const uint8_t *buf, size_t size, uint32_t crc)
#endif
-#if defined(CRC_GENERIC) && defined(CRC_CLMUL)
+#if defined(CRC_GENERIC) && defined(CRC_ARCH_OPTIMIZED)
//////////////////////////
// Function dispatching //
@@ -137,7 +137,8 @@ typedef uint32_t (*crc32_func_type)(
static crc32_func_type
crc32_resolve(void)
{
- return is_clmul_supported() ? &crc32_clmul : &crc32_generic;
+ return is_arch_extension_supported()
+ ? &crc32_arch_optimized : &crc32_generic;
}
#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(__clang__)
@@ -193,7 +194,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
extern LZMA_API(uint32_t)
lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
{
-#if defined(CRC_GENERIC) && defined(CRC_CLMUL)
+#if defined(CRC_GENERIC) && defined(CRC_ARCH_OPTIMIZED)
// If CLMUL is available, it is the best for non-tiny inputs,
// being over twice as fast as the generic slice-by-four version.
// However, for size <= 16 it's different. In the extreme case
@@ -225,8 +226,8 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
*/
return crc32_func(buf, size, crc);
-#elif defined(CRC_CLMUL)
- return crc32_clmul(buf, size, crc);
+#elif defined(CRC_ARCH_OPTIMIZED)
+ return crc32_arch_optimized(buf, size, crc);
#else
return crc32_generic(buf, size, crc);
diff --git a/src/liblzma/check/crc64_fast.c b/src/liblzma/check/crc64_fast.c
index 46b5c646..4edca1a2 100644
--- a/src/liblzma/check/crc64_fast.c
+++ b/src/liblzma/check/crc64_fast.c
@@ -14,7 +14,7 @@
#include "check.h"
#include "crc_common.h"
-#ifdef CRC_CLMUL
+#ifdef CRC_X86_CLMUL
# define BUILDING_CRC64_CLMUL
# include "crc_x86_clmul.h"
#endif
@@ -82,7 +82,7 @@ crc64_generic(const uint8_t *buf, size_t size, uint64_t crc)
#endif
-#if defined(CRC_GENERIC) && defined(CRC_CLMUL)
+#if defined(CRC_GENERIC) && defined(CRC_ARCH_OPTIMIZED)
//////////////////////////
// Function dispatching //
@@ -102,7 +102,8 @@ typedef uint64_t (*crc64_func_type)(
static crc64_func_type
crc64_resolve(void)
{
- return is_clmul_supported() ? &crc64_clmul : &crc64_generic;
+ return is_arch_extension_supported()
+ ? &crc64_arch_optimized : &crc64_generic;
}
#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(__clang__)
@@ -150,7 +151,7 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
extern LZMA_API(uint64_t)
lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
{
-#if defined(CRC_GENERIC) && defined(CRC_CLMUL)
+#if defined(CRC_GENERIC) && defined(CRC_ARCH_OPTIMIZED)
#ifdef CRC_USE_GENERIC_FOR_SMALL_INPUTS
if (size <= 16)
@@ -158,14 +159,14 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
#endif
return crc64_func(buf, size, crc);
-#elif defined(CRC_CLMUL)
+#elif defined(CRC_ARCH_OPTIMIZED)
// If CLMUL is used unconditionally without runtime CPU detection
// then omitting the generic version and its 8 KiB lookup table
// makes the library smaller.
//
// FIXME: Lookup table isn't currently omitted on 32-bit x86,
// see crc64_table.c.
- return crc64_clmul(buf, size, crc);
+ return crc64_arch_optimized(buf, size, crc);
#else
return crc64_generic(buf, size, crc);
diff --git a/src/liblzma/check/crc_common.h b/src/liblzma/check/crc_common.h
index 372ae4a4..045bc20e 100644
--- a/src/liblzma/check/crc_common.h
+++ b/src/liblzma/check/crc_common.h
@@ -70,7 +70,8 @@
#endif
#undef CRC_GENERIC
-#undef CRC_CLMUL
+#undef CRC_ARCH_OPTIMIZED
+#undef CRC_X86_CLMUL
#undef CRC_USE_IFUNC
#undef CRC_USE_GENERIC_FOR_SMALL_INPUTS
@@ -86,12 +87,14 @@
// NOTE: Keep this this in sync with crc32_table.c.
#elif (defined(__SSSE3__) && defined(__SSE4_1__) && defined(__PCLMUL__)) \
|| (defined(__e2k__) && __iset__ >= 6)
-# define CRC_CLMUL 1
+# define CRC_ARCH_OPTIMIZED 1
+# define CRC_X86_CLMUL 1
// Otherwise build both and detect at runtime which version to use.
#else
# define CRC_GENERIC 1
-# define CRC_CLMUL 1
+# define CRC_ARCH_OPTIMIZED 1
+# define CRC_X86_CLMUL 1
# ifdef HAVE_FUNC_ATTRIBUTE_IFUNC
# define CRC_USE_IFUNC 1
diff --git a/src/liblzma/check/crc_x86_clmul.h b/src/liblzma/check/crc_x86_clmul.h
index 7a47204a..bf3c2397 100644
--- a/src/liblzma/check/crc_x86_clmul.h
+++ b/src/liblzma/check/crc_x86_clmul.h
@@ -3,7 +3,7 @@
/// \file crc_x86_clmul.h
/// \brief CRC32 and CRC64 implementations using CLMUL instructions.
///
-/// crc32_clmul() and crc64_clmul() use 32/64-bit x86 SSSE3, SSE4.1, and
+/// The CRC32 and CRC64 implementations use 32/64-bit x86 SSSE3, SSE4.1, and
/// CLMUL instructions. This is compatible with Elbrus 2000 (E2K) too.
///
/// They were derived from
@@ -212,7 +212,7 @@ crc_simd_body(const uint8_t *buf, const size_t size, __m128i *v0, __m128i *v1,
/*
// These functions were used to generate the constants
-// at the top of lzma_crc32_clmul().
+// at the top of crc32_arch_optimized().
static uint64_t
calc_lo(uint64_t p, uint64_t a, int n)
{
@@ -240,7 +240,7 @@ calc_hi(uint64_t p, uint64_t a, int n)
crc_attr_target
crc_attr_no_sanitize_address
static uint32_t
-crc32_clmul(const uint8_t *buf, size_t size, uint32_t crc)
+crc32_arch_optimized(const uint8_t *buf, size_t size, uint32_t crc)
{
#ifndef CRC_USE_GENERIC_FOR_SMALL_INPUTS
// The code assumes that there is at least one byte of input.
@@ -284,7 +284,7 @@ crc32_clmul(const uint8_t *buf, size_t size, uint32_t crc)
/*
// These functions were used to generate the constants
-// at the top of lzma_crc64_clmul().
+// at the top of crc64_arch_optimized().
static uint64_t
calc_lo(uint64_t poly)
{
@@ -319,8 +319,9 @@ calc_hi(uint64_t poly, uint64_t a)
// and CRC32 CLMUL aren't affected by this problem. The problem does not
// happen in crc_simd_body() either (which is shared with CRC32 CLMUL anyway).
//
-// NOTE: Another pragma after lzma_crc64_clmul() restores the optimizations.
-// If the #if condition here is updated, the other one must be updated too.
+// NOTE: Another pragma after crc64_arch_optimized() restores
+// the optimizations. If the #if condition here is updated,
+// the other one must be updated too.
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \
&& defined(_M_IX86)
# pragma optimize("g", off)
@@ -329,7 +330,7 @@ calc_hi(uint64_t poly, uint64_t a)
crc_attr_target
crc_attr_no_sanitize_address
static uint64_t
-crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc)
+crc64_arch_optimized(const uint8_t *buf, size_t size, uint64_t crc)
{
#ifndef CRC_USE_GENERIC_FOR_SMALL_INPUTS
// The code assumes that there is at least one byte of input.
@@ -379,8 +380,8 @@ crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc)
#endif // BUILDING_CRC64_CLMUL
-// is_clmul_supported() must be inlined in this header file because the
-// ifunc resolver function may not support calling a function in another
+// is_arch_extension_supported() must be inlined in this header file because
+// the ifunc resolver function may not support calling a function in another
// translation unit. Depending on compiler-toolchain and flags, a call to
// a function defined in another translation unit could result in a
// reference to the PLT, which is unsafe to do in an ifunc resolver. The
@@ -389,7 +390,7 @@ crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc)
// the function body in crc32_resolve() and crc64_resolve(), but this is
// acceptable because the function results in very few instructions.
static inline bool
-is_clmul_supported(void)
+is_arch_extension_supported(void)
{
int success = 1;
uint32_t r[4]; // eax, ebx, ecx, edx