hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/tools/perf/util/compress.h
....@@ -2,6 +2,11 @@
22 #ifndef PERF_COMPRESS_H
33 #define PERF_COMPRESS_H
44
5
+#include <stdbool.h>
6
+#ifdef HAVE_ZSTD_SUPPORT
7
+#include <zstd.h>
8
+#endif
9
+
510 #ifdef HAVE_ZLIB_SUPPORT
611 int gzip_decompress_to_file(const char *input, int output_fd);
712 bool gzip_is_compressed(const char *input);
....@@ -12,4 +17,52 @@
1217 bool lzma_is_compressed(const char *input);
1318 #endif
1419
20
+struct zstd_data {
21
+#ifdef HAVE_ZSTD_SUPPORT
22
+ ZSTD_CStream *cstream;
23
+ ZSTD_DStream *dstream;
24
+#endif
25
+};
26
+
27
+#ifdef HAVE_ZSTD_SUPPORT
28
+
29
+int zstd_init(struct zstd_data *data, int level);
30
+int zstd_fini(struct zstd_data *data);
31
+
32
+size_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));
35
+
36
+size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size,
37
+ void *dst, size_t dst_size);
38
+#else /* !HAVE_ZSTD_SUPPORT */
39
+
40
+static inline int zstd_init(struct zstd_data *data __maybe_unused, int level __maybe_unused)
41
+{
42
+ return 0;
43
+}
44
+
45
+static inline int zstd_fini(struct zstd_data *data __maybe_unused)
46
+{
47
+ return 0;
48
+}
49
+
50
+static inline
51
+size_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
+}
59
+
60
+static 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
+}
66
+#endif
67
+
1568 #endif /* PERF_COMPRESS_H */