X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fpthread.h;h=bedfd91ff5387e26ef5f71da6afc19ba8614be02;hp=511ab089b3ed975c00cbb84e229b9c17c2bb2e22;hb=3f3e7eb74963e75f9b0bb76b854d8be2dcbb0443;hpb=3d77491e0be54807044a17d673431cb1bada7b67 diff --git a/src/common/compat/pthread.h b/src/common/compat/pthread.h index 511ab089b..bedfd91ff 100644 --- a/src/common/compat/pthread.h +++ b/src/common/compat/pthread.h @@ -12,6 +12,10 @@ #include #include +#ifdef __FreeBSD__ +#include +#endif + #define LTTNG_PTHREAD_NAMELEN 16 #if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID) @@ -28,27 +32,14 @@ int lttng_pthread_setname_np(const char *name) return pthread_setname_np(pthread_self(), name); } - -static inline -int lttng_pthread_getname_np(char *name, size_t len) -{ - return pthread_getname_np(pthread_self(), name, len); -} #elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) static inline int lttng_pthread_setname_np(const char *name) { return pthread_setname_np(name); } - -static inline -int lttng_pthread_getname_np(char *name, size_t len) -{ - return pthread_getname_np(name, len); -} #elif defined(HAVE_PTHREAD_SET_NAME_NP_WITH_TID) -#include static inline int lttng_pthread_setname_np(const char *name) { @@ -60,13 +51,6 @@ int lttng_pthread_setname_np(const char *name) pthread_set_name_np(pthread_self(), name); return 0; } - -static inline -int lttng_pthread_getname_np(char *name, size_t len) -{ - pthread_get_name_np(pthread_self(), name, len); - return 0; -} #elif defined(__linux__) /* Fallback on prtctl on Linux */ @@ -81,12 +65,6 @@ int lttng_pthread_setname_np(const char *name) } return prctl(PR_SET_NAME, name, 0, 0, 0); } - -static inline -int lttng_pthread_getname_np(char *name, size_t len) -{ - return prctl(PR_GET_NAME, name, 0, 0, 0); -} #else /* * For platforms without thread name support, do nothing. @@ -96,7 +74,42 @@ int lttng_pthread_setname_np(const char *name) { return -ENOSYS; } +#endif + +#if defined(HAVE_PTHREAD_GETNAME_NP_WITH_TID) +static inline +int lttng_pthread_getname_np(char *name, size_t len) +{ + return pthread_getname_np(pthread_self(), name, len); +} +#elif defined(HAVE_PTHREAD_GETNAME_NP_WITHOUT_TID) +static inline +int lttng_pthread_getname_np(char *name, size_t len) +{ + return pthread_getname_np(name, len); +} +#elif defined(HAVE_PTHREAD_GET_NAME_NP_WITH_TID) +static inline +int lttng_pthread_getname_np(char *name, size_t len) +{ + pthread_get_name_np(pthread_self(), name, len); + return 0; +} +#elif defined(__linux__) + +/* Fallback on prtctl on Linux */ +#include + +static inline +int lttng_pthread_getname_np(char *name, size_t len) +{ + return prctl(PR_GET_NAME, name, 0, 0, 0); +} +#else +/* + * For platforms without thread name support, do nothing. + */ static inline int lttng_pthread_getname_np(char *name, size_t len) {