[uClinux-dev] Re: [PATCH] m68k: merge mmu and non-mmu bitops.h

Greg Ungerer gerg at snapgear.com
Fri Jun 3 07:10:56 EDT 2011


Hi Finn,

On 03/06/11 21:02, Finn Thain wrote:
>> +#if defined(CONFIG_M68000) || defined(CONFIG_MCPU32) || defined(CONFIG_COLDFIRE)
>> +
>> +/*
>> + *     The newer ColdFire family members support a "bitrev" instruction
>> + *     and we can use that to implement a fast ffs. Older Coldfire parts,
>> + *     and normal 68000 parts don't have anything special, so we use the
>> + *     generic functions for those.
>> + */
>> +#if (defined(__mcfisaaplus__) || defined(__mcfisac__))&&  \
>> +    !defined(CONFIG_M68000)&&  !defined(CONFIG_MCPU32)
>
> Aren't the !defined(CONFIG_M68000)&&  !defined(CONFIG_MCPU32) terms
> redundant?

No, not in this case.

If we were compiling an image that could be run on any of ColdFire
or 68000 or CPU32 then we cannot compile in these specific ColdFire
optimized ffs and __ffs. The bitrev instruction only exists on ColdFire
and those that implement the ISA A+ and above instruction sets.
So to use them we must be only compiling for CONFIG_COLDFIRE.

Regards
Greg


> Finn
>
>> +static inline int __ffs(int x)
>> +{
>> +        __asm__ __volatile__ ("bitrev %0; ff1 %0"
>> +               : "=d" (x)
>> +               : "0" (x));
>> +        return x;
>> +}
>> +
>> +static inline int ffs(int x)
>> +{
>> +        if (!x)
>> +                return 0;
>> +       return __ffs(x) + 1;
>> +}
>> +
>> +#else
>> +#include<asm-generic/bitops/ffs.h>
>> +#include<asm-generic/bitops/__ffs.h>
>> +#endif
>> +
>> +#include<asm-generic/bitops/fls.h>
>> +#include<asm-generic/bitops/__fls.h>
>> +
>>   #else
>>
>
>
>




More information about the uClinux-dev mailing list