This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCHv2] PowerPC - Add a faster way to read the Time Base register


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]