Skip to content

Commit

Permalink
perf_counter tools: Share rbtree.with the kernel
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Jul 1, 2009
1 parent 73c24cb commit 43cbcd8
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 562 deletions.
7 changes: 5 additions & 2 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
# Those must not be GNU-specific; they are shared with perl/ which may
# be built by a different compiler. (Note that this is an artifact now
# but it still might be nice to keep that distinction.)
BASIC_CFLAGS =
BASIC_CFLAGS = -Iutil/include
BASIC_LDFLAGS =

# Guard against environment variables
Expand Down Expand Up @@ -289,10 +289,10 @@ export PERL_PATH
LIB_FILE=libperf.a

LIB_H += ../../include/linux/perf_counter.h
LIB_H += ../../include/linux/rbtree.h
LIB_H += perf.h
LIB_H += util/types.h
LIB_H += util/list.h
LIB_H += util/rbtree.h
LIB_H += util/levenshtein.h
LIB_H += util/parse-options.h
LIB_H += util/parse-events.h
Expand Down Expand Up @@ -691,6 +691,9 @@ builtin-init-db.o: builtin-init-db.c PERF-CFLAGS
util/config.o: util/config.c PERF-CFLAGS
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<

util/rbtree.o: ../../lib/rbtree.c PERF-CFLAGS
$(QUIET_CC)$(CC) -o util/rbtree.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<

perf-%$X: %.o $(PERFLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "util/color.h"
#include "util/list.h"
#include "util/cache.h"
#include "util/rbtree.h"
#include <linux/rbtree.h>
#include "util/symbol.h"
#include "util/string.h"

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "util/color.h"
#include "util/list.h"
#include "util/cache.h"
#include "util/rbtree.h"
#include <linux/rbtree.h>
#include "util/symbol.h"
#include "util/string.h"
#include "util/callchain.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "util/symbol.h"
#include "util/color.h"
#include "util/util.h"
#include "util/rbtree.h"
#include <linux/rbtree.h>
#include "util/parse-options.h"
#include "util/parse-events.h"

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/callchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "../perf.h"
#include "list.h"
#include "rbtree.h"
#include <linux/rbtree.h>
#include "symbol.h"


Expand Down
21 changes: 21 additions & 0 deletions tools/perf/util/include/linux/kernel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef PERF_LINUX_KERNEL_H_
#define PERF_LINUX_KERNEL_H_

#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif

#ifndef container_of
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ \
const typeof(((type *)0)->member) * __mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); })
#endif

#endif
6 changes: 6 additions & 0 deletions tools/perf/util/include/linux/module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef PERF_LINUX_MODULE_H
#define PERF_LINUX_MODULE_H

#define EXPORT_SYMBOL(name)

#endif
1 change: 1 addition & 0 deletions tools/perf/util/include/linux/rbtree.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../../../../include/linux/rbtree.h"
Loading

0 comments on commit 43cbcd8

Please sign in to comment.