4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
11 ******************************************************************************
13 ** This file contains inline asm code for retrieving "high-performance"
14 ** counters for x86 class CPUs.
20 ** The following routine only works on pentium-class (or newer) processors.
21 ** It uses the RDTSC opcode to read the cycle count value out of the
22 ** processor and returns that value. This can be used for high-res
25 #if (defined(__GNUC__) || defined(_MSC_VER)) && \
26 (defined(i386) || defined(__i386__) || defined(_M_IX86))
30 __inline__ sqlite_uint64
sqlite3Hwtime(void){
32 __asm__
__volatile__ ("rdtsc" : "=a" (lo
), "=d" (hi
));
33 return (sqlite_uint64
)hi
<< 32 | lo
;
36 #elif defined(_MSC_VER)
38 __declspec(naked
) __inline sqlite_uint64 __cdecl
sqlite3Hwtime(void){
41 ret
; return value at EDX
:EAX
47 #elif (defined(__GNUC__) && defined(__x86_64__))
49 __inline__ sqlite_uint64
sqlite3Hwtime(void){
51 __asm__
__volatile__ ("rdtsc" : "=A" (val
));
55 #elif (defined(__GNUC__) && defined(__ppc__))
57 __inline__ sqlite_uint64
sqlite3Hwtime(void){
58 unsigned long long retval
;
60 __asm__
__volatile__ ("\n\
66 : "=r" (retval
), "=r" (junk
));
72 #error Need implementation of sqlite3Hwtime() for your platform.
75 ** To compile without implementing sqlite3Hwtime() for your platform,
76 ** you can remove the above #error and use the following
77 ** stub function. You will lose timing support for many
78 ** of the debugging and testing utilities, but it should at
79 ** least compile and run.
81 sqlite_uint64
sqlite3Hwtime(void){ return ((sqlite_uint64
)0); }
85 #endif /* !defined(_HWTIME_H_) */