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=G1CbmiTA; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 8AACC5A061C for ; Wed, 06 Nov 2024 22:16:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1730927782; bh=veXbYMzMTell0NKTD8JPjY7PabfNU9xxs+OUslCZJCs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G1CbmiTAkiOZrUwpvFVDWlNeP4Kj7xc1TJoPtQmRRMefqYCC9CL8bw1rJqi+cYdOX K2dYuDzLuqBL4obK5dZweZ98uBiCFT1/TskqL6b0iRokfNmdL7TU0eukL5kOfq7WtF r7pTXqvSjxjLGUvA5u7RWMXfBLGnBmfhB1Fa74eMMxnbgjSoE/t2Heimkt+/UViH/b rymzNaifLidCz4TBbpSWw3DkGevaXmofCvMxqzZCNCqyTrxidATPeRYGEnojxFVNVF DZYWNK0fa25eNm/yeUfKgLvNviSn0qQfw/0DZtBoz1qlDq7U/N8gVZCE9kVEVobHaz 6Er9u7FHUBL8g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XkJ0k6wkGz4wbx; Thu, 7 Nov 2024 08:16:22 +1100 (AEDT) Date: Thu, 7 Nov 2024 07:56:06 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 3/8] linux_dep: Move close_range() conditional handling to linux_dep.h Message-ID: References: <20241106065421.2568179-1-david@gibson.dropbear.id.au> <20241106065421.2568179-4-david@gibson.dropbear.id.au> <20241106201053.5eab2fd2@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2tbfeDmQ4LUlQFzs" Content-Disposition: inline In-Reply-To: <20241106201053.5eab2fd2@elisabeth> Message-ID-Hash: CVSR26UD4L2TESVENWRLGBIJJOD4OOIN X-Message-ID-Hash: CVSR26UD4L2TESVENWRLGBIJJOD4OOIN 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: passt-dev@passt.top 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: --2tbfeDmQ4LUlQFzs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 06, 2024 at 08:10:53PM +0100, Stefano Brivio wrote: > On Wed, 6 Nov 2024 17:54:16 +1100 > David Gibson wrote: >=20 > > util.h has some #ifdefs and weak definitions to handle compatibility wi= th > > various kernel versions. Move this to linux_dep.h which handles several > > other similar cases. > >=20 > > Signed-off-by: David Gibson > > --- > > linux_dep.h | 20 ++++++++++++++++++++ > > util.h | 19 ------------------- > > 2 files changed, 20 insertions(+), 19 deletions(-) > >=20 > > 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 > > =20 > > +#include > > + > > +#ifdef CLOSE_RANGE_UNSHARE /* Linux kernel >=3D 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 > > =20 > > #include "log.h" > > =20 > > @@ -158,24 +157,6 @@ int do_clone(int (*fn)(void *), char *stack_area, = size_t stack_size, int flags, > > =20 > > struct ctx; > > =20 > > -#ifdef CLOSE_RANGE_UNSHARE /* Linux kernel >=3D 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 > > - >=20 > This breaks the build on Alpine as well: >=20 > util.c: In function 'close_open_files': > util.c:729:22: error: implicit declaration of function 'close_range'; did= you mean 'SYS_close_range'? [-Wimplicit-function-declaration] > 729 | rc =3D close_range(STDERR_FILENO + 1, ~0U, CLOSE_= RANGE_UNSHARE); > | ^~~~~~~~~~~ > | SYS_close_range > util.c:729:58: error: 'CLOSE_RANGE_UNSHARE' undeclared (first use in this= function) > 729 | rc =3D close_range(STDERR_FILENO + 1, ~0U, CLOSE_= RANGE_UNSHARE); > | ^~~~~~~~= ~~~~~~~~~~~ >=20 > and is fixed by including "linux_dep.h" from util.c. Oops again, adjusted. --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --2tbfeDmQ4LUlQFzs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmcr1+UACgkQzQJF27ox 2Gchbg//a0ueyafE96Ru8uUMEytPbBVEiXFSgbeNOJME7kYI9qd7vXVHWkyYRKir efEQQhVSHvo9XI3o7ttAs+27vvQllCwXLcNXuLgumG0VJbgmOhh9y+XcnOkdyhiX AiIp4ZqcqikiirtW7Bd0vPUbmm0Qy+BrzGmz5rg7geDyE2xDCKGnC8knglTo8c39 aGkfZ4VZK1ZUgUAfB1Gh+kdd7BowLnUnrKyQNLE9/NcmLD3z9+UnETr6g1FfhkFe ICZrjuQ5ow96I06KAw9a1xWkTVzSSjl8EBZuaYhTqKJvXUcbwj8C/U7iYKxLRu73 spoScUz/c7p7MkAubmMNM967VtugTyPcV0EeWjUu8AE+cGFOoqnPwR3AexdSYnp0 LH9eGyroJ5SNHc55FZ04+ExBCJa3xn13mn+YurT3WdK6fh0YZUxZUSGIJziTc2AP gQYnzNE08KaIFcROpEOTtfIy/NfnJ6DbQ8dLmFdDf0HNjLtsW3eVvHlZelPCRZNs g2NHVrG3IWrFtuKh+j1yW2vWL8YztWHNzMZlF7TZ8hkWALmNQIvo/gp7uI1uRn8S NiCjsSfFdirP8s5Xna05vCeTf/UCvljfU0Me9NomTKlT/5JiuYRqvTMc7AMHiJQH WpTI+Jvisgs2lwHAzwcvezDwwSTkZ+uQ9eeQSISQ+bvIlDQsHlg= =JIyZ -----END PGP SIGNATURE----- --2tbfeDmQ4LUlQFzs--