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