LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: "Robert P. J. Day" <rpjday@mindspring.com>
Cc: Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: can someone explain "inline" once and for all?
Date: Fri, 19 Jan 2007 15:15:03 -0200	[thread overview]
Message-ID: <orzm8f9bvs.fsf@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0701190645400.24224@CPE00045a9c397f-CM001225dbafb6> (Robert P. J. Day's message of "Fri\, 19 Jan 2007 06\:56\:54 -0500 \(EST\)")

On Jan 19, 2007, "Robert P. J. Day" <rpjday@mindspring.com> wrote:

>   first, there appear to be three possible ways of specifying an
> inline routine in the kernel source:

inline, __inline and __inline__ are equivalent as far as GCC is
concerned, as you've already figured out.

> i vaguely recall that this has something to do with a distinction
> between C99 inline and gcc inline

I suspect you're thinking of a different issue.

In C99, static inline means the same as in GNU89, non-static
non-extern inline means 'use this definition, that does not define
objects with static storage nor references identifiers with internal
linkage, for inlining or for a local definition, but make calls to it
fast and don't generate any out-of-line definition', and extern inline
means 'compile this code into a global out-of-line function, but also
inline it wherever it makes sense'.

In GNU89, static inline means 'compile this code into a local
out-of-line function if needed, but also inline it wherever it makes
sense', non-static non-extern inline means 'compile this code into a
global out-of-line function, but also inline it wherever it makes
sense', and extern inline means 'use this definition for inlining, but
don't generate any out-of-line definition; because either I have a
non-inline definition in this or in another translation unit, or I
want undefined-symbol errors at link time if inlining fails.'

So you see that the meaning of extern inline and non-extern inline are
also reversed comparing GNU89 with C99.  That's quite unfortunate,
and GNU libc went to some trouble to encapsulate the intended inline
meaning into preprocessor macros even in user headers, such that the
intended meaning is obtained regardless of the compiler version.

Fortunately, static inline is probably the most useful and thus common
case anyway.  Other constructs will work as in GNU89 up to GCC 4.3,
even with -std=c99, but the meaning of inline in C99 and GNU99 is
intended to be fixed to the C99 semantics in GCC 4.4, according to
http://gcc.gnu.org/ml/gcc/2006-11/msg00006.html

That's still a long way ahead (the 4.3 development cycle has just
started), but it wouldn't hurt to start fixing incompatibilities
sooner rather than later, and coming up with a clean and uniform set
of inline macros that express intended meaning for the kernel to use.

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

  parent reply	other threads:[~2007-01-19 17:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-19 11:56 Robert P. J. Day
2007-01-19 13:01 ` Pekka Enberg
2007-01-19 13:19   ` Robert P. J. Day
2007-01-19 14:13   ` Adrian Bunk
2007-01-19 14:44     ` Robert P. J. Day
2007-01-19 14:53     ` Robert P. J. Day
2007-01-19 13:37 ` Andreas Schwab
2007-01-19 13:48   ` Robert P. J. Day
2007-01-19 13:58     ` Andreas Schwab
2007-01-19 14:00       ` Robert P. J. Day
2007-01-19 17:15 ` Alexandre Oliva [this message]
2007-01-19 17:36   ` Adrian Bunk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=orzm8f9bvs.fsf@redhat.com \
    --to=aoliva@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpjday@mindspring.com \
    --subject='Re: can someone explain "inline" once and for all?' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).