Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
611f0afe ACM |
2 | #ifndef PERF_COMPRESS_H |
3 | #define PERF_COMPRESS_H | |
4 | ||
f24c1d75 | 5 | #include <stdbool.h> |
5940a20a IR |
6 | #include <stddef.h> |
7 | #include <sys/types.h> | |
f24c1d75 AB |
8 | #ifdef HAVE_ZSTD_SUPPORT |
9 | #include <zstd.h> | |
10 | #endif | |
11 | ||
611f0afe ACM |
12 | #ifdef HAVE_ZLIB_SUPPORT |
13 | int gzip_decompress_to_file(const char *input, int output_fd); | |
8b42b7e5 | 14 | bool gzip_is_compressed(const char *input); |
611f0afe ACM |
15 | #endif |
16 | ||
17 | #ifdef HAVE_LZMA_SUPPORT | |
18 | int lzma_decompress_to_file(const char *input, int output_fd); | |
8b42b7e5 | 19 | bool lzma_is_compressed(const char *input); |
611f0afe ACM |
20 | #endif |
21 | ||
f24c1d75 AB |
22 | struct zstd_data { |
23 | #ifdef HAVE_ZSTD_SUPPORT | |
24 | ZSTD_CStream *cstream; | |
cb62c6f1 | 25 | ZSTD_DStream *dstream; |
5940a20a | 26 | int comp_level; |
f24c1d75 AB |
27 | #endif |
28 | }; | |
29 | ||
30 | #ifdef HAVE_ZSTD_SUPPORT | |
31 | ||
32 | int zstd_init(struct zstd_data *data, int level); | |
33 | int zstd_fini(struct zstd_data *data); | |
34 | ||
5940a20a | 35 | ssize_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_t dst_size, |
f24c1d75 AB |
36 | void *src, size_t src_size, size_t max_record_size, |
37 | size_t process_header(void *record, size_t increment)); | |
cb62c6f1 AB |
38 | |
39 | size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size, | |
40 | void *dst, size_t dst_size); | |
f24c1d75 AB |
41 | #else /* !HAVE_ZSTD_SUPPORT */ |
42 | ||
43 | static inline int zstd_init(struct zstd_data *data __maybe_unused, int level __maybe_unused) | |
44 | { | |
45 | return 0; | |
46 | } | |
47 | ||
48 | static inline int zstd_fini(struct zstd_data *data __maybe_unused) | |
49 | { | |
50 | return 0; | |
51 | } | |
52 | ||
53 | static inline | |
5940a20a | 54 | ssize_t zstd_compress_stream_to_records(struct zstd_data *data __maybe_unused, |
f24c1d75 AB |
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) | |
59 | { | |
60 | return 0; | |
61 | } | |
cb62c6f1 AB |
62 | |
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) | |
66 | { | |
67 | return 0; | |
68 | } | |
f24c1d75 AB |
69 | #endif |
70 | ||
611f0afe | 71 | #endif /* PERF_COMPRESS_H */ |