X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=include%2Fust%2Ftracepoint.h;h=11de23dcffde26dea9b05c9e14d8184a8019603d;hb=37ed587a8b9aea32c383058b4765a5730497d74a;hp=76645dd6a1d1fce7181022f88151aa033f508a46;hpb=1fcf7ad708a39a7ab3b76b3cacbee2b39b19d0db;p=lttng-ust.git diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h index 76645dd6..11de23dc 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,33 @@ 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). + */ +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 /*