Skip to content

Commit

Permalink
21.07
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Pavlov authored and kornelski committed Jan 22, 2022
1 parent 52eeaf1 commit c3529a4
Show file tree
Hide file tree
Showing 88 changed files with 3,472 additions and 433 deletions.
13 changes: 12 additions & 1 deletion Asm/x86/7zAsm.asm
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
; 7zAsm.asm -- ASM macros
; 2021-08-29 : Igor Pavlov : Public domain
; 2021-12-25 : Igor Pavlov : Public domain


ifdef @wordsize
; @wordsize is defined only in JWASM and ASMC and is not defined in MASM
; @wordsize eq 8 for 64-bit x64
; @wordsize eq 2 for 32-bit x86
if @wordsize eq 8
x64 equ 1
endif
else
ifdef RAX
x64 equ 1
endif
endif


ifdef x64
IS_X64 equ 1
Expand Down
10 changes: 9 additions & 1 deletion Asm/x86/AesOpt.asm
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
; AesOpt.asm -- AES optimized code for x86 AES hardware instructions
; 2021-03-10 : Igor Pavlov : Public domain
; 2021-12-25 : Igor Pavlov : Public domain

include 7zAsm.asm

ifdef __ASMC__
use_vaes_256 equ 1
else
ifdef ymm0
use_vaes_256 equ 1
endif
endif


ifdef use_vaes_256
ECHO "++ VAES 256"
else
ECHO "-- NO VAES 256"
Expand Down
3 changes: 2 additions & 1 deletion C/7zTypes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zTypes.h -- Basic types
2021-07-13 : Igor Pavlov : Public domain */
2021-12-25 : Igor Pavlov : Public domain */

#ifndef __7Z_TYPES_H
#define __7Z_TYPES_H
Expand Down Expand Up @@ -105,6 +105,7 @@ typedef int WRes;

// we use errno equivalents for some WIN32 errors:

#define ERROR_INVALID_PARAMETER EINVAL
#define ERROR_INVALID_FUNCTION EINVAL
#define ERROR_ALREADY_EXISTS EEXIST
#define ERROR_FILE_EXISTS EEXIST
Expand Down
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 21
#define MY_VER_MINOR 06
#define MY_VER_MINOR 07
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "21.06"
#define MY_VERSION_NUMBERS "21.07"
#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 "2021-11-24"
#define MY_DATE "2021-12-26"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"
Expand Down
10 changes: 6 additions & 4 deletions C/DllSecur.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* DllSecur.c -- DLL loading security
2021-11-18 : Igor Pavlov : Public domain */
2021-12-25 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -33,17 +33,19 @@ static const char * const g_Dlls =

#endif

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

