From: drh Date: Wed, 4 Aug 2004 14:44:33 +0000 (+0000) Subject: Separate P4 timing asm code out of the SQLITE_DEBUG macro so that SQLITE_DEBUG X-Git-Tag: version-3.6.10~4269 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a9600bc692ec7852aa1357392def9aaef468a587;p=thirdparty%2Fsqlite.git 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 --- diff --git a/manifest b/manifest index 01711af2fb..7fc04d8500 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Separate\sthe\sifdefs\sfor\sINTPTR_TYPE\sand\sUINTPTR_TYPE\sin\ssqliteInt.h.\s(CVS\s1875) -D 2004-08-04T14:29:23 +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:44:34 F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -42,12 +42,12 @@ F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f F src/main.c 41da595846e299b757cc413d18de804f97f68748 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 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.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4 F src/os_test.c 6bf10100de2ca199a91fe7ac6474561c8a7166ae 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_win.c 54181eb73cb4783c4241feca9eaa490768b39008 F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44 @@ -240,7 +240,7 @@ F www/tclsqlite.tcl 06a86cba4d7fc88e2bcd633b57702d3d16abebb5 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 7ecff04a6153aa200233e6c0846a65e0213c3179 -R bb7c51783ef3b73e24fdafb73590b839 +P 4e7953c13fd2cb32e5c97737c4b2f99b1b1edc9b +R 32ad53e3950d031bf8dd62a53bdface5 U drh -Z 5df9b4b7e13f1695014f4ed2b1c6b64b +Z 06402d986b3876ed10b4e307c21b4abe diff --git a/manifest.uuid b/manifest.uuid index 4326682dd4..9a62ae3ef4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4e7953c13fd2cb32e5c97737c4b2f99b1b1edc9b \ No newline at end of file +add266ccc3146fa56572d109e84c8a79dc3df2ca \ No newline at end of file diff --git a/src/os_common.h b/src/os_common.h index c7b5fe0492..dc8f88096a 100644 --- a/src/os_common.h +++ b/src/os_common.h @@ -18,25 +18,19 @@ ** general purpose header file. */ - /* -** Macros for performance tracing. Normally turned off. Only works -** on i486 hardware. +** 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; -__inline__ unsigned long long int hwtime(void){ - unsigned long long int x; - __asm__("rdtsc\n\t" - "mov %%edx, %%ecx\n\t" - :"=A" (x)); - return x; -} -static unsigned long long int g_start; -static unsigned int elapse; -#define TIMER_START g_start=hwtime() -#define TIMER_END elapse=hwtime()-g_start #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) @@ -47,8 +41,6 @@ static unsigned int elapse; #define TRACE7(X,Y,Z,A,B,C,D) \ if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C,D) #else -#define TIMER_START -#define TIMER_END #define SEEK(X) #define TRACE1(X) #define TRACE2(X,Y) @@ -59,6 +51,28 @@ static unsigned int elapse; #define TRACE7(X,Y,Z,A,B,C,D) #endif +/* +** Macros for performance tracing. Normally turned off. Only works +** on i486 hardware. +*/ +#ifdef SQLITE_PERFORMANCE_TRACE +__inline__ unsigned long long int hwtime(void){ + unsigned long long int x; + __asm__("rdtsc\n\t" + "mov %%edx, %%ecx\n\t" + :"=A" (x)); + return x; +} +static unsigned long long int g_start; +static unsigned int elapse; +#define TIMER_START g_start=hwtime() +#define TIMER_END elapse=hwtime()-g_start +#define TIMER_ELAPSED elapse +#else +#define TIMER_START +#define TIMER_END +#define TIMER_ELAPSED 0 +#endif /* ** If we compile with the SQLITE_TEST macro set, then the following block diff --git a/src/os_unix.c b/src/os_unix.c index bdc0ea39ed..4d6039161d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -617,7 +617,7 @@ int sqlite3OsRead(OsFile *id, void *pBuf, int amt){ TIMER_START; got = read(id->h, pBuf, amt); 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); /* if( got<0 ) got = 0; */ if( got==amt ){ @@ -641,7 +641,7 @@ int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){ pBuf = &((char*)pBuf)[wrote]; } 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); if( amt>0 ){ return SQLITE_FULL;