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