Skip to content

Commit 482cf29

Browse files
brad0grooverdan
authored andcommitted
MDEV-23091: perfschema Add support for OpenBSD's getthrid() to retrieve the thread id
1 parent fe5dbfe commit 482cf29

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

storage/perfschema/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,16 @@ int main(int ac, char **av)
298298
}"
299299
HAVE_SYS_GETTID)
300300

301+
# Check for getthrid()
302+
CHECK_C_SOURCE_COMPILES("
303+
#include <unistd.h>
304+
int main(int ac, char **av)
305+
{
306+
unsigned long long tid = getthrid();
307+
return (tid != 0 ? 0 : 1);
308+
}"
309+
HAVE_GETTHRID)
310+
301311
# Check for pthread_getthreadid_np()
302312
CHECK_C_SOURCE_COMPILES("
303313
#include <pthread_np.h>

storage/perfschema/my_thread.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,18 @@ static inline my_thread_os_id_t my_thread_os_id()
6767
/* FreeBSD 10.2 */
6868
return pthread_getthreadid_np();
6969
#else
70+
#ifdef HAVE_GETTHRID
71+
/* OpenBSD */
72+
return getthrid();
73+
#else
7074
#ifdef HAVE_INTEGER_PTHREAD_SELF
7175
/* Unknown platform, fallback. */
7276
return pthread_self();
7377
#else
7478
/* Feature not available. */
7579
return 0;
7680
#endif /* HAVE_INTEGER_PTHREAD_SELF */
81+
#endif /* HAVE_GETTHRID */
7782
#endif /* HAVE_PTHREAD_GETTHREADID_NP */
7883
#endif /* _WIN32 */
7984
#endif /* HAVE_SYS_GETTID */

storage/perfschema/pfs_config.h.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#cmakedefine HAVE_PTHREAD_THREADID_NP 1
22
#cmakedefine HAVE_SYS_GETTID 1
3+
#cmakedefine HAVE_GETTHRID 1
34
#cmakedefine HAVE_PTHREAD_GETTHREADID_NP 1
45
#cmakedefine HAVE_INTEGER_PTHREAD_SELF 1

0 commit comments

Comments
 (0)