On Thu, 2008-09-18 at 17:22 +0530, Sandeep K Sinha wrote: > Hi Mahaveer, > > On Thu, Sep 18, 2008 at 3:59 PM, mahaveer darade > <mah.darade@xxxxxxxxx> wrote: > > > On Thu, Sep 18, 2008 at 5:41 AM, Balraj Dahiya > <dahbal76@xxxxxxxxx> wrote: > > Hi All, Why we use Inline Functions in Linux Kernel? > What is the importance of Inline functions and where > we should use them? BTW some functions (with inline-asm in them) must be "inlined" to avoid a stack frame. But that is only for arch-specific low-level functions necessary. Thus one either must rely on compiler-specific behavior or use #define. > its just a suggestion( not mandatory ) to compiler to > substitute code of function into caller. > there are plenty of scenarios to think of its usage. > > > What do you mean by its "not mandatory" ? Well, the compiler has to Exactly that. > follow the standards, if specified. And "inline" keyword is stated > quite clearly everywhere. And it has a very trivial meaning. Read chp. 6.7.4 of http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf: It is implementation-defined. That means that you must read the docs of the used compiler (and for the used version). In the extreme case: If a compiler simply doesn't implement it (and virtually ignores that keyword), it is OK as long as it's documented. BTW: A C compiler is also allowed to inline functions which are not explicitly marked inline. E.g. many gcc versions do this for exactly once called function (if the function is defined before it is used). > Can you tell me any scenario, where you would mark a function to be > inline and not expect to be patched into the caller. #1) Because the compiler decided in that file so. #2) Recursive functions?! Bernd -- Firmix Software GmbH http://www.firmix.at/ mobil: +43 664 4416156 fax: +43 1 7890849-55 Embedded Linux Development and Services -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