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.
>
Hi,
'inline' is just to state that, the programmer wishes to inline the
function. The compiler at compile time decides whether or not a particular
function is to be actually inlined. If it decides against inlining then,
even the keyword cannot force it. The compiler gets to decide whether
inlining would really benefit the code. If the size of the inlined function
is too big then, it probably would be detrimental to the performance due to
increase in code size which would eventually cause cache misses.
> Can you tell me any scenario, where you would mark a function to be inline
> and not expect to be patched into the caller.
>
>
Apart from size constraints, directly recursive functions might also not be
inlined.
Also, without the 'static' keyword, the compiler will have to search outside
the file to patch the code. Hence, it might decide to ignore the 'inline'
keyword in such a case too.
Kindly CMIIW.
Best regards,
Pranav
pranavsbrain.peshwe.com