1 << 31 redux

Kyle Evans kevans91 at ksu.edu
Sat Jan 13 17:34:41 UTC 2018


On Thu, Jan 11, 2018 at 6:03 AM, Eitan Adler <lists at eitanadler.com> wrote:
> Hi all,
>
> A few years ago I fixed most of the cases where we used 1 << 31 in FreeBSD.
> This expression is illegal in C. Since then the issue has arisen again.
>
> https://reviews.freebsd.org/D13858 fixed most of the non-contrib cases.
>
> I'd also like to see if we could find some more general solution, be it a
> compiler warning, bit set macro, or otherwise.
>

For what it's worth, I've really come to like and appreciate NetBSD's
approach with __BIT/__BITS. See [1] for implementation, [2] for usage.

[1] http://src.illumos.org/source/xref/netbsd-src/sys/sys/cdefs.h#577
[2] http://src.illumos.org/source/xref/netbsd-src/sys/arch/arm/sunxi/sunxi_usbphy.c#L44


More information about the freebsd-hackers mailing list