Add glibc gettid to wrapper
[lttng-ust.git] / src / common / compat / tid.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * gettid compatibility layer.
7 */
8
9 #ifndef _UST_COMMON_COMPAT_GETTID_H
10 #define _UST_COMMON_COMPAT_GETTID_H
11
12 #ifdef __linux__
13 #include <sys/syscall.h>
14 #endif
15
16 #ifdef HAVE_GETTID
17
18 #include <unistd.h>
19 static inline pid_t lttng_gettid(void)
20 {
21 return gettid();
22 }
23
24 #elif defined(__NR_gettid)
25
26 #include <unistd.h>
27 static inline pid_t lttng_gettid(void)
28 {
29 return syscall(__NR_gettid);
30 }
31
32 #else
33
34 #include <sys/types.h>
35 #include <unistd.h>
36
37 /* Fall-back on getpid for tid if not available. */
38 static inline pid_t lttng_gettid(void)
39 {
40 return getpid();
41 }
42
43 #endif
44
45 #endif /* _UST_COMMON_COMPAT_GETTID_H */
This page took 0.030149 seconds and 4 git commands to generate.