Project Alice
Loading...
Searching...
No Matches
zstd_trace.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
8 * You may select, at your option, one of the above-listed licenses.
9 */
10
11#ifndef ZSTD_TRACE_H
12#define ZSTD_TRACE_H
13
14#if defined (__cplusplus)
15extern "C" {
16#endif
17
18#include <stddef.h>
19
20/* weak symbol support
21 * For now, enable conservatively:
22 * - Only GNUC
23 * - Only ELF
24 * - Only x86-64, i386 and aarch64
25 * Also, explicitly disable on platforms known not to work so they aren't
26 * forgotten in the future.
27 */
28#if !defined(ZSTD_HAVE_WEAK_SYMBOLS) && \
29 defined(__GNUC__) && defined(__ELF__) && \
30 (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) || defined(__aarch64__)) && \
31 !defined(__APPLE__) && !defined(_WIN32) && !defined(__MINGW32__) && \
32 !defined(__CYGWIN__) && !defined(_AIX)
33# define ZSTD_HAVE_WEAK_SYMBOLS 1
34#else
35# define ZSTD_HAVE_WEAK_SYMBOLS 0
36#endif
37#if ZSTD_HAVE_WEAK_SYMBOLS
38# define ZSTD_WEAK_ATTR __attribute__((__weak__))
39#else
40# define ZSTD_WEAK_ATTR
41#endif
42
43/* Only enable tracing when weak symbols are available. */
44#ifndef ZSTD_TRACE
45# define ZSTD_TRACE ZSTD_HAVE_WEAK_SYMBOLS
46#endif
47
48#if ZSTD_TRACE
49
50struct ZSTD_CCtx_s;
51struct ZSTD_DCtx_s;
53
54typedef struct {
63 unsigned version;
67 unsigned streaming;
71 unsigned dictionaryID;
76 unsigned dictionaryIsCold;
80 size_t dictionarySize;
84 size_t uncompressedSize;
88 size_t compressedSize;
92 struct ZSTD_CCtx_params_s const* params;
96 struct ZSTD_CCtx_s const* cctx;
100 struct ZSTD_DCtx_s const* dctx;
101} ZSTD_Trace;
102
117typedef unsigned long long ZSTD_TraceCtx;
118
126ZSTD_WEAK_ATTR ZSTD_TraceCtx ZSTD_trace_compress_begin(
127 struct ZSTD_CCtx_s const* cctx);
128
134ZSTD_WEAK_ATTR void ZSTD_trace_compress_end(
135 ZSTD_TraceCtx ctx,
136 ZSTD_Trace const* trace);
137
145ZSTD_WEAK_ATTR ZSTD_TraceCtx ZSTD_trace_decompress_begin(
146 struct ZSTD_DCtx_s const* dctx);
147
153ZSTD_WEAK_ATTR void ZSTD_trace_decompress_end(
154 ZSTD_TraceCtx ctx,
155 ZSTD_Trace const* trace);
156
157#endif /* ZSTD_TRACE */
158
159#if defined (__cplusplus)
160}
161#endif
162
163#endif /* ZSTD_TRACE_H */
#define ZSTD_WEAK_ATTR
Definition: zstd_trace.h:40