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/