From 6cdf29f8cd289d763fae461c618975fe43095e8b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 26 Aug 2011 13:23:59 -0400 Subject: [PATCH] tracepoint.h: move code after used prototype declaration Signed-off-by: Mathieu Desnoyers --- include/ust/tracepoint.h | 61 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h index 76645dd..d793e58 100644 --- a/include/ust/tracepoint.h +++ b/include/ust/tracepoint.h @@ -45,37 +45,6 @@ struct tracepoint { */ #define tracepoint(name, args...) __trace_##name(args) -/* - * These weak symbols, the constructor, and destructor take care of - * registering only _one_ instance of the tracepoints per shared-ojbect - * (or for the whole main program). - * The dummy tracepoint entry ensures that the start/stop pointers get - * initialized by the linker when no tracepoints are present in a - * shared-object (or main program). - */ -extern struct tracepoint * const __start___tracepoints_ptrs[] - __attribute__((weak, visibility("hidden"))); -extern struct tracepoint * const __stop___tracepoints_ptrs[] - __attribute__((weak, visibility("hidden"))); -int __tracepoint_registered - __attribute__((weak, visibility("hidden"))); - -static void __attribute__((constructor)) __tracepoints__init(void) -{ - if (__tracepoint_registered++) - return; - tracepoint_register_lib(__start___tracepoints_ptrs, - __stop___tracepoints_ptrs - - __start___tracepoints_ptrs); -} - -static void __attribute__((destructor)) __tracepoints__destroy(void) -{ - if (--__tracepoint_registered) - return; - tracepoint_unregister_lib(__start___tracepoints_ptrs); -} - /* * it_func[0] is never NULL because there is at least one element in the array * when the array itself is non NULL. @@ -197,6 +166,36 @@ int tracepoint_register_lib(struct tracepoint * const *tracepoints_start, extern int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start); +/* + * These weak symbols, the constructor, and destructor take care of + * registering only _one_ instance of the tracepoints per shared-ojbect + * (or for the whole main program). + * The dummy tracepoint entry ensures that the start/stop pointers get + * initialized by the linker when no tracepoints are present in a + * shared-object (or main program). + */ +extern struct tracepoint * const __start___tracepoints_ptrs[] + __attribute__((weak, visibility("hidden"))); +extern struct tracepoint * const __stop___tracepoints_ptrs[] + __attribute__((weak, visibility("hidden"))); +int __tracepoint_registered + __attribute__((weak, visibility("hidden"))); + +static void __attribute__((constructor)) __tracepoints__init(void) +{ + if (__tracepoint_registered++) + return; + tracepoint_register_lib(__start___tracepoints_ptrs, + __stop___tracepoints_ptrs - + __start___tracepoints_ptrs); +} + +static void __attribute__((destructor)) __tracepoints__destroy(void) +{ + if (--__tracepoint_registered) + return; + tracepoint_unregister_lib(__start___tracepoints_ptrs); +} #ifndef TRACEPOINT_EVENT /* -- 2.34.1