From 17881ebbfd76529904e826f425f3266834cf3a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Fri, 8 Nov 2024 15:34:06 +0000 Subject: [PATCH] Add configure check for gettid() presence The gettid() function is available on Linux in glibc only since version 2.30. There are supported distributions that still use older glibc version. Thus add a configure check if the gettid() function is available and extend the check in src/prof_stack_range.c so it's skipped also when gettid() isn't available. Fixes: https://github.com/jemalloc/jemalloc/issues/2740 --- configure.ac | 9 +++++++++ src/prof_stack_range.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a330e33e..e5fb3a6d 100644 --- a/configure.ac +++ b/configure.ac @@ -2706,6 +2706,15 @@ if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ], [ ]) fi +JE_COMPILABLE([gettid], [ +#include +], [ + int tid = gettid(); +], [je_cv_gettid]) +if test "x${je_cv_gettid}" = "xyes" ; then + AC_DEFINE([JEMALLOC_HAVE_GETTID], [ ], [ ]) +fi + JE_CFLAGS_SAVE() JE_CFLAGS_ADD([-D_GNU_SOURCE]) JE_CFLAGS_ADD([-Werror]) diff --git a/src/prof_stack_range.c b/src/prof_stack_range.c index c3458044..1f40dcc5 100644 --- a/src/prof_stack_range.c +++ b/src/prof_stack_range.c @@ -4,7 +4,7 @@ #include "jemalloc/internal/malloc_io.h" #include "jemalloc/internal/prof_sys.h" -#if defined (__linux__) +#if defined (__linux__) && defined(JE_HAVE_GETTID) #include #include