rtla/SOURCES/rtla-Use-SYS_gettid-for-get...

51 lines
1.4 KiB
Diff

From 07ad224f2416e7c9411fd095fef148c67011eb49 Mon Sep 17 00:00:00 2001
From: root <root@hpe-dl160gen8-01.hpe2.lab.eng.bos.redhat.com>
Date: Wed, 20 Dec 2023 13:08:28 -0500
Subject: [PATCH] rtla: Use SYS_gettid for gettid
Use SYS_gettid for gettid since gittid is not available in the version
of glibc in rhel8.x
Also add the -lpthread to the flags in the Makefile for
pthread_setname_np
Signed-off-by: root <root@hpe-dl160gen8-01.hpe2.lab.eng.bos.redhat.com>
---
Makefile | 2 +-
src/timerlat_u.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 2456a399eb9a..db85545e9ec1 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ TRACEFS_HEADERS := $$($(PKG_CONFIG) --cflags libtracefs)
CFLAGS := -O -g -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(TRACEFS_HEADERS) $(EXTRA_CFLAGS)
LDFLAGS := -ggdb $(EXTRA_LDFLAGS)
-LIBS := $$($(PKG_CONFIG) --libs libtracefs)
+LIBS := $$($(PKG_CONFIG) --libs libtracefs) -lpthread
SRC := $(wildcard src/*.c)
HDR := $(wildcard src/*.h)
diff --git a/src/timerlat_u.c b/src/timerlat_u.c
index 01dbf9a6b5a5..e8d0ec92c8d2 100644
--- a/src/timerlat_u.c
+++ b/src/timerlat_u.c
@@ -16,6 +16,12 @@
#include <sys/wait.h>
#include <sys/prctl.h>
+#include <sys/syscall.h>
+#ifndef SYS_gettid
+#error "SYS_gettid unavailable"
+#endif
+#define gettid() ((pid_t)syscall(SYS_gettid))
+
#include "utils.h"
#include "timerlat_u.h"
--
2.43.0