aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/header.c22
-rw-r--r--tools/perf/util/header.h11
-rw-r--r--tools/perf/util/include/asm/asm-offsets.h1
-rw-r--r--tools/perf/util/include/linux/types.h8
4 files changed, 20 insertions, 22 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
149void perf_header__feat_trace_info(struct perf_header *header) 147void 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
154static void do_write(int fd, void *buf, size_t size) 152static 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
277static void perf_header__adds_read(struct perf_header *self, int fd) 275static 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
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 0eb4a9126b7c..2ea9dfb1236a 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -5,6 +5,8 @@
5#include <sys/types.h> 5#include <sys/types.h>
6#include "types.h" 6#include "types.h"
7 7
8#include <linux/bitmap.h>
9
8struct perf_header_attr { 10struct perf_header_attr {
9 struct perf_event_attr attr; 11 struct perf_event_attr attr;
10 int ids, size; 12 int ids, size;
@@ -16,8 +18,6 @@ struct perf_header_attr {
16 18
17#define HEADER_FEAT_BITS 256 19#define HEADER_FEAT_BITS 256
18 20
19typedef typeof(u64[HEADER_FEAT_BITS / 8]) feat_mask_t;
20
21struct perf_header { 21struct perf_header {
22 int frozen; 22 int frozen;
23 int attrs, size; 23 int attrs, size;
@@ -27,14 +27,9 @@ struct perf_header {
27 u64 data_size; 27 u64 data_size;
28 u64 event_offset; 28 u64 event_offset;
29 u64 event_size; 29 u64 event_size;
30 feat_mask_t adds_features; 30 DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
31}; 31};
32 32
33static inline unsigned long *perf_header__adds_mask(struct perf_header *self)
34{
35 return (unsigned long *)(void *)&self->adds_features;
36}
37
38struct perf_header *perf_header__read(int fd); 33struct perf_header *perf_header__read(int fd);
39void perf_header__write(struct perf_header *self, int fd); 34void perf_header__write(struct perf_header *self, int fd);
40 35
diff --git a/tools/perf/util/include/asm/asm-offsets.h b/tools/perf/util/include/asm/asm-offsets.h
new file mode 100644
index 000000000000..ed538942523d
--- /dev/null
+++ b/tools/perf/util/include/asm/asm-offsets.h
@@ -0,0 +1 @@
/* stub */
diff --git a/tools/perf/util/include/linux/types.h b/tools/perf/util/include/linux/types.h
index ed538942523d..858a38d08435 100644
--- a/tools/perf/util/include/linux/types.h
+++ b/tools/perf/util/include/linux/types.h
@@ -1 +1,7 @@
1/* stub */ 1#ifndef _PERF_LINUX_TYPES_H_
2#define _PERF_LINUX_TYPES_H_
3
4#define DECLARE_BITMAP(name,bits) \
5 unsigned long name[BITS_TO_LONGS(bits)]
6
7#endif