From 9700a009c5d114e08bc7572188f497989278aebd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 Aug 2021 01:43:08 +0200 Subject: [PATCH] (7zip) Use normal stdint.h types that don't conflict with PowerPC Mac's OSTypes.h --- deps/7zip/7z.h | 66 ++--- deps/7zip/7zArcIn.c | 280 +++++++++---------- deps/7zip/7zCrc.c | 30 +- deps/7zip/7zCrc.h | 6 +- deps/7zip/7zCrcOpt.c | 24 +- deps/7zip/7zDec.c | 52 ++-- deps/7zip/7zFile.c | 6 +- deps/7zip/7zFile.h | 4 +- deps/7zip/7zStream.c | 6 +- deps/7zip/7zTypes.h | 26 +- deps/7zip/Bcj2.c | 14 +- deps/7zip/Bcj2.h | 30 +- deps/7zip/Bra.c | 70 ++--- deps/7zip/Bra.h | 14 +- deps/7zip/Bra86.c | 10 +- deps/7zip/BraIA64.c | 12 +- deps/7zip/CpuArch.c | 16 +- deps/7zip/CpuArch.h | 78 +++--- deps/7zip/LzFind.c | 186 ++++++------- deps/7zip/LzFind.h | 66 ++--- deps/7zip/LzHash.h | 26 +- deps/7zip/Lzma2Dec.c | 28 +- deps/7zip/Lzma2Dec.h | 4 +- deps/7zip/LzmaDec.c | 76 ++--- deps/7zip/LzmaDec.h | 22 +- deps/7zip/LzmaEnc.c | 368 ++++++++++++------------- deps/7zip/LzmaEnc.h | 10 +- libretro-common/file/archive_file_7z.c | 4 +- 28 files changed, 759 insertions(+), 775 deletions(-) diff --git a/deps/7zip/7z.h b/deps/7zip/7z.h index 5e1d65e32e..08b02b405a 100644 --- a/deps/7zip/7z.h +++ b/deps/7zip/7z.h @@ -24,15 +24,15 @@ typedef struct typedef struct { size_t PropsOffset; - UInt32 MethodID; + uint32_t MethodID; Byte NumStreams; Byte PropsSize; } CSzCoderInfo; typedef struct { - UInt32 InIndex; - UInt32 OutIndex; + uint32_t InIndex; + uint32_t OutIndex; } CSzBond; #define SZ_NUM_CODERS_IN_FOLDER_MAX 4 @@ -41,11 +41,11 @@ typedef struct typedef struct { - UInt32 NumCoders; - UInt32 NumBonds; - UInt32 NumPackStreams; - UInt32 UnpackStream; - UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX]; + uint32_t NumCoders; + uint32_t NumBonds; + uint32_t NumPackStreams; + uint32_t UnpackStream; + uint32_t PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX]; CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX]; CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX]; } CSzFolder; @@ -55,20 +55,20 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd); typedef struct { - UInt32 Low; - UInt32 High; + uint32_t Low; + uint32_t High; } CNtfsFileTime; typedef struct { Byte *Defs; /* MSB 0 bit numbering */ - UInt32 *Vals; + uint32_t *Vals; } CSzBitUi32s; typedef struct { Byte *Defs; /* MSB 0 bit numbering */ - /* UInt64 *Vals; */ + /* uint64_t *Vals; */ CNtfsFileTime *Vals; } CSzBitUi64s; @@ -78,25 +78,25 @@ typedef struct typedef struct { - UInt32 NumPackStreams; - UInt32 NumFolders; + uint32_t NumPackStreams; + uint32_t NumFolders; - UInt64 *PackPositions; /* NumPackStreams + 1 */ + uint64_t *PackPositions; /* NumPackStreams + 1 */ CSzBitUi32s FolderCRCs; /* NumFolders */ size_t *FoCodersOffsets; /* NumFolders + 1 */ - UInt32 *FoStartPackStreamIndex; /* NumFolders + 1 */ - UInt32 *FoToCoderUnpackSizes; /* NumFolders + 1 */ + uint32_t *FoStartPackStreamIndex; /* NumFolders + 1 */ + uint32_t *FoToCoderUnpackSizes; /* NumFolders + 1 */ Byte *FoToMainUnpackSizeIndex; /* NumFolders */ - UInt64 *CoderUnpackSizes; /* for all coders in all folders */ + uint64_t *CoderUnpackSizes; /* for all coders in all folders */ Byte *CodersData; } CSzAr; -UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex); +uint64_t SzAr_GetFolderUnpackSize(const CSzAr *p, uint32_t folderIndex); -SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, - ILookInStream *stream, UInt64 startPos, +SRes SzAr_DecodeFolder(const CSzAr *p, uint32_t folderIndex, + ILookInStream *stream, uint64_t startPos, Byte *outBuffer, size_t outSize, ISzAllocPtr allocMain); @@ -104,12 +104,12 @@ typedef struct { CSzAr db; - UInt64 startPosAfterHeader; - UInt64 dataPos; + uint64_t startPosAfterHeader; + uint64_t dataPos; - UInt32 NumFiles; + uint32_t NumFiles; - UInt64 *UnpackPositions; /* NumFiles + 1 */ + uint64_t *UnpackPositions; /* NumFiles + 1 */ /* Byte *IsEmptyFiles; */ Byte *IsDirs; CSzBitUi32s CRCs; @@ -119,8 +119,8 @@ typedef struct CSzBitUi64s MTime; CSzBitUi64s CTime; - UInt32 *FolderToFile; /* NumFolders + 1 */ - UInt32 *FileToFolder; /* NumFiles */ + uint32_t *FolderToFile; /* NumFolders + 1 */ + uint32_t *FileToFolder; /* NumFiles */ size_t *FileNameOffsets; /* in 2-byte steps */ Byte *FileNames; /* UTF-16-LE */ @@ -132,8 +132,8 @@ typedef struct void SzArEx_Init(CSzArEx *p); void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc); -UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder); -int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize); +uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder); +int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize); /* if dest == NULL, the return value specifies the required size of the buffer, @@ -141,11 +141,11 @@ if dest == NULL, the return value specifies the required size of the buffer, if dest != NULL, the return value specifies the number of 16-bit characters that are written to the dest, including the null-terminating character. */ -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest); +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest); /* size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex); -UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest); +uint16_t *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, uint16_t *dest); */ @@ -173,8 +173,8 @@ UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 SRes SzArEx_Extract( const CSzArEx *db, ILookInStream *inStream, - UInt32 fileIndex, /* index of file */ - UInt32 *blockIndex, /* index of solid block */ + uint32_t fileIndex, /* index of file */ + uint32_t *blockIndex, /* index of solid block */ Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ size_t *outBufferSize, /* buffer size for output buffer */ size_t *offset, /* offset of stream for required file in *outBuffer */ diff --git a/deps/7zip/7zArcIn.c b/deps/7zip/7zArcIn.c index c658b87196..e2adaf5ed3 100644 --- a/deps/7zip/7zArcIn.c +++ b/deps/7zip/7zArcIn.c @@ -70,7 +70,7 @@ static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc) else { MY_ALLOC(Byte, p->Defs, (num + 7) >> 3, alloc); - MY_ALLOC(UInt32, p->Vals, num, alloc); + MY_ALLOC(uint32_t, p->Vals, num, alloc); } return SZ_OK; } @@ -190,11 +190,11 @@ static int TestSignatureCandidate(const Byte *testBytes) #define SZ_READ_32(dest) if (sd.Size < 4) return SZ_ERROR_ARCHIVE; \ dest = GetUi32(sd.Data); SKIP_DATA2(sd, 4); -static MY_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) +static MY_NO_INLINE SRes ReadNumber(CSzData *sd, uint64_t *value) { Byte firstByte, mask; unsigned i; - UInt32 v; + uint32_t v; SZ_READ_BYTE(firstByte); if ((firstByte & 0x80) == 0) @@ -205,33 +205,33 @@ static MY_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) SZ_READ_BYTE(v); if ((firstByte & 0x40) == 0) { - *value = (((UInt32)firstByte & 0x3F) << 8) | v; + *value = (((uint32_t)firstByte & 0x3F) << 8) | v; return SZ_OK; } SZ_READ_BYTE(mask); - *value = v | ((UInt32)mask << 8); + *value = v | ((uint32_t)mask << 8); mask = 0x20; for (i = 2; i < 8; i++) { Byte b; if ((firstByte & mask) == 0) { - UInt64 highPart = (unsigned)firstByte & (unsigned)(mask - 1); + uint64_t highPart = (unsigned)firstByte & (unsigned)(mask - 1); *value |= (highPart << (8 * i)); return SZ_OK; } SZ_READ_BYTE(b); - *value |= ((UInt64)b << (8 * i)); + *value |= ((uint64_t)b << (8 * i)); mask >>= 1; } return SZ_OK; } -static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) +static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, uint32_t *value) { Byte firstByte; - UInt64 value64; + uint64_t value64; if (sd->Size == 0) return SZ_ERROR_ARCHIVE; firstByte = *sd->Data; @@ -243,11 +243,11 @@ static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) return SZ_OK; } RINOK(ReadNumber(sd, &value64)); - if (value64 >= (UInt32)0x80000000 - 1) + if (value64 >= (uint32_t)0x80000000 - 1) return SZ_ERROR_UNSUPPORTED; - if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 4))) + if (value64 >= ((uint64_t)(1) << ((sizeof(size_t) - 1) * 8 + 4))) return SZ_ERROR_UNSUPPORTED; - *value = (UInt32)value64; + *value = (uint32_t)value64; return SZ_OK; } @@ -255,7 +255,7 @@ static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) static SRes SkipData(CSzData *sd) { - UInt64 size; + uint64_t size; RINOK(ReadNumber(sd, &size)); if (size > sd->Size) return SZ_ERROR_ARCHIVE; @@ -263,11 +263,11 @@ static SRes SkipData(CSzData *sd) return SZ_OK; } -static SRes WaitId(CSzData *sd, UInt32 id) +static SRes WaitId(CSzData *sd, uint32_t id) { for (;;) { - UInt64 type; + uint64_t type; RINOK(ReadID(sd, &type)); if (type == id) return SZ_OK; @@ -277,9 +277,9 @@ static SRes WaitId(CSzData *sd, UInt32 id) } } -static SRes RememberBitVector(CSzData *sd, UInt32 numItems, const Byte **v) +static SRes RememberBitVector(CSzData *sd, uint32_t numItems, const Byte **v) { - UInt32 numBytes = (numItems + 7) >> 3; + uint32_t numBytes = (numItems + 7) >> 3; if (numBytes > sd->Size) return SZ_ERROR_ARCHIVE; *v = sd->Data; @@ -287,11 +287,11 @@ static SRes RememberBitVector(CSzData *sd, UInt32 numItems, const Byte **v) return SZ_OK; } -static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems) +static uint32_t CountDefinedBits(const Byte *bits, uint32_t numItems) { Byte b = 0; unsigned m = 0; - UInt32 sum = 0; + uint32_t sum = 0; for (; numItems != 0; numItems--) { if (m == 0) @@ -305,11 +305,11 @@ static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems) return sum; } -static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, UInt32 numItems, Byte **v, ISzAllocPtr alloc) +static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, uint32_t numItems, Byte **v, ISzAllocPtr alloc) { Byte allAreDefined; Byte *v2; - UInt32 numBytes = (numItems + 7) >> 3; + uint32_t numBytes = (numItems + 7) >> 3; *v = NULL; SZ_READ_BYTE(allAreDefined); if (numBytes == 0) @@ -328,18 +328,18 @@ static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, UInt32 numItems, Byte **v, I { unsigned numBits = (unsigned)numItems & 7; if (numBits != 0) - v2[(size_t)numBytes - 1] = (Byte)((((UInt32)1 << numBits) - 1) << (8 - numBits)); + v2[(size_t)numBytes - 1] = (Byte)((((uint32_t)1 << numBits) - 1) << (8 - numBits)); } return SZ_OK; } -static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, UInt32 numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) +static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, uint32_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) { - UInt32 i; + uint32_t i; CSzData sd; - UInt32 *vals; + uint32_t *vals; const Byte *defs; - MY_ALLOC_ZE(UInt32, crcs->Vals, numItems, alloc); + MY_ALLOC_ZE(uint32_t, crcs->Vals, numItems, alloc); sd = *sd2; defs = crcs->Defs; vals = crcs->Vals; @@ -354,17 +354,17 @@ static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, UInt32 numItems, CSzBitUi32s *c return SZ_OK; } -static SRes ReadBitUi32s(CSzData *sd, UInt32 numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) +static SRes ReadBitUi32s(CSzData *sd, uint32_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) { SzBitUi32s_Free(crcs, alloc); RINOK(ReadBitVector(sd, numItems, &crcs->Defs, alloc)); return ReadUi32s(sd, numItems, crcs, alloc); } -static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems) +static SRes SkipBitUi32s(CSzData *sd, uint32_t numItems) { Byte allAreDefined; - UInt32 numDefined = numItems; + uint32_t numDefined = numItems; SZ_READ_BYTE(allAreDefined); if (!allAreDefined) { @@ -385,14 +385,14 @@ static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) RINOK(SzReadNumber32(sd, &p->NumPackStreams)); RINOK(WaitId(sd, k7zIdSize)); - MY_ALLOC(UInt64, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc); + MY_ALLOC(uint64_t, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc); { - UInt64 sum = 0; - UInt32 i; - UInt32 numPackStreams = p->NumPackStreams; + uint64_t sum = 0; + uint32_t i; + uint32_t numPackStreams = p->NumPackStreams; for (i = 0; i < numPackStreams; i++) { - UInt64 packSize; + uint64_t packSize; p->PackPositions[i] = sum; RINOK(ReadNumber(sd, &packSize)); sum += packSize; @@ -404,7 +404,7 @@ static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) for (;;) { - UInt64 type; + uint64_t type; RINOK(ReadID(sd, &type)); if (type == k7zIdEnd) return SZ_OK; @@ -431,8 +431,8 @@ static SRes SzReadSwitch(CSzData *sd) SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) { - UInt32 numCoders, i; - UInt32 numInStreams = 0; + uint32_t numCoders, i; + uint32_t numInStreams = 0; const Byte *dataStart = sd->Data; f->NumCoders = 0; @@ -449,7 +449,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) Byte mainByte; CSzCoderInfo *coder = f->Coders + i; unsigned idSize, j; - UInt64 id; + uint64_t id; SZ_READ_BYTE(mainByte); if ((mainByte & 0xC0) != 0) @@ -467,9 +467,9 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) sd->Data++; sd->Size--; } - if (id > (UInt32)0xFFFFFFFF) + if (id > (uint32_t)0xFFFFFFFF) return SZ_ERROR_UNSUPPORTED; - coder->MethodID = (UInt32)id; + coder->MethodID = (uint32_t)id; coder->NumStreams = 1; coder->PropsOffset = 0; @@ -477,7 +477,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) if ((mainByte & 0x10) != 0) { - UInt32 numStreams; + uint32_t numStreams; RINOK(SzReadNumber32(sd, &numStreams)); if (numStreams > k_NumCodersStreams_in_Folder_MAX) @@ -496,7 +496,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) if ((mainByte & 0x20) != 0) { - UInt32 propsSize = 0; + uint32_t propsSize = 0; RINOK(SzReadNumber32(sd, &propsSize)); if (propsSize > sd->Size) return SZ_ERROR_ARCHIVE; @@ -519,7 +519,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) */ { Byte streamUsed[k_NumCodersStreams_in_Folder_MAX]; - UInt32 numBonds, numPackStreams; + uint32_t numBonds, numPackStreams; numBonds = numCoders - 1; if (numInStreams < numBonds) @@ -581,7 +581,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) else for (i = 0; i < numPackStreams; i++) { - UInt32 index; + uint32_t index; RINOK(SzReadNumber32(sd, &index)); if (index >= numInStreams || streamUsed[index]) return SZ_ERROR_ARCHIVE; @@ -596,7 +596,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) } -static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num) +static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, uint32_t num) { CSzData sd; sd = *sd2; @@ -633,13 +633,13 @@ static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num) static SRes ReadUnpackInfo(CSzAr *p, CSzData *sd2, - UInt32 numFoldersMax, - const CBuf *tempBufs, UInt32 numTempBufs, + uint32_t numFoldersMax, + const CBuf *tempBufs, uint32_t numTempBufs, ISzAllocPtr alloc) { CSzData sd; - UInt32 fo, numFolders, numCodersOutStreams, packStreamIndex; + uint32_t fo, numFolders, numCodersOutStreams, packStreamIndex; const Byte *startBufPtr; Byte external; @@ -655,7 +655,7 @@ static SRes ReadUnpackInfo(CSzAr *p, sd = *sd2; else { - UInt32 index; + uint32_t index; RINOK(SzReadNumber32(sd2, &index)); if (index >= numTempBufs) return SZ_ERROR_ARCHIVE; @@ -664,8 +664,8 @@ static SRes ReadUnpackInfo(CSzAr *p, } MY_ALLOC(size_t, p->FoCodersOffsets, (size_t)numFolders + 1, alloc); - MY_ALLOC(UInt32, p->FoStartPackStreamIndex, (size_t)numFolders + 1, alloc); - MY_ALLOC(UInt32, p->FoToCoderUnpackSizes, (size_t)numFolders + 1, alloc); + MY_ALLOC(uint32_t, p->FoStartPackStreamIndex, (size_t)numFolders + 1, alloc); + MY_ALLOC(uint32_t, p->FoToCoderUnpackSizes, (size_t)numFolders + 1, alloc); MY_ALLOC_ZE(Byte, p->FoToMainUnpackSizeIndex, (size_t)numFolders, alloc); startBufPtr = sd.Data; @@ -675,7 +675,7 @@ static SRes ReadUnpackInfo(CSzAr *p, for (fo = 0; fo < numFolders; fo++) { - UInt32 numCoders, ci, numInStreams = 0; + uint32_t numCoders, ci, numInStreams = 0; p->FoCodersOffsets[fo] = sd.Data - startBufPtr; @@ -687,7 +687,7 @@ static SRes ReadUnpackInfo(CSzAr *p, { Byte mainByte; unsigned idSize; - UInt32 coderInStreams; + uint32_t coderInStreams; SZ_READ_BYTE_2(mainByte); if ((mainByte & 0xC0) != 0) @@ -703,7 +703,7 @@ static SRes ReadUnpackInfo(CSzAr *p, if ((mainByte & 0x10) != 0) { - UInt32 coderOutStreams; + uint32_t coderOutStreams; RINOK(SzReadNumber32(&sd, &coderInStreams)); RINOK(SzReadNumber32(&sd, &coderOutStreams)); if (coderInStreams > k_Scan_NumCodersStreams_in_Folder_MAX || coderOutStreams != 1) @@ -714,7 +714,7 @@ static SRes ReadUnpackInfo(CSzAr *p, if ((mainByte & 0x20) != 0) { - UInt32 propsSize; + uint32_t propsSize; RINOK(SzReadNumber32(&sd, &propsSize)); if (propsSize > sd.Size) return SZ_ERROR_ARCHIVE; @@ -723,16 +723,16 @@ static SRes ReadUnpackInfo(CSzAr *p, } { - UInt32 indexOfMainStream = 0; - UInt32 numPackStreams = 1; + uint32_t indexOfMainStream = 0; + uint32_t numPackStreams = 1; if (numCoders != 1 || numInStreams != 1) { Byte streamUsed[k_Scan_NumCodersStreams_in_Folder_MAX]; Byte coderUsed[k_Scan_NumCoders_MAX]; - UInt32 i; - UInt32 numBonds = numCoders - 1; + uint32_t i; + uint32_t numBonds = numCoders - 1; if (numInStreams < numBonds) return SZ_ERROR_ARCHIVE; @@ -746,7 +746,7 @@ static SRes ReadUnpackInfo(CSzAr *p, for (i = 0; i < numBonds; i++) { - UInt32 index; + uint32_t index; RINOK(SzReadNumber32(&sd, &index)); if (index >= numInStreams || streamUsed[index]) @@ -764,7 +764,7 @@ static SRes ReadUnpackInfo(CSzAr *p, if (numPackStreams != 1) for (i = 0; i < numPackStreams; i++) { - UInt32 index; + uint32_t index; RINOK(SzReadNumber32(&sd, &index)); if (index >= numInStreams || streamUsed[index]) return SZ_ERROR_ARCHIVE; @@ -812,9 +812,9 @@ static SRes ReadUnpackInfo(CSzAr *p, RINOK(WaitId(&sd, k7zIdCodersUnpackSize)); - MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc); + MY_ALLOC_ZE(uint64_t, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc); { - UInt32 i; + uint32_t i; for (i = 0; i < numCodersOutStreams; i++) { RINOK(ReadNumber(&sd, p->CoderUnpackSizes + i)); @@ -823,7 +823,7 @@ static SRes ReadUnpackInfo(CSzAr *p, for (;;) { - UInt64 type; + uint64_t type; RINOK(ReadID(&sd, &type)); if (type == k7zIdEnd) { @@ -840,7 +840,7 @@ static SRes ReadUnpackInfo(CSzAr *p, } -UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex) +uint64_t SzAr_GetFolderUnpackSize(const CSzAr *p, uint32_t folderIndex) { return p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex] + p->FoToMainUnpackSizeIndex[folderIndex]]; } @@ -848,8 +848,8 @@ UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex) typedef struct { - UInt32 NumTotalSubStreams; - UInt32 NumSubDigests; + uint32_t NumTotalSubStreams; + uint32_t NumSubDigests; CSzData sdNumSubStreams; CSzData sdSizes; CSzData sdCRCs; @@ -858,24 +858,24 @@ typedef struct static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) { - UInt64 type = 0; - UInt32 numSubDigests = 0; - UInt32 numFolders = p->NumFolders; - UInt32 numUnpackStreams = numFolders; - UInt32 numUnpackSizesInData = 0; + uint64_t type = 0; + uint32_t numSubDigests = 0; + uint32_t numFolders = p->NumFolders; + uint32_t numUnpackStreams = numFolders; + uint32_t numUnpackSizesInData = 0; for (;;) { RINOK(ReadID(sd, &type)); if (type == k7zIdNumUnpackStream) { - UInt32 i; + uint32_t i; ssi->sdNumSubStreams.Data = sd->Data; numUnpackStreams = 0; numSubDigests = 0; for (i = 0; i < numFolders; i++) { - UInt32 numStreams; + uint32_t numStreams; RINOK(SzReadNumber32(sd, &numStreams)); if (numUnpackStreams > numUnpackStreams + numStreams) return SZ_ERROR_UNSUPPORTED; @@ -931,12 +931,12 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) static SRes SzReadStreamsInfo(CSzAr *p, CSzData *sd, - UInt32 numFoldersMax, const CBuf *tempBufs, UInt32 numTempBufs, - UInt64 *dataOffset, + uint32_t numFoldersMax, const CBuf *tempBufs, uint32_t numTempBufs, + uint64_t *dataOffset, CSubStreamInfo *ssi, ISzAllocPtr alloc) { - UInt64 type; + uint64_t type; SzData_Clear(&ssi->sdSizes); SzData_Clear(&ssi->sdCRCs); @@ -973,13 +973,13 @@ static SRes SzReadAndDecodePackedStreams( ILookInStream *inStream, CSzData *sd, CBuf *tempBufs, - UInt32 numFoldersMax, - UInt64 baseOffset, + uint32_t numFoldersMax, + uint64_t baseOffset, CSzAr *p, ISzAllocPtr allocTemp) { - UInt64 dataStartPos; - UInt32 fo; + uint64_t dataStartPos; + uint32_t fo; CSubStreamInfo ssi; RINOK(SzReadStreamsInfo(p, sd, numFoldersMax, NULL, 0, &dataStartPos, &ssi, allocTemp)); @@ -994,7 +994,7 @@ static SRes SzReadAndDecodePackedStreams( for (fo = 0; fo < p->NumFolders; fo++) { CBuf *tempBuf = tempBufs + fo; - UInt64 unpackSize = SzAr_GetFolderUnpackSize(p, fo); + uint64_t unpackSize = SzAr_GetFolderUnpackSize(p, fo); if ((size_t)unpackSize != unpackSize) return SZ_ERROR_MEM; if (!Buf_Create(tempBuf, (size_t)unpackSize, allocTemp)) @@ -1011,7 +1011,7 @@ static SRes SzReadAndDecodePackedStreams( return SZ_OK; } -static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size_t *offsets) +static SRes SzReadFileNames(const Byte *data, size_t size, uint32_t numFiles, size_t *offsets) { size_t pos = 0; *offsets++ = 0; @@ -1028,7 +1028,7 @@ static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size return SZ_ERROR_ARCHIVE; for (p = data + pos; #ifdef _WIN32 - *(const UInt16 *)p != 0 + *(const uint16_t *)p != 0 #else p[0] != 0 || p[1] != 0 #endif @@ -1040,13 +1040,13 @@ static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; } -static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num, +static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, uint32_t num, CSzData *sd2, - const CBuf *tempBufs, UInt32 numTempBufs, + const CBuf *tempBufs, uint32_t numTempBufs, ISzAllocPtr alloc) { CSzData sd; - UInt32 i; + uint32_t i; CNtfsFileTime *vals; Byte *defs; Byte external; @@ -1058,7 +1058,7 @@ static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num, sd = *sd2; else { - UInt32 index; + uint32_t index; RINOK(SzReadNumber32(sd2, &index)); if (index >= numTempBufs) return SZ_ERROR_ARCHIVE; @@ -1095,7 +1095,7 @@ static SRes SzReadHeader2( CSzArEx *p, /* allocMain */ CSzData *sd, ILookInStream *inStream, - CBuf *tempBufs, UInt32 *numTempBufs, + CBuf *tempBufs, uint32_t *numTempBufs, ISzAllocPtr allocMain, ISzAllocPtr allocTemp ) @@ -1103,7 +1103,7 @@ static SRes SzReadHeader2( CSubStreamInfo ssi; { - UInt64 type; + uint64_t type; SzData_Clear(&ssi.sdSizes); SzData_Clear(&ssi.sdCRCs); @@ -1118,7 +1118,7 @@ static SRes SzReadHeader2( { for (;;) { - UInt64 type2; + uint64_t type2; RINOK(ReadID(sd, &type2)); if (type2 == k7zIdEnd) break; @@ -1145,7 +1145,7 @@ static SRes SzReadHeader2( if (type == k7zIdMainStreamsInfo) { - RINOK(SzReadStreamsInfo(&p->db, sd, (UInt32)1 << 30, tempBufs, *numTempBufs, + RINOK(SzReadStreamsInfo(&p->db, sd, (uint32_t)1 << 30, tempBufs, *numTempBufs, &p->dataPos, &ssi, allocMain)); p->dataPos += p->startPosAfterHeader; RINOK(ReadID(sd, &type)); @@ -1161,8 +1161,8 @@ static SRes SzReadHeader2( } { - UInt32 numFiles = 0; - UInt32 numEmptyStreams = 0; + uint32_t numFiles = 0; + uint32_t numEmptyStreams = 0; const Byte *emptyStreams = NULL; const Byte *emptyFiles = NULL; @@ -1171,8 +1171,8 @@ static SRes SzReadHeader2( for (;;) { - UInt64 type; - UInt64 size; + uint64_t type; + uint64_t size; RINOK(ReadID(sd, &type)); if (type == k7zIdEnd) break; @@ -1180,7 +1180,7 @@ static SRes SzReadHeader2( if (size > sd->Size) return SZ_ERROR_ARCHIVE; - if (type >= ((UInt32)1 << 8)) + if (type >= ((uint32_t)1 << 8)) { SKIP_DATA(sd, size); } @@ -1200,7 +1200,7 @@ static SRes SzReadHeader2( } else { - UInt32 index; + uint32_t index; RINOK(SzReadNumber32(sd, &index)); if (index >= *numTempBufs) return SZ_ERROR_ARCHIVE; @@ -1244,7 +1244,7 @@ static SRes SzReadHeader2( sdPtr = sd; else { - UInt32 index; + uint32_t index; RINOK(SzReadNumber32(sd, &index)); if (index >= *numTempBufs) return SZ_ERROR_ARCHIVE; @@ -1279,7 +1279,7 @@ static SRes SzReadHeader2( for (;;) { - UInt64 type; + uint64_t type; RINOK(ReadID(sd, &type)); if (type == k7zIdEnd) break; @@ -1287,24 +1287,24 @@ static SRes SzReadHeader2( } { - UInt32 i; - UInt32 emptyFileIndex = 0; - UInt32 folderIndex = 0; - UInt32 remSubStreams = 0; - UInt32 numSubStreams = 0; - UInt64 unpackPos = 0; + uint32_t i; + uint32_t emptyFileIndex = 0; + uint32_t folderIndex = 0; + uint32_t remSubStreams = 0; + uint32_t numSubStreams = 0; + uint64_t unpackPos = 0; const Byte *digestsDefs = NULL; const Byte *digestsVals = NULL; - UInt32 digestsValsIndex = 0; - UInt32 digestIndex; + uint32_t digestsValsIndex = 0; + uint32_t digestIndex; Byte allDigestsDefined = 0; Byte isDirMask = 0; Byte crcMask = 0; Byte mask = 0x80; - MY_ALLOC(UInt32, p->FolderToFile, p->db.NumFolders + 1, allocMain); - MY_ALLOC_ZE(UInt32, p->FileToFolder, p->NumFiles, allocMain); - MY_ALLOC(UInt64, p->UnpackPositions, p->NumFiles + 1, allocMain); + MY_ALLOC(uint32_t, p->FolderToFile, p->db.NumFolders + 1, allocMain); + MY_ALLOC_ZE(uint32_t, p->FileToFolder, p->NumFiles, allocMain); + MY_ALLOC(uint64_t, p->UnpackPositions, p->NumFiles + 1, allocMain); MY_ALLOC_ZE(Byte, p->IsDirs, (p->NumFiles + 7) >> 3, allocMain); RINOK(SzBitUi32s_Alloc(&p->CRCs, p->NumFiles, allocMain)); @@ -1328,7 +1328,7 @@ static SRes SzReadHeader2( { if (mask == 0) { - UInt32 byteIndex = (i - 1) >> 3; + uint32_t byteIndex = (i - 1) >> 3; p->IsDirs[byteIndex] = isDirMask; p->CRCs.Defs[byteIndex] = crcMask; isDirMask = 0; @@ -1351,7 +1351,7 @@ static SRes SzReadHeader2( isDirMask |= mask; if (remSubStreams == 0) { - p->FileToFolder[i] = (UInt32)-1; + p->FileToFolder[i] = (uint32_t)-1; continue; } } @@ -1372,7 +1372,7 @@ static SRes SzReadHeader2( if (numSubStreams != 0) break; { - UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); + uint64_t folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); unpackPos += folderUnpackSize; if (unpackPos < folderUnpackSize) return SZ_ERROR_ARCHIVE; @@ -1389,8 +1389,8 @@ static SRes SzReadHeader2( if (--remSubStreams == 0) { - UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); - UInt64 startFolderUnpackPos = p->UnpackPositions[p->FolderToFile[folderIndex]]; + uint64_t folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); + uint64_t startFolderUnpackPos = p->UnpackPositions[p->FolderToFile[folderIndex]]; if (folderUnpackSize < unpackPos - startFolderUnpackPos) return SZ_ERROR_ARCHIVE; unpackPos = startFolderUnpackPos + folderUnpackSize; @@ -1413,7 +1413,7 @@ static SRes SzReadHeader2( } else { - UInt64 v; + uint64_t v; RINOK(ReadNumber(&ssi.sdSizes, &v)); unpackPos += v; if (unpackPos < v) @@ -1429,7 +1429,7 @@ static SRes SzReadHeader2( if (mask != 0x80) { - UInt32 byteIndex = (i - 1) >> 3; + uint32_t byteIndex = (i - 1) >> 3; p->IsDirs[byteIndex] = isDirMask; p->CRCs.Defs[byteIndex] = crcMask; } @@ -1451,7 +1451,7 @@ static SRes SzReadHeader2( return SZ_ERROR_ARCHIVE; /* { - UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); + uint64_t folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); unpackPos += folderUnpackSize; if (unpackPos < folderUnpackSize) return SZ_ERROR_ARCHIVE; @@ -1475,8 +1475,8 @@ static SRes SzReadHeader( ISzAllocPtr allocMain, ISzAllocPtr allocTemp) { - UInt32 i; - UInt32 numTempBufs = 0; + uint32_t i; + uint32_t numTempBufs = 0; SRes res; CBuf tempBufs[NUM_ADDITIONAL_STREAMS_MAX]; @@ -1506,9 +1506,9 @@ static SRes SzArEx_Open2( { Byte header[k7zStartHeaderSize]; Int64 startArcPos; - UInt64 nextHeaderOffset, nextHeaderSize; + uint64_t nextHeaderOffset, nextHeaderSize; size_t nextHeaderSizeT; - UInt32 nextHeaderCRC; + uint32_t nextHeaderCRC; CBuf buf; SRes res; @@ -1543,9 +1543,9 @@ static SRes SzArEx_Open2( { Int64 pos = 0; RINOK(ILookInStream_Seek(inStream, &pos, SZ_SEEK_END)); - if ((UInt64)pos < startArcPos + nextHeaderOffset || - (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || - (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) + if ((uint64_t)pos < startArcPos + nextHeaderOffset || + (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || + (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) return SZ_ERROR_INPUT_EOF; } @@ -1562,7 +1562,7 @@ static SRes SzArEx_Open2( if (CrcCalc(buf.data, nextHeaderSizeT) == nextHeaderCRC) { CSzData sd; - UInt64 type; + uint64_t type; sd.Data = buf.data; sd.Size = buf.size; @@ -1635,8 +1635,8 @@ SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, SRes SzArEx_Extract( const CSzArEx *p, ILookInStream *inStream, - UInt32 fileIndex, - UInt32 *blockIndex, + uint32_t fileIndex, + uint32_t *blockIndex, Byte **tempBuf, size_t *outBufferSize, size_t *offset, @@ -1644,13 +1644,13 @@ SRes SzArEx_Extract( ISzAllocPtr allocMain, ISzAllocPtr allocTemp) { - UInt32 folderIndex = p->FileToFolder[fileIndex]; + uint32_t folderIndex = p->FileToFolder[fileIndex]; SRes res = SZ_OK; *offset = 0; *outSizeProcessed = 0; - if (folderIndex == (UInt32)-1) + if (folderIndex == (uint32_t)-1) { ISzAlloc_Free(allocMain, *tempBuf); *blockIndex = folderIndex; @@ -1661,9 +1661,9 @@ SRes SzArEx_Extract( if (*tempBuf == NULL || *blockIndex != folderIndex) { - UInt64 unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex); + uint64_t unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex); /* - UInt64 unpackSizeSpec = + uint64_t unpackSizeSpec = p->UnpackPositions[p->FolderToFile[(size_t)folderIndex + 1]] - p->UnpackPositions[p->FolderToFile[folderIndex]]; */ @@ -1695,7 +1695,7 @@ SRes SzArEx_Extract( if (res == SZ_OK) { - UInt64 unpackPos = p->UnpackPositions[fileIndex]; + uint64_t unpackPos = p->UnpackPositions[fileIndex]; *offset = (size_t)(unpackPos - p->UnpackPositions[p->FolderToFile[folderIndex]]); *outSizeProcessed = (size_t)(p->UnpackPositions[(size_t)fileIndex + 1] - unpackPos); if (*offset + *outSizeProcessed > *outBufferSize) @@ -1709,7 +1709,7 @@ SRes SzArEx_Extract( } -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest) +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest) { size_t offs = p->FileNameOffsets[fileIndex]; size_t len = p->FileNameOffsets[fileIndex + 1] - offs; @@ -1732,17 +1732,17 @@ size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex) len = 0; for (;;) { - UInt32 parent = (UInt32)(Int32)-1; + uint32_t parent = (uint32_t)(Int32)-1; len += p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; if SzBitWithVals_Check(&p->Parents, fileIndex) parent = p->Parents.Vals[fileIndex]; - if (parent == (UInt32)(Int32)-1) + if (parent == (uint32_t)(Int32)-1) return len; fileIndex = parent; } } -UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest) +uint16_t *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, uint16_t *dest) { BoolInt needSlash; if (!p->FileNameOffsets) @@ -1753,7 +1753,7 @@ UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 needSlash = False; for (;;) { - UInt32 parent = (UInt32)(Int32)-1; + uint32_t parent = (uint32_t)(Int32)-1; size_t curLen = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; SzArEx_GetFileNameUtf16(p, fileIndex, dest - curLen); if (needSlash) @@ -1763,7 +1763,7 @@ UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 if SzBitWithVals_Check(&p->Parents, fileIndex) parent = p->Parents.Vals[fileIndex]; - if (parent == (UInt32)(Int32)-1) + if (parent == (uint32_t)(Int32)-1) return dest; fileIndex = parent; } diff --git a/deps/7zip/7zCrc.c b/deps/7zip/7zCrc.c index b4d84f0233..55e4679b70 100644 --- a/deps/7zip/7zCrc.c +++ b/deps/7zip/7zCrc.c @@ -15,36 +15,36 @@ #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) - UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table); - UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table); + uint32_t MY_FAST_CALL CrcUpdateT1_BeT4(uint32_t v, const void *data, size_t size, const uint32_t *table); + uint32_t MY_FAST_CALL CrcUpdateT1_BeT8(uint32_t v, const void *data, size_t size, const uint32_t *table); #endif #ifndef MY_CPU_BE - UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); - UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); + uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); + uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); #endif -typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table); +typedef uint32_t (MY_FAST_CALL *CRC_FUNC)(uint32_t v, const void *data, size_t size, const uint32_t *table); CRC_FUNC g_CrcUpdateT4; CRC_FUNC g_CrcUpdateT8; CRC_FUNC g_CrcUpdate; -UInt32 g_CrcTable[256 * CRC_NUM_TABLES]; +uint32_t g_CrcTable[256 * CRC_NUM_TABLES]; -UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size) +uint32_t MY_FAST_CALL CrcUpdate(uint32_t v, const void *data, size_t size) { return g_CrcUpdate(v, data, size, g_CrcTable); } -UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size) +uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size) { return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; } #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) -UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table) +uint32_t MY_FAST_CALL CrcUpdateT1(uint32_t v, const void *data, size_t size, const uint32_t *table) { const Byte *p = (const Byte *)data; const Byte *pEnd = p + size; @@ -55,18 +55,18 @@ UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const U void MY_FAST_CALL CrcGenerateTable() { - UInt32 i; + uint32_t i; for (i = 0; i < 256; i++) { - UInt32 r = i; + uint32_t r = i; unsigned j; for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); + r = (r >> 1) ^ (kCrcPoly & ((uint32_t)0 - (r & 1))); g_CrcTable[i] = r; } for (i = 256; i < 256 * CRC_NUM_TABLES; i++) { - UInt32 r = g_CrcTable[(size_t)i - 256]; + uint32_t r = g_CrcTable[(size_t)i - 256]; g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); } @@ -93,7 +93,7 @@ void MY_FAST_CALL CrcGenerateTable() #else { #ifndef MY_CPU_BE - UInt32 k = 0x01020304; + uint32_t k = 0x01020304; const Byte *p = (const Byte *)&k; if (p[0] == 4 && p[1] == 3) { @@ -111,7 +111,7 @@ void MY_FAST_CALL CrcGenerateTable() { for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--) { - UInt32 x = g_CrcTable[(size_t)i - 256]; + uint32_t x = g_CrcTable[(size_t)i - 256]; g_CrcTable[i] = CRC_UINT32_SWAP(x); } g_CrcUpdateT4 = CrcUpdateT1_BeT4; diff --git a/deps/7zip/7zCrc.h b/deps/7zip/7zCrc.h index 8fd5795871..ca377188ca 100644 --- a/deps/7zip/7zCrc.h +++ b/deps/7zip/7zCrc.h @@ -8,7 +8,7 @@ EXTERN_C_BEGIN -extern UInt32 g_CrcTable[]; +extern uint32_t g_CrcTable[]; /* Call CrcGenerateTable one time before other CRC functions */ void MY_FAST_CALL CrcGenerateTable(void); @@ -17,8 +17,8 @@ void MY_FAST_CALL CrcGenerateTable(void); #define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) #define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) -UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size); -UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size); +uint32_t MY_FAST_CALL CrcUpdate(uint32_t crc, const void *data, size_t size); +uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size); EXTERN_C_END diff --git a/deps/7zip/7zCrcOpt.c b/deps/7zip/7zCrcOpt.c index 73beba298d..f8b0f9aff3 100644 --- a/deps/7zip/7zCrcOpt.c +++ b/deps/7zip/7zCrcOpt.c @@ -9,14 +9,14 @@ #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) -UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table) +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table) { const Byte *p = (const Byte *)data; for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) v = CRC_UPDATE_BYTE_2(v, *p); for (; size >= 4; size -= 4, p += 4) { - v ^= *(const UInt32 *)p; + v ^= *(const uint32_t *)p; v = (table + 0x300)[((v ) & 0xFF)] ^ (table + 0x200)[((v >> 8) & 0xFF)] @@ -28,21 +28,21 @@ UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const U return v; } -UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table) +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table) { const Byte *p = (const Byte *)data; for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) v = CRC_UPDATE_BYTE_2(v, *p); for (; size >= 8; size -= 8, p += 8) { - UInt32 d; - v ^= *(const UInt32 *)p; + uint32_t d; + v ^= *(const uint32_t *)p; v = (table + 0x700)[((v ) & 0xFF)] ^ (table + 0x600)[((v >> 8) & 0xFF)] ^ (table + 0x500)[((v >> 16) & 0xFF)] ^ (table + 0x400)[((v >> 24))]; - d = *((const UInt32 *)p + 1); + d = *((const uint32_t *)p + 1); v ^= (table + 0x300)[((d ) & 0xFF)] ^ (table + 0x200)[((d >> 8) & 0xFF)] @@ -63,7 +63,7 @@ UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const U #define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(((crc) >> 24) ^ (b))] ^ ((crc) << 8)) -UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table) +uint32_t MY_FAST_CALL CrcUpdateT1_BeT4(uint32_t v, const void *data, size_t size, const uint32_t *table) { const Byte *p = (const Byte *)data; table += 0x100; @@ -72,7 +72,7 @@ UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, co v = CRC_UPDATE_BYTE_2_BE(v, *p); for (; size >= 4; size -= 4, p += 4) { - v ^= *(const UInt32 *)p; + v ^= *(const uint32_t *)p; v = (table + 0x000)[((v ) & 0xFF)] ^ (table + 0x100)[((v >> 8) & 0xFF)] @@ -84,7 +84,7 @@ UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, co return CRC_UINT32_SWAP(v); } -UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table) +uint32_t MY_FAST_CALL CrcUpdateT1_BeT8(uint32_t v, const void *data, size_t size, const uint32_t *table) { const Byte *p = (const Byte *)data; table += 0x100; @@ -93,14 +93,14 @@ UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, co v = CRC_UPDATE_BYTE_2_BE(v, *p); for (; size >= 8; size -= 8, p += 8) { - UInt32 d; - v ^= *(const UInt32 *)p; + uint32_t d; + v ^= *(const uint32_t *)p; v = (table + 0x400)[((v ) & 0xFF)] ^ (table + 0x500)[((v >> 8) & 0xFF)] ^ (table + 0x600)[((v >> 16) & 0xFF)] ^ (table + 0x700)[((v >> 24))]; - d = *((const UInt32 *)p + 1); + d = *((const uint32_t *)p + 1); v ^= (table + 0x000)[((d ) & 0xFF)] ^ (table + 0x100)[((d >> 8) & 0xFF)] diff --git a/deps/7zip/7zDec.c b/deps/7zip/7zDec.c index 7c46352111..ed7e5de7d9 100644 --- a/deps/7zip/7zDec.c +++ b/deps/7zip/7zDec.c @@ -43,7 +43,7 @@ typedef struct const Byte *cur; const Byte *end; const Byte *begin; - UInt64 processed; + uint64_t processed; BoolInt extra; SRes res; const ILookInStream *inStream; @@ -70,7 +70,7 @@ static Byte ReadByte(const IByteIn *pp) return 0; } -static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, const ILookInStream *inStream, +static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, uint64_t inSize, const ILookInStream *inStream, Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) { CPpmd7 ppmd; @@ -89,7 +89,7 @@ static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, c { unsigned order = props[0]; - UInt32 memSize = GetUi32(props + 1); + uint32_t memSize = GetUi32(props + 1); if (order < PPMD7_MIN_ORDER || order > PPMD7_MAX_ORDER || memSize < PPMD7_MIN_MEM_SIZE || @@ -131,7 +131,7 @@ static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, c #endif -static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream, +static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, uint64_t inSize, ILookInStream *inStream, Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) { CLzmaDec state; @@ -191,7 +191,7 @@ static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, I #ifndef _7Z_NO_METHOD_LZMA2 -static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream, +static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, uint64_t inSize, ILookInStream *inStream, Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) { CLzma2Dec state; @@ -250,7 +250,7 @@ static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize, #endif -static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer) +static SRes SzDecodeCopy(uint64_t inSize, ILookInStream *inStream, Byte *outBuffer) { while (inSize > 0) { @@ -269,7 +269,7 @@ static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer return SZ_OK; } -static BoolInt IS_MAIN_METHOD(UInt32 m) +static BoolInt IS_MAIN_METHOD(uint32_t m) { switch (m) { @@ -290,8 +290,8 @@ static BoolInt IS_SUPPORTED_CODER(const CSzCoderInfo *c) { return c->NumStreams == 1 - /* && c->MethodID <= (UInt32)0xFFFFFFFF */ - && IS_MAIN_METHOD((UInt32)c->MethodID); + /* && c->MethodID <= (uint32_t)0xFFFFFFFF */ + && IS_MAIN_METHOD((uint32_t)c->MethodID); } #define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumStreams == 4) @@ -316,7 +316,7 @@ static SRes CheckSupportedFolder(const CSzFolder *f) { const CSzCoderInfo *c = &f->Coders[1]; if ( - /* c->MethodID > (UInt32)0xFFFFFFFF || */ + /* c->MethodID > (uint32_t)0xFFFFFFFF || */ c->NumStreams != 1 || f->NumPackStreams != 1 || f->PackStreams[0] != 0 @@ -324,7 +324,7 @@ static SRes CheckSupportedFolder(const CSzFolder *f) || f->Bonds[0].InIndex != 1 || f->Bonds[0].OutIndex != 0) return SZ_ERROR_UNSUPPORTED; - switch ((UInt32)c->MethodID) + switch ((uint32_t)c->MethodID) { case k_Delta: case k_BCJ: @@ -369,13 +369,13 @@ static SRes CheckSupportedFolder(const CSzFolder *f) static SRes SzFolder_Decode2(const CSzFolder *folder, const Byte *propsData, - const UInt64 *unpackSizes, - const UInt64 *packPositions, - ILookInStream *inStream, UInt64 startPos, + const uint64_t *unpackSizes, + const uint64_t *packPositions, + ILookInStream *inStream, uint64_t startPos, Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain, Byte *tempBuf[]) { - UInt32 ci; + uint32_t ci; SizeT tempSizes[3] = { 0, 0, 0}; SizeT tempSize3 = 0; Byte *tempBuf3 = 0; @@ -386,17 +386,17 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, { const CSzCoderInfo *coder = &folder->Coders[ci]; - if (IS_MAIN_METHOD((UInt32)coder->MethodID)) + if (IS_MAIN_METHOD((uint32_t)coder->MethodID)) { - UInt32 si = 0; - UInt64 offset; - UInt64 inSize; + uint32_t si = 0; + uint64_t offset; + uint64_t inSize; Byte *outBufCur = outBuffer; SizeT outSizeCur = outSize; if (folder->NumCoders == 4) { - UInt32 indices[] = { 3, 2, 0 }; - UInt64 unpackSize = unpackSizes[ci]; + uint32_t indices[] = { 3, 2, 0 }; + uint64_t unpackSize = unpackSizes[ci]; si = indices[ci]; if (ci < 2) { @@ -451,8 +451,8 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, } else if (coder->MethodID == k_BCJ2) { - UInt64 offset = packPositions[1]; - UInt64 s3Size = packPositions[2] - offset; + uint64_t offset = packPositions[1]; + uint64_t s3Size = packPositions[2] - offset; if (ci != 3) return SZ_ERROR_UNSUPPORTED; @@ -522,7 +522,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, { case k_BCJ: { - UInt32 state; + uint32_t state; x86_Convert_Init(state); x86_Convert(outBuffer, outSize, 0, &state, 0); break; @@ -546,8 +546,8 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, } -SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, - ILookInStream *inStream, UInt64 startPos, +SRes SzAr_DecodeFolder(const CSzAr *p, uint32_t folderIndex, + ILookInStream *inStream, uint64_t startPos, Byte *outBuffer, size_t outSize, ISzAllocPtr allocMain) { diff --git a/deps/7zip/7zFile.c b/deps/7zip/7zFile.c index 8992fb1c59..04365c5750 100644 --- a/deps/7zip/7zFile.c +++ b/deps/7zip/7zFile.c @@ -173,7 +173,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) LARGE_INTEGER value; DWORD moveMethod; value.LowPart = (DWORD)*pos; - value.HighPart = (LONG)((UInt64)*pos >> 16 >> 16); /* for case when UInt64 is 32-bit only */ + value.HighPart = (LONG)((uint64_t)*pos >> 16 >> 16); /* for case when uint64_t is 32-bit only */ switch (origin) { case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break; @@ -209,7 +209,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) #endif } -WRes File_GetLength(CSzFile *p, UInt64 *length) +WRes File_GetLength(CSzFile *p, uint64_t *length) { #ifdef USE_WINDOWS_FILE @@ -221,7 +221,7 @@ WRes File_GetLength(CSzFile *p, UInt64 *length) if (res != NO_ERROR) return res; } - *length = (((UInt64)sizeHigh) << 32) + sizeLow; + *length = (((uint64_t)sizeHigh) << 32) + sizeLow; return 0; #else diff --git a/deps/7zip/7zFile.h b/deps/7zip/7zFile.h index 0e7925382c..e777aa111d 100644 --- a/deps/7zip/7zFile.h +++ b/deps/7zip/7zFile.h @@ -46,8 +46,8 @@ WRes File_Read(CSzFile *p, void *data, size_t *size); /* writes *size bytes */ WRes File_Write(CSzFile *p, const void *data, size_t *size); -WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin); -WRes File_GetLength(CSzFile *p, UInt64 *length); +WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin); +WRes File_GetLength(CSzFile *p, uint64_t *length); /* ---------- FileInStream ---------- */ diff --git a/deps/7zip/7zStream.c b/deps/7zip/7zStream.c index 6b5aa1621d..5a34e3769d 100644 --- a/deps/7zip/7zStream.c +++ b/deps/7zip/7zStream.c @@ -35,9 +35,9 @@ SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf) -SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset) +SRes LookInStream_SeekTo(const ILookInStream *stream, uint64_t offset) { - Int64 t = offset; + int64_t t = offset; return ILookInStream_Seek(stream, &t, SZ_SEEK_SET); } @@ -134,7 +134,7 @@ static SRes LookToRead2_Read(const ILookInStream *pp, void *buf, size_t *size) return SZ_OK; } -static SRes LookToRead2_Seek(const ILookInStream *pp, Int64 *pos, ESzSeek origin) +static SRes LookToRead2_Seek(const ILookInStream *pp, int64_t *pos, ESzSeek origin) { GET_LookToRead2 p->pos = p->size = 0; diff --git a/deps/7zip/7zTypes.h b/deps/7zip/7zTypes.h index cd0138ef99..f66a5f65cd 100644 --- a/deps/7zip/7zTypes.h +++ b/deps/7zip/7zTypes.h @@ -4,11 +4,8 @@ #ifndef __7Z_TYPES_H #define __7Z_TYPES_H -#ifdef _WIN32 -/* #include */ -#endif - #include +#include #ifndef EXTERN_C_BEGIN #ifdef __cplusplus @@ -67,15 +64,6 @@ typedef int WRes; typedef unsigned char Byte; #endif typedef short Int16; -typedef unsigned short UInt16; - -#if defined(_LZMA_UINT32_IS_ULONG) && !defined(__LP64__) -typedef long Int32; -typedef unsigned long UInt32; -#else -typedef int Int32; -typedef unsigned int UInt32; -#endif #ifdef _SZ_NO_INT_64 @@ -83,24 +71,20 @@ typedef unsigned int UInt32; NOTES: Some code will work incorrectly in that case! */ typedef long Int64; -typedef unsigned long UInt64; - #else #if defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 Int64; -typedef unsigned __int64 UInt64; #define UINT64_CONST(n) n #else typedef long long int Int64; -typedef unsigned long long int UInt64; #define UINT64_CONST(n) n ## ULL #endif #endif #ifdef _LZMA_NO_SYSTEM_SIZE_T -typedef UInt32 SizeT; +typedef uint32_t SizeT; #else typedef size_t SizeT; #endif @@ -232,7 +216,7 @@ struct ILookInStream SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size); -SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset); +SRes LookInStream_SeekTo(const ILookInStream *stream, uint64_t offset); /* reads via ILookInStream::Read */ SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType); @@ -281,9 +265,9 @@ typedef struct ICompressProgress ICompressProgress; struct ICompressProgress { - SRes (*Progress)(const ICompressProgress *p, UInt64 inSize, UInt64 outSize); + SRes (*Progress)(const ICompressProgress *p, uint64_t inSize, uint64_t outSize); /* Returns: result. (result != SZ_OK) means break. - Value (UInt64)(Int64)-1 for size means unknown value. */ + Value (uint64_t)(Int64)-1 for size means unknown value. */ }; #define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize) diff --git a/deps/7zip/Bcj2.c b/deps/7zip/Bcj2.c index 576f19eac8..efd8fee364 100644 --- a/deps/7zip/Bcj2.c +++ b/deps/7zip/Bcj2.c @@ -6,10 +6,10 @@ #include "Bcj2.h" #include "CpuArch.h" -#define CProb UInt16 +#define CProb uint16_t #undef kTopValue -#define kTopValue ((UInt32)1 << 24) +#define kTopValue ((uint32_t)1 << 24) #define kNumModelBits 11 #undef kBitModelTotal #define kBitModelTotal (1 << kNumModelBits) @@ -78,7 +78,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p) p->bufs[p->state] = cur + 4; { - UInt32 val; + uint32_t val; Byte *dest; SizeT rem; @@ -176,7 +176,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p) { p->temp[3] = src[-1]; p->bufs[BCJ2_STREAM_MAIN] = src; - p->ip += (UInt32)num; + p->ip += (uint32_t)num; p->dest += num; p->state = p->bufs[BCJ2_STREAM_MAIN] == @@ -187,7 +187,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p) } { - UInt32 bound, ttt; + uint32_t bound, ttt; CProb *prob; Byte b = src[0]; Byte prev = (Byte)(num == 0 ? p->temp[3] : src[-1]); @@ -195,7 +195,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p) p->temp[3] = b; p->bufs[BCJ2_STREAM_MAIN] = src + 1; num++; - p->ip += (UInt32)num; + p->ip += (uint32_t)num; p->dest += num; prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)prev : (b == 0xE9 ? 1 : 0)); @@ -212,7 +212,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p) } { - UInt32 val; + uint32_t val; unsigned cj = (p->temp[3] == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP; const Byte *cur = p->bufs[cj]; Byte *dest; diff --git a/deps/7zip/Bcj2.h b/deps/7zip/Bcj2.h index 8824080acf..058a5845a0 100644 --- a/deps/7zip/Bcj2.h +++ b/deps/7zip/Bcj2.h @@ -68,11 +68,11 @@ typedef struct unsigned state; /* BCJ2_STREAM_MAIN has more priority than BCJ2_STATE_ORIG */ - UInt32 ip; + uint32_t ip; Byte temp[4]; - UInt32 range; - UInt32 code; - UInt16 probs[2 + 256]; + uint32_t range; + uint32_t code; + uint16_t probs[2 + 256]; } CBcj2Dec; void Bcj2Dec_Init(CBcj2Dec *p); @@ -104,28 +104,28 @@ typedef struct Byte prevByte; Byte cache; - UInt32 range; - UInt64 low; - UInt64 cacheSize; + uint32_t range; + uint64_t low; + uint64_t cacheSize; - UInt32 ip; + uint32_t ip; /* 32-bit ralative offset in JUMP/CALL commands is - (mod 4 GB) in 32-bit mode - signed Int32 in 64-bit mode We use (mod 4 GB) check for fileSize. Use fileSize up to 2 GB, if you want to support 32-bit and 64-bit code conversion. */ - UInt32 fileIp; - UInt32 fileSize; /* (fileSize <= ((UInt32)1 << 31)), 0 means no_limit */ - UInt32 relatLimit; /* (relatLimit <= ((UInt32)1 << 31)), 0 means desable_conversion */ + uint32_t fileIp; + uint32_t fileSize; /* (fileSize <= ((uint32_t)1 << 31)), 0 means no_limit */ + uint32_t relatLimit; /* (relatLimit <= ((uint32_t)1 << 31)), 0 means desable_conversion */ - UInt32 tempTarget; + uint32_t tempTarget; unsigned tempPos; Byte temp[4 * 2]; unsigned flushPos; - UInt16 probs[2 + 256]; + uint16_t probs[2 + 256]; } CBcj2Enc; void Bcj2Enc_Init(CBcj2Enc *p); @@ -136,10 +136,10 @@ void Bcj2Enc_Encode(CBcj2Enc *p); #define BCJ2_RELAT_LIMIT_NUM_BITS 26 -#define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS) +#define BCJ2_RELAT_LIMIT ((uint32_t)1 << BCJ2_RELAT_LIMIT_NUM_BITS) /* limit for CBcj2Enc::fileSize variable */ -#define BCJ2_FileSize_MAX ((UInt32)1 << 31) +#define BCJ2_FileSize_MAX ((uint32_t)1 << 31) EXTERN_C_END diff --git a/deps/7zip/Bra.c b/deps/7zip/Bra.c index aed17e330d..d4aeda28a8 100644 --- a/deps/7zip/Bra.c +++ b/deps/7zip/Bra.c @@ -6,7 +6,7 @@ #include "CpuArch.h" #include "Bra.h" -SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +SizeT ARM_Convert(Byte *data, SizeT size, uint32_t ip, int encoding) { Byte *p; const Byte *lim; @@ -28,9 +28,9 @@ SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) break; } { - UInt32 v = GetUi32(p - 4); + uint32_t v = GetUi32(p - 4); v <<= 2; - v += ip + (UInt32)(p - data); + v += ip + (uint32_t)(p - data); v >>= 2; v &= 0x00FFFFFF; v |= 0xEB000000; @@ -49,9 +49,9 @@ SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) break; } { - UInt32 v = GetUi32(p - 4); + uint32_t v = GetUi32(p - 4); v <<= 2; - v -= ip + (UInt32)(p - data); + v -= ip + (uint32_t)(p - data); v >>= 2; v &= 0x00FFFFFF; v |= 0xEB000000; @@ -61,7 +61,7 @@ SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) } -SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +SizeT ARMT_Convert(Byte *data, SizeT size, uint32_t ip, int encoding) { Byte *p; const Byte *lim; @@ -73,10 +73,10 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) for (;;) { - UInt32 b1; + uint32_t b1; for (;;) { - UInt32 b3; + uint32_t b3; if (p > lim) return p - data; b1 = p[1]; @@ -87,15 +87,15 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) break; } { - UInt32 v = - ((UInt32)b1 << 19) - + (((UInt32)p[1] & 0x7) << 8) - + (((UInt32)p[-2] << 11)) + uint32_t v = + ((uint32_t)b1 << 19) + + (((uint32_t)p[1] & 0x7) << 8) + + (((uint32_t)p[-2] << 11)) + (p[0]); p += 2; { - UInt32 cur = (ip + (UInt32)(p - data)) >> 1; + uint32_t cur = (ip + (uint32_t)(p - data)) >> 1; v += cur; } @@ -108,10 +108,10 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) for (;;) { - UInt32 b1; + uint32_t b1; for (;;) { - UInt32 b3; + uint32_t b3; if (p > lim) return p - data; b1 = p[1]; @@ -122,21 +122,21 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) break; } { - UInt32 v = - ((UInt32)b1 << 19) - + (((UInt32)p[1] & 0x7) << 8) - + (((UInt32)p[-2] << 11)) + uint32_t v = + ((uint32_t)b1 << 19) + + (((uint32_t)p[1] & 0x7) << 8) + + (((uint32_t)p[-2] << 11)) + (p[0]); p += 2; { - UInt32 cur = (ip + (UInt32)(p - data)) >> 1; + uint32_t cur = (ip + (uint32_t)(p - data)) >> 1; v -= cur; } /* - SetUi16(p - 4, (UInt16)(((v >> 11) & 0x7FF) | 0xF000)); - SetUi16(p - 2, (UInt16)(v | 0xF800)); + SetUi16(p - 4, (uint16_t)(((v >> 11) & 0x7FF) | 0xF000)); + SetUi16(p - 2, (uint16_t)(v | 0xF800)); */ p[-4] = (Byte)(v >> 11); @@ -148,7 +148,7 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) } -SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +SizeT PPC_Convert(Byte *data, SizeT size, uint32_t ip, int encoding) { Byte *p; const Byte *lim; @@ -169,11 +169,11 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) break; } { - UInt32 v = GetBe32(p - 4); + uint32_t v = GetBe32(p - 4); if (encoding) - v += ip + (UInt32)(p - data); + v += ip + (uint32_t)(p - data); else - v -= ip + (UInt32)(p - data); + v -= ip + (uint32_t)(p - data); v &= 0x03FFFFFF; v |= 0x48000000; SetBe32(p - 4, v); @@ -182,7 +182,7 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) } -SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +SizeT SPARC_Convert(Byte *data, SizeT size, uint32_t ip, int encoding) { Byte *p; const Byte *lim; @@ -200,10 +200,10 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) /* v = GetBe32(p); p += 4; - m = v + ((UInt32)5 << 29); - m ^= (UInt32)7 << 29; - m += (UInt32)1 << 22; - if ((m & ((UInt32)0x1FF << 23)) == 0) + m = v + ((uint32_t)5 << 29); + m ^= (uint32_t)7 << 29; + m += (uint32_t)1 << 22; + if ((m & ((uint32_t)0x1FF << 23)) == 0) break; */ p += 4; @@ -212,15 +212,15 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) break; } { - UInt32 v = GetBe32(p - 4); + uint32_t v = GetBe32(p - 4); v <<= 2; if (encoding) - v += ip + (UInt32)(p - data); + v += ip + (uint32_t)(p - data); else - v -= ip + (UInt32)(p - data); + v -= ip + (uint32_t)(p - data); v &= 0x01FFFFFF; - v -= (UInt32)1 << 24; + v -= (uint32_t)1 << 24; v ^= 0xFF000000; v >>= 2; v |= 0x40000000; diff --git a/deps/7zip/Bra.h b/deps/7zip/Bra.h index 855e37a6b5..12ac048710 100644 --- a/deps/7zip/Bra.h +++ b/deps/7zip/Bra.h @@ -40,7 +40,7 @@ in CALL instructions to increase the compression ratio. Example: - UInt32 ip = 0; + uint32_t ip = 0; for () { ; size must be >= Alignment + LookAhead, if it's not last block @@ -52,12 +52,12 @@ in CALL instructions to increase the compression ratio. */ #define x86_Convert_Init(state) { state = 0; } -SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding); -SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); +SizeT x86_Convert(Byte *data, SizeT size, uint32_t ip, uint32_t *state, int encoding); +SizeT ARM_Convert(Byte *data, SizeT size, uint32_t ip, int encoding); +SizeT ARMT_Convert(Byte *data, SizeT size, uint32_t ip, int encoding); +SizeT PPC_Convert(Byte *data, SizeT size, uint32_t ip, int encoding); +SizeT SPARC_Convert(Byte *data, SizeT size, uint32_t ip, int encoding); +SizeT IA64_Convert(Byte *data, SizeT size, uint32_t ip, int encoding); EXTERN_C_END diff --git a/deps/7zip/Bra86.c b/deps/7zip/Bra86.c index 93ed4d762b..a5a1a846b3 100644 --- a/deps/7zip/Bra86.c +++ b/deps/7zip/Bra86.c @@ -7,10 +7,10 @@ #define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0) -SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding) +SizeT x86_Convert(Byte *data, SizeT size, uint32_t ip, uint32_t *state, int encoding) { SizeT pos = 0; - UInt32 mask = *state & 7; + uint32_t mask = *state & 7; if (size < 5) return 0; size -= 4; @@ -48,8 +48,8 @@ SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding if (Test86MSByte(p[4])) { - UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]); - UInt32 cur = ip + (UInt32)pos; + uint32_t v = ((uint32_t)p[4] << 24) | ((uint32_t)p[3] << 16) | ((uint32_t)p[2] << 8) | ((uint32_t)p[1]); + uint32_t cur = ip + (uint32_t)pos; pos += 5; if (encoding) v += cur; @@ -60,7 +60,7 @@ SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding unsigned sh = (mask & 6) << 2; if (Test86MSByte((Byte)(v >> sh))) { - v ^= (((UInt32)0x100 << sh) - 1); + v ^= (((uint32_t)0x100 << sh) - 1); if (encoding) v += cur; else diff --git a/deps/7zip/BraIA64.c b/deps/7zip/BraIA64.c index d1dbc62c55..d7cf391c77 100644 --- a/deps/7zip/BraIA64.c +++ b/deps/7zip/BraIA64.c @@ -6,7 +6,7 @@ #include "CpuArch.h" #include "Bra.h" -SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +SizeT IA64_Convert(Byte *data, SizeT size, uint32_t ip, int encoding) { SizeT i; if (size < 16) @@ -15,7 +15,7 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) i = 0; do { - unsigned m = ((UInt32)0x334B0000 >> (data[i] & 0x1E)) & 3; + unsigned m = ((uint32_t)0x334B0000 >> (data[i] & 0x1E)) & 3; if (m) { m++; @@ -23,7 +23,7 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) { Byte *p = data + (i + (size_t)m * 5 - 8); if (((p[3] >> m) & 15) == 5 - && (((p[-1] | ((UInt32)p[0] << 8)) >> m) & 0x70) == 0) + && (((p[-1] | ((uint32_t)p[0] << 8)) >> m) & 0x70) == 0) { unsigned raw = GetUi32(p); unsigned v = raw >> m; @@ -31,15 +31,15 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) v <<= 4; if (encoding) - v += ip + (UInt32)i; + v += ip + (uint32_t)i; else - v -= ip + (UInt32)i; + v -= ip + (uint32_t)i; v >>= 4; v &= 0x1FFFFF; v += 0x700000; v &= 0x8FFFFF; - raw &= ~((UInt32)0x8FFFFF << m); + raw &= ~((uint32_t)0x8FFFFF << m); raw |= (v << m); SetUi32(p, raw); } diff --git a/deps/7zip/CpuArch.c b/deps/7zip/CpuArch.c index ebafb30c03..74daa4def0 100644 --- a/deps/7zip/CpuArch.c +++ b/deps/7zip/CpuArch.c @@ -16,7 +16,7 @@ #endif #if defined(USE_ASM) && !defined(MY_CPU_AMD64) -static UInt32 CheckFlag(UInt32 flag) +static uint32_t CheckFlag(uint32_t flag) { #ifdef _MSC_VER __asm pushfd; @@ -55,13 +55,13 @@ static UInt32 CheckFlag(UInt32 flag) #define CHECK_CPUID_IS_SUPPORTED #endif -void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) +void MyCPUID(uint32_t function, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) { #ifdef USE_ASM #ifdef _MSC_VER - UInt32 a2, b2, c2, d2; + uint32_t a2, b2, c2, d2; __asm xor EBX, EBX; __asm xor ECX, ECX; __asm xor EDX, EDX; @@ -123,7 +123,7 @@ BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p) return True; } -static const UInt32 kVendors[][3] = +static const uint32_t kVendors[][3] = { { 0x756E6547, 0x49656E69, 0x6C65746E}, { 0x68747541, 0x69746E65, 0x444D4163}, @@ -135,7 +135,7 @@ int x86cpuid_GetFirm(const Cx86cpuid *p) unsigned i; for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++) { - const UInt32 *v = kVendors[i]; + const uint32_t *v = kVendors[i]; if (v[0] == p->vendor[0] && v[1] == p->vendor[1] && v[2] == p->vendor[2]) @@ -148,7 +148,7 @@ BoolInt CPU_Is_InOrder(void) { Cx86cpuid p; int firm; - UInt32 family, model; + uint32_t family, model; if (!x86cpuid_CheckAndRead(&p)) return True; @@ -203,13 +203,13 @@ BoolInt CPU_IsSupported_PageGB(void) if (!x86cpuid_CheckAndRead(&cpuid)) return False; { - UInt32 d[4] = { 0 }; + uint32_t d[4] = { 0 }; MyCPUID(0x80000000, &d[0], &d[1], &d[2], &d[3]); if (d[0] < 0x80000001) return False; } { - UInt32 d[4] = { 0 }; + uint32_t d[4] = { 0 }; MyCPUID(0x80000001, &d[0], &d[1], &d[2], &d[3]); return (d[3] >> 26) & 1; } diff --git a/deps/7zip/CpuArch.h b/deps/7zip/CpuArch.h index f1edae3803..77adace39c 100644 --- a/deps/7zip/CpuArch.h +++ b/deps/7zip/CpuArch.h @@ -198,41 +198,41 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem #ifdef MY_CPU_LE_UNALIGN -#define GetUi16(p) (*(const UInt16 *)(const void *)(p)) -#define GetUi32(p) (*(const UInt32 *)(const void *)(p)) -#define GetUi64(p) (*(const UInt64 *)(const void *)(p)) +#define GetUi16(p) (*(const uint16_t *)(const void *)(p)) +#define GetUi32(p) (*(const uint32_t *)(const void *)(p)) +#define GetUi64(p) (*(const uint64_t *)(const void *)(p)) -#define SetUi16(p, v) { *(UInt16 *)(p) = (v); } -#define SetUi32(p, v) { *(UInt32 *)(p) = (v); } -#define SetUi64(p, v) { *(UInt64 *)(p) = (v); } +#define SetUi16(p, v) { *(uint16_t *)(p) = (v); } +#define SetUi32(p, v) { *(uint32_t *)(p) = (v); } +#define SetUi64(p, v) { *(uint64_t *)(p) = (v); } #else -#define GetUi16(p) ( (UInt16) ( \ +#define GetUi16(p) ( (uint16_t) ( \ ((const Byte *)(p))[0] | \ - ((UInt16)((const Byte *)(p))[1] << 8) )) + ((uint16_t)((const Byte *)(p))[1] << 8) )) #define GetUi32(p) ( \ ((const Byte *)(p))[0] | \ - ((UInt32)((const Byte *)(p))[1] << 8) | \ - ((UInt32)((const Byte *)(p))[2] << 16) | \ - ((UInt32)((const Byte *)(p))[3] << 24)) + ((uint32_t)((const Byte *)(p))[1] << 8) | \ + ((uint32_t)((const Byte *)(p))[2] << 16) | \ + ((uint32_t)((const Byte *)(p))[3] << 24)) -#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32)) +#define GetUi64(p) (GetUi32(p) | ((uint64_t)GetUi32(((const Byte *)(p)) + 4) << 32)) -#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ +#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); uint32_t _vvv_ = (v); \ _ppp_[0] = (Byte)_vvv_; \ _ppp_[1] = (Byte)(_vvv_ >> 8); } -#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ +#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); uint32_t _vvv_ = (v); \ _ppp_[0] = (Byte)_vvv_; \ _ppp_[1] = (Byte)(_vvv_ >> 8); \ _ppp_[2] = (Byte)(_vvv_ >> 16); \ _ppp_[3] = (Byte)(_vvv_ >> 24); } -#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \ - SetUi32(_ppp2_ , (UInt32)_vvv2_); \ - SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); } +#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); uint64_t _vvv2_ = (v); \ + SetUi32(_ppp2_ , (uint32_t)_vvv2_); \ + SetUi32(_ppp2_ + 4, (uint32_t)(_vvv2_ >> 32)); } #endif @@ -252,33 +252,33 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem #pragma intrinsic(_byteswap_ulong) #pragma intrinsic(_byteswap_uint64) -/* #define GetBe16(p) _byteswap_ushort(*(const UInt16 *)(const Byte *)(p)) */ -#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p)) -#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p)) +/* #define GetBe16(p) _byteswap_ushort(*(const uint16_t *)(const Byte *)(p)) */ +#define GetBe32(p) _byteswap_ulong(*(const uint32_t *)(const Byte *)(p)) +#define GetBe64(p) _byteswap_uint64(*(const uint64_t *)(const Byte *)(p)) -#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v) +#define SetBe32(p, v) (*(uint32_t *)(void *)(p)) = _byteswap_ulong(v) #elif defined(MY_CPU_LE_UNALIGN) && ( \ (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \ || (defined(__clang__) && MY__has_builtin(__builtin_bswap16)) ) -/* #define GetBe16(p) __builtin_bswap16(*(const UInt16 *)(const Byte *)(p)) */ -#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p)) -#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p)) +/* #define GetBe16(p) __builtin_bswap16(*(const uint16_t *)(const Byte *)(p)) */ +#define GetBe32(p) __builtin_bswap32(*(const uint32_t *)(const Byte *)(p)) +#define GetBe64(p) __builtin_bswap64(*(const uint64_t *)(const Byte *)(p)) -#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v) +#define SetBe32(p, v) (*(uint32_t *)(void *)(p)) = __builtin_bswap32(v) #else #define GetBe32(p) ( \ - ((UInt32)((const Byte *)(p))[0] << 24) | \ - ((UInt32)((const Byte *)(p))[1] << 16) | \ - ((UInt32)((const Byte *)(p))[2] << 8) | \ + ((uint32_t)((const Byte *)(p))[0] << 24) | \ + ((uint32_t)((const Byte *)(p))[1] << 16) | \ + ((uint32_t)((const Byte *)(p))[2] << 8) | \ ((const Byte *)(p))[3] ) -#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4)) +#define GetBe64(p) (((uint64_t)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4)) -#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ +#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); uint32_t _vvv_ = (v); \ _ppp_[0] = (Byte)(_vvv_ >> 24); \ _ppp_[1] = (Byte)(_vvv_ >> 16); \ _ppp_[2] = (Byte)(_vvv_ >> 8); \ @@ -289,8 +289,8 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem #ifndef GetBe16 -#define GetBe16(p) ( (UInt16) ( \ - ((UInt16)((const Byte *)(p))[0] << 8) | \ +#define GetBe16(p) ( (uint16_t) ( \ + ((uint16_t)((const Byte *)(p))[0] << 8) | \ ((const Byte *)(p))[1] )) #endif @@ -301,12 +301,12 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem typedef struct { - UInt32 maxFunc; - UInt32 vendor[3]; - UInt32 ver; - UInt32 b; - UInt32 c; - UInt32 d; + uint32_t maxFunc; + uint32_t vendor[3]; + uint32_t ver; + uint32_t b; + uint32_t c; + uint32_t d; } Cx86cpuid; enum @@ -316,7 +316,7 @@ enum CPU_FIRM_VIA }; -void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d); +void MyCPUID(uint32_t function, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d); BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p); int x86cpuid_GetFirm(const Cx86cpuid *p); diff --git a/deps/7zip/LzFind.c b/deps/7zip/LzFind.c index df55e86c14..e01160843c 100644 --- a/deps/7zip/LzFind.c +++ b/deps/7zip/LzFind.c @@ -9,10 +9,10 @@ #include "LzHash.h" #define kEmptyHashValue 0 -#define kMaxValForNormalize ((UInt32)0xFFFFFFFF) +#define kMaxValForNormalize ((uint32_t)0xFFFFFFFF) #define kNormalizeStepMin (1 << 10) /* it must be power of 2 */ -#define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1)) -#define kMaxHistorySize ((UInt32)7 << 29) +#define kNormalizeMask (~(uint32_t)(kNormalizeStepMin - 1)) +#define kMaxHistorySize ((uint32_t)7 << 29) #define kStartMaxLen 3 @@ -27,9 +27,9 @@ static void LzInWindow_Free(CMatchFinder *p, ISzAllocPtr alloc) /* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */ -static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAllocPtr alloc) +static int LzInWindow_Create(CMatchFinder *p, uint32_t keepSizeReserv, ISzAllocPtr alloc) { - UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; + uint32_t blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; if (p->directInput) { p->blockSize = blockSize; @@ -46,9 +46,9 @@ static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAllocPtr Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } -UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } +uint32_t MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue) +void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue) { p->posLimit -= subValue; p->pos -= subValue; @@ -64,9 +64,9 @@ static void MatchFinder_ReadBlock(CMatchFinder *p) if (p->directInput) { - UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos); + uint32_t curSize = 0xFFFFFFFF - (p->streamPos - p->pos); if (curSize > p->directInputRem) - curSize = (UInt32)p->directInputRem; + curSize = (uint32_t)p->directInputRem; p->directInputRem -= curSize; p->streamPos += curSize; if (p->directInputRem == 0) @@ -89,7 +89,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p) p->streamEndWasReached = 1; return; } - p->streamPos += (UInt32)size; + p->streamPos += (uint32_t)size; if (p->streamPos - p->pos > p->keepSizeAfter) return; } @@ -142,15 +142,15 @@ void MatchFinder_Construct(CMatchFinder *p) p->bufferBase = NULL; p->directInput = 0; p->hash = NULL; - p->expectedDataSize = (UInt64)(Int64)-1; + p->expectedDataSize = (uint64_t)(int64_t)-1; MatchFinder_SetDefaultSettings(p); for (i = 0; i < 256; i++) { - UInt32 r = (UInt32)i; + uint32_t r = (uint32_t)i; unsigned j; for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); + r = (r >> 1) ^ (kCrcPoly & ((uint32_t)0 - (r & 1))); p->crc[i] = r; } } @@ -175,11 +175,11 @@ static CLzRef* AllocRefs(size_t num, ISzAllocPtr alloc) return (CLzRef *)ISzAlloc_Alloc(alloc, sizeInBytes); } -int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, - UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, +int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, + uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter, ISzAllocPtr alloc) { - UInt32 sizeReserv; + uint32_t sizeReserv; if (historySize > kMaxHistorySize) { @@ -188,8 +188,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, } sizeReserv = historySize >> 1; - if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3; - else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2; + if (historySize >= ((uint32_t)3 << 30)) sizeReserv = historySize >> 3; + else if (historySize >= ((uint32_t)2 << 30)) sizeReserv = historySize >> 2; sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); @@ -200,8 +200,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, if (LzInWindow_Create(p, sizeReserv, alloc)) { - UInt32 newCyclicBufferSize = historySize + 1; - UInt32 hs; + uint32_t newCyclicBufferSize = historySize + 1; + uint32_t hs; p->matchMaxLen = matchMaxLen; { p->fixedHashSize = 0; @@ -211,7 +211,7 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, { hs = historySize; if (hs > p->expectedDataSize) - hs = (UInt32)p->expectedDataSize; + hs = (uint32_t)p->expectedDataSize; if (hs != 0) hs--; hs |= (hs >> 1); @@ -270,8 +270,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, static void MatchFinder_SetLimits(CMatchFinder *p) { - UInt32 limit = kMaxValForNormalize - p->pos; - UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; + uint32_t limit = kMaxValForNormalize - p->pos; + uint32_t limit2 = p->cyclicBufferSize - p->cyclicBufferPos; if (limit2 < limit) limit = limit2; @@ -289,7 +289,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p) limit = limit2; { - UInt32 lenLimit = p->streamPos - p->pos; + uint32_t lenLimit = p->streamPos - p->pos; if (lenLimit > p->matchMaxLen) lenLimit = p->matchMaxLen; p->lenLimit = lenLimit; @@ -342,17 +342,17 @@ void MatchFinder_Init(CMatchFinder *p) } -static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) +static uint32_t MatchFinder_GetSubValue(CMatchFinder *p) { return (p->pos - p->historySize - 1) & kNormalizeMask; } -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems) +void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, size_t numItems) { size_t i; for (i = 0; i < numItems; i++) { - UInt32 value = items[i]; + uint32_t value = items[i]; if (value <= subValue) value = kEmptyHashValue; else @@ -363,7 +363,7 @@ void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems) static void MatchFinder_Normalize(CMatchFinder *p) { - UInt32 subValue = MatchFinder_GetSubValue(p); + uint32_t subValue = MatchFinder_GetSubValue(p); MatchFinder_Normalize3(subValue, p->hash, p->numRefs); MatchFinder_ReduceOffsets(p, subValue); } @@ -386,15 +386,15 @@ static void MatchFinder_CheckLimits(CMatchFinder *p) (lenLimit > maxLen) */ MY_FORCE_INLINE -static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, - UInt32 *distances, unsigned maxLen) +static uint32_t * Hc_GetMatchesSpec(unsigned lenLimit, uint32_t curMatch, uint32_t pos, const Byte *cur, CLzRef *son, + uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue, + uint32_t *distances, unsigned maxLen) { /* son[_cyclicBufferPos] = curMatch; for (;;) { - UInt32 delta = pos - curMatch; + uint32_t delta = pos - curMatch; if (cutValue-- == 0 || delta >= _cyclicBufferSize) return distances; { @@ -402,7 +402,7 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; if (pb[maxLen] == cur[maxLen] && *pb == *cur) { - UInt32 len = 0; + uint32_t len = 0; while (++len != lenLimit) if (pb[len] != cur[len]) break; @@ -423,7 +423,7 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos son[_cyclicBufferPos] = curMatch; do { - UInt32 delta = pos - curMatch; + uint32_t delta = pos - curMatch; if (delta >= _cyclicBufferSize) break; { @@ -437,7 +437,7 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos { if (++c == lim) { - distances[0] = (UInt32)(lim - cur); + distances[0] = (uint32_t)(lim - cur); distances[1] = delta - 1; return distances + 2; } @@ -447,7 +447,7 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos if (maxLen < len) { maxLen = len; - distances[0] = (UInt32)len; + distances[0] = (uint32_t)len; distances[1] = delta - 1; distances += 2; } @@ -462,16 +462,16 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos MY_FORCE_INLINE -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, - UInt32 *distances, UInt32 maxLen) +uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const Byte *cur, CLzRef *son, + uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue, + uint32_t *distances, uint32_t maxLen) { CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); unsigned len0 = 0, len1 = 0; for (;;) { - UInt32 delta = pos - curMatch; + uint32_t delta = pos - curMatch; if (cutValue-- == 0 || delta >= _cyclicBufferSize) { *ptr0 = *ptr1 = kEmptyHashValue; @@ -481,7 +481,7 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); const Byte *pb = cur - delta; unsigned len = (len0 < len1 ? len0 : len1); - UInt32 pair0 = pair[0]; + uint32_t pair0 = pair[0]; if (pb[len] == cur[len]) { if (++len != lenLimit && pb[len] == cur[len]) @@ -490,8 +490,8 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt break; if (maxLen < len) { - maxLen = (UInt32)len; - *distances++ = (UInt32)len; + maxLen = (uint32_t)len; + *distances++ = (uint32_t)len; *distances++ = delta - 1; if (len == lenLimit) { @@ -519,15 +519,15 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt } } -static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue) +static void SkipMatchesSpec(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const Byte *cur, CLzRef *son, + uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue) { CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); unsigned len0 = 0, len1 = 0; for (;;) { - UInt32 delta = pos - curMatch; + uint32_t delta = pos - curMatch; if (cutValue-- == 0 || delta >= _cyclicBufferSize) { *ptr0 = *ptr1 = kEmptyHashValue; @@ -574,12 +574,12 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const p->buffer++; \ if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); -#define MOVE_POS_RET MOVE_POS return (UInt32)offset; +#define MOVE_POS_RET MOVE_POS return (uint32_t)offset; static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } #define GET_MATCHES_HEADER2(minLen, ret_op) \ - unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \ + unsigned lenLimit; uint32_t hv; const Byte *cur; uint32_t curMatch; \ lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ cur = p->buffer; @@ -589,11 +589,11 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } #define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue #define GET_MATCHES_FOOTER(offset, maxLen) \ - offset = (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, MF_PARAMS(p), \ - distances + offset, (UInt32)maxLen) - distances); MOVE_POS_RET; + offset = (unsigned)(GetMatchesSpec1((uint32_t)lenLimit, curMatch, MF_PARAMS(p), \ + distances + offset, (uint32_t)maxLen) - distances); MOVE_POS_RET; #define SKIP_FOOTER \ - SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; + SkipMatchesSpec((uint32_t)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; #define UPDATE_maxLen { \ ptrdiff_t diff = (ptrdiff_t)0 - d2; \ @@ -602,7 +602,7 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } for (; c != lim; c++) if (*(c + diff) != *c) break; \ maxLen = (unsigned)(c - cur); } -static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static uint32_t Bt2_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) { unsigned offset; GET_MATCHES_HEADER(2) @@ -613,7 +613,7 @@ static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) GET_MATCHES_FOOTER(offset, 1) } -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) { unsigned offset; GET_MATCHES_HEADER(3) @@ -624,11 +624,11 @@ UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) GET_MATCHES_FOOTER(offset, 2) } -static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) { - UInt32 h2, d2, pos; + uint32_t h2, d2, pos; unsigned maxLen, offset; - UInt32 *hash; + uint32_t *hash; GET_MATCHES_HEADER(3) HASH3_CALC; @@ -649,12 +649,12 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) { UPDATE_maxLen - distances[0] = (UInt32)maxLen; + distances[0] = (uint32_t)maxLen; distances[1] = d2 - 1; offset = 2; if (maxLen == lenLimit) { - SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); + SkipMatchesSpec((uint32_t)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS_RET; } } @@ -662,11 +662,11 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) GET_MATCHES_FOOTER(offset, maxLen) } -static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) { - UInt32 h2, h3, d2, d3, pos; + uint32_t h2, h3, d2, d3, pos; unsigned maxLen, offset; - UInt32 *hash; + uint32_t *hash; GET_MATCHES_HEADER(4) HASH4_CALC; @@ -705,10 +705,10 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) if (offset != 0) { UPDATE_maxLen - distances[(size_t)offset - 2] = (UInt32)maxLen; + distances[(size_t)offset - 2] = (uint32_t)maxLen; if (maxLen == lenLimit) { - SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); + SkipMatchesSpec((uint32_t)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS_RET; } } @@ -720,10 +720,10 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) } /* -static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static uint32_t Bt5_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) { - UInt32 h2, h3, h4, d2, d3, d4, maxLen, offset, pos; - UInt32 *hash; + uint32_t h2, h3, h4, d2, d3, d4, maxLen, offset, pos; + uint32_t *hash; GET_MATCHES_HEADER(5) HASH5_CALC; @@ -796,11 +796,11 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) } */ -static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) { - UInt32 h2, h3, d2, d3, pos; + uint32_t h2, h3, d2, d3, pos; unsigned maxLen, offset; - UInt32 *hash; + uint32_t *hash; GET_MATCHES_HEADER(4) HASH4_CALC; @@ -838,7 +838,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) if (offset != 0) { UPDATE_maxLen - distances[(size_t)offset - 2] = (UInt32)maxLen; + distances[(size_t)offset - 2] = (uint32_t)maxLen; if (maxLen == lenLimit) { p->son[p->cyclicBufferPos] = curMatch; @@ -855,10 +855,10 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) } /* -static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static uint32_t Hc5_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) { - UInt32 h2, h3, h4, d2, d3, d4, maxLen, offset, pos - UInt32 *hash; + uint32_t h2, h3, h4, d2, d3, d4, maxLen, offset, pos + uint32_t *hash; GET_MATCHES_HEADER(5) HASH5_CALC; @@ -927,13 +927,13 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) if (maxLen < 4) maxLen = 4; - offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), + offset = (uint32_t)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), distances + offset, maxLen) - (distances)); MOVE_POS_RET } */ -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) { unsigned offset; GET_MATCHES_HEADER(3) @@ -945,7 +945,7 @@ UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) MOVE_POS_RET } -static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +static void Bt2_MatchFinder_Skip(CMatchFinder *p, uint32_t num) { do { @@ -958,7 +958,7 @@ static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) while (--num != 0); } -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num) { do { @@ -971,12 +971,12 @@ void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) while (--num != 0); } -static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +static void Bt3_MatchFinder_Skip(CMatchFinder *p, uint32_t num) { do { - UInt32 h2; - UInt32 *hash; + uint32_t h2; + uint32_t *hash; SKIP_HEADER(3) HASH3_CALC; hash = p->hash; @@ -988,12 +988,12 @@ static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) while (--num != 0); } -static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +static void Bt4_MatchFinder_Skip(CMatchFinder *p, uint32_t num) { do { - UInt32 h2, h3; - UInt32 *hash; + uint32_t h2, h3; + uint32_t *hash; SKIP_HEADER(4) HASH4_CALC; hash = p->hash; @@ -1007,12 +1007,12 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) } /* -static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +static void Bt5_MatchFinder_Skip(CMatchFinder *p, uint32_t num) { do { - UInt32 h2, h3, h4; - UInt32 *hash; + uint32_t h2, h3, h4; + uint32_t *hash; SKIP_HEADER(5) HASH5_CALC; hash = p->hash; @@ -1027,12 +1027,12 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) } */ -static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +static void Hc4_MatchFinder_Skip(CMatchFinder *p, uint32_t num) { do { - UInt32 h2, h3; - UInt32 *hash; + uint32_t h2, h3; + uint32_t *hash; SKIP_HEADER(4) HASH4_CALC; hash = p->hash; @@ -1047,12 +1047,12 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) } /* -static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +static void Hc5_MatchFinder_Skip(CMatchFinder *p, uint32_t num) { do { - UInt32 h2, h3, h4; - UInt32 *hash; + uint32_t h2, h3, h4; + uint32_t *hash; SKIP_HEADER(5) HASH5_CALC; hash = p->hash; @@ -1068,7 +1068,7 @@ static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) } */ -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num) { do { diff --git a/deps/7zip/LzFind.h b/deps/7zip/LzFind.h index 42c13be157..3ec83b16e1 100644 --- a/deps/7zip/LzFind.h +++ b/deps/7zip/LzFind.h @@ -8,47 +8,47 @@ EXTERN_C_BEGIN -typedef UInt32 CLzRef; +typedef uint32_t CLzRef; typedef struct _CMatchFinder { Byte *buffer; - UInt32 pos; - UInt32 posLimit; - UInt32 streamPos; - UInt32 lenLimit; + uint32_t pos; + uint32_t posLimit; + uint32_t streamPos; + uint32_t lenLimit; - UInt32 cyclicBufferPos; - UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ + uint32_t cyclicBufferPos; + uint32_t cyclicBufferSize; /* it must be = (historySize + 1) */ Byte streamEndWasReached; Byte btMode; Byte bigHash; Byte directInput; - UInt32 matchMaxLen; + uint32_t matchMaxLen; CLzRef *hash; CLzRef *son; - UInt32 hashMask; - UInt32 cutValue; + uint32_t hashMask; + uint32_t cutValue; Byte *bufferBase; ISeqInStream *stream; - UInt32 blockSize; - UInt32 keepSizeBefore; - UInt32 keepSizeAfter; + uint32_t blockSize; + uint32_t keepSizeBefore; + uint32_t keepSizeAfter; - UInt32 numHashBytes; + uint32_t numHashBytes; size_t directInputRem; - UInt32 historySize; - UInt32 fixedHashSize; - UInt32 hashSizeSum; + uint32_t historySize; + uint32_t fixedHashSize; + uint32_t hashSizeSum; SRes result; - UInt32 crc[256]; + uint32_t crc[256]; size_t numRefs; - UInt64 expectedDataSize; + uint64_t expectedDataSize; } CMatchFinder; #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) @@ -71,16 +71,16 @@ void MatchFinder_Construct(CMatchFinder *p); historySize <= 3 GB keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB */ -int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, - UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, +int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, + uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter, ISzAllocPtr alloc); void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc); -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems); -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); +void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, size_t numItems); +void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue); -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, - UInt32 *distances, UInt32 maxLen); +uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const Byte *buffer, CLzRef *son, + uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t _cutValue, + uint32_t *distances, uint32_t maxLen); /* Conditions: @@ -89,10 +89,10 @@ Conditions: */ typedef void (*Mf_Init_Func)(void *object); -typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); +typedef uint32_t (*Mf_GetNumAvailableBytes_Func)(void *object); typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); -typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); -typedef void (*Mf_Skip_Func)(void *object, UInt32); +typedef uint32_t (*Mf_GetMatches_Func)(void *object, uint32_t *distances); +typedef void (*Mf_Skip_Func)(void *object, uint32_t); typedef struct _IMatchFinder { @@ -110,11 +110,11 @@ void MatchFinder_Init_HighHash(CMatchFinder *p); void MatchFinder_Init_3(CMatchFinder *p, int readData); void MatchFinder_Init(CMatchFinder *p); -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); +uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances); +uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances); -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); +void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num); +void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num); EXTERN_C_END diff --git a/deps/7zip/LzHash.h b/deps/7zip/LzHash.h index e7c942303d..1f4c2b4685 100644 --- a/deps/7zip/LzHash.h +++ b/deps/7zip/LzHash.h @@ -12,45 +12,45 @@ #define kFix4HashSize (kHash2Size + kHash3Size) #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) -#define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8); +#define HASH2_CALC hv = cur[0] | ((uint32_t)cur[1] << 8); #define HASH3_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + uint32_t temp = p->crc[cur[0]] ^ cur[1]; \ h2 = temp & (kHash2Size - 1); \ - hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } + hv = (temp ^ ((uint32_t)cur[2] << 8)) & p->hashMask; } #define HASH4_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + uint32_t temp = p->crc[cur[0]] ^ cur[1]; \ h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ + temp ^= ((uint32_t)cur[2] << 8); \ h3 = temp & (kHash3Size - 1); \ hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; } #define HASH5_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + uint32_t temp = p->crc[cur[0]] ^ cur[1]; \ h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ + temp ^= ((uint32_t)cur[2] << 8); \ h3 = temp & (kHash3Size - 1); \ temp ^= (p->crc[cur[3]] << 5); \ h4 = temp & (kHash4Size - 1); \ hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; } -/* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ -#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; +/* #define HASH_ZIP_CALC hv = ((cur[0] | ((uint32_t)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ +#define HASH_ZIP_CALC hv = ((cur[2] | ((uint32_t)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; #define MT_HASH2_CALC \ h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); #define MT_HASH3_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + uint32_t temp = p->crc[cur[0]] ^ cur[1]; \ h2 = temp & (kHash2Size - 1); \ - h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } + h3 = (temp ^ ((uint32_t)cur[2] << 8)) & (kHash3Size - 1); } #define MT_HASH4_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + uint32_t temp = p->crc[cur[0]] ^ cur[1]; \ h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ + temp ^= ((uint32_t)cur[2] << 8); \ h3 = temp & (kHash3Size - 1); \ h4 = (temp ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } diff --git a/deps/7zip/Lzma2Dec.c b/deps/7zip/Lzma2Dec.c index cef93f996a..759cd8adc7 100644 --- a/deps/7zip/Lzma2Dec.c +++ b/deps/7zip/Lzma2Dec.c @@ -32,7 +32,7 @@ #define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & (1 << 7)) == 0) #define LZMA2_LCLP_MAX 4 -#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)) +#define LZMA2_DIC_SIZE_FROM_PROP(p) (((uint32_t)2 | ((p) & 1)) << ((p) / 2 + 11)) #ifdef SHOW_DEBUG_INFO #define PRF(x) x @@ -56,7 +56,7 @@ typedef enum static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props) { - UInt32 dicSize; + uint32_t dicSize; if (prop > 40) return SZ_ERROR_UNSUPPORTED; dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); @@ -116,26 +116,26 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b) if (b < p->needInitLevel) return LZMA2_STATE_ERROR; p->needInitLevel = 0; - p->unpackSize = (UInt32)(b & 0x1F) << 16; + p->unpackSize = (uint32_t)(b & 0x1F) << 16; } return LZMA2_STATE_UNPACK0; case LZMA2_STATE_UNPACK0: - p->unpackSize |= (UInt32)b << 8; + p->unpackSize |= (uint32_t)b << 8; return LZMA2_STATE_UNPACK1; case LZMA2_STATE_UNPACK1: - p->unpackSize |= (UInt32)b; + p->unpackSize |= (uint32_t)b; p->unpackSize++; PRF(printf(" %7u", (unsigned)p->unpackSize)); return LZMA2_IS_UNCOMPRESSED_STATE(p) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; case LZMA2_STATE_PACK0: - p->packSize = (UInt32)b << 8; + p->packSize = (uint32_t)b << 8; return LZMA2_STATE_PACK1; case LZMA2_STATE_PACK1: - p->packSize |= (UInt32)b; + p->packSize |= (uint32_t)b; p->packSize++; /* if (p->packSize < 5) return LZMA2_STATE_ERROR; */ PRF(printf(" %5u", (unsigned)p->packSize)); @@ -166,7 +166,7 @@ static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT s p->dicPos += size; if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) p->checkDicSize = p->prop.dicSize; - p->processedPos += (UInt32)size; + p->processedPos += (uint32_t)size; } void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState); @@ -245,7 +245,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, src += inCur; *srcLen += inCur; - p->unpackSize -= (UInt32)inCur; + p->unpackSize -= (uint32_t)inCur; p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; } else @@ -267,9 +267,9 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, src += inCur; *srcLen += inCur; - p->packSize -= (UInt32)inCur; + p->packSize -= (uint32_t)inCur; outCur = p->decoder.dicPos - dicPos; - p->unpackSize -= (UInt32)outCur; + p->unpackSize -= (uint32_t)outCur; if (res != 0) break; @@ -371,7 +371,7 @@ ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, src += inCur; *srcLen += inCur; outSize -= inCur; - p->unpackSize -= (UInt32)inCur; + p->unpackSize -= (uint32_t)inCur; p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; } else @@ -400,7 +400,7 @@ ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, src += inCur; *srcLen += inCur; - p->packSize -= (UInt32)inCur; + p->packSize -= (uint32_t)inCur; if (p->packSize == 0) { @@ -408,7 +408,7 @@ ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, if (rem > p->unpackSize) rem = p->unpackSize; p->decoder.dicPos += rem; - p->unpackSize -= (UInt32)rem; + p->unpackSize -= (uint32_t)rem; outSize -= rem; if (p->unpackSize == 0) p->state = LZMA2_STATE_CONTROL; diff --git a/deps/7zip/Lzma2Dec.h b/deps/7zip/Lzma2Dec.h index c2ac844495..98573b4111 100644 --- a/deps/7zip/Lzma2Dec.h +++ b/deps/7zip/Lzma2Dec.h @@ -17,8 +17,8 @@ typedef struct Byte needInitLevel; Byte isExtraMode; Byte _pad_; - UInt32 packSize; - UInt32 unpackSize; + uint32_t packSize; + uint32_t unpackSize; CLzmaDec decoder; } CLzma2Dec; diff --git a/deps/7zip/LzmaDec.c b/deps/7zip/LzmaDec.c index ba3e1dd50e..4978d927ea 100644 --- a/deps/7zip/LzmaDec.c +++ b/deps/7zip/LzmaDec.c @@ -9,7 +9,7 @@ #include "LzmaDec.h" #define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) +#define kTopValue ((uint32_t)1 << kNumTopBits) #define kNumBitModelTotalBits 11 #define kBitModelTotal (1 << kNumBitModelTotalBits) @@ -19,7 +19,7 @@ #define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } -#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) +#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (uint32_t)ttt; if (code < bound) #define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); #define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ @@ -66,7 +66,7 @@ #define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); } -#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) +#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (uint32_t)ttt; if (code < bound) #define UPDATE_0_CHECK range = bound; #define UPDATE_1_CHECK range -= bound; code -= bound; #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ @@ -155,7 +155,7 @@ #define LZMA_LIT_SIZE 0x300 -#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) +#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((uint32_t)LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) #define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4) @@ -219,7 +219,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit { CLzmaProb *probs = GET_PROBS; unsigned state = (unsigned)p->state; - UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; + uint32_t rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; unsigned lc = p->prop.lc; unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc); @@ -228,18 +228,18 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit SizeT dicBufSize = p->dicBufSize; SizeT dicPos = p->dicPos; - UInt32 processedPos = p->processedPos; - UInt32 checkDicSize = p->checkDicSize; + uint32_t processedPos = p->processedPos; + uint32_t checkDicSize = p->checkDicSize; unsigned len = 0; const Byte *buf = p->buf; - UInt32 range = p->range; - UInt32 code = p->code; + uint32_t range = p->range; + uint32_t code = p->code; do { CLzmaProb *prob; - UInt32 bound; + uint32_t bound; unsigned ttt; unsigned posState = CALC_POS_STATE(processedPos, pbMask); @@ -250,7 +250,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit UPDATE_0(prob); prob = probs + Literal; if (processedPos != 0 || checkDicSize != 0) - prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc); + prob += (uint32_t)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc); processedPos++; if (state < kNumLitStates) @@ -339,7 +339,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit } else { - UInt32 distance; + uint32_t distance; UPDATE_1(prob); prob = probs + IsRepG1 + state; IF_BIT_0(prob) @@ -443,7 +443,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit if (state >= kNumStates) { - UInt32 distance; + uint32_t distance; prob = probs + PosSlot + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); TREE_6_DECODE(prob, distance); @@ -457,7 +457,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit distance <<= numDirectBits; prob = probs + SpecPos; { - UInt32 m = 1; + uint32_t m = 1; distance++; do { @@ -476,9 +476,9 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit range >>= 1; { - UInt32 t; + uint32_t t; code -= range; - t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ + t = (0 - ((uint32_t)code >> 31)); /* (uint32_t)((Int32)code >> 31) */ distance = (distance << 1) + (t + 1); code += range & t; } @@ -502,7 +502,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit REV_BIT_LAST (prob, i, 8); distance |= i; } - if (distance == (UInt32)0xFFFFFFFF) + if (distance == (uint32_t)0xFFFFFFFF) { len = kMatchSpecLenStart; state -= kNumStates; @@ -539,7 +539,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit curLen = ((rem < len) ? (unsigned)rem : len); pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0); - processedPos += (UInt32)curLen; + processedPos += (uint32_t)curLen; len -= curLen; if (curLen <= dicBufSize - pos) @@ -572,14 +572,14 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit p->buf = buf; p->range = range; p->code = code; - p->remainLen = (UInt32)len; + p->remainLen = (uint32_t)len; p->dicPos = dicPos; p->processedPos = processedPos; p->reps[0] = rep0; p->reps[1] = rep1; p->reps[2] = rep2; p->reps[3] = rep3; - p->state = (UInt32)state; + p->state = (uint32_t)state; return SZ_OK; } @@ -601,8 +601,8 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) p->checkDicSize = p->prop.dicSize; - p->processedPos += (UInt32)len; - p->remainLen -= (UInt32)len; + p->processedPos += (uint32_t)len; + p->remainLen -= (uint32_t)len; while (len != 0) { len--; @@ -628,7 +628,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte SizeT limit2 = limit; if (p->checkDicSize == 0) { - UInt32 rem = p->prop.dicSize - p->processedPos; + uint32_t rem = p->prop.dicSize - p->processedPos; if (limit - p->dicPos > rem) limit2 = p->dicPos + rem; @@ -659,8 +659,8 @@ typedef enum static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) { - UInt32 range = p->range; - UInt32 code = p->code; + uint32_t range = p->range; + uint32_t code = p->code; const Byte *bufLimit = buf + inSize; const CLzmaProb *probs = GET_PROBS; unsigned state = (unsigned)p->state; @@ -668,7 +668,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS { const CLzmaProb *prob; - UInt32 bound; + uint32_t bound; unsigned ttt; unsigned posState = CALC_POS_STATE(p->processedPos, (1 << p->prop.pb) - 1); @@ -681,7 +681,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS prob = probs + Literal; if (p->checkDicSize != 0 || p->processedPos != 0) - prob += ((UInt32)LZMA_LIT_SIZE * + prob += ((uint32_t)LZMA_LIT_SIZE * ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); @@ -892,10 +892,10 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr return SZ_OK; } p->code = - ((UInt32)p->tempBuf[1] << 24) - | ((UInt32)p->tempBuf[2] << 16) - | ((UInt32)p->tempBuf[3] << 8) - | ((UInt32)p->tempBuf[4]); + ((uint32_t)p->tempBuf[1] << 24) + | ((uint32_t)p->tempBuf[2] << 16) + | ((uint32_t)p->tempBuf[3] << 8) + | ((uint32_t)p->tempBuf[4]); p->range = 0xFFFFFFFF; p->tempBufSize = 0; @@ -1079,13 +1079,13 @@ void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc) SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) { - UInt32 dicSize; + uint32_t dicSize; Byte d; if (size < LZMA_PROPS_SIZE) return SZ_ERROR_UNSUPPORTED; else - dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); + dicSize = data[1] | ((uint32_t)data[2] << 8) | ((uint32_t)data[3] << 16) | ((uint32_t)data[4] << 24); if (dicSize < LZMA_DIC_MIN) dicSize = LZMA_DIC_MIN; @@ -1105,7 +1105,7 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAllocPtr alloc) { - UInt32 numProbs = LzmaProps_GetNumProbs(propNew); + uint32_t numProbs = LzmaProps_GetNumProbs(propNew); if (!p->probs || numProbs != p->numProbs) { LzmaDec_FreeProbs(p, alloc); @@ -1135,10 +1135,10 @@ SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAll RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); { - UInt32 dictSize = propNew.dicSize; - SizeT mask = ((UInt32)1 << 12) - 1; - if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1; - else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1;; + uint32_t dictSize = propNew.dicSize; + SizeT mask = ((uint32_t)1 << 12) - 1; + if (dictSize >= ((uint32_t)1 << 30)) mask = ((uint32_t)1 << 22) - 1; + else if (dictSize >= ((uint32_t)1 << 22)) mask = ((uint32_t)1 << 20) - 1;; dicBufSize = ((SizeT)dictSize + mask) & ~mask; if (dicBufSize < dictSize) dicBufSize = dictSize; diff --git a/deps/7zip/LzmaDec.h b/deps/7zip/LzmaDec.h index 1f0927ab13..47532c2ebb 100644 --- a/deps/7zip/LzmaDec.h +++ b/deps/7zip/LzmaDec.h @@ -14,9 +14,9 @@ EXTERN_C_BEGIN typedef #ifdef _LZMA_PROB32 - UInt32 + uint32_t #else - UInt16 + uint16_t #endif CLzmaProb; @@ -31,7 +31,7 @@ typedef struct _CLzmaProps Byte lp; Byte pb; Byte _pad_; - UInt32 dicSize; + uint32_t dicSize; } CLzmaProps; /* LzmaProps_Decode - decodes properties @@ -60,15 +60,15 @@ typedef struct SizeT dicBufSize; SizeT dicPos; const Byte *buf; - UInt32 range; - UInt32 code; - UInt32 processedPos; - UInt32 checkDicSize; - UInt32 reps[4]; - UInt32 state; - UInt32 remainLen; + uint32_t range; + uint32_t code; + uint32_t processedPos; + uint32_t checkDicSize; + uint32_t reps[4]; + uint32_t state; + uint32_t remainLen; - UInt32 numProbs; + uint32_t numProbs; unsigned tempBufSize; Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; } CLzmaDec; diff --git a/deps/7zip/LzmaEnc.c b/deps/7zip/LzmaEnc.c index de7006b40a..b3898557fd 100644 --- a/deps/7zip/LzmaEnc.c +++ b/deps/7zip/LzmaEnc.c @@ -23,11 +23,11 @@ static unsigned g_STAT_OFFSET = 0; #endif -#define kLzmaMaxHistorySize ((UInt32)3 << 29) -/* #define kLzmaMaxHistorySize ((UInt32)7 << 29) */ +#define kLzmaMaxHistorySize ((uint32_t)3 << 29) +/* #define kLzmaMaxHistorySize ((uint32_t)7 << 29) */ #define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) +#define kTopValue ((uint32_t)1 << kNumTopBits) #define kNumBitModelTotalBits 11 #define kBitModelTotal (1 << kNumBitModelTotalBits) @@ -44,7 +44,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p) { p->level = 5; p->dictSize = p->mc = 0; - p->reduceSize = (UInt64)(Int64)-1; + p->reduceSize = (uint64_t)(Int64)-1; p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1; p->writeEndMark = 0; } @@ -59,11 +59,11 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) if (p->dictSize > p->reduceSize) { unsigned i; - UInt32 reduceSize = (UInt32)p->reduceSize; + uint32_t reduceSize = (uint32_t)p->reduceSize; for (i = 11; i <= 30; i++) { - if (reduceSize <= ((UInt32)2 << i)) { p->dictSize = ((UInt32)2 << i); break; } - if (reduceSize <= ((UInt32)3 << i)) { p->dictSize = ((UInt32)3 << i); break; } + if (reduceSize <= ((uint32_t)2 << i)) { p->dictSize = ((uint32_t)2 << i); break; } + if (reduceSize <= ((uint32_t)3 << i)) { p->dictSize = ((uint32_t)3 << i); break; } } } @@ -86,7 +86,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) #endif } -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) +uint32_t LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) { CLzmaEncProps props = *props2; LzmaEncProps_Normalize(&props); @@ -104,7 +104,7 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) #define BSR2_RET(pos, res) { unsigned long zz; _BitScanReverse(&zz, (pos)); res = (zz + zz) + ((pos >> (zz - 1)) & 1); } -static unsigned GetPosSlot1(UInt32 pos) +static unsigned GetPosSlot1(uint32_t pos) { unsigned res; BSR2_RET(pos, res); @@ -137,16 +137,16 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos) } } -/* we can use ((limit - pos) >> 31) only if (pos < ((UInt32)1 << 31)) */ +/* we can use ((limit - pos) >> 31) only if (pos < ((uint32_t)1 << 31)) */ /* #define BSR2_RET(pos, res) { unsigned zz = 6 + ((kNumLogBits - 1) & \ - (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \ + (0 - (((((uint32_t)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \ res = p->g_FastPos[pos >> zz] + (zz * 2); } */ /* #define BSR2_RET(pos, res) { unsigned zz = 6 + ((kNumLogBits - 1) & \ - (0 - (((((UInt32)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \ + (0 - (((((uint32_t)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \ res = p->g_FastPos[pos >> zz] + (zz * 2); } */ @@ -168,20 +168,20 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos) #define LZMA_NUM_REPS 4 -typedef UInt16 CState; -typedef UInt16 CExtra; +typedef uint16_t CState; +typedef uint16_t CExtra; typedef struct { - UInt32 price; + uint32_t price; CState state; CExtra extra; /* 0 : normal * 1 : LIT : MATCH * > 1 : MATCH (extra-1) : LIT : REP0 (len) */ - UInt32 len; - UInt32 dist; - UInt32 reps[LZMA_NUM_REPS]; + uint32_t len; + uint32_t dist; + uint32_t reps[LZMA_NUM_REPS]; } COptimal; @@ -208,9 +208,9 @@ typedef struct #ifndef __LZMA_DEC_H typedef #ifdef _LZMA_PROB32 - UInt32 + uint32_t #else - UInt16 + uint16_t #endif CLzmaProb; #endif @@ -243,9 +243,9 @@ typedef struct typedef struct { unsigned tableSize; - UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; - /* UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols * 2]; */ - /* UInt32 prices2[kLenNumSymbolsTotal]; */ + uint32_t prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; + /* uint32_t prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols * 2]; */ + /* uint32_t prices2[kLenNumSymbolsTotal]; */ } CLenPriceEnc; #define GET_PRICE_LEN(p, posState, len) \ @@ -258,15 +258,15 @@ typedef struct typedef struct { - UInt32 range; + uint32_t range; unsigned cache; - UInt64 low; - UInt64 cacheSize; + uint64_t low; + uint64_t cacheSize; Byte *buf; Byte *bufLim; Byte *bufBase; ISeqOutStream *outStream; - UInt64 processed; + uint64_t processed; SRes res; } CRangeEnc; @@ -276,7 +276,7 @@ typedef struct CLzmaProb *litProbs; unsigned state; - UInt32 reps[LZMA_NUM_REPS]; + uint32_t reps[LZMA_NUM_REPS]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; CLzmaProb isRep[kNumStates]; @@ -295,7 +295,7 @@ typedef struct } CSaveState; -typedef UInt32 CProbPrice; +typedef uint32_t CProbPrice; typedef struct @@ -308,17 +308,17 @@ typedef struct unsigned longestMatchLen; unsigned numPairs; - UInt32 numAvail; + uint32_t numAvail; unsigned state; unsigned numFastBytes; unsigned additionalOffset; - UInt32 reps[LZMA_NUM_REPS]; + uint32_t reps[LZMA_NUM_REPS]; unsigned lpMask, pbMask; CLzmaProb *litProbs; CRangeEnc rc; - UInt32 backRes; + uint32_t backRes; unsigned lc, lp, pb; unsigned lclp; @@ -330,7 +330,7 @@ typedef struct BoolInt needInit; /* BoolInt _maxMode; */ - UInt64 nowPos64; + uint64_t nowPos64; unsigned matchPriceCount; /* unsigned alignPriceCount; */ @@ -338,7 +338,7 @@ typedef struct unsigned distTableSize; - UInt32 dictSize; + uint32_t dictSize; SRes result; #ifndef _7ZIP_ST @@ -357,11 +357,11 @@ typedef struct /* LZ thread */ CProbPrice ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; - UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1]; + uint32_t matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1]; - UInt32 alignPrices[kAlignTableSize]; - UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; - UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances]; + uint32_t alignPrices[kAlignTableSize]; + uint32_t posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; + uint32_t distancesPrices[kNumLenToPosStates][kNumFullDistances]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; CLzmaProb isRep[kNumStates]; @@ -418,7 +418,7 @@ void LzmaEnc_SaveState(CLzmaEncHandle pp) COPY_ARR(dest, p, posSlotEncoder); COPY_ARR(dest, p, posEncoders); - memcpy(dest->litProbs, p->litProbs, ((UInt32)0x300 << p->lclp) * sizeof(CLzmaProb)); + memcpy(dest->litProbs, p->litProbs, ((uint32_t)0x300 << p->lclp) * sizeof(CLzmaProb)); } @@ -444,7 +444,7 @@ void LzmaEnc_RestoreState(CLzmaEncHandle pp) COPY_ARR(dest, p, posSlotEncoder); COPY_ARR(dest, p, posEncoders); - memcpy(dest->litProbs, p->litProbs, ((UInt32)0x300 << dest->lclp) * sizeof(CLzmaProb)); + memcpy(dest->litProbs, p->litProbs, ((uint32_t)0x300 << dest->lclp) * sizeof(CLzmaProb)); } @@ -458,7 +458,7 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX - || props.dictSize > ((UInt64)1 << kDicLogSizeMaxCompress) + || props.dictSize > ((uint64_t)1 << kDicLogSizeMaxCompress) || props.dictSize > kLzmaMaxHistorySize) return SZ_ERROR_PARAM; @@ -508,7 +508,7 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) } -void LzmaEnc_SetDataSize(CLzmaEncHandle pp, UInt64 expectedDataSiize) +void LzmaEnc_SetDataSize(CLzmaEncHandle pp, uint64_t expectedDataSiize) { CLzmaEnc *p = (CLzmaEnc *)pp; p->matchFinderBase.expectedDataSize = expectedDataSiize; @@ -589,10 +589,10 @@ MY_NO_INLINE static void RangeEnc_FlushStream(CRangeEnc *p) MY_NO_INLINE static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p) { - UInt32 low = (UInt32)p->low; + uint32_t low = (uint32_t)p->low; unsigned high = (unsigned)(p->low >> 32); - p->low = (UInt32)(low << 8); - if (low < (UInt32)0xFF000000 || high != 0) + p->low = (uint32_t)(low << 8); + if (low < (uint32_t)0xFF000000 || high != 0) { { Byte *buf = p->buf; @@ -647,18 +647,18 @@ static void RangeEnc_FlushData(CRangeEnc *p) #else #define RC_BIT(p, prob, bit) { \ - UInt32 mask; \ + uint32_t mask; \ RC_BIT_PRE(p, prob) \ - mask = 0 - (UInt32)bit; \ + mask = 0 - (uint32_t)bit; \ range &= mask; \ mask &= newBound; \ range -= mask; \ (p)->low += mask; \ - mask = (UInt32)bit - 1; \ + mask = (uint32_t)bit - 1; \ range += newBound & mask; \ mask &= (kBitModelTotal - ((1 << kNumMoveBits) - 1)); \ mask += ((1 << kNumMoveBits) - 1); \ - ttt += (Int32)(mask - ttt) >> kNumMoveBits; \ + ttt += (int32_t)(mask - ttt) >> kNumMoveBits; \ *(prob) = (CLzmaProb)ttt; \ RC_NORM(p) \ } @@ -684,23 +684,23 @@ static void RangeEnc_FlushData(CRangeEnc *p) static void RangeEnc_EncodeBit_0(CRangeEnc *p, CLzmaProb *prob) { - UInt32 range, ttt, newBound; + uint32_t range, ttt, newBound; range = p->range; RC_BIT_PRE(p, prob) RC_BIT_0(p, prob) p->range = range; } -static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 sym) +static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, uint32_t sym) { - UInt32 range = p->range; + uint32_t range = p->range; sym |= 0x100; do { - UInt32 ttt, newBound; + uint32_t ttt, newBound; /* RangeEnc_EncodeBit(p, probs + (sym >> 8), (sym >> 7) & 1); */ CLzmaProb *prob = probs + (sym >> 8); - UInt32 bit = (sym >> 7) & 1; + uint32_t bit = (sym >> 7) & 1; sym <<= 1; RC_BIT(p, prob, bit); } @@ -708,16 +708,16 @@ static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 sym) p->range = range; } -static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 sym, UInt32 matchByte) +static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, uint32_t sym, uint32_t matchByte) { - UInt32 range = p->range; - UInt32 offs = 0x100; + uint32_t range = p->range; + uint32_t offs = 0x100; sym |= 0x100; do { - UInt32 ttt, newBound; + uint32_t ttt, newBound; CLzmaProb *prob; - UInt32 bit; + uint32_t bit; matchByte <<= 1; /* RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (sym >> 8)), (sym >> 7) & 1); */ prob = probs + (offs + (matchByte & offs) + (sym >> 8)); @@ -734,18 +734,18 @@ static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 sym, UIn static void LzmaEnc_InitPriceTables(CProbPrice *ProbPrices) { - UInt32 i; + uint32_t i; for (i = 0; i < (kBitModelTotal >> kNumMoveReducingBits); i++) { const unsigned kCyclesBits = kNumBitPriceShiftBits; - UInt32 w = (i << kNumMoveReducingBits) + (1 << (kNumMoveReducingBits - 1)); + uint32_t w = (i << kNumMoveReducingBits) + (1 << (kNumMoveReducingBits - 1)); unsigned bitCount = 0; unsigned j; for (j = 0; j < kCyclesBits; j++) { w = w * w; bitCount <<= 1; - while (w >= ((UInt32)1 << 16)) + while (w >= ((uint32_t)1 << 16)) { w >>= 1; bitCount++; @@ -770,9 +770,9 @@ static void LzmaEnc_InitPriceTables(CProbPrice *ProbPrices) #define GET_PRICEa_1(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] -static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, const CProbPrice *ProbPrices) +static uint32_t LitEnc_GetPrice(const CLzmaProb *probs, uint32_t sym, const CProbPrice *ProbPrices) { - UInt32 price = 0; + uint32_t price = 0; sym |= 0x100; do { @@ -785,10 +785,10 @@ static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, const CProbPri } -static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 sym, UInt32 matchByte, const CProbPrice *ProbPrices) +static uint32_t LitEnc_Matched_GetPrice(const CLzmaProb *probs, uint32_t sym, uint32_t matchByte, const CProbPrice *ProbPrices) { - UInt32 price = 0; - UInt32 offs = 0x100; + uint32_t price = 0; + uint32_t offs = 0x100; sym |= 0x100; do { @@ -804,11 +804,11 @@ static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 sym, UInt32 static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, unsigned numBits, unsigned sym) { - UInt32 range = rc->range; + uint32_t range = rc->range; unsigned m = 1; do { - UInt32 ttt, newBound; + uint32_t ttt, newBound; unsigned bit = sym & 1; /* RangeEnc_EncodeBit(rc, probs + m, bit); */ sym >>= 1; @@ -832,7 +832,7 @@ static void LenEnc_Init(CLenEnc *p) static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posState) { - UInt32 range, ttt, newBound; + uint32_t range, ttt, newBound; CLzmaProb *probs = p->low; range = rc->range; RC_BIT_PRE(rc, probs); @@ -865,13 +865,13 @@ static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posS } } -static void SetPrices_3(const CLzmaProb *probs, UInt32 startPrice, UInt32 *prices, const CProbPrice *ProbPrices) +static void SetPrices_3(const CLzmaProb *probs, uint32_t startPrice, uint32_t *prices, const CProbPrice *ProbPrices) { unsigned i; for (i = 0; i < 8; i += 2) { - UInt32 price = startPrice; - UInt32 prob; + uint32_t price = startPrice; + uint32_t prob; price += GET_PRICEa(probs[1 ], (i >> 2)); price += GET_PRICEa(probs[2 + (i >> 2)], (i >> 1) & 1); prob = probs[4 + (i >> 1)]; @@ -887,18 +887,18 @@ MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables( const CLenEnc *enc, const CProbPrice *ProbPrices) { - UInt32 b; + uint32_t b; { unsigned prob = enc->low[0]; - UInt32 a, c; + uint32_t a, c; unsigned posState; b = GET_PRICEa_1(prob); a = GET_PRICEa_0(prob); c = b + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); for (posState = 0; posState < numPosStates; posState++) { - UInt32 *prices = p->prices[posState]; + uint32_t *prices = p->prices[posState]; const CLzmaProb *probs = enc->low + (posState << (1 + kLenNumLowBits)); SetPrices_3(probs, a, prices, ProbPrices); SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols, ProbPrices); @@ -908,7 +908,7 @@ MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables( /* { unsigned i; - UInt32 b; + uint32_t b; a = GET_PRICEa_0(enc->low[0]); for (i = 0; i < kLenNumLowSymbols; i++) p->prices2[i] = a; @@ -929,7 +929,7 @@ MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables( if (i > kLenNumLowSymbols * 2) { const CLzmaProb *probs = enc->high; - UInt32 *prices = p->prices[0] + kLenNumLowSymbols * 2; + uint32_t *prices = p->prices[0] + kLenNumLowSymbols * 2; i -= kLenNumLowSymbols * 2 - 1; i >>= 1; b += GET_PRICEa_1(enc->low[kLenNumLowSymbols]); @@ -940,9 +940,9 @@ MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables( // RcTree_GetPrice(enc->high, kLenNumHighBits, i - kLenNumLowSymbols * 2, ProbPrices); LitEnc_GetPrice(probs, i - kLenNumLowSymbols * 2, ProbPrices); */ - /* UInt32 price = a + RcTree_GetPrice(probs, kLenNumHighBits - 1, sym, ProbPrices); */ + /* uint32_t price = a + RcTree_GetPrice(probs, kLenNumHighBits - 1, sym, ProbPrices); */ unsigned sym = --i + (1 << (kLenNumHighBits - 1)); - UInt32 price = b; + uint32_t price = b; do { unsigned bit = sym & 1; @@ -979,7 +979,7 @@ MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables( #undef MOVE_POS #define MOVE_POS(p, num) { \ p->additionalOffset += (num); \ - p->matchFinder.Skip(p->matchFinderObj, (UInt32)(num)); } + p->matchFinder.Skip(p->matchFinderObj, (uint32_t)(num)); } static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes) @@ -1008,7 +1008,7 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes) if (len != p->numFastBytes) return len; { - UInt32 numAvail = p->numAvail; + uint32_t numAvail = p->numAvail; if (numAvail > LZMA_MATCH_LEN_MAX) numAvail = LZMA_MATCH_LEN_MAX; { @@ -1024,7 +1024,7 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes) } } -#define MARK_LIT ((UInt32)(Int32)-1) +#define MARK_LIT ((uint32_t)(int32_t)-1) #define MakeAs_Lit(p) { (p)->dist = MARK_LIT; (p)->extra = 0; } #define MakeAs_ShortRep(p) { (p)->dist = 0; (p)->extra = 0; } @@ -1041,10 +1041,10 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes) + GET_PRICE_0(p->isRepG0[state]) MY_FORCE_INLINE -static UInt32 GetPrice_PureRep(const CLzmaEnc *p, unsigned repIndex, size_t state, size_t posState) +static uint32_t GetPrice_PureRep(const CLzmaEnc *p, unsigned repIndex, size_t state, size_t posState) { - UInt32 price; - UInt32 prob = p->isRepG0[state]; + uint32_t price; + uint32_t prob = p->isRepG0[state]; if (repIndex == 0) { price = GET_PRICE_0(prob); @@ -1073,7 +1073,7 @@ static unsigned Backward(CLzmaEnc *p, unsigned cur) for (;;) { - UInt32 dist = p->opt[cur].dist; + uint32_t dist = p->opt[cur].dist; unsigned len = (unsigned)p->opt[cur].len; unsigned extra = (unsigned)p->opt[cur].extra; cur -= len; @@ -1081,7 +1081,7 @@ static unsigned Backward(CLzmaEnc *p, unsigned cur) if (extra) { wr--; - p->opt[wr].len = (UInt32)len; + p->opt[wr].len = (uint32_t)len; cur -= extra; len = extra; if (extra == 1) @@ -1108,27 +1108,27 @@ static unsigned Backward(CLzmaEnc *p, unsigned cur) wr--; p->opt[wr].dist = dist; - p->opt[wr].len = (UInt32)len; + p->opt[wr].len = (uint32_t)len; } } #define LIT_PROBS(pos, prevByte) \ - (p->litProbs + (UInt32)3 * (((((pos) << 8) + (prevByte)) & p->lpMask) << p->lc)) + (p->litProbs + (uint32_t)3 * (((((pos) << 8) + (prevByte)) & p->lpMask) << p->lc)) -static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) +static unsigned GetOptimum(CLzmaEnc *p, uint32_t position) { unsigned last, cur; - UInt32 reps[LZMA_NUM_REPS]; + uint32_t reps[LZMA_NUM_REPS]; unsigned repLens[LZMA_NUM_REPS]; - UInt32 *matches; + uint32_t *matches; { - UInt32 numAvail; + uint32_t numAvail; unsigned numPairs, mainLen, repMaxIndex, i, posState; - UInt32 matchPrice, repMatchPrice; + uint32_t matchPrice, repMatchPrice; const Byte *data; Byte curByte, matchByte; @@ -1175,7 +1175,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (repLens[repMaxIndex] >= p->numFastBytes) { unsigned len; - p->backRes = (UInt32)repMaxIndex; + p->backRes = (uint32_t)repMaxIndex; len = repLens[repMaxIndex]; MOVE_POS(p, len - 1) return len; @@ -1223,7 +1223,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) /* 18.06 */ if (matchByte == curByte && repLens[0] == 0) { - UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, p->state, posState); + uint32_t shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, p->state, posState); if (shortRepPrice < p->opt[1].price) { p->opt[1].price = shortRepPrice; @@ -1248,19 +1248,19 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) for (i = 0; i < LZMA_NUM_REPS; i++) { unsigned repLen = repLens[i]; - UInt32 price; + uint32_t price; if (repLen < 2) continue; price = repMatchPrice + GetPrice_PureRep(p, i, p->state, posState); do { - UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, repLen); + uint32_t price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, repLen); COptimal *opt = &p->opt[repLen]; if (price2 < opt->price) { opt->price = price2; - opt->len = (UInt32)repLen; - opt->dist = (UInt32)i; + opt->len = (uint32_t)repLen; + opt->dist = (uint32_t)i; opt->extra = 0; } } @@ -1274,7 +1274,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (len <= mainLen) { unsigned offs = 0; - UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); + uint32_t normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); if (len < 2) len = 2; @@ -1285,8 +1285,8 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) for (; ; len++) { COptimal *opt; - UInt32 dist = matches[(size_t)offs + 1]; - UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); + uint32_t dist = matches[(size_t)offs + 1]; + uint32_t price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); unsigned lenToPosState = GetLenToPosState(len); if (dist < kNumFullDistances) @@ -1304,7 +1304,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (price < opt->price) { opt->price = price; - opt->len = (UInt32)len; + opt->len = (uint32_t)len; opt->dist = dist + LZMA_NUM_REPS; opt->extra = 0; } @@ -1340,9 +1340,9 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) for (;;) { unsigned numAvail; - UInt32 numAvailFull; + uint32_t numAvailFull; unsigned newLen, numPairs, prev, state, posState, startLen; - UInt32 litPrice, matchPrice, repMatchPrice; + uint32_t litPrice, matchPrice, repMatchPrice; BoolInt nextIsLit; Byte curByte, matchByte; const Byte *data; @@ -1355,11 +1355,11 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (cur >= kNumOpts - 64) { unsigned j, best; - UInt32 price = p->opt[cur].price; + uint32_t price = p->opt[cur].price; best = cur; for (j = cur + 1; j <= last; j++) { - UInt32 price2 = p->opt[j].price; + uint32_t price2 = p->opt[j].price; if (price >= price2) { price = price2; @@ -1409,8 +1409,8 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) else { const COptimal *prevOpt; - UInt32 b0; - UInt32 dist = curOpt->dist; + uint32_t b0; + uint32_t dist = curOpt->dist; if (curOpt->extra) { @@ -1489,7 +1489,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) */ { - UInt32 curPrice = curOpt->price; + uint32_t curPrice = curOpt->price; unsigned prob = p->isMatch[state][posState]; matchPrice = curPrice + GET_PRICE_1(prob); litPrice = curPrice + GET_PRICE_0(prob); @@ -1528,7 +1528,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) { unsigned temp = kNumOpts - 1 - cur; if (numAvailFull > temp) - numAvailFull = (UInt32)temp; + numAvailFull = (uint32_t)temp; } /* 18.06 */ @@ -1545,7 +1545,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) ) ) { - UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, state, posState); + uint32_t shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, state, posState); /* if (shortRepPrice <= nextOpt->price) // 17.old */ if (shortRepPrice < nextOpt->price) /* 18.new */ { @@ -1582,7 +1582,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) { unsigned state2 = kLiteralNextStates[state]; unsigned posState2 = (position + 1) & p->pbMask; - UInt32 price = litPrice + GetPrice_Rep_0(p, state2, posState2); + uint32_t price = litPrice + GetPrice_Rep_0(p, state2, posState2); { unsigned offset = cur + len; @@ -1591,7 +1591,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) /* do */ { - UInt32 price2; + uint32_t price2; COptimal *opt; len--; /* price2 = price + GetPrice_Len_Rep_0(p, len, state2, posState2); */ @@ -1602,7 +1602,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (price2 < opt->price) { opt->price = price2; - opt->len = (UInt32)len; + opt->len = (uint32_t)len; opt->dist = 0; opt->extra = 1; } @@ -1622,7 +1622,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) for (; repIndex < LZMA_NUM_REPS; repIndex++) { unsigned len; - UInt32 price; + uint32_t price; const Byte *data2 = data - reps[repIndex]; if (data[0] != data2[0] || data[1] != data2[1]) continue; @@ -1642,13 +1642,13 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) price = repMatchPrice + GetPrice_PureRep(p, repIndex, state, posState); do { - UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, len2); + uint32_t price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, len2); COptimal *opt = &p->opt[cur + len2]; if (price2 < opt->price) { opt->price = price2; - opt->len = (UInt32)len2; - opt->dist = (UInt32)repIndex; + opt->len = (uint32_t)len2; + opt->dist = (uint32_t)repIndex; opt->extra = 0; } } @@ -1700,7 +1700,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) last = offset; /* do */ { - UInt32 price2; + uint32_t price2; COptimal *opt; len2--; /* price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2); */ @@ -1711,9 +1711,9 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (price2 < opt->price) { opt->price = price2; - opt->len = (UInt32)len2; + opt->len = (uint32_t)len2; opt->extra = (CExtra)(len + 1); - opt->dist = (UInt32)repIndex; + opt->dist = (uint32_t)repIndex; } } /* while (len2 >= 3); */ @@ -1731,7 +1731,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) { newLen = numAvail; for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2); - matches[numPairs] = (UInt32)newLen; + matches[numPairs] = (uint32_t)newLen; numPairs += 2; } @@ -1739,8 +1739,8 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (newLen >= startLen) { - UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]); - UInt32 dist; + uint32_t normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]); + uint32_t dist; unsigned offs, posSlot, len; { @@ -1759,7 +1759,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) for (len = /*2*/ startLen; ; len++) { - UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); + uint32_t price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); { COptimal *opt; unsigned lenNorm = len - 2; @@ -1773,7 +1773,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (price < opt->price) { opt->price = price; - opt->len = (UInt32)len; + opt->len = (uint32_t)len; opt->dist = dist + LZMA_NUM_REPS; opt->extra = 0; } @@ -1821,7 +1821,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) last = offset; /* do */ { - UInt32 price2; + uint32_t price2; COptimal *opt; len2--; /* price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2); */ @@ -1831,7 +1831,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) if (price2 < opt->price) { opt->price = price2; - opt->len = (UInt32)len2; + opt->len = (uint32_t)len2; opt->extra = (CExtra)(len + 1); opt->dist = dist + LZMA_NUM_REPS; } @@ -1867,7 +1867,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) static unsigned GetOptimumFast(CLzmaEnc *p) { - UInt32 numAvail, mainDist; + uint32_t numAvail, mainDist; unsigned mainLen, numPairs, repIndex, repLen, i; const Byte *data; @@ -1899,7 +1899,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p) {} if (len >= p->numFastBytes) { - p->backRes = (UInt32)i; + p->backRes = (uint32_t)i; MOVE_POS(p, len - 1) return len; } @@ -1924,7 +1924,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p) mainDist = p->matches[(size_t)numPairs - 1]; while (numPairs > 2) { - UInt32 dist2; + uint32_t dist2; if (mainLen != p->matches[(size_t)numPairs - 4] + 1) break; dist2 = p->matches[(size_t)numPairs - 3]; @@ -1943,7 +1943,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p) || (repLen + 2 >= mainLen && mainDist >= (1 << 9)) || (repLen + 3 >= mainLen && mainDist >= (1 << 15))) { - p->backRes = (UInt32)repIndex; + p->backRes = (uint32_t)repIndex; MOVE_POS(p, repLen - 1) return repLen; } @@ -1957,7 +1957,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p) if (len1 >= 2) { - UInt32 newDist = p->matches[(size_t)p->numPairs - 1]; + uint32_t newDist = p->matches[(size_t)p->numPairs - 1]; if ( (len1 >= mainLen && newDist < mainDist) || (len1 == mainLen + 1 && !ChangePair(mainDist, newDist)) || (len1 > mainLen + 1) @@ -1997,10 +1997,10 @@ static unsigned GetOptimumFast(CLzmaEnc *p) static void WriteEndMarker(CLzmaEnc *p, unsigned posState) { - UInt32 range; + uint32_t range; range = p->rc.range; { - UInt32 ttt, newBound; + uint32_t ttt, newBound; CLzmaProb *prob = &p->isMatch[p->state][posState]; RC_BIT_PRE(&p->rc, prob) RC_BIT_1(&p->rc, prob) @@ -2020,7 +2020,7 @@ static void WriteEndMarker(CLzmaEnc *p, unsigned posState) unsigned m = 1; do { - UInt32 ttt, newBound; + uint32_t ttt, newBound; RC_BIT_PRE(p, probs + m) RC_BIT_1(&p->rc, probs + m); m = (m << 1) + 1; @@ -2028,7 +2028,7 @@ static void WriteEndMarker(CLzmaEnc *p, unsigned posState) while (m < (1 << kNumPosSlotBits)); } { - /* RangeEnc_EncodeDirectBits(&p->rc, ((UInt32)1 << (30 - kNumAlignBits)) - 1, 30 - kNumAlignBits); UInt32 range = p->range; */ + /* RangeEnc_EncodeDirectBits(&p->rc, ((uint32_t)1 << (30 - kNumAlignBits)) - 1, 30 - kNumAlignBits); uint32_t range = p->range; */ unsigned numBits = 30 - kNumAlignBits; do { @@ -2045,7 +2045,7 @@ static void WriteEndMarker(CLzmaEnc *p, unsigned posState) unsigned m = 1; do { - UInt32 ttt, newBound; + uint32_t ttt, newBound; RC_BIT_PRE(p, probs + m) RC_BIT_1(&p->rc, probs + m); m = (m << 1) + 1; @@ -2070,7 +2070,7 @@ static SRes CheckErrors(CLzmaEnc *p) } -MY_NO_INLINE static SRes Flush(CLzmaEnc *p, UInt32 nowPos) +MY_NO_INLINE static SRes Flush(CLzmaEnc *p, uint32_t nowPos) { /* ReleaseMFStream(); */ p->finished = True; @@ -2090,11 +2090,11 @@ MY_NO_INLINE static void FillAlignPrices(CLzmaEnc *p) /* p->alignPriceCount = 0; */ for (i = 0; i < kAlignTableSize / 2; i++) { - UInt32 price = 0; + uint32_t price = 0; unsigned sym = i; unsigned m = 1; unsigned bit; - UInt32 prob; + uint32_t prob; bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; @@ -2110,7 +2110,7 @@ MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) { /* int y; for (y = 0; y < 100; y++) { */ - UInt32 tempPrices[kNumFullDistances]; + uint32_t tempPrices[kNumFullDistances]; unsigned i, lps; const CProbPrice *ProbPrices = p->ProbPrices; @@ -2123,7 +2123,7 @@ MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) unsigned base = ((2 | (posSlot & 1)) << footerBits); const CLzmaProb *probs = p->posEncoders + (size_t)base * 2; /* tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base, footerBits, i - base, p->ProbPrices); */ - UInt32 price = 0; + uint32_t price = 0; unsigned m = 1; unsigned sym = i; unsigned offset = (unsigned)1 << footerBits; @@ -2150,13 +2150,13 @@ MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) { unsigned slot; unsigned distTableSize2 = (p->distTableSize + 1) >> 1; - UInt32 *posSlotPrices = p->posSlotPrices[lps]; + uint32_t *posSlotPrices = p->posSlotPrices[lps]; const CLzmaProb *probs = p->posSlotEncoder[lps]; for (slot = 0; slot < distTableSize2; slot++) { /* posSlotPrices[slot] = RcTree_GetPrice(encoder, kNumPosSlotBits, slot, p->ProbPrices); */ - UInt32 price; + uint32_t price; unsigned bit; unsigned sym = slot + (1 << (kNumPosSlotBits - 1)); unsigned prob; @@ -2171,17 +2171,17 @@ MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) } { - UInt32 delta = ((UInt32)((kEndPosModelIndex / 2 - 1) - kNumAlignBits) << kNumBitPriceShiftBits); + uint32_t delta = ((uint32_t)((kEndPosModelIndex / 2 - 1) - kNumAlignBits) << kNumBitPriceShiftBits); for (slot = kEndPosModelIndex / 2; slot < distTableSize2; slot++) { posSlotPrices[(size_t)slot * 2 ] += delta; posSlotPrices[(size_t)slot * 2 + 1] += delta; - delta += ((UInt32)1 << kNumBitPriceShiftBits); + delta += ((uint32_t)1 << kNumBitPriceShiftBits); } } { - UInt32 *dp = p->distancesPrices[lps]; + uint32_t *dp = p->distancesPrices[lps]; dp[0] = posSlotPrices[0]; dp[1] = posSlotPrices[1]; @@ -2190,7 +2190,7 @@ MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) for (i = 4; i < kNumFullDistances; i += 2) { - UInt32 slotPrice = posSlotPrices[GetPosSlot1(i)]; + uint32_t slotPrice = posSlotPrices[GetPosSlot1(i)]; dp[i ] = slotPrice + tempPrices[i]; dp[i + 1] = slotPrice + tempPrices[i + 1]; } @@ -2262,9 +2262,9 @@ void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig) } -static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpackSize) +static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, uint32_t maxPackSize, uint32_t maxUnpackSize) { - UInt32 nowPos32, startPos32; + uint32_t nowPos32, startPos32; if (p->needInit) { p->matchFinder.Init(p->matchFinderObj); @@ -2275,7 +2275,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa return p->result; RINOK(CheckErrors(p)); - nowPos32 = (UInt32)p->nowPos64; + nowPos32 = (uint32_t)p->nowPos64; startPos32 = nowPos32; if (p->nowPos64 == 0) @@ -2297,9 +2297,9 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa for (;;) { - UInt32 dist; + uint32_t dist; unsigned len, posState; - UInt32 range, ttt, newBound; + uint32_t range, ttt, newBound; CLzmaProb *probs; if (p->fastMode) @@ -2437,13 +2437,13 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa GetPosSlot(dist, posSlot); /* RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], posSlot); */ { - UInt32 sym = (UInt32)posSlot + (1 << kNumPosSlotBits); + uint32_t sym = (uint32_t)posSlot + (1 << kNumPosSlotBits); range = p->rc.range; probs = p->posSlotEncoder[GetLenToPosState(len)]; do { CLzmaProb *prob = probs + (sym >> kNumPosSlotBits); - UInt32 bit = (sym >> (kNumPosSlotBits - 1)) & 1; + uint32_t bit = (sym >> (kNumPosSlotBits - 1)) & 1; sym <<= 1; RC_BIT(&p->rc, prob, bit); } @@ -2462,7 +2462,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa } else { - UInt32 pos2 = (dist | 0xF) << (32 - footerBits); + uint32_t pos2 = (dist | 0xF) << (32 - footerBits); range = p->rc.range; /* RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits); */ /* @@ -2501,12 +2501,12 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa } } - nowPos32 += (UInt32)len; + nowPos32 += (uint32_t)len; p->additionalOffset -= len; if (p->additionalOffset == 0) { - UInt32 processed; + uint32_t processed; if (!p->fastMode) { @@ -2557,11 +2557,11 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa -#define kBigHashDicLimit ((UInt32)1 << 24) +#define kBigHashDicLimit ((uint32_t)1 << 24) -static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) +static SRes LzmaEnc_Alloc(CLzmaEnc *p, uint32_t keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) { - UInt32 beforeSize = kNumOpts; + uint32_t beforeSize = kNumOpts; if (!RangeEnc_Alloc(&p->rc, alloc)) return SZ_ERROR_MEM; @@ -2574,8 +2574,8 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, if (!p->litProbs || !p->saveState.litProbs || p->lclp != lclp) { LzmaEnc_FreeLits(p, alloc); - p->litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb)); - p->saveState.litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb)); + p->litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((uint32_t)0x300 << lclp) * sizeof(CLzmaProb)); + p->saveState.litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((uint32_t)0x300 << lclp) * sizeof(CLzmaProb)); if (!p->litProbs || !p->saveState.litProbs) { LzmaEnc_FreeLits(p, alloc); @@ -2657,8 +2657,8 @@ void LzmaEnc_Init(CLzmaEnc *p) } { - UInt32 num = (UInt32)0x300 << (p->lp + p->lc); - UInt32 k; + uint32_t num = (uint32_t)0x300 << (p->lp + p->lc); + uint32_t k; CLzmaProb *probs = p->litProbs; for (k = 0; k < num; k++) probs[k] = kProbInitValue; @@ -2679,7 +2679,7 @@ void LzmaEnc_Init(CLzmaEnc *p) p->additionalOffset = 0; p->pbMask = (1 << p->pb) - 1; - p->lpMask = ((UInt32)0x100 << p->lp) - ((unsigned)0x100 >> p->lc); + p->lpMask = ((uint32_t)0x100 << p->lp) - ((unsigned)0x100 >> p->lc); } @@ -2701,11 +2701,11 @@ void LzmaEnc_InitPrices(CLzmaEnc *p) LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, &p->repLenProbs, p->ProbPrices); } -static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) +static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, uint32_t keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) { unsigned i; for (i = kEndPosModelIndex / 2; i < kDicLogSizeMax; i++) - if (p->dictSize <= ((UInt32)1 << i)) + if (p->dictSize <= ((uint32_t)1 << i)) break; p->distTableSize = i * 2; @@ -2729,7 +2729,7 @@ static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInS } SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, - ISeqInStream *inStream, UInt32 keepWindowSize, + ISeqInStream *inStream, uint32_t keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) { CLzmaEnc *p = (CLzmaEnc *)pp; @@ -2746,7 +2746,7 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) } SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, - UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) + uint32_t keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) { CLzmaEnc *p = (CLzmaEnc *)pp; LzmaEnc_SetInputBuf(p, src, srcLen); @@ -2791,7 +2791,7 @@ static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const void *data, s } -UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) +uint32_t LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) { const CLzmaEnc *p = (CLzmaEnc *)pp; return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); @@ -2806,10 +2806,10 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, - Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) + Byte *dest, size_t *destLen, uint32_t desiredPackSize, uint32_t *unpackSize) { CLzmaEnc *p = (CLzmaEnc *)pp; - UInt64 nowPos64; + uint64_t nowPos64; SRes res; CLzmaEnc_SeqOutStreamBuf outStream; @@ -2835,7 +2835,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize); - *unpackSize = (UInt32)(p->nowPos64 - nowPos64); + *unpackSize = (uint32_t)(p->nowPos64 - nowPos64); *destLen -= outStream.rem; if (outStream.overflow) return SZ_ERROR_OUTPUT_EOF; @@ -2894,22 +2894,22 @@ SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) { CLzmaEnc *p = (CLzmaEnc *)pp; unsigned i; - UInt32 dictSize = p->dictSize; + uint32_t dictSize = p->dictSize; if (*size < LZMA_PROPS_SIZE) return SZ_ERROR_PARAM; *size = LZMA_PROPS_SIZE; props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc); - if (dictSize >= ((UInt32)1 << 22)) + if (dictSize >= ((uint32_t)1 << 22)) { - UInt32 kDictMask = ((UInt32)1 << 20) - 1; - if (dictSize < (UInt32)0xFFFFFFFF - kDictMask) + uint32_t kDictMask = ((uint32_t)1 << 20) - 1; + if (dictSize < (uint32_t)0xFFFFFFFF - kDictMask) dictSize = (dictSize + kDictMask) & ~kDictMask; } else for (i = 11; i <= 30; i++) { - if (dictSize <= ((UInt32)2 << i)) { dictSize = (2 << i); break; } - if (dictSize <= ((UInt32)3 << i)) { dictSize = (3 << i); break; } + if (dictSize <= ((uint32_t)2 << i)) { dictSize = (2 << i); break; } + if (dictSize <= ((uint32_t)3 << i)) { dictSize = (3 << i); break; } } for (i = 0; i < 4; i++) diff --git a/deps/7zip/LzmaEnc.h b/deps/7zip/LzmaEnc.h index 9194ee576d..44b8967844 100644 --- a/deps/7zip/LzmaEnc.h +++ b/deps/7zip/LzmaEnc.h @@ -13,7 +13,7 @@ EXTERN_C_BEGIN typedef struct _CLzmaEncProps { int level; /* 0 <= level <= 9 */ - UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version + uint32_t dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version (1 << 12) <= dictSize <= (3 << 29) for 64-bit version default = (1 << 24) */ int lc; /* 0 <= lc <= 8, default = 3 */ @@ -23,17 +23,17 @@ typedef struct _CLzmaEncProps int fb; /* 5 <= fb <= 273, default = 32 */ int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ int numHashBytes; /* 2, 3 or 4, default = 4 */ - UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ + uint32_t mc; /* 1 <= mc <= (1 << 30), default = 32 */ unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ int numThreads; /* 1 or 2, default = 2 */ - UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1. + uint64_t reduceSize; /* estimated size of data that will be compressed. default = (uint64_t)(Int64)-1. Encoder uses this value to reduce dictionary size */ } CLzmaEncProps; void LzmaEncProps_Init(CLzmaEncProps *p); void LzmaEncProps_Normalize(CLzmaEncProps *p); -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); +uint32_t LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); /* ---------- CLzmaEncHandle Interface ---------- */ @@ -55,7 +55,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc); void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig); SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); -void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize); +void LzmaEnc_SetDataSize(CLzmaEncHandle p, uint64_t expectedDataSiize); SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p); diff --git a/libretro-common/file/archive_file_7z.c b/libretro-common/file/archive_file_7z.c index b9a82c190f..c0aa7ad0ff 100644 --- a/libretro-common/file/archive_file_7z.c +++ b/libretro-common/file/archive_file_7z.c @@ -59,7 +59,7 @@ struct sevenzip_context_t uint32_t parse_index; uint32_t decompress_index; uint32_t packIndex; - UInt32 block_index; + uint32_t block_index; }; static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t size) @@ -200,7 +200,7 @@ static int64_t sevenzip_file_read( bool file_found = false; uint16_t *temp = NULL; size_t temp_size = 0; - UInt32 block_index = 0xFFFFFFFF; + uint32_t block_index = 0xFFFFFFFF; SRes res = SZ_OK; for (i = 0; i < db.NumFiles; i++)