Skip to content

Commit 43cbcd8

Browse files
acmelIngo Molnar
authored andcommitted
perf_counter tools: Share rbtree.with the kernel
The tools/perf/util/rbtree.c copy already drifted by three csets: 4b32412 4c60117 16c047a So remove the copy and use the lib/rbtree.c directly, sharing the source code while still generating a separate object file, since tools/perf uses a far more agressive -O6 switch. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <20090701152837.GG15682@ghostprotocols.net> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 73c24cb commit 43cbcd8

12 files changed

Lines changed: 39 additions & 562 deletions

File tree

‎tools/perf/Makefile‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
223223
# Those must not be GNU-specific; they are shared with perl/ which may
224224
# be built by a different compiler. (Note that this is an artifact now
225225
# but it still might be nice to keep that distinction.)
226-
BASIC_CFLAGS =
226+
BASIC_CFLAGS = -Iutil/include
227227
BASIC_LDFLAGS =
228228

229229
# Guard against environment variables
@@ -289,10 +289,10 @@ export PERL_PATH
289289
LIB_FILE=libperf.a
290290

291291
LIB_H += ../../include/linux/perf_counter.h
292+
LIB_H += ../../include/linux/rbtree.h
292293
LIB_H += perf.h
293294
LIB_H += util/types.h
294295
LIB_H += util/list.h
295-
LIB_H += util/rbtree.h
296296
LIB_H += util/levenshtein.h
297297
LIB_H += util/parse-options.h
298298
LIB_H += util/parse-events.h
@@ -691,6 +691,9 @@ builtin-init-db.o: builtin-init-db.c PERF-CFLAGS
691691
util/config.o: util/config.c PERF-CFLAGS
692692
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
693693

694+
util/rbtree.o: ../../lib/rbtree.c PERF-CFLAGS
695+
$(QUIET_CC)$(CC) -o util/rbtree.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
696+
694697
perf-%$X: %.o $(PERFLIBS)
695698
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
696699

‎tools/perf/builtin-annotate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "util/color.h"
1313
#include "util/list.h"
1414
#include "util/cache.h"
15-
#include "util/rbtree.h"
15+
#include <linux/rbtree.h>
1616
#include "util/symbol.h"
1717
#include "util/string.h"
1818

‎tools/perf/builtin-report.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "util/color.h"
1313
#include "util/list.h"
1414
#include "util/cache.h"
15-
#include "util/rbtree.h"
15+
#include <linux/rbtree.h>
1616
#include "util/symbol.h"
1717
#include "util/string.h"
1818
#include "util/callchain.h"

‎tools/perf/builtin-top.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "util/symbol.h"
2424
#include "util/color.h"
2525
#include "util/util.h"
26-
#include "util/rbtree.h"
26+
#include <linux/rbtree.h>
2727
#include "util/parse-options.h"
2828
#include "util/parse-events.h"
2929

‎tools/perf/util/callchain.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "../perf.h"
55
#include "list.h"
6-
#include "rbtree.h"
6+
#include <linux/rbtree.h>
77
#include "symbol.h"
88

99

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef PERF_LINUX_KERNEL_H_
2+
#define PERF_LINUX_KERNEL_H_
3+
4+
#ifndef offsetof
5+
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
6+
#endif
7+
8+
#ifndef container_of
9+
/**
10+
* container_of - cast a member of a structure out to the containing structure
11+
* @ptr: the pointer to the member.
12+
* @type: the type of the container struct this is embedded in.
13+
* @member: the name of the member within the struct.
14+
*
15+
*/
16+
#define container_of(ptr, type, member) ({ \
17+
const typeof(((type *)0)->member) * __mptr = (ptr); \
18+
(type *)((char *)__mptr - offsetof(type, member)); })
19+
#endif
20+
21+
#endif
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef PERF_LINUX_MODULE_H
2+
#define PERF_LINUX_MODULE_H
3+
4+
#define EXPORT_SYMBOL(name)
5+
6+
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../../../../include/linux/rbtree.h"

0 commit comments

Comments
 (0)