GammaCombo
Rev:Unversioneddirectory
core
include
rdtsc.h
Go to the documentation of this file.
1
#ifndef _RDTSC_H
2
#define _RDTSC_H
3
4
#if defined(__i386__)
5
static
__inline__
unsigned
long
long
rdtsc(
void
)
6
{
7
unsigned
long
long
int
x;
8
__asm__
volatile
(
".byte 0x0f, 0x31"
:
"=A"
(x));
9
return
x;
10
}
11
#elif defined(__x86_64__)
12
static
__inline__
unsigned
long
long
rdtsc(
void
)
13
{
14
unsigned
hi, lo;
15
__asm__ __volatile__ (
"rdtsc"
:
"=a"
(lo),
"=d"
(hi));
16
return
( (
unsigned
long
long
)lo)|( ((
unsigned
long
long)hi)<<32 );
17
}
18
#elif defined(__powerpc__)
19
static
__inline__
unsigned
long
long
rdtsc(
void
)
20
{
21
unsigned
long
long
int
result=0;
22
unsigned
long
int
upper, lower,tmp;
23
__asm__
volatile
(
24
"0: \n"
25
"\tmftbu %0 \n"
26
"\tmftb %1 \n"
27
"\tmftbu %2 \n"
28
"\tcmpw %2,%0 \n"
29
"\tbne 0b \n"
30
:
"=r"
(upper),
"=r"
(lower),
"=r"
(tmp)
31
);
32
result = upper;
33
result = result<<32;
34
result = result|lower;
35
36
return
(result);
37
}
38
#endif
39
40
#endif // _RDTSC_H
Generated on Fri Apr 28 2017 15:18:58 for GammaCombo by
1.8.12