diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-17 11:57:18 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-19 03:26:35 -0400 |
commit | db9f11e36d0125a5e3e595ea9ef2e4b89f7e8737 (patch) | |
tree | d0622b32432b06391a3f0ebece4d296a72bd0f3b /tools/perf/util/header.c | |
parent | 2ba0825075e76236d22a20decd8e2346a99faabe (diff) |
perf tools: Use DECLARE_BITMAP instead of an open-coded array
Use DECLARE_BITMAP instead of an open coded array for our bitmap
of featured sections.
This makes the array an unsigned long instead of a u64 but since
we use a 256 bits bitmap, the array size shouldn't vary between
different boxes.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1255795038-13751-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 171d51b6f359..622c60e45254 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -8,8 +8,6 @@ | |||
8 | #include "../perf.h" | 8 | #include "../perf.h" |
9 | #include "trace-event.h" | 9 | #include "trace-event.h" |
10 | 10 | ||
11 | #include <linux/bitmap.h> | ||
12 | |||
13 | /* | 11 | /* |
14 | * Create new perf.data header attribute: | 12 | * Create new perf.data header attribute: |
15 | */ | 13 | */ |
@@ -143,12 +141,12 @@ struct perf_file_header { | |||
143 | struct perf_file_section attrs; | 141 | struct perf_file_section attrs; |
144 | struct perf_file_section data; | 142 | struct perf_file_section data; |
145 | struct perf_file_section event_types; | 143 | struct perf_file_section event_types; |
146 | feat_mask_t adds_features; | 144 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); |
147 | }; | 145 | }; |
148 | 146 | ||
149 | void perf_header__feat_trace_info(struct perf_header *header) | 147 | void perf_header__feat_trace_info(struct perf_header *header) |
150 | { | 148 | { |
151 | set_bit(HEADER_TRACE_INFO, perf_header__adds_mask(header)); | 149 | set_bit(HEADER_TRACE_INFO, header->adds_features); |
152 | } | 150 | } |
153 | 151 | ||
154 | static void do_write(int fd, void *buf, size_t size) | 152 | static void do_write(int fd, void *buf, size_t size) |
@@ -168,7 +166,7 @@ static void perf_header__adds_write(struct perf_header *self, int fd) | |||
168 | { | 166 | { |
169 | struct perf_file_section trace_sec; | 167 | struct perf_file_section trace_sec; |
170 | u64 cur_offset = lseek(fd, 0, SEEK_CUR); | 168 | u64 cur_offset = lseek(fd, 0, SEEK_CUR); |
171 | unsigned long *feat_mask = perf_header__adds_mask(self); | 169 | unsigned long *feat_mask = self->adds_features; |
172 | 170 | ||
173 | if (test_bit(HEADER_TRACE_INFO, feat_mask)) { | 171 | if (test_bit(HEADER_TRACE_INFO, feat_mask)) { |
174 | /* Write trace info */ | 172 | /* Write trace info */ |
@@ -250,7 +248,7 @@ void perf_header__write(struct perf_header *self, int fd) | |||
250 | }, | 248 | }, |
251 | }; | 249 | }; |
252 | 250 | ||
253 | memcpy(&f_header.adds_features, &self->adds_features, sizeof(feat_mask_t)); | 251 | memcpy(&f_header.adds_features, &self->adds_features, sizeof(self->adds_features)); |
254 | 252 | ||
255 | lseek(fd, 0, SEEK_SET); | 253 | lseek(fd, 0, SEEK_SET); |
256 | do_write(fd, &f_header, sizeof(f_header)); | 254 | do_write(fd, &f_header, sizeof(f_header)); |
@@ -276,7 +274,7 @@ static void do_read(int fd, void *buf, size_t size) | |||
276 | 274 | ||
277 | static void perf_header__adds_read(struct perf_header *self, int fd) | 275 | static void perf_header__adds_read(struct perf_header *self, int fd) |
278 | { | 276 | { |
279 | const unsigned long *feat_mask = perf_header__adds_mask(self); | 277 | const unsigned long *feat_mask = self->adds_features; |
280 | 278 | ||
281 | if (test_bit(HEADER_TRACE_INFO, feat_mask)) { | 279 | if (test_bit(HEADER_TRACE_INFO, feat_mask)) { |
282 | struct perf_file_section trace_sec; | 280 | struct perf_file_section trace_sec; |
@@ -306,11 +304,9 @@ struct perf_header *perf_header__read(int fd) | |||
306 | 304 | ||
307 | if (f_header.size != sizeof(f_header)) { | 305 | if (f_header.size != sizeof(f_header)) { |
308 | /* Support the previous format */ | 306 | /* Support the previous format */ |
309 | if (f_header.size == offsetof(typeof(f_header), adds_features)) { | 307 | if (f_header.size == offsetof(typeof(f_header), adds_features)) |
310 | unsigned long *mask = (unsigned long *)(void *) | 308 | bitmap_zero(f_header.adds_features, HEADER_FEAT_BITS); |
311 | &f_header.adds_features; | 309 | else |
312 | bitmap_zero(mask, HEADER_FEAT_BITS); | ||
313 | } else | ||
314 | die("incompatible file format"); | 310 | die("incompatible file format"); |
315 | } | 311 | } |
316 | nr_attrs = f_header.attrs.size / sizeof(f_attr); | 312 | nr_attrs = f_header.attrs.size / sizeof(f_attr); |
@@ -346,7 +342,7 @@ struct perf_header *perf_header__read(int fd) | |||
346 | event_count = f_header.event_types.size / sizeof(struct perf_trace_event_type); | 342 | event_count = f_header.event_types.size / sizeof(struct perf_trace_event_type); |
347 | } | 343 | } |
348 | 344 | ||
349 | memcpy(&self->adds_features, &f_header.adds_features, sizeof(feat_mask_t)); | 345 | memcpy(&self->adds_features, &f_header.adds_features, sizeof(f_header.adds_features)); |
350 | 346 | ||
351 | perf_header__adds_read(self, fd); | 347 | perf_header__adds_read(self, fd); |
352 | 348 | ||