Re: a question about style(9) and inline

From: Warner Losh <imp_at_bsdimp.com>
Date: Wed, 13 Aug 2025 17:43:44 UTC
On Wed, Aug 13, 2025 at 11:32 AM Steve Kargl <
sgk@troutmask.apl.washington.edu> wrote:

> In looking at lib/msun/math_private, one finds
>
> static __inline float complex
> static __inline double complex
> static __inline long double complex
> static inline double
> static inline float
> static inline long double
> static __inline int
> static __inline int
> static __inline int
> static inline int32_t
> static inline int32_t
>
> style(9) seems to not contain any preference with respect
> to __inline versus inline.  As a matter of consistency,
> I would like to use whatever is the preferred keyword.
> So, which should be used.
>

We generally have static __inline, though the reasons for that are
historical. We originally did it to support building FreeBSD with a K&R
compiler.  Now, we've narrowed the scope of K&R support so we only really
require it for public files since we support K&R compilers that are like
how gcc implemented this (which basically is to have ansi keywords in the
identifier space). In that environment, __inline is an extension. In C
code, this is just a compiler extension meaning the same thing as inline.
For C++ mode, we redefine __inline to inline. And we have some vestigial
support for doing the same for the C compiler that doesn't support __inline.

However, I did a bit of a survey just now, and more recently we've given up
on that and just use a raw inline by and large. With __inline being a
legacy item.

In this context, though, math_private.h isn't public, so I'd just use
inline. It's ancient enough that the old-school considerations mandated
__inline (not least because bde favored building with such compilers). Now,
I don't think it matters anymore, and we should just use the standard way
of doing it.

Warner