Commit | Line | Data |
---|---|---|
d183b2df PP |
1 | #ifndef _BARECTF_TRACEPOINT_H |
2 | #define _BARECTF_TRACEPOINT_H | |
3 | ||
4 | /* | |
5 | * The MIT License (MIT) | |
6 | * | |
a32e4217 | 7 | * Copyright (c) 2016-2020 Philippe Proulx <pproulx@efficios.com> |
d183b2df | 8 | * |
a32e4217 PP |
9 | * Permission is hereby granted, free of charge, to any person obtaining |
10 | * a copy of this software and associated documentation files (the | |
11 | * "Software"), to deal in the Software without restriction, including | |
12 | * without limitation the rights to use, copy, modify, merge, publish, | |
13 | * distribute, sublicense, and/or sell copies of the Software, and to | |
14 | * permit persons to whom the Software is furnished to do so, subject to | |
15 | * the following conditions: | |
d183b2df | 16 | * |
a32e4217 PP |
17 | * The above copyright notice and this permission notice shall be |
18 | * included in all copies or substantial portions of the Software. | |
d183b2df | 19 | * |
a32e4217 PP |
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
27 | * SOFTWARE. | |
d183b2df PP |
28 | */ |
29 | ||
a32e4217 | 30 | /* Get identifier prefix */ |
d183b2df PP |
31 | #ifdef BARECTF_TRACEPOINT_PREFIX |
32 | # define _BARECTF_TRACEPOINT_PREFIX BARECTF_TRACEPOINT_PREFIX | |
33 | #else | |
a32e4217 PP |
34 | # ifdef _BARECTF_IDENTIFIER_PREFIX |
35 | # define _BARECTF_TRACEPOINT_PREFIX _BARECTF_IDENTIFIER_PREFIX | |
d183b2df | 36 | # else |
a32e4217 | 37 | # error You must define `BARECTF_TRACEPOINT_PREFIX` to use this header. |
d183b2df PP |
38 | # endif |
39 | #endif | |
40 | ||
a32e4217 | 41 | /* Get data stream type name to use */ |
d183b2df | 42 | #ifdef BARECTF_TRACEPOINT_STREAM |
a32e4217 PP |
43 | # define _BARECTF_TRACEPOINT_DST_NAME BARECTF_TRACEPOINT_STREAM |
44 | #elif defined(BARECTF_TRACEPOINT_DATA_STREAM_TYPE_NAME) | |
45 | # define _BARECTF_TRACEPOINT_DST_NAME BARECTF_TRACEPOINT_DATA_STREAM_TYPE_NAME | |
d183b2df | 46 | #else |
a32e4217 PP |
47 | # ifdef _BARECTF_DEFAULT_DATA_STREAM_TYPE_NAME |
48 | # define _BARECTF_TRACEPOINT_DST_NAME _BARECTF_DEFAULT_DATA_STREAM_TYPE_NAME | |
d183b2df | 49 | # else |
a32e4217 | 50 | # error You must define `BARECTF_TRACEPOINT_DATA_STREAM_TYPE_NAME` to use this header. |
d183b2df PP |
51 | # endif |
52 | #endif | |
53 | ||
a32e4217 | 54 | /* Get context to use */ |
d183b2df | 55 | #ifndef BARECTF_TRACEPOINT_CTX |
a32e4217 | 56 | # error You must define `BARECTF_TRACEPOINT_CTX` to use this header. |
d183b2df PP |
57 | #endif |
58 | ||
59 | /* | |
60 | * Combines 6 token. Inspired by __TP_COMBINE_TOKENS4() in | |
61 | * <lttng/tracepoint.h>. See sections 6.10.3 and 6.10.3.1 of | |
62 | * ISO/IEC 9899:1999. | |
63 | */ | |
64 | #define __COMBINE_TOKENS6(_a, _b, _c, _d, _e, _f) \ | |
65 | _a ## _b ## _c ## _d ## _e ## _f | |
66 | #define _COMBINE_TOKENS6(_a, _b, _c, _d, _e, _f) \ | |
67 | __COMBINE_TOKENS6(_a, _b, _c, _d, _e, _f) | |
68 | ||
69 | /* tracepoint() used by the user */ | |
70 | #undef tracepoint | |
71 | #define tracepoint(_prov_name, _tp_name, ...) \ | |
a32e4217 | 72 | _COMBINE_TOKENS6(_BARECTF_TRACEPOINT_PREFIX, _BARECTF_TRACEPOINT_DST_NAME, _trace_, _prov_name, _, _tp_name)(BARECTF_TRACEPOINT_CTX, ##__VA_ARGS__) |
d183b2df PP |
73 | |
74 | #endif /* _BARECTF_TRACEPOINT_H */ |