* [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on older glibc version
2025-07-31 22:05 [PATCH gwproxy v1 0/2] Fixes for older glibc version Alviro Iskandar Setiawan
@ 2025-07-31 22:05 ` Alviro Iskandar Setiawan
2025-07-31 22:17 ` Ammar Faizi
2025-07-31 22:05 ` [PATCH gwproxy v1 2/2] configure: Append `-lanl` lib to fix missing `getaddrinfo_a()` Alviro Iskandar Setiawan
1 sibling, 1 reply; 5+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 22:05 UTC (permalink / raw)
To: Ammar Faizi; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List
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 <alviro.iskandar@gnuweeb.org>
---
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 <gwproxy/common.h>
#include <gwproxy/log.h>
+#include <gwproxy/syscall.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
@@ -7,6 +8,11 @@
#include <unistd.h>
#include <stdarg.h>
+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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH gwproxy v1 2/2] configure: Append `-lanl` lib to fix missing `getaddrinfo_a()`
2025-07-31 22:05 [PATCH gwproxy v1 0/2] Fixes for older glibc version Alviro Iskandar Setiawan
2025-07-31 22:05 ` [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on " Alviro Iskandar Setiawan
@ 2025-07-31 22:05 ` Alviro Iskandar Setiawan
1 sibling, 0 replies; 5+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 22:05 UTC (permalink / raw)
To: Ammar Faizi; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List
Compiling on GNU CC version 8.5.0 20210514 (Red Hat 8.5.0-26) with
glibc version 2.28 throws this error:
undefined reference to `getaddrinfo_a'
As such, `getaddrinfo_a()` is never used in that environment eventhough
it's available. Append `-lanl` if on `getaddrinfo_a()` check.
Also, fix the warning about `_GNU_SOURCE` being redefined in the
`configure` script.
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
Makefile | 2 +-
configure | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index d0d6d85..6c2e9be 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,6 @@ ifndef OPTIMIZE
OPTIMIZE = -O2
endif
INCLUDE_FLAGS = -I./src/
-LIBS = -lpthread
DEPFLAGS = -MMD -MP -MF $@.d
LDFLAGS_SHARED = $(LDFLAGS) -shared
GWPROXY_DIR = ./src/gwproxy
@@ -80,6 +79,7 @@ config.make: configure
endif
endif
-include config.make
+LIBS=$(LIB_LDFLAGS)
ifeq ($(CONFIG_IO_URING),y)
GWPROXY_CC_SOURCES += $(GWPROXY_DIR)/ev/io_uring.c
diff --git a/configure b/configure
index 0b5815d..17bdf6f 100755
--- a/configure
+++ b/configure
@@ -356,20 +356,20 @@ fi;
# ------ Check for getaddrinfo_a() ------
cat > $tmp_c << EOF
-#define _GNU_SOURCE
#include <netdb.h>
int main(void)
{
struct sigevent ev;
- struct gaicb gc;
+ struct gaicb *gc = (void *)0;
getaddrinfo_a(GAI_NOWAIT, &gc, 1, &ev);
return 0;
}
EOF
l="Do we have getaddrinfo_a()?";
-if compile_cc "" "" "getaddrinfo_a()"; then
+if compile_cc "" "-lanl" "getaddrinfo_a()"; then
add_config "CONFIG_HAVE_GETADDRINFO_A";
print_supp "yes" "${l}";
+ LIB_LDFLAGS="${LIB_LDFLAGS} -lanl";
else
print_supp "no" "${l}";
fi;
--
Alviro Iskandar Setiawan
^ permalink raw reply related [flat|nested] 5+ messages in thread