comparison timer.h @ 718:fa8c9944568f libavutil

Split libavutil/timer.h per architecture
author mru
date Wed, 01 Apr 2009 22:56:22 +0000
parents 70bdd5501662
children faf384df4bd7
comparison
equal deleted inserted replaced
717:01f68e5fb9af 718:fa8c9944568f
26 26
27 #include <stdlib.h> 27 #include <stdlib.h>
28 #include <stdint.h> 28 #include <stdint.h>
29 #include "config.h" 29 #include "config.h"
30 30
31 #if ARCH_X86 || ARCH_PPC || ARCH_BFIN 31 #if ARCH_BFIN
32 #define AV_READ_TIME read_time 32 # include "bfin/timer.h"
33 #if ARCH_X86 33 #elif ARCH_PPC
34 static inline uint64_t read_time(void) 34 # include "ppc/timer.h"
35 { 35 #elif ARCH_X86
36 uint32_t a, d; 36 # include "x86/timer.h"
37 __asm__ volatile("rdtsc\n\t" 37 #endif
38 : "=a" (a), "=d" (d));
39 return ((uint64_t)d << 32) + a;
40 }
41 #elif ARCH_BFIN
42 static inline uint64_t read_time(void)
43 {
44 union {
45 struct {
46 unsigned lo;
47 unsigned hi;
48 } p;
49 unsigned long long c;
50 } t;
51 __asm__ volatile ("%0=cycles; %1=cycles2;" : "=d" (t.p.lo), "=d" (t.p.hi));
52 return t.c;
53 }
54 #else //FIXME check ppc64
55 static inline uint64_t read_time(void)
56 {
57 uint32_t tbu, tbl, temp;
58 38
59 /* from section 2.2.1 of the 32-bit PowerPC PEM */ 39 #if !defined(AV_READ_TIME) && HAVE_GETHRTIME
60 __asm__ volatile( 40 # define AV_READ_TIME gethrtime
61 "1:\n"
62 "mftbu %2\n"
63 "mftb %0\n"
64 "mftbu %1\n"
65 "cmpw %2,%1\n"
66 "bne 1b\n"
67 : "=r"(tbl), "=r"(tbu), "=r"(temp)
68 :
69 : "cc");
70
71 return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
72 }
73 #endif
74 #elif HAVE_GETHRTIME
75 #define AV_READ_TIME gethrtime
76 #endif 41 #endif
77 42
78 #ifdef AV_READ_TIME 43 #ifdef AV_READ_TIME
79 #define START_TIMER \ 44 #define START_TIMER \
80 uint64_t tend;\ 45 uint64_t tend;\