#include "../perf.h"
#include "trace-event.h"
-#include <linux/bitmap.h>
-
/*
* Create new perf.data header attribute:
*/
struct perf_file_section attrs;
struct perf_file_section data;
struct perf_file_section event_types;
- feat_mask_t adds_features;
+ DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
};
void perf_header__feat_trace_info(struct perf_header *header)
{
- set_bit(HEADER_TRACE_INFO, perf_header__adds_mask(header));
+ set_bit(HEADER_TRACE_INFO, header->adds_features);
}
static void do_write(int fd, void *buf, size_t size)
{
struct perf_file_section trace_sec;
u64 cur_offset = lseek(fd, 0, SEEK_CUR);
- unsigned long *feat_mask = perf_header__adds_mask(self);
+ unsigned long *feat_mask = self->adds_features;
if (test_bit(HEADER_TRACE_INFO, feat_mask)) {
/* Write trace info */
},
};
- memcpy(&f_header.adds_features, &self->adds_features, sizeof(feat_mask_t));
+ memcpy(&f_header.adds_features, &self->adds_features, sizeof(self->adds_features));
lseek(fd, 0, SEEK_SET);
do_write(fd, &f_header, sizeof(f_header));
static void perf_header__adds_read(struct perf_header *self, int fd)
{
- const unsigned long *feat_mask = perf_header__adds_mask(self);
+ const unsigned long *feat_mask = self->adds_features;
if (test_bit(HEADER_TRACE_INFO, feat_mask)) {
struct perf_file_section trace_sec;
if (f_header.size != sizeof(f_header)) {
/* Support the previous format */
- if (f_header.size == offsetof(typeof(f_header), adds_features)) {
- unsigned long *mask = (unsigned long *)(void *)
- &f_header.adds_features;
- bitmap_zero(mask, HEADER_FEAT_BITS);
- } else
+ if (f_header.size == offsetof(typeof(f_header), adds_features))
+ bitmap_zero(f_header.adds_features, HEADER_FEAT_BITS);
+ else
die("incompatible file format");
}
nr_attrs = f_header.attrs.size / sizeof(f_attr);
event_count = f_header.event_types.size / sizeof(struct perf_trace_event_type);
}
- memcpy(&self->adds_features, &f_header.adds_features, sizeof(feat_mask_t));
+ memcpy(&self->adds_features, &f_header.adds_features, sizeof(f_header.adds_features));
perf_header__adds_read(self, fd);
#include <sys/types.h>
#include "types.h"
+#include <linux/bitmap.h>
+
struct perf_header_attr {
struct perf_event_attr attr;
int ids, size;
#define HEADER_FEAT_BITS 256
-typedef typeof(u64[HEADER_FEAT_BITS / 8]) feat_mask_t;
-
struct perf_header {
int frozen;
int attrs, size;
u64 data_size;
u64 event_offset;
u64 event_size;
- feat_mask_t adds_features;
+ DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
};
-static inline unsigned long *perf_header__adds_mask(struct perf_header *self)
-{
- return (unsigned long *)(void *)&self->adds_features;
-}
-
struct perf_header *perf_header__read(int fd);
void perf_header__write(struct perf_header *self, int fd);