Merge pull request #2589 from terrelln/tracing

[trace] Remove default definitions of weak symbols
This commit is contained in:
Nick Terrell 2021-04-27 10:39:12 -07:00 committed by GitHub
commit 333dd60bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 52 deletions

View File

@ -22,7 +22,6 @@ libzstd_sources = [join_paths(zstd_rootdir, 'lib/common/entropy_common.c'),
join_paths(zstd_rootdir, 'lib/common/threading.c'), join_paths(zstd_rootdir, 'lib/common/threading.c'),
join_paths(zstd_rootdir, 'lib/common/pool.c'), join_paths(zstd_rootdir, 'lib/common/pool.c'),
join_paths(zstd_rootdir, 'lib/common/zstd_common.c'), join_paths(zstd_rootdir, 'lib/common/zstd_common.c'),
join_paths(zstd_rootdir, 'lib/common/zstd_trace.c'),
join_paths(zstd_rootdir, 'lib/common/error_private.c'), join_paths(zstd_rootdir, 'lib/common/error_private.c'),
join_paths(zstd_rootdir, 'lib/common/xxhash.c'), join_paths(zstd_rootdir, 'lib/common/xxhash.c'),
join_paths(zstd_rootdir, 'lib/compress/hist.c'), join_paths(zstd_rootdir, 'lib/compress/hist.c'),

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under both the BSD-style license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
*/
#include "zstd_trace.h"
#include "../zstd.h"
#include "compiler.h"
#if ZSTD_TRACE && ZSTD_HAVE_WEAK_SYMBOLS
ZSTD_WEAK_ATTR ZSTD_TraceCtx ZSTD_trace_compress_begin(ZSTD_CCtx const* cctx)
{
(void)cctx;
return 0;
}
ZSTD_WEAK_ATTR void ZSTD_trace_compress_end(ZSTD_TraceCtx ctx, ZSTD_Trace const* trace)
{
(void)ctx;
(void)trace;
}
ZSTD_WEAK_ATTR ZSTD_TraceCtx ZSTD_trace_decompress_begin(ZSTD_DCtx const* dctx)
{
(void)dctx;
return 0;
}
ZSTD_WEAK_ATTR void ZSTD_trace_decompress_end(ZSTD_TraceCtx ctx, ZSTD_Trace const* trace)
{
(void)ctx;
(void)trace;
}
#endif

View File

@ -114,14 +114,15 @@ typedef unsigned long long ZSTD_TraceCtx;
* @returns Non-zero if tracing is enabled. The return value is * @returns Non-zero if tracing is enabled. The return value is
* passed to ZSTD_trace_compress_end(). * passed to ZSTD_trace_compress_end().
*/ */
ZSTD_TraceCtx ZSTD_trace_compress_begin(struct ZSTD_CCtx_s const* cctx); ZSTD_WEAK_ATTR ZSTD_TraceCtx ZSTD_trace_compress_begin(
struct ZSTD_CCtx_s const* cctx);
/** /**
* Trace the end of a compression call. * Trace the end of a compression call.
* @param ctx The return value of ZSTD_trace_compress_begin(). * @param ctx The return value of ZSTD_trace_compress_begin().
* @param trace The zstd tracing info. * @param trace The zstd tracing info.
*/ */
void ZSTD_trace_compress_end( ZSTD_WEAK_ATTR void ZSTD_trace_compress_end(
ZSTD_TraceCtx ctx, ZSTD_TraceCtx ctx,
ZSTD_Trace const* trace); ZSTD_Trace const* trace);
@ -132,14 +133,15 @@ void ZSTD_trace_compress_end(
* @returns Non-zero if tracing is enabled. The return value is * @returns Non-zero if tracing is enabled. The return value is
* passed to ZSTD_trace_compress_end(). * passed to ZSTD_trace_compress_end().
*/ */
ZSTD_TraceCtx ZSTD_trace_decompress_begin(struct ZSTD_DCtx_s const* dctx); ZSTD_WEAK_ATTR ZSTD_TraceCtx ZSTD_trace_decompress_begin(
struct ZSTD_DCtx_s const* dctx);
/** /**
* Trace the end of a decompression call. * Trace the end of a decompression call.
* @param ctx The return value of ZSTD_trace_decompress_begin(). * @param ctx The return value of ZSTD_trace_decompress_begin().
* @param trace The zstd tracing info. * @param trace The zstd tracing info.
*/ */
void ZSTD_trace_decompress_end( ZSTD_WEAK_ATTR void ZSTD_trace_decompress_end(
ZSTD_TraceCtx ctx, ZSTD_TraceCtx ctx,
ZSTD_Trace const* trace); ZSTD_Trace const* trace);

View File

@ -4379,7 +4379,7 @@ static size_t ZSTD_compressBegin_internal(ZSTD_CCtx* cctx,
ZSTD_buffered_policy_e zbuff) ZSTD_buffered_policy_e zbuff)
{ {
#if ZSTD_TRACE #if ZSTD_TRACE
cctx->traceCtx = ZSTD_trace_compress_begin(cctx); cctx->traceCtx = (ZSTD_trace_compress_begin != NULL) ? ZSTD_trace_compress_begin(cctx) : 0;
#endif #endif
DEBUGLOG(4, "ZSTD_compressBegin_internal: wlog=%u", params->cParams.windowLog); DEBUGLOG(4, "ZSTD_compressBegin_internal: wlog=%u", params->cParams.windowLog);
/* params are supposed to be fully validated at this point */ /* params are supposed to be fully validated at this point */
@ -4510,7 +4510,7 @@ static size_t ZSTD_writeEpilogue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity)
void ZSTD_CCtx_trace(ZSTD_CCtx* cctx, size_t extraCSize) void ZSTD_CCtx_trace(ZSTD_CCtx* cctx, size_t extraCSize)
{ {
#if ZSTD_TRACE #if ZSTD_TRACE
if (cctx->traceCtx) { if (cctx->traceCtx && ZSTD_trace_compress_end != NULL) {
int const streaming = cctx->inBuffSize > 0 || cctx->outBuffSize > 0 || cctx->appliedParams.nbWorkers > 0; int const streaming = cctx->inBuffSize > 0 || cctx->outBuffSize > 0 || cctx->appliedParams.nbWorkers > 0;
ZSTD_Trace trace; ZSTD_Trace trace;
ZSTD_memset(&trace, 0, sizeof(trace)); ZSTD_memset(&trace, 0, sizeof(trace));
@ -5456,7 +5456,7 @@ static size_t ZSTD_CCtx_init_compressStream2(ZSTD_CCtx* cctx,
} }
if (params.nbWorkers > 0) { if (params.nbWorkers > 0) {
#if ZSTD_TRACE #if ZSTD_TRACE
cctx->traceCtx = ZSTD_trace_compress_begin(cctx); cctx->traceCtx = (ZSTD_trace_compress_begin != NULL) ? ZSTD_trace_compress_begin(cctx) : 0;
#endif #endif
/* mt context creation */ /* mt context creation */
if (cctx->mtctx == NULL) { if (cctx->mtctx == NULL) {

View File

@ -788,7 +788,7 @@ static size_t ZSTD_setRleBlock(void* dst, size_t dstCapacity,
static void ZSTD_DCtx_trace_end(ZSTD_DCtx const* dctx, U64 uncompressedSize, U64 compressedSize, unsigned streaming) static void ZSTD_DCtx_trace_end(ZSTD_DCtx const* dctx, U64 uncompressedSize, U64 compressedSize, unsigned streaming)
{ {
#if ZSTD_TRACE #if ZSTD_TRACE
if (dctx->traceCtx) { if (dctx->traceCtx && ZSTD_trace_decompress_end != NULL) {
ZSTD_Trace trace; ZSTD_Trace trace;
ZSTD_memset(&trace, 0, sizeof(trace)); ZSTD_memset(&trace, 0, sizeof(trace));
trace.version = ZSTD_VERSION_NUMBER; trace.version = ZSTD_VERSION_NUMBER;
@ -1383,7 +1383,7 @@ size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx)
{ {
assert(dctx != NULL); assert(dctx != NULL);
#if ZSTD_TRACE #if ZSTD_TRACE
dctx->traceCtx = ZSTD_trace_decompress_begin(dctx); dctx->traceCtx = (ZSTD_trace_decompress_begin != NULL) ? ZSTD_trace_decompress_begin(dctx) : 0;
#endif #endif
dctx->expected = ZSTD_startingInputLength(dctx->format); /* dctx->format must be properly set */ dctx->expected = ZSTD_startingInputLength(dctx->format); /* dctx->format must be properly set */
dctx->stage = ZSTDds_getFrameHeaderSize; dctx->stage = ZSTDds_getFrameHeaderSize;