1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-27 08:52:26 +03:00

Separate P4 timing asm code out of the SQLITE_DEBUG macro so that SQLITE_DEBUG

can be used on non-x86 machines and with compilers other than GCC.
Ticket #838. (CVS 1876)

FossilOrigin-Name: add266ccc3146fa56572d109e84c8a79dc3df2ca
This commit is contained in:
drh
2004-08-04 14:44:33 +00:00
parent d2f0a72331
commit a9600bc692
4 changed files with 45 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
C Separate\sthe\sifdefs\sfor\sINTPTR_TYPE\sand\sUINTPTR_TYPE\sin\ssqliteInt.h.\s(CVS\s1875) C Separate\sP4\stiming\sasm\scode\sout\sof\sthe\sSQLITE_DEBUG\smacro\sso\sthat\sSQLITE_DEBUG\ncan\sbe\sused\son\snon-x86\smachines\sand\swith\scompilers\sother\sthan\sGCC.\nTicket\s#838.\s(CVS\s1876)
D 2004-08-04T14:29:23 D 2004-08-04T14:44:34
F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -42,12 +42,12 @@ F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
F src/main.c 41da595846e299b757cc413d18de804f97f68748 F src/main.c 41da595846e299b757cc413d18de804f97f68748
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345 F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
F src/os_common.h fe9604754116bd2f2702d58f82d2d8b89998cb21 F src/os_common.h cd7eb025fdab7dc91e0e97bf6310f1648205857f
F src/os_mac.c 3d31e26be1411acfb7961033098631b4f3486fdf F src/os_mac.c 3d31e26be1411acfb7961033098631b4f3486fdf
F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4 F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
F src/os_test.c 6bf10100de2ca199a91fe7ac6474561c8a7166ae F src/os_test.c 6bf10100de2ca199a91fe7ac6474561c8a7166ae
F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162 F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162
F src/os_unix.c 02a08065f90ca2737514cdc19d60eb3c4b98fa6b F src/os_unix.c d084e3443211e1556f1a33fe48580e135facbcf7
F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13 F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13
F src/os_win.c 54181eb73cb4783c4241feca9eaa490768b39008 F src/os_win.c 54181eb73cb4783c4241feca9eaa490768b39008
F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44 F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
@@ -240,7 +240,7 @@ F www/tclsqlite.tcl 06a86cba4d7fc88e2bcd633b57702d3d16abebb5
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P 7ecff04a6153aa200233e6c0846a65e0213c3179 P 4e7953c13fd2cb32e5c97737c4b2f99b1b1edc9b
R bb7c51783ef3b73e24fdafb73590b839 R 32ad53e3950d031bf8dd62a53bdface5
U drh U drh
Z 5df9b4b7e13f1695014f4ed2b1c6b64b Z 06402d986b3876ed10b4e307c21b4abe

View File

@@ -1 +1 @@
4e7953c13fd2cb32e5c97737c4b2f99b1b1edc9b add266ccc3146fa56572d109e84c8a79dc3df2ca

View File

