From 35300925c26ce9eba9f4f1c9a4181708da771392 Mon Sep 17 00:00:00 2001
From: Honggang LI <honggangli@163.com>
Date: Tue, 12 Jul 2022 10:15:36 +0800
Subject: [PATCH] Replace gettid() with syscall(SYS_gettid)

Remove gettid() to address a backport issue for gazelle library.

Signed-off-by: Honggang LI <honggangli@163.com>
---
 src/include/arch/cc.h | 4 ++--
 src/include/lwiplog.h | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/include/arch/cc.h b/src/include/arch/cc.h
index 222b0c9..10d667b 100644
--- a/src/include/arch/cc.h
+++ b/src/include/arch/cc.h
@@ -62,7 +62,7 @@ void alloc_memp_##name##_base(void) \
     memp_pools[MEMP_##name] = &memp_ ## name; \
     \
     char mpname[MEMZONE_NAMESIZE] = {0}; \
-    snprintf(mpname, MEMZONE_NAMESIZE, "%d_%s", gettid(), #name); \
+    snprintf(mpname, MEMZONE_NAMESIZE, "%d_%s", (int)syscall(SYS_gettid), #name); \
     memp_memory_##name##_base = \
         sys_hugepage_malloc(mpname, LWIP_MEM_ALIGN_BUFFER(__size)); \
     memp_pools[MEMP_##name]->base = memp_memory_##name##_base; \
@@ -73,7 +73,7 @@ PER_THREAD uint8_t *variable_name; \
 void alloc_memory_##variable_name(void) \
 { \
     char mpname[MEMZONE_NAMESIZE] = {0}; \
-    snprintf(mpname, MEMZONE_NAMESIZE, "%d_%s", gettid(), #variable_name); \
+    snprintf(mpname, MEMZONE_NAMESIZE, "%d_%s", (int)syscall(SYS_gettid), #variable_name); \
     (variable_name) = \
         sys_hugepage_malloc(mpname, LWIP_MEM_ALIGN_BUFFER(size)); \
 }
diff --git a/src/include/lwiplog.h b/src/include/lwiplog.h
index 6fccac8..011ed21 100644
--- a/src/include/lwiplog.h
+++ b/src/include/lwiplog.h
@@ -35,13 +35,12 @@
 
 #include <stdio.h>
 #include <sys/syscall.h>
+#include <unistd.h>
 
 #include <rte_log.h>
 
 #include "lwipopts.h"
 
-extern int gettid(void);
-
 #if USE_DPDK_LOG
 
 #define LWIP_LOG_WARN   LWIP_DBG_LEVEL_WARNING
-- 
2.31.1

