1
/* ACC -- Automatic Compiler Configuration
3
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
6
This software is a copyrighted work licensed under the terms of
7
the GNU General Public License. Please consult the file "ACC_LICENSE"
10
Markus F.X.J. Oberhumer
11
<markus@oberhumer.com>
12
http://www.oberhumer.com/
16
#define __ACCLIB_RDTSC_CH_INCLUDED 1
17
#if !defined(ACCLIB_PUBLIC)
18
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
21
#if defined(acc_int32e_t)
24
/*************************************************************************
26
**************************************************************************/
28
ACCLIB_PUBLIC(int, acc_tsc_read) (acc_uint32e_t* t)
30
#if ((ACC_ARCH_AMD64 || ACC_ARCH_IA32) && ACC_CC_GNUC)
32
"clc \n" ".byte 0x0f, 0x31\n"
33
"movl %%eax,(%0)\n" "movl %%edx,4(%0)\n"
34
# if (ACC_CC_GNUC >= 0x020000ul)
35
: : "r" (t) : "cc", "memory", "eax", "edx"
37
: : "r" (t) : "ax", "dx"
41
#elif (ACC_ARCH_IA32 && ACC_CC_INTELC) && defined(__linux__)
43
"clc \n" ".byte 0x0f, 0x31\n"
44
"movl %%eax,(%0)\n" "movl %%edx,4(%0)\n"
45
: : "r" (t) : "memory", "eax", "edx"
48
#elif (ACC_ARCH_IA32 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC))
53
# if (ACC_CC_MSC && (_MSC_VER < 1200))
70
/*************************************************************************
72
**************************************************************************/
74
ACCLIB_PUBLIC(int, acc_tsc_read_add) (acc_uint32e_t* t)
76
#if ((ACC_ARCH_AMD64 || ACC_ARCH_IA32) && ACC_CC_GNUC)
78
"clc \n" ".byte 0x0f, 0x31\n"
79
"addl %%eax,(%0)\n" "adcl $0,%%edx\n" "addl %%edx,4(%0)\n"
80
# if (ACC_CC_GNUC >= 0x020000ul)
81
: : "r" (t) : "cc", "memory", "eax", "edx"
83
: : "r" (t) : "ax", "dx"
87
#elif (ACC_ARCH_IA32 && ACC_CC_INTELC) && defined(__linux__)
89
"clc \n" ".byte 0x0f, 0x31\n"
90
"addl %%eax,(%0)\n" "adcl $0,%%edx\n" "addl %%edx,4(%0)\n"
91
: : "r" (t) : "memory", "eax", "edx"
94
#elif (ACC_ARCH_IA32 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC))
99
# if (ACC_CC_MSC && (_MSC_VER < 1200))
115
if (t[0] < v[0]) t[1] += 1;
122
#endif /* defined(acc_int32e_t) */