Revision 439ccc4e libavutil/timer.h

View differences:

libavutil/timer.h
28 28
#include <stdint.h>
29 29
#include "config.h"
30 30

  
31
#if ARCH_X86 || ARCH_PPC || ARCH_BFIN
32
#define AV_READ_TIME read_time
33
#if ARCH_X86
34
static inline uint64_t read_time(void)
35
{
36
    uint32_t a, d;
37
    __asm__ volatile("rdtsc\n\t"
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

  
59
     /* from section 2.2.1 of the 32-bit PowerPC PEM */
60
     __asm__ volatile(
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
}
31
#if   ARCH_BFIN
32
#   include "bfin/timer.h"
33
#elif ARCH_PPC
34
#   include "ppc/timer.h"
35
#elif ARCH_X86
36
#   include "x86/timer.h"
73 37
#endif
74
#elif HAVE_GETHRTIME
75
#define AV_READ_TIME gethrtime
38

  
39
#if !defined(AV_READ_TIME) && HAVE_GETHRTIME
40
#   define AV_READ_TIME gethrtime
76 41
#endif
77 42

  
78 43
#ifdef AV_READ_TIME

Also available in: Unified diff