Distinguish static symbols, allow hiding them
Even with -fvisibility=hidden added to CFLAGS, any symbol which is given a default visibility attribute ends up exported in the dynamic library. This happens through zstd_internal.h which defines ..._STATIC_LINKING_ONLY before including various header files, and is included for example in lib/common/pool.c. To avoid this, this patch distinguishes static and non-static APIs, by using ZSTDLIB_API only for the latter, and introducing ZSTDLIB_STATIC_API for the former. For now, both are exported, but non-static APIs can be hidden by overriding the definition ZSTDLIB_STATIC_API. lib/Makefile is modified to allow this using make CPPFLAGS_DYNLIB=-DZSTDLIB_STATIC_API=ZSTDLIB_HIDDEN In addition, API declarations are dropped from zstd_compress.c (they aren't needed there). Signed-off-by: Stephen Kitt <steve@sk2.org>
This commit is contained in:
@@ -1067,7 +1067,7 @@ size_t ZSTD_CCtx_setParametersUsingCCtxParams(
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize)
|
||||
size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize)
|
||||
{
|
||||
DEBUGLOG(4, "ZSTD_CCtx_setPledgedSrcSize to %u bytes", (U32)pledgedSrcSize);
|
||||
RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong,
|
||||
@@ -1147,14 +1147,14 @@ size_t ZSTD_CCtx_loadDictionary_advanced(
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(
|
||||
size_t ZSTD_CCtx_loadDictionary_byReference(
|
||||
ZSTD_CCtx* cctx, const void* dict, size_t dictSize)
|
||||
{
|
||||
return ZSTD_CCtx_loadDictionary_advanced(
|
||||
cctx, dict, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto);
|
||||
}
|
||||
|
||||
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize)
|
||||
size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize)
|
||||
{
|
||||
return ZSTD_CCtx_loadDictionary_advanced(
|
||||
cctx, dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto);
|
||||
@@ -4842,7 +4842,7 @@ ZSTD_CDict* ZSTD_createCDict_advanced(const void* dictBuffer, size_t dictSize,
|
||||
&cctxParams, customMem);
|
||||
}
|
||||
|
||||
ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced2(
|
||||
ZSTD_CDict* ZSTD_createCDict_advanced2(
|
||||
const void* dict, size_t dictSize,
|
||||
ZSTD_dictLoadMethod_e dictLoadMethod,
|
||||
ZSTD_dictContentType_e dictContentType,
|
||||
|
||||
Reference in New Issue
Block a user