Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / perf / util / compress.h
blobb29109cd36095c4fe4063cff1d60cf50b420d66d
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef PERF_COMPRESS_H
3 #define PERF_COMPRESS_H
5 #include <stdbool.h>
6 #include <stddef.h>
7 #include <sys/types.h>
8 #ifdef HAVE_ZSTD_SUPPORT
9 #include <zstd.h>
10 #endif
12 #ifdef HAVE_ZLIB_SUPPORT
13 int gzip_decompress_to_file(const char *input, int output_fd);
14 bool gzip_is_compressed(const char *input);
15 #endif
17 #ifdef HAVE_LZMA_SUPPORT
18 int lzma_decompress_to_file(const char *input, int output_fd);
19 bool lzma_is_compressed(const char *input);
20 #endif
22 struct zstd_data {
23 #ifdef HAVE_ZSTD_SUPPORT
24 ZSTD_CStream *cstream;
25 ZSTD_DStream *dstream;
26 int comp_level;
27 #endif
30 #ifdef HAVE_ZSTD_SUPPORT
32 int zstd_init(struct zstd_data *data, int level);
33 int zstd_fini(struct zstd_data *data);
35 ssize_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_t dst_size,
36 void *src, size_t src_size, size_t max_record_size,
37 size_t process_header(void *record, size_t increment));
39 size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size,
40 void *dst, size_t dst_size);
41 #else /* !HAVE_ZSTD_SUPPORT */
43 static inline int zstd_init(struct zstd_data *data __maybe_unused, int level __maybe_unused)
45 return 0;
48 static inline int zstd_fini(struct zstd_data *data __maybe_unused)
50 return 0;
53 static inline
54 ssize_t zstd_compress_stream_to_records(struct zstd_data *data __maybe_unused,
55 void *dst __maybe_unused, size_t dst_size __maybe_unused,
56 void *src __maybe_unused, size_t src_size __maybe_unused,
57 size_t max_record_size __maybe_unused,
58 size_t process_header(void *record, size_t increment) __maybe_unused)
60 return 0;
63 static inline size_t zstd_decompress_stream(struct zstd_data *data __maybe_unused, void *src __maybe_unused,
64 size_t src_size __maybe_unused, void *dst __maybe_unused,
65 size_t dst_size __maybe_unused)
67 return 0;
69 #endif
71 #endif /* PERF_COMPRESS_H */