void My_SetDefaultDllDirectories()
{
#ifndef UNDER_CE

OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
GetVersionEx(&vi);
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)
{
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
(void(*)())GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
if (setDllDirs)
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
return;
Expand All @@ -66,7 +68,7 @@ void LoadSecurityDlls()
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)
{
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
(void(*)())GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
if (setDllDirs)
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
return;
Expand Down
15 changes: 11 additions & 4 deletions C/LzFind.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* LzFind.c -- Match finder for LZ algorithms
2021-09-03 : Igor Pavlov : Public domain */
2021-11-29 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -600,7 +600,9 @@ static
#ifdef ATTRIB_SSE41
ATTRIB_SSE41
#endif
void LzFind_SaturSub_128(UInt32 subValue, CLzRef *items, const CLzRef *lim)
void
MY_FAST_CALL
LzFind_SaturSub_128(UInt32 subValue, CLzRef *items, const CLzRef *lim)
{
v128 sub2 =
#ifdef MY_CPU_ARM_OR_ARM64
Expand Down Expand Up @@ -632,7 +634,9 @@ static
#ifdef ATTRIB_AVX2
ATTRIB_AVX2
#endif
void LzFind_SaturSub_256(UInt32 subValue, CLzRef *items, const CLzRef *lim)
void
MY_FAST_CALL
LzFind_SaturSub_256(UInt32 subValue, CLzRef *items, const CLzRef *lim)
{
__m256i sub2 = _mm256_set_epi32(
(Int32)subValue, (Int32)subValue, (Int32)subValue, (Int32)subValue,
Expand Down Expand Up @@ -669,7 +673,10 @@ static LZFIND_SATUR_SUB_CODE_FUNC g_LzFind_SaturSub;
#define DEFAULT_SaturSub LzFind_SaturSub_32

MY_NO_INLINE
static void LzFind_SaturSub_32(UInt32 subValue, CLzRef *items, const CLzRef *lim)
static
void
MY_FAST_CALL
LzFind_SaturSub_32(UInt32 subValue, CLzRef *items, const CLzRef *lim)
{
do
{
Expand Down
6 changes: 3 additions & 3 deletions C/LzFindMt.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
2021-07-12 : Igor Pavlov : Public domain */
2021-12-21 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -832,8 +832,8 @@ void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc)
#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)


static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE BtThreadFunc2(void *p)
static THREAD_FUNC_DECL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
static THREAD_FUNC_DECL BtThreadFunc2(void *p)
{
Byte allocaDummy[0x180];
unsigned i = 0;
Expand Down
6 changes: 3 additions & 3 deletions C/MtCoder.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* MtCoder.c -- Multi-thread Coder
2021-07-12 : Igor Pavlov : Public domain */
2021-12-21 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -44,7 +44,7 @@ static WRes ArEvent_OptCreate_And_Reset(CEvent *p)
}


static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp);
static THREAD_FUNC_DECL ThreadFunc(void *pp);


static SRes MtCoderThread_CreateAndStart(CMtCoderThread *t)
Expand Down Expand Up @@ -335,7 +335,7 @@ static SRes ThreadFunc2(CMtCoderThread *t)
}


static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp)
static THREAD_FUNC_DECL ThreadFunc(void *pp)
{
CMtCoderThread *t = (CMtCoderThread *)pp;
for (;;)
Expand Down
8 changes: 4 additions & 4 deletions C/MtDec.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* MtDec.c -- Multi-thread Decoder
2021-02-27 : Igor Pavlov : Public domain */
2021-12-21 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -102,7 +102,7 @@ typedef struct __CMtDecBufLink CMtDecBufLink;



static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp);
static THREAD_FUNC_DECL ThreadFunc(void *pp);


static WRes MtDecThread_CreateEvents(CMtDecThread *t)
Expand Down Expand Up @@ -836,7 +836,7 @@ static WRes ThreadFunc2(CMtDecThread *t)
#endif


static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc1(void *pp)
static THREAD_FUNC_DECL ThreadFunc1(void *pp)
{
WRes res;

Expand All @@ -862,7 +862,7 @@ static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc1(void *pp)
return (THREAD_FUNC_RET_TYPE)(UINT_PTR)res;
}

static MY_NO_INLINE THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp)
static MY_NO_INLINE THREAD_FUNC_DECL ThreadFunc(void *pp)
{
#ifdef USE_ALLOCA
CMtDecThread *t = (CMtDecThread *)pp;
Expand Down
10 changes: 5 additions & 5 deletions C/Threads.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Threads.c -- multithreading library
2021-07-12 : Igor Pavlov : Public domain */
2021-12-21 : Igor Pavlov : Public domain */

#include "Precomp.h"

#ifdef _WIN32

#ifndef UNDER_CE
#ifndef USE_THREADS_CreateThread
#include <process.h>
#endif

Expand Down Expand Up @@ -63,10 +63,10 @@ WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param)
{
/* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */

#ifdef UNDER_CE
#ifdef USE_THREADS_CreateThread

DWORD threadId;
*p = CreateThread(0, 0, func, param, 0, &threadId);
*p = CreateThread(NULL, 0, func, param, 0, &threadId);

#else

Expand All @@ -82,7 +82,7 @@ WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param)

WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity)
{
#ifdef UNDER_CE
#ifdef USE_THREADS_CreateThread

UNUSED_VAR(affinity)
return Thread_Create(p, func, param);
Expand Down
35 changes: 32 additions & 3 deletions C/Threads.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Threads.h -- multithreading library
2021-07-12 : Igor Pavlov : Public domain */
2021-12-21 : Igor Pavlov : Public domain */

#ifndef __7Z_THREADS_H
#define __7Z_THREADS_H
Expand Down Expand Up @@ -38,8 +38,14 @@ typedef HANDLE CThread;
#define Thread_Close(p) HandlePtr_Close(p)
// #define Thread_Wait(p) Handle_WaitObject(*(p))

#ifdef UNDER_CE
// if (USE_THREADS_CreateThread is defined), we use _beginthreadex()
// if (USE_THREADS_CreateThread is not definned), we use CreateThread()
#define USE_THREADS_CreateThread
#endif

typedef
#ifdef UNDER_CE
#ifdef USE_THREADS_CreateThread
DWORD
#else
unsigned
Expand Down Expand Up @@ -90,7 +96,30 @@ typedef UInt64 CCpuSet;


#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE

#if defined(_WIN32) && defined(__GNUC__)
/* GCC compiler for x86 32-bit uses the rule:
the stack is 16-byte aligned before CALL instruction for function calling.
But only root function main() contains instructions that
set 16-byte alignment for stack pointer. And another functions
just keep alignment, if it was set in some parent function.
The problem:
if we create new thread in MinGW (GCC) 32-bit x86 via _beginthreadex() or CreateThread(),
the root function of thread doesn't set 16-byte alignment.
And stack frames in all child functions also will be unaligned in that case.
Here we set (force_align_arg_pointer) attribute for root function of new thread.
Do we need (force_align_arg_pointer) also for another systems? */

#define THREAD_FUNC_ATTRIB_ALIGN_ARG __attribute__((force_align_arg_pointer))
// #define THREAD_FUNC_ATTRIB_ALIGN_ARG // for debug : bad alignment in SSE functions
#else
#define THREAD_FUNC_ATTRIB_ALIGN_ARG
#endif

#define THREAD_FUNC_DECL THREAD_FUNC_ATTRIB_ALIGN_ARG THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE

typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *);
WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param);
WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity);
Expand Down
Loading

0 comments on commit c3529a4

Please sign in to comment.