From d67caf18608ef5510521625b3c15951c415df944 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 11 Jan 2015 08:30:12 +0100 Subject: [PATCH] Applied changes same as on previous source (nw) --- 3rdparty/lzma/C/7zCrc.c | 5 +---- 3rdparty/lzma/C/Alloc.c | 4 ++-- 3rdparty/lzma/C/Alloc.h | 2 +- 3rdparty/lzma/C/CpuArch.c | 38 +++++++++++++++++++++++++------------- 3rdparty/lzma/C/CpuArch.h | 15 ++++++++------- 3rdparty/lzma/C/LzmaDec.c | 21 +++++++++++++++++++++ 3rdparty/lzma/C/LzmaDec.h | 5 +++++ 3rdparty/lzma/C/LzmaEnc.c | 12 ++++++------ 3rdparty/lzma/C/Ppmd7.c | 2 +- 3rdparty/lzma/C/Threads.c | 2 +- 3rdparty/lzma/C/Types.h | 8 ++++---- 11 files changed, 75 insertions(+), 39 deletions(-) diff --git a/3rdparty/lzma/C/7zCrc.c b/3rdparty/lzma/C/7zCrc.c index cd94201be97..a73b1379bad 100644 --- a/3rdparty/lzma/C/7zCrc.c +++ b/3rdparty/lzma/C/7zCrc.c @@ -6,10 +6,7 @@ #define kCrcPoly 0xEDB88320 -#ifdef MY_CPU_X86_OR_AMD64 - #define CRC_NUM_TABLES 8 - UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); -#elif defined(MY_CPU_LE) +#if defined(MY_CPU_LE) #define CRC_NUM_TABLES 4 #else #define CRC_NUM_TABLES 5 diff --git a/3rdparty/lzma/C/Alloc.c b/3rdparty/lzma/C/Alloc.c index 358a7b52650..df7412afe79 100644 --- a/3rdparty/lzma/C/Alloc.c +++ b/3rdparty/lzma/C/Alloc.c @@ -3,7 +3,7 @@ Igor Pavlov Public domain */ -#ifdef _WIN32 +#ifdef _WIN32_7Z #include #endif #include @@ -44,7 +44,7 @@ void MyFree(void *address) free(address); } -#ifdef _WIN32 +#ifdef _WIN32_7Z void *MidAlloc(size_t size) { diff --git a/3rdparty/lzma/C/Alloc.h b/3rdparty/lzma/C/Alloc.h index b8e4143677d..4b73481f4c6 100644 --- a/3rdparty/lzma/C/Alloc.h +++ b/3rdparty/lzma/C/Alloc.h @@ -13,7 +13,7 @@ extern "C" { void *MyAlloc(size_t size); void MyFree(void *address); -#ifdef _WIN32 +#ifdef _WIN32_7Z void SetLargePageSize(); diff --git a/3rdparty/lzma/C/CpuArch.c b/3rdparty/lzma/C/CpuArch.c index 260cc1f45dc..caf21643cef 100644 --- a/3rdparty/lzma/C/CpuArch.c +++ b/3rdparty/lzma/C/CpuArch.c @@ -72,16 +72,28 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) #else - __asm__ __volatile__ ( - "cpuid" - : "=a" (*a) , - "=b" (*b) , - "=c" (*c) , - "=d" (*d) - : "0" (function)) ; - - #endif + #ifdef __PIC__ + __asm__ __volatile__ ( + "mov %%ebx, %%edi;" + "cpuid;" + "xchgl %%ebx, %%edi;" + : "=a" (*a) , + "=D" (*b) , /* edi */ + "=c" (*c) , + "=d" (*d) + : "0" (function)) ; + #else // __PIC__ + __asm__ __volatile__ ( + "cpuid" + : "=a" (*a) , + "=b" (*b) , + "=c" (*c) , + "=d" (*d) + : "0" (function)) ; + #endif // __PIC__ + #endif + #else int CPUInfo[4]; @@ -123,7 +135,7 @@ int x86cpuid_GetFirm(const Cx86cpuid *p) return -1; } -Bool CPU_Is_InOrder() +Bool CPU_Is_InOrder(void) { Cx86cpuid p; int firm; @@ -142,8 +154,8 @@ Bool CPU_Is_InOrder() return True; } -#if !defined(MY_CPU_AMD64) && defined(_WIN32) -static Bool CPU_Sys_Is_SSE_Supported() +#if !defined(MY_CPU_AMD64) && defined(_WIN32_7Z) +static Bool CPU_Sys_Is_SSE_Supported(void) { OSVERSIONINFO vi; vi.dwOSVersionInfoSize = sizeof(vi); @@ -156,7 +168,7 @@ static Bool CPU_Sys_Is_SSE_Supported() #define CHECK_SYS_SSE_SUPPORT #endif -Bool CPU_Is_Aes_Supported() +Bool CPU_Is_Aes_Supported(void) { Cx86cpuid p; CHECK_SYS_SSE_SUPPORT diff --git a/3rdparty/lzma/C/CpuArch.h b/3rdparty/lzma/C/CpuArch.h index e3d7af2ebb1..50a7467f639 100644 --- a/3rdparty/lzma/C/CpuArch.h +++ b/3rdparty/lzma/C/CpuArch.h @@ -20,7 +20,7 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla #define MY_CPU_AMD64 #endif -#if defined(MY_CPU_AMD64) || defined(_M_IA64) +#ifdef PTR64 #define MY_CPU_64BIT #endif @@ -36,11 +36,11 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla #define MY_CPU_32BIT #endif -#if defined(_WIN32) && defined(_M_ARM) +#if defined(_WIN32_7Z) && defined(_M_ARM) #define MY_CPU_ARM_LE #endif -#if defined(_WIN32) && defined(_M_IA64) +#if defined(_WIN32_7Z) && defined(_M_IA64) #define MY_CPU_IA64_LE #endif @@ -52,7 +52,7 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla #define MY_CPU_LE #endif -#if defined(__BIG_ENDIAN__) || defined(__m68k__) || defined(__ARMEB__) || defined(__MIPSEB__) +#ifdef BIGENDIAN #define MY_CPU_BE #endif @@ -97,7 +97,8 @@ Stop_Compiling_Bad_Endian #endif -#if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300) +#if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (defined(_MSC_VER) && (_MSC_VER >= 1300)) +#include #pragma intrinsic(_byteswap_ulong) #pragma intrinsic(_byteswap_uint64) @@ -145,8 +146,8 @@ int x86cpuid_GetFirm(const Cx86cpuid *p); #define x86cpuid_GetModel(p) (((p)->ver >> 4) & 0xF00F) #define x86cpuid_GetStepping(p) ((p)->ver & 0xF) -Bool CPU_Is_InOrder(); -Bool CPU_Is_Aes_Supported(); +Bool CPU_Is_InOrder(void); +Bool CPU_Is_Aes_Supported(void); #endif diff --git a/3rdparty/lzma/C/LzmaDec.c b/3rdparty/lzma/C/LzmaDec.c index 8c1a1486df1..f7f79bb063d 100644 --- a/3rdparty/lzma/C/LzmaDec.c +++ b/3rdparty/lzma/C/LzmaDec.c @@ -967,6 +967,27 @@ SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAll return SZ_OK; } +// why isn't there an interface to pass in the properties directly???? +SRes LzmaDec_Allocate_MAME(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) +{ + SizeT dicBufSize; + RINOK(LzmaDec_AllocateProbs2(p, propNew, alloc)); + dicBufSize = propNew->dicSize; + if (p->dic == 0 || dicBufSize != p->dicBufSize) + { + LzmaDec_FreeDict(p, alloc); + p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); + if (p->dic == 0) + { + LzmaDec_FreeProbs(p, alloc); + return SZ_ERROR_MEM; + } + } + p->dicBufSize = dicBufSize; + p->prop = *propNew; + return SZ_OK; +} + SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) diff --git a/3rdparty/lzma/C/LzmaDec.h b/3rdparty/lzma/C/LzmaDec.h index bf7f084ba3d..e84a01e282e 100644 --- a/3rdparty/lzma/C/LzmaDec.h +++ b/3rdparty/lzma/C/LzmaDec.h @@ -224,6 +224,11 @@ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); +/* + * Why isn't there an interface to pass in the properties directly???? + */ +SRes LzmaDec_Allocate_MAME(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc); + #ifdef __cplusplus } #endif diff --git a/3rdparty/lzma/C/LzmaEnc.c b/3rdparty/lzma/C/LzmaEnc.c index ef26e0cfdbd..e1e170b1977 100644 --- a/3rdparty/lzma/C/LzmaEnc.c +++ b/3rdparty/lzma/C/LzmaEnc.c @@ -1905,11 +1905,13 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) { UInt32 beforeSize = kNumOpts; - Bool btMode; - if (!RangeEnc_Alloc(&p->rc, alloc)) - return SZ_ERROR_MEM; - btMode = (p->matchFinderBase.btMode != 0); #ifndef _7ZIP_ST + Bool btMode; + #endif + if (!RangeEnc_Alloc(&p->rc, alloc)) + return SZ_ERROR_MEM; + #ifndef _7ZIP_ST + btMode = (p->matchFinderBase.btMode != 0); p->mtMode = (p->multiThread && !p->fastMode && btMode); #endif @@ -2085,8 +2087,6 @@ void LzmaEnc_Finish(CLzmaEncHandle pp) CLzmaEnc *p = (CLzmaEnc *)pp; if (p->mtMode) MatchFinderMt_ReleaseStream(&p->matchFinderMt); - #else - pp = pp; #endif } diff --git a/3rdparty/lzma/C/Ppmd7.c b/3rdparty/lzma/C/Ppmd7.c index 060d86d2e0f..bba4d06f0ab 100644 --- a/3rdparty/lzma/C/Ppmd7.c +++ b/3rdparty/lzma/C/Ppmd7.c @@ -2,7 +2,7 @@ 2010-03-12 : Igor Pavlov : Public domain This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ -#include +#include #include "Ppmd7.h" diff --git a/3rdparty/lzma/C/Threads.c b/3rdparty/lzma/C/Threads.c index 7af1da2e26e..68561067fe6 100644 --- a/3rdparty/lzma/C/Threads.c +++ b/3rdparty/lzma/C/Threads.c @@ -1,7 +1,7 @@ /* Threads.c -- multithreading library 2009-09-20 : Igor Pavlov : Public domain */ -#ifndef _WIN32_WCE +#ifndef _WIN32_7Z_WCE #include #endif diff --git a/3rdparty/lzma/C/Types.h b/3rdparty/lzma/C/Types.h index 7732c240c69..1dfea2fbea4 100644 --- a/3rdparty/lzma/C/Types.h +++ b/3rdparty/lzma/C/Types.h @@ -6,7 +6,7 @@ #include -#ifdef _WIN32 +#ifdef _WIN32_7Z #include #endif @@ -42,7 +42,7 @@ EXTERN_C_BEGIN typedef int SRes; -#ifdef _WIN32 +#ifdef _WIN32_7Z typedef DWORD WRes; #else typedef int WRes; @@ -97,7 +97,7 @@ typedef int Bool; #define False 0 -#ifdef _WIN32 +#ifdef _WIN32_7Z #define MY_STD_CALL __stdcall #else #define MY_STD_CALL @@ -233,7 +233,7 @@ typedef struct #define IAlloc_Alloc(p, size) (p)->Alloc((p), size) #define IAlloc_Free(p, a) (p)->Free((p), a) -#ifdef _WIN32 +#ifdef _WIN32_7Z #define CHAR_PATH_SEPARATOR '\\' #define WCHAR_PATH_SEPARATOR L'\\'