From: drh Date: Mon, 23 Mar 2015 18:52:56 +0000 (+0000) Subject: Add the SQLITE_PTRSIZE macro. Use it to help sqlite3_status() run faster X-Git-Tag: version-3.8.9~40^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b4905c81fc1ee72c85f8bab318cc72735a34419;p=thirdparty%2Fsqlite.git Add the SQLITE_PTRSIZE macro. Use it to help sqlite3_status() run faster on 32-bit systems. FossilOrigin-Name: c742bd6047bc6d0319a5a8c31d97f6b9229507f6 --- diff --git a/manifest b/manifest index 362bf302a3..014d5df5b4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_status64()\sinterface.\s\sMake\sthe\snew\sinterface\sand\sthe\slegacy\nsqlite3_status()\sboth\satomic\sand\sthreadsafe.\s\sCheck\sthreadsafety\susing\nassert()s. -D 2015-03-23T17:25:18.212 +C Add\sthe\sSQLITE_PTRSIZE\smacro.\s\sUse\sit\sto\shelp\ssqlite3_status()\srun\sfaster\non\s32-bit\ssystems. +D 2015-03-23T18:52:56.780 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -195,7 +195,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770 F src/loadext.c 86bd4e2fccd520b748cba52492ab60c4a770f660 -F src/main.c fa997fa27d95febc16d57095299384b667a7f762 +F src/main.c 569d45ba9eb4fbdd631d53f440bcdb4a35ab1505 F src/malloc.c e818a0db9ac0898f9dc74002f3a5baca32232d05 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 @@ -235,9 +235,9 @@ F src/shell.c 9c1589c8271c04c02d23cdbc2c07bb40752fa9eb F src/sqlite.h.in df180ecc3215e4b87dbd536507869511bec88841 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d -F src/sqliteInt.h de9d20aa5757925a3cd26283d9e34a6ef49904fd +F src/sqliteInt.h e22a2bfbeed55ed3addff5e0ef34366e93ad0874 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 -F src/status.c 35d02aaf02600dfeade53d2adf2455186dfd741e +F src/status.c 8ccd03e35ac98e44b3df51cbc94a81119c6ab0dd F src/table.c e7a09215315a978057fb42c640f890160dbcc45e F src/tclsqlite.c fa72a7c5278662357c105ba7925c1d0972506ff9 F src/test1.c 90fbedce75330d48d99eadb7d5f4223e86969585 @@ -1246,10 +1246,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8d27e3e16a9be79fe227e833f4770ebe09a9d90b -R 2bfdb46ae6ff687a8efb07761e076d30 -T *branch * status64 -T *sym-status64 * -T -sym-trunk * +P 1ce8e8fa4b866aafa12b1da0eb4d02321af9293e +R 0b9a82d5d161d745ba0c858230f2a6bc U drh -Z 89310d97b168ea333a94dce0bcc0bc9f +Z e9a2419ecec514dae3eef3cef6e74ea6 diff --git a/manifest.uuid b/manifest.uuid index e93a4dbdf2..db394d0c85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1ce8e8fa4b866aafa12b1da0eb4d02321af9293e \ No newline at end of file +c742bd6047bc6d0319a5a8c31d97f6b9229507f6 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 092cbf8415..6967131143 100644 --- a/src/main.c +++ b/src/main.c @@ -128,6 +128,11 @@ int sqlite3_initialize(void){ } #endif + /* If the following assert() fails on some obscure processor/compiler + ** combination, the work-around is to set the correct pointer + ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */ + assert( SQLITE_PTRSIZE==sizeof(char*) ); + /* If SQLite is already completely initialized, then this call ** to sqlite3_initialize() should be a no-op. But the initialization ** must be complete. So isInit must not be set until the very end diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 78945c1dde..2b1d7ebc6e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -594,6 +594,20 @@ typedef INT8_TYPE i8; /* 1-byte signed integer */ */ typedef INT16_TYPE LogEst; +/* +** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer +*/ +#ifndef SQLITE_PTRSIZE +# if defined(__SIZEOF_POINTER__) +# define SQLITE_PTRSIZE __SIZEOF_POINTER__ +# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ + defined(_M_ARM) || defined(__arm__) || defined(__x86) +# define SQLITE_PTRSIZE 4 +# else +# define SQLITE_PTRSIZE 8 +# endif +#endif + /* ** Macros to determine whether the machine is big or little endian, ** and whether or not that determination is run-time or compile-time. diff --git a/src/status.c b/src/status.c index 0f6328318a..739249ec22 100644 --- a/src/status.c +++ b/src/status.c @@ -21,8 +21,13 @@ */ typedef struct sqlite3StatType sqlite3StatType; static SQLITE_WSD struct sqlite3StatType { +#if SQLITE_PTRSIZE>4 sqlite3_int64 nowValue[10]; /* Current value */ sqlite3_int64 mxValue[10]; /* Maximum value */ +#else + u32 nowValue[10]; /* Current value */ + u32 mxValue[10]; /* Maximum value */ +#endif } sqlite3Stat = { {0,}, {0,} }; /* @@ -152,8 +157,10 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){ if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT; #endif rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag); - *pCurrent = (int)iCur; - *pHighwater = (int)iHwtr; + if( rc==0 ){ + *pCurrent = (int)iCur; + *pHighwater = (int)iHwtr; + } return rc; }