Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2009-12-14 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:01 +0300
commit1fbaf0aac5000ca563a1ee2bb15ba6821a08e468 (patch)
treeec079944edffd096355ecb0c499f889364aefb4b
parent2fed8721946901375d21d4a506fe8b114045b397 (diff)
9.09 beta
-rwxr-xr-xAsm/arm/7zCrcOpt.asm100
-rwxr-xr-xAsm/x64/7zCrcT8U.asm101
-rwxr-xr-xAsm/x86/7zAsm.asm93
-rwxr-xr-xAsm/x86/7zCrcOpt.asm147
-rwxr-xr-xAsm/x86/7zCrcT8U.asm101
-rwxr-xr-xAsm/x86/AesOpt.asm237
-rwxr-xr-xC/7zCrc.c77
-rwxr-xr-xC/7zCrc.h15
-rwxr-xr-xC/7zCrcOpt.c34
-rwxr-xr-xC/7zCrcT8.c43
-rwxr-xr-xC/7zFile.c15
-rwxr-xr-xC/7zFile.h4
-rwxr-xr-xC/7zIn.c3
-rwxr-xr-xC/7zVersion.h6
-rwxr-xr-xC/Aes.c152
-rwxr-xr-xC/Aes.h58
-rwxr-xr-xC/AesOpt.c182
-rwxr-xr-xC/CpuArch.c168
-rwxr-xr-xC/CpuArch.h68
-rwxr-xr-xC/HuffEnc.c10
-rwxr-xr-xC/LzFindMt.c24
-rwxr-xr-xC/Lzma2Enc.c22
-rwxr-xr-xC/LzmaDec.c14
-rwxr-xr-xC/LzmaEnc.c26
-rwxr-xr-xC/MtCoder.h12
-rwxr-xr-xC/Threads.c6
-rwxr-xr-xC/Types.h12
-rwxr-xr-xC/Util/7z/7z.dsp32
-rwxr-xr-xC/Util/7z/7zMain.c5
-rwxr-xr-xC/Util/7z/makefile2
-rwxr-xr-xC/Util/7z/makefile.gcc12
-rwxr-xr-xC/Util/Lzma/makefile1
-rwxr-xr-xC/Util/Lzma/makefile.gcc2
-rwxr-xr-xC/Util/LzmaLib/LzmaLib.dsp2
-rwxr-xr-xC/Util/LzmaLib/makefile1
-rwxr-xr-xCPP/7zip/Aes.mak7
-rwxr-xr-xCPP/7zip/Archive/7z/7z.dsp14
-rwxr-xr-xCPP/7zip/Archive/7z/7zCompressionMode.h4
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.cpp4
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.h2
-rwxr-xr-xCPP/7zip/Archive/7z/7zEncode.cpp3
-rwxr-xr-xCPP/7zip/Archive/7z/7zExtract.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.cpp17
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.h6
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandlerOut.cpp12
-rwxr-xr-xCPP/7zip/Archive/7z/7zIn.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zItem.h10
-rwxr-xr-xCPP/7zip/Archive/7z/7zOut.cpp10
-rwxr-xr-xCPP/7zip/Archive/7z/7zRegister.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zUpdate.cpp20
-rwxr-xr-xCPP/7zip/Archive/7z/makefile9
-rwxr-xr-xCPP/7zip/Archive/ApmHandler.cpp356
-rwxr-xr-xCPP/7zip/Archive/Bz2Handler.cpp20
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHandler.cpp12
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.cpp14
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.h4
-rwxr-xr-xCPP/7zip/Archive/LzmaHandler.cpp3
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.cpp10
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.h3
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHandlerOut.cpp2
-rwxr-xr-xCPP/7zip/Archive/VhdHandler.cpp25
-rwxr-xr-xCPP/7zip/Archive/XarHandler.cpp33
-rwxr-xr-xCPP/7zip/Archive/XzHandler.cpp7
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.cpp60
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.h5
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipCompressionMode.h6
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.cpp77
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.h6
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandlerOut.cpp6
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHeader.h13
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipOut.cpp19
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipUpdate.cpp11
-rwxr-xr-xCPP/7zip/Asm.mak7
-rwxr-xr-xCPP/7zip/Bundles/Alone/Alone.dsp128
-rwxr-xr-xCPP/7zip/Bundles/Alone/makefile26
-rwxr-xr-xCPP/7zip/Bundles/Alone7z/makefile23
-rwxr-xr-xCPP/7zip/Bundles/Fm/FM.dsp94
-rwxr-xr-xCPP/7zip/Bundles/Fm/makefile19
-rwxr-xr-xCPP/7zip/Bundles/Format7z/makefile11
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtract/makefile11
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtractR/makefile8
-rwxr-xr-xCPP/7zip/Bundles/Format7zF/Format7z.dsp85
-rwxr-xr-xCPP/7zip/Bundles/Format7zF/makefile13
-rwxr-xr-xCPP/7zip/Bundles/Format7zR/makefile9
-rwxr-xr-xCPP/7zip/Bundles/LzmaCon/LzmaAlone.cpp (renamed from CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp)33
-rwxr-xr-xCPP/7zip/Bundles/LzmaCon/LzmaCon.dsp (renamed from CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp)211
-rwxr-xr-xCPP/7zip/Bundles/LzmaCon/LzmaCon.dsw (renamed from CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsw)2
-rwxr-xr-xCPP/7zip/Bundles/LzmaCon/StdAfx.cpp (renamed from CPP/7zip/Compress/LZMA_Alone/StdAfx.cpp)0
-rwxr-xr-xCPP/7zip/Bundles/LzmaCon/StdAfx.h (renamed from CPP/7zip/Compress/LZMA_Alone/StdAfx.h)0
-rwxr-xr-xCPP/7zip/Bundles/LzmaCon/makefile (renamed from CPP/7zip/Compress/LZMA_Alone/makefile)40
-rwxr-xr-xCPP/7zip/Bundles/LzmaCon/makefile.gcc (renamed from CPP/7zip/Compress/LZMA_Alone/makefile.gcc)54
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/SFXCon.dsp17
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/makefile11
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/SFXSetup.dsp16
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/makefile7
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/SFXWin.dsp17
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/makefile9
-rwxr-xr-xCPP/7zip/Bundles/makefile1
-rwxr-xr-xCPP/7zip/Common/CreateCoder.cpp5
-rwxr-xr-xCPP/7zip/Common/CreateCoder.h8
-rwxr-xr-xCPP/7zip/Common/FilterCoder.cpp72
-rwxr-xr-xCPP/7zip/Common/FilterCoder.h25
-rwxr-xr-xCPP/7zip/Common/MethodProps.h4
-rwxr-xr-xCPP/7zip/Common/RegisterArc.h8
-rwxr-xr-xCPP/7zip/Compress/ArjDecoder1.cpp10
-rwxr-xr-xCPP/7zip/Compress/BZip2Decoder.cpp10
-rwxr-xr-xCPP/7zip/Compress/BZip2Decoder.h16
-rwxr-xr-xCPP/7zip/Compress/BZip2Encoder.cpp24
-rwxr-xr-xCPP/7zip/Compress/BZip2Encoder.h16
-rwxr-xr-xCPP/7zip/Compress/BitlDecoder.h17
-rwxr-xr-xCPP/7zip/Compress/BitlEncoder.h15
-rwxr-xr-xCPP/7zip/Compress/BitmDecoder.h14
-rwxr-xr-xCPP/7zip/Compress/BitmEncoder.h12
-rwxr-xr-xCPP/7zip/Compress/DllExports.cpp8
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h20
-rwxr-xr-xCPP/7zip/Compress/LzmaDecoder.h2
-rwxr-xr-xCPP/7zip/Compress/Lzx.h42
-rwxr-xr-xCPP/7zip/Compress/LzxDecoder.cpp36
-rwxr-xr-xCPP/7zip/Compress/LzxDecoder.h34
-rwxr-xr-xCPP/7zip/Compress/QuantumDecoder.cpp36
-rwxr-xr-xCPP/7zip/Compress/QuantumDecoder.h99
-rwxr-xr-xCPP/7zip/Compress/Rar1Decoder.cpp2
-rwxr-xr-xCPP/7zip/Compress/Rar2Decoder.cpp2
-rwxr-xr-xCPP/7zip/Compress/Rar3Decoder.cpp5
-rwxr-xr-xCPP/7zip/Crc.mak19
-rwxr-xr-xCPP/7zip/Crc2.mak7
-rwxr-xr-xCPP/7zip/Crypto/7zAes.cpp4
-rwxr-xr-xCPP/7zip/Crypto/MyAes.cpp45
-rwxr-xr-xCPP/7zip/Crypto/MyAes.h25
-rwxr-xr-xCPP/7zip/Crypto/RarAes.cpp31
-rwxr-xr-xCPP/7zip/Crypto/RarAes.h22
-rwxr-xr-xCPP/7zip/Crypto/WzAes.cpp110
-rwxr-xr-xCPP/7zip/Crypto/WzAes.h53
-rwxr-xr-xCPP/7zip/Crypto/ZipStrong.cpp73
-rwxr-xr-xCPP/7zip/Crypto/ZipStrong.h18
-rwxr-xr-xCPP/7zip/Guid.txt1
-rwxr-xr-xCPP/7zip/ICoder.h1
-rwxr-xr-xCPP/7zip/MyVersion.h8
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.h6
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.cpp3
-rwxr-xr-xCPP/7zip/UI/Common/Bench.cpp (renamed from CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp)68
-rwxr-xr-xCPP/7zip/UI/Common/Bench.h (renamed from CPP/7zip/Compress/LZMA_Alone/LzmaBench.h)16
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall2.cpp9
-rwxr-xr-xCPP/7zip/UI/Common/Extract.cpp2
-rwxr-xr-xCPP/7zip/UI/Common/Extract.h2
-rwxr-xr-xCPP/7zip/UI/Console/BenchCon.cpp (renamed from CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp)36
-rwxr-xr-xCPP/7zip/UI/Console/BenchCon.h16
-rwxr-xr-xCPP/7zip/UI/Console/Console.dsp151
-rwxr-xr-xCPP/7zip/UI/Console/ConsoleClose.cpp6
-rwxr-xr-xCPP/7zip/UI/Console/Main.cpp20
-rwxr-xr-xCPP/7zip/UI/Console/UpdateCallbackConsole.cpp4
-rwxr-xr-xCPP/7zip/UI/Console/makefile23
-rwxr-xr-xCPP/7zip/UI/Far/Far.dsp10
-rwxr-xr-xCPP/7zip/UI/Far/makefile9
-rwxr-xr-xCPP/7zip/UI/FileManager/FM.dsp54
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/MyCom2.h13
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItemOpen.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/PhysDriveFolder.cpp295
-rwxr-xr-xCPP/7zip/UI/FileManager/PhysDriveFolder.h59
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.cpp15
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.h1
-rwxr-xr-xCPP/7zip/UI/FileManager/makefile7
-rwxr-xr-xCPP/7zip/UI/GUI/BenchmarkDialog.cpp17
-rwxr-xr-xCPP/7zip/UI/GUI/BenchmarkDialog.h13
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.cpp15
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.dsp96
-rwxr-xr-xCPP/7zip/UI/GUI/makefile20
-rwxr-xr-xCPP/7zip/makefile1
-rwxr-xr-xCPP/Build.mak17
-rwxr-xr-xCPP/Common/MyVector.cpp6
-rwxr-xr-xCPP/Common/UTFConvert.cpp2
-rwxr-xr-xCPP/Windows/Defs.h18
-rwxr-xr-xDOC/7zip.hhp1
-rwxr-xr-xDOC/7zip.inf4
-rwxr-xr-xDOC/7zip.nsi4
-rwxr-xr-xDOC/7zip.wxs2
-rwxr-xr-xDOC/history.txt7
-rwxr-xr-xDOC/lzma.txt5
179 files changed, 3350 insertions, 2121 deletions
diff --git a/Asm/arm/7zCrcOpt.asm b/Asm/arm/7zCrcOpt.asm
new file mode 100755
index 00000000..6001d8e3
--- /dev/null
+++ b/Asm/arm/7zCrcOpt.asm
@@ -0,0 +1,100 @@
+ CODE32
+
+ EXPORT |CrcUpdateT4@16|
+
+ AREA |.text|, CODE, ARM
+
+ MACRO
+ CRC32_STEP_1
+
+ ldrb r4, [r1], #1
+ subs r2, r2, #1
+ eor r4, r4, r0
+ and r4, r4, #0xFF
+ ldr r4, [r3, +r4, lsl #2]
+ eor r0, r4, r0, lsr #8
+
+ MEND
+
+
+ MACRO
+ CRC32_STEP_4 $STREAM_WORD
+
+ eor r7, r7, r8
+ eor r7, r7, r9
+ eor r0, r0, r7
+ eor r0, r0, $STREAM_WORD
+ ldr $STREAM_WORD, [r1], #4
+
+ and r7, r0, #0xFF
+ and r8, r0, #0xFF00
+ and r9, r0, #0xFF0000
+ and r0, r0, #0xFF000000
+
+ ldr r7, [r6, +r7, lsl #2]
+ ldr r8, [r5, +r8, lsr #6]
+ ldr r9, [r4, +r9, lsr #14]
+ ldr r0, [r3, +r0, lsr #22]
+
+ MEND
+
+
+|CrcUpdateT4@16| PROC
+
+ stmdb sp!, {r4-r11, lr}
+ cmp r2, #0
+ beq |$fin|
+
+|$v1|
+ tst r1, #7
+ beq |$v2|
+ CRC32_STEP_1
+ bne |$v1|
+
+|$v2|
+ cmp r2, #16
+ blo |$v3|
+
+ ldr r10, [r1], #4
+ ldr r11, [r1], #4
+
+ add r4, r3, #0x400
+ add r5, r3, #0x800
+ add r6, r3, #0xC00
+
+ mov r7, #0
+ mov r8, #0
+ mov r9, #0
+
+ sub r2, r2, #16
+
+|$loop|
+ ; pld [r1, #0x40]
+
+ CRC32_STEP_4 r10
+ CRC32_STEP_4 r11
+
+ subs r2, r2, #8
+ bhs |$loop|
+
+ sub r1, r1, #8
+ add r2, r2, #16
+
+ eor r7, r7, r8
+ eor r7, r7, r9
+ eor r0, r0, r7
+
+|$v3|
+ cmp r2, #0
+ beq |$fin|
+
+|$v4|
+ CRC32_STEP_1
+ bne |$v4|
+
+|$fin|
+ ldmia sp!, {r4-r11, pc}
+
+|CrcUpdateT4@16| ENDP
+
+ END
diff --git a/Asm/x64/7zCrcT8U.asm b/Asm/x64/7zCrcT8U.asm
deleted file mode 100755
index 41194324..00000000
--- a/Asm/x64/7zCrcT8U.asm
+++ /dev/null
@@ -1,101 +0,0 @@
-.code
-
-
-
-
-CRC1b macro
- movzx EDX, BYTE PTR [RSI]
- inc RSI
- movzx EBX, AL
- xor EDX, EBX
- shr EAX, 8
- xor EAX, [RDI + RDX * 4]
- dec R8
-endm
-
-
-
-
-align 16
-CrcUpdateT8 PROC
-
- push RBX
- push RSI
- push RDI
- push RBP
-
- mov EAX, ECX
- mov RSI, RDX
- mov RDI, R9
-
-
- test R8, R8
- jz sl_end
- sl:
- test RSI, 7
- jz sl_end
- CRC1b
- jnz sl
- sl_end:
-
- cmp R8, 16
- jb crc_end
- mov R9, R8
- and R8, 7
- add R8, 8
- sub R9, R8
-
- add R9, RSI
- xor EAX, [RSI]
- mov EBX, [RSI + 4]
- movzx ECX, BL
- align 16
- main_loop:
- mov EDX, [RDI + RCX*4 + 0C00h]
- movzx EBP, BH
- xor EDX, [RDI + RBP*4 + 0800h]
- shr EBX, 16
- movzx ECX, BL
- xor EDX, [RSI + 8]
- xor EDX, [RDI + RCX*4 + 0400h]
- movzx ECX, AL
- movzx EBP, BH
- xor EDX, [RDI + RBP*4 + 0000h]
-
- mov EBX, [RSI + 12]
-
- xor EDX, [RDI + RCX*4 + 01C00h]
- movzx EBP, AH
- shr EAX, 16
- movzx ECX, AL
- xor EDX, [RDI + RBP*4 + 01800h]
- movzx EBP, AH
- mov EAX, [RDI + RCX*4 + 01400h]
- add RSI, 8
- xor EAX, [RDI + RBP*4 + 01000h]
- movzx ECX, BL
- xor EAX,EDX
-
- cmp RSI, R9
- jne main_loop
- xor EAX, [RSI]
-
-
-
- crc_end:
-
- test R8, R8
- jz fl_end
- fl:
- CRC1b
- jnz fl
- fl_end:
-
- pop RBP
- pop RDI
- pop RSI
- pop RBX
- ret
-CrcUpdateT8 ENDP
-
-end
diff --git a/Asm/x86/7zAsm.asm b/Asm/x86/7zAsm.asm
new file mode 100755
index 00000000..3e42ab45
--- /dev/null
+++ b/Asm/x86/7zAsm.asm
@@ -0,0 +1,93 @@
+; 7zAsm.asm -- ASM macros
+; 2009-12-12 : Igor Pavlov : Public domain
+
+MY_ASM_START macro
+ ifdef x64
+ .code
+ else
+ .386
+ .model flat
+ _TEXT$00 SEGMENT PARA PUBLIC 'CODE'
+ endif
+endm
+
+MY_PROC macro name:req, numParams:req
+ align 16
+ proc_numParams equ numParams
+ ifdef x64
+ proc_name equ name
+ name PROC
+ else
+ proc_fastcall_name equ @CatStr(@,name,@, %numParams * 4)
+ public proc_fastcall_name
+ proc_fastcall_name:
+ endif
+endm
+
+MY_ENDP macro
+ ifdef x64
+ ret
+ proc_name ENDP
+ else
+ ret (proc_numParams - 2) * 4
+ endif
+endm
+
+ifdef x64
+ REG_SIZE equ 8
+else
+ REG_SIZE equ 4
+endif
+
+ x0 equ EAX
+ x1 equ ECX
+ x2 equ EDX
+ x3 equ EBX
+ x4 equ ESP
+ x5 equ EBP
+ x6 equ ESI
+ x7 equ EDI
+
+ x0_L equ AL
+ x1_L equ CL
+ x2_L equ DL
+ x3_L equ BL
+
+ x0_H equ AH
+ x1_H equ CH
+ x2_H equ DH
+ x3_H equ BH
+
+ifdef x64
+ r0 equ RAX
+ r1 equ RCX
+ r2 equ RDX
+ r3 equ RBX
+ r4 equ RSP
+ r5 equ RBP
+ r6 equ RSI
+ r7 equ RDI
+else
+ r0 equ x0
+ r1 equ x1
+ r2 equ x2
+ r3 equ x3
+ r4 equ x4
+ r5 equ x5
+ r6 equ x6
+ r7 equ x7
+endif
+
+MY_PUSH_4_REGS macro
+ push r3
+ push r5
+ push r6
+ push r7
+endm
+
+MY_POP_4_REGS macro
+ pop r7
+ pop r6
+ pop r5
+ pop r3
+endm
diff --git a/Asm/x86/7zCrcOpt.asm b/Asm/x86/7zCrcOpt.asm
new file mode 100755
index 00000000..724b9b2c
--- /dev/null
+++ b/Asm/x86/7zCrcOpt.asm
@@ -0,0 +1,147 @@
+; 7zCrcOpt.asm -- CRC32 calculation : optimized version
+; 2009-12-12 : Igor Pavlov : Public domain
+
+include 7zAsm.asm
+
+MY_ASM_START
+
+rD equ r2
+rN equ r7
+
+ifdef x64
+ num_VAR equ r8
+ table_VAR equ r9
+else
+ data_size equ (REG_SIZE * 5)
+ crc_table equ (REG_SIZE + data_size)
+ num_VAR equ [r4 + data_size]
+ table_VAR equ [r4 + crc_table]
+endif
+
+SRCDAT equ rN + rD + 4 *
+
+CRC macro op:req, dest:req, src:req, t:req
+ op dest, DWORD PTR [r5 + src * 4 + 0400h * t]
+endm
+
+CRC_XOR macro dest:req, src:req, t:req
+ CRC xor, dest, src, t
+endm
+
+CRC_MOV macro dest:req, src:req, t:req
+ CRC mov, dest, src, t
+endm
+
+CRC1b macro
+ movzx x6, BYTE PTR [rD]
+ inc rD
+ movzx x3, x0_L
+ xor x6, x3
+ shr x0, 8
+ CRC xor, x0, r6, 0
+ dec rN
+endm
+
+MY_PROLOG macro crc_end:req
+ MY_PUSH_4_REGS
+
+ mov x0, x1
+ mov rN, num_VAR
+ mov r5, table_VAR
+ test rN, rN
+ jz crc_end
+ @@:
+ test rD, 7
+ jz @F
+ CRC1b
+ jnz @B
+ @@:
+ cmp rN, 16
+ jb crc_end
+ add rN, rD
+ mov num_VAR, rN
+ sub rN, 8
+ and rN, NOT 7
+ sub rD, rN
+ xor x0, [SRCDAT 0]
+endm
+
+MY_EPILOG macro crc_end:req
+ xor x0, [SRCDAT 0]
+ mov rD, rN
+ mov rN, num_VAR
+ sub rN, rD
+ crc_end:
+ test rN, rN
+ jz @F
+ CRC1b
+ jmp crc_end
+ @@:
+ MY_POP_4_REGS
+endm
+
+MY_PROC CrcUpdateT8, 4
+ MY_PROLOG crc_end_8
+ mov x1, [SRCDAT 1]
+ align 16
+ main_loop_8:
+ mov x6, [SRCDAT 2]
+ movzx x3, x1_L
+ CRC_XOR x6, r3, 3
+ movzx x3, x1_H
+ CRC_XOR x6, r3, 2
+ shr x1, 16
+ movzx x3, x1_L
+ movzx x1, x1_H
+ CRC_XOR x6, r3, 1
+ movzx x3, x0_L
+ CRC_XOR x6, r1, 0
+
+ mov x1, [SRCDAT 3]
+ CRC_XOR x6, r3, 7
+ movzx x3, x0_H
+ shr x0, 16
+ CRC_XOR x6, r3, 6
+ movzx x3, x0_L
+ CRC_XOR x6, r3, 5
+ movzx x3, x0_H
+ CRC_MOV x0, r3, 4
+ xor x0, x6
+ add rD, 8
+ jnz main_loop_8
+
+ MY_EPILOG crc_end_8
+MY_ENDP
+
+MY_PROC CrcUpdateT4, 4
+ MY_PROLOG crc_end_4
+ align 16
+ main_loop_4:
+ movzx x1, x0_L
+ movzx x3, x0_H
+ shr x0, 16
+ movzx x6, x0_H
+ and x0, 0FFh
+ CRC_MOV x1, r1, 3
+ xor x1, [SRCDAT 1]
+ CRC_XOR x1, r3, 2
+ CRC_XOR x1, r6, 0
+ CRC_XOR x1, r0, 1
+
+ movzx x0, x1_L
+ movzx x3, x1_H
+ shr x1, 16
+ movzx x6, x1_H
+ and x1, 0FFh
+ CRC_MOV x0, r0, 3
+ xor x0, [SRCDAT 2]
+ CRC_XOR x0, r3, 2
+ CRC_XOR x0, r6, 0
+ CRC_XOR x0, r1, 1
+ add rD, 8
+ jnz main_loop_4
+
+ MY_EPILOG crc_end_4
+MY_ENDP
+
+end
diff --git a/Asm/x86/7zCrcT8U.asm b/Asm/x86/7zCrcT8U.asm
deleted file mode 100755
index 467724b8..00000000
--- a/Asm/x86/7zCrcT8U.asm
+++ /dev/null
@@ -1,101 +0,0 @@
-.386
-.model flat
-
-_TEXT$00 SEGMENT PARA PUBLIC 'CODE'
-
-CRC1b macro
- movzx EDX, BYTE PTR [ESI]
- inc ESI
- movzx EBX, AL
- xor EDX, EBX
- shr EAX, 8
- xor EAX, [EBP + EDX * 4]
- dec EDI
-endm
-
-data_size equ (4 + 4*4)
-crc_table equ (data_size + 4)
-
-align 16
-public @CrcUpdateT8@16
-@CrcUpdateT8@16:
- push EBX
- push ESI
- push EDI
- push EBP
-
- mov EAX, ECX
- mov ESI, EDX
- mov EDI, [ESP + data_size]
- mov EBP, [ESP + crc_table]
-
- test EDI, EDI
- jz sl_end
- sl:
- test ESI, 7
- jz sl_end
- CRC1b
- jnz sl
- sl_end:
-
- cmp EDI, 16
- jb crc_end
- mov [ESP + data_size], EDI
- sub EDI, 8
- and EDI, NOT 7
- sub [ESP + data_size], EDI
-
- add EDI, ESI
- xor EAX, [ESI]
- mov EBX, [ESI + 4]
- movzx ECX, BL
- align 16
- main_loop:
- mov EDX, [EBP + ECX*4 + 0C00h]
- movzx ECX, BH
- xor EDX, [EBP + ECX*4 + 0800h]
- shr EBX, 16
- movzx ECX, BL
- xor EDX, [EBP + ECX*4 + 0400h]
- xor EDX, [ESI + 8]
- movzx ECX, AL
- movzx EBX, BH
- xor EDX, [EBP + EBX*4 + 0000h]
-
- mov EBX, [ESI + 12]
-
- xor EDX, [EBP + ECX*4 + 01C00h]
- movzx ECX, AH
- add ESI, 8
- shr EAX, 16
- xor EDX, [EBP + ECX*4 + 01800h]
- movzx ECX, AL
- xor EDX, [EBP + ECX*4 + 01400h]
- movzx ECX, AH
- mov EAX, [EBP + ECX*4 + 01000h]
- movzx ECX, BL
- xor EAX,EDX
-
- cmp ESI, EDI
- jne main_loop
- xor EAX, [ESI]
-
- mov EDI, [ESP + data_size]
-
- crc_end:
-
- test EDI, EDI
- jz fl_end
- fl:
- CRC1b
- jnz fl
- fl_end:
-
- pop EBP
- pop EDI
- pop ESI
- pop EBX
- ret 8
-
-
-end
diff --git a/Asm/x86/AesOpt.asm b/Asm/x86/AesOpt.asm
new file mode 100755
index 00000000..21466712
--- /dev/null
+++ b/Asm/x86/AesOpt.asm
@@ -0,0 +1,237 @@
+; AesOpt.asm -- Intel's AES.
+; 2009-12-12 : Igor Pavlov : Public domain
+
+include 7zAsm.asm
+
+MY_ASM_START
+
+ifndef x64
+ .xmm
+endif
+
+ifdef x64
+ num equ r8
+else
+ num equ [r4 + REG_SIZE * 4]
+endif
+
+rD equ r2
+rN equ r0
+
+MY_PROLOG macro reg:req
+ ifdef x64
+ movdqa [r4 + 8], xmm6
+ movdqa [r4 + 8 + 16], xmm7
+ endif
+
+ push r3
+ push r5
+ push r6
+
+ mov rN, num
+ mov x6, [r1 + 16]
+ shl x6, 5
+
+ movdqa reg, [r1]
+ add r1, 32
+endm
+
+MY_EPILOG macro
+ pop r6
+ pop r5
+ pop r3
+
+ ifdef x64
+ movdqa xmm6, [r4 + 8]
+ movdqa xmm7, [r4 + 8 + 16]
+ endif
+
+ MY_ENDP
+endm
+
+ways equ 4
+ways16 equ (ways * 16)
+
+OP_W macro op, op2
+ i = 0
+ rept ways
+ op @CatStr(xmm,%i), op2
+ i = i + 1
+ endm
+endm
+
+LOAD_OP macro op:req, offs:req
+ op xmm0, [r1 + r3 offs]
+endm
+
+LOAD_OP_W macro op:req, offs:req
+ movdqa xmm7, [r1 + r3 offs]
+ OP_W op, xmm7
+endm
+
+
+; ---------- AES-CBC Decode ----------
+
+CBC_DEC_UPDATE macro reg, offs
+ pxor reg, xmm6
+ movdqa xmm6, [rD + offs]
+ movdqa [rD + offs], reg
+endm
+
+DECODE macro op:req
+ op aesdec, +16
+ @@:
+ op aesdec, +0
+ op aesdec, -16
+ sub x3, 32
+ jnz @B
+ op aesdeclast, +0
+endm
+
+MY_PROC AesCbc_Decode_Intel, 3
+ MY_PROLOG xmm6
+
+ sub x6, 32
+
+ jmp check2
+
+ align 16
+ nextBlocks2:
+ mov x3, x6
+ OP_W movdqa, [rD + i * 16]
+ LOAD_OP_W pxor, +32
+ DECODE LOAD_OP_W
+ OP_W CBC_DEC_UPDATE, i * 16
+ add rD, ways16
+ check2:
+ sub rN, ways
+ jnc nextBlocks2
+
+ add rN, ways
+ jmp check
+
+ nextBlock:
+ mov x3, x6
+ movdqa xmm1, [rD]
+ LOAD_OP movdqa, +32
+ pxor xmm0, xmm1
+ DECODE LOAD_OP
+ pxor xmm0, xmm6
+ movdqa [rD], xmm0
+ movdqa xmm6, xmm1
+ add rD, 16
+ check:
+ sub rN, 1
+ jnc nextBlock
+
+ movdqa [r1 - 32], xmm6
+ MY_EPILOG
+
+
+; ---------- AES-CBC Encode ----------
+
+ENCODE macro op:req
+ op aesenc, -16
+ @@:
+ op aesenc, +0
+ op aesenc, +16
+ add r3, 32
+ jnz @B
+ op aesenclast, +0
+endm
+
+MY_PROC AesCbc_Encode_Intel, 3
+ MY_PROLOG xmm0
+
+ add r1, r6
+ neg r6
+ add r6, 32
+
+ jmp check_e
+
+ align 16
+ nextBlock_e:
+ mov r3, r6
+ pxor xmm0, [rD]
+ pxor xmm0, [r1 + r3 - 32]
+ ENCODE LOAD_OP
+ movdqa [rD], xmm0
+ add rD, 16
+ check_e:
+ sub rN, 1
+ jnc nextBlock_e
+
+ movdqa [r1 + r6 - 64], xmm0
+ MY_EPILOG
+
+
+; ---------- AES-CTR ----------
+
+XOR_UPD_1 macro reg, offs
+ pxor reg, [rD + offs]
+endm
+
+XOR_UPD_2 macro reg, offs
+ movdqa [rD + offs], reg
+endm
+
+MY_PROC AesCtr_Code_Intel, 3
+ MY_PROLOG xmm6
+
+ mov r5, r4
+ shr r5, 4
+ dec r5
+ shl r5, 4
+
+ mov DWORD PTR [r5], 1
+ mov DWORD PTR [r5 + 4], 0
+ mov DWORD PTR [r5 + 8], 0
+ mov DWORD PTR [r5 + 12], 0
+
+ add r1, r6
+ neg r6
+ add r6, 32
+
+ jmp check2_c
+
+ align 16
+ nextBlocks2_c:
+ movdqa xmm7, [r5]
+
+ i = 0
+ rept ways
+ paddq xmm6, xmm7
+ movdqa @CatStr(xmm,%i), xmm6
+ i = i + 1
+ endm
+
+ mov r3, r6
+ LOAD_OP_W pxor, -32
+ ENCODE LOAD_OP_W
+ OP_W XOR_UPD_1, i * 16
+ OP_W XOR_UPD_2, i * 16
+ add rD, ways16
+ check2_c:
+ sub rN, ways
+ jnc nextBlocks2_c
+
+ add rN, ways
+ jmp check_c
+
+ nextBlock_c:
+ paddq xmm6, [r5]
+ mov r3, r6
+ movdqa xmm0, [r1 + r3 - 32]
+ pxor xmm0, xmm6
+ ENCODE LOAD_OP
+ XOR_UPD_1 xmm0, 0
+ XOR_UPD_2 xmm0, 0
+ add rD, 16
+ check_c:
+ sub rN, 1
+ jnc nextBlock_c
+
+ movdqa [r1 + r6 - 64], xmm6
+ MY_EPILOG
+
+end
diff --git a/C/7zCrc.c b/C/7zCrc.c
index 71962b2c..a9208496 100755
--- a/C/7zCrc.c
+++ b/C/7zCrc.c
@@ -1,35 +1,74 @@
/* 7zCrc.c -- CRC32 calculation
-2008-08-05
-Igor Pavlov
-Public domain */
+2009-11-23 : Igor Pavlov : Public domain */
#include "7zCrc.h"
+#include "CpuArch.h"
#define kCrcPoly 0xEDB88320
-UInt32 g_CrcTable[256];
-void MY_FAST_CALL CrcGenerateTable(void)
+#ifdef MY_CPU_LE
+#define CRC_NUM_TABLES 8
+#else
+#define CRC_NUM_TABLES 1
+#endif
+
+typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table);
+
+static CRC_FUNC g_CrcUpdate;
+UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
+
+#if CRC_NUM_TABLES == 1
+
+#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
+
+static UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table)
{
- UInt32 i;
- for (i = 0; i < 256; i++)
- {
- UInt32 r = i;
- int j;
- for (j = 0; j < 8; j++)
- r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
- g_CrcTable[i] = r;
- }
+ const Byte *p = (const Byte *)data;
+ for (; size > 0; size--, p++)
+ v = CRC_UPDATE_BYTE_2(v, *p);
+ return v;
}
+#else
+
+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);
+
+#endif
+
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
{
- const Byte *p = (const Byte *)data;
- for (; size > 0 ; size--, p++)
- v = CRC_UPDATE_BYTE(v, *p);
- return v;
+ return g_CrcUpdate(v, data, size, g_CrcTable);
}
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
{
- return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF;
+ return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL;
+}
+
+void MY_FAST_CALL CrcGenerateTable()
+{
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = i;
+ unsigned j;
+ for (j = 0; j < 8; j++)
+ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
+ g_CrcTable[i] = r;
+ }
+ #if CRC_NUM_TABLES == 1
+ g_CrcUpdate = CrcUpdateT1;
+ #else
+ for (; i < 256 * CRC_NUM_TABLES; i++)
+ {
+ UInt32 r = g_CrcTable[i - 256];
+ g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
+ }
+ g_CrcUpdate = CrcUpdateT4;
+ #ifdef MY_CPU_X86_OR_AMD64
+ if (!CPU_Is_InOrder())
+ g_CrcUpdate = CrcUpdateT8;
+ #endif
+ #endif
}
diff --git a/C/7zCrc.h b/C/7zCrc.h
index e0d59d40..38e3e5fb 100755
--- a/C/7zCrc.h
+++ b/C/7zCrc.h
@@ -1,30 +1,25 @@
/* 7zCrc.h -- CRC32 calculation
-2009-02-07 : Igor Pavlov : Public domain */
+2009-11-21 : Igor Pavlov : Public domain */
#ifndef __7Z_CRC_H
#define __7Z_CRC_H
-#include <stddef.h>
-
#include "Types.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+EXTERN_C_BEGIN
extern UInt32 g_CrcTable[];
+/* Call CrcGenerateTable one time before other CRC functions */
void MY_FAST_CALL CrcGenerateTable(void);
#define CRC_INIT_VAL 0xFFFFFFFF
-#define CRC_GET_DIGEST(crc) ((crc) ^ 0xFFFFFFFF)
+#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);
-#ifdef __cplusplus
-}
-#endif
+EXTERN_C_END
#endif
diff --git a/C/7zCrcOpt.c b/C/7zCrcOpt.c
new file mode 100755
index 00000000..6c766a20
--- /dev/null
+++ b/C/7zCrcOpt.c
@@ -0,0 +1,34 @@
+/* 7zCrcOpt.c -- CRC32 calculation : optimized version
+2009-11-23 : Igor Pavlov : Public domain */
+
+#include "CpuArch.h"
+
+#ifdef MY_CPU_LE
+
+#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)
+{
+ 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 =
+ table[0x300 + (v & 0xFF)] ^
+ table[0x200 + ((v >> 8) & 0xFF)] ^
+ table[0x100 + ((v >> 16) & 0xFF)] ^
+ table[0x000 + ((v >> 24))];
+ }
+ for (; size > 0; size--, p++)
+ v = CRC_UPDATE_BYTE_2(v, *p);
+ return v;
+}
+
+UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table)
+{
+ return CrcUpdateT4(v, data, size, table);
+}
+
+#endif
diff --git a/C/7zCrcT8.c b/C/7zCrcT8.c
deleted file mode 100755
index cd80e262..00000000
--- a/C/7zCrcT8.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* 7zCrcT8.c -- CRC32 calculation with 8 tables
-2008-03-19
-Igor Pavlov
-Public domain */
-
-#include "7zCrc.h"
-
-#define kCrcPoly 0xEDB88320
-#define CRC_NUM_TABLES 8
-
-UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
-
-void MY_FAST_CALL CrcGenerateTable()
-{
- UInt32 i;
- for (i = 0; i < 256; i++)
- {
- UInt32 r = i;
- int j;
- for (j = 0; j < 8; j++)
- r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
- g_CrcTable[i] = r;
- }
- #if CRC_NUM_TABLES > 1
- for (; i < 256 * CRC_NUM_TABLES; i++)
- {
- UInt32 r = g_CrcTable[i - 256];
- g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
- }
- #endif
-}
-
-UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
-
-UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
-{
- return CrcUpdateT8(v, data, size, g_CrcTable);
-}
-
-UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
-{
- return CrcUpdateT8(CRC_INIT_VAL, data, size, g_CrcTable) ^ 0xFFFFFFFF;
-}
diff --git a/C/7zFile.c b/C/7zFile.c
index 299e0c47..a66c9e9d 100755
--- a/C/7zFile.c
+++ b/C/7zFile.c
@@ -1,15 +1,15 @@
/* 7zFile.c -- File IO
-2009-08-16 : Igor Pavlov : Public domain */
+2009-11-24 : Igor Pavlov : Public domain */
#include "7zFile.h"
#ifndef USE_WINDOWS_FILE
+#ifndef UNDER_CE
#include <errno.h>
-
#endif
-#ifdef USE_WINDOWS_FILE
+#else
/*
ReadFile and WriteFile functions in Windows have BUG:
@@ -34,6 +34,7 @@ void File_Construct(CSzFile *p)
#endif
}
+#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)
static WRes File_Open(CSzFile *p, const char *name, int writeMode)
{
#ifdef USE_WINDOWS_FILE
@@ -45,12 +46,18 @@ static WRes File_Open(CSzFile *p, const char *name, int writeMode)
return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError();
#else
p->file = fopen(name, writeMode ? "wb+" : "rb");
- return (p->file != 0) ? 0 : errno;
+ return (p->file != 0) ? 0 :
+ #ifdef UNDER_CE
+ 2; /* ENOENT */
+ #else
+ errno;
+ #endif
#endif
}
WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); }
WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); }
+#endif
#ifdef USE_WINDOWS_FILE
static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode)
diff --git a/C/7zFile.h b/C/7zFile.h
index 58ee9128..84538c03 100755
--- a/C/7zFile.h
+++ b/C/7zFile.h
@@ -1,5 +1,5 @@
/* 7zFile.h -- File IO
-2009-08-16 : Igor Pavlov : Public domain */
+2009-11-24 : Igor Pavlov : Public domain */
#ifndef __7Z_FILE_H
#define __7Z_FILE_H
@@ -30,8 +30,10 @@ typedef struct
} CSzFile;
void File_Construct(CSzFile *p);
+#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)
WRes InFile_Open(CSzFile *p, const char *name);
WRes OutFile_Open(CSzFile *p, const char *name);
+#endif
#ifdef USE_WINDOWS_FILE
WRes InFile_OpenW(CSzFile *p, const WCHAR *name);
WRes OutFile_OpenW(CSzFile *p, const WCHAR *name);
diff --git a/C/7zIn.c b/C/7zIn.c
index e687fbf2..90619777 100755
--- a/C/7zIn.c
+++ b/C/7zIn.c
@@ -1,5 +1,5 @@
/* 7zIn.c -- 7z Input functions
-2009-08-17 : Igor Pavlov : Public domain */
+2009-11-24 : Igor Pavlov : Public domain */
#include <string.h>
@@ -1021,6 +1021,7 @@ static SRes SzReadHeader2(
MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain);
memcpy(p->FileNames.data, sd->Data, namesSize);
RINOK(SzReadFileNames(sd->Data, namesSize >> 1, numFiles, p->FileNameOffsets))
+ RINOK(SzSkeepDataSize(sd, namesSize));
break;
}
case k7zIdEmptyStream:
diff --git a/C/7zVersion.h b/C/7zVersion.h
index 6ffef36c..ade65b5d 100755
--- a/C/7zVersion.h
+++ b/C/7zVersion.h
@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 9
-#define MY_VER_MINOR 07
+#define MY_VER_MINOR 9
#define MY_VER_BUILD 0
-#define MY_VERSION "9.07 beta"
-#define MY_DATE "2009-08-29"
+#define MY_VERSION "9.09 beta"
+#define MY_DATE "2009-12-12"
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
diff --git a/C/Aes.c b/C/Aes.c
index 669fef6e..e7221cd2 100755
--- a/C/Aes.c
+++ b/C/Aes.c
@@ -1,5 +1,5 @@
/* Aes.c -- AES encryption / decryption
-2009-06-10 : Igor Pavlov : Public domain */
+2009-11-23 : Igor Pavlov : Public domain */
#include "Aes.h"
#include "CpuArch.h"
@@ -23,6 +23,18 @@ static Byte Sbox[256] = {
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16};
+void MY_FAST_CALL AesCbc_Encode(UInt32 *ivAes, Byte *data, size_t numBlocks);
+void MY_FAST_CALL AesCbc_Decode(UInt32 *ivAes, Byte *data, size_t numBlocks);
+void MY_FAST_CALL AesCtr_Code(UInt32 *ivAes, Byte *data, size_t numBlocks);
+
+void MY_FAST_CALL AesCbc_Encode_Intel(UInt32 *ivAes, Byte *data, size_t numBlocks);
+void MY_FAST_CALL AesCbc_Decode_Intel(UInt32 *ivAes, Byte *data, size_t numBlocks);
+void MY_FAST_CALL AesCtr_Code_Intel(UInt32 *ivAes, Byte *data, size_t numBlocks);
+
+AES_CODE_FUNC g_AesCbc_Encode;
+AES_CODE_FUNC g_AesCbc_Decode;
+AES_CODE_FUNC g_AesCtr_Code;
+
static UInt32 D[256 * 4];
static Byte InvS[256];
@@ -68,6 +80,17 @@ void AesGenTables(void)
D[0x300 + i] = Ui32(a9, aD, aB, aE);
}
}
+ g_AesCbc_Encode = AesCbc_Encode;
+ g_AesCbc_Decode = AesCbc_Decode;
+ g_AesCtr_Code = AesCtr_Code;
+ #ifdef MY_CPU_X86_OR_AMD64
+ if (CPU_Is_Aes_Supported())
+ {
+ g_AesCbc_Encode = AesCbc_Encode_Intel;
+ g_AesCbc_Decode = AesCbc_Decode_Intel;
+ g_AesCtr_Code = AesCtr_Code_Intel;
+ }
+ #endif
}
#define HT(i, x, s) (T + (x << 8))[gb ## x(s[(i + x) & 3])]
@@ -102,15 +125,13 @@ void AesGenTables(void)
#define FD(i, x) InvS[gb ## x(m[(i - x) & 3])]
#define FD4(i) dest[i] = Ui32(FD(i, 0), FD(i, 1), FD(i, 2), FD(i, 3)) ^ w[i];
-void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize)
+void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *w, const Byte *key, unsigned keySize)
{
unsigned i, wSize;
- UInt32 *w;
+ wSize = keySize + 28;
keySize /= 4;
- p->numRounds2 = keySize / 2 + 3;
-
- wSize = (p->numRounds2 * 2 + 1) * 4;
- w = p->rkey;
+ w[0] = ((UInt32)keySize / 2) + 3;
+ w += 4;
for (i = 0; i < keySize; i++, key += 4)
w[i] = GetUi32(key);
@@ -127,13 +148,12 @@ void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize)
}
}
-void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize)
+void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *w, const Byte *key, unsigned keySize)
{
unsigned i, num;
- UInt32 *w;
- Aes_SetKeyEncode(p, key, keySize);
- num = p->numRounds2 * 8 - 4;
- w = p->rkey + 4;
+ Aes_SetKey_Enc(w, key, keySize);
+ num = keySize + 20;
+ w += 8;
for (i = 0; i < num; i++)
{
UInt32 r = w[i];
@@ -145,10 +165,16 @@ void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize)
}
}
-static void AesEncode32(UInt32 *dest, const UInt32 *src, const UInt32 *w, unsigned numRounds2)
+/* Aes_Encode and Aes_Decode functions work with little-endian words.
+ src and dest are pointers to 4 UInt32 words.
+ arc and dest can point to same block */
+
+static void Aes_Encode(const UInt32 *w, UInt32 *dest, const UInt32 *src)
{
UInt32 s[4];
UInt32 m[4];
+ UInt32 numRounds2 = w[0];
+ w += 4;
s[0] = src[0] ^ w[0];
s[1] = src[1] ^ w[1];
s[2] = src[2] ^ w[2];
@@ -166,11 +192,12 @@ static void AesEncode32(UInt32 *dest, const UInt32 *src, const UInt32 *w, unsign
FT4(0); FT4(1); FT4(2); FT4(3);
}
-static void AesDecode32(UInt32 *dest, const UInt32 *src, const UInt32 *w, unsigned numRounds2)
+static void Aes_Decode(const UInt32 *w, UInt32 *dest, const UInt32 *src)
{
UInt32 s[4];
UInt32 m[4];
- w += numRounds2 * 8;
+ UInt32 numRounds2 = w[0];
+ w += 4 + numRounds2 * 8;
s[0] = src[0] ^ w[0];
s[1] = src[1] ^ w[1];
s[2] = src[2] ^ w[2];
@@ -186,75 +213,70 @@ static void AesDecode32(UInt32 *dest, const UInt32 *src, const UInt32 *w, unsign
FD4(0); FD4(1); FD4(2); FD4(3);
}
-void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src)
-{
- AesEncode32(dest, src, p->rkey, p->numRounds2);
-}
-
-void Aes_Decode32(const CAes *p, UInt32 *dest, const UInt32 *src)
-{
- AesDecode32(dest, src, p->rkey, p->numRounds2);
-}
-
-void AesCbc_Init(CAesCbc *p, const Byte *iv)
+void AesCbc_Init(UInt32 *p, const Byte *iv)
{
unsigned i;
for (i = 0; i < 4; i++)
- p->prev[i] = GetUi32(iv + i * 4);
+ p[i] = GetUi32(iv + i * 4);
}
-SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size)
+void MY_FAST_CALL AesCbc_Encode(UInt32 *p, Byte *data, size_t numBlocks)
{
- SizeT i;
- if (size == 0)
- return 0;
- if (size < AES_BLOCK_SIZE)
- return AES_BLOCK_SIZE;
- size -= AES_BLOCK_SIZE;
- for (i = 0; i <= size; i += AES_BLOCK_SIZE, data += AES_BLOCK_SIZE)
+ for (; numBlocks != 0; numBlocks--, data += AES_BLOCK_SIZE)
{
- p->prev[0] ^= GetUi32(data);
- p->prev[1] ^= GetUi32(data + 4);
- p->prev[2] ^= GetUi32(data + 8);
- p->prev[3] ^= GetUi32(data + 12);
+ p[0] ^= GetUi32(data);
+ p[1] ^= GetUi32(data + 4);
+ p[2] ^= GetUi32(data + 8);
+ p[3] ^= GetUi32(data + 12);
- AesEncode32(p->prev, p->prev, p->aes.rkey, p->aes.numRounds2);
+ Aes_Encode(p + 4, p, p);
- SetUi32(data, p->prev[0]);
- SetUi32(data + 4, p->prev[1]);
- SetUi32(data + 8, p->prev[2]);
- SetUi32(data + 12, p->prev[3]);
+ SetUi32(data, p[0]);
+ SetUi32(data + 4, p[1]);
+ SetUi32(data + 8, p[2]);
+ SetUi32(data + 12, p[3]);
}
- return i;
}
-SizeT AesCbc_Decode(CAesCbc *p, Byte *data, SizeT size)
+void MY_FAST_CALL AesCbc_Decode(UInt32 *p, Byte *data, size_t numBlocks)
{
- SizeT i;
UInt32 in[4], out[4];
- if (size == 0)
- return 0;
- if (size < AES_BLOCK_SIZE)
- return AES_BLOCK_SIZE;
- size -= AES_BLOCK_SIZE;
- for (i = 0; i <= size; i += AES_BLOCK_SIZE, data += AES_BLOCK_SIZE)
+ for (; numBlocks != 0; numBlocks--, data += AES_BLOCK_SIZE)
{
in[0] = GetUi32(data);
in[1] = GetUi32(data + 4);
in[2] = GetUi32(data + 8);
in[3] = GetUi32(data + 12);
+
+ Aes_Decode(p + 4, out, in);
+
+ SetUi32(data, p[0] ^ out[0]);
+ SetUi32(data + 4, p[1] ^ out[1]);
+ SetUi32(data + 8, p[2] ^ out[2]);
+ SetUi32(data + 12, p[3] ^ out[3]);
- AesDecode32(out, in, p->aes.rkey, p->aes.numRounds2);
-
- SetUi32(data, p->prev[0] ^ out[0]);
- SetUi32(data + 4, p->prev[1] ^ out[1]);
- SetUi32(data + 8, p->prev[2] ^ out[2]);
- SetUi32(data + 12, p->prev[3] ^ out[3]);
-
- p->prev[0] = in[0];
- p->prev[1] = in[1];
- p->prev[2] = in[2];
- p->prev[3] = in[3];
+ p[0] = in[0];
+ p[1] = in[1];
+ p[2] = in[2];
+ p[3] = in[3];
+ }
+}
+
+void MY_FAST_CALL AesCtr_Code(UInt32 *p, Byte *data, size_t numBlocks)
+{
+ for (; numBlocks != 0; numBlocks--)
+ {
+ UInt32 temp[4];
+ Byte buf[16];
+ int i;
+ if (++p[0] == 0)
+ p[1]++;
+ Aes_Encode(p + 4, temp, p);
+ SetUi32(buf, temp[0]);
+ SetUi32(buf + 4, temp[1]);
+ SetUi32(buf + 8, temp[2]);
+ SetUi32(buf + 12, temp[3]);
+ for (i = 0; i < 16; i++)
+ *data++ ^= buf[i];
}
- return i;
}
diff --git a/C/Aes.h b/C/Aes.h
index 5aa60955..c9b0677c 100755
--- a/C/Aes.h
+++ b/C/Aes.h
@@ -1,54 +1,38 @@
/* Aes.h -- AES encryption / decryption
-2009-02-07 : Igor Pavlov : Public domain */
+2009-11-23 : Igor Pavlov : Public domain */
#ifndef __AES_H
#define __AES_H
#include "Types.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+EXTERN_C_BEGIN
#define AES_BLOCK_SIZE 16
-typedef struct
-{
- unsigned numRounds2; /* = numRounds / 2 */
- UInt32 rkey[(14 + 1) * 4];
-} CAes;
-
/* Call AesGenTables one time before other AES functions */
void AesGenTables(void);
-/* keySize = 16 or 24 or 32 (bytes) */
-void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize);
-void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize);
-
-/* Aes_Encode32 and Aes_Decode32 functions work with little-endian words.
- src and dest are pointers to 4 UInt32 words.
- arc and dest can point to same block */
-void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src);
-void Aes_Decode32(const CAes *p, UInt32 *dest, const UInt32 *src);
-
-typedef struct
-{
- UInt32 prev[4];
- CAes aes;
-} CAesCbc;
+/* UInt32 pointers must be 16-byte aligned */
-void AesCbc_Init(CAesCbc *p, const Byte *iv); /* iv size is AES_BLOCK_SIZE */
+/* 16-byte (4 * 32-bit words) blocks: 1 (IV) + 1 (keyMode) + 15 (AES-256 roundKeys) */
+#define AES_NUM_IVMRK_WORDS ((1 + 1 + 15) * 4)
-/* AesCbc_Encode and AesCbc_Decode:
- if (res <= size): Filter have converted res bytes
- if (res > size): Filter have not converted anything. And it needs at
- least res = AES_BLOCK_SIZE bytes to convert one block */
-
-SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size);
-SizeT AesCbc_Decode(CAesCbc *p, Byte *data, SizeT size);
-
-#ifdef __cplusplus
-}
-#endif
+/* aes - 16-byte aligned pointer to keyMode+roundKeys sequence */
+/* keySize = 16 or 24 or 32 (bytes) */
+typedef void (MY_FAST_CALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize);
+void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize);
+void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *aes, const Byte *key, unsigned keySize);
+
+/* ivAes - 16-byte aligned pointer to iv+keyMode+roundKeys sequence: UInt32[AES_NUM_IVMRK_WORDS] */
+void AesCbc_Init(UInt32 *ivAes, const Byte *iv); /* iv size is AES_BLOCK_SIZE */
+/* data - 16-byte aligned pointer to data */
+/* numBlocks - the number of 16-byte blocks in data array */
+typedef void (MY_FAST_CALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks);
+extern AES_CODE_FUNC g_AesCbc_Encode;
+extern AES_CODE_FUNC g_AesCbc_Decode;
+extern AES_CODE_FUNC g_AesCtr_Code;
+
+EXTERN_C_END
#endif
diff --git a/C/AesOpt.c b/C/AesOpt.c
new file mode 100755
index 00000000..60cfd86d
--- /dev/null
+++ b/C/AesOpt.c
@@ -0,0 +1,182 @@
+/* AesOpt.c -- Intel's AES
+2009-11-23 : Igor Pavlov : Public domain */
+
+#include "CpuArch.h"
+
+#ifdef MY_CPU_X86_OR_AMD64
+#if _MSC_VER >= 1500
+#define USE_INTEL_AES
+#endif
+#endif
+
+#ifdef USE_INTEL_AES
+
+#include <wmmintrin.h>
+
+void MY_FAST_CALL AesCbc_Encode_Intel(__m128i *p, __m128i *data, size_t numBlocks)
+{
+ __m128i m = *p;
+ for (; numBlocks != 0; numBlocks--, data++)
+ {
+ UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1;
+ const __m128i *w = p + 3;
+ m = _mm_xor_si128(m, *data);
+ m = _mm_xor_si128(m, p[2]);
+ do
+ {
+ m = _mm_aesenc_si128(m, w[0]);
+ m = _mm_aesenc_si128(m, w[1]);
+ w += 2;
+ }
+ while (--numRounds2 != 0);
+ m = _mm_aesenc_si128(m, w[0]);
+ m = _mm_aesenclast_si128(m, w[1]);
+ *data = m;
+ }
+ *p = m;
+}
+
+#define NUM_WAYS 3
+
+#define AES_OP_W(op, n) { \
+ const __m128i t = w[n]; \
+ m0 = op(m0, t); \
+ m1 = op(m1, t); \
+ m2 = op(m2, t); \
+ }
+
+#define AES_DEC(n) AES_OP_W(_mm_aesdec_si128, n)
+#define AES_DEC_LAST(n) AES_OP_W(_mm_aesdeclast_si128, n)
+#define AES_ENC(n) AES_OP_W(_mm_aesenc_si128, n)
+#define AES_ENC_LAST(n) AES_OP_W(_mm_aesenclast_si128, n)
+
+void MY_FAST_CALL AesCbc_Decode_Intel(__m128i *p, __m128i *data, size_t numBlocks)
+{
+ __m128i iv = *p;
+ for (; numBlocks >= NUM_WAYS; numBlocks -= NUM_WAYS, data += NUM_WAYS)
+ {
+ UInt32 numRounds2 = *(const UInt32 *)(p + 1);
+ const __m128i *w = p + numRounds2 * 2;
+ __m128i m0, m1, m2;
+ {
+ const __m128i t = w[2];
+ m0 = _mm_xor_si128(t, data[0]);
+ m1 = _mm_xor_si128(t, data[1]);
+ m2 = _mm_xor_si128(t, data[2]);
+ }
+ numRounds2--;
+ do
+ {
+ AES_DEC(1)
+ AES_DEC(0)
+ w -= 2;
+ }
+ while (--numRounds2 != 0);
+ AES_DEC(1)
+ AES_DEC_LAST(0)
+
+ {
+ __m128i t;
+ t = _mm_xor_si128(m0, iv); iv = data[0]; data[0] = t;
+ t = _mm_xor_si128(m1, iv); iv = data[1]; data[1] = t;
+ t = _mm_xor_si128(m2, iv); iv = data[2]; data[2] = t;
+ }
+ }
+ for (; numBlocks != 0; numBlocks--, data++)
+ {
+ UInt32 numRounds2 = *(const UInt32 *)(p + 1);
+ const __m128i *w = p + numRounds2 * 2;
+ __m128i m = _mm_xor_si128(w[2], *data);
+ numRounds2--;
+ do
+ {
+ m = _mm_aesdec_si128(m, w[1]);
+ m = _mm_aesdec_si128(m, w[0]);
+ w -= 2;
+ }
+ while (--numRounds2 != 0);
+ m = _mm_aesdec_si128(m, w[1]);
+ m = _mm_aesdeclast_si128(m, w[0]);
+
+ m = _mm_xor_si128(m, iv);
+ iv = *data;
+ *data = m;
+ }
+ *p = iv;
+}
+
+void MY_FAST_CALL AesCtr_Code_Intel(__m128i *p, __m128i *data, size_t numBlocks)
+{
+ __m128i ctr = *p;
+ __m128i one;
+ one.m128i_u64[0] = 1;
+ one.m128i_u64[1] = 0;
+ for (; numBlocks >= NUM_WAYS; numBlocks -= NUM_WAYS, data += NUM_WAYS)
+ {
+ UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1;
+ const __m128i *w = p;
+ __m128i m0, m1, m2;
+ {
+ const __m128i t = w[2];
+ ctr = _mm_add_epi64(ctr, one); m0 = _mm_xor_si128(ctr, t);
+ ctr = _mm_add_epi64(ctr, one); m1 = _mm_xor_si128(ctr, t);
+ ctr = _mm_add_epi64(ctr, one); m2 = _mm_xor_si128(ctr, t);
+ }
+ w += 3;
+ do
+ {
+ AES_ENC(0)
+ AES_ENC(1)
+ w += 2;
+ }
+ while (--numRounds2 != 0);
+ AES_ENC(0)
+ AES_ENC_LAST(1)
+ data[0] = _mm_xor_si128(data[0], m0);
+ data[1] = _mm_xor_si128(data[1], m1);
+ data[2] = _mm_xor_si128(data[2], m2);
+ }
+ for (; numBlocks != 0; numBlocks--, data++)
+ {
+ UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1;
+ const __m128i *w = p;
+ __m128i m;
+ ctr = _mm_add_epi64(ctr, one);
+ m = _mm_xor_si128(ctr, p[2]);
+ w += 3;
+ do
+ {
+ m = _mm_aesenc_si128(m, w[0]);
+ m = _mm_aesenc_si128(m, w[1]);
+ w += 2;
+ }
+ while (--numRounds2 != 0);
+ m = _mm_aesenc_si128(m, w[0]);
+ m = _mm_aesenclast_si128(m, w[1]);
+ *data = _mm_xor_si128(*data, m);
+ }
+ *p = ctr;
+}
+
+#else
+
+void MY_FAST_CALL AesCbc_Encode(UInt32 *ivAes, Byte *data, size_t numBlocks);
+void MY_FAST_CALL AesCbc_Decode(UInt32 *ivAes, Byte *data, size_t numBlocks);
+void MY_FAST_CALL AesCtr_Code(UInt32 *ivAes, Byte *data, size_t numBlocks);
+
+void MY_FAST_CALL AesCbc_Encode_Intel(UInt32 *p, Byte *data, size_t numBlocks)
+{
+ AesCbc_Encode(p, data, numBlocks);
+}
+
+void MY_FAST_CALL AesCbc_Decode_Intel(UInt32 *p, Byte *data, size_t numBlocks)
+{
+ AesCbc_Decode(p, data, numBlocks);
+}
+
+void MY_FAST_CALL AesCtr_Code_Intel(UInt32 *p, Byte *data, size_t numBlocks)
+{
+ AesCtr_Code(p, data, numBlocks);
+}
+
+#endif
diff --git a/C/CpuArch.c b/C/CpuArch.c
new file mode 100755
index 00000000..5298e006
--- /dev/null
+++ b/C/CpuArch.c
@@ -0,0 +1,168 @@
+/* CpuArch.c -- CPU specific code
+2009-12-12: Igor Pavlov : Public domain */
+
+#include "CpuArch.h"
+
+#ifdef MY_CPU_X86_OR_AMD64
+
+#if (defined(_MSC_VER) && !defined(MY_CPU_AMD64)) || defined(__GNUC__)
+#define USE_ASM
+#endif
+
+#if defined(USE_ASM) && !defined(MY_CPU_AMD64)
+static UInt32 CheckFlag(UInt32 flag)
+{
+ #ifdef _MSC_VER
+ __asm pushfd;
+ __asm pop EAX;
+ __asm mov EDX, EAX;
+ __asm xor EAX, flag;
+ __asm push EAX;
+ __asm popfd;
+ __asm pushfd;
+ __asm pop EAX;
+ __asm xor EAX, EDX;
+ __asm push EDX;
+ __asm popfd;
+ __asm and flag, EAX;
+ #else
+ __asm__ __volatile__ (
+ "pushf\n\t"
+ "pop %%EAX\n\t"
+ "movl %%EAX,%%EDX\n\t"
+ "xorl %0,%%EAX\n\t"
+ "push %%EAX\n\t"
+ "popf\n\t"
+ "pushf\n\t"
+ "pop %%EAX\n\t"
+ "xorl %%EDX,%%EAX\n\t"
+ "push %%EDX\n\t"
+ "popf\n\t"
+ "andl %%EAX, %0\n\t":
+ "=c" (flag) : "c" (flag));
+ #endif
+ return flag;
+}
+#define CHECK_CPUID_IS_SUPPORTED if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) return False;
+#else
+#define CHECK_CPUID_IS_SUPPORTED
+#endif
+
+static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
+{
+ #ifdef USE_ASM
+
+ #ifdef _MSC_VER
+
+ UInt32 a2, b2, c2, d2;
+ __asm xor EBX, EBX;
+ __asm xor ECX, ECX;
+ __asm xor EDX, EDX;
+ __asm mov EAX, function;
+ __asm cpuid;
+ __asm mov a2, EAX;
+ __asm mov b2, EBX;
+ __asm mov c2, ECX;
+ __asm mov d2, EDX;
+
+ *a = a2;
+ *b = b2;
+ *c = c2;
+ *d = d2;
+
+ #else
+
+ __asm__ __volatile__ (
+ "cpuid"
+ : "=a" (*a) ,
+ "=b" (*b) ,
+ "=c" (*c) ,
+ "=d" (*d)
+ : "0" (function)) ;
+
+ #endif
+
+ #else
+
+ int CPUInfo[4];
+ __cpuid(CPUInfo, function);
+ *a = CPUInfo[0];
+ *b = CPUInfo[1];
+ *c = CPUInfo[2];
+ *d = CPUInfo[3];
+
+ #endif
+}
+
+Bool x86cpuid_CheckAndRead(Cx86cpuid *p)
+{
+ CHECK_CPUID_IS_SUPPORTED
+ MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]);
+ MyCPUID(1, &p->ver, &p->b, &p->c, &p->d);
+ return True;
+}
+
+static UInt32 kVendors[][3] =
+{
+ { 0x756E6547, 0x49656E69, 0x6C65746E},
+ { 0x68747541, 0x69746E65, 0x444D4163},
+ { 0x746E6543, 0x48727561, 0x736C7561}
+};
+
+int x86cpuid_GetFirm(const Cx86cpuid *p)
+{
+ unsigned i;
+ for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++)
+ {
+ const UInt32 *v = kVendors[i];
+ if (v[0] == p->vendor[0] &&
+ v[1] == p->vendor[1] &&
+ v[2] == p->vendor[2])
+ return (int)i;
+ }
+ return -1;
+}
+
+Bool CPU_Is_InOrder()
+{
+ Cx86cpuid p;
+ int firm;
+ UInt32 family, model;
+ if (!x86cpuid_CheckAndRead(&p))
+ return True;
+ family = x86cpuid_GetFamily(&p);
+ model = x86cpuid_GetModel(&p);
+ firm = x86cpuid_GetFirm(&p);
+ switch (firm)
+ {
+ case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && model == 0x100C));
+ case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA)));
+ case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF));
+ }
+ return True;
+}
+
+#if !defined(MY_CPU_AMD64) && defined(_WIN32)
+static Bool CPU_Sys_Is_SSE_Supported()
+{
+ OSVERSIONINFO vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (!GetVersionEx(&vi))
+ return False;
+ return (vi.dwMajorVersion >= 5);
+}
+#define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False;
+#else
+#define CHECK_SYS_SSE_SUPPORT
+#endif
+
+Bool CPU_Is_Aes_Supported()
+{
+ Cx86cpuid p;
+ CHECK_SYS_SSE_SUPPORT
+ if (!x86cpuid_CheckAndRead(&p))
+ return False;
+ return (p.c >> 25) & 1;
+}
+
+#endif
diff --git a/C/CpuArch.h b/C/CpuArch.h
index 13f53dd9..b32142fe 100755
--- a/C/CpuArch.h
+++ b/C/CpuArch.h
@@ -1,19 +1,19 @@
-/* CpuArch.h
-2009-08-11 : Igor Pavlov : Public domain */
+/* CpuArch.h -- CPU specific code
+2009-11-25: Igor Pavlov : Public domain */
#ifndef __CPU_ARCH_H
#define __CPU_ARCH_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "Types.h"
+
+EXTERN_C_BEGIN
/*
-LITTLE_ENDIAN_UNALIGN means:
- 1) CPU is LITTLE_ENDIAN
- 2) it's allowed to make unaligned memory accesses
-if LITTLE_ENDIAN_UNALIGN is not defined, it means that we don't know
-about these properties of platform.
+MY_CPU_LE means that CPU is LITTLE ENDIAN.
+If MY_CPU_LE is not defined, we don't know about that property of platform (it can be LITTLE ENDIAN).
+
+MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.
+If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform.
*/
#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__)
@@ -28,11 +28,19 @@ about these properties of platform.
#define MY_CPU_X86_OR_AMD64
#endif
+#if defined(_WIN32) && defined(_M_ARM)
+#define MY_CPU_ARM_LE
+#endif
+
#if defined(MY_CPU_X86_OR_AMD64)
-#define LITTLE_ENDIAN_UNALIGN
+#define MY_CPU_LE_UNALIGN
+#endif
+
+#if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE)
+#define MY_CPU_LE
#endif
-#ifdef LITTLE_ENDIAN_UNALIGN
+#ifdef MY_CPU_LE_UNALIGN
#define GetUi16(p) (*(const UInt16 *)(p))
#define GetUi32(p) (*(const UInt32 *)(p))
@@ -64,7 +72,7 @@ about these properties of platform.
#endif
-#if defined(LITTLE_ENDIAN_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
+#if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
#pragma intrinsic(_byteswap_ulong)
#pragma intrinsic(_byteswap_uint64)
@@ -85,8 +93,38 @@ about these properties of platform.
#define GetBe16(p) (((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1])
-#ifdef __cplusplus
-}
+
+#ifdef MY_CPU_X86_OR_AMD64
+
+typedef struct
+{
+ UInt32 maxFunc;
+ UInt32 vendor[3];
+ UInt32 ver;
+ UInt32 b;
+ UInt32 c;
+ UInt32 d;
+} Cx86cpuid;
+
+enum
+{
+ CPU_FIRM_INTEL,
+ CPU_FIRM_AMD,
+ CPU_FIRM_VIA
+};
+
+Bool x86cpuid_CheckAndRead(Cx86cpuid *p);
+int x86cpuid_GetFirm(const Cx86cpuid *p);
+
+#define x86cpuid_GetFamily(p) (((p)->ver >> 8) & 0xFF00F)
+#define x86cpuid_GetModel(p) (((p)->ver >> 4) & 0xF00F)
+#define x86cpuid_GetStepping(p) ((p)->ver & 0xF)
+
+Bool CPU_Is_InOrder();
+Bool CPU_Is_Aes_Supported();
+
#endif
+EXTERN_C_END
+
#endif
diff --git a/C/HuffEnc.c b/C/HuffEnc.c
index 6e58d2ce..561c7e5d 100755
--- a/C/HuffEnc.c
+++ b/C/HuffEnc.c
@@ -1,7 +1,5 @@
/* HuffEnc.c -- functions for Huffman encoding
-2008-08-05
-Igor Pavlov
-Public domain */
+2009-09-02 : Igor Pavlov : Public domain */
#include "HuffEnc.h"
#include "Sort.h"
@@ -67,11 +65,11 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
if (num < 2)
{
- int minCode = 0;
- int maxCode = 1;
+ unsigned minCode = 0;
+ unsigned maxCode = 1;
if (num == 1)
{
- maxCode = (int)(p[0] & MASK);
+ maxCode = (unsigned)p[0] & MASK;
if (maxCode == 0)
maxCode++;
}
diff --git a/C/LzFindMt.c b/C/LzFindMt.c
index 5c23f8ea..aa41ed98 100755
--- a/C/LzFindMt.c
+++ b/C/LzFindMt.c
@@ -1,5 +1,5 @@
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
-2009-05-26 : Igor Pavlov : Public domain */
+2009-09-20 : Igor Pavlov : Public domain */
#include "LzHash.h"
@@ -711,47 +711,47 @@ UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *distances)
return len;
}
-#define SKIP_HEADER2 do { GET_NEXT_BLOCK_IF_REQUIRED
-#define SKIP_HEADER(n) SKIP_HEADER2 if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash;
-#define SKIP_FOOTER } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while (--num != 0);
+#define SKIP_HEADER2_MT do { GET_NEXT_BLOCK_IF_REQUIRED
+#define SKIP_HEADER_MT(n) SKIP_HEADER2_MT if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash;
+#define SKIP_FOOTER_MT } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while (--num != 0);
void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num)
{
- SKIP_HEADER2 { p->btNumAvailBytes--;
- SKIP_FOOTER
+ SKIP_HEADER2_MT { p->btNumAvailBytes--;
+ SKIP_FOOTER_MT
}
void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num)
{
- SKIP_HEADER(2)
+ SKIP_HEADER_MT(2)
UInt32 hash2Value;
MT_HASH2_CALC
hash[hash2Value] = p->lzPos;
- SKIP_FOOTER
+ SKIP_FOOTER_MT
}
void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num)
{
- SKIP_HEADER(3)
+ SKIP_HEADER_MT(3)
UInt32 hash2Value, hash3Value;
MT_HASH3_CALC
hash[kFix3HashSize + hash3Value] =
hash[ hash2Value] =
p->lzPos;
- SKIP_FOOTER
+ SKIP_FOOTER_MT
}
/*
void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num)
{
- SKIP_HEADER(4)
+ SKIP_HEADER_MT(4)
UInt32 hash2Value, hash3Value, hash4Value;
MT_HASH4_CALC
hash[kFix4HashSize + hash4Value] =
hash[kFix3HashSize + hash3Value] =
hash[ hash2Value] =
p->lzPos;
- SKIP_FOOTER
+ SKIP_FOOTER_MT
}
*/
diff --git a/C/Lzma2Enc.c b/C/Lzma2Enc.c
index afccd4da..55c05fb5 100755
--- a/C/Lzma2Enc.c
+++ b/C/Lzma2Enc.c
@@ -1,14 +1,14 @@
/* Lzma2Enc.c -- LZMA2 Encoder
-2009-05-26 : Igor Pavlov : Public domain */
+2009-11-24 : Igor Pavlov : Public domain */
/* #include <stdio.h> */
#include <string.h>
-#include "Lzma2Enc.h"
+/* #define _7ZIP_ST */
-/* #define COMPRESS_MT */
+#include "Lzma2Enc.h"
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
#include "MtCoder.h"
#else
#define NUM_MT_CODER_THREADS_MAX 1
@@ -195,7 +195,7 @@ typedef struct _CLzma2Enc
CLzma2EncInt coders[NUM_MT_CODER_THREADS_MAX];
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
CMtCoder mtCoder;
#endif
@@ -242,7 +242,7 @@ static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
return res;
}
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
typedef struct
{
@@ -322,7 +322,7 @@ CLzma2EncHandle Lzma2Enc_Create(ISzAlloc *alloc, ISzAlloc *allocBig)
for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
p->coders[i].enc = 0;
}
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
MtCoder_Construct(&p->mtCoder);
#endif
@@ -343,7 +343,7 @@ void Lzma2Enc_Destroy(CLzma2EncHandle pp)
}
}
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
MtCoder_Destruct(&p->mtCoder);
#endif
@@ -363,7 +363,7 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
t2 = p->numBlockThreads;
t3 = p->numTotalThreads;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
if (t2 > NUM_MT_CODER_THREADS_MAX)
t2 = NUM_MT_CODER_THREADS_MAX;
#else
@@ -455,12 +455,12 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
}
}
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
if (p->props.numBlockThreads <= 1)
#endif
return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
{
CMtCallbackImp mtCallback;
diff --git a/C/LzmaDec.c b/C/LzmaDec.c
index d87eb191..2036761b 100755
--- a/C/LzmaDec.c
+++ b/C/LzmaDec.c
@@ -1,5 +1,5 @@
/* LzmaDec.c -- LZMA Decoder
-2008-11-06 : Igor Pavlov : Public domain */
+2009-09-20 : Igor Pavlov : Public domain */
#include "LzmaDec.h"
@@ -113,12 +113,6 @@
StopCompilingDueBUG
#endif
-static const Byte kLiteralNextStates[kNumStates * 2] =
-{
- 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5,
- 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10
-};
-
#define LZMA_DIC_MIN (1 << 12)
/* First LZMA-symbol is always decoded.
@@ -175,6 +169,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
if (state < kNumLitStates)
{
+ state -= (state < 4) ? state : 3;
symbol = 1;
do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
}
@@ -182,6 +177,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
{
unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
unsigned offs = 0x100;
+ state -= (state < 10) ? 3 : 6;
symbol = 1;
do
{
@@ -196,9 +192,6 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
}
dic[dicPos++] = (Byte)symbol;
processedPos++;
-
- state = kLiteralNextStates[state];
- /* if (state < 4) state = 0; else if (state < 10) state -= 3; else state -= 6; */
continue;
}
else
@@ -378,7 +371,6 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
else if (distance >= checkDicSize)
return SZ_ERROR_DATA;
state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
- /* state = kLiteralNextStates[state]; */
}
len += kMatchMinLen;
diff --git a/C/LzmaEnc.c b/C/LzmaEnc.c
index 20ad727f..169d4f46 100755
--- a/C/LzmaEnc.c
+++ b/C/LzmaEnc.c
@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder
-2009-04-22 : Igor Pavlov : Public domain */
+2009-11-24 : Igor Pavlov : Public domain */
#include <string.h>
@@ -13,7 +13,7 @@
#include "LzmaEnc.h"
#include "LzFind.h"
-#ifdef COMPRESS_MF_MT
+#ifndef _7ZIP_ST
#include "LzFindMt.h"
#endif
@@ -66,7 +66,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1);
if (p->numThreads < 0)
p->numThreads =
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
((p->btMode && p->algo) ? 2 : 1);
#else
1;
@@ -172,7 +172,7 @@ typedef struct
#define kEndPosModelIndex 14
#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex)
-#define kNumFullDistances (1 << (kEndPosModelIndex / 2))
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
#ifdef _LZMA_PROB32
#define CLzmaProb UInt32
@@ -259,14 +259,14 @@ typedef struct
IMatchFinder matchFinder;
void *matchFinderObj;
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
Bool mtMode;
CMatchFinderMt matchFinderMt;
#endif
CMatchFinder matchFinderBase;
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
Byte pad[128];
#endif
@@ -428,7 +428,7 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
p->writeEndMark = props.writeEndMark;
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
/*
if (newMultiThread != _multiThread)
{
@@ -1677,7 +1677,7 @@ void LzmaEnc_Construct(CLzmaEnc *p)
{
RangeEnc_Construct(&p->rc);
MatchFinder_Construct(&p->matchFinderBase);
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
MatchFinderMt_Construct(&p->matchFinderMt);
p->matchFinderMt.MatchFinder = &p->matchFinderBase;
#endif
@@ -1716,7 +1716,7 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
{
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
#endif
MatchFinder_Free(&p->matchFinderBase, allocBig);
@@ -1901,7 +1901,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, I
if (!RangeEnc_Alloc(&p->rc, alloc))
return SZ_ERROR_MEM;
btMode = (p->matchFinderBase.btMode != 0);
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
p->mtMode = (p->multiThread && !p->fastMode && btMode);
#endif
@@ -1926,7 +1926,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, I
if (beforeSize + p->dictSize < keepWindowSize)
beforeSize = keepWindowSize - p->dictSize;
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
if (p->mtMode)
{
RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig));
@@ -2073,7 +2073,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
void LzmaEnc_Finish(CLzmaEncHandle pp)
{
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
CLzmaEnc *p = (CLzmaEnc *)pp;
if (p->mtMode)
MatchFinderMt_ReleaseStream(&p->matchFinderMt);
@@ -2155,7 +2155,7 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
{
SRes res = SZ_OK;
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
Byte allocaDummy[0x300];
int i = 0;
for (i = 0; i < 16; i++)
diff --git a/C/MtCoder.h b/C/MtCoder.h
index fb813d4d..f0f06da2 100755
--- a/C/MtCoder.h
+++ b/C/MtCoder.h
@@ -1,14 +1,12 @@
/* MtCoder.h -- Multi-thread Coder
-2009-03-26 : Igor Pavlov : Public domain */
+2009-11-19 : Igor Pavlov : Public domain */
#ifndef __MT_CODER_H
#define __MT_CODER_H
#include "Threads.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+EXTERN_C_BEGIN
typedef struct
{
@@ -29,7 +27,7 @@ WRes LoopThread_StopAndWait(CLoopThread *p);
WRes LoopThread_StartSubThread(CLoopThread *p);
WRes LoopThread_WaitSubThread(CLoopThread *p);
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
#define NUM_MT_CODER_THREADS_MAX 32
#else
#define NUM_MT_CODER_THREADS_MAX 1
@@ -95,8 +93,6 @@ void MtCoder_Construct(CMtCoder* p);
void MtCoder_Destruct(CMtCoder* p);
SRes MtCoder_Code(CMtCoder *p);
-#ifdef __cplusplus
-}
-#endif
+EXTERN_C_END
#endif
diff --git a/C/Threads.c b/C/Threads.c
index 212032aa..7af1da2e 100755
--- a/C/Threads.c
+++ b/C/Threads.c
@@ -1,5 +1,5 @@
/* Threads.c -- multithreading library
-2009-07-20 : Igor Pavlov : Public domain */
+2009-09-20 : Igor Pavlov : Public domain */
#ifndef _WIN32_WCE
#include <process.h>
@@ -70,11 +70,15 @@ WRes Semaphore_Release1(CSemaphore *p) { return Semaphore_ReleaseN(p, 1); }
WRes CriticalSection_Init(CCriticalSection *p)
{
/* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */
+ #ifdef _MSC_VER
__try
+ #endif
{
InitializeCriticalSection(p);
/* InitializeCriticalSectionAndSpinCount(p, 0); */
}
+ #ifdef _MSC_VER
__except (EXCEPTION_EXECUTE_HANDLER) { return 1; }
+ #endif
return 0;
}
diff --git a/C/Types.h b/C/Types.h
index 04580915..4751acde 100755
--- a/C/Types.h
+++ b/C/Types.h
@@ -1,5 +1,5 @@
/* Types.h -- Basic types
-2009-08-14 : Igor Pavlov : Public domain */
+2009-11-23 : Igor Pavlov : Public domain */
#ifndef __7Z_TYPES_H
#define __7Z_TYPES_H
@@ -95,6 +95,12 @@ typedef int Bool;
#define False 0
+#ifdef _WIN32
+#define MY_STD_CALL __stdcall
+#else
+#define MY_STD_CALL
+#endif
+
#ifdef _MSC_VER
#if _MSC_VER >= 1300
@@ -104,13 +110,11 @@ typedef int Bool;
#endif
#define MY_CDECL __cdecl
-#define MY_STD_CALL __stdcall
-#define MY_FAST_CALL MY_NO_INLINE __fastcall
+#define MY_FAST_CALL __fastcall
#else
#define MY_CDECL
-#define MY_STD_CALL
#define MY_FAST_CALL
#endif
diff --git a/C/Util/7z/7z.dsp b/C/Util/7z/7z.dsp
index 491f3c94..1b185b6f 100755
--- a/C/Util/7z/7z.dsp
+++ b/C/Util/7z/7z.dsp
@@ -88,6 +88,10 @@ LINK32=link.exe
# PROP Default_Filter ""
# Begin Source File
+SOURCE=..\..\7z.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\7zBuf.c
# End Source File
# Begin Source File
@@ -104,6 +108,14 @@ SOURCE=..\..\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\7zCrcOpt.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\7zDec.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\7zFile.c
# End Source File
# Begin Source File
@@ -112,6 +124,10 @@ SOURCE=..\..\7zFile.h
# End Source File
# Begin Source File
+SOURCE=..\..\7zIn.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\7zStream.c
# End Source File
# Begin Source File
@@ -132,6 +148,10 @@ SOURCE=..\..\Bra86.c
# End Source File
# Begin Source File
+SOURCE=..\..\CpuArch.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\CpuArch.h
# End Source File
# Begin Source File
@@ -157,10 +177,6 @@ SOURCE=..\..\Types.h
# End Group
# Begin Source File
-SOURCE=..\..\7z.h
-# End Source File
-# Begin Source File
-
SOURCE=.\7zAlloc.c
# End Source File
# Begin Source File
@@ -169,14 +185,6 @@ SOURCE=.\7zAlloc.h
# End Source File
# Begin Source File
-SOURCE=..\..\7zDec.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\7zIn.c
-# End Source File
-# Begin Source File
-
SOURCE=.\7zMain.c
# End Source File
# End Target
diff --git a/C/Util/7z/7zMain.c b/C/Util/7z/7zMain.c
index 585449e3..c1033823 100755
--- a/C/Util/7z/7zMain.c
+++ b/C/Util/7z/7zMain.c
@@ -1,7 +1,6 @@
/* 7zMain.c - Test application for 7z Decoder
-2009-08-17 : Igor Pavlov : Public domain */
+2009-11-24 : Igor Pavlov : Public domain */
-#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -70,7 +69,7 @@ static Bool Utf16_To_Utf8(Byte *dest, size_t *destLen, const UInt16 *src, size_t
c2 = src[srcPos++];
if (c2 < 0xDC00 || c2 >= 0xE000)
break;
- value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
+ value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;
}
for (numAdds = 1; numAdds < 5; numAdds++)
if (value < (((UInt32)1) << (numAdds * 5 + 6)))
diff --git a/C/Util/7z/makefile b/C/Util/7z/makefile
index fc814dc9..0a5d7107 100755
--- a/C/Util/7z/makefile
+++ b/C/Util/7z/makefile
@@ -6,12 +6,14 @@ C_OBJS = \
$O\7zBuf.obj \
$O\7zBuf2.obj \
$O\7zCrc.obj \
+ $O\7zCrcOpt.obj \
$O\7zFile.obj \
$O\7zDec.obj \
$O\7zIn.obj \
$O\7zStream.obj \
$O\Bcj2.obj \
$O\Bra86.obj \
+ $O\CpuArch.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \
diff --git a/C/Util/7z/makefile.gcc b/C/Util/7z/makefile.gcc
index 25c0e69b..023bc285 100755
--- a/C/Util/7z/makefile.gcc
+++ b/C/Util/7z/makefile.gcc
@@ -4,13 +4,16 @@ LIB =
RM = rm -f
CFLAGS = -c -O2 -Wall
-OBJS = 7zAlloc.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zDec.o 7zIn.o 7zMain.o LzmaDec.o Lzma2Dec.o Bra86.o Bcj2.o 7zFile.o 7zStream.o
+OBJS = 7zMain.o 7zAlloc.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o 7zIn.o CpuArch.o LzmaDec.o Lzma2Dec.o Bra86.o Bcj2.o 7zFile.o 7zStream.o
all: $(PROG)
$(PROG): $(OBJS)
$(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
+7zMain.o: 7zMain.c
+ $(CXX) $(CFLAGS) 7zMain.c
+
7zAlloc.o: 7zAlloc.c
$(CXX) $(CFLAGS) 7zAlloc.c
@@ -23,14 +26,17 @@ $(PROG): $(OBJS)
7zCrc.o: ../../7zCrc.c
$(CXX) $(CFLAGS) ../../7zCrc.c
+7zCrcOpt.o: ../../7zCrc.c
+ $(CXX) $(CFLAGS) ../../7zCrcOpt.c
+
7zDec.o: ../../7zDec.c
$(CXX) $(CFLAGS) ../../7zDec.c
7zIn.o: ../../7zIn.c
$(CXX) $(CFLAGS) ../../7zIn.c
-7zMain.o: 7zMain.c
- $(CXX) $(CFLAGS) 7zMain.c
+CpuArch.o: ../../CpuArch.c
+ $(CXX) $(CFLAGS) ../../CpuArch.c
LzmaDec.o: ../../LzmaDec.c
$(CXX) $(CFLAGS) ../../LzmaDec.c
diff --git a/C/Util/Lzma/makefile b/C/Util/Lzma/makefile
index bd55f826..afac0716 100755
--- a/C/Util/Lzma/makefile
+++ b/C/Util/Lzma/makefile
@@ -2,7 +2,6 @@ MY_STATIC_LINK=1
PROG = LZMAc.exe
CFLAGS = $(CFLAGS) \
- -DCOMPRESS_MF_MT \
LIB_OBJS = \
$O\LzmaUtil.obj \
diff --git a/C/Util/Lzma/makefile.gcc b/C/Util/Lzma/makefile.gcc
index 9b0c5b7f..67aa8b17 100755
--- a/C/Util/Lzma/makefile.gcc
+++ b/C/Util/Lzma/makefile.gcc
@@ -2,7 +2,7 @@ PROG = lzma
CXX = g++
LIB =
RM = rm -f
-CFLAGS = -c -O2 -Wall
+CFLAGS = -c -O2 -Wall -D_7ZIP_ST
OBJS = \
LzmaUtil.o \
diff --git a/C/Util/LzmaLib/LzmaLib.dsp b/C/Util/LzmaLib/LzmaLib.dsp
index 163f6cd8..7d8d386f 100755
--- a/C/Util/LzmaLib/LzmaLib.dsp
+++ b/C/Util/LzmaLib/LzmaLib.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gr /MT /W3 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /D "COMPRESS_MF_MT" /FD /c
+# ADD CPP /nologo /Gr /MT /W3 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
diff --git a/C/Util/LzmaLib/makefile b/C/Util/LzmaLib/makefile
index 038bc15c..74103bb0 100755
--- a/C/Util/LzmaLib/makefile
+++ b/C/Util/LzmaLib/makefile
@@ -5,7 +5,6 @@ SLIBPATH = $O\$(SLIB)
DEF_FILE = LzmaLib.def
CFLAGS = $(CFLAGS) \
- -DCOMPRESS_MF_MT \
LIB_OBJS = \
$O\LzmaLibExports.obj \
diff --git a/CPP/7zip/Aes.mak b/CPP/7zip/Aes.mak
new file mode 100755
index 00000000..c5a58f28
--- /dev/null
+++ b/CPP/7zip/Aes.mak
@@ -0,0 +1,7 @@
+C_OBJS = $(C_OBJS) \
+ $O\Aes.obj
+
+!IF "$(CPU)" != "IA64" && "$(CPU)" != "MIPS" && "$(CPU)" != "ARM"
+ASM_OBJS = $(ASM_OBJS) \
+ $O\AesOpt.obj
+!ENDIF
diff --git a/CPP/7zip/Archive/7z/7z.dsp b/CPP/7zip/Archive/7z/7z.dsp
index cf7aa975..0484228d 100755
--- a/CPP/7zip/Archive/7z/7z.dsp
+++ b/CPP/7zip/Archive/7z/7z.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -70,7 +70,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -619,6 +619,11 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -628,6 +633,11 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
diff --git a/CPP/7zip/Archive/7z/7zCompressionMode.h b/CPP/7zip/Archive/7z/7zCompressionMode.h
index a7cf999c..55bbc68e 100755
--- a/CPP/7zip/Archive/7z/7zCompressionMode.h
+++ b/CPP/7zip/Archive/7z/7zCompressionMode.h
@@ -31,7 +31,7 @@ struct CCompressionMethodMode
{
CObjectVector<CMethodFull> Methods;
CRecordVector<CBind> Binds;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
UInt32 NumThreads;
#endif
bool PasswordIsDefined;
@@ -39,7 +39,7 @@ struct CCompressionMethodMode
bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); }
CCompressionMethodMode(): PasswordIsDefined(false)
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, NumThreads(1)
#endif
{}
diff --git a/CPP/7zip/Archive/7z/7zDecode.cpp b/CPP/7zip/Archive/7z/7zDecode.cpp
index 2d25ff2e..ab3db913 100755
--- a/CPP/7zip/Archive/7z/7zDecode.cpp
+++ b/CPP/7zip/Archive/7z/7zDecode.cpp
@@ -97,7 +97,7 @@ HRESULT CDecoder::Decode(
#ifndef _NO_CRYPTO
, ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
, bool mtMode, UInt32 numThreads
#endif
)
@@ -239,7 +239,7 @@ HRESULT CDecoder::Decode(
}
}
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
if (mtMode)
{
CMyComPtr<ICompressSetCoderMt> setCoderMt;
diff --git a/CPP/7zip/Archive/7z/7zDecode.h b/CPP/7zip/Archive/7z/7zDecode.h
index 1057a525..d8a424a3 100755
--- a/CPP/7zip/Archive/7z/7zDecode.h
+++ b/CPP/7zip/Archive/7z/7zDecode.h
@@ -57,7 +57,7 @@ public:
#ifndef _NO_CRYPTO
, ICryptoGetTextPassword *getTextPasswordSpec, bool &passwordIsDefined
#endif
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
, bool mtMode, UInt32 numThreads
#endif
);
diff --git a/CPP/7zip/Archive/7z/7zEncode.cpp b/CPP/7zip/Archive/7z/7zEncode.cpp
index 86753acd..ec0b5af4 100755
--- a/CPP/7zip/Archive/7z/7zEncode.cpp
+++ b/CPP/7zip/Archive/7z/7zEncode.cpp
@@ -15,7 +15,6 @@
static const UInt64 k_Delta = 0x03;
static const UInt64 k_BCJ = 0x03030103;
static const UInt64 k_BCJ2 = 0x0303011B;
-static const UInt64 k_AES = 0x06F10701;
namespace NArchive {
namespace N7z {
@@ -76,7 +75,7 @@ HRESULT CEncoder::CreateMixerCoder(
CMyComPtr<IUnknown> encoderCommon = encoder ? (IUnknown *)encoder : (IUnknown *)encoder2;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
{
CMyComPtr<ICompressSetCoderMt> setCoderMt;
encoderCommon.QueryInterface(IID_ICompressSetCoderMt, &setCoderMt);
diff --git a/CPP/7zip/Archive/7z/7zExtract.cpp b/CPP/7zip/Archive/7z/7zExtract.cpp
index 1b0f9ea1..6913d8fb 100755
--- a/CPP/7zip/Archive/7z/7zExtract.cpp
+++ b/CPP/7zip/Archive/7z/7zExtract.cpp
@@ -237,7 +237,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
#ifndef _NO_CRYPTO
, getTextPassword, passwordIsDefined
#endif
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
, true, _numThreads
#endif
);
diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp
index 136d0c5f..4ab7afa8 100755
--- a/CPP/7zip/Archive/7z/7zHandler.cpp
+++ b/CPP/7zip/Archive/7z/7zHandler.cpp
@@ -7,7 +7,7 @@
#include "../../../Common/ComTry.h"
#include "../../../Common/IntToString.h"
-#ifdef COMPRESS_MT
+#ifndef __7Z_SET_PROPERTIES
#include "../../../Windows/System.h"
#endif
@@ -38,7 +38,7 @@ CHandler::CHandler()
#endif
#ifdef EXTRACT_ONLY
- #ifdef COMPRESS_MT
+ #ifdef __7Z_SET_PROPERTIES
_numThreads = NSystem::GetNumberOfProcessors();
#endif
#else
@@ -190,18 +190,11 @@ static inline void AddHexToString(UString &res, Byte value)
#endif
-static const UInt64 k_AES = 0x06F10701;
-
bool CHandler::IsEncrypted(UInt32 index2) const
{
CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
if (folderIndex != kNumNoIndex)
- {
- const CFolder &folderInfo = _db.Folders[folderIndex];
- for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
- if (folderInfo.Coders[i].MethodID == k_AES)
- return true;
- }
+ return _db.Folders[folderIndex].IsEncrypted();
return false;
}
@@ -454,10 +447,8 @@ STDMETHODIMP CHandler::Close()
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
{
COM_TRY_BEGIN
- #ifdef COMPRESS_MT
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
_numThreads = numProcessors;
- #endif
for (int i = 0; i < numProperties; i++)
{
@@ -472,9 +463,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
{
if(name.Left(2).CompareNoCase(L"MT") == 0)
{
- #ifdef COMPRESS_MT
RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
- #endif
continue;
}
else
diff --git a/CPP/7zip/Archive/7z/7zHandler.h b/CPP/7zip/Archive/7z/7zHandler.h
index 68fb034f..56062d46 100755
--- a/CPP/7zip/Archive/7z/7zHandler.h
+++ b/CPP/7zip/Archive/7z/7zHandler.h
@@ -21,7 +21,7 @@ namespace N7z {
#ifndef __7Z_SET_PROPERTIES
#ifdef EXTRACT_ONLY
-#ifdef COMPRESS_MT
+#if !defined(_7ZIP_ST) && !defined(_SFX)
#define __7Z_SET_PROPERTIES
#endif
#else
@@ -80,7 +80,7 @@ private:
#ifdef EXTRACT_ONLY
- #ifdef COMPRESS_MT
+ #ifdef __7Z_SET_PROPERTIES
UInt32 _numThreads;
#endif
@@ -92,7 +92,7 @@ private:
HRESULT SetCompressionMethod(CCompressionMethodMode &method,
CObjectVector<COneMethodInfo> &methodsInfo
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, UInt32 numThreads
#endif
);
diff --git a/CPP/7zip/Archive/7z/7zHandlerOut.cpp b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
index 813510c8..a8ccab6d 100755
--- a/CPP/7zip/Archive/7z/7zHandlerOut.cpp
+++ b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
@@ -51,7 +51,7 @@ HRESULT CHandler::SetCompressionMethod(
CCompressionMethodMode &headerMethod)
{
HRESULT res = SetCompressionMethod(methodMode, _methods
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, _numThreads
#endif
);
@@ -91,8 +91,8 @@ HRESULT CHandler::SetCompressionMethod(
}
headerMethodInfoVector.Add(oneMethodInfo);
HRESULT res = SetCompressionMethod(headerMethod, headerMethodInfoVector
- #ifdef COMPRESS_MT
- ,1
+ #ifndef _7ZIP_ST
+ , 1
#endif
);
RINOK(res);
@@ -103,7 +103,7 @@ HRESULT CHandler::SetCompressionMethod(
HRESULT CHandler::SetCompressionMethod(
CCompressionMethodMode &methodMode,
CObjectVector<COneMethodInfo> &methodsInfo
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, UInt32 numThreads
#endif
)
@@ -122,7 +122,7 @@ HRESULT CHandler::SetCompressionMethod(
{
COneMethodInfo &oneMethodInfo = methodsInfo[i];
SetCompressionMethod2(oneMethodInfo
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, numThreads
#endif
);
@@ -327,7 +327,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
CCompressionMethodMode methodMode, headerMethod;
RINOK(SetCompressionMethod(methodMode, headerMethod));
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
methodMode.NumThreads = _numThreads;
headerMethod.NumThreads = 1;
#endif
diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp
index f1458e0c..79d60fc5 100755
--- a/CPP/7zip/Archive/7z/7zIn.cpp
+++ b/CPP/7zip/Archive/7z/7zIn.cpp
@@ -823,7 +823,7 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
#ifndef _NO_CRYPTO
, getTextPassword, passwordIsDefined
#endif
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
, false, 1
#endif
);
diff --git a/CPP/7zip/Archive/7z/7zItem.h b/CPP/7zip/Archive/7z/7zItem.h
index 1c3068bb..34f10775 100755
--- a/CPP/7zip/Archive/7z/7zItem.h
+++ b/CPP/7zip/Archive/7z/7zItem.h
@@ -13,6 +13,8 @@
namespace NArchive {
namespace N7z {
+const UInt64 k_AES = 0x06F10701;
+
typedef UInt32 CNum;
const CNum kNumMax = 0x7FFFFFFF;
const CNum kNumNoIndex = 0xFFFFFFFF;
@@ -83,6 +85,14 @@ struct CFolder
return -1;
}
+ bool IsEncrypted() const
+ {
+ for (int i = Coders.Size() - 1; i >= 0; i--)
+ if (Coders[i].MethodID == k_AES)
+ return true;
+ return false;
+ }
+
bool CheckStructure() const;
};
diff --git a/CPP/7zip/Archive/7z/7zOut.cpp b/CPP/7zip/Archive/7z/7zOut.cpp
index 8d241d74..0c8aa7e8 100755
--- a/CPP/7zip/Archive/7z/7zOut.cpp
+++ b/CPP/7zip/Archive/7z/7zOut.cpp
@@ -502,9 +502,11 @@ void COutArchive::SkipAlign(unsigned pos, unsigned alignSize)
}
*/
+static inline unsigned Bv_GetSizeInBytes(const CBoolVector &v) { return ((unsigned)v.Size() + 7) / 8; }
+
void COutArchive::WriteAlignedBoolHeader(const CBoolVector &v, int numDefined, Byte type, unsigned itemSize)
{
- const UInt64 bvSize = (numDefined == v.Size()) ? 0 : (v.Size() + 7) / 8;
+ const unsigned bvSize = (numDefined == v.Size()) ? 0 : Bv_GetSizeInBytes(v);
const UInt64 dataSize = (UInt64)numDefined * itemSize + bvSize + 2;
SkipAlign(3 + (unsigned)bvSize + (unsigned)GetBigNumberSize(dataSize), itemSize);
@@ -631,7 +633,7 @@ void COutArchive::WriteHeader(
if (numEmptyStreams > 0)
{
WriteByte(NID::kEmptyStream);
- WriteNumber((emptyStreamVector.Size() + 7) / 8);
+ WriteNumber(Bv_GetSizeInBytes(emptyStreamVector));
WriteBoolVector(emptyStreamVector);
CBoolVector emptyFileVector, antiVector;
@@ -656,14 +658,14 @@ void COutArchive::WriteHeader(
if (numEmptyFiles > 0)
{
WriteByte(NID::kEmptyFile);
- WriteNumber((emptyFileVector.Size() + 7) / 8);
+ WriteNumber(Bv_GetSizeInBytes(emptyFileVector));
WriteBoolVector(emptyFileVector);
}
if (numAntiItems > 0)
{
WriteByte(NID::kAnti);
- WriteNumber((antiVector.Size() + 7) / 8);
+ WriteNumber(Bv_GetSizeInBytes(antiVector));
WriteBoolVector(antiVector);
}
}
diff --git a/CPP/7zip/Archive/7z/7zRegister.cpp b/CPP/7zip/Archive/7z/7zRegister.cpp
index af59b644..6e9bf6b9 100755
--- a/CPP/7zip/Archive/7z/7zRegister.cpp
+++ b/CPP/7zip/Archive/7z/7zRegister.cpp
@@ -15,4 +15,4 @@ static IOutArchive *CreateArcOut() { return new NArchive::N7z::CHandler; }
static CArcInfo g_ArcInfo =
{ L"7z", L"7z", 0, 7, {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}, 6, false, CreateArc, CreateArcOut };
-REGISTER_ARC_DEC_SIG(7z)
+REGISTER_ARC(7z)
diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp
index d1082808..7b9e49e1 100755
--- a/CPP/7zip/Archive/7z/7zUpdate.cpp
+++ b/CPP/7zip/Archive/7z/7zUpdate.cpp
@@ -27,7 +27,6 @@ namespace N7z {
static const UInt64 k_LZMA = 0x030101;
static const UInt64 k_BCJ = 0x03030103;
static const UInt64 k_BCJ2 = 0x0303011B;
-static const UInt64 k_AES = 0x06F10701;
static const wchar_t *kMatchFinderForBCJ2_LZMA = L"BT2";
static const UInt32 kDictionaryForBCJ2_LZMA = 1 << 20;
@@ -580,7 +579,7 @@ public:
DECL_EXTERNAL_CODECS_VARS
CDecoder Decoder;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
bool MtMode;
UInt32 NumThreads;
#endif
@@ -588,7 +587,7 @@ public:
CThreadDecoder():
Decoder(true)
{
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
MtMode = false;
NumThreads = 1;
#endif
@@ -617,7 +616,7 @@ void CThreadDecoder::Execute()
#ifndef _NO_CRYPTO
, GetTextPassword, passwordIsDefined
#endif
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, MtMode, NumThreads
#endif
);
@@ -642,17 +641,6 @@ bool static Is86FilteredFolder(const CFolder &f)
return false;
}
-bool static IsEncryptedFolder(const CFolder &f)
-{
- for (int i = 0; i < f.Coders.Size(); i++)
- {
- CMethodId m = f.Coders[i].MethodID;
- if (m == k_AES)
- return true;
- }
- return false;
-}
-
#ifndef _NO_CRYPTO
class CCryptoGetTextPassword:
@@ -760,7 +748,7 @@ HRESULT Update(
rep.FolderIndex = i;
rep.NumCopyFiles = numCopyItems;
const CFolder &f = db->Folders[i];
- bool isEncrypted = IsEncryptedFolder(f);
+ bool isEncrypted = f.IsEncrypted();
rep.Group = GetGroupIndex(isEncrypted, Is86FilteredFolder(f));
folderRefs.Add(rep);
if (numCopyItems == numUnpackStreams)
diff --git a/CPP/7zip/Archive/7z/makefile b/CPP/7zip/Archive/7z/makefile
index baedf862..0abb3756 100755
--- a/CPP/7zip/Archive/7z/makefile
+++ b/CPP/7zip/Archive/7z/makefile
@@ -1,7 +1,6 @@
PROG = 7z.dll
DEF_FILE = ../Archive.def
CFLAGS = $(CFLAGS) -I ../../../ \
- -DCOMPRESS_MT \
-DEXTERNAL_CODECS \
AR_OBJS = \
@@ -71,9 +70,10 @@ AR_COMMON_OBJS = \
C_OBJS = \
$O\Alloc.obj \
+ $O\CpuArch.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -85,7 +85,7 @@ OBJS = \
$(AR_COMMON_OBJS) \
$O\CopyCoder.obj \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
!include "../../../Build.mak"
@@ -106,4 +106,5 @@ $O\CopyCoder.obj: ../../Compress/$(*B).cpp
$(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Archive/ApmHandler.cpp b/CPP/7zip/Archive/ApmHandler.cpp
new file mode 100755
index 00000000..a3b5e19b
--- /dev/null
+++ b/CPP/7zip/Archive/ApmHandler.cpp
@@ -0,0 +1,356 @@
+// ApmHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/MyString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/CopyCoder.h"
+
+#define Get16(p) GetBe16(p)
+#define Get32(p) GetBe32(p)
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NApm {
+
+struct CItem
+{
+ UInt32 StartBlock;
+ UInt32 NumBlocks;
+ char Name[32];
+ char Type[32];
+ /*
+ UInt32 DataStartBlock;
+ UInt32 NumDataBlocks;
+ UInt32 Status;
+ UInt32 BootStartBlock;
+ UInt32 BootSize;
+ UInt32 BootAddr;
+ UInt32 BootEntry;
+ UInt32 BootChecksum;
+ char Processor[16];
+ */
+
+ bool Parse(const Byte *p, UInt32 &numBlocksInMap)
+ {
+ if (p[0] != 0x50 || p[1] != 0x4D || p[2] != 0 || p[3] != 0)
+ return false;
+ numBlocksInMap = Get32(p + 4);
+ StartBlock = Get32(p + 8);
+ NumBlocks = Get32(p + 0xC);
+ memcpy(Name, p + 0x10, 32);
+ memcpy(Type, p + 0x30, 32);
+ /*
+ DataStartBlock = Get32(p + 0x50);
+ NumDataBlocks = Get32(p + 0x54);
+ Status = Get32(p + 0x58);
+ BootStartBlock = Get32(p + 0x5C);
+ BootSize = Get32(p + 0x60);
+ BootAddr = Get32(p + 0x64);
+ if (Get32(p + 0x68) != 0)
+ return false;
+ BootEntry = Get32(p + 0x6C);
+ if (Get32(p + 0x70) != 0)
+ return false;
+ BootChecksum = Get32(p + 0x74);
+ memcpy(Processor, p + 0x78, 16);
+ */
+ return true;
+ }
+};
+
+class CHandler:
+ public IInArchive,
+ public IInArchiveGetStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _stream;
+ CRecordVector<CItem> _items;
+
+ int _blockSizeLog;
+ UInt32 _numBlocks;
+
+ HRESULT ReadTables(IInStream *stream);
+ UInt64 BlocksToBytes(UInt32 i) const { return (UInt64)i << _blockSizeLog; }
+ UInt64 GetItemSize(const CItem &item) { return BlocksToBytes(item.NumBlocks); }
+public:
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
+ INTERFACE_IInArchive(;)
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+};
+
+static inline int GetLog(UInt32 num)
+{
+ for (int i = 0; i < 31; i++)
+ if (((UInt32)1 << i) == num)
+ return i;
+ return -1;
+}
+
+HRESULT CHandler::ReadTables(IInStream *stream)
+{
+ const UInt32 kSectorSize = 512;
+ Byte buf[kSectorSize];
+ {
+ RINOK(ReadStream_FALSE(stream, buf, kSectorSize));
+ if (buf[0] != 0x45 || buf[1] != 0x52)
+ return S_FALSE;
+ _blockSizeLog = GetLog(Get16(buf + 2));
+ if (_blockSizeLog < 9 || _blockSizeLog > 14)
+ return S_FALSE;
+ _numBlocks = Get32(buf + 4);
+ for (int i = 8; i < 16; i++)
+ if (buf[i] != 0)
+ return S_FALSE;
+ }
+
+ unsigned numSkips = (unsigned)1 << (_blockSizeLog - 9);
+ for (unsigned j = 1; j < numSkips; j++)
+ {
+ RINOK(ReadStream_FALSE(stream, buf, kSectorSize));
+ }
+
+ UInt32 numBlocksInMap = 0;
+ for (unsigned i = 0;;)
+ {
+ RINOK(ReadStream_FALSE(stream, buf, kSectorSize));
+
+ CItem item;
+
+ UInt32 numBlocksInMap2;
+ if (!item.Parse(buf, numBlocksInMap2))
+ return S_FALSE;
+ if (i == 0)
+ {
+ numBlocksInMap = numBlocksInMap2;
+ if (numBlocksInMap > (1 << 8))
+ return S_FALSE;
+ }
+ else if (numBlocksInMap2 != numBlocksInMap)
+ return S_FALSE;
+
+ UInt32 finish = item.StartBlock + item.NumBlocks;
+ if (finish < item.StartBlock)
+ return S_FALSE;
+ _numBlocks = MyMax(_numBlocks, finish);
+
+ _items.Add(item);
+ for (unsigned j = 1; j < numSkips; j++)
+ {
+ RINOK(ReadStream_FALSE(stream, buf, kSectorSize));
+ }
+ if (++i == numBlocksInMap)
+ break;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ RINOK(ReadTables(stream));
+ _stream = stream;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _items.Clear();
+ _stream.Release();
+ return S_OK;
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidOffset, VT_UI8}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidClusterSize, VT_UI4},
+ { NULL, kpidPhySize, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+static AString GetString(const char *s)
+{
+ AString res;
+ for (int i = 0; i < 32 && s[i] != 0; i++)
+ res += s[i];
+ return res;
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMainSubfile:
+ {
+ int mainIndex = -1;
+ for (int i = 0; i < _items.Size(); i++)
+ {
+ AString s = GetString(_items[i].Type);
+ if (s != "Apple_Free" &&
+ s != "Apple_partition_map")
+ {
+ if (mainIndex >= 0)
+ {
+ mainIndex = -1;
+ break;
+ }
+ mainIndex = i;
+ }
+ }
+ if (mainIndex >= 0)
+ prop = (UInt32)mainIndex;
+ break;
+ }
+ case kpidClusterSize: prop = (UInt32)1 << _blockSizeLog; break;
+ case kpidPhySize: prop = BlocksToBytes(_numBlocks); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ const CItem &item = _items[index];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ AString s = GetString(item.Name);
+ if (s.IsEmpty())
+ {
+ char s2[32];
+ ConvertUInt32ToString(index, s2);
+ s = s2;
+ }
+ AString type = GetString(item.Type);
+ if (type == "Apple_HFS")
+ type = "hfs";
+ if (!type.IsEmpty())
+ {
+ s += '.';
+ s += type;
+ }
+ prop = s;
+ break;
+ }
+ case kpidSize:
+ case kpidPackSize:
+ prop = GetItemSize(item);
+ break;
+ case kpidOffset: prop = BlocksToBytes(item.StartBlock); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
+ Int32 testMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == (UInt32)-1);
+ if (allFilesMode)
+ numItems = _items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += GetItemSize(_items[allFilesMode ? i : indices[i]]);
+ extractCallback->SetTotal(totalSize);
+
+ totalSize = 0;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_stream);
+
+ for (i = 0; i < numItems; i++)
+ {
+ lps->InSize = totalSize;
+ lps->OutSize = totalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> outStream;
+ Int32 askMode = testMode ?
+ NExtract::NAskMode::kTest :
+ NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _items[index];
+
+ RINOK(extractCallback->GetStream(index, &outStream, askMode));
+ UInt64 size = GetItemSize(item);
+ totalSize += size;
+ if (!testMode && !outStream)
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ RINOK(_stream->Seek(BlocksToBytes(item.StartBlock), STREAM_SEEK_SET, NULL));
+ streamSpec->Init(size);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == size ?
+ NExtract::NOperationResult::kOK:
+ NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
+{
+ COM_TRY_BEGIN
+ const CItem &item = _items[index];
+ return CreateLimitedInStream(_stream, BlocksToBytes(item.StartBlock), GetItemSize(item), stream);
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"APM", L"", 0, 0xD4, { 0x50, 0x4D, 0, 0, 0, 0, 0 }, 7, false, CreateArc, 0 };
+
+REGISTER_ARC(Apm)
+
+}}
diff --git a/CPP/7zip/Archive/Bz2Handler.cpp b/CPP/7zip/Archive/Bz2Handler.cpp
index 5d2620ba..98cbcc18 100755
--- a/CPP/7zip/Archive/Bz2Handler.cpp
+++ b/CPP/7zip/Archive/Bz2Handler.cpp
@@ -6,7 +6,7 @@
#include "Windows/PropVariant.h"
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
#include "../../Windows/System.h"
#endif
@@ -51,7 +51,7 @@ class CHandler:
UInt32 _level;
UInt32 _dicSize;
UInt32 _numPasses;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
UInt32 _numThreads;
#endif
@@ -60,7 +60,7 @@ class CHandler:
_level = 5;
_dicSize =
_numPasses = 0xFFFFFFFF;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
_numThreads = NWindows::NSystem::GetNumberOfProcessors();;
#endif
}
@@ -187,7 +187,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
decoderSpec->SetInStream(_seqStream);
- #if defined( COMPRESS_MT) && defined( COMPRESS_BZIP2_MT)
+ #ifndef _7ZIP_ST
RINOK(decoderSpec->SetNumberOfThreads(_numThreads));
#endif
@@ -249,7 +249,7 @@ static HRESULT UpdateArchive(
int indexInClient,
UInt32 dictionary,
UInt32 numPasses,
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
UInt32 numThreads,
#endif
IArchiveUpdateCallback *updateCallback)
@@ -273,7 +273,7 @@ static HRESULT UpdateArchive(
{
dictionary,
numPasses
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, numThreads
#endif
};
@@ -281,7 +281,7 @@ static HRESULT UpdateArchive(
{
NCoderPropID::kDictionarySize,
NCoderPropID::kNumPasses
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, NCoderPropID::kNumThreads
#endif
};
@@ -351,7 +351,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
return UpdateArchive(
size, outStream, 0, dicSize, numPasses,
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
_numThreads,
#endif
updateCallback);
@@ -366,7 +366,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps)
{
InitMethodProperties();
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
_numThreads = numProcessors;
#endif
@@ -398,7 +398,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
}
else if (name.Left(2) == L"MT")
{
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
#endif
}
diff --git a/CPP/7zip/Archive/Cab/CabHandler.cpp b/CPP/7zip/Archive/Cab/CabHandler.cpp
index 480a9a8a..672172a6 100755
--- a/CPP/7zip/Archive/Cab/CabHandler.cpp
+++ b/CPP/7zip/Archive/Cab/CabHandler.cpp
@@ -233,17 +233,14 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
HRESULT res = S_FALSE;
CInArchive archive;
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
- {
- CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = callback;
- openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
- }
-
+ callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
+
CMyComPtr<IInStream> nextStream = inStream;
bool prevChecked = false;
UInt64 numItems = 0;
try
{
- while(nextStream != 0)
+ while (nextStream != 0)
{
CDatabaseEx db;
db.Stream = nextStream;
@@ -296,6 +293,9 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
if (!otherArchive)
break;
const UString fullName = MultiByteToUnicodeString(otherArchive->FileName, CP_ACP);
+ if (!openVolumeCallback)
+ break;
+
HRESULT result = openVolumeCallback->GetStream(fullName, &nextStream);
if (result == S_OK)
break;
diff --git a/CPP/7zip/Archive/Common/HandlerOut.cpp b/CPP/7zip/Archive/Common/HandlerOut.cpp
index 46f835ef..70ad47aa 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.cpp
+++ b/CPP/7zip/Archive/Common/HandlerOut.cpp
@@ -6,7 +6,7 @@
#include "../../../Windows/PropVariant.h"
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
#include "../../../Windows/System.h"
#endif
@@ -190,7 +190,7 @@ static void SetMethodProp(COneMethodInfo &m, PROPID propID, const NCOM::CPropVar
}
void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, UInt32 numThreads
#endif
)
@@ -224,7 +224,7 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
SetMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo);
SetMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
SetMethodProp(oneMethodInfo, NCoderPropID::kMatchFinder, matchFinder);
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
SetMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
#endif
}
@@ -262,7 +262,7 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
SetMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
SetMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
SetMethodProp(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
#endif
}
@@ -476,7 +476,7 @@ void COutHandler::Init()
WriteATime = false;
WriteMTime = true;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
_numThreads = NSystem::GetNumberOfProcessors();
#endif
@@ -490,7 +490,7 @@ void COutHandler::Init()
void COutHandler::BeforeSetProperty()
{
Init();
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
numProcessors = NSystem::GetNumberOfProcessors();
#endif
@@ -538,7 +538,7 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
{
if(name.Left(2).CompareNoCase(L"MT") == 0)
{
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
RINOK(ParseMtProp(name.Mid(2), value, numProcessors, _numThreads));
#endif
return S_OK;
diff --git a/CPP/7zip/Archive/Common/HandlerOut.h b/CPP/7zip/Archive/Common/HandlerOut.h
index 7ba22b24..72ea4032 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.h
+++ b/CPP/7zip/Archive/Common/HandlerOut.h
@@ -24,7 +24,7 @@ public:
HRESULT SetSolidSettings(const UString &s);
HRESULT SetSolidSettings(const PROPVARIANT &value);
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
UInt32 _numThreads;
#endif
@@ -55,7 +55,7 @@ public:
HRESULT SetParams(COneMethodInfo &oneMethodInfo, const UString &srcString);
void SetCompressionMethod2(COneMethodInfo &oneMethodInfo
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, UInt32 numThreads
#endif
);
diff --git a/CPP/7zip/Archive/LzmaHandler.cpp b/CPP/7zip/Archive/LzmaHandler.cpp
index d9851501..a83e6a1a 100755
--- a/CPP/7zip/Archive/LzmaHandler.cpp
+++ b/CPP/7zip/Archive/LzmaHandler.cpp
@@ -188,8 +188,7 @@ class CHandler:
DECL_ISetCompressCodecsInfo
public:
- MY_QUERYINTERFACE_BEGIN
- MY_QUERYINTERFACE_ENTRY(IInArchive)
+ MY_QUERYINTERFACE_BEGIN2(IInArchive)
MY_QUERYINTERFACE_ENTRY(IArchiveOpenSeq)
QUERY_ENTRY_ISetCompressCodecsInfo
MY_QUERYINTERFACE_END
diff --git a/CPP/7zip/Archive/Rar/RarIn.cpp b/CPP/7zip/Archive/Rar/RarIn.cpp
index 5ea12c2d..c5d30fac 100755
--- a/CPP/7zip/Archive/Rar/RarIn.cpp
+++ b/CPP/7zip/Archive/Rar/RarIn.cpp
@@ -70,7 +70,7 @@ bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
{
if (m_CryptoMode)
{
- const Byte *bufData = (const Byte *)m_DecryptedData;
+ const Byte *bufData = m_DecryptedDataAligned;
UInt32 bufSize = m_DecryptedDataSize;
UInt32 i;
for (i = 0; i < size && m_CryptoPos < bufSize; i++)
@@ -423,13 +423,15 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa
const UInt32 kDecryptedBufferSize = (1 << 12);
if (m_DecryptedData.GetCapacity() == 0)
{
- m_DecryptedData.SetCapacity(kDecryptedBufferSize);
+ const UInt32 kAlign = 16;
+ m_DecryptedData.SetCapacity(kDecryptedBufferSize + kAlign);
+ m_DecryptedDataAligned = (Byte *)((ptrdiff_t)((Byte *)m_DecryptedData + kAlign - 1) & ~(ptrdiff_t)(kAlign - 1));
}
RINOK(m_RarAES->Init());
size_t decryptedDataSizeT = kDecryptedBufferSize;
- RINOK(ReadStream(m_Stream, (Byte *)m_DecryptedData, &decryptedDataSizeT));
+ RINOK(ReadStream(m_Stream, m_DecryptedDataAligned, &decryptedDataSizeT));
m_DecryptedDataSize = (UInt32)decryptedDataSizeT;
- m_DecryptedDataSize = m_RarAES->Filter((Byte *)m_DecryptedData, m_DecryptedDataSize);
+ m_DecryptedDataSize = m_RarAES->Filter(m_DecryptedDataAligned, m_DecryptedDataSize);
m_CryptoMode = true;
m_CryptoPos = 0;
diff --git a/CPP/7zip/Archive/Rar/RarIn.h b/CPP/7zip/Archive/Rar/RarIn.h
index 3d446977..5d9f67a3 100755
--- a/CPP/7zip/Archive/Rar/RarIn.h
+++ b/CPP/7zip/Archive/Rar/RarIn.h
@@ -76,8 +76,6 @@ class CInArchive
void AddToSeekValue(UInt64 addValue);
-protected:
-
CDynamicBuffer<Byte> m_FileHeaderData;
NHeader::NBlock::CBlock m_BlockHeader;
@@ -94,6 +92,7 @@ protected:
void ReadTime(Byte mask, CRarTime &rarTime);
CBuffer<Byte> m_DecryptedData;
+ Byte *m_DecryptedDataAligned;
UInt32 m_DecryptedDataSize;
bool m_CryptoMode;
diff --git a/CPP/7zip/Archive/Tar/TarHandlerOut.cpp b/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
index 4c0cb5f8..92b8abdc 100755
--- a/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
+++ b/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
@@ -107,6 +107,8 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (prop.vt != VT_UI8)
return E_INVALIDARG;
ui.Size = prop.uhVal.QuadPart;
+ if (ui.Size >= ((UInt64)1 << 33))
+ return E_INVALIDARG;
}
updateItems.Add(ui);
}
diff --git a/CPP/7zip/Archive/VhdHandler.cpp b/CPP/7zip/Archive/VhdHandler.cpp
index 439b8691..9d1c928e 100755
--- a/CPP/7zip/Archive/VhdHandler.cpp
+++ b/CPP/7zip/Archive/VhdHandler.cpp
@@ -220,7 +220,6 @@ class CHandler:
HRESULT ReadPhy(UInt64 offset, void *data, UInt32 size);
bool NeedParent() const { return Footer.Type == kDiskType_Diff; }
- UInt64 GetSize() const { return Footer.CurrentSize; }
UInt64 GetPackSize() const
{ return Footer.ThereIsDynamic() ? ((UInt64)NumUsedBlocks << Dyn.BlockSizeLog) : Footer.CurrentSize; }
@@ -317,7 +316,12 @@ HRESULT CHandler::Open3()
if (Dyn.NumBlocks >= (UInt32)1 << 31)
return S_FALSE;
- if (GetSize() != ((UInt64)Dyn.NumBlocks << Dyn.BlockSizeLog))
+ if (Footer.CurrentSize == 0)
+ {
+ if (Dyn.NumBlocks != 0)
+ return S_FALSE;
+ }
+ else if (((Footer.CurrentSize - 1) >> Dyn.BlockSizeLog) + 1 != Dyn.NumBlocks)
return S_FALSE;
Bat.Reserve(Dyn.NumBlocks);
@@ -341,8 +345,11 @@ STDMETHODIMP CHandler::Read(void *data, UInt32 size, UInt32 *processedSize)
{
if (processedSize != NULL)
*processedSize = 0;
- if (_virtPos >= GetSize())
- return (GetSize() == _virtPos) ? S_OK: E_FAIL;
+ if (_virtPos >= Footer.CurrentSize)
+ return (Footer.CurrentSize == _virtPos) ? S_OK: E_FAIL;
+ UInt64 rem = Footer.CurrentSize - _virtPos;
+ if (size > rem)
+ size = (UInt32)rem;
if (size == 0)
return S_OK;
UInt32 blockIndex = (UInt32)(_virtPos >> Dyn.BlockSizeLog);
@@ -406,7 +413,7 @@ STDMETHODIMP CHandler::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition
{
case STREAM_SEEK_SET: _virtPos = offset; break;
case STREAM_SEEK_CUR: _virtPos += offset; break;
- case STREAM_SEEK_END: _virtPos = GetSize() + offset; break;
+ case STREAM_SEEK_END: _virtPos = Footer.CurrentSize + offset; break;
default: return STG_E_INVALIDFUNCTION;
}
if (newPosition)
@@ -627,7 +634,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIAN
switch(propID)
{
- case kpidSize: prop = GetSize(); break;
+ case kpidSize: prop = Footer.CurrentSize; break;
case kpidPackSize: prop = GetPackSize(); break;
case kpidCTime: VhdTimeToFileTime(Footer.CTime, prop); break;
/*
@@ -650,7 +657,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0))
return E_INVALIDARG;
- RINOK(extractCallback->SetTotal(GetSize()));
+ RINOK(extractCallback->SetTotal(Footer.CurrentSize));
CMyComPtr<ISequentialOutStream> outStream;
Int32 askMode = testMode ?
NExtract::NAskMode::kTest :
@@ -678,7 +685,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
HRESULT hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
if (hres == S_OK)
{
- if (copyCoderSpec->TotalSize == GetSize())
+ if (copyCoderSpec->TotalSize == Footer.CurrentSize)
res = NExtract::NOperationResult::kOK;
}
else
@@ -703,7 +710,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 /* index */, ISequentialInStream **strea
CLimitedInStream *streamSpec = new CLimitedInStream;
CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
streamSpec->SetStream(Stream);
- streamSpec->InitAndSeek(0, GetSize());
+ streamSpec->InitAndSeek(0, Footer.CurrentSize);
RINOK(streamSpec->SeekToStart());
*stream = streamTemp.Detach();
return S_OK;
diff --git a/CPP/7zip/Archive/XarHandler.cpp b/CPP/7zip/Archive/XarHandler.cpp
index 5a2489d2..56570230 100755
--- a/CPP/7zip/Archive/XarHandler.cpp
+++ b/CPP/7zip/Archive/XarHandler.cpp
@@ -198,25 +198,28 @@ static bool AddItem(const CXmlItem &item, CObjectVector<CFile> &files, int paren
file.Sha1IsDefined = ParseSha1(dataItem, "extracted-checksum", file.Sha1);
// file.packSha1IsDefined = ParseSha1(dataItem, "archived-checksum", file.packSha1);
int encodingIndex = dataItem.FindSubTag("encoding");
- const CXmlItem &encodingItem = dataItem.SubItems[encodingIndex];
- if (encodingItem.IsTag)
+ if (encodingIndex >= 0)
{
- AString s = encodingItem.GetPropertyValue("style");
- if (s.Length() >= 0)
+ const CXmlItem &encodingItem = dataItem.SubItems[encodingIndex];
+ if (encodingItem.IsTag)
{
- AString appl = "application/";
- if (s.Left(appl.Length()) == appl)
+ AString s = encodingItem.GetPropertyValue("style");
+ if (s.Length() >= 0)
{
- s = s.Mid(appl.Length());
- AString xx = "x-";
- if (s.Left(xx.Length()) == xx)
+ AString appl = "application/";
+ if (s.Left(appl.Length()) == appl)
{
- s = s.Mid(xx.Length());
- if (s == "gzip")
- s = METHOD_NAME_ZLIB;
+ s = s.Mid(appl.Length());
+ AString xx = "x-";
+ if (s.Left(xx.Length()) == xx)
+ {
+ s = s.Mid(xx.Length());
+ if (s == "gzip")
+ s = METHOD_NAME_ZLIB;
+ }
}
+ file.Method = s;
}
- file.Method = s;
}
}
}
@@ -359,7 +362,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidMethod:
{
UString name;
- if (ConvertUTF8ToUnicode(item.Method, name))
+ if (!item.Method.IsEmpty() && ConvertUTF8ToUnicode(item.Method, name))
prop = name;
break;
}
@@ -521,7 +524,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
HRESULT res = S_OK;
ICompressCoder *coder = NULL;
- if (item.Method == "octet-stream")
+ if (item.Method.IsEmpty() || item.Method == "octet-stream")
if (item.PackSize == item.Size)
coder = copyCoder;
else
diff --git a/CPP/7zip/Archive/XzHandler.cpp b/CPP/7zip/Archive/XzHandler.cpp
index f37a5841..64b7a586 100755
--- a/CPP/7zip/Archive/XzHandler.cpp
+++ b/CPP/7zip/Archive/XzHandler.cpp
@@ -73,8 +73,7 @@ class CHandler:
HRESULT Open2(IInStream *inStream, IArchiveOpenCallback *callback);
public:
- MY_QUERYINTERFACE_BEGIN
- MY_QUERYINTERFACE_ENTRY(IInArchive)
+ MY_QUERYINTERFACE_BEGIN2(IInArchive)
MY_QUERYINTERFACE_ENTRY(IArchiveOpenSeq)
#ifndef EXTRACT_ONLY
MY_QUERYINTERFACE_ENTRY(IOutArchive)
@@ -644,7 +643,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
{
COneMethodInfo &m = _methods[i];
SetCompressionMethod2(m
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, _numThreads
#endif
);
@@ -658,7 +657,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
}
}
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
lzma2Props.numTotalThreads = _numThreads;
#endif
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
index 9157deeb..8800270b 100755
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
@@ -102,7 +102,7 @@ static HRESULT GetStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC)
HRESULT CAddCommon::Compress(
DECL_EXTERNAL_CODECS_LOC_VARS
ISequentialInStream *inStream, IOutStream *outStream,
- ICompressProgressInfo *progress, CCompressingResult &operationResult)
+ ICompressProgressInfo *progress, CCompressingResult &opRes)
{
CSequentialInStreamWithCRC *inSecCrcStreamSpec = 0;
CInStreamWithCRC *inCrcStreamSpec = 0;
@@ -139,13 +139,17 @@ HRESULT CAddCommon::Compress(
}
Byte method = 0;
COutStreamReleaser outStreamReleaser;
+ opRes.ExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_Default;
for (int i = 0; i < numTestMethods; i++)
{
+ opRes.ExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_Default;
if (inCrcStreamSpec != 0)
RINOK(inCrcStreamSpec->Seek(0, STREAM_SEEK_SET, NULL));
RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
if (_options.PasswordIsDefined)
{
+ opRes.ExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_ZipCrypto;
+
if (!_cryptoStream)
{
_cryptoStreamSpec = new CFilterCoder;
@@ -153,17 +157,24 @@ HRESULT CAddCommon::Compress(
}
if (_options.IsAesMode)
{
- _cryptoStreamSpec->Filter = _aesFilter = _filterAesSpec = new NCrypto::NWzAes::CEncoder;
- _filterAesSpec->SetKeyMode(_options.AesKeyMode);
- RINOK(_filterAesSpec->CryptoSetPassword(
+ opRes.ExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_Aes;
+ if (!_cryptoStreamSpec->Filter)
+ {
+ _cryptoStreamSpec->Filter = _filterAesSpec = new NCrypto::NWzAes::CEncoder;
+ _filterAesSpec->SetKeyMode(_options.AesKeyMode);
+ RINOK(_filterAesSpec->CryptoSetPassword(
(const Byte *)(const char *)_options.Password, _options.Password.Length()));
+ }
RINOK(_filterAesSpec->WriteHeader(outStream));
}
else
{
- _cryptoStreamSpec->Filter = _zipCryptoFilter = _filterSpec = new NCrypto::NZip::CEncoder;
- RINOK(_filterSpec->CryptoSetPassword(
+ if (!_cryptoStreamSpec->Filter)
+ {
+ _cryptoStreamSpec->Filter = _filterSpec = new NCrypto::NZip::CEncoder;
+ RINOK(_filterSpec->CryptoSetPassword(
(const Byte *)(const char *)_options.Password, _options.Password.Length()));
+ }
UInt32 crc = 0;
RINOK(GetStreamCRC(inStream, crc));
RINOK(inCrcStreamSpec->Seek(0, STREAM_SEEK_SET, NULL));
@@ -190,7 +201,6 @@ HRESULT CAddCommon::Compress(
else
outStreamNew = outStream;
RINOK(_copyCoder->Code(inCrcStream, outStreamNew, NULL, NULL, progress));
- operationResult.ExtractVersion = NFileHeader::NCompressionMethod::kStoreExtractVersion;
break;
}
default:
@@ -199,11 +209,12 @@ HRESULT CAddCommon::Compress(
{
if (method == NFileHeader::NCompressionMethod::kLZMA)
{
+ _compressExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_LZMA;
CLzmaEncoder *_lzmaEncoder = new CLzmaEncoder();
_compressEncoder = _lzmaEncoder;
NWindows::NCOM::CPropVariant props[] =
{
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
_options.NumThreads,
#endif
_options.Algo,
@@ -214,7 +225,7 @@ HRESULT CAddCommon::Compress(
};
PROPID propIDs[] =
{
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
NCoderPropID::kNumThreads,
#endif
NCoderPropID::kAlgorithm,
@@ -235,8 +246,12 @@ HRESULT CAddCommon::Compress(
{
case NFileHeader::NCompressionMethod::kBZip2:
methodId = kMethodId_BZip2;
+ _compressExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_BZip2;
break;
default:
+ _compressExtractVersion = ((method == NFileHeader::NCompressionMethod::kDeflated64) ?
+ NFileHeader::NCompressionMethod::kExtractVersion_Deflate64 :
+ NFileHeader::NCompressionMethod::kExtractVersion_Deflate);
methodId = kMethodId_ZipBase + method;
break;
}
@@ -279,7 +294,7 @@ HRESULT CAddCommon::Compress(
{
_options.DicSize,
_options.NumPasses
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, _options.NumThreads
#endif
};
@@ -287,7 +302,7 @@ HRESULT CAddCommon::Compress(
{
NCoderPropID::kDictionarySize,
NCoderPropID::kNumPasses
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
, NCoderPropID::kNumThreads
#endif
};
@@ -305,41 +320,42 @@ HRESULT CAddCommon::Compress(
outStreamNew = _cryptoStream;
else
outStreamNew = outStream;
+ if (_compressExtractVersion > opRes.ExtractVersion)
+ opRes.ExtractVersion = _compressExtractVersion;
RINOK(_compressEncoder->Code(inCrcStream, outStreamNew, NULL, NULL, progress));
- operationResult.ExtractVersion = NFileHeader::NCompressionMethod::kDeflateExtractVersion;
break;
}
}
- RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &operationResult.PackSize));
+ RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &opRes.PackSize));
if (inCrcStreamSpec != 0)
{
- operationResult.CRC = inCrcStreamSpec->GetCRC();
- operationResult.UnpackSize = inCrcStreamSpec->GetSize();
+ opRes.CRC = inCrcStreamSpec->GetCRC();
+ opRes.UnpackSize = inCrcStreamSpec->GetSize();
}
else
{
- operationResult.CRC = inSecCrcStreamSpec->GetCRC();
- operationResult.UnpackSize = inSecCrcStreamSpec->GetSize();
+ opRes.CRC = inSecCrcStreamSpec->GetCRC();
+ opRes.UnpackSize = inSecCrcStreamSpec->GetSize();
}
if (_options.PasswordIsDefined)
{
- if (operationResult.PackSize < operationResult.UnpackSize +
+ if (opRes.PackSize < opRes.UnpackSize +
(_options.IsAesMode ? _filterAesSpec->GetHeaderSize() : NCrypto::NZip::kHeaderSize))
break;
}
- else if (operationResult.PackSize < operationResult.UnpackSize)
+ else if (opRes.PackSize < opRes.UnpackSize)
break;
}
if (_options.IsAesMode)
{
RINOK(_filterAesSpec->WriteFooter(outStream));
- RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &operationResult.PackSize));
+ RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &opRes.PackSize));
}
- operationResult.Method = method;
- return outStream->SetSize(operationResult.PackSize);
+ opRes.Method = method;
+ return outStream->SetSize(opRes.PackSize);
}
}}
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.h b/CPP/7zip/Archive/Zip/ZipAddCommon.h
index 8f5b568d..e4c02db3 100755
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.h
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.h
@@ -35,6 +35,7 @@ class CAddCommon
CMyComPtr<ICompressCoder> _copyCoder;
CMyComPtr<ICompressCoder> _compressEncoder;
+ Byte _compressExtractVersion;
CFilterCoder *_cryptoStreamSpec;
CMyComPtr<ISequentialOutStream> _cryptoStream;
@@ -42,10 +43,6 @@ class CAddCommon
NCrypto::NZip::CEncoder *_filterSpec;
NCrypto::NWzAes::CEncoder *_filterAesSpec;
- CMyComPtr<ICompressFilter> _zipCryptoFilter;
- CMyComPtr<ICompressFilter> _aesFilter;
-
-
public:
CAddCommon(const CCompressionMethodMode &options);
HRESULT Compress(
diff --git a/CPP/7zip/Archive/Zip/ZipCompressionMode.h b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
index de5f5ccd..e5acfa6b 100755
--- a/CPP/7zip/Archive/Zip/ZipCompressionMode.h
+++ b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
@@ -1,7 +1,7 @@
// CompressionMode.h
-#ifndef __ZIP_COMPRESSIONMETHOD_H
-#define __ZIP_COMPRESSIONMETHOD_H
+#ifndef __ZIP_COMPRESSION_MODE_H
+#define __ZIP_COMPRESSION_MODE_H
#include "Common/MyString.h"
@@ -18,7 +18,7 @@ struct CCompressionMethodMode
bool NumMatchFinderCyclesDefined;
UInt32 NumMatchFinderCycles;
UInt32 DicSize;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
UInt32 NumThreads;
#endif
bool PasswordIsDefined;
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index 2e551931..df1ca20b 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -63,30 +63,7 @@ static const char *kHostOS[] =
static const char *kUnknownOS = "Unknown";
-STATPROPSTG kProps[] =
-{
- { NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsDir, VT_BOOL},
- { NULL, kpidSize, VT_UI8},
- { NULL, kpidPackSize, VT_UI8},
- { NULL, kpidMTime, VT_FILETIME},
- { NULL, kpidCTime, VT_FILETIME},
- { NULL, kpidATime, VT_FILETIME},
-
- { NULL, kpidAttrib, VT_UI4},
-
- { NULL, kpidEncrypted, VT_BOOL},
- { NULL, kpidComment, VT_BSTR},
-
- { NULL, kpidCRC, VT_UI4},
-
- { NULL, kpidMethod, VT_BSTR},
- { NULL, kpidHostOS, VT_BSTR}
-
- // { NULL, kpidUnpackVer, VT_UI1},
-};
-
-const char *kMethods[] =
+static const char *kMethods[] =
{
"Store",
"Shrink",
@@ -101,23 +78,20 @@ const char *kMethods[] =
"PKImploding"
};
-const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
-const char *kBZip2Method = "BZip2";
-const char *kLZMAMethod = "LZMA";
-const char *kJpegMethod = "Jpeg";
-const char *kWavPackMethod = "WavPack";
-const char *kPPMdMethod = "PPMd";
-const char *kAESMethod = "AES";
-const char *kZipCryptoMethod = "ZipCrypto";
-const char *kStrongCryptoMethod = "StrongCrypto";
-
-struct CStrongCryptoPair
+static const char *kBZip2Method = "BZip2";
+static const char *kLZMAMethod = "LZMA";
+static const char *kJpegMethod = "Jpeg";
+static const char *kWavPackMethod = "WavPack";
+static const char *kPPMdMethod = "PPMd";
+static const char *kAESMethod = "AES";
+static const char *kZipCryptoMethod = "ZipCrypto";
+static const char *kStrongCryptoMethod = "StrongCrypto";
+
+static struct CStrongCryptoPair
{
UInt16 Id;
const char *Name;
-};
-
-CStrongCryptoPair g_StrongCryptoPairs[] =
+} g_StrongCryptoPairs[] =
{
{ NStrongCryptoFlags::kDES, "DES" },
{ NStrongCryptoFlags::kRC2old, "RC2a" },
@@ -132,7 +106,25 @@ CStrongCryptoPair g_StrongCryptoPairs[] =
{ NStrongCryptoFlags::kRC4, "RC4" }
};
-STATPROPSTG kArcProps[] =
+static STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidEncrypted, VT_BOOL},
+ { NULL, kpidComment, VT_BSTR},
+ { NULL, kpidCRC, VT_UI4},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidUnpackVer, VT_UI4}
+};
+
+static STATPROPSTG kArcProps[] =
{
{ NULL, kpidBit64, VT_BOOL},
{ NULL, kpidComment, VT_BSTR}
@@ -289,7 +281,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
method += ' ';
}
}
- if (methodId < kNumMethods)
+ if (methodId < sizeof(kMethods) / sizeof(kMethods[0]))
method += kMethods[methodId];
else switch (methodId)
{
@@ -316,6 +308,9 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = (item.MadeByVersion.HostOS < sizeof(kHostOS) / sizeof(kHostOS[0])) ?
(kHostOS[item.MadeByVersion.HostOS]) : kUnknownOS;
break;
+ case kpidUnpackVer:
+ prop = (UInt32)item.ExtractVersion.Version;
+ break;
}
prop.Detach(value);
return S_OK;
@@ -637,7 +632,7 @@ HRESULT CZipDecoder::Decode(
}
}
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
{
CMyComPtr<ICompressSetCoderMt> setCoderMt;
coder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h
index 1a3a441a..6236b20c 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.h
+++ b/CPP/7zip/Archive/Zip/ZipHandler.h
@@ -12,7 +12,7 @@
#include "ZipIn.h"
#include "ZipCompressionMode.h"
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
#include "../../../Windows/System.h"
#endif
@@ -63,7 +63,7 @@ private:
bool m_ForseLocal;
bool m_ForseUtf8;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
UInt32 _numThreads;
#endif
@@ -85,7 +85,7 @@ private:
m_WriteNtfsTimeExtra = false;
m_ForseLocal = false;
m_ForseUtf8 = false;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
_numThreads = NWindows::NSystem::GetNumberOfProcessors();;
#endif
}
diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index 22d8eeea..3571fdeb 100755
--- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -297,7 +297,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
options.NumMatchFinderCycles = m_NumMatchFinderCycles;
options.NumMatchFinderCyclesDefined = m_NumMatchFinderCyclesDefined;
options.Algo = m_Algo;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
options.NumThreads = _numThreads;
#endif
if (isLz)
@@ -357,7 +357,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties)
{
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
_numThreads = numProcessors;
#endif
@@ -467,7 +467,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
}
else if (name.Left(2) == L"MT")
{
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
RINOK(ParseMtProp(name.Mid(2), prop, numProcessors, _numThreads));
#endif
}
diff --git a/CPP/7zip/Archive/Zip/ZipHeader.h b/CPP/7zip/Archive/Zip/ZipHeader.h
index 4839f554..1233af6c 100755
--- a/CPP/7zip/Archive/Zip/ZipHeader.h
+++ b/CPP/7zip/Archive/Zip/ZipHeader.h
@@ -80,10 +80,17 @@ namespace NFileHeader
const int kNumCompressionMethods = 11;
const Byte kMadeByProgramVersion = 20;
- const Byte kDeflateExtractVersion = 20;
- const Byte kStoreExtractVersion = 10;
+ const Byte kExtractVersion_Default = 10;
+ const Byte kExtractVersion_Dir = 20;
+ const Byte kExtractVersion_ZipCrypto = 20;
+ const Byte kExtractVersion_Deflate = 20;
+ const Byte kExtractVersion_Deflate64 = 21;
+ const Byte kExtractVersion_Zip64 = 45;
+ const Byte kExtractVersion_BZip2 = 46;
+ const Byte kExtractVersion_Aes = 51;
+ const Byte kExtractVersion_LZMA = 63;
- const Byte kSupportedVersion = 20;
+ // const Byte kSupportedVersion = 20;
}
namespace NExtraID
diff --git a/CPP/7zip/Archive/Zip/ZipOut.cpp b/CPP/7zip/Archive/Zip/ZipOut.cpp
index 5b1bdeee..0807369c 100755
--- a/CPP/7zip/Archive/Zip/ZipOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipOut.cpp
@@ -2,10 +2,9 @@
#include "StdAfx.h"
-#include "ZipOut.h"
-#include "Common/StringConvert.h"
#include "../../Common/OffsetStream.h"
-#include "../../Common/StreamUtils.h"
+
+#include "ZipOut.h"
namespace NArchive {
namespace NZip {
@@ -115,7 +114,12 @@ void COutArchive::WriteLocalHeader(const CLocalItem &item)
bool isZip64 = m_IsZip64 || item.PackSize >= 0xFFFFFFFF || item.UnPackSize >= 0xFFFFFFFF;
WriteUInt32(NSignature::kLocalFileHeader);
- WriteByte(item.ExtractVersion.Version);
+ {
+ Byte ver = item.ExtractVersion.Version;
+ if (isZip64 && ver < NFileHeader::NCompressionMethod::kExtractVersion_Zip64)
+ ver = NFileHeader::NCompressionMethod::kExtractVersion_Zip64;
+ WriteByte(ver);
+ }
WriteByte(item.ExtractVersion.HostOS);
WriteUInt16(item.Flags);
WriteUInt16(item.CompressionMethod);
@@ -162,7 +166,12 @@ void COutArchive::WriteCentralHeader(const CItem &item)
WriteUInt32(NSignature::kCentralFileHeader);
WriteByte(item.MadeByVersion.Version);
WriteByte(item.MadeByVersion.HostOS);
- WriteByte(item.ExtractVersion.Version);
+ {
+ Byte ver = item.ExtractVersion.Version;
+ if (isZip64 && ver < NFileHeader::NCompressionMethod::kExtractVersion_Zip64)
+ ver = NFileHeader::NCompressionMethod::kExtractVersion_Zip64;
+ WriteByte(ver);
+ }
WriteByte(item.ExtractVersion.HostOS);
WriteUInt16(item.Flags);
WriteUInt16(item.CompressionMethod);
diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.cpp b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
index 056a8cd2..004e67f8 100755
--- a/CPP/7zip/Archive/Zip/ZipUpdate.cpp
+++ b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
@@ -13,7 +13,7 @@
#include "../../Common/LimitedStreams.h"
#include "../../Common/OutMemStream.h"
#include "../../Common/ProgressUtils.h"
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
#include "../../Common/ProgressMt.h"
#endif
@@ -40,7 +40,6 @@ static const Byte kMadeByHostOS = kHostOS;
static const Byte kExtractHostOS = kHostOS;
static const Byte kMethodForDirectory = NFileHeader::NCompressionMethod::kStored;
-static const Byte kExtractVersionForDirectory = NFileHeader::NCompressionMethod::kStoreExtractVersion;
static HRESULT CopyBlockToArchive(ISequentialInStream *inStream,
COutArchive &outArchive, ICompressProgressInfo *progress)
@@ -101,7 +100,7 @@ static void SetFileHeader(
item.SetEncrypted(!isDir && options.PasswordIsDefined);
if (isDir)
{
- item.ExtractVersion.Version = kExtractVersionForDirectory;
+ item.ExtractVersion.Version = NFileHeader::NCompressionMethod::kExtractVersion_Dir;
item.CompressionMethod = kMethodForDirectory;
item.PackSize = 0;
item.FileCRC = 0; // test it
@@ -134,7 +133,7 @@ static void SetItemInfoFromCompressingResult(const CCompressingResult &compressi
}
}
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo);
@@ -525,7 +524,7 @@ static HRESULT Update2(
complexity = 0;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
const size_t kNumMaxThreads = (1 << 10);
UInt32 numThreads = options->NumThreads;
@@ -584,7 +583,7 @@ static HRESULT Update2(
inputItems, updateItems, options, comment, updateCallback);
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
CObjectVector<CItem> items;
diff --git a/CPP/7zip/Asm.mak b/CPP/7zip/Asm.mak
new file mode 100755
index 00000000..4ab94f15
--- /dev/null
+++ b/CPP/7zip/Asm.mak
@@ -0,0 +1,7 @@
+!IF "$(CPU)" == "ARM"
+$(ASM_OBJS): ../../../../Asm/Arm/$(*B).asm
+ $(COMPL_ASM)
+!ELSEIF "$(CPU)" != "IA64" && "$(CPU)" != "MIPS"
+$(ASM_OBJS): ../../../../Asm/x86/$(*B).asm
+ $(COMPL_ASM)
+!ENDIF
diff --git a/CPP/7zip/Bundles/Alone/Alone.dsp b/CPP/7zip/Bundles/Alone/Alone.dsp
index 7c557105..4f57cba9 100755
--- a/CPP/7zip/Bundles/Alone/Alone.dsp
+++ b/CPP/7zip/Bundles/Alone/Alone.dsp
@@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "BREAK_HANDLER" /D "_7ZIP_LARGE_PAGES" /D "BENCH_MT" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "BREAK_HANDLER" /D "_7ZIP_LARGE_PAGES" /D "BENCH_MT" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -93,8 +93,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "ReleaseU"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "BREAK_HANDLER" /D "_7ZIP_LARGE_PAGES" /D "BENCH_MT" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -120,8 +120,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "DebugU"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "BREAK_HANDLER" /D "_7ZIP_LARGE_PAGES" /D "BENCH_MT" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -176,6 +176,14 @@ SOURCE=..\..\UI\Console\List.h
# End Source File
# Begin Source File
+SOURCE=..\..\UI\Console\BenchCon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\BenchCon.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\UI\Console\Main.cpp
# End Source File
# Begin Source File
@@ -1099,26 +1107,6 @@ SOURCE=..\..\Compress\QuantumDecoder.cpp
SOURCE=..\..\Compress\QuantumDecoder.h
# End Source File
# End Group
-# Begin Group "LZMA_Alone"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBenchCon.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBenchCon.h
-# End Source File
-# End Group
# Begin Source File
SOURCE=..\..\Compress\Bcj2Coder.cpp
@@ -1593,6 +1581,14 @@ SOURCE=..\..\Archive\Bz2Handler.cpp
# End Source File
# Begin Source File
+SOURCE=..\..\Archive\DeflateProps.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\DeflateProps.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Archive\GzHandler.cpp
# End Source File
# Begin Source File
@@ -1681,6 +1677,14 @@ SOURCE=..\..\UI\Common\LoadCodecs.h
# End Source File
# Begin Source File
+SOURCE=..\..\UI\Common\Bench.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Bench.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\UI\Common\OpenArchive.cpp
# End Source File
# Begin Source File
@@ -2136,6 +2140,30 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\7zStream.c
!IF "$(CFG)" == "Alone - Win32 Release"
@@ -2188,6 +2216,30 @@ SOURCE=..\..\..\..\C\Aes.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\AesOpt.c
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
!IF "$(CFG)" == "Alone - Win32 Release"
@@ -2329,6 +2381,30 @@ SOURCE=..\..\..\..\C\BwtSort.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+
+!IF "$(CFG)" == "Alone - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 ReleaseU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Alone - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\CpuArch.h
# End Source File
# Begin Source File
diff --git a/CPP/7zip/Bundles/Alone/makefile b/CPP/7zip/Bundles/Alone/makefile
index bd18aa73..ef6a33cb 100755
--- a/CPP/7zip/Bundles/Alone/makefile
+++ b/CPP/7zip/Bundles/Alone/makefile
@@ -1,17 +1,13 @@
PROG = 7za.exe
MY_CONSOLE = 1
-CFLAGS = $(CFLAGS) -I ../../../ \
- -DCOMPRESS_MT \
- -DCOMPRESS_BZIP2_MT \
- -DCOMPRESS_MF_MT \
- -DBREAK_HANDLER \
- -DBENCH_MT \
+CFLAGS = $(CFLAGS) -I ../../../
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
!ENDIF
CONSOLE_OBJS = \
+ $O\BenchCon.obj \
$O\ConsoleClose.obj \
$O\ExtractCallbackConsole.obj \
$O\List.obj \
@@ -78,6 +74,7 @@ UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
+ $O\Bench.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
@@ -202,10 +199,6 @@ COMPRESS_OBJS = \
$O\ShrinkDecoder.obj \
$O\ZDecoder.obj \
-LZMA_BENCH_OBJS = \
- $O\LzmaBench.obj \
- $O\LzmaBenchCon.obj \
-
CRYPTO_OBJS = \
$O\7zAes.obj \
$O\7zAesRegister.obj \
@@ -220,12 +213,12 @@ CRYPTO_OBJS = \
C_OBJS = \
$O\7zStream.obj \
- $O\Aes.obj \
$O\Alloc.obj \
$O\Bra.obj \
$O\Bra86.obj \
$O\BraIA64.obj \
$O\BwtSort.obj \
+ $O\CpuArch.obj \
$O\Delta.obj \
$O\HuffEnc.obj \
$O\LzFind.obj \
@@ -244,7 +237,8 @@ C_OBJS = \
$O\XzEnc.obj \
$O\XzIn.obj \
-!include "../../Crc2.mak"
+!include "../../Aes.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -264,7 +258,7 @@ OBJS = \
$(LZMA_BENCH_OBJS) \
$(CRYPTO_OBJS) \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -298,12 +292,10 @@ $(ZIP_OBJS): ../../Archive/Zip/$(*B).cpp
$(COMPRESS_OBJS): ../../Compress/$(*B).cpp
$(COMPL_O2)
-$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp
- $(COMPL)
-
$(CRYPTO_OBJS): ../../Crypto/$(*B).cpp
$(COMPL_O2)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/Alone7z/makefile b/CPP/7zip/Bundles/Alone7z/makefile
index 94d28509..2aefcbd0 100755
--- a/CPP/7zip/Bundles/Alone7z/makefile
+++ b/CPP/7zip/Bundles/Alone7z/makefile
@@ -1,17 +1,14 @@
PROG = 7zr.exe
MY_CONSOLE = 1
CFLAGS = $(CFLAGS) -I ../../../ \
- -DCOMPRESS_MT \
- -DCOMPRESS_MF_MT \
-D_NO_CRYPTO \
- -DBREAK_HANDLER \
- -DBENCH_MT \
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH
!ENDIF
CONSOLE_OBJS = \
+ $O\BenchCon.obj \
$O\ConsoleClose.obj \
$O\ExtractCallbackConsole.obj \
$O\List.obj \
@@ -75,6 +72,7 @@ UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
+ $O\Bench.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
@@ -146,16 +144,13 @@ COMPRESS_OBJS = \
$O\LzmaEncoder.obj \
$O\LzmaRegister.obj \
-LZMA_BENCH_OBJS = \
- $O\LzmaBench.obj \
- $O\LzmaBenchCon.obj \
-
C_OBJS = \
$O\7zStream.obj \
+ $O\Alloc.obj \
$O\Bra.obj \
$O\Bra86.obj \
$O\BraIA64.obj \
- $O\Alloc.obj \
+ $O\CpuArch.obj \
$O\Delta.obj \
$O\LzFind.obj \
$O\LzFindMt.obj \
@@ -172,7 +167,7 @@ C_OBJS = \
$O\XzEnc.obj \
$O\XzIn.obj \
-!include "../../Crc2.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -185,9 +180,8 @@ OBJS = \
$(AR_COMMON_OBJS) \
$(7Z_OBJS) \
$(COMPRESS_OBJS) \
- $(LZMA_BENCH_OBJS) \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -213,8 +207,7 @@ $(7Z_OBJS): ../../Archive/7z/$(*B).cpp
$(COMPL)
$(COMPRESS_OBJS): ../../Compress/$(*B).cpp
$(COMPL_O2)
-$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp
- $(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/Fm/FM.dsp b/CPP/7zip/Bundles/Fm/FM.dsp
index fa36bd66..6b08e9dc 100755
--- a/CPP/7zip/Bundles/Fm/FM.dsp
+++ b/CPP/7zip/Bundles/Fm/FM.dsp
@@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "EXTERNAL_LZMA" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -72,7 +72,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "EXTERNAL_LZMA" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -99,7 +99,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "EXTERNAL_LZMA" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -127,7 +127,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "EXTERNAL_LZMA" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -658,6 +658,31 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+
+!IF "$(CFG)" == "FM - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -667,6 +692,35 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+
+!IF "$(CFG)" == "FM - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\CpuArch.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Sha256.c
!IF "$(CFG)" == "FM - Win32 Release"
@@ -1196,6 +1250,14 @@ SOURCE=..\..\UI\Common\ArchiveOpenCallback.h
# End Source File
# Begin Source File
+SOURCE=..\..\UI\Common\Bench.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\Bench.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\UI\Common\CompressCall.h
# End Source File
# Begin Source File
@@ -1204,6 +1266,14 @@ SOURCE=..\..\UI\Common\CompressCall2.cpp
# End Source File
# Begin Source File
+SOURCE=..\..\Common\CreateCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\CreateCoder.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\UI\Common\DefaultName.cpp
# End Source File
# Begin Source File
@@ -1248,6 +1318,14 @@ SOURCE=..\..\UI\Common\ExtractMode.h
# End Source File
# Begin Source File
+SOURCE=..\..\Common\FilterCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilterCoder.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\UI\Common\IFileExtractCallback.h
# End Source File
# Begin Source File
@@ -1507,14 +1585,6 @@ SOURCE=..\..\Compress\CopyCoder.cpp
SOURCE=..\..\Compress\CopyCoder.h
# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.h
-# End Source File
# End Group
# Begin Group "Interface"
diff --git a/CPP/7zip/Bundles/Fm/makefile b/CPP/7zip/Bundles/Fm/makefile
index 47bc8eb3..3cd64c20 100755
--- a/CPP/7zip/Bundles/Fm/makefile
+++ b/CPP/7zip/Bundles/Fm/makefile
@@ -3,9 +3,6 @@ CFLAGS = $(CFLAGS) -I ../../../ \
-DLANG \
-DNEW_FOLDER_INTERFACE \
-DEXTERNAL_CODECS \
- -DCOMPRESS_MT \
- -DCOMPRESS_BZIP2_MT \
- -DCOMPRESS_MF_MT \
!IFDEF UNDER_CE
LIBS = $(LIBS) ceshell.lib Commctrl.lib
@@ -206,6 +203,7 @@ UI_COMMON_OBJS = \
$O\ArchiveExtractCallback.obj \
$O\ArchiveName.obj \
$O\ArchiveOpenCallback.obj \
+ $O\Bench.obj \
$O\CompressCall2.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
@@ -388,9 +386,6 @@ COMPRESS_OBJS = \
$O\ZlibEncoder.obj \
$O\ZDecoder.obj \
-LZMA_BENCH_OBJS = \
- $O\LzmaBench.obj \
-
CRYPTO_OBJS = \
$O\7zAes.obj \
$O\7zAesRegister.obj \
@@ -409,12 +404,12 @@ CRYPTO_OBJS = \
C_OBJS = \
$O\7zBuf2.obj \
$O\7zStream.obj \
- $O\Aes.obj \
$O\Alloc.obj \
$O\Bra.obj \
$O\Bra86.obj \
$O\BraIA64.obj \
$O\BwtSort.obj \
+ $O\CpuArch.obj \
$O\Delta.obj \
$O\HuffEnc.obj \
$O\LzFind.obj \
@@ -433,7 +428,8 @@ C_OBJS = \
$O\XzEnc.obj \
$O\XzIn.obj \
-!include "../../Crc2.mak"
+!include "../../Aes.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -461,10 +457,9 @@ OBJS = \
$(WIM_OBJS) \
$(ZIP_OBJS) \
$(COMPRESS_OBJS) \
- $(LZMA_BENCH_OBJS) \
$(CRYPTO_OBJS) \
- $(CRC_OBJS) \
$(C_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res \
!include "../../../Build.mak"
@@ -512,8 +507,6 @@ $(ZIP_OBJS): ../../Archive/Zip/$(*B).cpp
$(COMPRESS_OBJS): ../../Compress/$(*B).cpp
$(COMPL_O2)
-$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp
- $(COMPL)
$(CRYPTO_OBJS): ../../Crypto/$(*B).cpp
$(COMPL_O2)
@@ -530,4 +523,4 @@ $(GUI_OBJS): ../../UI/GUI/$(*B).cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/Format7z/makefile b/CPP/7zip/Bundles/Format7z/makefile
index a475bf9b..3a091e22 100755
--- a/CPP/7zip/Bundles/Format7z/makefile
+++ b/CPP/7zip/Bundles/Format7z/makefile
@@ -1,9 +1,6 @@
PROG = 7za.dll
DEF_FILE = ../../Archive/Archive2.def
CFLAGS = $(CFLAGS) -I ../../../ \
- -DCOMPRESS_MT \
- -DCOMPRESS_MF_MT \
- -DCOMPRESS_BZIP2_MT \
-DDEFLATE_EXTRACT_ONLY \
-DBZIP2_EXTRACT_ONLY \
@@ -121,6 +118,7 @@ C_OBJS = \
$O\Bra86.obj \
$O\BraIA64.obj \
$O\BwtSort.obj \
+ $O\CpuArch.obj \
$O\Delta.obj \
$O\HuffEnc.obj \
$O\LzFind.obj \
@@ -134,7 +132,8 @@ C_OBJS = \
$O\Sort.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Aes.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -148,7 +147,7 @@ OBJS = \
$(COMPRESS_OBJS) \
$(CRYPTO_OBJS) \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -177,4 +176,4 @@ $(CRYPTO_OBJS): ../../Crypto/$(*B).cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/Format7zExtract/makefile b/CPP/7zip/Bundles/Format7zExtract/makefile
index d082a007..6769be45 100755
--- a/CPP/7zip/Bundles/Format7zExtract/makefile
+++ b/CPP/7zip/Bundles/Format7zExtract/makefile
@@ -2,8 +2,6 @@ PROG = 7zxa.dll
DEF_FILE = ../../Archive/Archive2.def
CFLAGS = $(CFLAGS) -I ../../../ \
-DEXTRACT_ONLY \
- -DCOMPRESS_MT \
- -DCOMPRESS_BZIP2_MT \
COMMON_OBJS = \
$O\CRC.obj \
@@ -92,18 +90,19 @@ CRYPTO_OBJS = \
$O\MyAes.obj \
C_OBJS = \
- $O\Aes.obj \
$O\Alloc.obj \
$O\Bra.obj \
$O\Bra86.obj \
$O\BraIA64.obj \
+ $O\CpuArch.obj \
$O\Delta.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \
$O\Sha256.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Aes.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -117,7 +116,7 @@ OBJS = \
$(COMPRESS_OBJS) \
$(CRYPTO_OBJS) \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -146,4 +145,4 @@ $(CRYPTO_OBJS): ../../Crypto/$(*B).cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/Format7zExtractR/makefile b/CPP/7zip/Bundles/Format7zExtractR/makefile
index 5c5a9187..e953af90 100755
--- a/CPP/7zip/Bundles/Format7zExtractR/makefile
+++ b/CPP/7zip/Bundles/Format7zExtractR/makefile
@@ -2,7 +2,6 @@ PROG = 7zxr.dll
DEF_FILE = ../../Archive/Archive2.def
CFLAGS = $(CFLAGS) -I ../../../ \
-DEXTRACT_ONLY \
- -DCOMPRESS_MT \
-D_NO_CRYPTO
COMMON_OBJS = \
@@ -81,16 +80,18 @@ COMPRESS_OBJS = \
$O\LzmaRegister.obj \
C_OBJS = \
- $O\7zCrc.obj \
$O\Alloc.obj \
$O\Bra.obj \
$O\Bra86.obj \
$O\BraIA64.obj \
+ $O\CpuArch.obj \
$O\Delta.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \
$O\Threads.obj \
+!include "../../Crc.mak"
+
OBJS = \
$O\StdAfx.obj \
$(CONSOLE_OBJS) \
@@ -102,6 +103,7 @@ OBJS = \
$(7Z_OBJS) \
$(COMPRESS_OBJS) \
$(C_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -126,3 +128,5 @@ $(COMPRESS_OBJS): ../../Compress/$(*B).cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
+
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/Format7zF/Format7z.dsp b/CPP/7zip/Bundles/Format7zF/Format7z.dsp
index 8785faaf..fd992ae0 100755
--- a/CPP/7zip/Bundles/Format7zF/Format7z.dsp
+++ b/CPP/7zip/Bundles/Format7zF/Format7z.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gr /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "NO_REGISTRY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "_LZMA_PROB32_" /FAcs /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gr /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "NO_REGISTRY" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /FAcs /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -70,7 +70,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gr /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "NO_REGISTRY" /D "COMPRESS_MF_MT" /D "COMPRESS_MT" /D "COMPRESS_BZIP2_MT" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "_LZMA_PROB32" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gr /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\SDK" /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "NO_REGISTRY" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -1316,6 +1316,11 @@ SOURCE=..\..\..\..\C\BwtSort.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\CpuArch.h
# End Source File
# Begin Source File
@@ -2175,6 +2180,10 @@ SOURCE=..\..\Archive\Udf\UdfRegister.cpp
# End Group
# Begin Source File
+SOURCE=..\..\Archive\ApmHandler.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Archive\ArjHandler.cpp
# End Source File
# Begin Source File
@@ -2382,5 +2391,77 @@ SOURCE=..\..\..\Windows\Time.cpp
SOURCE=..\..\..\Windows\Time.h
# End Source File
# End Group
+# Begin Group "Asm"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\Asm\x86\7zAsm.asm
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\Asm\x86\7zCrcOpt.asm
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# Begin Custom Build
+OutDir=.\Release
+InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
+InputName=7zCrcOpt
+
+"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ml.exe -c -Fo$(OutDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# Begin Custom Build
+OutDir=.\Debug
+InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
+InputName=7zCrcOpt
+
+"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ml.exe -c -omf -Fo$(OutDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\Asm\x86\AesOpt.asm
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build
+OutDir=.\Release
+InputPath=..\..\..\..\Asm\x86\AesOpt.asm
+InputName=AesOpt
+
+"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ml.exe -c -Fo$(OutDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build
+OutDir=.\Debug
+InputPath=..\..\..\..\Asm\x86\AesOpt.asm
+InputName=AesOpt
+
+"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ml.exe -c -omf -WX -W3 -Fo$(OutDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
# End Target
# End Project
diff --git a/CPP/7zip/Bundles/Format7zF/makefile b/CPP/7zip/Bundles/Format7zF/makefile
index 7c35791e..fe0791a5 100755
--- a/CPP/7zip/Bundles/Format7zF/makefile
+++ b/CPP/7zip/Bundles/Format7zF/makefile
@@ -2,9 +2,6 @@ PROG = 7z.dll
DEF_FILE = ../../Archive/Archive2.def
CFLAGS = $(CFLAGS) -I ../../../ \
-DEXTERNAL_CODECS \
- -DCOMPRESS_MT \
- -DCOMPRESS_BZIP2_MT \
- -DCOMPRESS_MF_MT \
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -D_7ZIP_LARGE_PAGES
@@ -57,6 +54,7 @@ WIN_OBJS = \
AR_OBJS = \
$O\ArchiveExports.obj \
$O\DllExports2.obj \
+ $O\ApmHandler.obj \
$O\ArjHandler.obj \
$O\Bz2Handler.obj \
$O\CpioHandler.obj \
@@ -257,12 +255,12 @@ CRYPTO_OBJS = \
C_OBJS = \
$O\7zBuf2.obj \
$O\7zStream.obj \
- $O\Aes.obj \
$O\Alloc.obj \
$O\Bra.obj \
$O\Bra86.obj \
$O\BraIA64.obj \
$O\BwtSort.obj \
+ $O\CpuArch.obj \
$O\Delta.obj \
$O\HuffEnc.obj \
$O\LzFind.obj \
@@ -281,7 +279,8 @@ C_OBJS = \
$O\XzEnc.obj \
$O\XzIn.obj \
-!include "../../Crc2.mak"
+!include "../../Aes.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -306,7 +305,7 @@ OBJS = \
$(COMPRESS_OBJS) \
$(CRYPTO_OBJS) \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -357,4 +356,4 @@ $(CRYPTO_OBJS): ../../Crypto/$(*B).cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/Format7zR/makefile b/CPP/7zip/Bundles/Format7zR/makefile
index a286303d..d7ffcea1 100755
--- a/CPP/7zip/Bundles/Format7zR/makefile
+++ b/CPP/7zip/Bundles/Format7zR/makefile
@@ -1,8 +1,6 @@
PROG = 7zra.dll
DEF_FILE = ../../Archive/Archive2.def
CFLAGS = $(CFLAGS) -I ../../../ \
- -DCOMPRESS_MT \
- -DCOMPRESS_MF_MT \
-D_NO_CRYPTO
COMMON_OBJS = \
@@ -94,11 +92,11 @@ COMPRESS_OBJS = \
$O\LzmaRegister.obj \
C_OBJS = \
- $O\7zCrc.obj \
$O\Alloc.obj \
$O\Bra.obj \
$O\Bra86.obj \
$O\BraIA64.obj \
+ $O\CpuArch.obj \
$O\Delta.obj \
$O\LzFind.obj \
$O\LzFindMt.obj \
@@ -109,6 +107,8 @@ C_OBJS = \
$O\MtCoder.obj \
$O\Threads.obj \
+!include "../../Crc.mak"
+
OBJS = \
$O\StdAfx.obj \
$(CONSOLE_OBJS) \
@@ -120,6 +120,7 @@ OBJS = \
$(7Z_OBJS) \
$(COMPRESS_OBJS) \
$(C_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -144,3 +145,5 @@ $(COMPRESS_OBJS): ../../Compress/$(*B).cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
+
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/CPP/7zip/Bundles/LzmaCon/LzmaAlone.cpp
index 90476378..01c6c7cd 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
+++ b/CPP/7zip/Bundles/LzmaCon/LzmaAlone.cpp
@@ -2,9 +2,6 @@
#include "StdAfx.h"
-#include "../../../Common/MyWindows.h"
-#include "../../../Common/MyInitGuid.h"
-
#include <stdio.h>
#if (defined(_WIN32) || defined(OS2) || defined(MSDOS)) && !defined(UNDER_CE)
@@ -15,27 +12,31 @@
#define MY_SET_BINARY_MODE(file)
#endif
+// #include "../../../Common/MyWindows.h"
+#include "../../../Common/MyInitGuid.h"
+
+#include "../../../../C/7zVersion.h"
+#include "../../../../C/Alloc.h"
+#include "../../../../C/Lzma86.h"
+
+#include "../../../Windows/NtCheck.h"
+
+#ifndef _7ZIP_ST
+#include "../../../Windows/System.h"
+#endif
+
#include "../../../Common/CommandLineParser.h"
#include "../../../Common/StringConvert.h"
#include "../../../Common/StringToInt.h"
-#include "../../../Windows/NtCheck.h"
-
#include "../../Common/FileStreams.h"
#include "../../Common/StreamUtils.h"
-#include "../LzmaDecoder.h"
-#include "../LzmaEncoder.h"
-
-#include "LzmaBenchCon.h"
+#include "../../Compress/LzmaDecoder.h"
+#include "../../Compress/LzmaEncoder.h"
-#ifdef COMPRESS_MF_MT
-#include "../../../Windows/System.h"
-#endif
+#include "../../UI/Console/BenchCon.h"
-#include "../../../../C/7zVersion.h"
-#include "../../../../C/Alloc.h"
-#include "../../../../C/Lzma86.h"
using namespace NCommandLineParser;
@@ -213,7 +214,7 @@ int main2(int numArgs, const char *args[])
UInt32 numThreads = (UInt32)-1;
- #ifdef COMPRESS_MF_MT
+ #ifndef _7ZIP_ST
if (parser[NKey::kMultiThread].ThereIs)
{
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
diff --git a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp b/CPP/7zip/Bundles/LzmaCon/LzmaCon.dsp
index 6c31e3ea..e171539d 100755
--- a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp
+++ b/CPP/7zip/Bundles/LzmaCon/LzmaCon.dsp
@@ -1,26 +1,24 @@
-# Microsoft Developer Studio Project File - Name="AloneLZMA" - Package Owner=<4>
+# Microsoft Developer Studio Project File - Name="LzmaCon" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
-CFG=AloneLZMA - Win32 DebugU
+CFG=LzmaCon - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
-!MESSAGE NMAKE /f "AloneLZMA.mak".
+!MESSAGE NMAKE /f "LzmaCon.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
-!MESSAGE NMAKE /f "AloneLZMA.mak" CFG="AloneLZMA - Win32 DebugU"
+!MESSAGE NMAKE /f "LzmaCon.mak" CFG="LzmaCon - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
-!MESSAGE "AloneLZMA - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "AloneLZMA - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "AloneLZMA - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
-!MESSAGE "AloneLZMA - Win32 DebugU" (based on "Win32 (x86) Console Application")
+!MESSAGE "LzmaCon - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "LzmaCon - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
@@ -30,7 +28,7 @@ CFG=AloneLZMA - Win32 DebugU
CPP=cl.exe
RSC=rc.exe
-!IF "$(CFG)" == "AloneLZMA - Win32 Release"
+!IF "$(CFG)" == "LzmaCon - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
@@ -44,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /FAcs /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gr /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -52,10 +50,9 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"C:\Util\lzma.exe"
-!ELSEIF "$(CFG)" == "AloneLZMA - Win32 Debug"
+!ELSEIF "$(CFG)" == "LzmaCon - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
@@ -69,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -77,68 +74,14 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
-
-!ELSEIF "$(CFG)" == "AloneLZMA - Win32 ReleaseU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ReleaseU"
-# PROP BASE Intermediate_Dir "ReleaseU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "ReleaseU"
-# PROP Intermediate_Dir "ReleaseU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /c
-# ADD BASE RSC /l 0x419 /d "NDEBUG"
-# ADD RSC /l 0x419 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\7za2.exe" /opt:NOWIN98
-# SUBTRACT BASE LINK32 /pdb:none
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "AloneLZMA - Win32 DebugU"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "DebugU"
-# PROP BASE Intermediate_Dir "DebugU"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "DebugU"
-# PROP Intermediate_Dir "DebugU"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c
-# ADD BASE RSC /l 0x419 /d "_DEBUG"
-# ADD RSC /l 0x419 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za2.exe" /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"C:\Util\lzma.exe" /pdbtype:sept
!ENDIF
# Begin Target
-# Name "AloneLZMA - Win32 Release"
-# Name "AloneLZMA - Win32 Debug"
-# Name "AloneLZMA - Win32 ReleaseU"
-# Name "AloneLZMA - Win32 DebugU"
+# Name "LzmaCon - Win32 Release"
+# Name "LzmaCon - Win32 Debug"
# Begin Group "Spec"
# PROP Default_Filter ""
@@ -155,27 +98,27 @@ SOURCE=.\StdAfx.h
# Begin Group "Compress"
# PROP Default_Filter ""
-# Begin Group "LZMA"
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\Compress\LzmaDecoder.cpp
+# End Source File
# Begin Source File
-SOURCE=..\LzmaDecoder.cpp
+SOURCE=..\..\Compress\LzmaDecoder.h
# End Source File
# Begin Source File
-SOURCE=..\LzmaDecoder.h
+SOURCE=..\..\Compress\LzmaEncoder.cpp
# End Source File
# Begin Source File
-SOURCE=..\LzmaEncoder.cpp
+SOURCE=..\..\Compress\LzmaEncoder.h
# End Source File
# Begin Source File
-SOURCE=..\LzmaEncoder.h
+SOURCE=..\..\Compress\LzmaRegister.cpp
# End Source File
# End Group
-# End Group
# Begin Group "Windows"
# PROP Default_Filter ""
@@ -221,15 +164,15 @@ SOURCE=..\..\..\Common\CommandLineParser.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\CRC.cpp
+SOURCE=..\..\..\Common\ComTry.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Defs.h
+SOURCE=..\..\..\Common\CRC.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Defs.h
+SOURCE=..\..\..\Common\Defs.h
# End Source File
# Begin Source File
@@ -253,6 +196,10 @@ SOURCE=..\..\..\Common\MyString.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Common\MyUnknown.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Common\MyVector.cpp
# End Source File
# Begin Source File
@@ -261,6 +208,10 @@ SOURCE=..\..\..\Common\MyVector.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Common\MyWindows.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Common\MyWindows.h
# End Source File
# Begin Source File
@@ -297,6 +248,14 @@ SOURCE=..\..\..\Common\Types.h
# PROP Default_Filter ""
# Begin Source File
+SOURCE=..\..\Common\CreateCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\CreateCoder.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Common\CWrappers.cpp
# End Source File
# Begin Source File
@@ -313,36 +272,64 @@ SOURCE=..\..\Common\FileStreams.h
# End Source File
# Begin Source File
-SOURCE=..\..\Common\InBuffer.cpp
+SOURCE=..\..\Common\FilterCoder.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\InBuffer.h
+SOURCE=..\..\Common\FilterCoder.h
# End Source File
# Begin Source File
-SOURCE=..\..\Common\OutBuffer.cpp
+SOURCE=..\..\Common\StreamUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\OutBuffer.h
+SOURCE=..\..\Common\StreamUtils.h
# End Source File
+# End Group
+# Begin Group "UI Common"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\Common\StreamUtils.cpp
+SOURCE=..\..\UI\Common\Bench.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\StreamUtils.h
+SOURCE=..\..\UI\Common\Bench.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\LoadCodecs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Common\LoadCodecs.h
# End Source File
# End Group
-# Begin Group "C"
+# Begin Group "Console"
# PROP Default_Filter ""
-# Begin Group "LzmaUtil"
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\UI\Console\BenchCon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\BenchCon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ConsoleClose.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\UI\Console\ConsoleClose.h
+# End Source File
# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\..\C\7zCrc.c
@@ -354,6 +341,11 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -363,6 +355,11 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\Bra.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Bra.h
# End Source File
# Begin Source File
@@ -372,6 +369,20 @@ SOURCE=..\..\..\..\C\Bra86.c
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\BraIA64.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\CpuArch.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\CpuArch.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\LzFind.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -440,27 +451,7 @@ SOURCE=..\..\..\..\C\Types.h
# End Group
# Begin Source File
-SOURCE=..\..\ICoder.h
-# End Source File
-# Begin Source File
-
SOURCE=.\LzmaAlone.cpp
# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaBench.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaBench.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaBenchCon.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\LzmaBenchCon.h
-# End Source File
# End Target
# End Project
diff --git a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsw b/CPP/7zip/Bundles/LzmaCon/LzmaCon.dsw
index d7482d8a..e62c9d2f 100755
--- a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsw
+++ b/CPP/7zip/Bundles/LzmaCon/LzmaCon.dsw
@@ -3,7 +3,7 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
###############################################################################
-Project: "AloneLZMA"=.\AloneLZMA.dsp - Package Owner=<4>
+Project: "LzmaCon"=.\LzmaCon.dsp - Package Owner=<4>
Package=<5>
{{{
diff --git a/CPP/7zip/Compress/LZMA_Alone/StdAfx.cpp b/CPP/7zip/Bundles/LzmaCon/StdAfx.cpp
index d0feea85..d0feea85 100755
--- a/CPP/7zip/Compress/LZMA_Alone/StdAfx.cpp
+++ b/CPP/7zip/Bundles/LzmaCon/StdAfx.cpp
diff --git a/CPP/7zip/Compress/LZMA_Alone/StdAfx.h b/CPP/7zip/Bundles/LzmaCon/StdAfx.h
index e7fb6986..e7fb6986 100755
--- a/CPP/7zip/Compress/LZMA_Alone/StdAfx.h
+++ b/CPP/7zip/Bundles/LzmaCon/StdAfx.h
diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile b/CPP/7zip/Bundles/LzmaCon/makefile
index 197b0ee6..4a76bbde 100755
--- a/CPP/7zip/Compress/LZMA_Alone/makefile
+++ b/CPP/7zip/Bundles/LzmaCon/makefile
@@ -1,17 +1,14 @@
PROG = lzma.exe
MY_CONSOLE = 1
-CFLAGS = $(CFLAGS) \
- -DCOMPRESS_MF_MT \
- -DBENCH_MT \
+CFLAGS = $(CFLAGS)
LZMA_OBJS = \
$O\LzmaAlone.obj \
- $O\LzmaBench.obj \
- $O\LzmaBenchCon.obj \
-LZMA_OPT_OBJS = \
+COMPRESS_OBJS = \
$O\LzmaDecoder.obj \
$O\LzmaEncoder.obj \
+ $O\LzmaRegister.obj \
COMMON_OBJS = \
$O\CommandLineParser.obj \
@@ -23,18 +20,28 @@ COMMON_OBJS = \
$O\MyVector.obj
WIN_OBJS = \
+ $O\FileIO.obj \
$O\System.obj
7ZIP_COMMON_OBJS = \
$O\CWrappers.obj \
- $O\InBuffer.obj \
+ $O\CreateCoder.obj \
+ $O\FileStreams.obj \
+ $O\FilterCoder.obj \
$O\OutBuffer.obj \
$O\StreamUtils.obj \
+UI_COMMON_OBJS = \
+ $O\Bench.obj \
+
+CONSOLE_OBJS = \
+ $O\ConsoleClose.obj \
+ $O\BenchCon.obj \
+
C_OBJS = \
- $O\7zCrc.obj \
$O\Alloc.obj \
$O\Bra86.obj \
+ $O\CpuArch.obj \
$O\LzFind.obj \
$O\LzFindMt.obj \
$O\Lzma86Dec.obj \
@@ -43,23 +50,26 @@ C_OBJS = \
$O\LzmaEnc.obj \
$O\Threads.obj \
+!include "../../Crc.mak"
+
OBJS = \
$O\StdAfx.obj \
$(LZMA_OBJS) \
- $(LZMA_OPT_OBJS) \
+ $(COMPRESS_OBJS) \
$(COMMON_OBJS) \
$(WIN_OBJS) \
$(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $(CONSOLE_OBJS) \
$(C_OBJS) \
- $O\FileStreams.obj \
- $O\FileIO.obj \
+ $(ASM_OBJS) \
!include "../../../Build.mak"
$(LZMA_OBJS): $(*B).cpp
$(COMPL)
-$(LZMA_OPT_OBJS): ../$(*B).cpp
+$(COMPRESS_OBJS): ../../Compress/$(*B).cpp
$(COMPL_O2)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)
@@ -67,9 +77,11 @@ $(WIN_OBJS): ../../../Windows/$(*B).cpp
$(COMPL)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)
-$O\FileStreams.obj: ../../Common/FileStreams.cpp
+$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
$(COMPL)
-$O\FileIO.obj: ../../../Windows/FileIO.cpp
+$(CONSOLE_OBJS): ../../UI/Console/$(*B).cpp
$(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
+
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc b/CPP/7zip/Bundles/LzmaCon/makefile.gcc
index 288ed33a..32c85f15 100755
--- a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
+++ b/CPP/7zip/Bundles/LzmaCon/makefile.gcc
@@ -3,7 +3,7 @@ CXX = g++ -O2 -Wall
CXX_C = gcc -O2 -Wall
LIB = -lm
RM = rm -f
-CFLAGS = -c
+CFLAGS = -c -D_7ZIP_ST
ifdef SystemDrive
IS_MINGW = 1
@@ -20,14 +20,16 @@ endif
OBJS = \
LzmaAlone.o \
- LzmaBench.o \
- LzmaBenchCon.o \
+ Bench.o \
+ BenchCon.o \
+ ConsoleClose.o \
LzmaDecoder.o \
LzmaEncoder.o \
+ LzmaRegister.o \
+ CreateCoder.o \
CWrappers.o \
- InBuffer.o \
- OutBuffer.o \
FileStreams.o \
+ FilterCoder.o \
StreamUtils.o \
$(FILE_IO).o \
CommandLineParser.o \
@@ -38,8 +40,10 @@ OBJS = \
StringToInt.o \
MyVector.o \
7zCrc.o \
+ 7zCrcOpt.o \
Alloc.o \
Bra86.o \
+ CpuArch.o \
LzFind.o \
LzmaDec.o \
LzmaEnc.o \
@@ -55,30 +59,36 @@ $(PROG): $(OBJS)
LzmaAlone.o: LzmaAlone.cpp
$(CXX) $(CFLAGS) LzmaAlone.cpp
-LzmaBench.o: LzmaBench.cpp
- $(CXX) $(CFLAGS) LzmaBench.cpp
+Bench.o: ../../UI/Common/Bench.cpp
+ $(CXX) $(CFLAGS) ../../UI/Common/Bench.cpp
-LzmaBenchCon.o: LzmaBenchCon.cpp
- $(CXX) $(CFLAGS) LzmaBenchCon.cpp
+BenchCon.o: ../../UI/Console/BenchCon.cpp
+ $(CXX) $(CFLAGS) ../../UI/Console/BenchCon.cpp
-LzmaDecoder.o: ../LzmaDecoder.cpp
- $(CXX) $(CFLAGS) ../LzmaDecoder.cpp
+ConsoleClose.o: ../../UI/Console/ConsoleClose.cpp
+ $(CXX) $(CFLAGS) ../../UI/Console/ConsoleClose.cpp
-LzmaEncoder.o: ../LzmaEncoder.cpp
- $(CXX) $(CFLAGS) ../LzmaEncoder.cpp
+LzmaDecoder.o: ../../Compress/LzmaDecoder.cpp
+ $(CXX) $(CFLAGS) ../../Compress/LzmaDecoder.cpp
-CWrappers.o: ../../Common/CWrappers.cpp
- $(CXX) $(CFLAGS) ../../Common/CWrappers.cpp
+LzmaEncoder.o: ../../Compress/LzmaEncoder.cpp
+ $(CXX) $(CFLAGS) ../../Compress/LzmaEncoder.cpp
-InBuffer.o: ../../Common/InBuffer.cpp
- $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
+LzmaRegister.o: ../../Compress/LzmaRegister.cpp
+ $(CXX) $(CFLAGS) ../../Compress/LzmaRegister.cpp
-OutBuffer.o: ../../Common/OutBuffer.cpp
- $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
+CreateCoder.o: ../../Common/CreateCoder.cpp
+ $(CXX) $(CFLAGS) ../../Common/CreateCoder.cpp
+
+CWrappers.o: ../../Common/CWrappers.cpp
+ $(CXX) $(CFLAGS) ../../Common/CWrappers.cpp
FileStreams.o: ../../Common/FileStreams.cpp
$(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
+FilterCoder.o: ../../Common/FilterCoder.cpp
+ $(CXX) $(CFLAGS) ../../Common/FilterCoder.cpp
+
StreamUtils.o: ../../Common/StreamUtils.cpp
$(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
@@ -113,12 +123,18 @@ MyVector.o: ../../../Common/MyVector.cpp
7zCrc.o: ../../../../C/7zCrc.c
$(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
+7zCrcOpt.o: ../../../../C/7zCrcOpt.c
+ $(CXX_C) $(CFLAGS) ../../../../C/7zCrcOpt.c
+
Alloc.o: ../../../../C/Alloc.c
$(CXX_C) $(CFLAGS) ../../../../C/Alloc.c
Bra86.o: ../../../../C/Bra86.c
$(CXX_C) $(CFLAGS) ../../../../C/Bra86.c
+CpuArch.o: ../../../../C/CpuArch.c
+ $(CXX_C) $(CFLAGS) ../../../../C/CpuArch.c
+
LzFind.o: ../../../../C/LzFind.c
$(CXX_C) $(CFLAGS) ../../../../C/LzFind.c
diff --git a/CPP/7zip/Bundles/SFXCon/SFXCon.dsp b/CPP/7zip/Bundles/SFXCon/SFXCon.dsp
index c4e367f6..6c624f8d 100755
--- a/CPP/7zip/Bundles/SFXCon/SFXCon.dsp
+++ b/CPP/7zip/Bundles/SFXCon/SFXCon.dsp
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "COMPRESS_BCJ2" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "_SFX" /D "NO_READ_FROM_CODER" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "EXTRACT_ONLY" /D "_SFX" /D "NO_READ_FROM_CODER" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -710,6 +710,11 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Aes.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -719,6 +724,11 @@ SOURCE=..\..\..\..\C\Aes.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\AesOpt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -737,6 +747,11 @@ SOURCE=..\..\..\..\C\Bra86.c
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Lzma2Dec.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
diff --git a/CPP/7zip/Bundles/SFXCon/makefile b/CPP/7zip/Bundles/SFXCon/makefile
index eadd5684..f465db5a 100755
--- a/CPP/7zip/Bundles/SFXCon/makefile
+++ b/CPP/7zip/Bundles/SFXCon/makefile
@@ -38,7 +38,7 @@ WIN_OBJS = \
$O\FileName.obj \
$O\PropVariant.obj \
$O\PropVariantConversions.obj \
- $O\Synchronization.obj
+ $O\Synchronization.obj \
7ZIP_COMMON_OBJS = \
$O\CreateCoder.obj \
@@ -103,15 +103,16 @@ CRYPTO_OBJS = \
$O\MyAes.obj \
C_OBJS = \
- $O\Aes.obj \
$O\Alloc.obj \
$O\Bra86.obj \
+ $O\CpuArch.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \
$O\Sha256.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Aes.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -126,7 +127,7 @@ OBJS = \
$(COMPRESS_OBJS) \
$(CRYPTO_OBJS) \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -157,4 +158,4 @@ $(CRYPTO_OBJS): ../../Crypto/$(*B).cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp
index 61ec0470..53b59569 100755
--- a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp
+++ b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp
@@ -97,7 +97,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "ReleaseD"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "_SFX" /Yu"StdAfx.h" /FD /c
+# ADD BASE CPP /nologo /MD /W3 /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "_SFX" /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "NO_REGISTRY" /D "_SFX" /D "_NO_CRYPTO" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -650,6 +650,11 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -668,6 +673,15 @@ SOURCE=..\..\..\..\C\Bra86.c
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\CpuArch.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\LzmaDec.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
diff --git a/CPP/7zip/Bundles/SFXSetup/makefile b/CPP/7zip/Bundles/SFXSetup/makefile
index a3c2b12c..b2b892dc 100755
--- a/CPP/7zip/Bundles/SFXSetup/makefile
+++ b/CPP/7zip/Bundles/SFXSetup/makefile
@@ -92,10 +92,11 @@ COMPRESS_OBJS = \
C_OBJS = \
$O\Alloc.obj \
$O\Bra86.obj \
+ $O\CpuArch.obj \
$O\LzmaDec.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -111,7 +112,7 @@ OBJS = \
$(COMPRESS_OBJS) \
$O\MyMessages.obj \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -146,4 +147,4 @@ $O\MyMessages.obj: ../../UI/Explorer/MyMessages.cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp
index f41bc029..b4dedf32 100755
--- a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp
+++ b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp
@@ -97,7 +97,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "SFXWin___Win32_ReleaseD"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_PPMD" /D "_SFX" /D "CRYPTO_7ZAES" /D "CRYPTO_AES" /Yu"StdAfx.h" /FD /c
+# ADD BASE CPP /nologo /Gz /MT /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "_SFX" /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_SFXWIN32" /D "_WINDOWS" /D "_MBCS" /D "EXTRACT_ONLY" /D "NO_REGISTRY" /D "NO_READ_FROM_CODER" /D "_SFX" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -770,6 +770,11 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Aes.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -779,6 +784,11 @@ SOURCE=..\..\..\..\C\Aes.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\AesOpt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -797,6 +807,11 @@ SOURCE=..\..\..\..\C\Bra86.c
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Lzma2Dec.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
diff --git a/CPP/7zip/Bundles/SFXWin/makefile b/CPP/7zip/Bundles/SFXWin/makefile
index 5668fc13..94793df3 100755
--- a/CPP/7zip/Bundles/SFXWin/makefile
+++ b/CPP/7zip/Bundles/SFXWin/makefile
@@ -120,15 +120,16 @@ CRYPTO_OBJS = \
$O\MyAes.obj \
C_OBJS = \
- $O\Aes.obj \
$O\Alloc.obj \
$O\Bra86.obj \
+ $O\CpuArch.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \
$O\Sha256.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Aes.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -146,7 +147,7 @@ OBJS = \
$(CRYPTO_OBJS) \
$O\MyMessages.obj \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
@@ -184,4 +185,4 @@ $O\MyMessages.obj: ../../UI/Explorer/MyMessages.cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/Bundles/makefile b/CPP/7zip/Bundles/makefile
index 6a4f16cd..e3b4b88f 100755
--- a/CPP/7zip/Bundles/makefile
+++ b/CPP/7zip/Bundles/makefile
@@ -7,6 +7,7 @@ DIRS = \
Format7zR\~ \
Format7zExtract\~ \
Format7zExtractR\~ \
+ LzmaCon\~ \
SFXCon\~ \
SFXSetup\~ \
SFXWin\~ \
diff --git a/CPP/7zip/Common/CreateCoder.cpp b/CPP/7zip/Common/CreateCoder.cpp
index 2742495d..cc82a0db 100755
--- a/CPP/7zip/Common/CreateCoder.cpp
+++ b/CPP/7zip/Common/CreateCoder.cpp
@@ -2,10 +2,11 @@
#include "StdAfx.h"
+#include "../../Windows/Defs.h"
+#include "../../Windows/PropVariant.h"
+
#include "CreateCoder.h"
-#include "../../Windows/PropVariant.h"
-#include "../../Windows/Defs.h"
#include "FilterCoder.h"
#include "RegisterCodec.h"
diff --git a/CPP/7zip/Common/CreateCoder.h b/CPP/7zip/Common/CreateCoder.h
index 1fcc1343..bf0e96a3 100755
--- a/CPP/7zip/Common/CreateCoder.h
+++ b/CPP/7zip/Common/CreateCoder.h
@@ -1,10 +1,10 @@
// CreateCoder.h
-#ifndef __CREATECODER_H
-#define __CREATECODER_H
+#ifndef __CREATE_CODER_H
+#define __CREATE_CODER_H
-#include "Common/MyCom.h"
-#include "Common/MyString.h"
+#include "../../Common/MyCom.h"
+#include "../../Common/MyString.h"
#include "../ICoder.h"
#include "MethodId.h"
diff --git a/CPP/7zip/Common/FilterCoder.cpp b/CPP/7zip/Common/FilterCoder.cpp
index d9911085..88bab018 100755
--- a/CPP/7zip/Common/FilterCoder.cpp
+++ b/CPP/7zip/Common/FilterCoder.cpp
@@ -14,6 +14,8 @@ static const UInt32 kBufferSize = 1 << 17;
CFilterCoder::CFilterCoder()
{
_buffer = (Byte *)::MidAlloc(kBufferSize);
+ if (_buffer == 0)
+ throw 1;
}
CFilterCoder::~CFilterCoder()
@@ -34,10 +36,8 @@ HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 siz
return S_OK;
}
-
-STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
- ICompressProgressInfo *progress)
+STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
{
RINOK(Init());
UInt32 bufferPos = 0;
@@ -45,7 +45,7 @@ STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
if (_outSizeIsDefined)
_outSize = *outSize;
- while(NeedMore())
+ while (!_outSizeIsDefined || _nowPos64 < _outSize)
{
size_t processedSize = kBufferSize - bufferPos;
@@ -57,16 +57,16 @@ STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
bufferPos = Filter->Filter(_buffer, endPos);
if (bufferPos > endPos)
{
- for (; endPos< bufferPos; endPos++)
+ for (; endPos < bufferPos; endPos++)
_buffer[endPos] = 0;
bufferPos = Filter->Filter(_buffer, endPos);
}
if (bufferPos == 0)
{
- if (endPos > 0)
- return WriteWithLimit(outStream, endPos);
- return S_OK;
+ if (endPos == 0)
+ return S_OK;
+ return WriteWithLimit(outStream, endPos);
}
RINOK(WriteWithLimit(outStream, bufferPos));
if (progress != NULL)
@@ -74,14 +74,13 @@ STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream,
RINOK(progress->SetRatioInfo(&_nowPos64, &_nowPos64));
}
UInt32 i = 0;
- while(bufferPos < endPos)
+ while (bufferPos < endPos)
_buffer[i++] = _buffer[bufferPos++];
bufferPos = i;
}
return S_OK;
}
-// #ifdef _ST_MODE
STDMETHODIMP CFilterCoder::SetOutStream(ISequentialOutStream *outStream)
{
_bufferPos = 0;
@@ -98,16 +97,15 @@ STDMETHODIMP CFilterCoder::ReleaseOutStream()
STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processedSize)
{
- UInt32 processedSizeTotal = 0;
- while(size > 0)
+ if (processedSize != NULL)
+ *processedSize = 0;
+ while (size > 0)
{
- UInt32 sizeMax = kBufferSize - _bufferPos;
- UInt32 sizeTemp = size;
- if (sizeTemp > sizeMax)
- sizeTemp = sizeMax;
- memmove(_buffer + _bufferPos, data, sizeTemp);
+ UInt32 sizeTemp = MyMin(size, kBufferSize - _bufferPos);
+ memcpy(_buffer + _bufferPos, data, sizeTemp);
size -= sizeTemp;
- processedSizeTotal += sizeTemp;
+ if (processedSize != NULL)
+ *processedSize += sizeTemp;
data = (const Byte *)data + sizeTemp;
UInt32 endPos = _bufferPos + sizeTemp;
_bufferPos = Filter->Filter(_buffer, endPos);
@@ -124,12 +122,10 @@ STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processe
}
RINOK(WriteWithLimit(_outStream, _bufferPos));
UInt32 i = 0;
- while(_bufferPos < endPos)
+ while (_bufferPos < endPos)
_buffer[i++] = _buffer[_bufferPos++];
_bufferPos = i;
}
- if (processedSize != NULL)
- *processedSize = processedSizeTotal;
return S_OK;
}
@@ -137,6 +133,7 @@ STDMETHODIMP CFilterCoder::Flush()
{
if (_bufferPos != 0)
{
+ // _buffer contains only data refused by previous Filter->Filter call.
UInt32 endPos = Filter->Filter(_buffer, _bufferPos);
if (endPos > _bufferPos)
{
@@ -145,13 +142,13 @@ STDMETHODIMP CFilterCoder::Flush()
if (Filter->Filter(_buffer, endPos) != endPos)
return E_FAIL;
}
- RINOK(WriteStream(_outStream, _buffer, _bufferPos));
+ RINOK(WriteWithLimit(_outStream, _bufferPos));
_bufferPos = 0;
}
CMyComPtr<IOutStreamFlush> flush;
_outStream.QueryInterface(IID_IOutStreamFlush, &flush);
if (flush)
- return flush->Flush();
+ return flush->Flush();
return S_OK;
}
@@ -171,37 +168,36 @@ STDMETHODIMP CFilterCoder::ReleaseInStream()
STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
{
- UInt32 processedSizeTotal = 0;
- while(size > 0)
+ if (processedSize != NULL)
+ *processedSize = 0;
+ while (size > 0)
{
if (_convertedPosBegin != _convertedPosEnd)
{
UInt32 sizeTemp = MyMin(size, _convertedPosEnd - _convertedPosBegin);
- memmove(data, _buffer + _convertedPosBegin, sizeTemp);
+ memcpy(data, _buffer + _convertedPosBegin, sizeTemp);
_convertedPosBegin += sizeTemp;
data = (void *)((Byte *)data + sizeTemp);
size -= sizeTemp;
- processedSizeTotal += sizeTemp;
+ if (processedSize != NULL)
+ *processedSize += sizeTemp;
break;
}
- int i;
+ UInt32 i;
for (i = 0; _convertedPosEnd + i < _bufferPos; i++)
- _buffer[i] = _buffer[i + _convertedPosEnd];
+ _buffer[i] = _buffer[_convertedPosEnd + i];
_bufferPos = i;
_convertedPosBegin = _convertedPosEnd = 0;
size_t processedSizeTemp = kBufferSize - _bufferPos;
RINOK(ReadStream(_inStream, _buffer + _bufferPos, &processedSizeTemp));
- _bufferPos = _bufferPos + (UInt32)processedSizeTemp;
+ _bufferPos += (UInt32)processedSizeTemp;
_convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
if (_convertedPosEnd == 0)
{
if (_bufferPos == 0)
break;
- else
- {
- _convertedPosEnd = _bufferPos; // check it
- continue;
- }
+ _convertedPosEnd = _bufferPos; // check it
+ continue;
}
if (_convertedPosEnd > _bufferPos)
{
@@ -210,13 +206,9 @@ STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
_convertedPosEnd = Filter->Filter(_buffer, _bufferPos);
}
}
- if (processedSize != NULL)
- *processedSize = processedSizeTotal;
return S_OK;
}
-// #endif // _ST_MODE
-
#ifndef _NO_CRYPTO
STDMETHODIMP CFilterCoder::CryptoSetPassword(const Byte *data, UInt32 size)
{
diff --git a/CPP/7zip/Common/FilterCoder.h b/CPP/7zip/Common/FilterCoder.h
index a0ec08ca..8132a6dd 100755
--- a/CPP/7zip/Common/FilterCoder.h
+++ b/CPP/7zip/Common/FilterCoder.h
@@ -1,7 +1,7 @@
// FilterCoder.h
-#ifndef __FILTERCODER_H
-#define __FILTERCODER_H
+#ifndef __FILTER_CODER_H
+#define __FILTER_CODER_H
#include "../../Common/MyCom.h"
#include "../ICoder.h"
@@ -13,13 +13,11 @@
class CFilterCoder:
public ICompressCoder,
- // #ifdef _ST_MODE
public ICompressSetInStream,
public ISequentialInStream,
public ICompressSetOutStream,
public ISequentialOutStream,
public IOutStreamFlush,
- // #endif
#ifndef _NO_CRYPTO
public ICryptoSetPassword,
@@ -35,13 +33,11 @@ class CFilterCoder:
{
protected:
Byte *_buffer;
- // #ifdef _ST_MODE
CMyComPtr<ISequentialInStream> _inStream;
CMyComPtr<ISequentialOutStream> _outStream;
UInt32 _bufferPos;
UInt32 _convertedPosBegin;
UInt32 _convertedPosEnd;
- // #endif
bool _outSizeIsDefined;
UInt64 _outSize;
UInt64 _nowPos64;
@@ -67,20 +63,14 @@ public:
CFilterCoder();
~CFilterCoder();
HRESULT WriteWithLimit(ISequentialOutStream *outStream, UInt32 size);
- bool NeedMore() const
- { return (!_outSizeIsDefined || (_nowPos64 < _outSize)); }
public:
- MY_QUERYINTERFACE_BEGIN
- MY_QUERYINTERFACE_ENTRY(ICompressCoder)
- // #ifdef _ST_MODE
+ MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
MY_QUERYINTERFACE_ENTRY(ISequentialInStream)
-
MY_QUERYINTERFACE_ENTRY(ICompressSetOutStream)
MY_QUERYINTERFACE_ENTRY(ISequentialOutStream)
MY_QUERYINTERFACE_ENTRY(IOutStreamFlush)
- // #endif
#ifndef _NO_CRYPTO
MY_QUERYINTERFACE_ENTRY_AG(ICryptoSetPassword, Filter, _setPassword)
@@ -96,10 +86,8 @@ public:
MY_QUERYINTERFACE_ENTRY_AG(ICompressSetDecoderProperties2, Filter, _setDecoderProperties)
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
- ICompressProgressInfo *progress);
- // #ifdef _ST_MODE
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(ReleaseInStream)();
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); \
@@ -107,7 +95,6 @@ public:
STDMETHOD(ReleaseOutStream)();
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Flush)();
- // #endif
#ifndef _NO_CRYPTO
STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
@@ -122,7 +109,6 @@ public:
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
};
-// #ifdef _ST_MODE
class CInStreamReleaser
{
public:
@@ -138,6 +124,5 @@ public:
COutStreamReleaser(): FilterCoder(0) {}
~COutStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseOutStream(); }
};
-// #endif
#endif
diff --git a/CPP/7zip/Common/MethodProps.h b/CPP/7zip/Common/MethodProps.h
index c0761c51..8127e21e 100755
--- a/CPP/7zip/Common/MethodProps.h
+++ b/CPP/7zip/Common/MethodProps.h
@@ -24,12 +24,12 @@ struct CMethod
struct CMethodsMode
{
CObjectVector<CMethod> Methods;
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
UInt32 NumThreads;
#endif
CMethodsMode()
- #ifdef COMPRESS_MT
+ #ifndef _7ZIP_ST
: NumThreads(1)
#endif
{}
diff --git a/CPP/7zip/Common/RegisterArc.h b/CPP/7zip/Common/RegisterArc.h
index ba5ed7c3..bc2a034f 100755
--- a/CPP/7zip/Common/RegisterArc.h
+++ b/CPP/7zip/Common/RegisterArc.h
@@ -1,7 +1,7 @@
// RegisterArc.h
-#ifndef __REGISTERARC_H
-#define __REGISTERARC_H
+#ifndef __REGISTER_ARC_H
+#define __REGISTER_ARC_H
#include "../Archive/IArchive.h"
@@ -25,10 +25,6 @@ void RegisterArc(const CArcInfo *arcInfo);
#define REGISTER_ARC_NAME(x) CRegister ## x
-#define REGISTER_ARC_DEC_SIG(x) struct REGISTER_ARC_NAME(x) { \
- REGISTER_ARC_NAME(x)() { g_ArcInfo.Signature[0]--; RegisterArc(&g_ArcInfo); }}; \
- static REGISTER_ARC_NAME(x) g_RegisterArc;
-
#define REGISTER_ARC(x) struct REGISTER_ARC_NAME(x) { \
REGISTER_ARC_NAME(x)() { RegisterArc(&g_ArcInfo); }}; \
static REGISTER_ARC_NAME(x) g_RegisterArc;
diff --git a/CPP/7zip/Compress/ArjDecoder1.cpp b/CPP/7zip/Compress/ArjDecoder1.cpp
index 3e66feeb..2c354e1e 100755
--- a/CPP/7zip/Compress/ArjDecoder1.cpp
+++ b/CPP/7zip/Compress/ArjDecoder1.cpp
@@ -246,15 +246,9 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *ou
if (!m_InBitStream.Create(1 << 20))
return E_OUTOFMEMORY;
- int size1 = sizeof(c_table) / sizeof(c_table[0]);
- for (int i = 0; i < size1; i++)
- {
- if (i % 100 == 0)
- c_table[i] = 0;
-
+ // check it
+ for (int i = 0; i < CTABLESIZE; i++)
c_table[i] = 0;
- }
-
UInt64 pos = 0;
m_OutWindowStream.SetStream(outStream);
diff --git a/CPP/7zip/Compress/BZip2Decoder.cpp b/CPP/7zip/Compress/BZip2Decoder.cpp
index 76a7187b..96ecf4b5 100755
--- a/CPP/7zip/Compress/BZip2Decoder.cpp
+++ b/CPP/7zip/Compress/BZip2Decoder.cpp
@@ -420,7 +420,7 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn
CDecoder::CDecoder()
{
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
m_States = 0;
m_NumThreadsPrev = 0;
NumThreads = 1;
@@ -428,7 +428,7 @@ CDecoder::CDecoder()
_needInStreamInit = true;
}
-#ifdef COMPRESS_BZIP2_MT
+#ifndef _7ZIP_ST
CDecoder::~CDecoder()
{
@@ -521,8 +521,8 @@ HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
{
- #ifdef COMPRESS_BZIP2_MT
Progress = progress;
+ #ifndef _7ZIP_ST
RINOK(Create());
for (UInt32 t = 0; t < NumThreads; t++)
{
@@ -556,7 +556,7 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
UInt32 dicSize = (UInt32)(s[3] - kArSig3) * kBlockSizeStep;
CombinedCrc.Init();
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
if (MtMode)
{
NextBlockIndex = 0;
@@ -662,7 +662,7 @@ HRESULT CDecoder::CodeResume(ISequentialOutStream *outStream, bool &isBZ, ICompr
STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { m_InStream.SetStream(inStream); return S_OK; }
STDMETHODIMP CDecoder::ReleaseInStream() { m_InStream.ReleaseStream(); return S_OK; }
-#ifdef COMPRESS_BZIP2_MT
+#ifndef _7ZIP_ST
static THREAD_FUNC_DECL MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
diff --git a/CPP/7zip/Compress/BZip2Decoder.h b/CPP/7zip/Compress/BZip2Decoder.h
index 39520ee3..d02b70a8 100755
--- a/CPP/7zip/Compress/BZip2Decoder.h
+++ b/CPP/7zip/Compress/BZip2Decoder.h
@@ -5,7 +5,7 @@
#include "../../Common/MyCom.h"
-#ifdef COMPRESS_BZIP2_MT
+#ifndef _7ZIP_ST
#include "../../Windows/Synchronization.h"
#include "../../Windows/Thread.h"
#endif
@@ -31,7 +31,7 @@ struct CState
{
UInt32 *Counters;
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
CDecoder *Decoder;
NWindows::CThread Thread;
@@ -59,7 +59,7 @@ struct CState
class CDecoder :
public ICompressCoder,
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
public ICompressSetCoderMt,
#endif
public CMyUnknownImp
@@ -104,9 +104,9 @@ private:
public:
CBZip2CombinedCrc CombinedCrc;
-
- #ifdef COMPRESS_BZIP2_MT
ICompressProgressInfo *Progress;
+
+ #ifndef _7ZIP_ST
CState *m_States;
UInt32 m_NumThreadsPrev;
@@ -145,8 +145,8 @@ public:
m_OutStream.ReleaseStream();
}
- MY_QUERYINTERFACE_BEGIN
- #ifdef COMPRESS_BZIP2_MT
+ MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
+ #ifndef _7ZIP_ST
MY_QUERYINTERFACE_ENTRY(ICompressSetCoderMt)
#endif
@@ -163,7 +163,7 @@ public:
HRESULT CodeResume(ISequentialOutStream *outStream, bool &isBZ, ICompressProgressInfo *progress);
UInt64 GetInputProcessedSize() const { return m_InStream.GetProcessedSize(); }
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
#endif
};
diff --git a/CPP/7zip/Compress/BZip2Encoder.cpp b/CPP/7zip/Compress/BZip2Encoder.cpp
index 0546c15c..eaa10855 100755
--- a/CPP/7zip/Compress/BZip2Encoder.cpp
+++ b/CPP/7zip/Compress/BZip2Encoder.cpp
@@ -46,7 +46,7 @@ void CThreadInfo::Free()
m_Block = 0;
}
-#ifdef COMPRESS_BZIP2_MT
+#ifndef _7ZIP_ST
static THREAD_FUNC_DECL MFThread(void *threadCoderInfo)
{
@@ -127,14 +127,14 @@ CEncoder::CEncoder():
m_OptimizeNumTables(false),
m_BlockSizeMult(kBlockSizeMultMax)
{
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
ThreadsInfo = 0;
m_NumThreadsPrev = 0;
NumThreads = 1;
#endif
}
-#ifdef COMPRESS_BZIP2_MT
+#ifndef _7ZIP_ST
CEncoder::~CEncoder()
{
Free();
@@ -680,7 +680,7 @@ HRESULT CThreadInfo::EncodeBlock3(UInt32 blockSize)
EncodeBlock2(m_Block, blockSize, Encoder->NumPasses);
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
if (Encoder->MtMode)
Encoder->ThreadsInfo[m_BlockIndex].CanWriteEvent.Lock();
#endif
@@ -688,7 +688,7 @@ HRESULT CThreadInfo::EncodeBlock3(UInt32 blockSize)
Encoder->CombinedCrc.Update(m_CRCs[i]);
Encoder->WriteBytes(m_TempArray, outStreamTemp.GetPos(), outStreamTemp.GetCurByte());
HRESULT res = S_OK;
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
if (Encoder->MtMode)
{
UInt32 blockIndex = m_BlockIndex + 1;
@@ -719,13 +719,13 @@ void CEncoder::WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte)
HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
{
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
Progress = progress;
RINOK(Create());
for (UInt32 t = 0; t < NumThreads; t++)
#endif
{
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
CThreadInfo &ti = ThreadsInfo[t];
if (MtMode)
{
@@ -760,7 +760,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *
CFlusher flusher(this);
CombinedCrc.Init();
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
NextBlockIndex = 0;
StreamWasFinished = false;
CloseThreads = false;
@@ -772,7 +772,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *
WriteByte(kArSig2);
WriteByte((Byte)(kArSig3 + m_BlockSizeMult));
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
if (MtMode)
{
@@ -795,7 +795,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *
for (;;)
{
CThreadInfo &ti =
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
ThreadsInfo[0];
#else
ThreadsInfo;
@@ -866,7 +866,7 @@ HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *p
}
case NCoderPropID::kNumThreads:
{
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
if (prop.vt != VT_UI4)
return E_INVALIDARG;
NumThreads = prop.ulVal;
@@ -882,7 +882,7 @@ HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *p
return S_OK;
}
-#ifdef COMPRESS_BZIP2_MT
+#ifndef _7ZIP_ST
STDMETHODIMP CEncoder::SetNumberOfThreads(UInt32 numThreads)
{
NumThreads = numThreads;
diff --git a/CPP/7zip/Compress/BZip2Encoder.h b/CPP/7zip/Compress/BZip2Encoder.h
index a79813f3..a863172f 100755
--- a/CPP/7zip/Compress/BZip2Encoder.h
+++ b/CPP/7zip/Compress/BZip2Encoder.h
@@ -6,7 +6,7 @@
#include "../../Common/Defs.h"
#include "../../Common/MyCom.h"
-#ifdef COMPRESS_BZIP2_MT
+#ifndef _7ZIP_ST
#include "../../Windows/Synchronization.h"
#include "../../Windows/Thread.h"
#endif
@@ -120,7 +120,7 @@ private:
public:
bool m_OptimizeNumTables;
CEncoder *Encoder;
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
NWindows::CThread Thread;
NWindows::NSynchronization::CAutoResetEvent StreamWasFinishedEvent;
@@ -148,7 +148,7 @@ public:
class CEncoder :
public ICompressCoder,
public ICompressSetCoderProperties,
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
public ICompressSetCoderMt,
#endif
public CMyUnknownImp
@@ -166,7 +166,7 @@ public:
UInt32 NumPasses;
CBZip2CombinedCrc CombinedCrc;
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
CThreadInfo *ThreadsInfo;
NWindows::NSynchronization::CManualResetEvent CanProcessEvent;
NWindows::NSynchronization::CCriticalSection CS;
@@ -192,14 +192,14 @@ public:
void WriteBit(bool v);
void WriteCrc(UInt32 v);
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
HRESULT Create();
void Free();
#endif
public:
CEncoder();
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
~CEncoder();
#endif
@@ -222,7 +222,7 @@ public:
}
};
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
MY_UNKNOWN_IMP2(ICompressSetCoderMt, ICompressSetCoderProperties)
#else
MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
@@ -235,7 +235,7 @@ public:
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
- #ifdef COMPRESS_BZIP2_MT
+ #ifndef _7ZIP_ST
STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);
#endif
};
diff --git a/CPP/7zip/Compress/BitlDecoder.h b/CPP/7zip/Compress/BitlDecoder.h
index 3bee413a..ff373bac 100755
--- a/CPP/7zip/Compress/BitlDecoder.h
+++ b/CPP/7zip/Compress/BitlDecoder.h
@@ -7,10 +7,9 @@
namespace NBitl {
-const int kNumBigValueBits = 8 * 4;
-
-const int kNumValueBytes = 3;
-const int kNumValueBits = 8 * kNumValueBytes;
+const unsigned kNumBigValueBits = 8 * 4;
+const unsigned kNumValueBytes = 3;
+const unsigned kNumValueBits = 8 * kNumValueBytes;
const UInt32 kMask = (1 << kNumValueBits) - 1;
@@ -20,7 +19,7 @@ template<class TInByte>
class CBaseDecoder
{
protected:
- int m_BitPos;
+ unsigned m_BitPos;
UInt32 m_Value;
TInByte m_Stream;
public:
@@ -51,7 +50,7 @@ public:
}
}
- UInt32 ReadBits(int numBits)
+ UInt32 ReadBits(unsigned numBits)
{
Normalize();
UInt32 res = m_Value & ((1 << numBits) - 1);
@@ -95,19 +94,19 @@ public:
}
}
- UInt32 GetValue(int numBits)
+ UInt32 GetValue(unsigned numBits)
{
Normalize();
return ((this->m_Value >> (8 - this->m_BitPos)) & kMask) >> (kNumValueBits - numBits);
}
- void MovePos(int numBits)
+ void MovePos(unsigned numBits)
{
this->m_BitPos += numBits;
m_NormalValue >>= numBits;
}
- UInt32 ReadBits(int numBits)
+ UInt32 ReadBits(unsigned numBits)
{
Normalize();
UInt32 res = m_NormalValue & ((1 << numBits) - 1);
diff --git a/CPP/7zip/Compress/BitlEncoder.h b/CPP/7zip/Compress/BitlEncoder.h
index 02f5a9c6..7de57545 100755
--- a/CPP/7zip/Compress/BitlEncoder.h
+++ b/CPP/7zip/Compress/BitlEncoder.h
@@ -8,12 +8,14 @@
class CBitlEncoder
{
COutBuffer m_Stream;
- int m_BitPos;
+ unsigned m_BitPos;
Byte m_CurByte;
public:
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream); }
void ReleaseStream() { m_Stream.ReleaseStream(); }
+ UInt32 GetBitPosition() const { return (8 - m_BitPos); }
+ UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
void Init()
{
m_Stream.Init();
@@ -25,18 +27,16 @@ public:
FlushByte();
return m_Stream.Flush();
}
-
void FlushByte()
{
- if(m_BitPos < 8)
+ if (m_BitPos < 8)
m_Stream.WriteByte(m_CurByte);
m_BitPos = 8;
m_CurByte = 0;
}
-
- void WriteBits(UInt32 value, int numBits)
+ void WriteBits(UInt32 value, unsigned numBits)
{
- while(numBits > 0)
+ while (numBits > 0)
{
if (numBits < m_BitPos)
{
@@ -51,9 +51,6 @@ public:
m_CurByte = 0;
}
}
- UInt32 GetBitPosition() const { return (8 - m_BitPos); }
- UInt64 GetProcessedSize() const {
- return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
void WriteByte(Byte b) { m_Stream.WriteByte(b);}
};
diff --git a/CPP/7zip/Compress/BitmDecoder.h b/CPP/7zip/Compress/BitmDecoder.h
index 2885ed78..4369b452 100755
--- a/CPP/7zip/Compress/BitmDecoder.h
+++ b/CPP/7zip/Compress/BitmDecoder.h
@@ -7,16 +7,16 @@
namespace NBitm {
-const int kNumBigValueBits = 8 * 4;
-const int kNumValueBytes = 3;
-const int kNumValueBits = 8 * kNumValueBytes;
+const unsigned kNumBigValueBits = 8 * 4;
+const unsigned kNumValueBytes = 3;
+const unsigned kNumValueBits = 8 * kNumValueBytes;
const UInt32 kMask = (1 << kNumValueBits) - 1;
template<class TInByte>
class CDecoder
{
- UInt32 m_BitPos;
+ unsigned m_BitPos;
UInt32 m_Value;
public:
TInByte m_Stream;
@@ -39,19 +39,19 @@ public:
m_Value = (m_Value << 8) | m_Stream.ReadByte();
}
- UInt32 GetValue(UInt32 numBits) const
+ UInt32 GetValue(unsigned numBits) const
{
// return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits);
return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits);
}
- void MovePos(UInt32 numBits)
+ void MovePos(unsigned numBits)
{
m_BitPos += numBits;
Normalize();
}
- UInt32 ReadBits(UInt32 numBits)
+ UInt32 ReadBits(unsigned numBits)
{
UInt32 res = GetValue(numBits);
MovePos(numBits);
diff --git a/CPP/7zip/Compress/BitmEncoder.h b/CPP/7zip/Compress/BitmEncoder.h
index 25976ef6..a85dbff8 100755
--- a/CPP/7zip/Compress/BitmEncoder.h
+++ b/CPP/7zip/Compress/BitmEncoder.h
@@ -9,12 +9,13 @@ template<class TOutByte>
class CBitmEncoder
{
TOutByte m_Stream;
- int m_BitPos;
+ unsigned m_BitPos;
Byte m_CurByte;
public:
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream);}
void ReleaseStream() { m_Stream.ReleaseStream(); }
+ UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) / 8; }
void Init()
{
m_Stream.Init();
@@ -23,14 +24,13 @@ public:
}
HRESULT Flush()
{
- if(m_BitPos < 8)
+ if (m_BitPos < 8)
WriteBits(0, m_BitPos);
return m_Stream.Flush();
}
-
- void WriteBits(UInt32 value, int numBits)
+ void WriteBits(UInt32 value, unsigned numBits)
{
- while(numBits > 0)
+ while (numBits > 0)
{
if (numBits < m_BitPos)
{
@@ -45,8 +45,6 @@ public:
m_CurByte = 0;
}
}
- UInt64 GetProcessedSize() const {
- return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) / 8; }
};
#endif
diff --git a/CPP/7zip/Compress/DllExports.cpp b/CPP/7zip/Compress/DllExports.cpp
index a7ec9027..6af7e5ec 100755
--- a/CPP/7zip/Compress/DllExports.cpp
+++ b/CPP/7zip/Compress/DllExports.cpp
@@ -19,7 +19,13 @@ void RegisterCodec(const CCodecInfo *codecInfo)
#ifdef _WIN32
extern "C"
-BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
+BOOL WINAPI DllMain(
+ #ifdef UNDER_CE
+ HANDLE
+ #else
+ HINSTANCE
+ #endif
+ , DWORD /* dwReason */, LPVOID /*lpReserved*/)
{
return TRUE;
}
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h b/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h
deleted file mode 100755
index ea8539d1..00000000
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// LzmaBenchCon.h
-
-#ifndef __LZMABENCHCON_H
-#define __LZMABENCHCON_H
-
-#include <stdio.h>
-#include "../../../Common/Types.h"
-#ifdef EXTERNAL_LZMA
-#include "../../UI/Common/LoadCodecs.h"
-#endif
-HRESULT LzmaBenchCon(
- #ifdef EXTERNAL_LZMA
- CCodecs *codecs,
- #endif
- FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
-
-HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
-
-#endif
-
diff --git a/CPP/7zip/Compress/LzmaDecoder.h b/CPP/7zip/Compress/LzmaDecoder.h
index d4bc9d3b..b4c7c135 100755
--- a/CPP/7zip/Compress/LzmaDecoder.h
+++ b/CPP/7zip/Compress/LzmaDecoder.h
@@ -37,7 +37,7 @@ class CDecoder:
void SetOutStreamSizeResume(const UInt64 *outSize);
public:
- MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_BEGIN2(ICompressCoder)
MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2)
#ifndef NO_READ_FROM_CODER
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
diff --git a/CPP/7zip/Compress/Lzx.h b/CPP/7zip/Compress/Lzx.h
index 249cbe51..09ab7f07 100755
--- a/CPP/7zip/Compress/Lzx.h
+++ b/CPP/7zip/Compress/Lzx.h
@@ -6,7 +6,7 @@
namespace NCompress {
namespace NLzx {
-const int kNumHuffmanBits = 16;
+const unsigned kNumHuffmanBits = 16;
const UInt32 kNumRepDistances = 3;
const UInt32 kNumLenSlots = 8;
@@ -14,7 +14,7 @@ const UInt32 kMatchMinLen = 2;
const UInt32 kNumLenSymbols = 249;
const UInt32 kMatchMaxLen = kMatchMinLen + (kNumLenSlots - 1) + kNumLenSymbols - 1;
-const int kNumAlignBits = 3;
+const unsigned kNumAlignBits = 3;
const UInt32 kAlignTableSize = 1 << kNumAlignBits;
const UInt32 kNumPosSlots = 50;
@@ -24,36 +24,36 @@ const UInt32 kMainTableSize = 256 + kNumPosLenSlots;
const UInt32 kLevelTableSize = 20;
const UInt32 kMaxTableSize = kMainTableSize;
-const int kNumBlockTypeBits = 3;
-const int kBlockTypeVerbatim = 1;
-const int kBlockTypeAligned = 2;
-const int kBlockTypeUncompressed = 3;
+const unsigned kNumBlockTypeBits = 3;
+const unsigned kBlockTypeVerbatim = 1;
+const unsigned kBlockTypeAligned = 2;
+const unsigned kBlockTypeUncompressed = 3;
-const int kUncompressedBlockSizeNumBits = 24;
+const unsigned kUncompressedBlockSizeNumBits = 24;
-const int kNumBitsForPreTreeLevel = 4;
+const unsigned kNumBitsForPreTreeLevel = 4;
-const int kLevelSymbolZeros = 17;
-const int kLevelSymbolZerosBig = 18;
-const int kLevelSymbolSame = 19;
+const unsigned kLevelSymbolZeros = 17;
+const unsigned kLevelSymbolZerosBig = 18;
+const unsigned kLevelSymbolSame = 19;
-const int kLevelSymbolZerosStartValue = 4;
-const int kLevelSymbolZerosNumBits = 4;
+const unsigned kLevelSymbolZerosStartValue = 4;
+const unsigned kLevelSymbolZerosNumBits = 4;
-const int kLevelSymbolZerosBigStartValue = kLevelSymbolZerosStartValue +
+const unsigned kLevelSymbolZerosBigStartValue = kLevelSymbolZerosStartValue +
(1 << kLevelSymbolZerosNumBits);
-const int kLevelSymbolZerosBigNumBits = 5;
+const unsigned kLevelSymbolZerosBigNumBits = 5;
-const int kLevelSymbolSameNumBits = 1;
-const int kLevelSymbolSameStartValue = 4;
+const unsigned kLevelSymbolSameNumBits = 1;
+const unsigned kLevelSymbolSameStartValue = 4;
-const int kNumBitsForAlignLevel = 3;
+const unsigned kNumBitsForAlignLevel = 3;
-const int kNumDictionaryBitsMin = 15;
-const int kNumDictionaryBitsMax = 21;
+const unsigned kNumDictionaryBitsMin = 15;
+const unsigned kNumDictionaryBitsMax = 21;
const UInt32 kDictionarySizeMax = (1 << kNumDictionaryBitsMax);
-const int kNumLinearPosSlotBits = 17;
+const unsigned kNumLinearPosSlotBits = 17;
const UInt32 kNumPowerPosSlots = 0x26;
}}
diff --git a/CPP/7zip/Compress/LzxDecoder.cpp b/CPP/7zip/Compress/LzxDecoder.cpp
index 373c902c..6224bea5 100755
--- a/CPP/7zip/Compress/LzxDecoder.cpp
+++ b/CPP/7zip/Compress/LzxDecoder.cpp
@@ -33,7 +33,7 @@ STDMETHODIMP CDecoder::Flush()
return m_x86ConvertOutStreamSpec->Flush();
}
-UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits); }
+UInt32 CDecoder::ReadBits(unsigned numBits) { return m_InBitStream.ReadBits(numBits); }
#define RIF(x) { if (!(x)) return false; }
@@ -44,7 +44,7 @@ bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols)
for (i = 0; i < kLevelTableSize; i++)
levelLevels[i] = (Byte)ReadBits(kNumBitsForPreTreeLevel);
RIF(m_LevelDecoder.SetCodeLengths(levelLevels));
- int num = 0;
+ unsigned num = 0;
Byte symbol = 0;
for (i = 0; i < numSymbols;)
{
@@ -58,12 +58,12 @@ bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols)
UInt32 number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
if (number == kLevelSymbolZeros)
{
- num = kLevelSymbolZerosStartValue + (int)ReadBits(kLevelSymbolZerosNumBits);
+ num = kLevelSymbolZerosStartValue + (unsigned)ReadBits(kLevelSymbolZerosNumBits);
symbol = 0;
}
else if (number == kLevelSymbolZerosBig)
{
- num = kLevelSymbolZerosBigStartValue + (int)ReadBits(kLevelSymbolZerosBigNumBits);
+ num = kLevelSymbolZerosBigStartValue + (unsigned)ReadBits(kLevelSymbolZerosBigNumBits);
symbol = 0;
}
else if (number == kLevelSymbolSame || number <= kNumHuffmanBits)
@@ -72,7 +72,7 @@ bool CDecoder::ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols)
num = 1;
else
{
- num = kLevelSymbolSameStartValue + (int)ReadBits(kLevelSymbolSameNumBits);
+ num = kLevelSymbolSameStartValue + (unsigned)ReadBits(kLevelSymbolSameNumBits);
number = m_LevelDecoder.DecodeSymbol(&m_InBitStream);
if (number > kNumHuffmanBits)
return false;
@@ -93,7 +93,7 @@ bool CDecoder::ReadTables(void)
m_InBitStream.DirectReadByte();
m_InBitStream.Normalize();
- int blockType = (int)ReadBits(kNumBlockTypeBits);
+ unsigned blockType = (unsigned)ReadBits(kNumBlockTypeBits);
if (blockType > kBlockTypeUncompressed)
return false;
if (_wimMode)
@@ -114,10 +114,10 @@ bool CDecoder::ReadTables(void)
if (!m_InBitStream.ReadUInt32(m_RepDistances[0]))
return false;
m_RepDistances[0]--;
- for (int i = 1; i < kNumRepDistances; i++)
+ for (unsigned i = 1; i < kNumRepDistances; i++)
{
UInt32 rep = 0;
- for (int j = 0; j < 4; j++)
+ for (unsigned j = 0; j < 4; j++)
rep |= (UInt32)m_InBitStream.DirectReadByte() << (8 * j);
m_RepDistances[i] = rep - 1;
}
@@ -126,7 +126,7 @@ bool CDecoder::ReadTables(void)
m_AlignIsUsed = (blockType == kBlockTypeAligned);
if (m_AlignIsUsed)
{
- for(int i = 0; i < kAlignTableSize; i++)
+ for (unsigned i = 0; i < kAlignTableSize; i++)
newLevels[i] = (Byte)ReadBits(kNumBitsForAlignLevel);
RIF(m_AlignDecoder.SetCodeLengths(newLevels));
}
@@ -159,7 +159,7 @@ public:
void CDecoder::ClearPrevLevels()
{
- int i;
+ unsigned i;
for (i = 0; i < kMainTableSize; i++)
m_LastMainLevels[i] = 0;
for (i = 0; i < kNumLenSymbols; i++)
@@ -193,19 +193,19 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
}
m_x86ConvertOutStreamSpec->Init(translationMode, i86TranslationSize);
- for(int i = 0 ; i < kNumRepDistances; i++)
+ for (unsigned i = 0 ; i < kNumRepDistances; i++)
m_RepDistances[i] = 0;
}
}
- while(_remainLen > 0 && curSize > 0)
+ while (_remainLen > 0 && curSize > 0)
{
m_OutWindowStream.PutByte(m_OutWindowStream.GetByte(m_RepDistances[0]));
_remainLen--;
curSize--;
}
- while(curSize > 0)
+ while (curSize > 0)
{
if (m_UnCompressedBlockSize == 0)
if (!ReadTables())
@@ -215,13 +215,13 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
m_UnCompressedBlockSize -= next;
if (m_IsUncompressedBlock)
{
- while(next > 0)
+ while (next > 0)
{
m_OutWindowStream.PutByte(m_InBitStream.DirectReadByte());
next--;
}
}
- else while(next > 0)
+ else while (next > 0)
{
UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
if (number < 256)
@@ -254,10 +254,10 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
else
{
UInt32 distance;
- int numDirectBits;
+ unsigned numDirectBits;
if (posSlot < kNumPowerPosSlots)
{
- numDirectBits = (int)(posSlot >> 1) - 1;
+ numDirectBits = (unsigned)(posSlot >> 1) - 1;
distance = ((2 | (posSlot & 1)) << numDirectBits);
}
else
@@ -365,7 +365,7 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
return S_OK;
}
-HRESULT CDecoder::SetParams(int numDictBits)
+HRESULT CDecoder::SetParams(unsigned numDictBits)
{
if (numDictBits < kNumDictionaryBitsMin || numDictBits > kNumDictionaryBitsMax)
return E_INVALIDARG;
diff --git a/CPP/7zip/Compress/LzxDecoder.h b/CPP/7zip/Compress/LzxDecoder.h
index d7979231..73a05061 100755
--- a/CPP/7zip/Compress/LzxDecoder.h
+++ b/CPP/7zip/Compress/LzxDecoder.h
@@ -17,15 +17,15 @@ namespace NLzx {
namespace NBitStream {
-const int kNumBigValueBits = 8 * 4;
-const int kNumValueBits = 17;
+const unsigned kNumBigValueBits = 8 * 4;
+const unsigned kNumValueBits = 17;
const UInt32 kBitDecoderValueMask = (1 << kNumValueBits) - 1;
class CDecoder
{
CInBuffer m_Stream;
UInt32 m_Value;
- int m_BitPos;
+ unsigned m_BitPos;
public:
CDecoder() {}
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
@@ -39,14 +39,13 @@ public:
m_BitPos = kNumBigValueBits;
}
- UInt64 GetProcessedSize() const
- { return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
+ UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
- int GetBitPosition() const { return m_BitPos & 0xF; }
+ unsigned GetBitPosition() const { return m_BitPos & 0xF; }
void Normalize()
{
- for (;m_BitPos >= 16; m_BitPos -= 16)
+ for (; m_BitPos >= 16; m_BitPos -= 16)
{
Byte b0 = m_Stream.ReadByte();
Byte b1 = m_Stream.ReadByte();
@@ -55,29 +54,28 @@ public:
}
}
- UInt32 GetValue(int numBits) const
+ UInt32 GetValue(unsigned numBits) const
{
- return ((m_Value >> ((32 - kNumValueBits) - m_BitPos)) & kBitDecoderValueMask) >>
- (kNumValueBits - numBits);
+ return ((m_Value >> ((32 - kNumValueBits) - m_BitPos)) & kBitDecoderValueMask) >> (kNumValueBits - numBits);
}
- void MovePos(UInt32 numBits)
+ void MovePos(unsigned numBits)
{
- m_BitPos += (int)numBits;
+ m_BitPos += numBits;
Normalize();
}
- UInt32 ReadBits(int numBits)
+ UInt32 ReadBits(unsigned numBits)
{
UInt32 res = GetValue(numBits);
MovePos(numBits);
return res;
}
- UInt32 ReadBitsBig(int numBits)
+ UInt32 ReadBitsBig(unsigned numBits)
{
- int numBits0 = numBits / 2;
- int numBits1 = numBits - numBits0;
+ unsigned numBits0 = numBits / 2;
+ unsigned numBits1 = numBits - numBits0;
UInt32 res = ReadBits(numBits0) << numBits1;
return res + ReadBits(numBits1);
}
@@ -128,7 +126,7 @@ class CDecoder :
bool _wimMode;
- UInt32 ReadBits(int numBits);
+ UInt32 ReadBits(unsigned numBits);
bool ReadTable(Byte *lastLevels, Byte *newLevels, UInt32 numSymbols);
bool ReadTables();
void ClearPrevLevels();
@@ -152,7 +150,7 @@ public:
STDMETHOD(ReleaseInStream)();
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
- HRESULT SetParams(int numDictBits);
+ HRESULT SetParams(unsigned numDictBits);
void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
};
diff --git a/CPP/7zip/Compress/QuantumDecoder.cpp b/CPP/7zip/Compress/QuantumDecoder.cpp
index b4c1c256..501bd0e1 100755
--- a/CPP/7zip/Compress/QuantumDecoder.cpp
+++ b/CPP/7zip/Compress/QuantumDecoder.cpp
@@ -9,19 +9,23 @@
namespace NCompress {
namespace NQuantum {
-// const UInt32 kDictionarySizeMax = (1 << 21);
+static const int kLenIdNeedInit = -2;
-const int kLenIdNeedInit = -2;
+static const unsigned kNumLenSymbols = 27;
+static const unsigned kMatchMinLen = 3;
+static const unsigned kNumSimplePosSlots = 4;
+static const unsigned kNumSimpleLenSlots = 6;
void CDecoder::Init()
{
m_Selector.Init(kNumSelectors);
- for (unsigned int i = 0; i < kNumLitSelectors; i++)
+ unsigned i;
+ for (i = 0; i < kNumLitSelectors; i++)
m_Literals[i].Init(kNumLitSymbols);
- unsigned int numItems = _numDictBits << 1;
- m_PosSlot[0].Init(MyMin(numItems, kNumLen3PosSymbolsMax));
- m_PosSlot[1].Init(MyMin(numItems, kNumLen4PosSymbolsMax));
- m_PosSlot[2].Init(MyMin(numItems, kNumLen5PosSymbolsMax));
+ unsigned numItems = (_numDictBits == 0 ? 1 : (_numDictBits << 1));
+ const unsigned kNumPosSymbolsMax[kNumMatchSelectors] = { 24, 36, 42 };
+ for (i = 0; i < kNumMatchSelectors; i++)
+ m_PosSlot[i].Init(MyMin(numItems, kNumPosSymbolsMax[i]));
m_LenSlot.Init(kNumLenSymbols);
}
@@ -31,7 +35,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
{
if (!_keepHistory)
{
- if (!_outWindowStream.Create(_dictionarySize))
+ if (!_outWindowStream.Create((UInt32)1 << _numDictBits))
return E_OUTOFMEMORY;
Init();
}
@@ -43,7 +47,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
if (curSize == 0)
return S_OK;
- while(_remainLen > 0 && curSize > 0)
+ while (_remainLen > 0 && curSize > 0)
{
_remainLen--;
Byte b = _outWindowStream.GetByte(_rep0);
@@ -51,12 +55,12 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
curSize--;
}
- while(curSize > 0)
+ while (curSize > 0)
{
if (_rangeDecoder.Stream.WasFinished())
return S_FALSE;
- unsigned int selector = m_Selector.Decode(&_rangeDecoder);
+ unsigned selector = m_Selector.Decode(&_rangeDecoder);
if (selector < kNumLitSelectors)
{
Byte b = (Byte)((selector << (8 - kNumLitSelectorBits)) + m_Literals[selector].Decode(&_rangeDecoder));
@@ -66,10 +70,10 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
else
{
selector -= kNumLitSelectors;
- unsigned int len = selector + kMatchMinLen;
+ unsigned len = selector + kMatchMinLen;
if (selector == 2)
{
- unsigned int lenSlot = m_LenSlot.Decode(&_rangeDecoder);;
+ unsigned lenSlot = m_LenSlot.Decode(&_rangeDecoder);
if (lenSlot >= kNumSimpleLenSlots)
{
lenSlot -= 2;
@@ -81,15 +85,15 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
else
len += lenSlot;
}
- UInt32 rep0 = m_PosSlot[selector].Decode(&_rangeDecoder);;
+ UInt32 rep0 = m_PosSlot[selector].Decode(&_rangeDecoder);
if (rep0 >= kNumSimplePosSlots)
{
int numDirectBits = (int)((rep0 >> 1) - 1);
rep0 = ((2 | (rep0 & 1)) << numDirectBits) + _rangeDecoder.Stream.ReadBits(numDirectBits);
}
- unsigned int locLen = len;
+ unsigned locLen = len;
if (len > curSize)
- locLen = (unsigned int)curSize;
+ locLen = (unsigned)curSize;
if (!_outWindowStream.CopyBlock(rep0, locLen))
return S_FALSE;
curSize -= locLen;
diff --git a/CPP/7zip/Compress/QuantumDecoder.h b/CPP/7zip/Compress/QuantumDecoder.h
index d9007a61..e9ab023b 100755
--- a/CPP/7zip/Compress/QuantumDecoder.h
+++ b/CPP/7zip/Compress/QuantumDecoder.h
@@ -16,30 +16,30 @@ namespace NQuantum {
class CStreamBitDecoder
{
- UInt32 m_Value;
- CInBuffer m_Stream;
+ UInt32 Value;
+ CInBuffer Stream;
public:
- bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
- void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
- void ReleaseStream() { m_Stream.ReleaseStream();}
+ bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
+ void ReleaseStream() { Stream.ReleaseStream(); }
- void Finish() { m_Value = 0x10000; }
+ void Finish() { Value = 0x10000; }
void Init()
{
- m_Stream.Init();
- m_Value = 0x10000;
+ Stream.Init();
+ Value = 0x10000;
}
- UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize(); }
- bool WasFinished() const { return m_Stream.WasFinished(); };
+ UInt64 GetProcessedSize() const { return Stream.GetProcessedSize(); }
+ bool WasFinished() const { return Stream.WasFinished(); }
UInt32 ReadBit()
{
- if (m_Value >= 0x10000)
- m_Value = 0x100 | m_Stream.ReadByte();
- UInt32 res = (m_Value >> 7) & 1;
- m_Value <<= 1;
+ if (Value >= 0x10000)
+ Value = 0x100 | Stream.ReadByte();
+ UInt32 res = (Value >> 7) & 1;
+ Value <<= 1;
return res;
}
@@ -48,26 +48,17 @@ public:
UInt32 res = 0;
do
res = (res << 1) | ReadBit();
- while(--numBits != 0);
+ while (--numBits != 0);
return res;
}
};
-const int kNumLitSelectorBits = 2;
-const unsigned int kNumLitSelectors = (1 << kNumLitSelectorBits);
-const unsigned int kNumLitSymbols = 1 << (8 - kNumLitSelectorBits);
-const unsigned int kNumMatchSelectors = 3;
-const unsigned int kNumSelectors = kNumLitSelectors + kNumMatchSelectors;
-const unsigned int kNumLen3PosSymbolsMax = 24;
-const unsigned int kNumLen4PosSymbolsMax = 36;
-const unsigned int kNumLen5PosSymbolsMax = 42;
-const unsigned int kNumLenSymbols = 27;
-
-const unsigned int kNumSymbolsMax = kNumLitSymbols; // 64
-
-const unsigned int kMatchMinLen = 3;
-const unsigned int kNumSimplePosSlots = 4;
-const unsigned int kNumSimpleLenSlots = 6;
+const unsigned kNumLitSelectorBits = 2;
+const unsigned kNumLitSelectors = (1 << kNumLitSelectorBits);
+const unsigned kNumLitSymbols = 1 << (8 - kNumLitSelectorBits);
+const unsigned kNumMatchSelectors = 3;
+const unsigned kNumSelectors = kNumLitSelectors + kNumMatchSelectors;
+const unsigned kNumSymbolsMax = kNumLitSymbols; // 64
namespace NRangeCoder {
@@ -135,16 +126,16 @@ const UInt16 kReorderCount = 50;
class CModelDecoder
{
- unsigned int NumItems;
- unsigned int ReorderCount;
+ unsigned NumItems;
+ unsigned ReorderCount;
UInt16 Freqs[kNumSymbolsMax + 1];
Byte Values[kNumSymbolsMax];
public:
- void Init(unsigned int numItems)
+ void Init(unsigned numItems)
{
NumItems = numItems;
ReorderCount = kReorderCountStart;
- for(unsigned int i = 0; i < numItems; i++)
+ for (unsigned i = 0; i < numItems; i++)
{
Freqs[i] = (UInt16)(numItems - i);
Values[i] = (Byte)i;
@@ -152,26 +143,26 @@ public:
Freqs[numItems] = 0;
}
- unsigned int Decode(CDecoder *rangeDecoder)
+ unsigned Decode(CDecoder *rangeDecoder)
{
UInt32 threshold = rangeDecoder->GetThreshold(Freqs[0]);
- unsigned int i;
+ unsigned i;
for (i = 1; Freqs[i] > threshold; i++);
rangeDecoder->Decode(Freqs[i], Freqs[i - 1], Freqs[0]);
- unsigned int res = Values[--i];
+ unsigned res = Values[--i];
do
Freqs[i] += kUpdateStep;
- while(i-- != 0);
+ while (i-- != 0);
if (Freqs[0] > kFreqSumMax)
{
if (--ReorderCount == 0)
{
ReorderCount = kReorderCount;
- for(i = 0; i < NumItems; i++)
+ for (i = 0; i < NumItems; i++)
Freqs[i] = (UInt16)(((Freqs[i] - Freqs[i + 1]) + 1) >> 1);
- for(i = 0; i < NumItems - 1; i++)
- for(unsigned int j = i + 1; j < NumItems; j++)
+ for (i = 0; i < NumItems - 1; i++)
+ for (unsigned j = i + 1; j < NumItems; j++)
if (Freqs[i] < Freqs[j])
{
UInt16 tmpFreq = Freqs[i];
@@ -183,7 +174,7 @@ public:
}
do
Freqs[i] = (UInt16)(Freqs[i] + Freqs[i + 1]);
- while(i-- != 0);
+ while (i-- != 0);
}
else
{
@@ -194,11 +185,11 @@ public:
if (Freqs[i] <= Freqs[i + 1])
Freqs[i] = (UInt16)(Freqs[i + 1] + 1);
}
- while(i-- != 0);
+ while (i-- != 0);
}
}
return res;
- };
+ }
};
}
@@ -212,23 +203,17 @@ class CDecoder:
CLzOutWindow _outWindowStream;
NRangeCoder::CDecoder _rangeDecoder;
- ///////////////////
- // State
UInt64 _outSize;
- // UInt64 _nowPos64;
int _remainLen; // -1 means end of stream. // -2 means need Init
UInt32 _rep0;
int _numDictBits;
- UInt32 _dictionarySize;
+ bool _keepHistory;
NRangeCoder::CModelDecoder m_Selector;
NRangeCoder::CModelDecoder m_Literals[kNumLitSelectors];
NRangeCoder::CModelDecoder m_PosSlot[kNumMatchSelectors];
NRangeCoder::CModelDecoder m_LenSlot;
-
- bool _keepHistory;
-
void Init();
HRESULT CodeSpec(UInt32 size);
public:
@@ -268,16 +253,8 @@ public:
STDMETHOD(ReleaseInStream)();
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
- void SetParams(int numDictBits)
- {
- _numDictBits = numDictBits;
- _dictionarySize = (UInt32)1 << numDictBits;
- }
- void SetKeepHistory(bool keepHistory)
- {
- _keepHistory = keepHistory;
- }
-
+ void SetParams(int numDictBits) { _numDictBits = numDictBits; }
+ void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
CDecoder(): _keepHistory(false) {}
virtual ~CDecoder() {}
};
diff --git a/CPP/7zip/Compress/Rar1Decoder.cpp b/CPP/7zip/Compress/Rar1Decoder.cpp
index c7540b92..eadca7b3 100755
--- a/CPP/7zip/Compress/Rar1Decoder.cpp
+++ b/CPP/7zip/Compress/Rar1Decoder.cpp
@@ -42,6 +42,8 @@ UInt32 CDecoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits);
HRESULT CDecoder::CopyBlock(UInt32 distance, UInt32 len)
{
+ if (len == 0)
+ return S_FALSE;
m_UnpackSize -= len;
return m_OutWindowStream.CopyBlock(distance, len) ? S_OK : S_FALSE;
}
diff --git a/CPP/7zip/Compress/Rar2Decoder.cpp b/CPP/7zip/Compress/Rar2Decoder.cpp
index 16d6b30c..4e669bd6 100755
--- a/CPP/7zip/Compress/Rar2Decoder.cpp
+++ b/CPP/7zip/Compress/Rar2Decoder.cpp
@@ -256,6 +256,8 @@ bool CDecoder::DecodeLz(Int32 pos)
else if (number == kRepBothNumber)
{
length = m_LastLength;
+ if (length == 0)
+ return false;
distance = m_RepDists[(m_RepDistPtr + 4 - 1) & 3];
}
else if (number < kLen2Number)
diff --git a/CPP/7zip/Compress/Rar3Decoder.cpp b/CPP/7zip/Compress/Rar3Decoder.cpp
index b7345eb0..77106278 100755
--- a/CPP/7zip/Compress/Rar3Decoder.cpp
+++ b/CPP/7zip/Compress/Rar3Decoder.cpp
@@ -623,8 +623,7 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
if (number < 256)
{
- PutByte(Byte(number));
-
+ PutByte((Byte)number);
continue;
}
else if (number == kSymbolReadTable)
@@ -640,6 +639,8 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
}
else if (number == 258)
{
+ if (length == 0)
+ return S_FALSE;
}
else if (number < kSymbolRep + 4)
{
diff --git a/CPP/7zip/Crc.mak b/CPP/7zip/Crc.mak
index 872fb378..7f2552c1 100755
--- a/CPP/7zip/Crc.mak
+++ b/CPP/7zip/Crc.mak
@@ -1,15 +1,8 @@
-!IFNDEF CPU
-$O\7zCrcT8U.obj: ../../../../Asm/x86/$(*B).asm
- $(COMPL_ASM)
-$O\7zCrcT8.obj: ../../../../C/$(*B).c
- $(COMPL_O2)
-!ELSE IF "$(CPU)" == "AMD64"
-$O\7zCrcT8U.obj: ../../../../Asm/x64/$(*B).asm
- $(COMPL_ASM)
-$O\7zCrcT8.obj: ../../../../C/$(*B).c
- $(COMPL_O2)
+C_OBJS = $(C_OBJS) \
+ $O\7zCrc.obj
+!IF "$(CPU)" == "IA64" || "$(CPU)" == "MIPS"
+C_OBJS = $(C_OBJS) \
!ELSE
-$(CRC_OBJS): ../../../../C/$(*B).c
- $(COMPL_O2)
+ASM_OBJS = $(ASM_OBJS) \
!ENDIF
-
+ $O\7zCrcOpt.obj
diff --git a/CPP/7zip/Crc2.mak b/CPP/7zip/Crc2.mak
deleted file mode 100755
index c257a077..00000000
--- a/CPP/7zip/Crc2.mak
+++ /dev/null
@@ -1,7 +0,0 @@
-CRC_OBJS = \
-!IF "$(CPU)" != "IA64" && "$(CPU)" != "ARM"
- $O\7zCrcT8U.obj \
- $O\7zCrcT8.obj \
-!ELSE
- $O\7zCrc.obj \
-!ENDIF
diff --git a/CPP/7zip/Crypto/7zAes.cpp b/CPP/7zip/Crypto/7zAes.cpp
index 41ccb1d2..b686fb61 100755
--- a/CPP/7zip/Crypto/7zAes.cpp
+++ b/CPP/7zip/Crypto/7zAes.cpp
@@ -47,7 +47,7 @@ void CKeyInfo::CalculateDigest()
{
CSha256 sha;
Sha256_Init(&sha);
- const UInt64 numRounds = UInt64(1) << (NumCyclesPower);
+ const UInt64 numRounds = (UInt64)1 << NumCyclesPower;
Byte temp[8] = { 0,0,0,0,0,0,0,0 };
for (UInt64 round = 0; round < numRounds; round++)
{
@@ -206,7 +206,7 @@ STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
_key.Salt[i] = data[pos++];
for (i = 0; i < ivSize; i++)
_iv[i] = data[pos++];
- return S_OK;
+ return (_key.NumCyclesPower <= 24) ? S_OK : E_NOTIMPL;
}
STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
diff --git a/CPP/7zip/Crypto/MyAes.cpp b/CPP/7zip/Crypto/MyAes.cpp
index 5b0d1e8a..70a7dccf 100755
--- a/CPP/7zip/Crypto/MyAes.cpp
+++ b/CPP/7zip/Crypto/MyAes.cpp
@@ -8,50 +8,41 @@ namespace NCrypto {
struct CAesTabInit { CAesTabInit() { AesGenTables();} } g_AesTabInit;
-STDMETHODIMP CAesCbcEncoder::Init() { return S_OK; }
-
-STDMETHODIMP_(UInt32) CAesCbcEncoder::Filter(Byte *data, UInt32 size)
-{
- return (UInt32)AesCbc_Encode(&Aes, data, size);
-}
-
-STDMETHODIMP CAesCbcEncoder::SetKey(const Byte *data, UInt32 size)
-{
- if ((size & 0x7) != 0 || size < 16 || size > 32)
- return E_INVALIDARG;
- Aes_SetKeyEncode(&Aes.aes, data, size);
- return S_OK;
-}
-
-STDMETHODIMP CAesCbcEncoder::SetInitVector(const Byte *data, UInt32 size)
+CAesCbcCoder::CAesCbcCoder()
{
- if (size != AES_BLOCK_SIZE)
- return E_INVALIDARG;
- AesCbc_Init(&Aes, data);
- return S_OK;
+ _offset = ((0 - (unsigned)(ptrdiff_t)_aes) & 0xF) / sizeof(UInt32);
}
-STDMETHODIMP CAesCbcDecoder::Init() { return S_OK; }
+STDMETHODIMP CAesCbcCoder::Init() { return S_OK; }
-STDMETHODIMP_(UInt32) CAesCbcDecoder::Filter(Byte *data, UInt32 size)
+STDMETHODIMP_(UInt32) CAesCbcCoder::Filter(Byte *data, UInt32 size)
{
- return (UInt32)AesCbc_Decode(&Aes, data, size);
+ if (size == 0)
+ return 0;
+ if (size < AES_BLOCK_SIZE)
+ return AES_BLOCK_SIZE;
+ size >>= 4;
+ _codeFunc(_aes + _offset, data, size);
+ return size << 4;
}
-STDMETHODIMP CAesCbcDecoder::SetKey(const Byte *data, UInt32 size)
+STDMETHODIMP CAesCbcCoder::SetKey(const Byte *data, UInt32 size)
{
if ((size & 0x7) != 0 || size < 16 || size > 32)
return E_INVALIDARG;
- Aes_SetKeyDecode(&Aes.aes, data, size);
+ _setKeyFunc(_aes + _offset + 4, data, size);
return S_OK;
}
-STDMETHODIMP CAesCbcDecoder::SetInitVector(const Byte *data, UInt32 size)
+STDMETHODIMP CAesCbcCoder::SetInitVector(const Byte *data, UInt32 size)
{
if (size != AES_BLOCK_SIZE)
return E_INVALIDARG;
- AesCbc_Init(&Aes, data);
+ AesCbc_Init(_aes + _offset, data);
return S_OK;
}
+CAesCbcEncoder::CAesCbcEncoder() { _codeFunc = g_AesCbc_Encode; _setKeyFunc = Aes_SetKey_Enc; }
+CAesCbcDecoder::CAesCbcDecoder() { _codeFunc = g_AesCbc_Decode; _setKeyFunc = Aes_SetKey_Dec; }
+
}
diff --git a/CPP/7zip/Crypto/MyAes.h b/CPP/7zip/Crypto/MyAes.h
index 24e90d6f..60b13845 100755
--- a/CPP/7zip/Crypto/MyAes.h
+++ b/CPP/7zip/Crypto/MyAes.h
@@ -6,19 +6,23 @@
#include "../../../C/Aes.h"
#include "../../Common/MyCom.h"
-#include "../../Common/Types.h"
#include "../ICoder.h"
namespace NCrypto {
-class CAesCbcEncoder:
+class CAesCbcCoder:
public ICompressFilter,
public ICryptoProperties,
public CMyUnknownImp
{
- CAesCbc Aes;
+protected:
+ AES_CODE_FUNC _codeFunc;
+ AES_SET_KEY_FUNC _setKeyFunc;
+ unsigned _offset;
+ UInt32 _aes[AES_NUM_IVMRK_WORDS + 3];
public:
+ CAesCbcCoder();
MY_UNKNOWN_IMP1(ICryptoProperties)
STDMETHOD(Init)();
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
@@ -26,19 +30,8 @@ public:
STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
};
-class CAesCbcDecoder:
- public ICompressFilter,
- public ICryptoProperties,
- public CMyUnknownImp
-{
- CAesCbc Aes;
-public:
- MY_UNKNOWN_IMP1(ICryptoProperties)
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
- STDMETHOD(SetKey)(const Byte *data, UInt32 size);
- STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
-};
+struct CAesCbcEncoder: public CAesCbcCoder { CAesCbcEncoder(); };
+struct CAesCbcDecoder: public CAesCbcCoder { CAesCbcDecoder(); };
}
diff --git a/CPP/7zip/Crypto/RarAes.cpp b/CPP/7zip/Crypto/RarAes.cpp
index bbb4ccef..4e4aa59b 100755
--- a/CPP/7zip/Crypto/RarAes.cpp
+++ b/CPP/7zip/Crypto/RarAes.cpp
@@ -33,7 +33,7 @@ STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
same = true;
if (_thereIsSalt)
{
- for (int i = 0; i < sizeof(_salt); i++)
+ for (unsigned i = 0; i < sizeof(_salt); i++)
if (_salt[i] != data[i])
{
same = false;
@@ -41,14 +41,14 @@ STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
}
}
}
- for (int i = 0; i < sizeof(_salt); i++)
+ for (unsigned i = 0; i < sizeof(_salt); i++)
_salt[i] = data[i];
if (!_needCalculate && !same)
_needCalculate = true;
return S_OK;
}
-static const int kMaxPasswordLength = 127 * 2;
+static const unsigned kMaxPasswordLength = 127 * 2;
STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
{
@@ -75,21 +75,16 @@ STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
STDMETHODIMP CDecoder::Init()
{
Calculate();
- Aes_SetKeyDecode(&Aes.aes, aesKey, kRarAesKeySize);
- AesCbc_Init(&Aes, aesInit);
+ SetKey(aesKey, kRarAesKeySize);
+ AesCbc_Init(_aes + _offset, _aesInit);
return S_OK;
}
-STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
-{
- return (UInt32)AesCbc_Decode(&Aes, data, size);
-}
-
void CDecoder::Calculate()
{
if (_needCalculate)
{
- const int kSaltSize = 8;
+ const unsigned kSaltSize = 8;
Byte rawPassword[kMaxPasswordLength + kSaltSize];
@@ -106,20 +101,20 @@ void CDecoder::Calculate()
NSha1::CContext sha;
sha.Init();
- // seems rar reverts hash for sha.
- const int hashRounds = 0x40000;
- int i;
- for (i = 0; i < hashRounds; i++)
+ // rar reverts hash for sha.
+ const unsigned kNumRounds = (1 << 18);
+ unsigned i;
+ for (i = 0; i < kNumRounds; i++)
{
sha.Update(rawPassword, rawLength, _rar350Mode);
Byte pswNum[3] = { (Byte)i, (Byte)(i >> 8), (Byte)(i >> 16) };
sha.Update(pswNum, 3, _rar350Mode);
- if (i % (hashRounds / 16) == 0)
+ if (i % (kNumRounds / 16) == 0)
{
NSha1::CContext shaTemp = sha;
Byte digest[NSha1::kDigestSize];
shaTemp.Final(digest);
- aesInit[i / (hashRounds / 16)] = (Byte)digest[4 * 4 + 3];
+ _aesInit[i / (kNumRounds / 16)] = (Byte)digest[4 * 4 + 3];
}
}
/*
@@ -130,7 +125,7 @@ void CDecoder::Calculate()
Byte digest[20];
sha.Final(digest);
for (i = 0; i < 4; i++)
- for (int j = 0; j < 4; j++)
+ for (unsigned j = 0; j < 4; j++)
aesKey[i * 4 + j] = (digest[i * 4 + 3 - j]);
}
_needCalculate = false;
diff --git a/CPP/7zip/Crypto/RarAes.h b/CPP/7zip/Crypto/RarAes.h
index 374017b8..119cc233 100755
--- a/CPP/7zip/Crypto/RarAes.h
+++ b/CPP/7zip/Crypto/RarAes.h
@@ -6,48 +6,36 @@
#include "../../../C/Aes.h"
#include "Common/Buffer.h"
-#include "Common/MyCom.h"
-#include "../ICoder.h"
#include "../IPassword.h"
+#include "MyAes.h"
+
namespace NCrypto {
namespace NRar29 {
const UInt32 kRarAesKeySize = 16;
class CDecoder:
- public ICompressFilter,
+ public CAesCbcDecoder,
public ICompressSetDecoderProperties2,
- public ICryptoSetPassword,
- public CMyUnknownImp
+ public ICryptoSetPassword
{
Byte _salt[8];
bool _thereIsSalt;
CByteBuffer buffer;
Byte aesKey[kRarAesKeySize];
- Byte aesInit[AES_BLOCK_SIZE];
+ Byte _aesInit[AES_BLOCK_SIZE];
bool _needCalculate;
-
- CAesCbc Aes;
-
bool _rar350Mode;
void Calculate();
-
public:
-
MY_UNKNOWN_IMP2(
ICryptoSetPassword,
ICompressSetDecoderProperties2)
-
STDMETHOD(Init)();
-
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
-
STDMETHOD(CryptoSetPassword)(const Byte *aData, UInt32 aSize);
-
- // ICompressSetDecoderProperties
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
CDecoder();
diff --git a/CPP/7zip/Crypto/WzAes.cpp b/CPP/7zip/Crypto/WzAes.cpp
index beb24217..08a1818c 100755
--- a/CPP/7zip/Crypto/WzAes.cpp
+++ b/CPP/7zip/Crypto/WzAes.cpp
@@ -21,7 +21,7 @@ Note: you must include MyAes.cpp to project to initialize AES tables
namespace NCrypto {
namespace NWzAes {
-const unsigned int kAesKeySizeMax = 32;
+const unsigned kAesKeySizeMax = 32;
static const UInt32 kNumKeyGenIterations = 1000;
@@ -34,36 +34,11 @@ STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
return S_OK;
}
-#define SetUi32(p, d) { UInt32 x = (d); (p)[0] = (Byte)x; (p)[1] = (Byte)(x >> 8); \
- (p)[2] = (Byte)(x >> 16); (p)[3] = (Byte)(x >> 24); }
-
-void CBaseCoder::EncryptData(Byte *data, UInt32 size)
-{
- unsigned int pos = _blockPos;
- for (; size > 0; size--)
- {
- if (pos == AES_BLOCK_SIZE)
- {
- if (++_counter[0] == 0)
- _counter[1]++;
- UInt32 temp[4];
- Aes_Encode32(&Aes, temp, _counter);
- SetUi32(_buffer, temp[0]);
- SetUi32(_buffer + 4, temp[1]);
- SetUi32(_buffer + 8, temp[2]);
- SetUi32(_buffer + 12, temp[3]);
- pos = 0;
- }
- *data++ ^= _buffer[pos++];
- }
- _blockPos = pos;
-}
-
#ifndef _NO_WZAES_OPTIMIZATIONS
-static void BytesToBeUInt32s(const Byte *src, UInt32 *dest, int destSize)
+static void BytesToBeUInt32s(const Byte *src, UInt32 *dest, unsigned destSize)
{
- for (int i = 0 ; i < destSize; i++)
+ for (unsigned i = 0; i < destSize; i++)
dest[i] =
((UInt32)(src[i * 4 + 0]) << 24) |
((UInt32)(src[i * 4 + 1]) << 16) |
@@ -79,7 +54,7 @@ STDMETHODIMP CBaseCoder::Init()
UInt32 keysTotalSize = 2 * keySize + kPwdVerifCodeSize;
Byte buf[2 * kAesKeySizeMax + kPwdVerifCodeSize];
- // for (int ii = 0; ii < 1000; ii++)
+ // for (unsigned ii = 0; ii < 1000; ii++)
{
#ifdef _NO_WZAES_OPTIMIZATIONS
@@ -109,23 +84,12 @@ STDMETHODIMP CBaseCoder::Init()
_hmac.SetKey(buf + keySize, keySize);
memcpy(_key.PwdVerifComputed, buf + 2 * keySize, kPwdVerifCodeSize);
-
- _blockPos = AES_BLOCK_SIZE;
- for (int i = 0; i < 4; i++)
- _counter[i] = 0;
- Aes_SetKeyEncode(&Aes, buf, keySize);
+ AesCtr2_Init(&_aes);
+ Aes_SetKey_Enc(_aes.aes + _aes.offset + 8, buf, keySize);
return S_OK;
}
-/*
-STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
-{
- Byte keySizeMode = 3;
- return outStream->Write(&keySizeMode, 1, NULL);
-}
-*/
-
HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream)
{
UInt32 saltSize = _key.GetSaltSize();
@@ -147,11 +111,7 @@ STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
if (size != 1)
return E_INVALIDARG;
_key.Init();
- Byte keySizeMode = data[0];
- if (keySizeMode < 1 || keySizeMode > 3)
- return E_INVALIDARG;
- _key.KeySizeMode = keySizeMode;
- return S_OK;
+ return SetKeyMode(data[0]) ? S_OK : E_INVALIDARG;
}
HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream)
@@ -192,9 +152,61 @@ HRESULT CDecoder::CheckMac(ISequentialInStream *inStream, bool &isOK)
return S_OK;
}
+CAesCtr2::CAesCtr2()
+{
+ offset = ((0 - (unsigned)(ptrdiff_t)aes) & 0xF) / sizeof(UInt32);
+}
+
+void AesCtr2_Init(CAesCtr2 *p)
+{
+ UInt32 *ctr = p->aes + p->offset + 4;
+ unsigned i;
+ for (i = 0; i < 4; i++)
+ ctr[i] = 0;
+ p->pos = AES_BLOCK_SIZE;
+}
+
+void AesCtr2_Code(CAesCtr2 *p, Byte *data, SizeT size)
+{
+ unsigned pos = p->pos;
+ UInt32 *buf32 = p->aes + p->offset;
+ if (size == 0)
+ return;
+ if (pos != AES_BLOCK_SIZE)
+ {
+ const Byte *buf = (const Byte *)buf32;
+ do
+ *data++ ^= buf[pos++];
+ while (--size != 0 && pos != AES_BLOCK_SIZE);
+ }
+ if (size >= 16)
+ {
+ SizeT size2 = size >> 4;
+ g_AesCtr_Code(buf32 + 4, data, size2);
+ size2 <<= 4;
+ data += size2;
+ size -= size2;
+ pos = AES_BLOCK_SIZE;
+ }
+ if (size != 0)
+ {
+ unsigned j;
+ const Byte *buf;
+ for (j = 0; j < 4; j++)
+ buf32[j] = 0;
+ g_AesCtr_Code(buf32 + 4, (Byte *)buf32, 1);
+ buf = (const Byte *)buf32;
+ pos = 0;
+ do
+ *data++ ^= buf[pos++];
+ while (--size != 0 && pos != AES_BLOCK_SIZE);
+ }
+ p->pos = pos;
+}
+
STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
{
- EncryptData(data, size);
+ AesCtr2_Code(&_aes, data, size);
_hmac.Update(data, size);
return size;
}
@@ -202,7 +214,7 @@ STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
{
_hmac.Update(data, size);
- EncryptData(data, size);
+ AesCtr2_Code(&_aes, data, size);
return size;
}
diff --git a/CPP/7zip/Crypto/WzAes.h b/CPP/7zip/Crypto/WzAes.h
index 22f4d4dd..f37fe644 100755
--- a/CPP/7zip/Crypto/WzAes.h
+++ b/CPP/7zip/Crypto/WzAes.h
@@ -26,18 +26,25 @@ specified in password Based File Encryption Utility:
namespace NCrypto {
namespace NWzAes {
-const unsigned int kSaltSizeMax = 16;
-const unsigned int kMacSize = 10;
+const unsigned kSaltSizeMax = 16;
+const unsigned kMacSize = 10;
const UInt32 kPasswordSizeMax = 99; // 128;
// Password Verification Code Size
-const unsigned int kPwdVerifCodeSize = 2;
+const unsigned kPwdVerifCodeSize = 2;
+
+enum EKeySizeMode
+{
+ kKeySizeMode_AES128 = 1,
+ kKeySizeMode_AES192 = 2,
+ kKeySizeMode_AES256 = 3
+};
class CKeyInfo
{
public:
- Byte KeySizeMode; // 1 - 128-bit , 2 - 192-bit , 3 - 256-bit
+ EKeySizeMode KeySizeMode;
Byte Salt[kSaltSizeMax];
Byte PwdVerifComputed[kPwdVerifCodeSize];
@@ -47,9 +54,20 @@ public:
UInt32 GetSaltSize() const { return (4 * (KeySizeMode & 3) + 4); }
CKeyInfo() { Init(); }
- void Init() { KeySizeMode = 3; }
+ void Init() { KeySizeMode = kKeySizeMode_AES256; }
};
+struct CAesCtr2
+{
+ unsigned pos;
+ unsigned offset;
+ UInt32 aes[4 + AES_NUM_IVMRK_WORDS + 3];
+ CAesCtr2();
+};
+
+void AesCtr2_Init(CAesCtr2 *p);
+void AesCtr2_Code(CAesCtr2 *p, Byte *data, SizeT size);
+
class CBaseCoder:
public ICompressFilter,
public ICryptoSetPassword,
@@ -57,15 +75,9 @@ class CBaseCoder:
{
protected:
CKeyInfo _key;
- UInt32 _counter[AES_BLOCK_SIZE / 4];
- Byte _buffer[AES_BLOCK_SIZE];
NSha1::CHmac _hmac;
- unsigned int _blockPos;
Byte _pwdVerifFromArchive[kPwdVerifCodeSize];
-
- void EncryptData(Byte *data, UInt32 size);
-
- CAes Aes;
+ CAesCtr2 _aes;
public:
STDMETHOD(Init)();
@@ -74,26 +86,23 @@ public:
STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
UInt32 GetHeaderSize() const { return _key.GetSaltSize() + kPwdVerifCodeSize; }
+ bool SetKeyMode(unsigned mode)
+ {
+ if (mode < kKeySizeMode_AES128 || mode > kKeySizeMode_AES256)
+ return false;
+ _key.KeySizeMode = (EKeySizeMode)mode;
+ return true;
+ }
};
class CEncoder:
public CBaseCoder
- // public ICompressWriteCoderProperties
{
public:
MY_UNKNOWN_IMP1(ICryptoSetPassword)
- // ICompressWriteCoderProperties
- // STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
HRESULT WriteHeader(ISequentialOutStream *outStream);
HRESULT WriteFooter(ISequentialOutStream *outStream);
- bool SetKeyMode(Byte mode)
- {
- if (mode < 1 || mode > 3)
- return false;
- _key.KeySizeMode = mode;
- return true;
- }
};
class CDecoder:
diff --git a/CPP/7zip/Crypto/ZipStrong.cpp b/CPP/7zip/Crypto/ZipStrong.cpp
index be5b4275..d635fee1 100755
--- a/CPP/7zip/Crypto/ZipStrong.cpp
+++ b/CPP/7zip/Crypto/ZipStrong.cpp
@@ -57,11 +57,6 @@ STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
return S_OK;
}
-STDMETHODIMP CBaseCoder::Init()
-{
- return S_OK;
-}
-
HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream, UInt32 /* crc */, UInt64 /* unpackSize */)
{
Byte temp[4];
@@ -85,79 +80,70 @@ HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream, UInt32 /* crc */, UI
return E_NOTIMPL;
RINOK(ReadStream_FALSE(inStream, temp, 4));
_remSize = GetUi32(temp);
- if (_remSize > _buf.GetCapacity())
+ const UInt32 kAlign = 16;
+ if (_remSize < 16 || _remSize > (1 << 18))
+ return E_NOTIMPL;
+ if (_remSize + kAlign > _buf.GetCapacity())
{
_buf.Free();
- _buf.SetCapacity(_remSize);
+ _buf.SetCapacity(_remSize + kAlign);
+ _bufAligned = (Byte *)((ptrdiff_t)((Byte *)_buf + kAlign - 1) & ~(ptrdiff_t)(kAlign - 1));
}
- return ReadStream_FALSE(inStream, _buf, _remSize);
+ return ReadStream_FALSE(inStream, _bufAligned, _remSize);
}
HRESULT CDecoder::CheckPassword(bool &passwOK)
{
passwOK = false;
- if (_remSize < 10)
+ if (_remSize < 16)
return E_NOTIMPL;
- Byte *p = _buf;
+ Byte *p = _bufAligned;
UInt16 format = GetUi16(p);
if (format != 3)
return E_NOTIMPL;
- UInt16 algId = GetUi16(p + 2);
+ UInt16 algId = GetUi16(p + 2);
if (algId < kAES128)
return E_NOTIMPL;
algId -= kAES128;
if (algId > 2)
return E_NOTIMPL;
UInt16 bitLen = GetUi16(p + 4);
- UInt16 flags = GetUi16(p + 6);
+ UInt16 flags = GetUi16(p + 6);
if (algId * 64 + 128 != bitLen)
return E_NOTIMPL;
_key.KeySize = 16 + algId * 8;
if ((flags & 1) == 0)
return E_NOTIMPL;
UInt32 rdSize = GetUi16(p + 8);
- UInt32 pos = 10;
- Byte *rd = p + pos;
- pos += rdSize;
- if (pos + 4 > _remSize)
+ if ((rdSize & 0xF) != 0 || rdSize + 16 > _remSize)
return E_NOTIMPL;
- UInt32 reserved = GetUi32(p + pos);
- pos += 4;
- if (reserved != 0)
+ memmove(p, p + 10, rdSize);
+ Byte *validData = p + rdSize + 16;
+ if (GetUi32(validData - 6) != 0) // reserved
return E_NOTIMPL;
- if (pos + 2 > _remSize)
- return E_NOTIMPL;
- UInt32 validSize = GetUi16(p + pos);
- pos += 2;
- Byte *validData = p + pos;
- if (pos + validSize != _remSize)
+ UInt32 validSize = GetUi16(validData - 2);
+ if ((validSize & 0xF) != 0 || 16 + rdSize + validSize != _remSize)
return E_NOTIMPL;
- if (!_aesFilter)
- _aesFilter = new CAesCbcDecoder;
- CMyComPtr<ICryptoProperties> cp;
- RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
{
- RINOK(cp->SetKey(_key.MasterKey, _key.KeySize));
- RINOK(cp->SetInitVector(_iv, 16));
- _aesFilter->Init();
- if (_aesFilter->Filter(rd, rdSize) != rdSize)
- return E_NOTIMPL;
+ RINOK(SetKey(_key.MasterKey, _key.KeySize));
+ RINOK(SetInitVector(_iv, 16));
+ Init();
+ Filter(p, rdSize);
}
Byte fileKey[32];
NSha1::CContext sha;
sha.Init();
sha.Update(_iv, 16);
- sha.Update(rd, rdSize - 16); // we don't use last 16 bytes (PAD bytes)
+ sha.Update(p, rdSize - 16); // we don't use last 16 bytes (PAD bytes)
DeriveKey(sha, fileKey);
- RINOK(cp->SetKey(fileKey, _key.KeySize));
- RINOK(cp->SetInitVector(_iv, 16));
- _aesFilter->Init();
- if (_aesFilter->Filter(validData, validSize) != validSize)
- return E_NOTIMPL;
+ RINOK(SetKey(fileKey, _key.KeySize));
+ RINOK(SetInitVector(_iv, 16));
+ Init();
+ Filter(validData, validSize);
if (validSize < 4)
return E_NOTIMPL;
@@ -165,13 +151,8 @@ HRESULT CDecoder::CheckPassword(bool &passwOK)
if (GetUi32(validData + validSize) != CrcCalc(validData, validSize))
return S_OK;
passwOK = true;
- _aesFilter->Init();
+ Init();
return S_OK;
}
-STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
-{
- return _aesFilter->Filter(data, size);
-}
-
}}
diff --git a/CPP/7zip/Crypto/ZipStrong.h b/CPP/7zip/Crypto/ZipStrong.h
index 6ea00b34..151677ea 100755
--- a/CPP/7zip/Crypto/ZipStrong.h
+++ b/CPP/7zip/Crypto/ZipStrong.h
@@ -3,12 +3,12 @@
#ifndef __CRYPTO_ZIP_STRONG_H
#define __CRYPTO_ZIP_STRONG_H
-#include "Common/MyCom.h"
#include "Common/Buffer.h"
-#include "../ICoder.h"
#include "../IPassword.h"
+#include "MyAes.h"
+
namespace NCrypto {
namespace NZipStrong {
@@ -20,30 +20,24 @@ struct CKeyInfo
};
class CBaseCoder:
- public ICompressFilter,
- public ICryptoSetPassword,
- public CMyUnknownImp
+ public CAesCbcDecoder,
+ public ICryptoSetPassword
{
protected:
CKeyInfo _key;
- CMyComPtr<ICompressFilter> _aesFilter;
CByteBuffer _buf;
+ Byte *_bufAligned;
public:
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) = 0;
-
STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
};
-class CDecoder:
- public CBaseCoder
+class CDecoder: public CBaseCoder
{
UInt32 _ivSize;
Byte _iv[16];
UInt32 _remSize;
public:
MY_UNKNOWN_IMP1(ICryptoSetPassword)
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
HRESULT ReadHeader(ISequentialInStream *inStream, UInt32 crc, UInt64 unpackSize);
HRESULT CheckPassword(bool &passwOK);
};
diff --git a/CPP/7zip/Guid.txt b/CPP/7zip/Guid.txt
index cb4d73d9..9843b16e 100755
--- a/CPP/7zip/Guid.txt
+++ b/CPP/7zip/Guid.txt
@@ -125,6 +125,7 @@ Handler GUIDs:
0B lzma86
0C xz
+ D4 APM
D5 Mslz
D6 Flv
D7 Swf
diff --git a/CPP/7zip/ICoder.h b/CPP/7zip/ICoder.h
index b5d4d556..6a2ca6ca 100755
--- a/CPP/7zip/ICoder.h
+++ b/CPP/7zip/ICoder.h
@@ -111,6 +111,7 @@ CODER_INTERFACE(ICompressFilter, 0x40)
{
STDMETHOD(Init)() PURE;
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) PURE;
+ // Filter converts as most as possible bytes
// Filter return outSize (UInt32)
// if (outSize <= size): Filter have converted outSize bytes
// if (outSize > size): Filter have not converted anything.
diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h
index a254d321..c9ebe92b 100755
--- a/CPP/7zip/MyVersion.h
+++ b/CPP/7zip/MyVersion.h
@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 9
-#define MY_VER_MINOR 07
+#define MY_VER_MINOR 9
#define MY_VER_BUILD 0
-#define MY_VERSION "9.07 beta"
-#define MY_7ZIP_VERSION "7-Zip 9.07 beta"
-#define MY_DATE "2009-08-29"
+#define MY_VERSION "9.09 beta"
+#define MY_7ZIP_VERSION "7-Zip 9.09 beta"
+#define MY_DATE "2009-12-12"
#define MY_COPYRIGHT "Copyright (c) 1999-2009 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
diff --git a/CPP/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h
index 50b101f4..6e157615 100755
--- a/CPP/7zip/UI/Agent/Agent.h
+++ b/CPP/7zip/UI/Agent/Agent.h
@@ -48,8 +48,7 @@ class CAgentFolder:
{
public:
- MY_QUERYINTERFACE_BEGIN
- MY_QUERYINTERFACE_ENTRY(IFolderFolder)
+ MY_QUERYINTERFACE_BEGIN2(IFolderFolder)
MY_QUERYINTERFACE_ENTRY(IFolderProperties)
MY_QUERYINTERFACE_ENTRY(IGetFolderArchiveProperties)
MY_QUERYINTERFACE_ENTRY(IArchiveFolder)
@@ -142,8 +141,7 @@ class CAgent:
{
public:
- MY_QUERYINTERFACE_BEGIN
- MY_QUERYINTERFACE_ENTRY(IInFolderArchive)
+ MY_QUERYINTERFACE_BEGIN2(IInFolderArchive)
MY_QUERYINTERFACE_ENTRY(IFolderArchiveProperties)
#ifndef EXTRACT_ONLY
MY_QUERYINTERFACE_ENTRY(IOutFolderArchive)
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
index cfb0f796..93806717 100755
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
@@ -181,6 +181,7 @@ static const int kCommandIndex = 0;
// exception messages
static const char *kUserErrorMessage = "Incorrect command line";
+static const char *kCannotFindListFile = "Cannot find listfile";
static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
static const char *kIncorrectWildCardInListFile = "Incorrect wildcard in listfile";
static const char *kIncorrectWildCardInCommandLine = "Incorrect wildcard in command line";
@@ -281,6 +282,8 @@ static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
{
UStringVector names;
+ if (!NFind::DoesFileExist(fileName))
+ throw kCannotFindListFile;
if (!ReadNamesFromListFile(fileName, names, codePage))
throw kIncorrectListFile;
for (int i = 0; i < names.Size(); i++)
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp b/CPP/7zip/UI/Common/Bench.cpp
index d115ed23..36449660 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
+++ b/CPP/7zip/UI/Common/Bench.cpp
@@ -1,8 +1,8 @@
-// LzmaBench.cpp
+// Bench.cpp
#include "StdAfx.h"
-#include "LzmaBench.h"
+#include "Bench.h"
#ifndef _WIN32
#define USE_POSIX_TIME
@@ -31,20 +31,12 @@
#include "../../../../C/7zCrc.h"
#include "../../../../C/Alloc.h"
-#include "../../../Common/MyCom.h"
-
-#ifdef BENCH_MT
+#ifndef _7ZIP_ST
#include "../../../Windows/Synchronization.h"
#include "../../../Windows/Thread.h"
#endif
-#ifdef EXTERNAL_LZMA
#include "../../../Windows/PropVariant.h"
-#include "../../ICoder.h"
-#else
-#include "../LzmaDecoder.h"
-#include "../LzmaEncoder.h"
-#endif
static const UInt32 kUncompressMinBlockSize =
#ifdef UNDER_CE
@@ -316,7 +308,7 @@ static UInt64 GetUserFreq()
class CBenchProgressStatus
{
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
NWindows::NSynchronization::CCriticalSection CS;
#endif
public:
@@ -324,14 +316,14 @@ public:
bool EncodeMode;
void SetResult(HRESULT res)
{
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
NWindows::NSynchronization::CCriticalSectionLock lock(CS);
#endif
Res = res;
}
HRESULT GetResult()
{
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
NWindows::NSynchronization::CCriticalSectionLock lock(CS);
#endif
return Res;
@@ -467,16 +459,11 @@ UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt
return MyMultDiv64(numCommands, elapsedTime, freq);
}
-#ifdef EXTERNAL_LZMA
-typedef UInt32 (WINAPI * CreateObjectPointer)(const GUID *clsID,
- const GUID *interfaceID, void **outObject);
-#endif
-
struct CEncoderInfo;
struct CEncoderInfo
{
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
NWindows::CThread thread[2];
#endif
CMyComPtr<ICompressCoder> encoder;
@@ -515,7 +502,7 @@ struct CEncoderInfo
CEncoderInfo(): outStreamSpec(0), callback(0), propStreamSpec(0) {}
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
static THREAD_FUNC_DECL EncodeThreadFunction(void *param)
{
CEncoderInfo *encoder = (CEncoderInfo *)param;
@@ -677,19 +664,17 @@ struct CBenchEncoders
};
HRESULT LzmaBench(
- #ifdef EXTERNAL_LZMA
- CCodecs *codecs,
- #endif
+ DECL_EXTERNAL_CODECS_LOC_VARS
UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback)
{
UInt32 numEncoderThreads =
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
(numThreads > 1 ? numThreads / 2 : 1);
#else
1;
#endif
UInt32 numSubDecoderThreads =
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
(numThreads > 1 ? 2 : 1);
#else
1;
@@ -702,9 +687,6 @@ HRESULT LzmaBench(
CBenchEncoders encodersSpec(numEncoderThreads);
CEncoderInfo *encoders = encodersSpec.encoders;
- #ifdef EXTERNAL_LZMA
- UString name = L"LZMA";
- #endif
UInt32 i;
for (i = 0; i < numEncoderThreads; i++)
@@ -712,18 +694,11 @@ HRESULT LzmaBench(
CEncoderInfo &encoder = encoders[i];
encoder.callback = (i == 0) ? callback : 0;
- #ifdef EXTERNAL_LZMA
- RINOK(codecs->CreateCoder(name, true, encoder.encoder));
- #else
- encoder.encoder = new NCompress::NLzma::CEncoder;
- #endif
+ const UInt32 kLzmaId = 0x030101;
+ RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS kLzmaId, encoder.encoder, true));
for (UInt32 j = 0; j < numSubDecoderThreads; j++)
{
- #ifdef EXTERNAL_LZMA
- RINOK(codecs->CreateCoder(name, false, encoder.decoders[j]));
- #else
- encoder.decoders[j] = new NCompress::NLzma::CDecoder;
- #endif
+ RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS kLzmaId, encoder.decoders[j], false));
}
}
@@ -753,7 +728,7 @@ HRESULT LzmaBench(
SetStartTime(encoder.progressInfoSpec[0]->BenchInfo);
}
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
if (numEncoderThreads > 1)
{
#ifdef USE_ALLOCA
@@ -767,7 +742,7 @@ HRESULT LzmaBench(
RINOK(encoder.Encode());
}
}
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
if (numEncoderThreads > 1)
for (i = 0; i < numEncoderThreads; i++)
encoders[i].thread[0].Wait();
@@ -806,7 +781,7 @@ HRESULT LzmaBench(
SetStartTime(encoder.progressInfoSpec[0]->BenchInfo);
}
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
if (numDecoderThreads > 1)
{
for (UInt32 j = 0; j < numSubDecoderThreads; j++)
@@ -825,7 +800,7 @@ HRESULT LzmaBench(
RINOK(encoder.Decode(0));
}
}
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
HRESULT res = S_OK;
if (numDecoderThreads > 1)
for (i = 0; i < numEncoderThreads; i++)
@@ -840,7 +815,7 @@ HRESULT LzmaBench(
#endif
RINOK(status.Res);
SetFinishTime(encoders[0].progressInfoSpec[0]->BenchInfo, info);
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
#ifdef UNDER_CE
if (numDecoderThreads > 1)
for (i = 0; i < numEncoderThreads; i++)
@@ -901,7 +876,7 @@ static bool CrcBig(const void *data, UInt32 size, UInt32 numCycles, UInt32 crcBa
return true;
}
-#ifdef BENCH_MT
+#ifndef _7ZIP_ST
struct CCrcInfo
{
NWindows::CThread Thread;
@@ -1004,7 +979,7 @@ HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed)
UInt32 numCycles = (kCrcBlockSize) / ((bufferSize >> 2) + 1) + 1;
UInt64 timeVal;
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
CCrcThreads threads;
if (numThreads > 1)
{
@@ -1047,4 +1022,3 @@ HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed)
speed = MyMultDiv64(size, timeVal, GetFreq());
return S_OK;
}
-
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h b/CPP/7zip/UI/Common/Bench.h
index f8aeb6be..a8d02a19 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h
+++ b/CPP/7zip/UI/Common/Bench.h
@@ -1,13 +1,9 @@
-// LzmaBench.h
+// Bench.h
-#ifndef __LZMABENCH_H
-#define __LZMABENCH_H
+#ifndef __7ZIP_BENCH_H
+#define __7ZIP_BENCH_H
-#include <stdio.h>
-#include "../../../Common/Types.h"
-#ifdef EXTERNAL_LZMA
-#include "../../UI/Common/LoadCodecs.h"
-#endif
+#include "../../Common/CreateCoder.h"
struct CBenchInfo
{
@@ -33,9 +29,7 @@ UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq,
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations);
HRESULT LzmaBench(
- #ifdef EXTERNAL_LZMA
- CCodecs *codecs,
- #endif
+ DECL_EXTERNAL_CODECS_LOC_VARS
UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback);
const int kBenchMinDicLogSize = 18;
diff --git a/CPP/7zip/UI/Common/CompressCall2.cpp b/CPP/7zip/UI/Common/CompressCall2.cpp
index 0ed227ca..473f7d93 100755
--- a/CPP/7zip/UI/Common/CompressCall2.cpp
+++ b/CPP/7zip/UI/Common/CompressCall2.cpp
@@ -163,9 +163,14 @@ HRESULT Benchmark()
HRESULT result;
MY_TRY_BEGIN
CREATE_CODECS
+
+ #ifdef EXTERNAL_CODECS
+ CObjectVector<CCodecInfoEx> externalCodecs;
+ RINOK(LoadExternalCodecs(codecs, externalCodecs));
+ #endif
result = Benchmark(
- #ifdef EXTERNAL_LZMA
- codecs,
+ #ifdef EXTERNAL_CODECS
+ codecs, &externalCodecs,
#endif
(UInt32)-1, (UInt32)-1, g_HWND);
MY_TRY_FINISH
diff --git a/CPP/7zip/UI/Common/Extract.cpp b/CPP/7zip/UI/Common/Extract.cpp
index 93329091..f9de663b 100755
--- a/CPP/7zip/UI/Common/Extract.cpp
+++ b/CPP/7zip/UI/Common/Extract.cpp
@@ -78,7 +78,7 @@ static HRESULT DecompressArchive(
removePathParts,
packSize);
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
RINOK(SetProperties(archive, options.Properties));
#endif
diff --git a/CPP/7zip/UI/Common/Extract.h b/CPP/7zip/UI/Common/Extract.h
index 442dd2b0..5a939ed2 100755
--- a/CPP/7zip/UI/Common/Extract.h
+++ b/CPP/7zip/UI/Common/Extract.h
@@ -28,7 +28,7 @@ struct CExtractOptions
// bool ShowDialog;
// bool PasswordEnabled;
// UString Password;
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
CObjectVector<CProperty> Properties;
#endif
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp b/CPP/7zip/UI/Console/BenchCon.cpp
index b1c455e9..96997dcb 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
+++ b/CPP/7zip/UI/Console/BenchCon.cpp
@@ -1,21 +1,18 @@
-// LzmaBenchCon.cpp
+// BenchCon.cpp
#include "StdAfx.h"
-#include <stdio.h>
-
-#include "LzmaBench.h"
-#include "LzmaBenchCon.h"
#include "../../../Common/IntToString.h"
+#include "../../../Common/MyCom.h"
-#if defined(BENCH_MT) || defined(_WIN32)
+#if !defined(_7ZIP_ST) || defined(_WIN32)
#include "../../../Windows/System.h"
#endif
-#ifdef BREAK_HANDLER
-#include "../../UI/Console/ConsoleClose.h"
-#endif
-#include "../../../Common/MyCom.h"
+#include "../Common/Bench.h"
+
+#include "BenchCon.h"
+#include "ConsoleClose.h"
struct CTotalBenchRes
{
@@ -117,11 +114,8 @@ static void PrintTotals(FILE *f, const CTotalBenchRes &res)
HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
{
- #ifdef BREAK_HANDLER
if (NConsoleClose::TestBreakSignal())
return E_ABORT;
- #endif
-
if (final)
{
UInt64 rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, info.UnpackSize);
@@ -135,10 +129,8 @@ static const char *kSep = " | ";
HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
{
- #ifdef BREAK_HANDLER
if (NConsoleClose::TestBreakSignal())
return E_ABORT;
- #endif
if (final)
{
UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
@@ -160,14 +152,12 @@ static void PrintRequirements(FILE *f, const char *sizeString, UInt64 size, cons
}
HRESULT LzmaBenchCon(
- #ifdef EXTERNAL_LZMA
- CCodecs *codecs,
- #endif
+ DECL_EXTERNAL_CODECS_LOC_VARS
FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
{
if (!CrcInternalTest())
return S_FALSE;
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
@@ -222,9 +212,7 @@ HRESULT LzmaBenchCon(
fprintf(f, "%2d:", pow);
callback.dictionarySize = (UInt32)1 << pow;
HRESULT res = LzmaBench(
- #ifdef EXTERNAL_LZMA
- codecs,
- #endif
+ EXTERNAL_CODECS_LOC_VARS
numThreads, callback.dictionarySize, &callback);
fprintf(f, "\n");
RINOK(res);
@@ -255,7 +243,7 @@ HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dic
if (!CrcInternalTest())
return S_FALSE;
- #ifdef BENCH_MT
+ #ifndef _7ZIP_ST
UInt64 ramSize = NWindows::NSystem::GetRamSize();
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
@@ -288,10 +276,8 @@ HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dic
UInt64 speed;
for (UInt32 ti = 0; ti < numThreads; ti++)
{
- #ifdef BREAK_HANDLER
if (NConsoleClose::TestBreakSignal())
return E_ABORT;
- #endif
RINOK(CrcBench(ti + 1, bufSize, speed));
PrintNumber(f, (speed >> 20), 5);
speedTotals.Values[ti] += speed;
diff --git a/CPP/7zip/UI/Console/BenchCon.h b/CPP/7zip/UI/Console/BenchCon.h
new file mode 100755
index 00000000..966a83a6
--- /dev/null
+++ b/CPP/7zip/UI/Console/BenchCon.h
@@ -0,0 +1,16 @@
+// BenchCon.h
+
+#ifndef __BENCH_CON_H
+#define __BENCH_CON_H
+
+#include <stdio.h>
+
+#include "../../Common/CreateCoder.h"
+
+HRESULT LzmaBenchCon(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
+
+HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
+
+#endif
diff --git a/CPP/7zip/UI/Console/Console.dsp b/CPP/7zip/UI/Console/Console.dsp
index 05d15e65..aa2e0cb8 100755
--- a/CPP/7zip/UI/Console/Console.dsp
+++ b/CPP/7zip/UI/Console/Console.dsp
@@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BREAK_HANDLER" /D "BENCH_MT" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /FAs /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BREAK_HANDLER" /D "BENCH_MT" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -94,7 +94,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BREAK_HANDLER" /D "BENCH_MT" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -120,7 +120,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BREAK_HANDLER" /D "BENCH_MT" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -184,6 +184,14 @@ SOURCE=.\List.h
# End Source File
# Begin Source File
+SOURCE=.\BenchCon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BenchCon.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Main.cpp
# End Source File
# Begin Source File
@@ -540,6 +548,14 @@ SOURCE=..\Common\LoadCodecs.h
# End Source File
# Begin Source File
+SOURCE=..\Common\Bench.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\Bench.h
+# End Source File
+# Begin Source File
+
SOURCE=..\Common\OpenArchive.cpp
# End Source File
# Begin Source File
@@ -640,64 +656,60 @@ SOURCE=..\Common\ZipRegistry.h
# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\Common\FilePathAutoRename.cpp
+SOURCE=..\..\Common\CreateCoder.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\FilePathAutoRename.h
+SOURCE=..\..\Common\CreateCoder.h
# End Source File
# Begin Source File
-SOURCE=..\..\Common\FileStreams.cpp
+SOURCE=..\..\Common\FilePathAutoRename.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\FileStreams.h
+SOURCE=..\..\Common\FilePathAutoRename.h
# End Source File
# Begin Source File
-SOURCE=..\..\Common\ProgressUtils.cpp
+SOURCE=..\..\Common\FileStreams.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\ProgressUtils.h
+SOURCE=..\..\Common\FileStreams.h
# End Source File
# Begin Source File
-SOURCE=..\..\Common\RegisterArc.h
+SOURCE=..\..\Common\FilterCoder.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\StreamUtils.cpp
+SOURCE=..\..\Common\FilterCoder.h
# End Source File
# Begin Source File
-SOURCE=..\..\Common\StreamUtils.h
+SOURCE=..\..\Common\ProgressUtils.cpp
# End Source File
-# End Group
-# Begin Group "Compress"
-
-# PROP Default_Filter ""
-# Begin Group "LzmaBench"
-
-# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.cpp
+SOURCE=..\..\Common\ProgressUtils.h
# End Source File
# Begin Source File
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.h
+SOURCE=..\..\Common\RegisterArc.h
# End Source File
# Begin Source File
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBenchCon.cpp
+SOURCE=..\..\Common\StreamUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBenchCon.h
+SOURCE=..\..\Common\StreamUtils.h
# End Source File
# End Group
+# Begin Group "Compress"
+
+# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Compress\CopyCoder.cpp
@@ -713,7 +725,26 @@ SOURCE=..\..\Compress\CopyCoder.h
# Begin Source File
SOURCE=..\..\..\..\C\7zCrc.c
+
+!IF "$(CFG)" == "Console - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Console - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Console - Win32 ReleaseU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "Console - Win32 DebugU"
+
# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
# End Source File
# Begin Source File
@@ -730,6 +761,15 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\CpuArch.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -750,5 +790,68 @@ SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
# End Source File
# End Group
+# Begin Group "Asm"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\Asm\x86\7zAsm.asm
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\Asm\x86\7zCrcOpt.asm
+
+!IF "$(CFG)" == "Console - Win32 Release"
+
+# Begin Custom Build
+OutDir=.\Release
+InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
+InputName=7zCrcOpt
+
+"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ml.exe -c -Fo$(OutDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "Console - Win32 Debug"
+
+# Begin Custom Build
+OutDir=.\Debug
+InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
+InputName=7zCrcOpt
+
+"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ml.exe -c -omf -Fo$(OutDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "Console - Win32 ReleaseU"
+
+# Begin Custom Build
+OutDir=.\ReleaseU
+InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
+InputName=7zCrcOpt
+
+"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ml.exe -c -Fo$(OutDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "Console - Win32 DebugU"
+
+# Begin Custom Build
+OutDir=.\DebugU
+InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
+InputName=7zCrcOpt
+
+"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ml.exe -c -omf -Fo$(OutDir)\$(InputName).obj $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
# End Target
# End Project
diff --git a/CPP/7zip/UI/Console/ConsoleClose.cpp b/CPP/7zip/UI/Console/ConsoleClose.cpp
index f1356a28..5acae942 100755
--- a/CPP/7zip/UI/Console/ConsoleClose.cpp
+++ b/CPP/7zip/UI/Console/ConsoleClose.cpp
@@ -9,7 +9,7 @@ static const int kBreakAbortThreshold = 2;
namespace NConsoleClose {
-#ifndef UNDER_CE
+#if !defined(UNDER_CE) && defined(_WIN32)
static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
{
if (ctrlType == CTRL_LOGOFF_EVENT)
@@ -56,7 +56,7 @@ void CheckCtrlBreak()
CCtrlHandlerSetter::CCtrlHandlerSetter()
{
- #ifndef UNDER_CE
+ #if !defined(UNDER_CE) && defined(_WIN32)
if(!SetConsoleCtrlHandler(HandlerRoutine, TRUE))
throw "SetConsoleCtrlHandler fails";
#endif
@@ -64,7 +64,7 @@ CCtrlHandlerSetter::CCtrlHandlerSetter()
CCtrlHandlerSetter::~CCtrlHandlerSetter()
{
- #ifndef UNDER_CE
+ #if !defined(UNDER_CE) && defined(_WIN32)
if(!SetConsoleCtrlHandler(HandlerRoutine, FALSE))
throw "SetConsoleCtrlHandler fails";
#endif
diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp
index c8327361..7cb2a396 100755
--- a/CPP/7zip/UI/Console/Main.cpp
+++ b/CPP/7zip/UI/Console/Main.cpp
@@ -28,8 +28,7 @@
#endif
#include "../Common/PropIDUtils.h"
-#include "../../Compress/LZMA_Alone/LzmaBenchCon.h"
-
+#include "BenchCon.h"
#include "ExtractCallbackConsole.h"
#include "List.h"
#include "OpenCallbackConsole.h"
@@ -355,10 +354,17 @@ int Main2(
}
else
{
- HRESULT res = LzmaBenchCon(
- #ifdef EXTERNAL_LZMA
- codecs,
- #endif
+ HRESULT res;
+ #ifdef EXTERNAL_CODECS
+ CObjectVector<CCodecInfoEx> externalCodecs;
+ res = LoadExternalCodecs(compressCodecsInfo, externalCodecs);
+ if (res != S_OK)
+ throw CSystemException(res);
+ #endif
+ res = LzmaBenchCon(
+ #ifdef EXTERNAL_CODECS
+ compressCodecsInfo, &externalCodecs,
+ #endif
(FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
if (res != S_OK)
{
@@ -404,7 +410,7 @@ int Main2(
eo.OutputDir = options.OutputDir;
eo.YesToAll = options.YesToAll;
eo.CalcCrc = options.CalcCrc;
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
eo.Properties = options.ExtractProperties;
#endif
UString errorMessage;
diff --git a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
index ccb6c866..7f337319 100755
--- a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
+++ b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
@@ -5,7 +5,7 @@
#include "UpdateCallbackConsole.h"
#include "Windows/Error.h"
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
#include "Windows/Synchronization.h"
#endif
@@ -14,7 +14,7 @@
using namespace NWindows;
-#ifdef COMPRESS_MT
+#ifndef _7ZIP_ST
static NSynchronization::CCriticalSection g_CriticalSection;
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
#else
diff --git a/CPP/7zip/UI/Console/makefile b/CPP/7zip/UI/Console/makefile
index 467651ca..9b8fc37a 100755
--- a/CPP/7zip/UI/Console/makefile
+++ b/CPP/7zip/UI/Console/makefile
@@ -1,11 +1,7 @@
PROG = 7z.exe
MY_CONSOLE = 1
CFLAGS = $(CFLAGS) -I ../../../ \
- -DCOMPRESS_MT \
- -DEXTERNAL_LZMA \
-DEXTERNAL_CODECS \
- -DBREAK_HANDLER \
- -DBENCH_MT \
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
@@ -16,6 +12,7 @@ CONSOLE_OBJS = \
$O\ConsoleClose.obj \
$O\ExtractCallbackConsole.obj \
$O\List.obj \
+ $O\BenchCon.obj \
$O\Main.obj \
$O\MainAr.obj \
$O\OpenCallbackConsole.obj \
@@ -53,8 +50,10 @@ WIN_OBJS = \
$O\Time.obj \
7ZIP_COMMON_OBJS = \
+ $O\CreateCoder.obj \
$O\FilePathAutoRename.obj \
$O\FileStreams.obj \
+ $O\FilterCoder.obj \
$O\ProgressUtils.obj \
$O\StreamUtils.obj \
@@ -66,6 +65,7 @@ UI_COMMON_OBJS = \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
+ $O\Bench.obj \
$O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
@@ -82,15 +82,12 @@ UI_COMMON_OBJS = \
AR_COMMON_OBJS = \
$O\OutStreamWithCRC.obj \
-LZMA_BENCH_OBJS = \
- $O\LzmaBench.obj \
- $O\LzmaBenchCon.obj \
-
C_OBJS = \
$O\Alloc.obj \
+ $O\CpuArch.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -101,9 +98,8 @@ OBJS = \
$(UI_COMMON_OBJS) \
$(AR_COMMON_OBJS) \
$O\CopyCoder.obj \
- $(LZMA_BENCH_OBJS) \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
!include "../../../Build.mak"
@@ -122,8 +118,7 @@ $(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
$(COMPL)
$O\CopyCoder.obj: ../../Compress/$(*B).cpp
$(COMPL)
-$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp
- $(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+
+!include "../../Asm.mak"
diff --git a/CPP/7zip/UI/Far/Far.dsp b/CPP/7zip/UI/Far/Far.dsp
index 229035f9..0a96bc08 100755
--- a/CPP/7zip/UI/Far/Far.dsp
+++ b/CPP/7zip/UI/Far/Far.dsp
@@ -579,6 +579,11 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -588,6 +593,11 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Sort.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
diff --git a/CPP/7zip/UI/Far/makefile b/CPP/7zip/UI/Far/makefile
index 29d7bcf4..076818e4 100755
--- a/CPP/7zip/UI/Far/makefile
+++ b/CPP/7zip/UI/Far/makefile
@@ -74,10 +74,11 @@ AGENT_OBJS = \
C_OBJS = \
$O\Alloc.obj \
+ $O\CpuArch.obj \
$O\Sort.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -88,9 +89,9 @@ OBJS = \
$(UI_COMMON_OBJS) \
$(AR_COMMON_OBJS) \
$(AGENT_OBJS) \
- $(C_OBJS) \
$O\CopyCoder.obj \
- $(CRC_OBJS) \
+ $(C_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
!include "../../../Build.mak"
@@ -113,4 +114,4 @@ $O\CopyCoder.obj: ../../Compress/$(*B).cpp
$(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp
index 615043b5..f8ec9364 100755
--- a/CPP/7zip/UI/FileManager/FM.dsp
+++ b/CPP/7zip/UI/FileManager/FM.dsp
@@ -660,6 +660,31 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+
+!IF "$(CFG)" == "FM - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -669,6 +694,35 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+
+!IF "$(CFG)" == "FM - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\CpuArch.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Sha256.c
!IF "$(CFG)" == "FM - Win32 Release"
diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h
index 42e33242..e39004ad 100755
--- a/CPP/7zip/UI/FileManager/FSFolder.h
+++ b/CPP/7zip/UI/FileManager/FSFolder.h
@@ -50,7 +50,7 @@ class CFSFolder:
{
UInt64 GetSizeOfItem(int anIndex) const;
public:
- MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_BEGIN2(IFolderFolder)
MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
// MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin)
MY_QUERYINTERFACE_ENTRY(IFolderOperations)
diff --git a/CPP/7zip/UI/FileManager/MyCom2.h b/CPP/7zip/UI/FileManager/MyCom2.h
index 756a8169..98b1d708 100755
--- a/CPP/7zip/UI/FileManager/MyCom2.h
+++ b/CPP/7zip/UI/FileManager/MyCom2.h
@@ -10,23 +10,14 @@ STDMETHOD_(ULONG, AddRef)() { InterlockedIncrement((LONG *)&__m_RefCount); retur
STDMETHOD_(ULONG, Release)() { InterlockedDecrement((LONG *)&__m_RefCount); if (__m_RefCount != 0) \
return __m_RefCount; delete this; return 0; }
-#define MY_UNKNOWN_IMP_SPEC_MT(i) \
- MY_QUERYINTERFACE_BEGIN \
- MY_QUERYINTERFACE_ENTRY(IUnknown) \
- i \
- MY_QUERYINTERFACE_END \
- MY_ADDREF_RELEASE_MT
-
#define MY_UNKNOWN_IMP_SPEC_MT2(i1, i) \
MY_QUERYINTERFACE_BEGIN \
- if (iid == IID_IUnknown) \
- { *outObject = (void *)(IUnknown *)(i1 *)this; AddRef(); return S_OK; } i \
+ MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \
+ i \
MY_QUERYINTERFACE_END \
MY_ADDREF_RELEASE_MT
-#define MY_UNKNOWN_IMP_MT MY_UNKNOWN_IMP_SPEC_MT(;)
-
#define MY_UNKNOWN_IMP1_MT(i) MY_UNKNOWN_IMP_SPEC_MT2( \
i, \
MY_QUERYINTERFACE_ENTRY(i) \
diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
index 2deea0af..b77d3e2a 100755
--- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
@@ -172,7 +172,7 @@ static const wchar_t *kStartExtensions[] =
L"docx", L"docm", L"dotx", L"dotm", L"xlsx", L"xlsm", L"xltx", L"xltm", L"xlsb",
L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn",
-
+ L"msg",
L"dwf",
L"flv", L"swf",
diff --git a/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp b/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp
deleted file mode 100755
index 12b7dce8..00000000
--- a/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-// PhysDriveFolder.cpp
-
-#include "StdAfx.h"
-
-#include "../../../../C/Alloc.h"
-
-#include "Common/Buffer.h"
-
-#include "Windows/PropVariant.h"
-#include "Windows/FileDevice.h"
-#include "Windows/FileSystem.h"
-
-#include "../../PropID.h"
-
-#include "PhysDriveFolder.h"
-
-using namespace NWindows;
-
-static const UInt32 kBufferSize = (4 << 20);
-static STATPROPSTG kProperties[] =
-{
- { NULL, kpidName, VT_BSTR},
- { NULL, kpidSize, VT_UI8}
-};
-
-HRESULT CPhysDriveFolder::Init(const UString &path)
-{
- _prefix = L"\\\\.\\";
- _path = path;
- NFile::NDevice::CInFile inFile;
- if (!inFile.Open(GetFullPath()))
- return GetLastError();
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::LoadItems()
-{
- _driveType = NFile::NSystem::MyGetDriveType(_path + L"\\");
- _name = _path.Left(1);
- _name += L'.';
- if (_driveType == DRIVE_CDROM)
- _name += L"iso";
- else
- _name += L"img";
- Int32 dummy;
- WasChanged(&dummy);
- return GetLength(_length);
-}
-
-STDMETHODIMP CPhysDriveFolder::GetNumberOfItems(UInt32 *numItems)
-{
- *numItems = 1;
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
-{
- NCOM::CPropVariant prop;
- if (itemIndex >= 1)
- return E_INVALIDARG;
- switch(propID)
- {
- case kpidIsDir: prop = false; break;
- case kpidName: prop = _name; break;
- case kpidSize: prop = _length; break;
- }
- prop.Detach(value);
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::BindToFolder(UInt32 /* index */, IFolderFolder ** /* resultFolder */)
- { return E_NOTIMPL; }
-
-STDMETHODIMP CPhysDriveFolder::BindToFolder(const wchar_t * /* name */, IFolderFolder ** /* resultFolder */)
- { return E_NOTIMPL; }
-
-STDMETHODIMP CPhysDriveFolder::BindToParentFolder(IFolderFolder **resultFolder)
-{
- *resultFolder = 0;
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::GetNumberOfProperties(UInt32 *numProperties)
-{
- *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::GetPropertyInfo(UInt32 index,
- BSTR *name, PROPID *propID, VARTYPE *varType)
-{
- if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
- return E_INVALIDARG;
- const STATPROPSTG &prop = kProperties[index];
- *propID = prop.propid;
- *varType = prop.vt;
- *name = 0;
- return S_OK;
-}
-
-
-STDMETHODIMP CPhysDriveFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
-{
- NWindows::NCOM::CPropVariant prop;
- switch(propID)
- {
- case kpidType: prop = L"PhysDrive"; break;
- case kpidPath: prop = (GetFullPath() + L"\\"); break;
- }
- prop.Detach(value);
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::WasChanged(Int32 *wasChanged)
-{
- bool wasChangedMain = false;
- *wasChanged = BoolToInt(wasChangedMain);
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::Clone(IFolderFolder **resultFolder)
-{
- CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
- CMyComPtr<IFolderFolder> folderNew = folderSpec;
- folderSpec->Init(_path);
- *resultFolder = folderNew.Detach();
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress * /* progress */)
-{
- NCOM::CPropVariant prop;
- if (index >= 1)
- return E_INVALIDARG;
- UInt64 size = 0;
- HRESULT result = GetLength(size);
- prop = size;
- prop.Detach(value);
- return result;
-}
-
-STDMETHODIMP CPhysDriveFolder::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */)
- { return E_NOTIMPL; }
-
-STDMETHODIMP CPhysDriveFolder::CreateFile(const wchar_t * /* name */, IProgress * /* progress */)
- { return E_NOTIMPL; }
-
-STDMETHODIMP CPhysDriveFolder::Rename(UInt32 /* index */, const wchar_t * /* newName */, IProgress * /* progress */)
- { return E_NOTIMPL; }
-
-STDMETHODIMP CPhysDriveFolder::Delete(const UInt32 * /* indices */, UInt32 /* numItems */, IProgress * /* progress */)
- { return E_NOTIMPL; }
-
-STDMETHODIMP CPhysDriveFolder::SetProperty(UInt32 index, PROPID /* propID */,
- const PROPVARIANT * /* value */, IProgress * /* progress */)
-{
- if (index >= 1)
- return E_INVALIDARG;
- return E_NOTIMPL;
-}
-
-HRESULT CPhysDriveFolder::GetLength(UInt64 &length) const
-{
- NFile::NDevice::CInFile inFile;
- if (!inFile.Open(GetFullPath()))
- return GetLastError();
- if (!inFile.GetLengthSmart(length))
- return GetLastError();
- return S_OK;
-}
-
-struct CPhysTempBuffer
-{
- void *buffer;
- CPhysTempBuffer(): buffer(0) {}
- ~CPhysTempBuffer() { MyFree(buffer); }
-};
-
-HRESULT CopyFileSpec(LPCWSTR fromPath, LPCWSTR toPath, bool writeToDisk, UInt64 fileSize,
- UInt32 bufferSize, UInt64 progressStart, IProgress *progress)
-{
- NFile::NIO::CInFile inFile;
- if (!inFile.Open(fromPath))
- return GetLastError();
- if (fileSize == (UInt64)(Int64)-1)
- {
- if (!inFile.GetLength(fileSize))
- ::GetLastError();
- }
- NFile::NIO::COutFile outFile;
- if (writeToDisk)
- {
- if (!outFile.Open(toPath, FILE_SHARE_WRITE, OPEN_EXISTING, 0))
- return GetLastError();
- }
- else
- if (!outFile.Create(toPath, true))
- return GetLastError();
- CPhysTempBuffer tempBuffer;
- tempBuffer.buffer = MyAlloc(bufferSize);
- if (tempBuffer.buffer == 0)
- return E_OUTOFMEMORY;
-
- for (UInt64 pos = 0; pos < fileSize;)
- {
- UInt64 progressCur = progressStart + pos;
- RINOK(progress->SetCompleted(&progressCur));
- UInt64 rem = fileSize - pos;
- UInt32 curSize = (UInt32)MyMin(rem, (UInt64)bufferSize);
- UInt32 processedSize;
- if (!inFile.Read(tempBuffer.buffer, curSize, processedSize))
- return GetLastError();
- if (processedSize == 0)
- break;
- curSize = processedSize;
- if (writeToDisk)
- {
- const UInt32 kMask = 0x1FF;
- curSize = (curSize + kMask) & ~kMask;
- if (curSize > bufferSize)
- return E_FAIL;
- }
-
- if (!outFile.Write(tempBuffer.buffer, curSize, processedSize))
- return GetLastError();
- if (curSize != processedSize)
- return E_FAIL;
- pos += curSize;
- }
- return S_OK;
-}
-
-STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numItems,
- const wchar_t *path, IFolderOperationsExtractCallback *callback)
-{
- if (numItems == 0)
- return S_OK;
- UString destPath = path;
- if (destPath.IsEmpty())
- return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
- if (directName)
- {
- if (numItems > 1)
- return E_INVALIDARG;
- }
- else
- destPath += _name;
-
- UInt64 fileSize;
- if (GetLength(fileSize) == S_OK)
- {
- RINOK(callback->SetTotal(fileSize));
- }
-
- Int32 writeAskResult;
- CMyComBSTR destPathResult;
- RINOK(callback->AskWrite(GetFullPath(), BoolToInt(false), NULL, &fileSize,
- destPath, &destPathResult, &writeAskResult));
- if (!IntToBool(writeAskResult))
- return S_OK;
-
- RINOK(callback->SetCurrentFilePath(GetFullPathWithName()));
-
- UInt32 bufferSize = (_driveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
- return CopyFileSpec(GetFullPath(), destPathResult, false, fileSize, bufferSize, 0, callback);
-}
-
-/////////////////////////////////////////////////
-// Move Operations
-
-STDMETHODIMP CPhysDriveFolder::MoveTo(
- const UInt32 * /* indices */,
- UInt32 /* numItems */,
- const wchar_t * /* path */,
- IFolderOperationsExtractCallback * /* callback */)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CPhysDriveFolder::CopyFrom(
- const wchar_t * fromFolderPath,
- const wchar_t ** itemsPaths, UInt32 numItems, IProgress *callback)
-{
- if (numItems == 0)
- return S_OK;
- if (numItems != 1)
- return E_INVALIDARG;
- if (_driveType != DRIVE_REMOVABLE /* && _driveType != DRIVE_CDROM */)
- return E_NOTIMPL;
- UInt32 bufferSize = (_driveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
- // MessageBoxW(0, fromFolderPath, itemsPaths[0], 0);
- return CopyFileSpec((UString)fromFolderPath + itemsPaths[0], GetFullPath(), true, (UInt64)(Int64)-1, bufferSize, 0, callback);
-}
-
diff --git a/CPP/7zip/UI/FileManager/PhysDriveFolder.h b/CPP/7zip/UI/FileManager/PhysDriveFolder.h
deleted file mode 100755
index 64a36b91..00000000
--- a/CPP/7zip/UI/FileManager/PhysDriveFolder.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// PhysDriveFolder.h
-
-#ifndef __PHYSDRIVEFOLDER_H
-#define __PHYSDRIVEFOLDER_H
-
-#include "Common/MyString.h"
-#include "Common/MyCom.h"
-#include "../../Archive/IArchive.h"
-
-#include "IFolder.h"
-
-class CPhysDriveFolder:
- public IFolderFolder,
- public IFolderWasChanged,
- public IFolderOperations,
- public IFolderGetItemFullSize,
- public IFolderClone,
- // public IFolderGetSystemIconIndex,
- public CMyUnknownImp
-{
- UInt64 GetSizeOfItem(int anIndex) const;
-public:
- MY_QUERYINTERFACE_BEGIN
- MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
- MY_QUERYINTERFACE_ENTRY(IFolderOperations)
- MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
- MY_QUERYINTERFACE_ENTRY(IFolderClone)
- // MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
- MY_QUERYINTERFACE_END
- MY_ADDREF_RELEASE
-
-
- INTERFACE_FolderFolder(;)
- INTERFACE_FolderOperations(;)
-
- STDMETHOD(WasChanged)(Int32 *wasChanged);
- STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
- STDMETHOD(Clone)(IFolderFolder **resultFolder);
-
- // STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
-
-private:
- UString _name;
- UString _prefix;
- UString _path;
- UString GetFullPath() const { return _prefix + _path; }
- UString GetFullPathWithName() const { return GetFullPath() + L'\\' + _name; }
- CMyComPtr<IFolderFolder> _parentFolder;
-
- UINT _driveType;
- DISK_GEOMETRY geom;
- UInt64 _length;
-
-public:
- HRESULT Init(const UString &path);
- HRESULT GetLength(UInt64 &size) const;
-};
-
-#endif
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
index 2c9996ab..313b6181 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
@@ -46,6 +46,7 @@ static CIDLangPair kIDLangPairs[] =
{ IDC_PROGRESS_RATIO, 0x02000C06 },
{ IDC_PROGRESS_SPEED, 0x02000C04 },
{ IDC_PROGRESS_FILES, 0x02000320 },
+ { IDC_PROGRESS_ERRORS, 0x0308000A },
{ IDC_BUTTON_PROGRESS_PRIORITY, 0x02000C10 },
{ IDC_BUTTON_PAUSE, 0x02000C12 },
{ IDCANCEL, 0x02000711 },
@@ -86,6 +87,7 @@ CProgressDialog::CProgressDialog(): _timer(0), CompressingMode(true)
_externalCloseMessageWasReceived = false;
_numPostedMessages = 0;
+ _numAutoSizeMessages = 0;
_errorsWereDisplayed = false;
_waitCloseByCancelButton = false;
_cancelWasPressed = false;
@@ -843,13 +845,19 @@ void CProgressDialog::AddMessage(LPCWSTR message)
AddMessageDirect(s);
}
+static unsigned GetNumDigits(UInt32 value)
+{
+ unsigned i;
+ for (i = 0; value >= 10; i++)
+ value /= 10;
+ return i;
+}
+
void CProgressDialog::UpdateMessagesDialog()
{
- int numMessages;
UStringVector messages;
{
NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs);
- numMessages = _numPostedMessages;
for (int i = _numPostedMessages; i < Sync.Messages.Size(); i++)
messages.Add(Sync.Messages[i]);
_numPostedMessages = Sync.Messages.Size();
@@ -858,10 +866,11 @@ void CProgressDialog::UpdateMessagesDialog()
{
for (int i = 0; i < messages.Size(); i++)
AddMessage(messages[i]);
- if (numMessages < 128)
+ if (_numAutoSizeMessages < 256 || GetNumDigits(_numPostedMessages) > GetNumDigits(_numAutoSizeMessages))
{
_messageList.SetColumnWidthAuto(0);
_messageList.SetColumnWidthAuto(1);
+ _numAutoSizeMessages = _numPostedMessages;
}
}
}
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h
index bbdc5afa..ed096f06 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h
@@ -237,6 +237,7 @@ private:
bool _needClose;
UInt32 _numPostedMessages;
+ UInt32 _numAutoSizeMessages;
bool _errorsWereDisplayed;
diff --git a/CPP/7zip/UI/FileManager/makefile b/CPP/7zip/UI/FileManager/makefile
index d26aa04b..01016038 100755
--- a/CPP/7zip/UI/FileManager/makefile
+++ b/CPP/7zip/UI/FileManager/makefile
@@ -172,11 +172,12 @@ AGENT_OBJS = \
C_OBJS = \
$O\Alloc.obj \
+ $O\CpuArch.obj \
$O\Sha256.obj \
$O\Sort.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -190,8 +191,8 @@ OBJS = \
$(EXPLORER_OBJS) \
$(AGENT_OBJS) \
$O\CopyCoder.obj \
- $(CRC_OBJS) \
$(C_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res \
!include "../../../Build.mak"
@@ -220,4 +221,4 @@ $O\CopyCoder.obj: ../../Compress/$(*B).cpp
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+!include "../../Asm.mak"
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
index f669c0e1..e4d6c019 100755
--- a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
+++ b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
@@ -415,9 +415,7 @@ struct CThreadBenchmark
{
CBenchmarkDialog *BenchmarkDialog;
UInt64 _startTime;
- #ifdef EXTERNAL_LZMA
- CCodecs *codecs;
- #endif
+ DECL_EXTERNAL_CODECS_VARS
// UInt32 dictionarySize;
// UInt32 numThreads;
@@ -514,9 +512,7 @@ HRESULT CThreadBenchmark::Process()
try
{
result = LzmaBench(
- #ifdef EXTERNAL_LZMA
- codecs,
- #endif
+ EXTERNAL_CODECS_VARS
numThreads, dictionarySize, &callback);
}
catch(...)
@@ -564,14 +560,13 @@ HRESULT CThreadBenchmark::Process()
}
HRESULT Benchmark(
- #ifdef EXTERNAL_LZMA
- CCodecs *codecs,
- #endif
+ DECL_EXTERNAL_CODECS_LOC_VARS
UInt32 numThreads, UInt32 dictionarySize, HWND hwndParent)
{
CThreadBenchmark benchmarker;
- #ifdef EXTERNAL_LZMA
- benchmarker.codecs = codecs;
+ #ifdef EXTERNAL_CODECS
+ benchmarker._codecsInfo = codecsInfo;
+ benchmarker._externalCodecs = *externalCodecs;
#endif
CBenchmarkDialog benchmarkDialog;
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.h b/CPP/7zip/UI/GUI/BenchmarkDialog.h
index 3152ee6c..2b6216fd 100755
--- a/CPP/7zip/UI/GUI/BenchmarkDialog.h
+++ b/CPP/7zip/UI/GUI/BenchmarkDialog.h
@@ -3,13 +3,10 @@
#ifndef __BENCHMARK_DIALOG_H
#define __BENCHMARK_DIALOG_H
-#include "Windows/Control/ComboBox.h"
#include "Windows/Synchronization.h"
-#include "../../Compress/LZMA_Alone/LzmaBench.h"
+#include "Windows/Control/ComboBox.h"
-#ifdef EXTERNAL_LZMA
-#include "../Common/LoadCodecs.h"
-#endif
+#include "../Common/Bench.h"
#include "../FileManager/DialogSize.h"
@@ -132,9 +129,7 @@ public:
};
HRESULT Benchmark(
- #ifdef EXTERNAL_LZMA
- CCodecs *codecs,
- #endif
- UInt32 dictionarySize, UInt32 numThreads, HWND hwndParent = NULL);
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ UInt32 numThreads, UInt32 dictionarySize, HWND hwndParent = NULL);
#endif
diff --git a/CPP/7zip/UI/GUI/GUI.cpp b/CPP/7zip/UI/GUI/GUI.cpp
index a59e7557..377c7841 100755
--- a/CPP/7zip/UI/GUI/GUI.cpp
+++ b/CPP/7zip/UI/GUI/GUI.cpp
@@ -110,9 +110,16 @@ static int Main2()
if (options.Command.CommandType == NCommandType::kBenchmark)
{
- HRESULT res = Benchmark(
- #ifdef EXTERNAL_LZMA
- codecs,
+ HRESULT res;
+ #ifdef EXTERNAL_CODECS
+ CObjectVector<CCodecInfoEx> externalCodecs;
+ res = LoadExternalCodecs(codecs, externalCodecs);
+ if (res != S_OK)
+ throw CSystemException(res);
+ #endif
+ res = Benchmark(
+ #ifdef EXTERNAL_CODECS
+ codecs, &externalCodecs,
#endif
options.NumThreads, options.DictionarySize);
if (res != S_OK)
@@ -138,7 +145,7 @@ static int Main2()
eo.PathMode = options.Command.GetPathMode();
eo.TestMode = options.Command.IsTestMode();
eo.CalcCrc = options.CalcCrc;
- #ifdef COMPRESS_MT
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
eo.Properties = options.ExtractProperties;
#endif
diff --git a/CPP/7zip/UI/GUI/GUI.dsp b/CPP/7zip/UI/GUI/GUI.dsp
index 16a24d40..d54e944f 100755
--- a/CPP/7zip/UI/GUI/GUI.dsp
+++ b/CPP/7zip/UI/GUI/GUI.dsp
@@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BENCH_MT" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -72,7 +72,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BENCH_MT" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -99,7 +99,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BENCH_MT" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -127,7 +127,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BENCH_MT" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -205,6 +205,14 @@ SOURCE=..\Common\ArchiveOpenCallback.h
# End Source File
# Begin Source File
+SOURCE=..\Common\Bench.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\Bench.h
+# End Source File
+# Begin Source File
+
SOURCE=..\Common\DefaultName.cpp
# End Source File
# Begin Source File
@@ -545,6 +553,14 @@ SOURCE=.\UpdateGUI.h
# PROP Default_Filter ""
# Begin Source File
+SOURCE=..\..\Common\CreateCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\CreateCoder.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Common\FilePathAutoRename.cpp
# End Source File
# Begin Source File
@@ -561,6 +577,14 @@ SOURCE=..\..\Common\FileStreams.h
# End Source File
# Begin Source File
+SOURCE=..\..\Common\FilterCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilterCoder.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Common\ProgressUtils.cpp
# End Source File
# Begin Source File
@@ -579,18 +603,6 @@ SOURCE=..\..\Common\StreamUtils.h
# Begin Group "Compress"
# PROP Default_Filter ""
-# Begin Group "LZMA Bench"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.h
-# End Source File
-# End Group
# Begin Source File
SOURCE=..\..\Compress\CopyCoder.cpp
@@ -633,6 +645,30 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\7zCrcOpt.c
+
+!IF "$(CFG)" == "GUI - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 ReleaseU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -642,6 +678,34 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\C\CpuArch.c
+
+!IF "$(CFG)" == "GUI - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 ReleaseU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\CpuArch.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
diff --git a/CPP/7zip/UI/GUI/makefile b/CPP/7zip/UI/GUI/makefile
index a3763cbf..fdedb44a 100755
--- a/CPP/7zip/UI/GUI/makefile
+++ b/CPP/7zip/UI/GUI/makefile
@@ -1,10 +1,7 @@
PROG = 7zG.exe
CFLAGS = $(CFLAGS) -I ../../../ \
-DLANG \
- -DCOMPRESS_MT \
- -DEXTERNAL_LZMA \
-DEXTERNAL_CODECS \
- -DBENCH_MT \
!IFDEF UNDER_CE
LIBS = $(LIBS) ceshell.lib Commctrl.lib
@@ -62,8 +59,10 @@ WIN_CTRL_OBJS = \
$O\ListView.obj \
7ZIP_COMMON_OBJS = \
+ $O\CreateCoder.obj \
$O\FilePathAutoRename.obj \
$O\FileStreams.obj \
+ $O\FilterCoder.obj \
$O\ProgressUtils.obj \
$O\StreamUtils.obj \
@@ -71,6 +70,7 @@ UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
+ $O\Bench.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
@@ -92,9 +92,6 @@ UI_COMMON_OBJS = \
AR_COMMON_OBJS = \
$O\OutStreamWithCRC.obj \
-LZMA_BENCH_OBJS = \
- $O\LzmaBench.obj \
-
FM_OBJS = \
$O\ExtractCallback.obj \
$O\FormatUtils.obj \
@@ -117,9 +114,10 @@ FM_OBJS = $(FM_OBJS) \
C_OBJS = \
$O\Alloc.obj \
+ $O\CpuArch.obj \
$O\Threads.obj \
-!include "../../Crc2.mak"
+!include "../../Crc.mak"
OBJS = \
$O\StdAfx.obj \
@@ -135,7 +133,7 @@ OBJS = \
$O\CopyCoder.obj \
$(LZMA_BENCH_OBJS) \
$(C_OBJS) \
- $(CRC_OBJS) \
+ $(ASM_OBJS) \
$O\resource.res
!include "../../../Build.mak"
@@ -159,11 +157,9 @@ $(FM_OBJS): ../FileManager/$(*B).cpp
$O\MyMessages.obj: ../Explorer/MyMessages.cpp
$(COMPL)
-
$O\CopyCoder.obj: ../../Compress/$(*B).cpp
$(COMPL)
-$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp
- $(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
-!include "../../Crc.mak"
+
+!include "../../Asm.mak"
diff --git a/CPP/7zip/makefile b/CPP/7zip/makefile
index fde715a4..9d31e6bd 100755
--- a/CPP/7zip/makefile
+++ b/CPP/7zip/makefile
@@ -1,7 +1,6 @@
DIRS = \
UI\~ \
Bundles\~ \
- Compress\~ \
all: $(DIRS)
diff --git a/CPP/Build.mak b/CPP/Build.mak
index 3356b8e5..9209a32e 100755
--- a/CPP/Build.mak
+++ b/CPP/Build.mak
@@ -15,12 +15,12 @@ O=O
!ENDIF
!ENDIF
-!IF "$(CPU)" != "IA64"
-!IF "$(CPU)" != "AMD64"
-MY_ML = ml
+!IF "$(CPU)" == "AMD64"
+MY_ML = ml64 -Dx64
+!ELSEIF "$(CPU)" == "ARM"
+MY_ML = armasm
!ELSE
-MY_ML = ml64
-!ENDIF
+MY_ML = ml
!ENDIF
@@ -30,13 +30,18 @@ RFLAGS = $(RFLAGS) -dUNDER_CE
LFLAGS = $(LFLAGS) /ENTRY:mainACRTStartup
!ENDIF
!ELSE
+!IFNDEF NEW_COMPILER
LFLAGS = $(LFLAGS) -OPT:NOWIN98
+!ENDIF
CFLAGS = $(CFLAGS) -Gr
LIBS = $(LIBS) user32.lib advapi32.lib shell32.lib
!ENDIF
-
+!IF "$(CPU)" == "ARM"
+COMPL_ASM = $(MY_ML) $** $O/$(*B).obj
+!ELSE
COMPL_ASM = $(MY_ML) -c -Fo$O/ $**
+!ENDIF
CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -WX -EHsc -Gy -GR-
diff --git a/CPP/Common/MyVector.cpp b/CPP/Common/MyVector.cpp
index 88d9993a..3b531768 100755
--- a/CPP/Common/MyVector.cpp
+++ b/CPP/Common/MyVector.cpp
@@ -25,12 +25,12 @@ void CBaseRecordVector::ReserveOnePosition()
{
if (_size != _capacity)
return;
- int delta = 1;
+ unsigned delta = 1;
if (_capacity >= 64)
- delta = _capacity / 4;
+ delta = (unsigned)_capacity / 4;
else if (_capacity >= 8)
delta = 8;
- Reserve(_capacity + delta);
+ Reserve(_capacity + (int)delta);
}
void CBaseRecordVector::Reserve(int newCapacity)
diff --git a/CPP/Common/UTFConvert.cpp b/CPP/Common/UTFConvert.cpp
index 9d1fd005..95362430 100755
--- a/CPP/Common/UTFConvert.cpp
+++ b/CPP/Common/UTFConvert.cpp
@@ -99,7 +99,7 @@ static Bool Utf16_To_Utf8(char *dest, size_t *destLen, const wchar_t *src, size_
c2 = src[srcPos++];
if (c2 < 0xDC00 || c2 >= 0xE000)
break;
- value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
+ value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;
}
for (numAdds = 1; numAdds < 5; numAdds++)
if (value < (((UInt32)1) << (numAdds * 5 + 6)))
diff --git a/CPP/Windows/Defs.h b/CPP/Windows/Defs.h
index 898be8d7..281c40c3 100755
--- a/CPP/Windows/Defs.h
+++ b/CPP/Windows/Defs.h
@@ -3,21 +3,15 @@
#ifndef __WINDOWS_DEFS_H
#define __WINDOWS_DEFS_H
-inline bool BOOLToBool(BOOL value)
- { return (value != FALSE); }
+#include "../Common/MyWindows.h"
#ifdef _WIN32
-inline bool LRESULTToBool(LRESULT value)
- { return (value != FALSE); }
+inline bool LRESULTToBool(LRESULT v) { return (v != FALSE); }
+inline bool BOOLToBool(BOOL v) { return (v != FALSE); }
+inline BOOL BoolToBOOL(bool v) { return (v ? TRUE: FALSE); }
#endif
-inline BOOL BoolToBOOL(bool value)
- { return (value ? TRUE: FALSE); }
-
-inline VARIANT_BOOL BoolToVARIANT_BOOL(bool value)
- { return (value ? VARIANT_TRUE: VARIANT_FALSE); }
-
-inline bool VARIANT_BOOLToBool(VARIANT_BOOL value)
- { return (value != VARIANT_FALSE); }
+inline VARIANT_BOOL BoolToVARIANT_BOOL(bool v) { return (v ? VARIANT_TRUE: VARIANT_FALSE); }
+inline bool VARIANT_BOOLToBool(VARIANT_BOOL v) { return (v != VARIANT_FALSE); }
#endif
diff --git a/DOC/7zip.hhp b/DOC/7zip.hhp
index 9af0db78..41159aac 100755
--- a/DOC/7zip.hhp
+++ b/DOC/7zip.hhp
@@ -17,7 +17,6 @@ general\formats.htm
general\index.htm
general\license.htm
general\performance.htm
-general\register.htm
general\7z.htm
cmdline\index.htm
cmdline\syntax.htm
diff --git a/DOC/7zip.inf b/DOC/7zip.inf
index 95022eaa..52fcf36a 100755
--- a/DOC/7zip.inf
+++ b/DOC/7zip.inf
@@ -10,8 +10,8 @@ AppName = "7-Zip"
InstallDir = %CE1%\%AppName%
[Strings]
-AppVer = "9.07"
-AppDate = "2009-08-29"
+AppVer = "9.09"
+AppDate = "2009-12-12"
[CEDevice]
; ProcessorType = 2577 ; ARM
diff --git a/DOC/7zip.nsi b/DOC/7zip.nsi
index 3cf428f6..fb6db17b 100755
--- a/DOC/7zip.nsi
+++ b/DOC/7zip.nsi
@@ -2,7 +2,7 @@
;Defines
!define VERSION_MAJOR 9
-!define VERSION_MINOR 07
+!define VERSION_MINOR 09
!define VERSION_POSTFIX_FULL " beta"
!ifdef WIN64
!ifdef IA64
@@ -54,7 +54,7 @@
;Compressor
!ifndef NO_COMPRESSION
SetCompressor /solid lzma
- SetCompressorFilter 1
+ ; SetCompressorFilter 1
!ifdef IA64
SetCompressorDictSize 8
!else
diff --git a/DOC/7zip.wxs b/DOC/7zip.wxs
index 9515f3cd..89cf83fc 100755
--- a/DOC/7zip.wxs
+++ b/DOC/7zip.wxs
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?define VerMajor = "9" ?>
-<?define VerMinor = "07" ?>
+<?define VerMinor = "09" ?>
<?define VerBuild = "00" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?>
diff --git a/DOC/history.txt b/DOC/history.txt
index 36c53e06..0d5e4a90 100755
--- a/DOC/history.txt
+++ b/DOC/history.txt
@@ -1,6 +1,13 @@
Sources history of the 7-Zip
----------------------------
+9.09 2009-12-12
+-------------------------
+- The bug was fixed:
+ Utf16_To_Utf8 funstions in UTFConvert.cpp and 7zMain.c
+ incorrectly converted surrogate characters (the code >= 0x10000) to UTF-8.
+
+
9.05 2009-07-05
-------------------------
- FileMapping.h::CFileMapping now returns WRes
diff --git a/DOC/lzma.txt b/DOC/lzma.txt
index c3963384..f96b5423 100755
--- a/DOC/lzma.txt
+++ b/DOC/lzma.txt
@@ -1,4 +1,4 @@
-LZMA SDK 9.06
+LZMA SDK 9.09
-------------
LZMA SDK provides the documentation, samples, header files, libraries,
@@ -524,7 +524,8 @@ static ISzAlloc g_Alloc = { SzAlloc, SzFree };
LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc);
-If callback function return some error code, LzmaEnc_Encode also returns that code.
+If callback function return some error code, LzmaEnc_Encode also returns that code
+or it can return the code like SZ_ERROR_READ, SZ_ERROR_WRITE or SZ_ERROR_PROGRESS.
Single-call RAM->RAM Compression