summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/util.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-03 19:50:55 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-03 19:50:55 +0100
commit1e7972cc5c16e06f258b0278d8c9adfb5aa75c68 (patch)
treeb73bbe4083bba9e345474fd17082d8a179f93157 /tools/perf/util/util.c
parentperf evsel: Adopt MATCH_EVENT macro from 'stat' (diff)
downloadlinux-1e7972cc5c16e06f258b0278d8c9adfb5aa75c68.tar.xz
linux-1e7972cc5c16e06f258b0278d8c9adfb5aa75c68.zip
perf util: Move do_read from session to util
Not really something to be exported from session.c. Rename it to 'readn' as others did in the past. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r--tools/perf/util/util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 214265674ddd..5b3ea49aa63e 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -114,3 +114,20 @@ unsigned long convert_unit(unsigned long value, char *unit)
return value;
}
+
+int readn(int fd, void *buf, size_t n)
+{
+ void *buf_start = buf;
+
+ while (n) {
+ int ret = read(fd, buf, n);
+
+ if (ret <= 0)
+ return ret;
+
+ n -= ret;
+ buf += ret;
+ }
+
+ return buf - buf_start;
+}