Skip to content

Commit

Permalink
7-zip 22.01 source code
Browse files Browse the repository at this point in the history
  • Loading branch information
cielavenir committed Jul 16, 2022
1 parent 4799c03 commit 61c9f0c
Show file tree
Hide file tree
Showing 47 changed files with 2,468 additions and 795 deletions.
6 changes: 3 additions & 3 deletions C/7zVersion.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 22
#define MY_VER_MINOR 00
#define MY_VER_MINOR 01
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "22.00"
#define MY_VERSION_NUMBERS "22.01"
#define MY_VERSION MY_VERSION_NUMBERS

#ifdef MY_CPU_NAME
Expand All @@ -10,7 +10,7 @@
#define MY_VERSION_CPU MY_VERSION
#endif

#define MY_DATE "2022-06-15"
#define MY_DATE "2022-07-15"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"
Expand Down
42 changes: 36 additions & 6 deletions C/7zip_gcc_c.mak
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,32 @@ CFLAGS_BASE = $(MY_ARCH_2) -O2 $(CFLAGS_BASE_LIST) -Wall -Werror -Wextra $(CFLAG
-DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE


LDFLAGS_STATIC = -DNDEBUG
# -static

ifdef SystemDrive
IS_MINGW = 1
else
ifdef SYSTEMDRIVE
# ifdef OS
IS_MINGW = 1
endif
endif

ifdef IS_MINGW
LDFLAGS_STATIC_2 = -static
else
ifndef DEF_FILE
ifndef IS_NOT_STANDALONE
ifndef MY_DYNAMIC_LINK
ifneq ($(CC), clang)
LDFLAGS_STATIC_2 =
# -static
# -static-libstdc++ -static-libgcc
endif
endif
endif
endif
endif

LDFLAGS_STATIC = -DNDEBUG $(LDFLAGS_STATIC_2)

ifdef DEF_FILE

Expand Down Expand Up @@ -62,15 +82,22 @@ endif

ifdef IS_MINGW

ifdef MSYSTEM
RM = rm -f
MY_MKDIR=mkdir -p
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)
else
RM = del
MY_MKDIR=mkdir
LIB2 = -loleaut32 -luuid -ladvapi32 -lUser32
DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll
endif


LIB2 = -lOle32 -loleaut32 -luuid -ladvapi32 -lUser32

CXXFLAGS_EXTRA = -DUNICODE -D_UNICODE
# -Wno-delete-non-virtual-dtor

DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll

else

Expand Down Expand Up @@ -306,7 +333,10 @@ $O/7zMain.o: ../../../C/Util/7z/7zMain.c
$(CC) $(CFLAGS) $<
$O/LzmaUtil.o: ../../../C/Util/Lzma/LzmaUtil.c
$(CC) $(CFLAGS) $<

$O/7zipInstall.o: ../../../C/Util/7zipInstall/7zipInstall.c
$(CC) $(CFLAGS) $<
$O/7zipUninstall.o: ../../../C/Util/7zipUninstall/7zipUninstall.c
$(CC) $(CFLAGS) $<


clean:
Expand Down
17 changes: 10 additions & 7 deletions C/CpuArch.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* CpuArch.h -- CPU specific code
2021-07-13 : Igor Pavlov : Public domain */
2022-07-15 : Igor Pavlov : Public domain */

#ifndef __CPU_ARCH_H
#define __CPU_ARCH_H
Expand Down Expand Up @@ -123,12 +123,15 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#endif


#if defined(__sparc64__)
#define MY_CPU_NAME "sparc64"
#define MY_CPU_64BIT
#elif defined(__sparc__)
#define MY_CPU_NAME "sparc"
/* #define MY_CPU_32BIT */
#if defined(__riscv) \
|| defined(__riscv__)
#if __riscv_xlen == 32
#define MY_CPU_NAME "riscv32"
#elif __riscv_xlen == 64
#define MY_CPU_NAME "riscv64"
#else
#define MY_CPU_NAME "riscv"
#endif
#endif


Expand Down
8 changes: 6 additions & 2 deletions C/DllSecur.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* DllSecur.c -- DLL loading security
2021-12-25 : Igor Pavlov : Public domain */
2022-07-15 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand All @@ -11,6 +11,10 @@

#ifndef UNDER_CE

#if defined(__GNUC__) && (__GNUC__ >= 8)
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif

typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags);

#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400
Expand All @@ -34,7 +38,7 @@ static const char * const g_Dlls =
#endif

// #define MY_CAST_FUNC (void(*)())
#define MY_CAST_FUNC
#define MY_CAST_FUNC

void My_SetDefaultDllDirectories()
{
Expand Down
11 changes: 4 additions & 7 deletions C/LzmaEnc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder
2021-11-18: Igor Pavlov : Public domain */
2022-07-15: Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -2970,6 +2970,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
}


