Linux 5.1.15
[linux/fpc-iii.git] / tools / perf / util / data.h
blob259868a39019890ce6c91de895fc7cf2048c7e6e
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_DATA_H
3 #define __PERF_DATA_H
5 #include <stdbool.h>
7 enum perf_data_mode {
8 PERF_DATA_MODE_WRITE,
9 PERF_DATA_MODE_READ,
12 struct perf_data_file {
13 char *path;
14 int fd;
15 unsigned long size;
18 struct perf_data {
19 const char *path;
20 struct perf_data_file file;
21 bool is_pipe;
22 bool is_dir;
23 bool force;
24 enum perf_data_mode mode;
26 struct {
27 u64 version;
28 struct perf_data_file *files;
29 int nr;
30 } dir;
33 static inline bool perf_data__is_read(struct perf_data *data)
35 return data->mode == PERF_DATA_MODE_READ;
38 static inline bool perf_data__is_write(struct perf_data *data)
40 return data->mode == PERF_DATA_MODE_WRITE;
43 static inline int perf_data__is_pipe(struct perf_data *data)
45 return data->is_pipe;
48 static inline bool perf_data__is_dir(struct perf_data *data)
50 return data->is_dir;
53 static inline int perf_data__fd(struct perf_data *data)
55 return data->file.fd;
58 int perf_data__open(struct perf_data *data);
59 void perf_data__close(struct perf_data *data);
60 ssize_t perf_data__write(struct perf_data *data,
61 void *buf, size_t size);
62 ssize_t perf_data_file__write(struct perf_data_file *file,
63 void *buf, size_t size);
65 * If at_exit is set, only rename current perf.data to
66 * perf.data.<postfix>, continue write on original data.
67 * Set at_exit when flushing the last output.
69 * Return value is fd of new output.
71 int perf_data__switch(struct perf_data *data,
72 const char *postfix,
73 size_t pos, bool at_exit, char **new_filepath);
75 int perf_data__create_dir(struct perf_data *data, int nr);
76 int perf_data__open_dir(struct perf_data *data);
77 void perf_data__close_dir(struct perf_data *data);
78 int perf_data__update_dir(struct perf_data *data);
79 unsigned long perf_data__size(struct perf_data *data);
80 #endif /* __PERF_DATA_H */