From 15bc09b06b7e65d4969bdc852659cfbc46bd60b5 Mon Sep 17 00:00:00 2001 From: Ruslan Piasetskyi Date: Fri, 5 Jan 2024 13:59:16 +0100 Subject: [PATCH] engine: platform: linux: Add gettid definition for old systems The gettid() library support was added in glibc 2.30. Earlier glibc versions did not provide a wrapper for this system call, necessitating the use of syscall(2). Also, put _GNU_SOURCE definition in the guard to avoid the warning: ../engine/platform/linux/sys_linux.c:16: warning: "_GNU_SOURCE" redefined #define _GNU_SOURCE : note: this is the location of the previous definition --- engine/platform/linux/sys_linux.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/engine/platform/linux/sys_linux.c b/engine/platform/linux/sys_linux.c index 210a727c..908f2cca 100644 --- a/engine/platform/linux/sys_linux.c +++ b/engine/platform/linux/sys_linux.c @@ -13,7 +13,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif + #include #include #include @@ -24,6 +27,19 @@ GNU General Public License for more details. #include #include #include "platform/platform.h" +#include + +#if defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 30) +// Library support was added in glibc 2.30. +// Earlier glibc versions did not provide a wrapper for this system call, +// necessitating the use of syscall(2). +#include + +static pid_t gettid( void ) +{ + return syscall( SYS_gettid ); +} +#endif static void *g_hsystemd; static int (*g_pfn_sd_notify)( int unset_environment, const char *state );