18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef PERF_COMPRESS_H 38c2ecf20Sopenharmony_ci#define PERF_COMPRESS_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <stdbool.h> 68c2ecf20Sopenharmony_ci#ifdef HAVE_ZSTD_SUPPORT 78c2ecf20Sopenharmony_ci#include <zstd.h> 88c2ecf20Sopenharmony_ci#endif 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifdef HAVE_ZLIB_SUPPORT 118c2ecf20Sopenharmony_ciint gzip_decompress_to_file(const char *input, int output_fd); 128c2ecf20Sopenharmony_cibool gzip_is_compressed(const char *input); 138c2ecf20Sopenharmony_ci#endif 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifdef HAVE_LZMA_SUPPORT 168c2ecf20Sopenharmony_ciint lzma_decompress_to_file(const char *input, int output_fd); 178c2ecf20Sopenharmony_cibool lzma_is_compressed(const char *input); 188c2ecf20Sopenharmony_ci#endif 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistruct zstd_data { 218c2ecf20Sopenharmony_ci#ifdef HAVE_ZSTD_SUPPORT 228c2ecf20Sopenharmony_ci ZSTD_CStream *cstream; 238c2ecf20Sopenharmony_ci ZSTD_DStream *dstream; 248c2ecf20Sopenharmony_ci#endif 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#ifdef HAVE_ZSTD_SUPPORT 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciint zstd_init(struct zstd_data *data, int level); 308c2ecf20Sopenharmony_ciint zstd_fini(struct zstd_data *data); 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cisize_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_t dst_size, 338c2ecf20Sopenharmony_ci void *src, size_t src_size, size_t max_record_size, 348c2ecf20Sopenharmony_ci size_t process_header(void *record, size_t increment)); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cisize_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size, 378c2ecf20Sopenharmony_ci void *dst, size_t dst_size); 388c2ecf20Sopenharmony_ci#else /* !HAVE_ZSTD_SUPPORT */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistatic inline int zstd_init(struct zstd_data *data __maybe_unused, int level __maybe_unused) 418c2ecf20Sopenharmony_ci{ 428c2ecf20Sopenharmony_ci return 0; 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic inline int zstd_fini(struct zstd_data *data __maybe_unused) 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci return 0; 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistatic inline 518c2ecf20Sopenharmony_cisize_t zstd_compress_stream_to_records(struct zstd_data *data __maybe_unused, 528c2ecf20Sopenharmony_ci void *dst __maybe_unused, size_t dst_size __maybe_unused, 538c2ecf20Sopenharmony_ci void *src __maybe_unused, size_t src_size __maybe_unused, 548c2ecf20Sopenharmony_ci size_t max_record_size __maybe_unused, 558c2ecf20Sopenharmony_ci size_t process_header(void *record, size_t increment) __maybe_unused) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci return 0; 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic inline size_t zstd_decompress_stream(struct zstd_data *data __maybe_unused, void *src __maybe_unused, 618c2ecf20Sopenharmony_ci size_t src_size __maybe_unused, void *dst __maybe_unused, 628c2ecf20Sopenharmony_ci size_t dst_size __maybe_unused) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci return 0; 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci#endif 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#endif /* PERF_COMPRESS_H */ 69