1#ifndef __PERF_DATA_H 2#define __PERF_DATA_H 3 4#include <stdbool.h> 5 6enum perf_data_mode { 7 PERF_DATA_MODE_WRITE, 8 PERF_DATA_MODE_READ, 9}; 10 11struct perf_data_file { 12 const char *path; 13 int fd; 14}; 15 16struct perf_data { 17 struct perf_data_file file; 18 bool is_pipe; 19 bool force; 20 unsigned long size; 21 enum perf_data_mode mode; 22}; 23 24static inline bool perf_data__is_read(struct perf_data *data) 25{ 26 return data->mode == PERF_DATA_MODE_READ; 27} 28 29static inline bool perf_data__is_write(struct perf_data *data) 30{ 31 return data->mode == PERF_DATA_MODE_WRITE; 32} 33 34static inline int perf_data__is_pipe(struct perf_data *data) 35{ 36 return data->is_pipe; 37} 38 39static inline int perf_data__fd(struct perf_data *data) 40{ 41 return data->file.fd; 42} 43 44static inline unsigned long perf_data__size(struct perf_data *data) 45{ 46 return data->size; 47} 48 49int perf_data__open(struct perf_data *data); 50void perf_data__close(struct perf_data *data); 51ssize_t perf_data__write(struct perf_data *data, 52 void *buf, size_t size); 53ssize_t perf_data_file__write(struct perf_data_file *file, 54 void *buf, size_t size); 55/* 56 * If at_exit is set, only rename current perf.data to 57 * perf.data.<postfix>, continue write on original data. 58 * Set at_exit when flushing the last output. 59 * 60 * Return value is fd of new output. 61 */ 62int perf_data__switch(struct perf_data *data, 63 const char *postfix, 64 size_t pos, bool at_exit); 65#endif /* __PERF_DATA_H */ 66