aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-01-04 13:19:28 -0500
committerIngo Molnar <mingo@elte.hu>2010-01-13 04:09:09 -0500
commitf92cb24c78a7c853435e46a20d1bd5c894378132 (patch)
tree0522276bb82ac541461604f244aaed0bea4d8ee1 /tools/perf/util/header.c
parent36a3e6461a0dac8e84b8c94877365324010c151b (diff)
perf tools: Create write_padded routine out of __dsos__write_buildid_table
Will be used by other options where padding is needed. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1262629169-22797-3-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 709e3252f049..942f7da8bf84 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -173,6 +173,20 @@ static int do_write(int fd, const void *buf, size_t size)
173 return 0; 173 return 0;
174} 174}
175 175
176#define NAME_ALIGN 64
177
178static int write_padded(int fd, const void *bf, size_t count,
179 size_t count_aligned)
180{
181 static const char zero_buf[NAME_ALIGN];
182 int err = do_write(fd, bf, count);
183
184 if (!err)
185 err = do_write(fd, zero_buf, count_aligned - count);
186
187 return err;
188}
189
176#define dsos__for_each_with_build_id(pos, head) \ 190#define dsos__for_each_with_build_id(pos, head) \
177 list_for_each_entry(pos, head, node) \ 191 list_for_each_entry(pos, head, node) \
178 if (!pos->has_build_id) \ 192 if (!pos->has_build_id) \
@@ -181,9 +195,7 @@ static int do_write(int fd, const void *buf, size_t size)
181 195
182static int __dsos__write_buildid_table(struct list_head *head, int fd) 196static int __dsos__write_buildid_table(struct list_head *head, int fd)
183{ 197{
184#define NAME_ALIGN 64
185 struct dso *pos; 198 struct dso *pos;
186 static const char zero_buf[NAME_ALIGN];
187 199
188 dsos__for_each_with_build_id(pos, head) { 200 dsos__for_each_with_build_id(pos, head) {
189 int err; 201 int err;
@@ -197,10 +209,8 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd)
197 err = do_write(fd, &b, sizeof(b)); 209 err = do_write(fd, &b, sizeof(b));
198 if (err < 0) 210 if (err < 0)
199 return err; 211 return err;
200 err = do_write(fd, pos->long_name, pos->long_name_len + 1); 212 err = write_padded(fd, pos->long_name,
201 if (err < 0) 213 pos->long_name_len + 1, len);
202 return err;
203 err = do_write(fd, zero_buf, len - pos->long_name_len - 1);
204 if (err < 0) 214 if (err < 0)
205 return err; 215 return err;
206 } 216 }