X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fpthread.h;fp=src%2Fcommon%2Fcompat%2Fpthread.h;h=a5f91b339123976bb6e5a95a6f2f46054692fa90;hp=0000000000000000000000000000000000000000;hb=cb8d0d245b5739e7493dcf27314f6e42615f14b1;hpb=97285430b75f44b6ce590e86cb9d996390e514c8 diff --git a/src/common/compat/pthread.h b/src/common/compat/pthread.h new file mode 100644 index 000000000..a5f91b339 --- /dev/null +++ b/src/common/compat/pthread.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Michael Jeanson + * + * SPDX-License-Identifier: GPL-2.0-only + * + */ + +#ifndef _COMPAT_PTHREAD_H +#define _COMPAT_PTHREAD_H + +#include + +#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID) +static inline +int lttng_pthread_setname_np(const char *name) +{ + return pthread_setname_np(pthread_self(), name); +} +#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) +static inline +int lttng_pthread_setname_np(const char *name) +{ + return pthread_setname_np(name); +} +#else +/* + * For platforms without thread name support, do nothing. + */ +static inline +int lttng_pthread_setname_np(const char *name) +{ + return -ENOSYS; +} +#endif + +#endif /* _COMPAT_PTHREAD_H */