Add common util to set thread name
[lttng-tools.git] / src / common / compat / pthread.h
1 /*
2 * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef _COMPAT_PTHREAD_H
9 #define _COMPAT_PTHREAD_H
10
11 #include <pthread.h>
12
13 #if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
14 static inline
15 int lttng_pthread_setname_np(const char *name)
16 {
17 return pthread_setname_np(pthread_self(), name);
18 }
19 #elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
20 static inline
21 int lttng_pthread_setname_np(const char *name)
22 {
23 return pthread_setname_np(name);
24 }
25 #else
26 /*
27 * For platforms without thread name support, do nothing.
28 */
29 static inline
30 int lttng_pthread_setname_np(const char *name)
31 {
32 return -ENOSYS;
33 }
34 #endif
35
36 #endif /* _COMPAT_PTHREAD_H */
This page took 0.038819 seconds and 4 git commands to generate.