mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-12 16:06:42 +02:00
76 lines
2.3 KiB
Diff
76 lines
2.3 KiB
Diff
Patch-Source: https://github.com/lpereira/lwan/commit/870a8aa013544b944db15abf484690b5fb0b88be
|
|
From 870a8aa013544b944db15abf484690b5fb0b88be Mon Sep 17 00:00:00 2001
|
|
From: Leandro Pereira <leandro@hardinfo.org>
|
|
Date: Wed, 9 Oct 2019 22:03:06 -0700
|
|
Subject: [PATCH] Only provide gettid() implementation if not available in libc
|
|
|
|
Newer glibc provides a wrapper for this syscall now.
|
|
---
|
|
CMakeLists.txt | 1 +
|
|
src/cmake/lwan-build-config.h.cmake | 1 +
|
|
src/lib/missing.c | 6 +++++-
|
|
src/lib/missing/sys/types.h | 4 +++-
|
|
4 files changed, 10 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 8266609..7028963 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -85,6 +85,7 @@ check_function_exists(readahead HAS_READAHEAD)
|
|
check_function_exists(mkostemp HAS_MKOSTEMP)
|
|
check_function_exists(clock_gettime HAS_CLOCK_GETTIME)
|
|
check_function_exists(pthread_barrier_init HAS_PTHREADBARRIER)
|
|
+check_function_exists(gettid HAVE_GETTID)
|
|
|
|
if (NOT HAS_CLOCK_GETTIME AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
list(APPEND ADDITIONAL_LIBRARIES rt)
|
|
diff --git a/src/cmake/lwan-build-config.h.cmake b/src/cmake/lwan-build-config.h.cmake
|
|
index 4708ed5..3d80c20 100644
|
|
--- a/src/cmake/lwan-build-config.h.cmake
|
|
+++ b/src/cmake/lwan-build-config.h.cmake
|
|
@@ -30,6 +30,7 @@
|
|
#cmakedefine HAS_READAHEAD
|
|
#cmakedefine HAS_REALLOCARRAY
|
|
#cmakedefine HAS_MKOSTEMP
|
|
+#cmakedefine HAVE_GETTID
|
|
|
|
/* Compiler builtins for specific CPU instruction support */
|
|
#cmakedefine HAVE_BUILTIN_CLZLL
|
|
diff --git a/src/lib/missing.c b/src/lib/missing.c
|
|
index 22dddaa..c3b5a4b 100644
|
|
--- a/src/lib/missing.c
|
|
+++ b/src/lib/missing.c
|
|
@@ -351,13 +351,17 @@ proc_pidpath(pid_t pid, void *buffer, size_t buffersize)
|
|
#endif
|
|
|
|
#if defined(__linux__)
|
|
+
|
|
+#if !defined(HAVE_GETTID)
|
|
#include <sys/syscall.h>
|
|
|
|
-long
|
|
+pid_t
|
|
gettid(void)
|
|
{
|
|
- return syscall(SYS_gettid);
|
|
+ return (pid_t)syscall(SYS_gettid);
|
|
}
|
|
+#endif
|
|
+
|
|
#elif defined(__FreeBSD__)
|
|
#include <sys/thr.h>
|
|
|
|
diff --git a/src/lib/missing/sys/types.h b/src/lib/missing/sys/types.h
|
|
index f178de8..cdc0658 100644
|
|
--- a/src/lib/missing/sys/types.h
|
|
+++ b/src/lib/missing/sys/types.h
|
|
@@ -22,6 +22,8 @@
|
|
#ifndef MISSING_SYS_TYPES_H
|
|
#define MISSING_SYS_TYPES_H
|
|
|
|
-long gettid(void);
|
|
+#ifndef HAVE_GETTID
|
|
+pid_t gettid(void);
|
|
+#endif
|
|
|
|
#endif
|