Hi Manish, On Thu, Sep 18, 2008 at 5:56 PM, Manish Katiyar <[EMAIL PROTECTED]> wrote:
> On Thu, Sep 18, 2008 at 5:22 PM, Sandeep K Sinha > <[EMAIL PROTECTED]> wrote: > > Hi Mahaveer, > > > > On Thu, Sep 18, 2008 at 3:59 PM, mahaveer darade <[EMAIL PROTECTED]> > > wrote: > >> > >> > >> On Thu, Sep 18, 2008 at 5:41 AM, Balraj Dahiya <[EMAIL PROTECTED]> > wrote: > >>> > >>> Hi All, > >>> > >>> Why we use Inline Functions in Linux Kernel? What is the importance of > >>> Inline functions and where we should use them? > >> > >> 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 > follow > > the standards, if specified. And "inline" keyword is stated quite clearly > > everywhere. And it has a very trivial meaning. > > > > Can you tell me any scenario, where you would mark a function to be > inline > > and not expect to be patched into the caller. > > Just write a function of 200 lines and then put it with inline. And > then check in gdb if it is actually inlined..... > I might agree that under certain circumstances, the compiler like gcc might decide not to inline the function. thanks for pointing it out though. But I did write a function with 200 lines and inlined it, gcc inlined it. bash-2.05b$ gcc a.c -Winline bash-2.05b$ My a.c is a function of around 200+ lines. It goes fine. Now a few lines from gcc: Note that certain usages in a function definition can make it unsuitable for inline substitution. Among these usages are: use of varargs, use of alloca, use of variable sized data types (see Variable Length<http://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html#Variable-Length>), use of computed goto (see Labels as Values<http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html#Labels-as-Values>), use of nonlocal goto, and nested functions (see Nested Functions<http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html#Nested-Functions>). Using -Winline will warn when a function marked inline could not be substituted, and will give the reason for the failure. Source: http://gcc.gnu.org/onlinedocs/gcc/Inline.html > > >> > >> > >>> > >>> > >>> Is it mandotary to put "static" before inline which declaring the > inline > >>> function? > >> > >> no its not mandatory. but if you do then you have to take care of couple > >> of thinks like if u take pointer to static inline functions then they > won't > >> match & code is going to behave differently. > > > > Do you intend to say that pointers to static inline functions won't match > ? > > And the behavior is unpredictable ? > > > >> > >> > >>> > >>> > >>> Can you please explain it to me? > >>> > >>> Thanks, > >>> Raj > >> > >> > >> > >> -- > >> --------------------------- > >> Thanks & Regards, > >> Mahaveer Darade > >> [EMAIL PROTECTED] > >> Mobile - 9970365267 > >> > >> > >> --- Dream it , Code it. > >> > > > > > > > > -- > > Regards, > > Sandeep. > > > > > > > > > > > > > > "To learn is to change. Education is a process that changes the learner." > > > -- Regards, Sandeep. "To learn is to change. Education is a process that changes the learner."
