From 22e6e65b1b7ef6459f515096b7767e9cea0b6b8a Mon Sep 17 00:00:00 2001 From: Klemens Morgenstern Date: Tue, 2 Jul 2024 16:33:43 +0800 Subject: [PATCH] added musl workaround. --- src/posix/close_handles.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/posix/close_handles.cpp b/src/posix/close_handles.cpp index 1603467c5..f4892f566 100644 --- a/src/posix/close_handles.cpp +++ b/src/posix/close_handles.cpp @@ -12,6 +12,7 @@ #include #include +#include // linux has close_range since 5.19 @@ -44,11 +45,35 @@ int fdwalk(int (*func)(void *, int), void *cd); #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0) // kernel has close_range +#include +#if (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 34) // glibc is compiled with close_range support // https://man7.org/linux/man-pages/man2/close_range.2.html + #include -#define BOOST_PROCESS_V2_HAS_CLOSE_RANGE 1 +#define BOOST_PROCESS_V2_HAS_CLOSE_RANGE 1 +#else + +#include + +#if defined(SYS_close_range) + +#define BOOST_PROCESS_V2_HAS_CLOSE_RANGE 1 +int close_range(unsigned int first, unsigned int last, int flags) +{ + return ::syscall(SYS_close_range, first, last, flags); +} + +#else + +#include + +#endif + +#endif + + #else #include @@ -56,11 +81,11 @@ int fdwalk(int (*func)(void *, int), void *cd); #endif #else - #include #endif + BOOST_PROCESS_V2_BEGIN_NAMESPACE namespace posix