comparison common.h @ 2727:41ae70d266fd libavcodec

START/STOP_TIMER for ppc32 by (Luca Barbato: lu_zero, gentoo org)
author michael
date Sat, 21 May 2005 21:37:07 +0000
parents 08cce4785567
children 3dc4bfdda4b3
comparison
equal deleted inserted replaced
2726:77ba1f653619 2727:41ae70d266fd
454 (a)=(b);\ 454 (a)=(b);\
455 (c)=(d);\ 455 (c)=(d);\
456 } 456 }
457 #endif 457 #endif
458 458
459 #if defined(ARCH_X86) || defined(ARCH_X86_64) 459 #if defined(ARCH_X86) || defined(ARCH_X86_64) || defined(ARCH_POWERPC)
460 #if defined(ARCH_X86_64) 460 #if defined(ARCH_X86_64)
461 static inline uint64_t rdtsc(void) 461 static inline uint64_t read_time(void)
462 { 462 {
463 uint64_t a, d; 463 uint64_t a, d;
464 asm volatile( "rdtsc\n\t" 464 asm volatile( "rdtsc\n\t"
465 : "=a" (a), "=d" (d) 465 : "=a" (a), "=d" (d)
466 ); 466 );
467 return (d << 32) | (a & 0xffffffff); 467 return (d << 32) | (a & 0xffffffff);
468 } 468 }
469 #else 469 #elif defined(ARCH_X86)
470 static inline long long rdtsc(void) 470 static inline long long read_time(void)
471 { 471 {
472 long long l; 472 long long l;
473 asm volatile( "rdtsc\n\t" 473 asm volatile( "rdtsc\n\t"
474 : "=A" (l) 474 : "=A" (l)
475 ); 475 );
476 return l; 476 return l;
477 } 477 }
478 #else //FIXME check ppc64
479 static inline uint64_t read_time(void)
480 {
481 uint32_t tbu, tbl, temp;
482
483 /* from section 2.2.1 of the 32-bit PowerPC PEM */
484 __asm__ __volatile__(
485 "1:\n"
486 "mftbu %2\n"
487 "mftb %0\n"
488 "mftbu %1\n"
489 "cmpw %2,%1\n"
490 "bne 1b\n"
491 : "=r"(tbl), "=r"(tbu), "=r"(temp)
492 :
493 : "cc");
494
495 return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
496 }
478 #endif 497 #endif
479 498
480 #define START_TIMER \ 499 #define START_TIMER \
481 uint64_t tend;\ 500 uint64_t tend;\
482 uint64_t tstart= rdtsc();\ 501 uint64_t tstart= read_time();\
483 502
484 #define STOP_TIMER(id) \ 503 #define STOP_TIMER(id) \
485 tend= rdtsc();\ 504 tend= read_time();\
486 {\ 505 {\
487 static uint64_t tsum=0;\ 506 static uint64_t tsum=0;\
488 static int tcount=0;\ 507 static int tcount=0;\
489 static int tskip_count=0;\ 508 static int tskip_count=0;\
490 if(tcount<2 || tend - tstart < 8*tsum/tcount){\ 509 if(tcount<2 || tend - tstart < 8*tsum/tcount){\