Commit f92cb24c authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar

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: default avatarArnaldo 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: default avatarIngo Molnar <mingo@elte.hu>
parent 36a3e646
...@@ -173,6 +173,20 @@ static int do_write(int fd, const void *buf, size_t size) ...@@ -173,6 +173,20 @@ static int do_write(int fd, const void *buf, size_t size)
return 0; return 0;
} }
#define NAME_ALIGN 64
static int write_padded(int fd, const void *bf, size_t count,
size_t count_aligned)
{
static const char zero_buf[NAME_ALIGN];
int err = do_write(fd, bf, count);
if (!err)
err = do_write(fd, zero_buf, count_aligned - count);
return err;
}
#define dsos__for_each_with_build_id(pos, head) \ #define dsos__for_each_with_build_id(pos, head) \
list_for_each_entry(pos, head, node) \ list_for_each_entry(pos, head, node) \
if (!pos->has_build_id) \ if (!pos->has_build_id) \
...@@ -181,9 +195,7 @@ static int do_write(int fd, const void *buf, size_t size) ...@@ -181,9 +195,7 @@ static int do_write(int fd, const void *buf, size_t size)
static int __dsos__write_buildid_table(struct list_head *head, int fd) static int __dsos__write_buildid_table(struct list_head *head, int fd)
{ {
#define NAME_ALIGN 64
struct dso *pos; struct dso *pos;
static const char zero_buf[NAME_ALIGN];
dsos__for_each_with_build_id(pos, head) { dsos__for_each_with_build_id(pos, head) {
int err; int err;
...@@ -197,10 +209,8 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd) ...@@ -197,10 +209,8 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd)
err = do_write(fd, &b, sizeof(b)); err = do_write(fd, &b, sizeof(b));
if (err < 0) if (err < 0)
return err; return err;
err = do_write(fd, pos->long_name, pos->long_name_len + 1); err = write_padded(fd, pos->long_name,
if (err < 0) pos->long_name_len + 1, len);
return err;
err = do_write(fd, zero_buf, len - pos->long_name_len - 1);
if (err < 0) if (err < 0)
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment