Commit 482cf29e authored by Brad Smith's avatar Brad Smith Committed by Daniel Black

MDEV-23091: perfschema Add support for OpenBSD's getthrid() to retrieve the thread id

parent fe5dbfe7
...@@ -298,6 +298,16 @@ int main(int ac, char **av) ...@@ -298,6 +298,16 @@ int main(int ac, char **av)
}" }"
HAVE_SYS_GETTID) HAVE_SYS_GETTID)
# Check for getthrid()
CHECK_C_SOURCE_COMPILES("
#include <unistd.h>
int main(int ac, char **av)
{
unsigned long long tid = getthrid();
return (tid != 0 ? 0 : 1);
}"
HAVE_GETTHRID)
# Check for pthread_getthreadid_np() # Check for pthread_getthreadid_np()
CHECK_C_SOURCE_COMPILES(" CHECK_C_SOURCE_COMPILES("
#include <pthread_np.h> #include <pthread_np.h>
......
...@@ -67,6 +67,10 @@ static inline my_thread_os_id_t my_thread_os_id() ...@@ -67,6 +67,10 @@ static inline my_thread_os_id_t my_thread_os_id()
/* FreeBSD 10.2 */ /* FreeBSD 10.2 */
return pthread_getthreadid_np(); return pthread_getthreadid_np();
#else #else
#ifdef HAVE_GETTHRID
/* OpenBSD */
return getthrid();
#else
#ifdef HAVE_INTEGER_PTHREAD_SELF #ifdef HAVE_INTEGER_PTHREAD_SELF
/* Unknown platform, fallback. */ /* Unknown platform, fallback. */
return pthread_self(); return pthread_self();
...@@ -74,6 +78,7 @@ static inline my_thread_os_id_t my_thread_os_id() ...@@ -74,6 +78,7 @@ static inline my_thread_os_id_t my_thread_os_id()
/* Feature not available. */ /* Feature not available. */
return 0; return 0;
#endif /* HAVE_INTEGER_PTHREAD_SELF */ #endif /* HAVE_INTEGER_PTHREAD_SELF */
#endif /* HAVE_GETTHRID */
#endif /* HAVE_PTHREAD_GETTHREADID_NP */ #endif /* HAVE_PTHREAD_GETTHREADID_NP */
#endif /* _WIN32 */ #endif /* _WIN32 */
#endif /* HAVE_SYS_GETTID */ #endif /* HAVE_SYS_GETTID */
......
#cmakedefine HAVE_PTHREAD_THREADID_NP 1 #cmakedefine HAVE_PTHREAD_THREADID_NP 1
#cmakedefine HAVE_SYS_GETTID 1 #cmakedefine HAVE_SYS_GETTID 1
#cmakedefine HAVE_GETTHRID 1
#cmakedefine HAVE_PTHREAD_GETTHREADID_NP 1 #cmakedefine HAVE_PTHREAD_GETTHREADID_NP 1
#cmakedefine HAVE_INTEGER_PTHREAD_SELF 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