V4L2: __ucmpdi2 undefined on ppc

Segher Boessenkool segher at kernel.crashing.org
Wed Mar 5 09:43:25 EST 2008


>> Every occurrence of r7 here is wrong (and some of the r6).  Is there
>> any reason to do this in assembler code at all?
>
> The fact that the obvious C code generates ... a call to __ucmpdi2? :)

Hrm?  Here's the "obvious" C code, portable to all architectures
(modulo the specific types used, this isn't a proposed patch):


unsigned int ucmpdi2(unsigned long long a, unsigned long long b)
{
         unsigned long ahi, bhi, alo, blo;

         ahi = a >> 32;
         bhi = b >> 32;
         if (ahi < bhi)
                 return 0;
         if (ahi > bhi)
                 return 2;

         alo = a;
         blo = b;
         if (alo < blo)
                 return 0;
         if (alo > blo)
                 return 2;

         return 1;
}


(libgcc does it a bit differently, with unions and stuff).


Segher




More information about the Linuxppc-dev mailing list