Revision 439ccc4e

View differences:

libavutil/bfin/timer.h
1
/*
2
 * Copyright (C) 2007 Marc Hoffman
3
 *
4
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with FFmpeg; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20

  
21
#ifndef AVUTIL_BFIN_TIMER_H
22
#define AVUTIL_BFIN_TIMER_H
23

  
24
#include <stdint.h>
25

  
26
#define AV_READ_TIME read_time
27

  
28
static inline uint64_t read_time(void)
29
{
30
    union {
31
        struct {
32
            unsigned lo;
33
            unsigned hi;
34
        } p;
35
        unsigned long long c;
36
    } t;
37
    __asm__ volatile ("%0=cycles; %1=cycles2;" : "=d" (t.p.lo), "=d" (t.p.hi));
38
    return t.c;
39
}
40

  
41
#endif /* AVUTIL_BFIN_TIMER_H */
libavutil/ppc/timer.h
1
/*
2
 * Copyright (c) 2005 Luca Barbato <lu_zero@gentoo.org>
3
 *
4
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with FFmpeg; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20

  
21
#ifndef AVUTIL_PPC_TIMER_H
22
#define AVUTIL_PPC_TIMER_H
23

  
24
#include <stdint.h>
25

  
26
#define AV_READ_TIME read_time
27

  
28
static inline uint64_t read_time(void)
29
{
30
    uint32_t tbu, tbl, temp;
31

  
32
     /* from section 2.2.1 of the 32-bit PowerPC PEM */
33
     __asm__ volatile(
34
         "1:\n"
35
         "mftbu  %2\n"
36
         "mftb   %0\n"
37
         "mftbu  %1\n"
38
         "cmpw   %2,%1\n"
39
         "bne    1b\n"
40
     : "=r"(tbl), "=r"(tbu), "=r"(temp)
41
     :
42
     : "cc");
43

  
44
     return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
45
}
46

  
47
#endif /* AVUTIL_PPC_TIMER_H */
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
libavutil/x86/timer.h
1
/*
2
 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3
 *
4
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with FFmpeg; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20

  
21
#ifndef AVUTIL_X86_TIMER_H
22
#define AVUTIL_X86_TIMER_H
23

  
24
#include <stdint.h>
25

  
26
#define AV_READ_TIME read_time
27

  
28
static inline uint64_t read_time(void)
29
{
30
    uint32_t a, d;
31
    __asm__ volatile("rdtsc" : "=a" (a), "=d" (d));
32
    return ((uint64_t)d << 32) + a;
33
}
34

  
35
#endif /* AVUTIL_X86_TIMER_H */

Also available in: Unified diff