From 4a62318422ca3f0f72b6fd00031daba556a10687 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 4 Dec 2024 15:32:40 +0100 Subject: Add a configure test for gettid. * configure.ac (HAVE_GETTID,HAVE_SYS_GETTID): New test. * src/debug.c: Include syscall.h if needed. (tid_log_callback) [HAVE_SYS_GETTID]: Use SYS_gettid -- Linux introduced the gettid syscall with 2.4.11 but glibc only with its version 2.30. This patch allows building on older platforms. Co-authored-by: lgh1 --- configure.ac | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 7eef3523..d8d7dc42 100644 --- a/configure.ac +++ b/configure.ac @@ -919,6 +919,25 @@ fi # Check for getgid etc AC_CHECK_FUNCS(getgid getegid closefrom nanosleep) +# Check for gettid - test taken from strongswan git +AC_CHECK_FUNC(gettid, + [AC_DEFINE(HAVE_GETTID, 1, [Defined if gettid is available.])], + [AC_MSG_CHECKING([for SYS_gettid]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#define _GNU_SOURCE + #include + #include + ]], + [[int main() { + return syscall(SYS_gettid);}]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_SYS_GETTID,1, + [Defined is the system call gettid is available])], + [AC_MSG_RESULT([no])] + )] +) + # Replacement functions. AC_REPLACE_FUNCS(stpcpy) -- cgit v1.2.3