Commit | Line | Data |
---|---|---|
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 | ||
c0c0989a MJ |
9 | #ifndef _LTTNG_UST_TID_H |
10 | #define _LTTNG_UST_TID_H | |
11 | ||
49c0da7d | 12 | #ifdef __linux__ |
809b9294 | 13 | #include <sys/syscall.h> |
49c0da7d MD |
14 | #endif |
15 | ||
0f029713 MJ |
16 | #if defined(__NR_gettid) |
17 | ||
49c0da7d | 18 | #include <unistd.h> |
0f029713 | 19 | static inline pid_t lttng_gettid(void) |
49c0da7d MD |
20 | { |
21 | return syscall(__NR_gettid); | |
22 | } | |
0f029713 | 23 | |
49c0da7d | 24 | #else |
0f029713 | 25 | |
49c0da7d MD |
26 | #include <sys/types.h> |
27 | #include <unistd.h> | |
28 | ||
d02d8cf8 | 29 | /* Fall-back on getpid for tid if not available. */ |
0f029713 | 30 | static inline pid_t lttng_gettid(void) |
49c0da7d MD |
31 | { |
32 | return getpid(); | |
33 | } | |
0f029713 | 34 | |
49c0da7d MD |
35 | #endif |
36 | ||
37 | #endif /* _LTTNG_UST_TID_H */ |