[Cbe-oss-dev] [PATCH 1/2]MARS/core: Tick counter api

Arnd Bergmann arnd at arndb.de
Tue Nov 25 07:38:14 EST 2008


On Monday 24 November 2008, Yuji Mano wrote:
> It's defined in <ppu_intrinsics.h>
> Documented in Language_Extensions_for_CBEA_2.4.pdf - page 90
> 
> #ifdef __powerpc64__
> #define __mftb() __extension__                  \
>   ({ unsigned long long result;                 \
>   __asm__ volatile ("mftb %0" : "=r" (result)); \
>   result; })
> #else
> #define __mftb() __extension__                  \
>   ({ unsigned long long result;                 \
>   unsigned long t;                              \
>   __asm__ volatile ("1:\n"                      \
>                     "\tmftbu %0\n"              \
>                     "\tmftb %L0\n"              \
>                     "\tmftbu %1\n"              \
>                     "\tcmpw %0,%1\n"            \
>                     "\tbne 1b"                  \
>                     : "=r" (result), "=r" (t)); \
>   result; })
> #endif /* __powerpc64__ */
> 
> 
> > Does it have the fixup for the cell erratum reading the time base?
> 
> Maybe Andrew Pinski or someone more familiar with this has the answer?
> 

The 32 bit version is ok, the 64 bit version is not. In general, it's much
easier to just use the gettimeofday() libc function, which is almost as
fast, and is guaranteed to work correctly.

In general, functions named __foo are internal to the implementation and
should not be used directly.

	Arnd <><


More information about the cbe-oss-dev mailing list