c - What does __devexit mean in a function declaration? -
a driver looked @ has
static void __devexit rtsx_remove(struct pci_dev *pci)
what __devexit
mean in context of function definition? other functions i've seen have, @ most, static
, return type.
long-ish story short:
this macro expands set of gcc attributes. way of providing compiler special information various stuff in code, like, in case, function.
different compilers have different syntaxis purpose, isn't standartized. example, gcc uses attributes, other compilers use different constructs.
long-ish story long-ish:
so, i'm no linux kernel expert, judging source code, macro used hotplug. believe signifies function should specific device exiting.
for example, function provided seems set of hotplug functions working realtek pci-express card reader driver.
what macro do? well, let's take closer @ macro's definition:
#define __devexit __section(.devexit.text) __exitused __cold
the first part __section(.devexit.text)
:
# define __section(s) __attribute__ ((__section__(#s)))
as can see, creates __attribute__(__section__())
section name being ".devexit.text"
. means gcc compile assembly code of function attribute named section in compiled binary name .devexit.text
(instead of default section).
the second part __exitused
(defined if module
macro defined):
#define __exitused __used
and __used
is, depending on gcc version, defined either this:
# define __used __attribute__((__used__))
or this:
# define __used __attribute__((__unused__))
the former makes sure function has attribute compiled if not referenced anywhere. latter suppresses compiler warnings in same case, although doesn't affect compilation in way.
and, finally, __cold
:
#define __cold __attribute__((__cold__))
this attribute informs compiler function attribute not going called often, can optimize accordingly.
sooo, have in end? looks functions marked __devexit
just functions aren't called often (if called @ all), , stuffed named section.
all source code taken here. looks macro has been removed linux kernel.
Comments
Post a Comment