Skip to content

Commit

Permalink
recode come checksumPlugin & update doc; add private TDiffToSingleStr…
Browse files Browse the repository at this point in the history
…eam_resetStream();
  • Loading branch information
housisong committed Dec 19, 2023
1 parent 42e6c45 commit fb4325e
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 56 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ options:
-c-bzip2[-{1..9}] (or -bz2) DEFAULT level 9
-c-pbzip2[-{1..9}] (or -pbz2) DEFAULT level 8
support run by multi-thread parallel, fast!
WARNING: code not compatible with it compressed by -c-bzip2!
NOTE: code not compatible with it compressed by -c-bzip2!
and code size may be larger than if it compressed by -c-bzip2.
-c-lzma[-{0..9}[-dictSize]] DEFAULT level 7
dictSize can like 4096 or 4k or 4m or 128m etc..., DEFAULT 8m
support run by 2-thread parallel.
-c-lzma2[-{0..9}[-dictSize]] DEFAULT level 7
dictSize can like 4096 or 4k or 4m or 128m etc..., DEFAULT 8m
support run by multi-thread parallel, fast!
WARNING: code not compatible with it compressed by -c-lzma!
NOTE: code not compatible with it compressed by -c-lzma!
-c-zstd[-{0..22}[-dictBits]] DEFAULT level 20
dictBits can 10--30, DEFAULT 23.
support run by multi-thread parallel, fast!
Expand Down
16 changes: 8 additions & 8 deletions builds/vc/bzip2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
Expand All @@ -174,7 +174,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
Expand All @@ -190,7 +190,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
Expand All @@ -206,7 +206,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
Expand All @@ -221,7 +221,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
Expand All @@ -237,7 +237,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
Expand All @@ -253,7 +253,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
Expand All @@ -269,7 +269,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
Expand Down
4 changes: 2 additions & 2 deletions checksum_plugin_demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ static void _xxh3_end(hpatch_checksumHandle handle,
}
static hpatch_TChecksum xxh3ChecksumPlugin={ _xxh3_checksumType,_xxh3_checksumByteSize,_xxh3_open,
_xxh3_close,_xxh3_begin,_xxh3_append,_xxh3_end};
#endif//_ChecksumPlugin_mbedtls_xxh3
#endif//_ChecksumPlugin_xxh3


#ifdef _ChecksumPlugin_xxh128
Expand Down Expand Up @@ -695,6 +695,6 @@ static void _xxh128_end(hpatch_checksumHandle handle,
}
static hpatch_TChecksum xxh128ChecksumPlugin={ _xxh128_checksumType,_xxh128_checksumByteSize,_xxh128_open,
_xxh128_close,_xxh128_begin,_xxh128_append,_xxh128_end};
#endif//_ChecksumPlugin_mbedtls_xxh128
#endif//_ChecksumPlugin_xxh128