// (desiredPackSize == 0) is not allowed
SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
{
Expand All @@ -2990,14 +2991,10 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
if (reInit)
LzmaEnc_Init(p);
LzmaEnc_InitPrices(p);

nowPos64 = p->nowPos64;
RangeEnc_Init(&p->rc);
p->rc.outStream = &outStream.vt;

if (desiredPackSize == 0)
return SZ_ERROR_OUTPUT_EOF;

nowPos64 = p->nowPos64;

res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);

*unpackSize = (UInt32)(p->nowPos64 - nowPos64);
Expand Down
8 changes: 6 additions & 2 deletions C/Util/7zipInstall/7zipInstall.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zipInstall.c - 7-Zip Installer
2021-09-02 : Igor Pavlov : Public domain */
2022-07-15 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand All @@ -22,6 +22,10 @@

#include "resource.h"

#if defined(__GNUC__) && (__GNUC__ >= 8)
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif

#define LLL_(quote) L##quote
#define LLL(quote) LLL_(quote)

Expand Down Expand Up @@ -70,7 +74,7 @@ static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip";
#endif
#endif

#define k_7zip_with_Ver k_7zip_with_Ver_base k_Postfix
#define k_7zip_with_Ver k_7zip_with_Ver_base k_Postfix


static LPCWSTR const k_7zip_with_Ver_str = k_7zip_with_Ver;
Expand Down
6 changes: 5 additions & 1 deletion C/Util/7zipUninstall/7zipUninstall.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zipUninstall.c - 7-Zip Uninstaller
2021-11-24 : Igor Pavlov : Public domain */
2022-07-15 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand All @@ -17,6 +17,10 @@

#include "resource.h"

#if defined(__GNUC__) && (__GNUC__ >= 8)
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif

#define LLL_(quote) L##quote
#define LLL(quote) LLL_(quote)

Expand Down
39 changes: 32 additions & 7 deletions CPP/7zip/7zip_gcc.mak
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ CFLAGS_BASE = -O2 $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \

ifdef SystemDrive
IS_MINGW = 1
else
ifdef SYSTEMDRIVE
# ifdef OS
IS_MINGW = 1
endif
endif

ifdef IS_MINGW
Expand Down Expand Up @@ -97,20 +102,30 @@ PROGPATH_STATIC = $(O)/$(PROG)s$(SHARED_EXT)

ifdef IS_MINGW

ifdef MSYSTEM
RM = rm -f
MY_MKDIR=mkdir -p
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)
LIB_HTMLHELP=-lhtmlhelp
else
RM = del
MY_MKDIR=mkdir
LIB2_GUI = -lOle32 -lGdi32 -lComctl32 -lComdlg32
DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll
endif

LIB2_GUI = -lOle32 -lGdi32 -lComctl32 -lComdlg32 $(LIB_HTMLHELP)
LIB2 = -loleaut32 -luuid -ladvapi32 -lUser32 $(LIB2_GUI)

CXXFLAGS_EXTRA = -DUNICODE -D_UNICODE
# -Wno-delete-non-virtual-dtor

DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll

else

RM = rm -f
MY_MKDIR=mkdir -p
DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)

# CFLAGS_BASE := $(CFLAGS_BASE) -D_7ZIP_ST
# CXXFLAGS_EXTRA = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE

Expand All @@ -119,9 +134,6 @@ MY_MKDIR=mkdir -p
LIB2 = -lpthread -ldl



DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)

endif


Expand All @@ -130,9 +142,19 @@ CFLAGS = $(MY_ARCH_2) $(LOCAL_FLAGS) $(CFLAGS_BASE2) $(CFLAGS_BASE) $(CC_SHARED)


ifdef IS_MINGW

ifdef IS_X64
AFLAGS_ABI = -win64
else
AFLAGS_ABI = -coff -DABI_CDECL
# -DABI_CDECL
# -DABI_LINUX
# -DABI_CDECL
endif
AFLAGS = -nologo $(AFLAGS_ABI) -Fo$(O)/$(basename $(<F)).o
else

else # IS_MINGW

ifdef IS_X64
AFLAGS_ABI = -elf64 -DABI_LINUX
else
Expand All @@ -142,7 +164,10 @@ AFLAGS_ABI = -elf -DABI_LINUX -DABI_CDECL
# -DABI_CDECL
endif
AFLAGS = -nologo $(AFLAGS_ABI) -Fo$(O)/
endif

endif # IS_MINGW



ifdef USE_ASM
CONSOLE_ASM_FLAGS=-D_7ZIP_ASM
Expand Down
Loading

0 comments on commit 61c9f0c

Please sign in to comment.