@@ -18,14 +18,44 @@
** general purpose header file. ** general purpose header file.
*/ */
/*
** At least two bugs have slipped in because we changed the MEMORY_DEBUG
** macro to SQLITE_DEBUG and some older makefiles have not yet made the
** switch. The following code should catch this problem at compile-time.
*/
#ifdef MEMORY_DEBUG
# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
#endif
int sqlite3_os_trace = 0;
#ifdef SQLITE_DEBUG
static int last_page = 0;
#define SEEK(X) last_page=(X)
#define TRACE1(X) if( sqlite3_os_trace ) sqlite3DebugPrintf(X)
#define TRACE2(X,Y) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y)
#define TRACE3(X,Y,Z) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z)
#define TRACE4(X,Y,Z,A) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A)
#define TRACE5(X,Y,Z,A,B) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A,B)
#define TRACE6(X,Y,Z,A,B,C) if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C)
#define TRACE7(X,Y,Z,A,B,C,D) \
if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C,D)
#else
#define SEEK(X)
#define TRACE1(X)
#define TRACE2(X,Y)
#define TRACE3(X,Y,Z)
#define TRACE4(X,Y,Z,A)
#define TRACE5(X,Y,Z,A,B)
#define TRACE6(X,Y,Z,A,B,C)
#define TRACE7(X,Y,Z,A,B,C,D)
#endif
/* /*
** Macros for performance tracing. Normally turned off. Only works ** Macros for performance tracing. Normally turned off. Only works
** on i486 hardware. ** on i486 hardware.
*/ */
int sqlite3_os_trace = 0; #ifdef SQLITE_PERFORMANCE_TRACE
#ifdef SQLITE_DEBUG
static int last_page = 0;
__inline__ unsigned long long int hwtime(void){ __inline__ unsigned long long int hwtime(void){
unsigned long long int x; unsigned long long int x;
__asm__("rdtsc\n\t" __asm__("rdtsc\n\t"
@@ -37,29 +67,13 @@ static unsigned long long int g_start;
static unsigned int elapse; static unsigned int elapse;
#define TIMER_START g_start=hwtime() #define TIMER_START g_start=hwtime()
#define TIMER_END elapse=hwtime()-g_start #define TIMER_END elapse=hwtime()-g_start
#define SEEK(X) last_page=(X) #define TIMER_ELAPSED elapse
#define TRACE1(X) if( sqlite3_os_trace ) sqlite3DebugPrintf(X)
#define TRACE2(X,Y) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y)
#define TRACE3(X,Y,Z) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z)
#define TRACE4(X,Y,Z,A) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A)
#define TRACE5(X,Y,Z,A,B) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A,B)
#define TRACE6(X,Y,Z,A,B,C) if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C)
#define TRACE7(X,Y,Z,A,B,C,D) \
if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C,D)
#else #else
#define TIMER_START #define TIMER_START
#define TIMER_END #define TIMER_END
#define SEEK(X) #define TIMER_ELAPSED 0
#define TRACE1(X)
#define TRACE2(X,Y)
#define TRACE3(X,Y,Z)
#define TRACE4(X,Y,Z,A)
#define TRACE5(X,Y,Z,A,B)
#define TRACE6(X,Y,Z,A,B,C)
#define TRACE7(X,Y,Z,A,B,C,D)
#endif #endif
/* /*
** If we compile with the SQLITE_TEST macro set, then the following block ** If we compile with the SQLITE_TEST macro set, then the following block
** of code will give us the ability to simulate a disk I/O error. This ** of code will give us the ability to simulate a disk I/O error. This

View File

@@ -617,7 +617,7 @@ int sqlite3OsRead(OsFile *id, void *pBuf, int amt){
TIMER_START; TIMER_START;
got = read(id->h, pBuf, amt); got = read(id->h, pBuf, amt);
TIMER_END; TIMER_END;
TRACE4("READ %-3d %7d %d\n", id->h, last_page, elapse); TRACE4("READ %-3d %7d %d\n", id->h, last_page, TIMER_ELAPSED);
SEEK(0); SEEK(0);
/* if( got<0 ) got = 0; */ /* if( got<0 ) got = 0; */
if( got==amt ){ if( got==amt ){
@@ -641,7 +641,7 @@ int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){
pBuf = &((char*)pBuf)[wrote]; pBuf = &((char*)pBuf)[wrote];
} }
TIMER_END; TIMER_END;
TRACE4("WRITE %-3d %7d %d\n", id->h, last_page, elapse); TRACE4("WRITE %-3d %7d %d\n", id->h, last_page, TIMER_ELAPSED);
SEEK(0); SEEK(0);
if( amt>0 ){ if( amt>0 ){
return SQLITE_FULL; return SQLITE_FULL;