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
This commit is contained in:
Dan Horák 2024-11-08 15:34:06 +00:00 committed by Qi Wang
parent 4b88bddbca
commit 17881ebbfd
2 changed files with 10 additions and 1 deletions

View File

@ -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 <unistd.h>
], [
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])

View File

@ -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 <errno.h>
#include <fcntl.h>