Date: Fri, 3 Dec 2021 08:30:01 -0500 From: Shawn Webb <shawn.webb@hardenedbsd.org> To: Stefan Esser <se@freebsd.org> Cc: FreeBSD CURRENT <freebsd-current@freebsd.org> Subject: Re: [REVIEW] Hide BIT_* macros from userland code Message-ID: <20211203133001.scaxfsnjy7voast6@mutt-hbsd> In-Reply-To: <77845d03-6351-8a8b-2eae-1db98f8a192c@freebsd.org> References: <7d97e129-4aa7-aa98-dc91-e332a3da620f@freebsd.org> <20211202164648.276kuh3blin6b2wp@mutt-hbsd> <77845d03-6351-8a8b-2eae-1db98f8a192c@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--qymcuzu56lw4m24j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 03, 2021 at 11:03:54AM +0100, Stefan Esser wrote: > Am 02.12.21 um 17:46 schrieb Shawn Webb: > > Hey Stefan, > >=20 > > On Thu, Dec 02, 2021 at 05:26:55PM +0100, Stefan Esser wrote: > >> I have created > >> > >> https://reviews.freebsd.org/D33235 > >> > >> to remove the BIT_* macros used in the kernel from the userland API. > >> > >> They conflict with differing definitions in some 3rd party code and > >> lead to compile issues in a number of ports (via CPU_* macros based > >> on the BIT_* macros). > >> > >> See PR259787 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D259787 > >> for an example of such a problem. > >=20 > > I recently was in a position to evaluate BIT_* macros for userland > > use. It was around the time when the conversation regarding hiding > > BIT_* from userland, which conversation caused me to find another > > solution. > >=20 > > I think such an API is incredibly useful, so I wonder if there's a way > > to satisfy both. For example, maybe prefix the userland side with a > > USERLAND_ or something similar? Kernel would use BIT_* and userland > > would use USERLAND_BIT_* (just spitballing, not actually advocating > > for "USERLAND_BIT_*" but rather just the idea of it.) >=20 > Hi Shawn, >=20 > I have updated the patch set in review D33235 and have added you to > the reviewer list. >=20 > IMHO the approach proposed by Konstantin Belousov is better than the > introduction of prefixed macro names for the userland. >=20 > A simple #define _WANT_FREEBSD_BITSET makes the __BIT* macros available > by their traditional names, no other changes are required in the code. >=20 > This does not solve the potential case of a program that wants to use > both the BSD and GLIBC variants of the macros in a single source file. > But I think that such a case is constructed and does not occur in > actual code. >=20 > And in any case, the IMHO __BIT* names are as good as the USERLAND_BIT* > names you suggest (and I understand that you did not want that specific > name - therefore a prefix of __ might be considered to match what you > proposed ;-) ). >=20 > And you are of course free to map __BIT* to any other prefixed name in > a header file in your code ... >=20 > An update of the bitset(9) man page might be a good idea, explaining > the visibility rules and _WANT_FREEBSD_BITSET for system utilities that > need to work with kernel style bitsets. Awesome. kib's suggestion makes sense here. And thanks for adding me to the review. I'll make sure to pay attention as it progresses. :-) Thanks again, --=20 Shawn Webb Cofounder / Security Engineer HardenedBSD https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/03A= 4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc --qymcuzu56lw4m24j Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEA6TL67gupaZ9nzhT/y5nonf44foFAmGqG9kACgkQ/y5nonf4 4fo+vA/7B48h4Dk5YDfATIpbnQEb7yDPSpLDjJxRwKijpsE+QfLQXHzXpXybMfxB 6xlHdCC+O1XnoQwMy8A/ZCulvNtRT+0l70cElhuXNiay/KHF7Q1XGYpFvOd01FRK qP9QC8s+lFehyn30kzdDChqegN9OPLwz9u6miQmX5qLyb0KSzJjFSA31mNPF8Fqy aMUmAiSWuR52AMgkpuR2lNTIzxDf7VrE+wFutoVXVG0OYxfzh4tst6zuzG/Tc4fh HbcS8gjuVq8jv5nCbYXa4umdXfLCzvt4kHLh7GUpTpx/ZuBUF6ClIQfiZE6llS/4 zVRAEasWuAOwIc6C/BT2/ZuEpfXohP1bqwrVnCexexYIVySh7I2y6+udMFnLwt73 vxHrtTwhbZeTGRHYvvglO3Jj7cRY1Q7bdM6Uih/Rc1HTKFIG/7p7ARdMY1nkr+VH lxBSLPdATOCSS1NYlTXzvRwk8oQACorBqQmqoB2p9+YclJoIEtb+JiZPYTQvXBQL ujWjT0ebc4ZRZoGLAp92rgGuPGGmsi4mHx13yXSlew7K8hXhJjeCC71/JWMnGM5h moDuetLnjJ8uwM5/oRVyigyA641gJb3lwMjYezfCiBKTwTBUKvJwD1kRjZY6r7Uv eWZoeRLKvGb0w+EppNXCmZEzJxOZtCLfuAyCthwSyMlVvUPTDic= =KuU3 -----END PGP SIGNATURE----- --qymcuzu56lw4m24j--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20211203133001.scaxfsnjy7voast6>