aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorIrina Tirdea <irina.tirdea@gmail.com>2012-09-10 18:15:01 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-09-11 10:48:30 -0400
commit9ac3e487f0eeef0fa058d72da7681398cc052ee9 (patch)
tree1a6bb20a22c574e759e336db8a71029475d93eb9 /tools/perf
parent3f34f6c0233ae055b592e8f8da23d873b82070bb (diff)
perf tools: fix ALIGN redefinition in system headers
On some systems (e.g. Android), ALIGN is defined in system headers as ALIGN(p). The definition of ALIGN used in perf takes 2 parameters: ALIGN(x,a). This leads to redefinition conflicts. Redefinition error on Android: In file included from util/include/linux/list.h:1:0, from util/callchain.h:5, from util/hist.h:6, from util/session.h:4, from util/build-id.h:4, from util/annotate.c:11: util/include/linux/kernel.h:11:0: error: "ALIGN" redefined [-Werror] bionic/libc/include/sys/param.h:38:0: note: this is the location of the previous definition Conflics with system defined ALIGN in Android: util/event.c: In function 'perf_event__synthesize_comm': util/event.c:115:32: error: macro "ALIGN" passed 2 arguments, but takes just 1 util/event.c:115:9: error: 'ALIGN' undeclared (first use in this function) util/event.c:115:9: note: each undeclared identifier is reported only once for each function it appears in In order to avoid this redefinition, ALIGN is renamed to PERF_ALIGN. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Acked-by: Pekka Enberg <penberg@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Irina Tirdea <irina.tirdea@intel.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/1347315303-29906-5-git-send-email-irina.tirdea@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/event.c10
-rw-r--r--tools/perf/util/event.h2
-rw-r--r--tools/perf/util/header.c16
-rw-r--r--tools/perf/util/include/linux/kernel.h4
-rw-r--r--tools/perf/util/session.c4
-rw-r--r--tools/perf/util/symbol.c2
6 files changed, 19 insertions, 19 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 84ff6f160cd0..f7f480503af4 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -112,7 +112,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
112 event->comm.header.type = PERF_RECORD_COMM; 112 event->comm.header.type = PERF_RECORD_COMM;
113 113
114 size = strlen(event->comm.comm) + 1; 114 size = strlen(event->comm.comm) + 1;
115 size = ALIGN(size, sizeof(u64)); 115 size = PERF_ALIGN(size, sizeof(u64));
116 memset(event->comm.comm + size, 0, machine->id_hdr_size); 116 memset(event->comm.comm + size, 0, machine->id_hdr_size);
117 event->comm.header.size = (sizeof(event->comm) - 117 event->comm.header.size = (sizeof(event->comm) -
118 (sizeof(event->comm.comm) - size) + 118 (sizeof(event->comm.comm) - size) +
@@ -145,7 +145,7 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
145 sizeof(event->comm.comm)); 145 sizeof(event->comm.comm));
146 146
147 size = strlen(event->comm.comm) + 1; 147 size = strlen(event->comm.comm) + 1;
148 size = ALIGN(size, sizeof(u64)); 148 size = PERF_ALIGN(size, sizeof(u64));
149 memset(event->comm.comm + size, 0, machine->id_hdr_size); 149 memset(event->comm.comm + size, 0, machine->id_hdr_size);
150 event->comm.header.size = (sizeof(event->comm) - 150 event->comm.header.size = (sizeof(event->comm) -
151 (sizeof(event->comm.comm) - size) + 151 (sizeof(event->comm.comm) - size) +
@@ -228,7 +228,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
228 size = strlen(execname); 228 size = strlen(execname);
229 execname[size - 1] = '\0'; /* Remove \n */ 229 execname[size - 1] = '\0'; /* Remove \n */
230 memcpy(event->mmap.filename, execname, size); 230 memcpy(event->mmap.filename, execname, size);
231 size = ALIGN(size, sizeof(u64)); 231 size = PERF_ALIGN(size, sizeof(u64));
232 event->mmap.len -= event->mmap.start; 232 event->mmap.len -= event->mmap.start;
233 event->mmap.header.size = (sizeof(event->mmap) - 233 event->mmap.header.size = (sizeof(event->mmap) -
234 (sizeof(event->mmap.filename) - size)); 234 (sizeof(event->mmap.filename) - size));
@@ -282,7 +282,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool,
282 if (pos->dso->kernel) 282 if (pos->dso->kernel)
283 continue; 283 continue;
284 284
285 size = ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); 285 size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64));
286 event->mmap.header.type = PERF_RECORD_MMAP; 286 event->mmap.header.type = PERF_RECORD_MMAP;
287 event->mmap.header.size = (sizeof(event->mmap) - 287 event->mmap.header.size = (sizeof(event->mmap) -
288 (sizeof(event->mmap.filename) - size)); 288 (sizeof(event->mmap.filename) - size));
@@ -494,7 +494,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
494 map = machine->vmlinux_maps[MAP__FUNCTION]; 494 map = machine->vmlinux_maps[MAP__FUNCTION];
495 size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), 495 size = snprintf(event->mmap.filename, sizeof(event->mmap.filename),
496 "%s%s", mmap_name, symbol_name) + 1; 496 "%s%s", mmap_name, symbol_name) + 1;
497 size = ALIGN(size, sizeof(u64)); 497 size = PERF_ALIGN(size, sizeof(u64));
498 event->mmap.header.type = PERF_RECORD_MMAP; 498 event->mmap.header.type = PERF_RECORD_MMAP;
499 event->mmap.header.size = (sizeof(event->mmap) - 499 event->mmap.header.size = (sizeof(event->mmap) -
500 (sizeof(event->mmap.filename) - size) + machine->id_hdr_size); 500 (sizeof(event->mmap.filename) - size) + machine->id_hdr_size);
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 0e088d046e56..21b99e741a87 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -101,7 +101,7 @@ struct perf_sample {
101struct build_id_event { 101struct build_id_event {
102 struct perf_event_header header; 102 struct perf_event_header header;
103 pid_t pid; 103 pid_t pid;
104 u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))]; 104 u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))];
105 char filename[]; 105 char filename[];
106}; 106};
107 107
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index d07bc134e562..974e7589a6b5 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -129,7 +129,7 @@ static int do_write_string(int fd, const char *str)
129 int ret; 129 int ret;
130 130
131 olen = strlen(str) + 1; 131 olen = strlen(str) + 1;
132 len = ALIGN(olen, NAME_ALIGN); 132 len = PERF_ALIGN(olen, NAME_ALIGN);
133 133
134 /* write len, incl. \0 */ 134 /* write len, incl. \0 */
135 ret = do_write(fd, &len, sizeof(len)); 135 ret = do_write(fd, &len, sizeof(len));
@@ -220,7 +220,7 @@ static int __dsos__write_buildid_table(struct list_head *head, pid_t pid,
220 if (!pos->hit) 220 if (!pos->hit)
221 continue; 221 continue;
222 len = pos->long_name_len + 1; 222 len = pos->long_name_len + 1;
223 len = ALIGN(len, NAME_ALIGN); 223 len = PERF_ALIGN(len, NAME_ALIGN);
224 memset(&b, 0, sizeof(b)); 224 memset(&b, 0, sizeof(b));
225 memcpy(&b.build_id, pos->build_id, sizeof(pos->build_id)); 225 memcpy(&b.build_id, pos->build_id, sizeof(pos->build_id));
226 b.pid = pid; 226 b.pid = pid;
@@ -1532,7 +1532,7 @@ static int perf_header__read_build_ids_abi_quirk(struct perf_header *header,
1532 struct perf_session *session = container_of(header, struct perf_session, header); 1532 struct perf_session *session = container_of(header, struct perf_session, header);
1533 struct { 1533 struct {
1534 struct perf_event_header header; 1534 struct perf_event_header header;
1535 u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))]; 1535 u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))];
1536 char filename[0]; 1536 char filename[0];
1537 } old_bev; 1537 } old_bev;
1538 struct build_id_event bev; 1538 struct build_id_event bev;
@@ -2439,7 +2439,7 @@ int perf_event__synthesize_attr(struct perf_tool *tool,
2439 int err; 2439 int err;
2440 2440
2441 size = sizeof(struct perf_event_attr); 2441 size = sizeof(struct perf_event_attr);
2442 size = ALIGN(size, sizeof(u64)); 2442 size = PERF_ALIGN(size, sizeof(u64));
2443 size += sizeof(struct perf_event_header); 2443 size += sizeof(struct perf_event_header);
2444 size += ids * sizeof(u64); 2444 size += ids * sizeof(u64);
2445 2445
@@ -2537,7 +2537,7 @@ int perf_event__synthesize_event_type(struct perf_tool *tool,
2537 2537
2538 ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE; 2538 ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE;
2539 size = strlen(ev.event_type.event_type.name); 2539 size = strlen(ev.event_type.event_type.name);
2540 size = ALIGN(size, sizeof(u64)); 2540 size = PERF_ALIGN(size, sizeof(u64));
2541 ev.event_type.header.size = sizeof(ev.event_type) - 2541 ev.event_type.header.size = sizeof(ev.event_type) -
2542 (sizeof(ev.event_type.event_type.name) - size); 2542 (sizeof(ev.event_type.event_type.name) - size);
2543 2543
@@ -2606,7 +2606,7 @@ int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd,
2606 2606
2607 ev.tracing_data.header.type = PERF_RECORD_HEADER_TRACING_DATA; 2607 ev.tracing_data.header.type = PERF_RECORD_HEADER_TRACING_DATA;
2608 size = tdata->size; 2608 size = tdata->size;
2609 aligned_size = ALIGN(size, sizeof(u64)); 2609 aligned_size = PERF_ALIGN(size, sizeof(u64));
2610 padding = aligned_size - size; 2610 padding = aligned_size - size;
2611 ev.tracing_data.header.size = sizeof(ev.tracing_data); 2611 ev.tracing_data.header.size = sizeof(ev.tracing_data);
2612 ev.tracing_data.size = aligned_size; 2612 ev.tracing_data.size = aligned_size;
@@ -2637,7 +2637,7 @@ int perf_event__process_tracing_data(union perf_event *event,
2637 2637
2638 size_read = trace_report(session->fd, &session->pevent, 2638 size_read = trace_report(session->fd, &session->pevent,
2639 session->repipe); 2639 session->repipe);
2640 padding = ALIGN(size_read, sizeof(u64)) - size_read; 2640 padding = PERF_ALIGN(size_read, sizeof(u64)) - size_read;
2641 2641
2642 if (read(session->fd, buf, padding) < 0) 2642 if (read(session->fd, buf, padding) < 0)
2643 die("reading input file"); 2643 die("reading input file");
@@ -2671,7 +2671,7 @@ int perf_event__synthesize_build_id(struct perf_tool *tool,
2671 memset(&ev, 0, sizeof(ev)); 2671 memset(&ev, 0, sizeof(ev));
2672 2672
2673 len = pos->long_name_len + 1; 2673 len = pos->long_name_len + 1;
2674 len = ALIGN(len, NAME_ALIGN); 2674 len = PERF_ALIGN(len, NAME_ALIGN);
2675 memcpy(&ev.build_id.build_id, pos->build_id, sizeof(pos->build_id)); 2675 memcpy(&ev.build_id.build_id, pos->build_id, sizeof(pos->build_id));
2676 ev.build_id.header.type = PERF_RECORD_HEADER_BUILD_ID; 2676 ev.build_id.header.type = PERF_RECORD_HEADER_BUILD_ID;
2677 ev.build_id.header.misc = misc; 2677 ev.build_id.header.misc = misc;
diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h
index a978f269d8d2..d8c927c868ee 100644
--- a/tools/perf/util/include/linux/kernel.h
+++ b/tools/perf/util/include/linux/kernel.h
@@ -8,8 +8,8 @@
8 8
9#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 9#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
10 10
11#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) 11#define PERF_ALIGN(x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
12#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) 12#define __PERF_ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
13 13
14#ifndef offsetof 14#ifndef offsetof
15#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 15#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 945375897c2a..3806ea49f1f7 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -527,7 +527,7 @@ static void perf_event__comm_swap(union perf_event *event, bool sample_id_all)
527 if (sample_id_all) { 527 if (sample_id_all) {
528 void *data = &event->comm.comm; 528 void *data = &event->comm.comm;
529 529
530 data += ALIGN(strlen(data) + 1, sizeof(u64)); 530 data += PERF_ALIGN(strlen(data) + 1, sizeof(u64));
531 swap_sample_id_all(event, data); 531 swap_sample_id_all(event, data);
532 } 532 }
533} 533}
@@ -544,7 +544,7 @@ static void perf_event__mmap_swap(union perf_event *event,
544 if (sample_id_all) { 544 if (sample_id_all) {
545 void *data = &event->mmap.filename; 545 void *data = &event->mmap.filename;
546 546
547 data += ALIGN(strlen(data) + 1, sizeof(u64)); 547 data += PERF_ALIGN(strlen(data) + 1, sizeof(u64));
548 swap_sample_id_all(event, data); 548 swap_sample_id_all(event, data);
549 } 549 }
550} 550}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 753699a20bc8..ba85d4ffef06 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1991,7 +1991,7 @@ int symbol__init(void)
1991 if (symbol_conf.initialized) 1991 if (symbol_conf.initialized)
1992 return 0; 1992 return 0;
1993 1993
1994 symbol_conf.priv_size = ALIGN(symbol_conf.priv_size, sizeof(u64)); 1994 symbol_conf.priv_size = PERF_ALIGN(symbol_conf.priv_size, sizeof(u64));
1995 1995
1996 symbol__elf_init(); 1996 symbol__elf_init();
1997 1997