From: Steven Rostedt on
From: Mathieu Desnoyers <mathieu.desnoyers(a)efficios.com>

This check is meant to be used by tracepoint users which do a direct cast of
callbacks to (void *) for direct registration, thus bypassing the
register_trace_##name and unregister_trace_##name checks.

This permits to ensure that the callback type matches the function type at the
call site, but without generating any code.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers(a)efficios.com>
LKML-Reference: <20100430165959.GA25605(a)Krystal>
CC: Steven Rostedt <rostedt(a)goodmis.org>
CC: Ingo Molnar <mingo(a)elte.hu>
CC: Andrew Morton <akpm(a)linux-foundation.org>
CC: Thomas Gleixner <tglx(a)linutronix.de>
CC: Peter Zijlstra <peterz(a)infradead.org>
CC: Frederic Weisbecker <fweisbec(a)gmail.com>
CC: Arnaldo Carvalho de Melo <acme(a)redhat.com>
CC: Lai Jiangshan <laijs(a)cn.fujitsu.com>
CC: Li Zefan <lizf(a)cn.fujitsu.com>
CC: Masami Hiramatsu <mhiramat(a)redhat.com>
CC: Christoph Hellwig <hch(a)lst.de>
Signed-off-by: Steven Rostedt <rostedt(a)goodmis.org>
---
include/linux/tracepoint.h | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 1d85f9a..8d5e4f6 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -137,9 +137,11 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
static inline int unregister_trace_##name(void (*probe)(proto)) \
{ \
return tracepoint_probe_unregister(#name, (void *)probe);\
+ } \
+ static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
+ { \
}

-
#define DEFINE_TRACE_FN(name, reg, unreg) \
static const char __tpstrtab_##name[] \
__attribute__((section("__tracepoints_strings"))) = #name; \
@@ -168,6 +170,9 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
static inline int unregister_trace_##name(void (*probe)(proto)) \
{ \
return -ENOSYS; \
+ } \
+ static inline void check_trace_callback_type_##name(void (*cb)(proto)) \
+ { \
}

#define DEFINE_TRACE_FN(name, reg, unreg)
--
1.7.0


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/