Add common util to set thread name
[lttng-tools.git] / src / common / compat / tid.h
CommitLineData
ffe60014 1/*
ab5be9fa 2 * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ffe60014 3 *
ab5be9fa 4 * SPDX-License-Identifier: MIT
ffe60014 5 *
ffe60014
DG
6 */
7
8#ifndef LTTNG_TID_H
9#define LTTNG_TID_H
10
11#ifdef __linux__
12#include <syscall.h>
13#endif
14
557ac9b9
MJ
15#if defined(__NR_gettid)
16
ffe60014 17#include <unistd.h>
557ac9b9 18static inline pid_t lttng_gettid(void)
ffe60014
DG
19{
20 return syscall(__NR_gettid);
21}
557ac9b9 22
ffe60014 23#else
557ac9b9 24
ffe60014
DG
25#include <sys/types.h>
26#include <unistd.h>
27
28/* Fall-back on getpid for tid if not available. */
557ac9b9 29static inline pid_t lttng_gettid(void)
ffe60014
DG
30{
31 return getpid();
32}
557ac9b9 33
ffe60014
DG
34#endif
35
36#endif /* LTTNG_TID_H */
This page took 0.044583 seconds and 4 git commands to generate.