Results 1 to 3 of 3
Hi all!
I'm writing a LKM for my ARM/Linux 2.4.27 based server. I have downloaded the matching kernel code and also built my own armv5b GCC toolchain using the kegel ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-08-2010 #1Just Joined!
- Join Date
- Apr 2008
- Location
- Stockholm, Sweden
- Posts
- 4
bitops.h inline and extern has different names
Hi all!
I'm writing a LKM for my ARM/Linux 2.4.27 based server. I have downloaded the matching kernel code and also built my own armv5b GCC toolchain using the kegel crosstool. When I tried to load the module, insmod complained about "unresolved symbol" for "test_and_clear_bit" and some related functions. I traced those identifiers down to the asm/bitops.h include file and found that there where external declarations and matching inline function definitions with the difference that the inline has an "__" prefix. I don't really understand how this is supposed to work. After googling for a while without finding any explanation I tried adding these lines of code before the #include statements:
After this change the insmod works and the module works too however the solution is most likely not the one that the kernel developers intended. Could someone give me some tips on what I may have done wrong?Code:#define test_and_clear_bit __test_and_clear_bit #define test_and_set_bit __test_and_set_bit #define set_bit __set_bit #define clear_bit __clear_bit #include <asm/bitops.h>
(Yes, I do have optimization turned on: -O -O2).
Thanks,
Mats
- 03-08-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,233
Without looking at the headers you are using where the extern and inlines were declared/defined I can't say, though it is likely due to a conditional compilation switch that pulled in the inline functions, yet your code was using the extern ones which haven't been implemented in your system. FWIW, you probably did, more or less, "the right thing" to get this to work. As the saying goes, if it ain't broke, don't fix it.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 03-12-2010 #3Just Joined!
- Join Date
- Apr 2008
- Location
- Stockholm, Sweden
- Posts
- 4
@Rubberman: Hmm... Thanks for the answer but my quriosity is not satisfied...
I didn't use any (related) identifier directly in my code so they must have been used by other inline code in the standard network related includes I use in the network driver I'm developing.
I have traced the source of the problem further and found that (among other) it was the inline function call:
that inside its definition in netdevice.h:netif_wake_queue(dev);
uses a function and not the macro. In bitops.h the declaration is as follows:static inline void netif_wake_queue(struct net_device *dev)
{
if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state))
__netif_schedule(dev);
}
The comment suggests that the prototype is only there to avoid compiler warnings but it's really the inline that is supposed to be used. I can't see how this is supposed to happen... Any compiler wizard out there to my rescue?/*
* Function prototypes to keep gcc -Wall happy.
*/
// ...
extern int test_and_clear_bit(int nr, volatile void * addr);
static inline int __test_and_clear_bit(int nr, volatile void *addr)
{
...
}
Thanks // Mats


Reply With Quote
