perf_counter tools: Share rbtree.[ch] with the kernel
PATCH 1/1 perf_counter tools: Share rbtree.[ch] with the kernel
The tools/perf/util/rbtree.c copy already drifted by three csets:
4b324126e0c6c3a5080ca3ec0981e8766ed6f1ee4c60117811171d867d4f27f17ea07d7419d45dae16c047add3ceaf0ab882e3e094d1ec904d02312d
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.
--- tools/perf/Makefile | 7 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/util/callchain.h | 2 +- tools/perf/util/include/linux/kernel.h | 21 ++ tools/perf/util/include/linux/module.h | 6 + tools/perf/util/include/linux/rbtree.h | 1 + tools/perf/util/rbtree.c | 383 -------------------------------- tools/perf/util/rbtree.h | 171 -------------- tools/perf/util/strlist.h | 2 +- tools/perf/util/symbol.h | 2 +- 12 files changed, 39 insertions(+), 562 deletions(-) create mode 100644 tools/perf/util/include/linux/kernel.h create mode 100644 tools/perf/util/include/linux/module.h create mode 100644 tools/perf/util/include/linux/rbtree.h delete mode 100644 tools/perf/util/rbtree.c delete mode 100644 tools/perf/util/rbtree.h
tools/perf/Makefile +5 -2
@@ -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
@@ -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
@@ -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)
tools/perf/builtin-annotate.c +1 -1
@@ -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"
tools/perf/builtin-report.c +1 -1
@@ -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"
tools/perf/builtin-top.c +1 -1
@@ -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"
tools/perf/util/callchain.h +1 -1
@@ -3,7 +3,7 @@#include "../perf.h" #include "list.h" -#include "rbtree.h" +#include <linux/rbtree.h> #include "symbol.h"
tools/perf/util/include/linux/kernel.h new file +21 -0
@@ -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
tools/perf/util/include/linux/module.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef PERF_LINUX_MODULE_H +#define PERF_LINUX_MODULE_H + +#define EXPORT_SYMBOL (name) + +#endif
tools/perf/util/include/linux/rbtree.h new file +1 -0
@@ -0,0 +1 @@ +#include "../../../../include/linux/rbtree.h"
tools/perf/util/rbtree.c deleted +0 -383
383 lines not on this page · raw message
tools/perf/util/rbtree.h deleted +0 -171
171 lines not on this page · raw message
tools/perf/util/strlist.h +1 -1
@@ -1,7 +1,7 @@#ifndef STRLIST_H_ #define STRLIST_H_ -#include "rbtree.h" +#include <linux/rbtree.h> #include <stdbool.h> struct str_node {
tools/perf/util/symbol.h +1 -1
@@ -4,7 +4,7 @@#include <linux/types.h> #include "types.h" #include "list.h" -#include "rbtree.h" +#include <linux/rbtree.h> struct symbol {struct rb_node rb_node;
Signature · 1 line
1.6.2.5
[tip:perfcounters/urgent] perf_counter tools: Share rbtree.with the kernel
Commit-ID: 43cbcd8acb4c992cbd22d1ec8a08c0591be5d719 Gitweb: http://git.kernel.org/tip/43cbcd8acb4c992cbd22d1ec8a08c0591be5d719 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 1 Jul 2009 12:28:37 -0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 1 Jul 2009 22:37:22 +0200
perf_counter tools: Share rbtree.with the kernel
The tools/perf/util/rbtree.c copy already drifted by three csets:
4b324126e0c6c3a5080ca3ec0981e8766ed6f1ee
4c60117811171d867d4f27f17ea07d7419d45dae
16c047add3ceaf0ab882e3e094d1ec904d02312d
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.
LKML-Reference: <[email protected]>
--- tools/perf/Makefile | 7 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/util/callchain.h | 2 +- tools/perf/util/include/linux/kernel.h | 21 ++ tools/perf/util/include/linux/module.h | 6 + tools/perf/util/include/linux/rbtree.h | 1 + tools/perf/util/rbtree.c | 383 -------------------------------- tools/perf/util/rbtree.h | 171 -------------- tools/perf/util/strlist.h | 2 +- tools/perf/util/symbol.h | 2 +- 12 files changed, 39 insertions(+), 562 deletions(-)
tools/perf/Makefile +5 -2
@@ -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
@@ -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
@@ -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)
tools/perf/builtin-annotate.c +1 -1
@@ -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"
tools/perf/builtin-report.c +1 -1
@@ -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"
tools/perf/builtin-top.c +1 -1
@@ -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"
tools/perf/util/callchain.h +1 -1
@@ -3,7 +3,7 @@#include "../perf.h" #include "list.h" -#include "rbtree.h" +#include <linux/rbtree.h> #include "symbol.h"
tools/perf/util/include/linux/kernel.h new file +21 -0
@@ -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
tools/perf/util/include/linux/module.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef PERF_LINUX_MODULE_H +#define PERF_LINUX_MODULE_H + +#define EXPORT_SYMBOL (name) + +#endif
tools/perf/util/include/linux/rbtree.h new file +1 -0
@@ -0,0 +1 @@ +#include "../../../../include/linux/rbtree.h"
tools/perf/util/rbtree.c deleted +0 -383
383 lines not on this page · raw message
tools/perf/util/rbtree.h deleted +0 -171
171 lines not on this page · raw message
tools/perf/util/strlist.h +1 -1
@@ -1,7 +1,7 @@#ifndef STRLIST_H_ #define STRLIST_H_ -#include "rbtree.h" +#include <linux/rbtree.h> #include <stdbool.h> struct str_node {
tools/perf/util/symbol.h +1 -1
@@ -4,7 +4,7 @@#include <linux/types.h> #include "types.h" #include "list.h" -#include "rbtree.h" +#include <linux/rbtree.h> struct symbol {struct rb_node rb_node;