From be9a7f8d052b997d9bea384a69508081d48ade63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nerijus=20Bali=C5=ABnas?= Date: Sat, 4 May 2024 01:02:05 +0300 Subject: [PATCH 1/4] Fix undefined reference to 'gettid' on CentOS 8 --- src/vabackend.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vabackend.h b/src/vabackend.h index 4b590cb..fb049b2 100644 --- a/src/vabackend.h +++ b/src/vabackend.h @@ -13,6 +13,13 @@ #include "direct/nv-driver.h" #include "common.h" +#include +#include +#ifndef SYS_gettid +#error "SYS_gettid unavailable on this system" +#endif +#define gettid() ((pid_t)syscall(SYS_gettid)) + #define SURFACE_QUEUE_SIZE 16 #define MAX_IMAGE_COUNT 64 From 1478ac801b8a4015c472b88cdc40cb29be6a1711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nerijus=20Bali=C5=ABnas?= Date: Sat, 4 May 2024 01:58:53 +0300 Subject: [PATCH 2/4] Revert "Fix undefined reference to 'gettid' on CentOS 8" This reverts commit be9a7f8d052b997d9bea384a69508081d48ade63. --- src/vabackend.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/vabackend.h b/src/vabackend.h index fb049b2..4b590cb 100644 --- a/src/vabackend.h +++ b/src/vabackend.h @@ -13,13 +13,6 @@ #include "direct/nv-driver.h" #include "common.h" -#include -#include -#ifndef SYS_gettid -#error "SYS_gettid unavailable on this system" -#endif -#define gettid() ((pid_t)syscall(SYS_gettid)) - #define SURFACE_QUEUE_SIZE 16 #define MAX_IMAGE_COUNT 64 From a9f1aee050c576ce3e8f9d801c721f02347fb350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nerijus=20Bali=C5=ABnas?= Date: Sat, 4 May 2024 16:05:27 +0300 Subject: [PATCH 3/4] Fix undefined reference to 'gettid' on CentOS 8 --- src/vabackend.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/vabackend.c b/src/vabackend.c index b803441..aaf529f 100644 --- a/src/vabackend.c +++ b/src/vabackend.c @@ -36,8 +36,34 @@ #if __has_include() #include #define gettid pthread_getthreadid_np +#define HAVE_GETTID 1 #endif +#ifndef HAVE_GETTID +#include +#include +/* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and + * has a definition for it */ +#ifdef __BIONIC__ +#define HAVE_GETTID 1 +#elif !defined(__GLIBC_PREREQ) +#define HAVE_GETTID 0 +#elif !__GLIBC_PREREQ(2,30) +#define HAVE_GETTID 0 +#else +#define HAVE_GETTID 1 +#endif +#endif + +static pid_t nv_gettid(void) +{ +#if HAVE_GETTID + return gettid(); +#else + return syscall(__NR_gettid); +#endif +} + static pthread_mutex_t concurrency_mutex = PTHREAD_MUTEX_INITIALIZER; static uint32_t instances; static uint32_t max_instances; @@ -176,7 +202,7 @@ void logger(const char *filename, const char *function, int line, const char *ms struct timespec tp; clock_gettime(CLOCK_MONOTONIC, &tp); - fprintf(LOG_OUTPUT, "%10ld.%09ld [%d-%d] %s:%4d %24s %s\n", (long)tp.tv_sec, tp.tv_nsec, getpid(), gettid(), filename, line, function, formattedMessage); + fprintf(LOG_OUTPUT, "%10ld.%09ld [%d-%d] %s:%4d %24s %s\n", (long)tp.tv_sec, tp.tv_nsec, getpid(), nv_gettid(), filename, line, function, formattedMessage); fflush(LOG_OUTPUT); } From 66d16932ab692a7369fed009f1c64bb12f4f54a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nerijus=20Bali=C5=ABnas?= Date: Sat, 4 May 2024 16:14:46 +0300 Subject: [PATCH 4/4] Remove duplicated include --- src/vabackend.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vabackend.c b/src/vabackend.c index aaf529f..8b50e1b 100644 --- a/src/vabackend.c +++ b/src/vabackend.c @@ -41,7 +41,6 @@ #ifndef HAVE_GETTID #include -#include /* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and * has a definition for it */ #ifdef __BIONIC__