Skip to contentSkip to conversation

strange code in linux kernel

DISCUSSION Rajat Jain 2 participants 2 messages Oct 6, 2009 – Oct 7, 2009

lore
Share & tools
lore

Rajat Jain

author
#0 lore raw

Hi List,

I found that there are some weird looking instances in kernel where a function has been DEFINED (as opposite to DECLARED) using and "extern" keyword. For e.g., the following code in arch/alpha/include/asm/io.h:

extern inline void __iomem *generic_ioportmap(unsigned long a)

{
        return alpha_mv.mv_ioportmap(a);
}

Using a definition along with extern does not make any sense to me. Can some one please enlighten what is its use / purpose?

Thanks,

Rajat Jain

--
To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to [email protected] Please read the FAQ at http://kernelnewbies.org/FAQ

#1 lore raw
Quoted 11 lines · Rajat Jain

I found that there are some weird looking instances in kernel where a function has been DEFINED (as opposite to DECLARED) using and "extern" keyword. For e.g., the following code in arch/alpha/include/asm/io.h:

extern inline void __iomem *generic_ioportmap(unsigned long a)

{
        return alpha_mv.mv_ioportmap(a);
}

Using a definition along with extern does not make any sense to me. Can some one please enlighten what is its use / purpose?

Note that at the same time an "inline" keyword has been used. You might want to refer to GCC's documentation in particular
<http://gcc.gnu.org/onlinedocs/gcc/Inline.html> for more information. Google also pointed to this site
<http://www.greenend.org.uk/rjk/2003/03/inline.html> which also might have some insight.

Signature · 4 lines
Best regards,                                         _     _
 .o. | Liege of Serenly Enlightened Majesty of      o' \,=./ `o
 ..o | Computer Science,  Michal "mina86" Nazarewicz   (o o)
 ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--