Fix: forbid session name creation if contains /
[lttng-tools.git] / src / common / testpoint / testpoint.h
1 /*
2 * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #ifdef NTESTPOINT
19
20 #define testpoint(name)
21 #define TESTPOINT_DECL(name)
22
23 #else /* NTESTPOINT */
24
25 #include <urcu.h> /* for caa_likely/unlikely */
26
27 extern int lttng_testpoint_activated;
28
29 void *lttng_testpoint_lookup(const char *name);
30
31 /*
32 * Testpoint is only active if the global lttng_testpoint_activated flag is
33 * set.
34 * Return a non-zero error code to indicate failure.
35 */
36 #define testpoint(name) \
37 ((caa_unlikely(lttng_testpoint_activated)) \
38 ? __testpoint_##name##_wrapper() : 0)
39
40 /*
41 * One wrapper per testpoint is generated. This is to keep track of the symbol
42 * lookup status and the corresponding function pointer, if any.
43 */
44 #define _TESTPOINT_DECL(_name) \
45 static inline int __testpoint_##_name##_wrapper(void) \
46 { \
47 int ret = 0; \
48 static int (*tp)(void); \
49 static int found; \
50 const char *tp_name = "__testpoint_" #_name; \
51 \
52 if (tp) { \
53 ret = tp(); \
54 } else { \
55 if (!found) { \
56 tp = lttng_testpoint_lookup(tp_name); \
57 if (tp) { \
58 found = 1; \
59 ret = tp(); \
60 } else { \
61 found = -1; \
62 } \
63 } \
64 } \
65 return ret; \
66 }
67
68 /* Testpoint declaration */
69 #define TESTPOINT_DECL(name) \
70 _TESTPOINT_DECL(name)
71
72 #endif /* NTESTPOINT */
This page took 0.035541 seconds and 4 git commands to generate.