From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=new2025; t=1753999553; bh=EaBcLqZ+g9AmXJAITsOVT9+ECtwGaBHcu2NblWWO5q4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID: Date:From:Reply-To:Subject:To:Cc:In-Reply-To:References: Resent-Date:Resent-From:Resent-To:Resent-Cc:User-Agent: Content-Type:Content-Transfer-Encoding; b=vv7SsqlBvIaoFwbdySO9bO7A9GqmRlUy2CuJBI5vKYHtufOTGic4JwmHXrf7eYXtH Dtrzythgcv5a33ALjwMsVLgjRxzbCMF8G/TWaHX+rG/6TNH4bw1Gl4t5u4TZdGAg5e /rQ6k7tpWuRa3Zz4tDtfV+j84wQtZRJAlh0Xr1rZcs6E7HkEY4g6qHmLGGEmeEupXX 3bApdAmehYmBam2/7y6+YSk1Uwh7iou/OeoaIGnNRpsH0LgjFJcSn/wwEe56yHgAvh M8Nfl/KRBEYvVhHH3RzDa8I+55TBz1OBHwr8EKDgRI5yOd9/EpRY6euxhOHYUwM9X7 ZygSjS8xcGS3w== Received: from localhost.localdomain (unknown [68.183.184.174]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id 7F2B93126ED7; Thu, 31 Jul 2025 22:05:52 +0000 (UTC) From: Alviro Iskandar Setiawan To: Ammar Faizi Cc: Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on older glibc version Date: Fri, 1 Aug 2025 05:05:45 +0700 Message-Id: <20250731220546.303497-2-alviro.iskandar@gnuweeb.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250731220546.303497-1-alviro.iskandar@gnuweeb.org> References: <20250731220546.303497-1-alviro.iskandar@gnuweeb.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: Compiling on GNU CC version 8.5.0 20210514 (Red Hat 8.5.0-26) with glibc version 2.28 throws this error: src/gwproxy/log.c: In function ‘__pr_log’: src/gwproxy/log.c:51:56: warning: implicit declaration of function ‘gettid’; \ did you mean ‘getgid’? [-Wimplicit-function-declaration] fprintf(handle, "[%s][%s][%08d]: %s\n", time_buf, ls, gettid(), pb); ^~~~~~ getgid src/gwproxy/log.c:51: undefined reference to `gettid' collect2: error: ld returned 1 exit status Fix it by defining our own `__sys_gettid()`. Signed-off-by: Alviro Iskandar Setiawan --- src/gwproxy/log.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gwproxy/log.c b/src/gwproxy/log.c index 95d1930..574c5e0 100644 --- a/src/gwproxy/log.c +++ b/src/gwproxy/log.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -7,6 +8,11 @@ #include #include +static inline pid_t __sys_gettid(void) +{ + return (pid_t)__do_syscall0(__NR_gettid); +} + __attribute__((__format__(printf, 3, 4))) void __pr_log(FILE *handle, int level, const char *fmt, ...) { @@ -48,7 +54,7 @@ void __pr_log(FILE *handle, int level, const char *fmt, ...) else time_buf[0] = '\0'; - fprintf(handle, "[%s][%s][%08d]: %s\n", time_buf, ls, gettid(), pb); + fprintf(handle, "[%s][%s][%08d]: %s\n", time_buf, ls, __sys_gettid(), pb); if (unlikely(pb != loc_buf)) free(pb); out: -- Alviro Iskandar Setiawan