| 1 | /* |
| 2 | * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com> |
| 3 | * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; |
| 8 | * version 2.1 of the License. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * |
| 20 | * Trace files that want to automate creationg of all tracepoints defined |
| 21 | * in their file should include this file. The following are macros that the |
| 22 | * trace file may define: |
| 23 | * |
| 24 | * TRACEPOINT_PROVIDER defines the provider the tracepoint is for: |
| 25 | * < [com_company_]project_[component_] > |
| 26 | * |
| 27 | * TRACEPOINT_INCLUDE_FILE if the file name is something other than |
| 28 | * TRACEPOINT_PROVIDER.h. This macro may be defined to tell |
| 29 | * define_trace.h what file to include. Note, leave off the ".h". |
| 30 | * |
| 31 | * TRACEPOINT_INCLUDE_PATH if the path is something other than within |
| 32 | * the system's include/tracepoint/ path, then this macro can define |
| 33 | * the path to use. This path is relative to tracepoint-event.h, or |
| 34 | * to the include search path. Trick: Use a |
| 35 | * #define TRACEPOINT_INCLUDE_PATH . |
| 36 | * combined with -Ipath_to_header as compiler argument to allow |
| 37 | * searching for a header within your project build tree. |
| 38 | * |
| 39 | * Note considering licensing: |
| 40 | * |
| 41 | * Including the tracepoint-event.h header without the |
| 42 | * TRACEPOINT_CREATE_PROBES macro defined is fine within any application |
| 43 | * source code, even for non-LGPL-compatible applications. |
| 44 | * |
| 45 | * However, TRACEPOINT_CREATE_PROBES should only be defined within |
| 46 | * LGPL-compatible C files. This means that the tracepoint probe object |
| 47 | * should be relinkable when distributed, either by providing it as a |
| 48 | * dynamically linkable shared object (.so library), or by providing the |
| 49 | * build scripts and object files required to relink the object if |
| 50 | * statically linked. |
| 51 | */ |
| 52 | |
| 53 | #ifdef __cplusplus |
| 54 | extern "C" { |
| 55 | #endif |
| 56 | |
| 57 | #ifdef TRACEPOINT_CREATE_PROBES |
| 58 | |
| 59 | /* Prevent recursion */ |
| 60 | #undef TRACEPOINT_CREATE_PROBES |
| 61 | |
| 62 | #ifndef __tp_stringify |
| 63 | #define __tp_stringify_1(x...) #x |
| 64 | #define __tp_stringify(x...) __tp_stringify_1(x) |
| 65 | #endif |
| 66 | |
| 67 | #undef TRACEPOINT_EVENT |
| 68 | #define TRACEPOINT_EVENT(provider, name, args, fields) \ |
| 69 | _DEFINE_TRACEPOINT(provider, name) |
| 70 | |
| 71 | #undef TRACEPOINT_EVENT_INSTANCE |
| 72 | #define TRACEPOINT_EVENT_INSTANCE(provider, template, name, args) \ |
| 73 | _DEFINE_TRACEPOINT(provider, name) |
| 74 | |
| 75 | #undef TRACEPOINT_INCLUDE |
| 76 | #undef __TRACEPOINT_INCLUDE |
| 77 | |
| 78 | #ifndef TRACEPOINT_INCLUDE_FILE |
| 79 | # define TRACEPOINT_INCLUDE_FILE TRACEPOINT_PROVIDER |
| 80 | # define UNDEF_TRACEPOINT_INCLUDE_FILE |
| 81 | #endif |
| 82 | |
| 83 | #ifndef TRACEPOINT_INCLUDE_PATH |
| 84 | # define __TRACEPOINT_INCLUDE(provider) <tracepoint/provider.h> |
| 85 | # define UNDEF_TRACEPOINT_INCLUDE_PATH |
| 86 | #else |
| 87 | # define __TRACEPOINT_INCLUDE(provider) \ |
| 88 | __tp_stringify(TRACEPOINT_INCLUDE_PATH/provider.h) |
| 89 | #endif |
| 90 | |
| 91 | # define TRACEPOINT_INCLUDE(provider) __TRACEPOINT_INCLUDE(provider) |
| 92 | |
| 93 | /* Let the trace headers be reread */ |
| 94 | #define TRACEPOINT_HEADER_MULTI_READ |
| 95 | |
| 96 | #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) |
| 97 | |
| 98 | #include <lttng/ust-tracepoint-event.h> |
| 99 | |
| 100 | #undef TRACEPOINT_EVENT |
| 101 | #undef TRACEPOINT_EVENT_CLASS |
| 102 | #undef TRACEPOINT_EVENT_INSTANCE |
| 103 | #undef TRACEPOINT_HEADER_MULTI_READ |
| 104 | |
| 105 | /* Only undef what we defined in this file */ |
| 106 | #ifdef UNDEF_TRACEPOINT_INCLUDE_FILE |
| 107 | # undef TRACEPOINT_INCLUDE_FILE |
| 108 | # undef UNDEF_TRACEPOINT_INCLUDE_FILE |
| 109 | #endif |
| 110 | |
| 111 | #ifdef UNDEF_TRACEPOINT_INCLUDE_PATH |
| 112 | # undef TRACEPOINT_INCLUDE_PATH |
| 113 | # undef UNDEF_TRACEPOINT_INCLUDE_PATH |
| 114 | #endif |
| 115 | |
| 116 | /* We may be processing more files */ |
| 117 | #define TRACEPOINT_CREATE_PROBES |
| 118 | |
| 119 | #endif /* TRACEPOINT_CREATE_PROBES */ |
| 120 | |
| 121 | #ifdef __cplusplus |
| 122 | } |
| 123 | #endif |