#endif
52 changes: 21 additions & 31 deletions hdiffz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static void printUsage(){
# if (_IS_USED_MULTITHREAD)
" -c-pbzip2[-{1..9}] (or -pbz2) DEFAULT level 8\n"
" support run by multi-thread parallel, fast!\n"
" WARNING: code not compatible with it compressed by -c-bzip2!\n"
" NOTE: code not compatible with it compressed by -c-bzip2!\n"
" and code size may be larger than if it compressed by -c-bzip2.\n"
# endif
#endif
Expand All @@ -247,7 +247,7 @@ static void printUsage(){
# if (_IS_USED_MULTITHREAD)
" support run by multi-thread parallel, fast!\n"
# endif
" WARNING: code not compatible with it compressed by -c-lzma!\n"
" NOTE: code not compatible with it compressed by -c-lzma!\n"
#endif
#ifdef _CompressPlugin_lz4
" -c-lz4[-{1..50}] DEFAULT level 50 (as lz4 acceleration 1)\n"
Expand Down Expand Up @@ -549,6 +549,18 @@ static inline hpatch_BOOL _trySetChecksum(hpatch_TChecksum** out_checksumPlugin,
static hpatch_BOOL findChecksum(hpatch_TChecksum** out_checksumPlugin,const char* checksumType){
*out_checksumPlugin=0;
if (strlen(checksumType)==0) return hpatch_TRUE;
#ifdef _ChecksumPlugin_fadler64
__setChecksum(&fadler64ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_xxh128
__setChecksum(&xxh128ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_xxh3
__setChecksum(&xxh3ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_md5
__setChecksum(&md5ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_crc32
__setChecksum(&crc32ChecksumPlugin);
#endif
Expand All @@ -561,23 +573,11 @@ static hpatch_BOOL findChecksum(hpatch_TChecksum** out_checksumPlugin,const char
#ifdef _ChecksumPlugin_fadler32
__setChecksum(&fadler32ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_fadler64
__setChecksum(&fadler64ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_fadler128
__setChecksum(&fadler128ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_md5
__setChecksum(&md5ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_blake3
__setChecksum(&blake3ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_xxh3
__setChecksum(&xxh3ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_xxh128
__setChecksum(&xxh128ChecksumPlugin);
#endif
return hpatch_FALSE;
}
Expand Down Expand Up @@ -1075,6 +1075,8 @@ int hdiff_cmd_line(int argc, const char * argv[]){
}
#endif
#if (_IS_NEED_DIR_DIFF_PATCH)
if (isSetChecksum==_kNULL_VALUE)
isSetChecksum=hpatch_FALSE;
if (kMaxOpenFileNumber==_kNULL_SIZE)
kMaxOpenFileNumber=kMaxOpenFileNumber_default_diff;
if (kMaxOpenFileNumber<kMaxOpenFileNumber_default_min)
Expand Down Expand Up @@ -1120,9 +1122,6 @@ int hdiff_cmd_line(int argc, const char * argv[]){
#if (_IS_NEED_DIR_DIFF_PATCH)
if (isForceRunDirDiff==_kNULL_VALUE)
isForceRunDirDiff=hpatch_FALSE;
if (isSetChecksum==_kNULL_VALUE)
isSetChecksum=hpatch_FALSE;

if ((!manifestOld.empty())||(!manifestNew.empty())){
isForceRunDirDiff=hpatch_TRUE;
_options_check(manifestOut.empty()&&(!manifestNew.empty()),"-M?");
Expand Down Expand Up @@ -1168,16 +1167,12 @@ int hdiff_cmd_line(int argc, const char * argv[]){
hpatch_BOOL isUseDirDiff=isForceRunDirDiff||(kPathType_dir==oldType)||(kPathType_dir==newType);
if (isUseDirDiff){
#ifdef _ChecksumPlugin_fadler64
if (isSetChecksum==hpatch_FALSE){
if (isSetChecksum==hpatch_FALSE)
checksumPlugin=&fadler64ChecksumPlugin; //DEFAULT
isSetChecksum=hpatch_TRUE;
}
#else
# ifdef _ChecksumPlugin_crc32
if (isSetChecksum==hpatch_FALSE){
if (isSetChecksum==hpatch_FALSE)
checksumPlugin=&crc32ChecksumPlugin; //DEFAULT
isSetChecksum=hpatch_TRUE;
}
# endif
#endif
}else
Expand Down Expand Up @@ -1210,19 +1205,14 @@ int hdiff_cmd_line(int argc, const char * argv[]){
_options_check(arg_values.size()==1,"create manifest file used one inputPath");
_options_check(ignoreOldPathList.empty(),"-g-old unsupport run with create manifest file mode");
_options_check(ignoreNewPathList.empty(),"-g-new unsupport run with create manifest file mode");
if (isSetChecksum==_kNULL_VALUE)
isSetChecksum=hpatch_FALSE;

#ifdef _ChecksumPlugin_fadler64
if (isSetChecksum==hpatch_FALSE){
if (isSetChecksum==hpatch_FALSE)
checksumPlugin=&fadler64ChecksumPlugin; //DEFAULT
isSetChecksum=hpatch_TRUE;
}
#else
# ifdef _ChecksumPlugin_crc32
if (isSetChecksum==hpatch_FALSE){
if (isSetChecksum==hpatch_FALSE)
checksumPlugin=&crc32ChecksumPlugin; //DEFAULT
isSetChecksum=hpatch_TRUE;
}
# endif
#endif

Expand Down
24 changes: 12 additions & 12 deletions hpatchz.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,18 @@ hpatch_BOOL _trySetChecksum(hpatch_TChecksum** out_checksumPlugin,const char* ch
static hpatch_BOOL findChecksum(hpatch_TChecksum** out_checksumPlugin,const char* checksumType){
*out_checksumPlugin=0;
if (strlen(checksumType)==0) return hpatch_TRUE;
#ifdef _ChecksumPlugin_fadler64
__setChecksum(&fadler64ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_xxh128
__setChecksum(&xxh128ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_xxh3
__setChecksum(&xxh3ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_md5
__setChecksum(&md5ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_crc32
__setChecksum(&crc32ChecksumPlugin);
#endif
Expand All @@ -879,23 +891,11 @@ static hpatch_BOOL findChecksum(hpatch_TChecksum** out_checksumPlugin,const char
#ifdef _ChecksumPlugin_fadler32
__setChecksum(&fadler32ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_fadler64
__setChecksum(&fadler64ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_fadler128
__setChecksum(&fadler128ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_md5
__setChecksum(&md5ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_blake3
__setChecksum(&blake3ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_xxh3
__setChecksum(&xxh3ChecksumPlugin);
#endif
#ifdef _ChecksumPlugin_xxh128
__setChecksum(&xxh128ChecksumPlugin);
#endif
return hpatch_FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion libHDiffPatch/HDiff/private_diff/pack_uint.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inline static void pushBack(std::vector<unsigned char>& out_buf,const std::vecto
}

static void pushBack(std::vector<unsigned char>& out_buf,const hpatch_TStreamInput* data){
const size_t kStepSize=hpatch_kStreamCacheSize*4;
const size_t kStepSize=hpatch_kStreamCacheSize*2;
unsigned char buf[kStepSize];
out_buf.reserve(out_buf.size()+(size_t)data->streamSize);
hpatch_StreamPos_t curPos=0;
Expand Down
5 changes: 5 additions & 0 deletions libHDiffPatch/HPatch/patch_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ void TDiffToSingleStream_init(TDiffToSingleStream* self,const hpatch_TStreamInpu
hpatch_inline static
void TDiffToSingleStream_setInSingleStream(TDiffToSingleStream* self,hpatch_StreamPos_t singleStreamPos){
self->isInSingleStream=hpatch_TRUE; }

hpatch_inline static
void TDiffToSingleStream_resetStream(TDiffToSingleStream* self,const hpatch_TStreamInput* diffStream){
self->diffStream=diffStream; }


#ifdef __cplusplus
}
Expand Down

0 comments on commit fb4325e

Please sign in to comment.