| 1 |
#ifndef _BARECTF_TRACEPOINT_H |
| 2 |
#define _BARECTF_TRACEPOINT_H |
| 3 |
|
| 4 |
/* |
| 5 |
* The MIT License (MIT) |
| 6 |
* |
| 7 |
* Copyright (c) 2016-2020 Philippe Proulx <[email protected]> |
| 8 |
* |
| 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: |
| 16 |
* |
| 17 |
* The above copyright notice and this permission notice shall be |
| 18 |
* included in all copies or substantial portions of the Software. |
| 19 |
* |
| 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. |
| 28 |
*/ |
| 29 |
|
| 30 |
/* Get identifier prefix */ |
| 31 |
#ifdef BARECTF_TRACEPOINT_PREFIX |
| 32 |
# define _BARECTF_TRACEPOINT_PREFIX BARECTF_TRACEPOINT_PREFIX |
| 33 |
#else |
| 34 |
# ifdef _BARECTF_IDENTIFIER_PREFIX |
| 35 |
# define _BARECTF_TRACEPOINT_PREFIX _BARECTF_IDENTIFIER_PREFIX |
| 36 |
# else |
| 37 |
# error You must define `BARECTF_TRACEPOINT_PREFIX` to use this header. |
| 38 |
# endif |
| 39 |
#endif |
| 40 |
|
| 41 |
/* Get data stream type name to use */ |
| 42 |
#ifdef BARECTF_TRACEPOINT_STREAM |
| 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 |
| 46 |
#else |
| 47 |
# ifdef _BARECTF_DEFAULT_DATA_STREAM_TYPE_NAME |
| 48 |
# define _BARECTF_TRACEPOINT_DST_NAME _BARECTF_DEFAULT_DATA_STREAM_TYPE_NAME |
| 49 |
# else |
| 50 |
# error You must define `BARECTF_TRACEPOINT_DATA_STREAM_TYPE_NAME` to use this header. |
| 51 |
# endif |
| 52 |
#endif |
| 53 |
|
| 54 |
/* Get context to use */ |
| 55 |
#ifndef BARECTF_TRACEPOINT_CTX |
| 56 |
# error You must define `BARECTF_TRACEPOINT_CTX` to use this header. |
| 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, ...) \ |
| 72 |
_COMBINE_TOKENS6(_BARECTF_TRACEPOINT_PREFIX, _BARECTF_TRACEPOINT_DST_NAME, _trace_, _prov_name, _, _tp_name)(BARECTF_TRACEPOINT_CTX, ##__VA_ARGS__) |
| 73 |
|
| 74 |
#endif /* _BARECTF_TRACEPOINT_H */ |