blob: 0cd3369af2a4f2cdfb184f25e22a3beb53c87040 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Arnaldo Carvalho de Melo611f0af2017-04-19 16:29:38 -03002#ifndef PERF_COMPRESS_H
3#define PERF_COMPRESS_H
4
Alexey Budankovf24c1d72019-03-18 20:42:55 +03005#include <stdbool.h>
6#ifdef HAVE_ZSTD_SUPPORT
7#include <zstd.h>
8#endif
9
Arnaldo Carvalho de Melo611f0af2017-04-19 16:29:38 -030010#ifdef HAVE_ZLIB_SUPPORT
11int gzip_decompress_to_file(const char *input, int output_fd);
Jiri Olsa8b42b7e2018-08-17 11:48:10 +020012bool gzip_is_compressed(const char *input);
Arnaldo Carvalho de Melo611f0af2017-04-19 16:29:38 -030013#endif
14
15#ifdef HAVE_LZMA_SUPPORT
16int lzma_decompress_to_file(const char *input, int output_fd);
Jiri Olsa8b42b7e2018-08-17 11:48:10 +020017bool lzma_is_compressed(const char *input);
Arnaldo Carvalho de Melo611f0af2017-04-19 16:29:38 -030018#endif
19
Alexey Budankovf24c1d72019-03-18 20:42:55 +030020struct zstd_data {
21#ifdef HAVE_ZSTD_SUPPORT
22 ZSTD_CStream *cstream;
Alexey Budankovcb62c6f2019-03-18 20:45:11 +030023 ZSTD_DStream *dstream;
Alexey Budankovf24c1d72019-03-18 20:42:55 +030024#endif
25};
26
27#ifdef HAVE_ZSTD_SUPPORT
28
29int zstd_init(struct zstd_data *data, int level);
30int zstd_fini(struct zstd_data *data);
31
32size_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_t dst_size,
33 void *src, size_t src_size, size_t max_record_size,
34 size_t process_header(void *record, size_t increment));
Alexey Budankovcb62c6f2019-03-18 20:45:11 +030035
36size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size,
37 void *dst, size_t dst_size);
Alexey Budankovf24c1d72019-03-18 20:42:55 +030038#else /* !HAVE_ZSTD_SUPPORT */
39
40static inline int zstd_init(struct zstd_data *data __maybe_unused, int level __maybe_unused)
41{
42 return 0;
43}
44
45static inline int zstd_fini(struct zstd_data *data __maybe_unused)
46{
47 return 0;
48}
49
50static inline
51size_t zstd_compress_stream_to_records(struct zstd_data *data __maybe_unused,
52 void *dst __maybe_unused, size_t dst_size __maybe_unused,
53 void *src __maybe_unused, size_t src_size __maybe_unused,
54 size_t max_record_size __maybe_unused,
55 size_t process_header(void *record, size_t increment) __maybe_unused)
56{
57 return 0;
58}
Alexey Budankovcb62c6f2019-03-18 20:45:11 +030059
60static inline size_t zstd_decompress_stream(struct zstd_data *data __maybe_unused, void *src __maybe_unused,
61 size_t src_size __maybe_unused, void *dst __maybe_unused,
62 size_t dst_size __maybe_unused)
63{
64 return 0;
65}
Alexey Budankovf24c1d72019-03-18 20:42:55 +030066#endif
67
Arnaldo Carvalho de Melo611f0af2017-04-19 16:29:38 -030068#endif /* PERF_COMPRESS_H */