Date: Fri, 3 Dec 2021 11:03:54 +0100 From: Stefan Esser <se@freebsd.org> To: Shawn Webb <shawn.webb@hardenedbsd.org> Cc: FreeBSD CURRENT <freebsd-current@freebsd.org> Subject: Re: [REVIEW] Hide BIT_* macros from userland code Message-ID: <77845d03-6351-8a8b-2eae-1db98f8a192c@freebsd.org> In-Reply-To: <20211202164648.276kuh3blin6b2wp@mutt-hbsd> References: <7d97e129-4aa7-aa98-dc91-e332a3da620f@freebsd.org> <20211202164648.276kuh3blin6b2wp@mutt-hbsd>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------7fJerW2eTavEse5JA9lhZC5g Content-Type: multipart/mixed; boundary="------------StiE8KZpu6BOYfw0r6NJz1bR"; protected-headers="v1" From: Stefan Esser <se@freebsd.org> To: Shawn Webb <shawn.webb@hardenedbsd.org> Cc: FreeBSD CURRENT <freebsd-current@freebsd.org> Message-ID: <77845d03-6351-8a8b-2eae-1db98f8a192c@freebsd.org> Subject: Re: [REVIEW] Hide BIT_* macros from userland code References: <7d97e129-4aa7-aa98-dc91-e332a3da620f@freebsd.org> <20211202164648.276kuh3blin6b2wp@mutt-hbsd> In-Reply-To: <20211202164648.276kuh3blin6b2wp@mutt-hbsd> --------------StiE8KZpu6BOYfw0r6NJz1bR Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=3D25978= 7 >> 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.) Hi Shawn, I have updated the patch set in review D33235 and have added you to the reviewer list. IMHO the approach proposed by Konstantin Belousov is better than the introduction of prefixed macro names for the userland. A simple #define _WANT_FREEBSD_BITSET makes the __BIT* macros available by their traditional names, no other changes are required in the code. 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. 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 ;-) ). And you are of course free to map __BIT* to any other prefixed name in a header file in your code ... 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. Regards, STefan --------------StiE8KZpu6BOYfw0r6NJz1bR-- --------------7fJerW2eTavEse5JA9lhZC5g Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAmGp64sFAwAAAAAACgkQR+u171r99URv wQgApvC3nHQqyAI7klB15zMEcgRyhqc334UCgBcFBg1uJhO5r/7Iw1n+dCaTGtfedhbAzmjNnULy 8MMaDJw96+Ze023dYJy9CcM8n3aBWfV43VlhWXzysJJQl9vz4thNCRajN1n1e6iyFHQhLdi4Yres FY0JwvLCfgye6YrAJYB0zz1M42VCaM1CFFFycR081YvUykFjJnJfG49BWYnBfuHkWdlUNcinNzCV 2XHA8t/4NNjRf6xImvy9LllG6L2GDv9pXI9U8a2nmHnS/6WS/yEtDvhvE6Wxq1GO5iomOlhqc8VP BvxtbgGTuR5lJbYTBC+/ws9I9+SW5WRmLE0Bh8DEFw== =gfdj -----END PGP SIGNATURE----- --------------7fJerW2eTavEse5JA9lhZC5g--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?77845d03-6351-8a8b-2eae-1db98f8a192c>