static int perf_tracepoint_open(struct gpu_perf *gp,
const char *sys, const char *name,
- int (*func)(struct gpu_perf *, void *))
+ int (*func)(struct gpu_perf *, const void *))
{
struct perf_event_attr attr;
struct gpu_perf_sample *sample;
return EINVAL;
}
-static int seqno_start(struct gpu_perf *gp, void *event)
+static int seqno_start(struct gpu_perf *gp, const void *event)
{
return 0;
}
-static int seqno_end(struct gpu_perf *gp, void *event)
+static int seqno_end(struct gpu_perf *gp, const void *event)
{
return 0;
}
-static int flip_complete(struct gpu_perf *gp, void *event)
+static int flip_complete(struct gpu_perf *gp, const void *event)
{
gp->flip_complete++;
return 1;
}
static int process_sample(struct gpu_perf *gp,
- struct perf_event_header *header)
+ const struct perf_event_header *header)
{
- struct sample_event *sample = (struct sample_event *)header;
+ const struct sample_event *sample = (const struct sample_event *)header;
int n, update = 0;
/* hash me! */
for (n = 0; n < gp->nr_cpus; n++) {
struct perf_event_mmap_page *mmap = gp->map[n];
- uint8_t *data;
+ const uint8_t *data;
uint64_t head, tail;
tail = mmap->data_tail;
data = (uint8_t *)mmap + gp->page_size;
while (head - tail >= sizeof (struct perf_event_header)) {
- struct perf_event_header *header;
+ const struct perf_event_header *header;
- header = (struct perf_event_header *)(data + (tail & mask));
+ header = (const struct perf_event_header *)(data + (tail & mask));
if (header->size > head - tail)
break;
- if (data + (tail & mask) + header->size > data + size) {
- int before, after;
+ if ((const uint8_t *)header + header->size > data + size) {
+ int before;
if (header->size > buffer_size) {
uint8_t *b = realloc(buffer, header->size);
buffer_size = header->size;
}
- after = (tail & mask) + header->size - size;
- before = header->size - after;
+ before = data + size - (const uint8_t *)header;
- memcpy(buffer, data + (tail & mask), before);
- memcpy(buffer + before, data, after);
+ memcpy(buffer, header, before);
+ memcpy(buffer + before, data, header->size - before);
header = (struct perf_event_header *)buffer;
}