Commit | Line | Data |
---|---|---|
9e32c5c0 CB |
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 | #include <stdlib.h> | |
19 | #include <string.h> | |
20 | #include <pthread.h> | |
21 | ||
22 | /* | |
23 | * Check if the specified environment variable is set. | |
24 | * Return 1 if set, otherwise 0. | |
25 | */ | |
26 | int check_env_var(const char *env) | |
27 | { | |
28 | if (env) { | |
29 | char *env_val = getenv(env); | |
30 | if (env_val && (strncmp(env_val, "1", 1) == 0)) { | |
31 | return 1; | |
32 | } | |
33 | } | |
34 | ||
35 | return 0; | |
36 | } | |
37 | ||
6993eeb3 | 38 | int __testpoint_thread_manage_clients(void) |
9e32c5c0 CB |
39 | { |
40 | const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_EXIT"; | |
41 | ||
42 | if (check_env_var(var)) { | |
43 | pthread_exit(NULL); | |
44 | } | |
6993eeb3 CB |
45 | |
46 | return 0; | |
9e32c5c0 CB |
47 | } |
48 | ||
6993eeb3 | 49 | int __testpoint_thread_registration_apps(void) |
9e32c5c0 CB |
50 | { |
51 | const char *var = "LTTNG_THREAD_REG_APPS_EXIT"; | |
52 | ||
53 | if (check_env_var(var)) { | |
54 | pthread_exit(NULL); | |
55 | } | |
6993eeb3 CB |
56 | |
57 | return 0; | |
9e32c5c0 CB |
58 | } |
59 | ||
6993eeb3 | 60 | int __testpoint_thread_manage_apps(void) |
9e32c5c0 CB |
61 | { |
62 | const char *var = "LTTNG_THREAD_MANAGE_APPS_EXIT"; | |
63 | ||
64 | if (check_env_var(var)) { | |
65 | pthread_exit(NULL); | |
66 | } | |
6993eeb3 CB |
67 | |
68 | return 0; | |
9e32c5c0 CB |
69 | } |
70 | ||
6993eeb3 | 71 | int __testpoint_thread_manage_kernel(void) |
9e32c5c0 CB |
72 | { |
73 | const char *var = "LTTNG_THREAD_MANAGE_KERNEL_EXIT"; | |
74 | ||
75 | if (check_env_var(var)) { | |
76 | pthread_exit(NULL); | |
77 | } | |
6993eeb3 CB |
78 | |
79 | return 0; | |
9e32c5c0 CB |
80 | } |
81 | ||
6993eeb3 | 82 | int __testpoint_thread_manage_consumer(void) |
9e32c5c0 CB |
83 | { |
84 | const char *var = "LTTNG_THREAD_MANAGE_CONSUMER_EXIT"; | |
85 | ||
86 | if (check_env_var(var)) { | |
87 | pthread_exit(NULL); | |
88 | } | |
6993eeb3 CB |
89 | |
90 | return 0; | |
9e32c5c0 | 91 | } |