Thanks, I've looked at the code of do_div on PPC, and it uses % and /. Will it still work?
Also, I tried to use do_div on i386 (kernel 2.4.18), and I get wrong answer. Attached is a small test program, where do_div is the version from the i386 sources, and do_div1 is the version from PPC sources. The first one give wrong answer, while the second one works fine. What am I missing? Will the code in v4l2 that uses do_div works on Intel platforms? Thanks, Ilan Gerd Knorr wrote: >> /lib/modules/2.4.16/kernel/drivers/media/video/videodevX.o: unresolved >> symbol __udivdi3 >> /lib/modules/2.4.16/kernel/drivers/media/video/videodevX.o: unresolved >> symbol __umoddi3 > > > libgcc functions for 64bit math, which are not present in the kernel > because it isn't linked against libgcc. > > >> I see in videodevX.c that the function v4l2_math_div6432(...) I see that >> for intel cpus, there is an assembly code, and for others, a use of the >> '/' and '%', can this be the problem? > > > Yes. > > The modules in http://bytesex.org/patches/12_v4l2-2.4.19-pre2.diff.gz > have this fixed, they use the kernel functions for 64bit division. > > Gerd > -- Ilan Finci Engineering Manager Advanced Technology Development MobilEye Vision Technologies Ltd 24 Mishol Hadkalim st. Jerusalem, 97278, Israel Tel: 972-2-5866989 ext. 105 Fax: 972-2-5867720 E-Fax: 1-801-912-3251 Email: mailto:[EMAIL PROTECTED] http://www.mobileye.com
#define do_div(n,base) ({ \
unsigned long __upper, __low, __high, __mod; \
asm("":"=a" (__low), "=d" (__high):"A" (n)); \
__upper = __high; \
if (__high) { \
__upper = __high % (base); \
__high = __high / (base); \
} \
asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (base), "0" (__low), "1"
(__upper)); \
asm("":"=A" (n):"a" (__low),"d" (__high)); \
__mod; \
})
#define do_div1(n,base) ({ \
int __res; \
__res = ((unsigned long) n) % (unsigned) base; \
n = ((unsigned long) n) / (unsigned) base; \
__res; })
int main()
{
unsigned long a = 14;
unsigned long b = 5;
unsigned long c = 0;
printf("a = %u, b = %u, c = %u\n", a, b, c);
c = do_div(a, b);
printf("a = %u, b = %u, c = %u\n", a, b, c);
a = 14;
c = do_div1(a, b);
printf("a = %u, b = %u, c = %u\n", a, b, c);
return 0;
}
smime.p7s
Description: S/MIME Cryptographic Signature
