]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - tools/perf/util/data.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / tools / perf / util / data.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
f5fc1412
JO
2#ifndef __PERF_DATA_H
3#define __PERF_DATA_H
4
5#include <stdbool.h>
6
7enum perf_data_mode {
8 PERF_DATA_MODE_WRITE,
9 PERF_DATA_MODE_READ,
10};
11
12struct perf_data_file {
6f9a317f
JO
13 const char *path;
14 int fd;
15 bool is_pipe;
16 bool force;
17 unsigned long size;
18 enum perf_data_mode mode;
f5fc1412
JO
19};
20
21static inline bool perf_data_file__is_read(struct perf_data_file *file)
22{
23 return file->mode == PERF_DATA_MODE_READ;
24}
25
26static inline bool perf_data_file__is_write(struct perf_data_file *file)
27{
28 return file->mode == PERF_DATA_MODE_WRITE;
29}
30
cc9784bd
JO
31static inline int perf_data_file__is_pipe(struct perf_data_file *file)
32{
33 return file->is_pipe;
34}
35
36static inline int perf_data_file__fd(struct perf_data_file *file)
37{
38 return file->fd;
39}
40
41static inline unsigned long perf_data_file__size(struct perf_data_file *file)
42{
43 return file->size;
44}
45
6a4d98d7
JO
46int perf_data_file__open(struct perf_data_file *file);
47void perf_data_file__close(struct perf_data_file *file);
6f9a317f
JO
48ssize_t perf_data_file__write(struct perf_data_file *file,
49 void *buf, size_t size);
040f9915
WN
50/*
51 * If at_exit is set, only rename current perf.data to
52 * perf.data.<postfix>, continue write on original file.
53 * Set at_exit when flushing the last output.
54 *
55 * Return value is fd of new output.
56 */
57int perf_data_file__switch(struct perf_data_file *file,
58 const char *postfix,
59 size_t pos, bool at_exit);
f5fc1412 60#endif /* __PERF_DATA_H */