Blame include/lttng/ust-tid.h

Packit c04fcb
#ifndef _LTTNG_UST_TID_H
Packit c04fcb
#define _LTTNG_UST_TID_H
Packit c04fcb
Packit c04fcb
/*
Packit c04fcb
 * lttng/ust-tid.h
Packit c04fcb
 *
Packit c04fcb
 * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Packit c04fcb
 *
Packit c04fcb
 * gettid compatibility layer.
Packit c04fcb
 *
Packit c04fcb
 * Permission is hereby granted, free of charge, to any person obtaining a copy
Packit c04fcb
 * of this software and associated documentation files (the "Software"), to deal
Packit c04fcb
 * in the Software without restriction, including without limitation the rights
Packit c04fcb
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Packit c04fcb
 * copies of the Software, and to permit persons to whom the Software is
Packit c04fcb
 * furnished to do so, subject to the following conditions:
Packit c04fcb
 *
Packit c04fcb
 * The above copyright notice and this permission notice shall be included in
Packit c04fcb
 * all copies or substantial portions of the Software.
Packit c04fcb
 *
Packit c04fcb
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit c04fcb
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit c04fcb
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Packit c04fcb
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Packit c04fcb
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Packit c04fcb
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit c04fcb
 * SOFTWARE.
Packit c04fcb
 */
Packit c04fcb
Packit c04fcb
#ifdef __linux__
Packit c04fcb
#include <syscall.h>
Packit c04fcb
#endif
Packit c04fcb
Packit c04fcb
#if defined(_syscall0)
Packit c04fcb
_syscall0(pid_t, gettid)
Packit c04fcb
#elif defined(__NR_gettid)
Packit c04fcb
#include <unistd.h>
Packit c04fcb
static inline pid_t gettid(void)
Packit c04fcb
{
Packit c04fcb
	return syscall(__NR_gettid);
Packit c04fcb
}
Packit c04fcb
#else
Packit c04fcb
#include <sys/types.h>
Packit c04fcb
#include <unistd.h>
Packit c04fcb
Packit c04fcb
/* Fall-back on getpid for tid if not available. */
Packit c04fcb
static inline pid_t gettid(void)
Packit c04fcb
{
Packit c04fcb
	return getpid();
Packit c04fcb
}
Packit c04fcb
#endif
Packit c04fcb
Packit c04fcb
#endif /* _LTTNG_UST_TID_H */