Merge pull request #837 from facebook/libzstd-nomt
makes it possible to compile libzstd in single-thread mode without zs…
This commit is contained in:
@@ -3,6 +3,7 @@ license : changed /examples license to BSD + GPLv2
|
|||||||
license : fix a few header files to reflect new license (#825)
|
license : fix a few header files to reflect new license (#825)
|
||||||
fix : 32-bits build can now decode large offsets (levels 21+)
|
fix : 32-bits build can now decode large offsets (levels 21+)
|
||||||
fix : a rare compression bug when compression generates very large distances (only possible at --ultra -22)
|
fix : a rare compression bug when compression generates very large distances (only possible at --ultra -22)
|
||||||
|
build: fix : no-multithread variant compiles without pool.c dependency, reported by Mitchell Blank Jr (@mitchblank) (#819)
|
||||||
build: better compatibility with reproducible builds, by Bernhard M. Wiedemann (@bmwiedemann) (#818)
|
build: better compatibility with reproducible builds, by Bernhard M. Wiedemann (@bmwiedemann) (#818)
|
||||||
|
|
||||||
v1.3.1
|
v1.3.1
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ dependencies:
|
|||||||
test:
|
test:
|
||||||
override:
|
override:
|
||||||
- ? |
|
- ? |
|
||||||
if [[ "$CIRCLE_NODE_INDEX" == "0" ]] ; then cc -v; make all && make clean; fi &&
|
if [[ "$CIRCLE_NODE_INDEX" == "0" ]] ; then cc -v; make all && make clean && make -C lib libzstd-nomt && make clean; fi &&
|
||||||
if [[ "$CIRCLE_NODE_TOTAL" < "2" ]] || [[ "$CIRCLE_NODE_INDEX" == "1" ]]; then make gnu90build && make clean; fi
|
if [[ "$CIRCLE_NODE_TOTAL" < "2" ]] || [[ "$CIRCLE_NODE_INDEX" == "1" ]]; then make gnu90build && make clean; fi
|
||||||
:
|
:
|
||||||
parallel: true
|
parallel: true
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
# make install artefact
|
# make install artefact
|
||||||
libzstd.pc
|
libzstd.pc
|
||||||
|
libzstd-nomt
|
||||||
|
|||||||
+10
-1
@@ -101,10 +101,19 @@ lib-release lib-release-mt: DEBUGFLAGS :=
|
|||||||
lib-release: lib
|
lib-release: lib
|
||||||
lib-release-mt: lib-mt
|
lib-release-mt: lib-mt
|
||||||
|
|
||||||
|
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
||||||
|
ZSTDMT_FILES = compress/zstdmt_compress.c
|
||||||
|
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
||||||
|
libzstd-nomt: LDFLAGS += -shared -fPIC -fvisibility=hidden
|
||||||
|
libzstd-nomt: $(ZSTD_NOMT_FILES)
|
||||||
|
@echo compiling single-thread dynamic library $(LIBVER)
|
||||||
|
@echo files : $(ZSTD_NOMT_FILES)
|
||||||
|
@$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(RM) -r *.dSYM # Mac OS-X specific
|
@$(RM) -r *.dSYM # Mac OS-X specific
|
||||||
@$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
@$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
||||||
@$(RM) dll/libzstd.dll dll/libzstd.lib
|
@$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
||||||
@$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
|
@$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
|
||||||
@echo Cleaning library completed
|
@echo Cleaning library completed
|
||||||
|
|
||||||
|
|||||||
@@ -112,23 +112,37 @@ size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx)
|
|||||||
cctx->workSpace = NULL;
|
cctx->workSpace = NULL;
|
||||||
ZSTD_freeCDict(cctx->cdictLocal);
|
ZSTD_freeCDict(cctx->cdictLocal);
|
||||||
cctx->cdictLocal = NULL;
|
cctx->cdictLocal = NULL;
|
||||||
|
#ifdef ZSTD_MULTITHREAD
|
||||||
ZSTDMT_freeCCtx(cctx->mtctx);
|
ZSTDMT_freeCCtx(cctx->mtctx);
|
||||||
cctx->mtctx = NULL;
|
cctx->mtctx = NULL;
|
||||||
|
#endif
|
||||||
ZSTD_free(cctx, cctx->customMem);
|
ZSTD_free(cctx, cctx->customMem);
|
||||||
return 0; /* reserved as a potential error code in the future */
|
return 0; /* reserved as a potential error code in the future */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static size_t ZSTD_sizeof_mtctx(const ZSTD_CCtx* cctx)
|
||||||
|
{
|
||||||
|
#ifdef ZSTD_MULTITHREAD
|
||||||
|
return ZSTDMT_sizeof_CCtx(cctx->mtctx);
|
||||||
|
#else
|
||||||
|
(void) cctx;
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx)
|
size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx)
|
||||||
{
|
{
|
||||||
if (cctx==NULL) return 0; /* support sizeof on NULL */
|
if (cctx==NULL) return 0; /* support sizeof on NULL */
|
||||||
DEBUGLOG(5, "sizeof(*cctx) : %u", (U32)sizeof(*cctx));
|
DEBUGLOG(5, "sizeof(*cctx) : %u", (U32)sizeof(*cctx));
|
||||||
DEBUGLOG(5, "workSpaceSize : %u", (U32)cctx->workSpaceSize);
|
DEBUGLOG(5, "workSpaceSize : %u", (U32)cctx->workSpaceSize);
|
||||||
DEBUGLOG(5, "streaming buffers : %u", (U32)(cctx->outBuffSize + cctx->inBuffSize));
|
DEBUGLOG(5, "streaming buffers : %u", (U32)(cctx->outBuffSize + cctx->inBuffSize));
|
||||||
DEBUGLOG(5, "inner MTCTX : %u", (U32)ZSTDMT_sizeof_CCtx(cctx->mtctx));
|
DEBUGLOG(5, "inner MTCTX : %u", (U32)ZSTD_sizeof_mtctx(cctx));
|
||||||
return sizeof(*cctx) + cctx->workSpaceSize
|
return sizeof(*cctx) + cctx->workSpaceSize
|
||||||
+ ZSTD_sizeof_CDict(cctx->cdictLocal)
|
+ ZSTD_sizeof_CDict(cctx->cdictLocal)
|
||||||
+ cctx->outBuffSize + cctx->inBuffSize
|
+ cctx->outBuffSize + cctx->inBuffSize
|
||||||
+ ZSTDMT_sizeof_CCtx(cctx->mtctx);
|
+ ZSTD_sizeof_mtctx(cctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs)
|
size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs)
|
||||||
@@ -238,10 +252,6 @@ static ZSTD_CCtx_params ZSTD_assignParamsToCCtxParams(
|
|||||||
return ERROR(parameter_outOfBound); \
|
return ERROR(parameter_outOfBound); \
|
||||||
} }
|
} }
|
||||||
|
|
||||||
size_t ZSTDMT_CCtxParam_setMTCtxParameter(
|
|
||||||
ZSTD_CCtx_params* params, ZSTDMT_parameter parameter, unsigned value);
|
|
||||||
size_t ZSTDMT_initializeCCtxParameters(ZSTD_CCtx_params* params, unsigned nbThreads);
|
|
||||||
|
|
||||||
size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value)
|
size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value)
|
||||||
{
|
{
|
||||||
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
|
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
|
||||||
@@ -379,16 +389,26 @@ size_t ZSTD_CCtxParam_setParameter(
|
|||||||
if (value == 0) return 0;
|
if (value == 0) return 0;
|
||||||
#ifndef ZSTD_MULTITHREAD
|
#ifndef ZSTD_MULTITHREAD
|
||||||
if (value > 1) return ERROR(parameter_unsupported);
|
if (value > 1) return ERROR(parameter_unsupported);
|
||||||
#endif
|
return 0;
|
||||||
|
#else
|
||||||
return ZSTDMT_initializeCCtxParameters(params, value);
|
return ZSTDMT_initializeCCtxParameters(params, value);
|
||||||
|
#endif
|
||||||
|
|
||||||
case ZSTD_p_jobSize :
|
case ZSTD_p_jobSize :
|
||||||
|
#ifndef ZSTD_MULTITHREAD
|
||||||
|
return ERROR(parameter_unsupported);
|
||||||
|
#else
|
||||||
if (params->nbThreads <= 1) return ERROR(parameter_unsupported);
|
if (params->nbThreads <= 1) return ERROR(parameter_unsupported);
|
||||||
return ZSTDMT_CCtxParam_setMTCtxParameter(params, ZSTDMT_p_sectionSize, value);
|
return ZSTDMT_CCtxParam_setMTCtxParameter(params, ZSTDMT_p_sectionSize, value);
|
||||||
|
#endif
|
||||||
|
|
||||||
case ZSTD_p_overlapSizeLog :
|
case ZSTD_p_overlapSizeLog :
|
||||||
|
#ifndef ZSTD_MULTITHREAD
|
||||||
|
return ERROR(parameter_unsupported);
|
||||||
|
#else
|
||||||
if (params->nbThreads <= 1) return ERROR(parameter_unsupported);
|
if (params->nbThreads <= 1) return ERROR(parameter_unsupported);
|
||||||
return ZSTDMT_CCtxParam_setMTCtxParameter(params, ZSTDMT_p_overlapSectionLog, value);
|
return ZSTDMT_CCtxParam_setMTCtxParameter(params, ZSTDMT_p_overlapSectionLog, value);
|
||||||
|
#endif
|
||||||
|
|
||||||
default: return ERROR(parameter_unsupported);
|
default: return ERROR(parameter_unsupported);
|
||||||
}
|
}
|
||||||
@@ -2531,16 +2551,6 @@ size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuf
|
|||||||
return ZSTD_compressStream_generic(zcs, output, input, ZSTD_e_continue);
|
return ZSTD_compressStream_generic(zcs, output, input, ZSTD_e_continue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ZSTDMT_initCStream_internal() :
|
|
||||||
* Private use only. Init streaming operation.
|
|
||||||
* expects params to be valid.
|
|
||||||
* must receive dict, or cdict, or none, but not both.
|
|
||||||
* @return : 0, or an error code */
|
|
||||||
size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
|
|
||||||
const void* dict, size_t dictSize, ZSTD_dictMode_e dictMode,
|
|
||||||
const ZSTD_CDict* cdict,
|
|
||||||
ZSTD_CCtx_params params, unsigned long long pledgedSrcSize);
|
|
||||||
|
|
||||||
|
|
||||||
size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
|
||||||
ZSTD_outBuffer* output,
|
ZSTD_outBuffer* output,
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
* Dependencies
|
* Dependencies
|
||||||
***************************************/
|
***************************************/
|
||||||
#include "zstd_internal.h"
|
#include "zstd_internal.h"
|
||||||
#include "zstdmt_compress.h"
|
#ifdef ZSTD_MULTITHREAD
|
||||||
|
# include "zstdmt_compress.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -90,7 +92,9 @@ struct ZSTD_CCtx_s {
|
|||||||
ZSTD_prefixDict prefixDict; /* single-usage dictionary */
|
ZSTD_prefixDict prefixDict; /* single-usage dictionary */
|
||||||
|
|
||||||
/* Multi-threading */
|
/* Multi-threading */
|
||||||
|
#ifdef ZSTD_MULTITHREAD
|
||||||
ZSTDMT_CCtx* mtctx;
|
ZSTDMT_CCtx* mtctx;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -164,7 +168,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
|
|||||||
unsigned long r = 0;
|
unsigned long r = 0;
|
||||||
_BitScanForward64( &r, (U64)val );
|
_BitScanForward64( &r, (U64)val );
|
||||||
return (unsigned)(r>>3);
|
return (unsigned)(r>>3);
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
return (__builtin_ctzll((U64)val) >> 3);
|
return (__builtin_ctzll((U64)val) >> 3);
|
||||||
# else
|
# else
|
||||||
static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2,
|
static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2,
|
||||||
@@ -198,7 +202,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
|
|||||||
unsigned long r = 0;
|
unsigned long r = 0;
|
||||||
_BitScanReverse64( &r, val );
|
_BitScanReverse64( &r, val );
|
||||||
return (unsigned)(r>>3);
|
return (unsigned)(r>>3);
|
||||||
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
# elif defined(__GNUC__) && (__GNUC__ >= 4)
|
||||||
return (__builtin_clzll(val) >> 3);
|
return (__builtin_clzll(val) >> 3);
|
||||||
# else
|
# else
|
||||||
unsigned r;
|
unsigned r;
|
||||||
|
|||||||
@@ -108,6 +108,22 @@ ZSTDLIB_API size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
|
|||||||
ZSTD_EndDirective endOp);
|
ZSTD_EndDirective endOp);
|
||||||
|
|
||||||
|
|
||||||
|
/* === Private definitions; never ever use directly === */
|
||||||
|
|
||||||
|
size_t ZSTDMT_CCtxParam_setMTCtxParameter(ZSTD_CCtx_params* params, ZSTDMT_parameter parameter, unsigned value);
|
||||||
|
|
||||||
|
size_t ZSTDMT_initializeCCtxParameters(ZSTD_CCtx_params* params, unsigned nbThreads);
|
||||||
|
|
||||||
|
/*! ZSTDMT_initCStream_internal() :
|
||||||
|
* Private use only. Init streaming operation.
|
||||||
|
* expects params to be valid.
|
||||||
|
* must receive dict, or cdict, or none, but not both.
|
||||||
|
* @return : 0, or an error code */
|
||||||
|
size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
|
||||||
|
const void* dict, size_t dictSize, ZSTD_dictMode_e dictMode,
|
||||||
|
const ZSTD_CDict* cdict,
|
||||||
|
ZSTD_CCtx_params params, unsigned long long pledgedSrcSize);
|
||||||
|
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user