diff -Naurp dietlibc-0.32-20090113/test/cycles.c dietlibc-0.32-20090113.oden/test/cycles.c --- dietlibc-0.32-20090113/test/cycles.c 2004-08-24 12:10:48.000000000 +0200 +++ dietlibc-0.32-20090113.oden/test/cycles.c 2009-01-28 22:26:54.000000000 +0100 @@ -12,6 +12,16 @@ asm volatile ("rdtsc" : "=a" (l), "=d" (h)); \ dst = (((uint64_t)h) << 32) | l; \ } while (0) +#elif defined (__powerpc64__) +#define RDTSC(dst) asm volatile ("mftb %0" : "=r" (dst)) +#elif defined (__powerpc__) +#define RDTSC(dst) do { \ + uint32_t chk, tbl, tbu; \ + /* The code below is as suggested in Motorola reference manual for 32 bits PPCs. */ \ + __asm__ __volatile__ ("1: mftbu %0; mftb %1; mftbu %2; cmpw %2,%0; bne 1b" \ + : "=r" (tbu), "=r" (tbl), "=r" (chk) ); \ + dst = ((uint64_t)tbu << 32) | tbl; \ +} while (0) #else #error "Unimplemented rdtsc" #endif