X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Flttng%2Fust-tid.h;fp=include%2Flttng%2Fust-tid.h;h=c6819f25a734d860c1e9cfcc603700b94871ff30;hb=d9ecffa9ad6203df66b5fa81e8d505c3a9779c16;hp=0000000000000000000000000000000000000000;hpb=dd197c1b48acdf4f9e84f3e7afad5fefff7d4572;p=lttng-ust.git diff --git a/include/lttng/ust-tid.h b/include/lttng/ust-tid.h new file mode 100644 index 00000000..c6819f25 --- /dev/null +++ b/include/lttng/ust-tid.h @@ -0,0 +1,44 @@ +#ifndef _LTTNG_UST_TID_H +#define _LTTNG_UST_TID_H + +/* + * lttng/ust-tid.h + * + * Copyright 2012 (c) - Mathieu Desnoyers + * + * gettid compatibility layer. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#ifdef __linux__ +#include +#endif + +#if defined(_syscall0) +_syscall0(pid_t, gettid) +#elif defined(__NR_gettid) +#include +static inline pid_t gettid(void) +{ + return syscall(__NR_gettid); +} +#else +#include +#include + +#warning "use pid as tid" +static inline pid_t gettid(void) +{ + return getpid(); +} +#endif + +#endif /* _LTTNG_UST_TID_H */