Re: [REVIEW] Hide BIT_* macros from userland code

From: Shawn Webb <shawn.webb_at_hardenedbsd.org>
Date: Thu, 02 Dec 2021 16:46:48 UTC
Hey Stefan,

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=259787
> for an example of such a problem.

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.

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.)

Thanks,

-- 
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc