error using unsigned long long not working in 2.4.x
hi i am writing a kernel 2.4.x driver and need to do maths on 64 bit ints (unsigned long long)
bcause you can not use the FPU
but when i insmod i get the error unresolved symbol __udivdi3 i need!! 64 bit ints
i have included the code
thank you
Quoted 8 lines · dave
hi i am writing a kernel 2.4.x driver and need to do maths on 64 bit ints (unsigned long long)
bcause you can not use the FPU
but when i insmod i get the error unresolved symbol__udivdi3i need!! 64 bit intsi have included the code
thank you
The original reason for Linux kernel not being linked with -lgcc where that routine is defined, is that of wanting to catch careless coding of 64-bit arithmetic in kernel. It does cause massiveish performance penalty in the system, if used unchecked in code fast paths.
If you can do it with at most 31 bit divider, and can handle
side-effectfull division, system has do_div() macro.
Use like:
#include <asm/div64.h> long long n, vco; long divisor; long remainder; n = vco; divisor = some_expression; remainder = do_div(n, divisor);
You will, most likely, ignore the remainder.
BECAUSE there is side-effect of modifying the dividend (n), you must use it like in this illustriation.
The divisor can not have value in excess of 2^31.
Also there are architectures which do not properly implement this routine, and do merely 32/32 division, where 64/32 is really wanted. (The i386 architecture does handle it.)
/Matti Aarnio
On Mon, 17 Mar 2003 21:44:16 -0800 "dave" <[email protected]> wrote:
| hi i am writing a kernel 2.4.x driver and need to do maths on 64 bit ints | (unsigned long long) | bcause you can not use the FPU | but when i insmod i get the error unresolved symbol __udivdi3 i need!! 64 | bit ints
Other alternatives are search the lkml archive for a patch from George Anzinger on 2003-mar-05,
subject: [PATCH] Functions to do easy scaled math.
or if all you need is 64-bit mul and div, and only during setup (when speed isn't a huge factor), you could use the divrem64() function in this sample /procfs module:
http://www.xenotime.net/linux/procfs_ex/procdiv64.c
--
~Randy