In x86 the specification of "=A" is EDX:EAX, however in x86-64 is RAX. And, rdtsc always store EDX:EAX. In a word, the code of sqlite3Hwtime is opposite.
diff -u sqlite-source-3_6_20/hwtime.h sqlite-source-3_6_20.1/hwtime.h --- sqlite-source-3_6_20/hwtime.h Wed Nov 4 08:54:16 2009 +++ sqlite-source-3_6_20.1/hwtime.h Thu Dec 3 00:52:48 2009 @@ -30,9 +30,9 @@ #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; + unsigned long long val; + __asm__ __volatile__ ("rdtsc" : "=A" (val)); + return val; } #elif defined(_MSC_VER) @@ -46,14 +46,25 @@ #endif -#elif (defined(__GNUC__) && defined(__x86_64__)) +#elif (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1400)) && \ + (defined(__x86_64__) || defined(_M_X64)) + + #if defined(__GNUC__) __inline__ sqlite_uint64 sqlite3Hwtime(void){ - unsigned long val; - __asm__ __volatile__ ("rdtsc" : "=A" (val)); - return val; + unsigned int lo, hi; + __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); + return (sqlite_uint64)hi << 32 | lo; } - + + #elif defined(_MSC_VER) + + __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ + return __rdtsc(); + } + + #endif + #elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ diff -u sqlite-source-3_6_20/mutex_w32.c sqlite-source-3_6_20.1/mutex_w32.c --- sqlite-source-3_6_20/mutex_w32.c Wed Nov 4 08:54:16 2009 +++ sqlite-source-3_6_20.1/mutex_w32.c Thu Dec 3 00:34:38 2009 @@ -49,7 +49,7 @@ ** this out as well. */ #if 0 -#if SQLITE_OS_WINCE +#if SQLITE_OS_WINCE || SQLITE_OS_WIN64 # define mutexIsNT() (1) #else static int mutexIsNT(void){ diff -u sqlite-source-3_6_20/os.h sqlite-source-3_6_20.1/os.h --- sqlite-source-3_6_20/os.h Wed Nov 4 08:54:16 2009 +++ sqlite-source-3_6_20.1/os.h Thu Dec 3 00:07:44 2009 @@ -77,6 +77,14 @@ # define SQLITE_OS_WINCE 0 #endif +/* +** Determine if we are dealing with 64-bit Windows +*/ +#if defined(_WIN64) +# define SQLITE_OS_WIN64 1 +#else +# define SQLITE_OS_WIN64 0 +#endif /* ** Define the maximum size of a temporary filename diff -u sqlite-source-3_6_20/os_win.c sqlite-source-3_6_20.1/os_win.c --- sqlite-source-3_6_20/os_win.c Wed Nov 4 08:54:16 2009 +++ sqlite-source-3_6_20.1/os_win.c Thu Dec 3 00:07:44 2009 @@ -147,7 +147,7 @@ ** WinNT/2K/XP so that we will know whether or not we can safely call ** the LockFileEx() API. */ -#if SQLITE_OS_WINCE +#if SQLITE_OS_WINCE || SQLITE_OS_WIN64 # define isNT() (1) #else static int isNT(void){ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users