From f406813c13937ae4f6947339aef7d1ee84111d4a Mon Sep 17 00:00:00 2001 From: sisong Date: Thu, 7 Sep 2023 09:30:39 +0800 Subject: [PATCH] fix make for riscv32; --- Makefile | 5 +++++ .../limit_mem_diff/digest_matcher.cpp | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 5883a2b3..aa23a806 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ MT := 1 ZLIB := 2 LZMA := 1 ARM64ASM := 0 +RISCV32 := 0 # 0: not need zstd; 1: compile zstd source code; 2: used -lzstd to link zstd lib; ZSTD := 1 MD5 := 1 @@ -211,6 +212,10 @@ DEF_FLAGS := \ -D_IS_NEED_DEFAULT_CompressPlugin=0 \ -D_IS_NEED_ALL_ChecksumPlugin=0 \ -D_IS_NEED_DEFAULT_ChecksumPlugin=0 +ifeq ($(RISCV32),0) +else + DEF_FLAGS += -D_IS_NO_ATOMIC_U64=1 +endif ifeq ($(M32),0) else DEF_FLAGS += -m32 diff --git a/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp b/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp index 5187c76d..1f1076e0 100644 --- a/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp +++ b/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp @@ -689,11 +689,16 @@ void TDigestMatcher::_search_cover(const hpatch_TStreamInput* newData,hpatch_Str } #if (_IS_USED_MULTITHREAD) +# if (_IS_NO_ATOMIC_U64) +# define uint_work size_t +# else +# define uint_work hpatch_StreamPos_t +# endif struct mt_data_t{ CHLocker newDataLocker; CHLocker dataLocker; - hpatch_StreamPos_t workCount; - volatile hpatch_StreamPos_t workIndex; + uint_work workCount; + volatile uint_work workIndex; }; #endif @@ -702,11 +707,11 @@ void TDigestMatcher::_search_cover_thread(hpatch_TOutputCovers* out_covers, #if (_IS_USED_MULTITHREAD) const size_t kPartPepeatSize=m_kMatchBlockSize-1; mt_data_t& mt=*(mt_data_t*)mt_data; - const hpatch_StreamPos_t workCount=mt.workCount; + const uint_work workCount=mt.workCount; const hpatch_StreamPos_t rollCount=m_newData->streamSize-(m_kMatchBlockSize-1); - std::atomic& workIndex=*(std::atomic*)&mt.workIndex; + std::atomic& workIndex=*(std::atomic*)&mt.workIndex; while (true){ - hpatch_StreamPos_t curWorkIndex=workIndex++; + uint_work curWorkIndex=workIndex++; if (curWorkIndex>=workCount) break; hpatch_StreamPos_t new_begin=rollCount*curWorkIndex/workCount; hpatch_StreamPos_t new_end=(curWorkIndex+1workCount)?threadNum:workCount; mt_data_t mt_data; - mt_data.workCount=workCount; + mt_data.workCount=(uint_work)workCount; + if ((sizeof(mt_data.workCount) threads(threadCount);