[PATCHv2] PowerPC - Add a faster way to read the Time Base register
Richard Henderson
rth@twiddle.net
Wed Feb 22 19:22:00 GMT 2012
On 02/22/12 09:49, Tulio Magno Quites Machado Filho wrote:
> + __ppc_timebase __tb;
> + __asm__ volatile (
> + "mfspr %[tb], 268\n"
> + : [tb]"=r" (__tb)
> + : );
> + return __tb;
> +}
> +#else /* not __powerpc64__ */
> +static inline __ppc_timebase
> +__ppc_get_timebase (void)
> +{
> + register unsigned long __tbu, __tbl, __tmp; \
> + __asm__ volatile (
> + "0:\n"
> + "mftbu %[tbu]\n"
> + "mftbl %[tbl]\n"
> + "mftbu %[tmp]\n"
> + "cmpw %[tbu], %[tmp]\n"
> + "bne- 0b\n"
> + : [tbu]"=r" (__tbu), [tbl]"=r" (__tbl), [tmp]"=r" (__tmp)
The only comment I have is that there's little point in using __ names for
the variables if the assembler labels are still in the user's namespace.
I'd suggest dropping the assembler labels and using %[0-9]; these asm blocks
are small enough that it may even be easier to read that way.
Otherwise the patch looks good.
r~
More information about the Libc-alpha
mailing list