⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hwtime.h

📁 最新的sqlite3.6.2源代码
💻 H
字号:
/*** 2008 May 27**** The author disclaims copyright to this source code.  In place of** a legal notice, here is a blessing:****    May you do good and not evil.**    May you find forgiveness for yourself and forgive others.**    May you share freely, never taking more than you give.************************************************************************************ This file contains inline asm code for retrieving "high-performance"** counters for x86 class CPUs.**** $Id: hwtime.h,v 1.3 2008/08/01 14:33:15 shane Exp $*/#ifndef _HWTIME_H_#define _HWTIME_H_/*** The following routine only works on pentium-class (or newer) processors.** It uses the RDTSC opcode to read the cycle count value out of the** processor and returns that value.  This can be used for high-res** profiling.*/#if (defined(__GNUC__) || defined(_MSC_VER)) && \      (defined(i386) || defined(__i386__) || defined(_M_IX86))  #if defined(__GNUC__)  __inline__ sqlite_uint64 sqlite3Hwtime(void){     unsigned int lo, hi;     __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));     return (sqlite_uint64)hi << 32 | lo;  }  #elif defined(_MSC_VER)  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){     __asm {        rdtsc        ret       ; return value at EDX:EAX     }  }  #endif#elif (defined(__GNUC__) && defined(__x86_64__))  __inline__ sqlite_uint64 sqlite3Hwtime(void){      unsigned long val;      __asm__ __volatile__ ("rdtsc" : "=A" (val));      return val;  } #elif (defined(__GNUC__) && defined(__ppc__))  __inline__ sqlite_uint64 sqlite3Hwtime(void){      unsigned long long retval;      unsigned long junk;      __asm__ __volatile__ ("\n\          1:      mftbu   %1\n\                  mftb    %L0\n\                  mftbu   %0\n\                  cmpw    %0,%1\n\                  bne     1b"                  : "=r" (retval), "=r" (junk));      return retval;  }#else  #error Need implementation of sqlite3Hwtime() for your platform.  /*  ** To compile without implementing sqlite3Hwtime() for your platform,  ** you can remove the above #error and use the following  ** stub function.  You will lose timing support for many  ** of the debugging and testing utilities, but it should at  ** least compile and run.  */  sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }#endif#endif /* !defined(_HWTIME_H_) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -