From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=Nk8GZPxr; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D45495A061F for ; Wed, 06 Nov 2024 07:54:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1730876064; bh=lPnpl2g2jL5GMAPuhf1Jw6FkB/fD0kwj+0LYowXfGpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nk8GZPxrKapF5zF/5bKRzeTXL9/Uk9HqigT38AsMLLY8z2mTuKESRzGTW3Rc7XJnz TAAbNhecKoQ2Kvd9Qpzi7VqOkZBYi5acmf4hbrWz5SdpwmWcMakQvRXr1mQuGGJ/IK dAB1rfmYfyocI1TSJC/EZ20+dp7femNF2gCBp2WDam37RzbhsNEBFolx2dJAcSIyB3 MAamqY/gAvmbM5DFdpohKw2yNDHbhJbzxqP80hEuJw8qWMIBGJ4l5f/fttXNGobgMl LLz1aAkXgE0HAMlyJGx0adotgIVfpkar4kLxQBKiRz9F7ymuans2ocY2rmonRR9Nnj 19cz7Rk1c8lCg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Xjwt80kKzz4xCV; Wed, 6 Nov 2024 17:54:24 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 3/8] linux_dep: Move close_range() conditional handling to linux_dep.h Date: Wed, 6 Nov 2024 17:54:16 +1100 Message-ID: <20241106065421.2568179-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106065421.2568179-1-david@gibson.dropbear.id.au> References: <20241106065421.2568179-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: EVEUL24VD7XICPO7ECRYN3A6ZGG652MA X-Message-ID-Hash: EVEUL24VD7XICPO7ECRYN3A6ZGG652MA X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: util.h has some #ifdefs and weak definitions to handle compatibility with various kernel versions. Move this to linux_dep.h which handles several other similar cases. Signed-off-by: David Gibson --- linux_dep.h | 20 ++++++++++++++++++++ util.h | 19 ------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/linux_dep.h b/linux_dep.h index eae9c3c..3a41e42 100644 --- a/linux_dep.h +++ b/linux_dep.h @@ -125,4 +125,24 @@ struct tcp_info_linux { #define FALLOC_FL_COLLAPSE_RANGE 0x08 #endif +#include + +#ifdef CLOSE_RANGE_UNSHARE /* Linux kernel >= 5.9 */ +/* glibc < 2.34 and musl as of 1.2.5 need these */ +#ifndef SYS_close_range +#define SYS_close_range 436 +#endif +__attribute__ ((weak)) +/* cppcheck-suppress funcArgNamesDifferent */ +int close_range(unsigned int first, unsigned int last, int flags) { + return syscall(SYS_close_range, first, last, flags); +} +#else +/* No reasonable fallback option */ +/* cppcheck-suppress funcArgNamesDifferent */ +int close_range(unsigned int first, unsigned int last, int flags) { + return 0; +} +#endif + #endif /* LINUX_DEP_H */ diff --git a/util.h b/util.h index 2858b10..fdc3af8 100644 --- a/util.h +++ b/util.h @@ -17,7 +17,6 @@ #include #include #include -#include #include "log.h" @@ -158,24 +157,6 @@ int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags, struct ctx; -#ifdef CLOSE_RANGE_UNSHARE /* Linux kernel >= 5.9 */ -/* glibc < 2.34 and musl as of 1.2.5 need these */ -#ifndef SYS_close_range -#define SYS_close_range 436 -#endif -__attribute__ ((weak)) -/* cppcheck-suppress funcArgNamesDifferent */ -int close_range(unsigned int first, unsigned int last, int flags) { - return syscall(SYS_close_range, first, last, flags); -} -#else -/* No reasonable fallback option */ -/* cppcheck-suppress funcArgNamesDifferent */ -int close_range(unsigned int first, unsigned int last, int flags) { - return 0; -} -#endif - int sock_l4_sa(const struct ctx *c, enum epoll_type type, const void *sa, socklen_t sl, const char *ifname, bool v6only, uint32_t data); -- 2.47.0