Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Aug 2025 11:43:44 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        sgk@troutmask.apl.washington.edu
Cc:        freebsd-current@freebsd.org
Subject:   Re: a question about style(9) and inline
Message-ID:  <CANCZdfqM22c1h-wvGJAGmUWi8V0ZR1=b0aO_H_i%2BZkBoF60cnw@mail.gmail.com>
In-Reply-To: <aJzL8JUop1vDFPNJ@troutmask.apl.washington.edu>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
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

[-- Attachment #2 --]
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Aug 13, 2025 at 11:32 AM Steve Kargl &lt;<a href="mailto:sgk@troutmask.apl.washington.edu">sgk@troutmask.apl.washington.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In looking at lib/msun/math_private, one finds<br>
<br>
static __inline float complex<br>
static __inline double complex<br>
static __inline long double complex<br>
static inline double<br>
static inline float<br>
static inline long double<br>
static __inline int<br>
static __inline int<br>
static __inline int<br>
static inline int32_t<br>
static inline int32_t<br>
<br>
style(9) seems to not contain any preference with respect<br>
to __inline versus inline.  As a matter of consistency,<br>
I would like to use whatever is the preferred keyword.<br>
So, which should be used.<br></blockquote><div><br></div><div>We generally have static __inline, though the reasons for that are historical. We originally did it to support building FreeBSD with a K&amp;R compiler.  Now, we&#39;ve narrowed the scope of K&amp;R support so we only really require it for public files since we support K&amp;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&#39;t support __inline.</div><div><br></div><div>However, I did a bit of a survey just now, and more recently we&#39;ve given up on that and just use a raw inline by and large. With __inline being a legacy item.</div><div><br></div><div>In this context, though, math_private.h isn&#39;t public, so I&#39;d just use inline. It&#39;s ancient enough that the old-school considerations mandated __inline (not least because bde favored building with such compilers). Now, I don&#39;t think it matters anymore, and we should just use the standard way of doing it.</div><div><br></div><div>Warner</div></div></div>
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfqM22c1h-wvGJAGmUWi8V0ZR1=b0aO_H_i%2BZkBoF60cnw>