Re: git: ce9e720af2f8 - main - <sys/_pv_entry>: Add a fallback for __LONG_WIDTH__ for older compilers.

From: Warner Losh <imp_at_bsdimp.com>
Date: Fri, 07 Oct 2022 20:50:23 UTC
Hey John,

On Fri, Oct 7, 2022 at 2:43 PM John Baldwin <jhb@freebsd.org> wrote:

> On 10/7/22 1:32 PM, John Baldwin wrote:
> > The branch main has been updated by jhb:
> >
> > URL:
> https://cgit.FreeBSD.org/src/commit/?id=ce9e720af2f8fa378e36134bab8a82ebf67c159d
> >
> > commit ce9e720af2f8fa378e36134bab8a82ebf67c159d
> > Author:     John Baldwin <jhb@FreeBSD.org>
> > AuthorDate: 2022-10-07 19:44:31 +0000
> > Commit:     John Baldwin <jhb@FreeBSD.org>
> > CommitDate: 2022-10-07 19:44:31 +0000
> >
> >      <sys/_pv_entry>: Add a fallback for __LONG_WIDTH__ for older
> compilers.
> >
> >      clang only includes a __LONG_WIDTH__ builtin in clang 14 and later.
> > ---
> >   sys/sys/_pv_entry.h | 5 +++++
> >   1 file changed, 5 insertions(+)
> >
> > diff --git a/sys/sys/_pv_entry.h b/sys/sys/_pv_entry.h
> > index 411643cf49ec..3cd0d9c687f6 100644
> > --- a/sys/sys/_pv_entry.h
> > +++ b/sys/sys/_pv_entry.h
> > @@ -77,6 +77,11 @@ typedef struct pv_entry {
> >   #error Unsupported page size
> >   #endif
> >
> > +/* Support clang < 14 */
> > +#ifndef __LONG_WIDTH__
> > +#define      __LONG_WIDTH__  (__CHAR_BIT__ * __SIZEOF_LONG__)
> > +#endif
> > +
>
> This was the smallest change to fix CI breakage.  However, we may want to
> do
> this differently.  We could perhaps add this fallback for __LONG_WIDTH__ to
> <sys/cdefs.h>, or we could change sys/_pv_entry.h to use the expanded form
> always (or pick a different spelling?)
>

I'm inclined to move those 5 lines to sys/cdefs.h since that file generally
tries to provide
either a FreeBSD-specific spelling of compiler-specific things, or provides
the standard
thing when that's not available. __LONG_WIDTH__ is trending towards
standardization,
imho, so it may make sense to standardize FreeBSD's uses there as well.

Warner