From 839151eaaad24771892afaae6bac690e31e58384 Mon Sep 17 00:00:00 2001 From: Igor Pavlov <87184205+ip7z@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:00:00 +0000 Subject: 26.00 --- C/7zVersion.h | 10 +++--- C/7zWindows.h | 10 ++++-- C/7zip_gcc_c.mak | 2 +- C/CpuArch.c | 4 +-- C/CpuArch.h | 19 ++++++++++- C/HuffEnc.c | 9 +++--- C/HuffEnc.h | 2 +- C/Xxh64.c | 98 +++++++++++++++++++++++++++++++++++++++++++++----------- 8 files changed, 120 insertions(+), 34 deletions(-) (limited to 'C') diff --git a/C/7zVersion.h b/C/7zVersion.h index b6142e9..770370a 100644 --- a/C/7zVersion.h +++ b/C/7zVersion.h @@ -1,7 +1,7 @@ -#define MY_VER_MAJOR 25 -#define MY_VER_MINOR 1 +#define MY_VER_MAJOR 26 +#define MY_VER_MINOR 0 #define MY_VER_BUILD 0 -#define MY_VERSION_NUMBERS "25.01" +#define MY_VERSION_NUMBERS "26.00" #define MY_VERSION MY_VERSION_NUMBERS #ifdef MY_CPU_NAME @@ -10,12 +10,12 @@ #define MY_VERSION_CPU MY_VERSION #endif -#define MY_DATE "2025-08-03" +#define MY_DATE "2026-02-12" #undef MY_COPYRIGHT #undef MY_VERSION_COPYRIGHT_DATE #define MY_AUTHOR_NAME "Igor Pavlov" #define MY_COPYRIGHT_PD "Igor Pavlov : Public domain" -#define MY_COPYRIGHT_CR "Copyright (c) 1999-2025 Igor Pavlov" +#define MY_COPYRIGHT_CR "Copyright (c) 1999-2026 Igor Pavlov" #ifdef USE_COPYRIGHT_CR #define MY_COPYRIGHT MY_COPYRIGHT_CR diff --git a/C/7zWindows.h b/C/7zWindows.h index 42c6db8..381159e 100644 --- a/C/7zWindows.h +++ b/C/7zWindows.h @@ -1,11 +1,17 @@ -/* 7zWindows.h -- StdAfx -2023-04-02 : Igor Pavlov : Public domain */ +/* 7zWindows.h -- Windows.h and related code +Igor Pavlov : Public domain */ #ifndef ZIP7_INC_7Z_WINDOWS_H #define ZIP7_INC_7Z_WINDOWS_H #ifdef _WIN32 +#if defined(_MSC_VER) && _MSC_VER >= 1950 && !defined(__clang__) // VS2026 +// and some another windows files need that option +// VS2026: wtypesbase.h: warning C4865: 'tagCLSCTX': the underlying type will change from 'int' to 'unsigned int' when '/Zc:enumTypes' is specified on the command line +#pragma warning(disable : 4865) +#endif + #if defined(__clang__) # pragma clang diagnostic push #endif diff --git a/C/7zip_gcc_c.mak b/C/7zip_gcc_c.mak index 195d23d..006cfe0 100644 --- a/C/7zip_gcc_c.mak +++ b/C/7zip_gcc_c.mak @@ -106,7 +106,7 @@ DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll endif -LIB2 = -lOle32 -loleaut32 -luuid -ladvapi32 -lUser32 -lShell32 +LIB2 = -lole32 -loleaut32 -luuid -ladvapi32 -luser32 -lshell32 CFLAGS_EXTRA = -DUNICODE -D_UNICODE # -Wno-delete-non-virtual-dtor diff --git a/C/CpuArch.c b/C/CpuArch.c index 6e02551..342280d 100644 --- a/C/CpuArch.c +++ b/C/CpuArch.c @@ -859,7 +859,7 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYPTO_SUPPORT_VAL; } #if defined(__GLIBC__) && (__GLIBC__ * 100 + __GLIBC_MINOR__ >= 216) #define Z7_GETAUXV_AVAILABLE -#else +#elif !defined(__QNXNTO__) // #pragma message("=== is not NEW GLIBC === ") #if defined __has_include #if __has_include () @@ -877,7 +877,7 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYPTO_SUPPORT_VAL; } #ifdef USE_HWCAP -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) static unsigned long MY_getauxval(int aux) { unsigned long val; diff --git a/C/CpuArch.h b/C/CpuArch.h index 1690a5b..c682720 100644 --- a/C/CpuArch.h +++ b/C/CpuArch.h @@ -31,7 +31,12 @@ MY_CPU_64BIT means that processor can work with 64-bit registers. #define MY_CPU_NAME "x32" #define MY_CPU_SIZEOF_POINTER 4 #else - #define MY_CPU_NAME "x64" + #if defined(__APX_EGPR__) || defined(__EGPR__) + #define MY_CPU_NAME "x64-apx" + #define MY_CPU_AMD64_APX + #else + #define MY_CPU_NAME "x64" + #endif #define MY_CPU_SIZEOF_POINTER 8 #endif #define MY_CPU_64BIT @@ -596,8 +601,20 @@ problem-4 : performace: #define SetBe32a(p, v) { *(UInt32 *)(void *)(p) = (v); } #define SetBe16a(p, v) { *(UInt16 *)(void *)(p) = (v); } +// gcc and clang for powerpc can transform load byte access to load reverse word access. +// sp we can use byte access instead of word access. Z7_BSWAP64 cab be slow +#if 1 && defined(Z7_CPU_FAST_BSWAP_SUPPORTED) && defined(MY_CPU_64BIT) +#define GetUi64a(p) Z7_BSWAP64 (*(const UInt64 *)(const void *)(p)) +#else #define GetUi64a(p) GetUi64(p) +#endif + +#if 1 && defined(Z7_CPU_FAST_BSWAP_SUPPORTED) +#define GetUi32a(p) Z7_BSWAP32 (*(const UInt32 *)(const void *)(p)) +#else #define GetUi32a(p) GetUi32(p) +#endif + #define GetUi16a(p) GetUi16(p) #define SetUi32a(p, v) SetUi32(p, v) #define SetUi16a(p, v) SetUi16(p, v) diff --git a/C/HuffEnc.c b/C/HuffEnc.c index cbf8c22..297b41a 100644 --- a/C/HuffEnc.c +++ b/C/HuffEnc.c @@ -13,7 +13,7 @@ Igor Pavlov : Public domain */ #define NUM_BITS 10 #define MASK ((1u << NUM_BITS) - 1) #define FREQ_MASK (~(UInt32)MASK) -#define NUM_COUNTERS (48 * 2) +#define NUM_COUNTERS (104 * 2) // (80 * 2) or (128 * 2) : ((prime_number + 1) * 2) for smaller code. #if 1 && (defined(MY_CPU_LE) || defined(MY_CPU_BE)) #if defined(MY_CPU_LE) @@ -95,9 +95,10 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, unsigned numSy counters[1] = 0; for (i = 2; i != NUM_COUNTERS; i += 2) { - unsigned c; - c = (counters )[i]; (counters )[i] = num; num += c; - c = (counters + 1)[i]; (counters + 1)[i] = num; num += c; + const unsigned c0 = (counters )[i]; + const unsigned c1 = (counters + 1)[i]; + (counters )[i] = num; num += c0; + (counters + 1)[i] = num; num += c1; } counters[0] = num; // we want to write (freq==0) symbols to the end of (p) array { diff --git a/C/HuffEnc.h b/C/HuffEnc.h index 2217f55..45567d0 100644 --- a/C/HuffEnc.h +++ b/C/HuffEnc.h @@ -16,7 +16,7 @@ Conditions: 1 <= maxLen <= 16 = Z7_HUFFMAN_LEN_MAX Num_Items(p) >= HUFFMAN_TEMP_SIZE(num) */ -void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen); +void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, unsigned num, unsigned maxLen); EXTERN_C_END diff --git a/C/Xxh64.c b/C/Xxh64.c index dc02a02..660e0be 100644 --- a/C/Xxh64.c +++ b/C/Xxh64.c @@ -1,6 +1,6 @@ /* Xxh64.c -- XXH64 hash calculation original code: Copyright (c) Yann Collet. -2023-08-18 : modified by Igor Pavlov. +modified by Igor Pavlov. This source code is licensed under BSD 2-Clause License. */ @@ -27,6 +27,14 @@ void Xxh64State_Init(CXxh64State *p) #if !defined(MY_CPU_64BIT) && defined(MY_CPU_X86) && defined(_MSC_VER) #define Z7_XXH64_USE_ASM +#elif !defined(MY_CPU_LE_UNALIGN_64) // && defined (MY_CPU_LE) + #define Z7_XXH64_USE_ALIGNED +#endif + +#ifdef Z7_XXH64_USE_ALIGNED + #define Xxh64State_UpdateBlocks_Unaligned_Select Xxh64State_UpdateBlocks_Unaligned +#else + #define Xxh64State_UpdateBlocks_Unaligned_Select Xxh64State_UpdateBlocks #endif #if !defined(MY_CPU_64BIT) && defined(MY_CPU_X86) \ @@ -188,32 +196,76 @@ Xxh64State_UpdateBlocks(CXxh64State *p, const void *data, const void *end) #else +#ifdef Z7_XXH64_USE_ALIGNED +static +#endif void Z7_NO_INLINE Z7_FASTCALL -Xxh64State_UpdateBlocks(CXxh64State *p, const void *_data, const void *end) +Xxh64State_UpdateBlocks_Unaligned_Select(CXxh64State *p, const void *_data, const void *end) { const Byte *data = (const Byte *)_data; - UInt64 v[4]; - v[0] = p->v[0]; - v[1] = p->v[1]; - v[2] = p->v[2]; - v[3] = p->v[3]; + UInt64 v0, v1, v2, v3; + v0 = p->v[0]; + v1 = p->v[1]; + v2 = p->v[2]; + v3 = p->v[3]; do { - v[0] = Xxh64_Round(v[0], GetUi64(data)); data += 8; - v[1] = Xxh64_Round(v[1], GetUi64(data)); data += 8; - v[2] = Xxh64_Round(v[2], GetUi64(data)); data += 8; - v[3] = Xxh64_Round(v[3], GetUi64(data)); data += 8; + v0 = Xxh64_Round(v0, GetUi64(data)); data += 8; + v1 = Xxh64_Round(v1, GetUi64(data)); data += 8; + v2 = Xxh64_Round(v2, GetUi64(data)); data += 8; + v3 = Xxh64_Round(v3, GetUi64(data)); data += 8; } while (data != end); - p->v[0] = v[0]; - p->v[1] = v[1]; - p->v[2] = v[2]; - p->v[3] = v[3]; + p->v[0] = v0; + p->v[1] = v1; + p->v[2] = v2; + p->v[3] = v3; } -#endif + +#ifdef Z7_XXH64_USE_ALIGNED + +static +void +Z7_NO_INLINE +Z7_FASTCALL +Xxh64State_UpdateBlocks_Aligned(CXxh64State *p, const void *_data, const void *end) +{ + const Byte *data = (const Byte *)_data; + UInt64 v0, v1, v2, v3; + v0 = p->v[0]; + v1 = p->v[1]; + v2 = p->v[2]; + v3 = p->v[3]; + do + { + v0 = Xxh64_Round(v0, GetUi64a(data)); data += 8; + v1 = Xxh64_Round(v1, GetUi64a(data)); data += 8; + v2 = Xxh64_Round(v2, GetUi64a(data)); data += 8; + v3 = Xxh64_Round(v3, GetUi64a(data)); data += 8; + } + while (data != end); + p->v[0] = v0; + p->v[1] = v1; + p->v[2] = v2; + p->v[3] = v3; +} + +void +Z7_NO_INLINE +Z7_FASTCALL +Xxh64State_UpdateBlocks(CXxh64State *p, const void *data, const void *end) +{ + if (((unsigned)(ptrdiff_t)data & 7) == 0) + Xxh64State_UpdateBlocks_Aligned(p, data, end); + else + Xxh64State_UpdateBlocks_Unaligned(p, data, end); +} + +#endif // Z7_XXH64_USE_ALIGNED +#endif // Z7_XXH64_USE_ASM UInt64 Xxh64State_Digest(const CXxh64State *p, const void *_data, UInt64 count) { @@ -306,12 +358,22 @@ void Xxh64_Update(CXxh64 *p, const void *_data, size_t size) while (--rem); if (cnt != 32) return; - Xxh64State_UpdateBlocks(&p->state, p->buf64, &p->buf64[4]); +#ifdef Z7_XXH64_USE_ALIGNED + Xxh64State_UpdateBlocks_Aligned +#else + Xxh64State_UpdateBlocks_Unaligned_Select +#endif + (&p->state, p->buf64, &p->buf64[4]); } if (size &= ~(size_t)31) { - Xxh64State_UpdateBlocks(&p->state, data, data + size); +#ifdef Z7_XXH64_USE_ALIGNED + if (((unsigned)(ptrdiff_t)data & 7) == 0) + Xxh64State_UpdateBlocks_Aligned(&p->state, data, data + size); + else +#endif + Xxh64State_UpdateBlocks_Unaligned_Select(&p->state, data, data + size); data += size; } -- cgit v1.2.3-55-g6feb