^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef PERF_COMPRESS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define PERF_COMPRESS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifdef HAVE_ZSTD_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <zstd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifdef HAVE_ZLIB_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) int gzip_decompress_to_file(const char *input, int output_fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) bool gzip_is_compressed(const char *input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #ifdef HAVE_LZMA_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) int lzma_decompress_to_file(const char *input, int output_fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) bool lzma_is_compressed(const char *input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct zstd_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #ifdef HAVE_ZSTD_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) ZSTD_CStream *cstream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ZSTD_DStream *dstream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #ifdef HAVE_ZSTD_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int zstd_init(struct zstd_data *data, int level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int zstd_fini(struct zstd_data *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) size_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_t dst_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void *src, size_t src_size, size_t max_record_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) size_t process_header(void *record, size_t increment));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) void *dst, size_t dst_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #else /* !HAVE_ZSTD_SUPPORT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static inline int zstd_init(struct zstd_data *data __maybe_unused, int level __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static inline int zstd_fini(struct zstd_data *data __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) size_t zstd_compress_stream_to_records(struct zstd_data *data __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) void *dst __maybe_unused, size_t dst_size __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void *src __maybe_unused, size_t src_size __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) size_t max_record_size __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) size_t process_header(void *record, size_t increment) __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static inline size_t zstd_decompress_stream(struct zstd_data *data __maybe_unused, void *src __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) size_t src_size __maybe_unused, void *dst __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) size_t dst_size __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #endif /* PERF_COMPRESS_H */