diff options
author | Jiri Olsa <jolsa@redhat.com> | 2013-11-28 05:30:17 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-02 07:22:46 -0500 |
commit | 6f9a317f2a2d4950880ecfa7eea53ed79f85255f (patch) | |
tree | b28279beffaf2239ce60111c0b4344bc15ee7ac4 | |
parent | bc3a502bc2bc78d03526d6abcc5697aab18d5ae9 (diff) |
perf tools: Add perf_data_file__write interface
Adding perf_data_file__write interface to centralize output to files.
The function prototype is:
ssize_t perf_data_file__write(struct perf_data_file *file,
void *buf, size_t size);
Returns number of bytes written or -1 in case of error.
NOTE: Also indenting 'struct perf_data_file' members, no functional
change done.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1385634619-8129-6-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/data.c | 6 | ||||
-rw-r--r-- | tools/perf/util/data.h | 14 |
2 files changed, 14 insertions, 6 deletions
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 7d09faf85cf1..1fbcd8bdc11b 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c | |||
@@ -118,3 +118,9 @@ void perf_data_file__close(struct perf_data_file *file) | |||
118 | { | 118 | { |
119 | close(file->fd); | 119 | close(file->fd); |
120 | } | 120 | } |
121 | |||
122 | ssize_t perf_data_file__write(struct perf_data_file *file, | ||
123 | void *buf, size_t size) | ||
124 | { | ||
125 | return writen(file->fd, buf, size); | ||
126 | } | ||
diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h index 8c2df80152a5..2b15d0c95c7f 100644 --- a/tools/perf/util/data.h +++ b/tools/perf/util/data.h | |||
@@ -9,12 +9,12 @@ enum perf_data_mode { | |||
9 | }; | 9 | }; |
10 | 10 | ||
11 | struct perf_data_file { | 11 | struct perf_data_file { |
12 | const char *path; | 12 | const char *path; |
13 | int fd; | 13 | int fd; |
14 | bool is_pipe; | 14 | bool is_pipe; |
15 | bool force; | 15 | bool force; |
16 | unsigned long size; | 16 | unsigned long size; |
17 | enum perf_data_mode mode; | 17 | enum perf_data_mode mode; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | static inline bool perf_data_file__is_read(struct perf_data_file *file) | 20 | static inline bool perf_data_file__is_read(struct perf_data_file *file) |
@@ -44,5 +44,7 @@ static inline unsigned long perf_data_file__size(struct perf_data_file *file) | |||
44 | 44 | ||
45 | int perf_data_file__open(struct perf_data_file *file); | 45 | int perf_data_file__open(struct perf_data_file *file); |
46 | void perf_data_file__close(struct perf_data_file *file); | 46 | void perf_data_file__close(struct perf_data_file *file); |
47 | ssize_t perf_data_file__write(struct perf_data_file *file, | ||
48 | void *buf, size_t size); | ||
47 | 49 | ||
48 | #endif /* __PERF_DATA_H */ | 50 | #endif /* __PERF_DATA_H */ |