Re: can someone explain "inline" once and for all?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 19 Jan 2007, Pekka Enberg wrote:

> On 1/19/07, Robert P. J. Day <[email protected]> wrote:
> > is there a simple explanation for how to *properly* define inline
> > routines in the kernel?  and maybe this can be added to the
> > CodingStyle guide (he mused, wistfully).
>
> AFAIK __always_inline is the only reliable way to force inlining
> where it matters for correctness (for example, when playing tricks
> with __builtin_return_address like we do in the slab).
>
> Anything else is just a hint to the compiler that might be ignored
> if the optimizer thinks it knows better.

  oh, *that* part i knew.  what i don't understand is the difference
between "inline", "__inline" and "__inline__".  you can see in
include/linux/compiler-gcc4.h:

#ifdef CONFIG_FORCED_INLINING
# undef inline
# undef __inline__
# undef __inline
# define inline                 inline          __attribute__((always_inline))
# define __inline__             __inline__      __attribute__((always_inline))
# define __inline               __inline        __attribute__((always_inline))
#endif

  so that header file certainly suggests that there's some sort of
difference.  after which it gets even more confusing as various macros
seem to mix and match:

  drivers/cdrom/sbpcd.c:#define INLINE inline
  arch/arm/nwfpe/ARM-gcc.h:#define INLINE extern __inline__
  arch/cris/arch-v10/kernel/fasttimer.c:#define __INLINE__ inline
  arch/alpha/mm/fault.c:#define __EXTERN_INLINE inline
  ... etc etc ...

  i mean, how many different kinds of inline *are* there?

rday

p.s.  apparently, some of the alpha people are less than thrilled with
the situation:

include/asm-alpha/compiler.h:
-----------------------------

#ifdef __KERNEL__
/* Some idiots over in <linux/compiler.h> thought inline should imply
   always_inline.  This breaks stuff.  We'll include this file whenever
   we run into such problems.  */

#include <linux/compiler.h>
#undef inline
#undef __inline__
#undef __inline
#undef __always_inline
#define __always_inline         inline __attribute__((always_inline))

#endif /* __KERNEL__ */




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux