diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-02-06 01:15:14 +0300 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-02-09 19:18:11 +0300 |
commit | d8dda255108e56bd45c714be6b3a479cb49823c6 (patch) | |
tree | a3da500650f69164b8a2e78c64b1e36dce79c50b /contrib/libs/lzma/liblzma/check | |
parent | c29b5e57643acd331dfdacd1e3ab836b6e4b018d (diff) | |
download | ydb-d8dda255108e56bd45c714be6b3a479cb49823c6.tar.gz |
Update contrib/libs/lzma to 5.4.6
Diffstat (limited to 'contrib/libs/lzma/liblzma/check')
-rw-r--r-- | contrib/libs/lzma/liblzma/check/check.h | 11 | ||||
-rw-r--r-- | contrib/libs/lzma/liblzma/check/crc64_fast.c | 28 | ||||
-rw-r--r-- | contrib/libs/lzma/liblzma/check/crc64_table.c | 6 | ||||
-rw-r--r-- | contrib/libs/lzma/liblzma/check/sha256.c | 2 |
4 files changed, 37 insertions, 10 deletions
diff --git a/contrib/libs/lzma/liblzma/check/check.h b/contrib/libs/lzma/liblzma/check/check.h index 129113d61b..6b8cd546a8 100644 --- a/contrib/libs/lzma/liblzma/check/check.h +++ b/contrib/libs/lzma/liblzma/check/check.h @@ -99,19 +99,22 @@ typedef struct { /// lzma_crc32_table[0] is needed by LZ encoder so we need to keep /// the array two-dimensional. #ifdef HAVE_SMALL +lzma_attr_visibility_hidden extern uint32_t lzma_crc32_table[1][256]; + extern void lzma_crc32_init(void); + #else + +lzma_attr_visibility_hidden extern const uint32_t lzma_crc32_table[8][256]; + +lzma_attr_visibility_hidden extern const uint64_t lzma_crc64_table[4][256]; #endif /// \brief Initialize *check depending on type -/// -/// \return LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not -/// supported by the current version or build of liblzma. -/// LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX. extern void lzma_check_init(lzma_check_state *check, lzma_check type); /// Update the check state diff --git a/contrib/libs/lzma/liblzma/check/crc64_fast.c b/contrib/libs/lzma/liblzma/check/crc64_fast.c index e3cbf1b1e9..0c8622a1f3 100644 --- a/contrib/libs/lzma/liblzma/check/crc64_fast.c +++ b/contrib/libs/lzma/liblzma/check/crc64_fast.c @@ -184,6 +184,20 @@ calc_hi(uint64_t poly, uint64_t a) MASK_H(in, mask, high) +// MSVC (VS2015 - VS2022) produces bad 32-bit x86 code from the CLMUL CRC +// code when optimizations are enabled (release build). According to the bug +// report, the ebx register is corrupted and the calculated result is wrong. +// Trying to workaround the problem with "__asm mov ebx, ebx" didn't help. +// The following pragma works and performance is still good. x86-64 builds +// aren't affected by this problem. +// +// NOTE: Another pragma after the function 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) +#endif + // EDG-based compilers (Intel's classic compiler and compiler for E2K) can // define __GNUC__ but the attribute must not be used with them. // The new Clang-based ICX needs the attribute. @@ -192,6 +206,14 @@ calc_hi(uint64_t poly, uint64_t a) #if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__) __attribute__((__target__("ssse3,sse4.1,pclmul"))) #endif +// The intrinsics use 16-byte-aligned reads from buf, thus they may read +// up to 15 bytes before or after the buffer (depending on the alignment +// of the buf argument). The values of the extra bytes are ignored. +// This unavoidably trips -fsanitize=address so address sanitizier has +// to be disabled for this function. +#if lzma_has_attribute(__no_sanitize_address__) +__attribute__((__no_sanitize_address__)) +#endif static uint64_t crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc) { @@ -242,7 +264,7 @@ crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc) // C = buf + size == aligned_buf + size2 // D = buf + size + skip_end == aligned_buf + size2 + skip_end const size_t skip_start = (size_t)((uintptr_t)buf & 15); - const size_t skip_end = (size_t)(-(uintptr_t)(buf + size) & 15); + const size_t skip_end = (size_t)((0U - (uintptr_t)(buf + size)) & 15); const __m128i *aligned_buf = (const __m128i *)( (uintptr_t)buf & ~(uintptr_t)15); @@ -371,6 +393,10 @@ crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc) # pragma GCC diagnostic pop #endif } +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \ + && defined(_M_IX86) +# pragma optimize("", on) +#endif #endif diff --git a/contrib/libs/lzma/liblzma/check/crc64_table.c b/contrib/libs/lzma/liblzma/check/crc64_table.c index 307846ab14..bac9301aa4 100644 --- a/contrib/libs/lzma/liblzma/check/crc64_table.c +++ b/contrib/libs/lzma/liblzma/check/crc64_table.c @@ -18,10 +18,8 @@ #if (defined(__x86_64__) && defined(__SSSE3__) \ && defined(__SSE4_1__) && defined(__PCLMUL__)) \ || (defined(__e2k__) && __iset__ >= 6) -// No table needed but something has to be exported to keep some toolchains -// happy. Also use a declaration to silence compiler warnings. -extern const char lzma_crc64_dummy; -const char lzma_crc64_dummy; +// No table needed. Use a typedef to avoid an empty translation unit. +typedef void lzma_crc64_dummy; #else // Having the declaration here silences clang -Wmissing-variable-declarations. diff --git a/contrib/libs/lzma/liblzma/check/sha256.c b/contrib/libs/lzma/liblzma/check/sha256.c index 5eede5ce05..6feb342565 100644 --- a/contrib/libs/lzma/liblzma/check/sha256.c +++ b/contrib/libs/lzma/liblzma/check/sha256.c @@ -8,7 +8,7 @@ /// conditionally to keep the code working on older boxes. // // This code is based on the code found from 7-Zip, which has a modified -// version of the SHA-256 found from Crypto++ <http://www.cryptopp.com/>. +// version of the SHA-256 found from Crypto++ <https://www.cryptopp.com/>. // The code was modified a little to fit into liblzma. // // Authors: Kevin Springle |