Commit 90adf2aa authored by Daniel Black's avatar Daniel Black

perfschema: use glibc gettid if available

parent 68eac8a3
......@@ -322,6 +322,7 @@ SET(HAVE_SCHED_GETCPU CACHE INTERNAL "")
SET(HAVE_NANOSLEEP CACHE INTERNAL "")
SET(HAVE_PTHREAD_THREADID_NP CACHE INTERNAL "")
SET(HAVE_SYS_GETTID CACHE INTERNAL "")
SET(HAVE_GETTID CACHE INTERNAL "")
SET(HAVE_INTEGER_PTHREAD_SELF CACHE INTERNAL "")
SET(HAVE_PTHREAD_GETTHREADID_NP CACHE INTERNAL "")
SET(HAVE_TIMER_DELETE CACHE INTERNAL "")
......
......@@ -290,6 +290,9 @@ int main(int ac, char **av)
}"
HAVE_PTHREAD_THREADID_NP)
# gettid() library function (glibc-2.30+)
CHECK_SYMBOL_EXISTS(gettid unistd.h HAVE_GETTID)
# Check for gettid() system call
CHECK_C_SOURCE_COMPILES("
#include <sys/types.h>
......
......@@ -50,12 +50,14 @@ static inline my_thread_os_id_t my_thread_os_id()
pthread_threadid_np(nullptr, &tid64);
return (pid_t)tid64;
#else
#ifdef HAVE_GETTID
/* Linux glibc-2.30+ */
return gettid();
#else
#ifdef HAVE_SYS_GETTID
/*
Linux.
Linux before glibc-2.30
See man gettid
See GLIBC Bug 6399 - gettid() should have a wrapper
https://sourceware.org/bugzilla/show_bug.cgi?id=6399
*/
return syscall(SYS_gettid);
#else
......@@ -82,7 +84,8 @@ static inline my_thread_os_id_t my_thread_os_id()
#endif /* HAVE_PTHREAD_GETTHREADID_NP */
#endif /* _WIN32 */
#endif /* HAVE_SYS_GETTID */
#endif /* HAVE_SYS_THREAD_SELFID */
#endif /* HAVE_GETTID */
#endif /* HAVE_PTHREAD_THREADID_NP */
}
#define CHANNEL_NAME_LENGTH MAX_CONNECTION_NAME
......
#cmakedefine HAVE_PTHREAD_THREADID_NP 1
#cmakedefine HAVE_SYS_GETTID 1
#cmakedefine HAVE_GETTID
#cmakedefine HAVE_GETTHRID 1
#cmakedefine HAVE_PTHREAD_GETTHREADID_NP 1
#cmakedefine HAVE_INTEGER_PTHREAD_SELF 1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment