From: danielk1977 Date: Mon, 23 Mar 2009 04:33:32 +0000 (+0000) Subject: Use the ROUND8() macro to round an integer up to the nearest multiple of 8 and ROUNDD... X-Git-Tag: version-3.6.15~378 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc73971db6162bf60d775775b180cea06615b29c;p=thirdparty%2Fsqlite.git Use the ROUND8() macro to round an integer up to the nearest multiple of 8 and ROUNDDOWN8() macro to round down to the nearest multiple of 8. This is a cosmetic change. (CVS 6372) FossilOrigin-Name: db1d4d2f5083adf5438c7f387b115180800e7bd9 --- diff --git a/manifest b/manifest index 175f8094dd..e0393068c9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarning\sin\sMSVC.\s(CVS\s6371) -D 2009-03-23T02:34:32 +C Use\sthe\sROUND8()\smacro\sto\sround\san\sinteger\sup\sto\sthe\snearest\smultiple\sof\s8\sand\sROUNDDOWN8()\smacro\sto\sround\sdown\sto\sthe\snearest\smultiple\sof\s8.\sThis\sis\sa\scosmetic\schange.\s(CVS\s6372) +D 2009-03-23T04:33:32 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -111,7 +111,7 @@ F src/callback.c 09c6fedc77a45db99ba25a75d61382830314b357 F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c F src/date.c 0d804df3bbda46329946a01ff5c75c3f4f135218 F src/delete.c eb1066b2f35489fee46ad765d2b66386fc7d8adf -F src/expr.c 7252b38f6453043cd19c71f0d6a7787d94f854dc +F src/expr.c ca5d176acc69497401cc5c376a91f785159b83a4 F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff F src/func.c de2eed7d96365210faecda877c5a12cf440bdf42 F src/global.c 448419c44ce0701104c2121b0e06919b44514c0c @@ -122,11 +122,11 @@ F src/insert.c 71286d081a919a27ef22eaeccbe2718f93dc6aa9 F src/journal.c e00df0c0da8413ab6e1bb7d7cab5665d4a9000d0 F src/legacy.c 2ad5b52df322d0f132f66817095e0e79c8942611 F src/loadext.c 3f96631089fc4f3871a67f02f2e4fc7ea4d51edc -F src/main.c cb5ce39624f312888a9058d6fcacb54a9f6e5e85 -F src/malloc.c b9c59b33539af74641362a7496ecc3efd6477f6d +F src/main.c 95e13cd23b7a88e33c1acfe233c748fd9dd7e467 +F src/malloc.c 1a52c55bc06e5645543c90bdbeb43d26b2a97314 F src/mem0.c f2f84062d1f35814d6535c9f9e33de3bfb3b132c -F src/mem1.c 3bfb39e4f60b0179713a7c087b2d4f0dc205735f -F src/mem2.c 692c5b50141f49c32d85d7c0c39c751f6d520093 +F src/mem1.c e6d5c23941288df8191b8a98c28e3f57771e2270 +F src/mem2.c d02bd6a5b34f2d59012a852615621939d9c09548 F src/mem3.c 67153ec933e08b70714055e872efb58a6b287939 F src/mem5.c 838309b521c96a2a34507f74a5a739d28de4aac6 F src/memjournal.c 17e9281ea5d7981e3e7b0dd3274921ecba4f773c @@ -143,12 +143,12 @@ F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 F src/os_unix.c a20fe61c025117452c003ae4cafd05c3e610b616 F src/os_win.c 40636702058ed4dcd35d68151bfab56d4997cdc1 -F src/pager.c 01e3facb2f7c5f307e36a0f4ed9343cf3761711a +F src/pager.c da7ffd068347cdc88b477875585d53dcf2bdc4a7 F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f F src/parse.y 30ae25cd9ce8002527fca3011052a7fba0aff349 F src/pcache.c fcf7738c83c4d3e9d45836b2334c8a368cc41274 F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324 -F src/pcache1.c f12518540ba776df3051215c4244e9cdc06b09cd +F src/pcache1.c f587565f4ba0fd1772067eaa96814dce761b7a4c F src/pragma.c 22ed04836aab8ce134c53be1ca896f3ad20fabdb F src/prepare.c 14e61702b09a325e50000e5f5f3156cd20c4afe1 F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f @@ -159,7 +159,7 @@ F src/select.c 4d0b77fd76ff80f09a798ee98953e344c9de8fbb F src/shell.c 0a11f831603f17fea20ca97133c0f64e716af4a7 F src/sqlite.h.in 0db1e59d89aeacb8fe64a19fd14c13a796060ccb F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17 -F src/sqliteInt.h 0ba7aac31f707d69f73455f2cff296787f76e109 +F src/sqliteInt.h b6858d742b30d556886cca16437fb0a4aad2e065 F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76 F src/table.c 332ab0ea691e63862e2a8bdfe2c0617ee61062a3 @@ -193,7 +193,7 @@ F src/test_schema.c 4b4bf7bb329326458c491b0e6facd4c8c4c5b479 F src/test_server.c f0a403b5f699c09bd2b1236b6f69830fd6221f6b F src/test_tclvar.c 9e42fa59d3d2f064b7ab8628e7ab2dc8a9fe93d4 F src/test_thread.c 870a862d9c740d083b93ed30a0b5c0b491b30f43 -F src/test_wsd.c c297d7d6b8a990239e1bd25935e81d612d8ae31d +F src/test_wsd.c 3ae5101de6cbfda2720152ab659ea84079719241 F src/tokenize.c 6987fb7f0d6a87ac53499aee568cabb05eb4bea8 F src/trigger.c 21f39db410cdc32166a94900ac1b3df98ea560e6 F src/update.c 8ededddcde6f7b6da981dd0429a5d34518a475b7 @@ -204,7 +204,7 @@ F src/vdbe.c f8164c2830f82714a77b1f2a97c2e9c4efbcb3bb F src/vdbe.h d70a68bee196ab228914a3902c79dbd24342a0f2 F src/vdbeInt.h 53a2f4696871712646c77351904576cca6ad9752 F src/vdbeapi.c 025d83f51f5e0a6e0fb55d603103d24825577967 -F src/vdbeaux.c 8b3ce0123c7622544bbad1e7fbedac79ed436e84 +F src/vdbeaux.c be958dfe3a476ccb58dbc0d5786d58717f40f4b0 F src/vdbeblob.c 3408f5e1ab62627300b9c9c3168cff1de65e1658 F src/vdbemem.c 543a79d722734d2f8b7ad70f08218c30bcc5bbf5 F src/vtab.c 18d671f0a45d0159088070bc6b219a3105034c87 @@ -709,7 +709,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 53149c9f5d5cfaba3374703cd3af92a9d4cf8718 -R 7594c1241f5f5ff5987bb39db6374524 -U shane -Z 7711d30d6a1e9899b7dbb6fec4505945 +P 83a4d5b3d7abe983c2be00a694cc7d4c4847f253 +R e8c1b980a9474b2681755e6236a2eed3 +U danielk1977 +Z af91f276a825722179e40ac35b5fa895 diff --git a/manifest.uuid b/manifest.uuid index 40342278e5..a50af64cf4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -83a4d5b3d7abe983c2be00a694cc7d4c4847f253 \ No newline at end of file +db1d4d2f5083adf5438c7f387b115180800e7bd9 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index a7a954c092..edea9224d8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.420 2009/03/18 10:36:13 drh Exp $ +** $Id: expr.c,v 1.421 2009/03/23 04:33:32 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -714,7 +714,7 @@ static int dupedExprNodeSize(Expr *p, int flags){ ){ nByte += p->span.n; } - return (nByte+7)&~7; + return ROUND8(nByte); } /* diff --git a/src/main.c b/src/main.c index 5eddc02e6c..072e14e07f 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.533 2009/03/19 18:51:07 danielk1977 Exp $ +** $Id: main.c,v 1.534 2009/03/23 04:33:32 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -404,12 +404,12 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ sz = 0; pStart = 0; }else if( pBuf==0 ){ - sz = (sz + 7)&~7; + sz = ROUND8(sz); sqlite3BeginBenignMalloc(); pStart = sqlite3Malloc( sz*cnt ); sqlite3EndBenignMalloc(); }else{ - sz = sz&~7; + sz = ROUNDDOWN8(sz); pStart = pBuf; } db->lookaside.pStart = pStart; diff --git a/src/malloc.c b/src/malloc.c index dc111ba366..2678526ad6 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -12,7 +12,7 @@ ** ** Memory allocation functions used throughout sqlite. ** -** $Id: malloc.c,v 1.58 2009/03/05 04:20:32 shane Exp $ +** $Id: malloc.c,v 1.59 2009/03/23 04:33:33 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -121,7 +121,7 @@ int sqlite3MallocInit(void){ if( sqlite3GlobalConfig.pScratch && sqlite3GlobalConfig.szScratch>=100 && sqlite3GlobalConfig.nScratch>=0 ){ int i; - sqlite3GlobalConfig.szScratch = (sqlite3GlobalConfig.szScratch - 4) & ~7; + sqlite3GlobalConfig.szScratch = ROUNDDOWN8(sqlite3GlobalConfig.szScratch-4); mem0.aScratchFree = (u32*)&((char*)sqlite3GlobalConfig.pScratch) [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch]; for(i=0; i=1 ){ int i; int overhead; - int sz = sqlite3GlobalConfig.szPage & ~7; + int sz = ROUNDDOWN8(sqlite3GlobalConfig.szPage); int n = sqlite3GlobalConfig.nPage; overhead = (4*n + sz - 1)/sz; sqlite3GlobalConfig.nPage -= overhead; diff --git a/src/mem1.c b/src/mem1.c index ca1e6aecf1..e3b886341c 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -17,7 +17,7 @@ ** This file contains implementations of the low-level memory allocation ** routines specified in the sqlite3_mem_methods object. ** -** $Id: mem1.c,v 1.29 2008/12/10 21:19:57 drh Exp $ +** $Id: mem1.c,v 1.30 2009/03/23 04:33:33 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -39,7 +39,7 @@ static void *sqlite3MemMalloc(int nByte){ sqlite3_int64 *p; assert( nByte>0 ); - nByte = (nByte+7)&~7; + nByte = ROUND8(nByte); p = malloc( nByte+8 ); if( p ){ p[0] = nByte; @@ -76,7 +76,7 @@ static void sqlite3MemFree(void *pPrior){ static void *sqlite3MemRealloc(void *pPrior, int nByte){ sqlite3_int64 *p = (sqlite3_int64*)pPrior; assert( pPrior!=0 && nByte>0 ); - nByte = (nByte+7)&~7; + nByte = ROUND8(nByte); p = (sqlite3_int64*)pPrior; p--; p = realloc(p, nByte+8 ); @@ -103,7 +103,7 @@ static int sqlite3MemSize(void *pPrior){ ** Round up a request size to the next valid allocation size. */ static int sqlite3MemRoundup(int n){ - return (n+7) & ~7; + return ROUND8(n); } /* diff --git a/src/mem2.c b/src/mem2.c index 436683659c..8c498a2abd 100644 --- a/src/mem2.c +++ b/src/mem2.c @@ -19,7 +19,7 @@ ** This file contains implementations of the low-level memory allocation ** routines specified in the sqlite3_mem_methods object. ** -** $Id: mem2.c,v 1.44 2009/02/19 14:39:25 danielk1977 Exp $ +** $Id: mem2.c,v 1.45 2009/03/23 04:33:33 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -128,7 +128,7 @@ static struct { ** Adjust memory usage statistics */ static void adjustStats(int iSize, int increment){ - int i = ((iSize+7)&~7)/8; + int i = ROUND8(iSize)/8; if( i>NCSIZE-1 ){ i = NCSIZE - 1; } @@ -159,7 +159,7 @@ static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){ p = (struct MemBlockHdr*)pAllocation; p--; assert( p->iForeGuard==(int)FOREGUARD ); - nReserve = (p->iSize+7)&~7; + nReserve = ROUND8(p->iSize); pInt = (int*)pAllocation; pU8 = (u8*)pAllocation; assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD ); @@ -209,7 +209,7 @@ static void sqlite3MemShutdown(void *NotUsed){ ** Round up a request size to the next valid allocation size. */ static int sqlite3MemRoundup(int n){ - return (n+7) & ~7; + return ROUND8(n); } /* @@ -225,7 +225,7 @@ static void *sqlite3MemMalloc(int nByte){ int nReserve; sqlite3_mutex_enter(mem.mutex); assert( mem.disallow==0 ); - nReserve = (nByte+7)&~7; + nReserve = ROUND8(nByte); totalSize = nReserve + sizeof(*pHdr) + sizeof(int) + mem.nBacktrace*sizeof(void*) + mem.nTitle; p = malloc(totalSize); @@ -372,7 +372,7 @@ void sqlite3MemdebugSettitle(const char *zTitle){ if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1; memcpy(mem.zTitle, zTitle, n); mem.zTitle[n] = 0; - mem.nTitle = (n+7)&~7; + mem.nTitle = ROUND8(n); sqlite3_mutex_leave(mem.mutex); } diff --git a/src/pager.c b/src/pager.c index fc13b38c2b..335ec21e51 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.571 2009/03/05 04:20:32 shane Exp $ +** @(#) $Id: pager.c,v 1.572 2009/03/23 04:33:33 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -99,12 +99,6 @@ int sqlite3PagerTrace=1; /* True to enable tracing */ #define PAGER_EXCLUSIVE 4 /* same as EXCLUSIVE_LOCK */ #define PAGER_SYNCED 5 -/* -** This macro rounds values up so that if the value is an address it -** is guaranteed to be an address that is aligned to an 8-byte boundary. -*/ -#define FORCE_ALIGNMENT(X) (((X)+7)&~7) - /* ** A macro used for invoking the codec if there is one */ @@ -3279,7 +3273,7 @@ int sqlite3PagerOpen( } /* Initialize the PCache object. */ - nExtra = FORCE_ALIGNMENT(nExtra); + nExtra = ROUND8(nExtra); sqlite3PcacheOpen(szPageDflt, nExtra, !memDb, !memDb?pagerStress:0, (void *)pPager, pPager->pPCache); diff --git a/src/pcache1.c b/src/pcache1.c index d43ce6406c..0f2c36d785 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -16,7 +16,7 @@ ** If the default page cache implementation is overriden, then neither of ** these two features are available. ** -** @(#) $Id: pcache1.c,v 1.9 2009/03/05 14:59:40 danielk1977 Exp $ +** @(#) $Id: pcache1.c,v 1.10 2009/03/23 04:33:33 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -129,7 +129,7 @@ static SQLITE_WSD struct PCacheGlobal { */ void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){ PgFreeslot *p; - sz &= ~7; + sz = ROUNDDOWN8(sz); pcache1.szSlot = sz; pcache1.pStart = pBuf; pcache1.pFree = 0; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 506daaee94..67836d1b07 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.844 2009/03/20 14:18:52 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.845 2009/03/23 04:33:33 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -448,7 +448,12 @@ extern const int sqlite3one; ** Round up a number to the next larger multiple of 8. This is used ** to force 8-byte alignment on 64-bit architectures. */ -#define ROUND8(x) ((x+7)&~7) +#define ROUND8(x) (((x)+7)&~7) + +/* +** Round down to the nearest multiple of 8 +*/ +#define ROUNDDOWN8(x) ((x)&~7) /* ** An instance of the following structure is used to store the busy-handler diff --git a/src/test_wsd.c b/src/test_wsd.c index a7fad263ad..a5d10a71f4 100644 --- a/src/test_wsd.c +++ b/src/test_wsd.c @@ -14,7 +14,7 @@ ** sqlite3_wsd_init() and sqlite3_wsd_find() functions required if the ** SQLITE_OMIT_WSD symbol is defined at build time. ** -** $Id: test_wsd.c,v 1.3 2008/10/07 15:25:49 drh Exp $ +** $Id: test_wsd.c,v 1.4 2009/03/23 04:33:33 danielk1977 Exp $ */ #if defined(SQLITE_OMIT_WSD) && defined(SQLITE_TEST) @@ -69,7 +69,7 @@ void *sqlite3_wsd_find(void *K, int L){ /* If no entry for K was found, create and populate a new one. */ if( !pVar ){ - int nByte = (sizeof(ProcessLocalVar) + L + 7)&~7; + int nByte = ROUND8(sizeof(ProcessLocalVar) + L); assert( pGlobal->nFree>=nByte ); pVar = (ProcessLocalVar *)pGlobal->pFree; pVar->pKey = K; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 8ff424517d..e1c965a7d2 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -14,7 +14,7 @@ ** to version 2.8.7, all this code was combined into the vdbe.c source file. ** But that file was getting too big so this subroutines were split out. ** -** $Id: vdbeaux.c,v 1.444 2009/03/20 14:42:11 danielk1977 Exp $ +** $Id: vdbeaux.c,v 1.445 2009/03/23 04:33:33 danielk1977 Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -1024,7 +1024,7 @@ static void allocSpace( int *pnByte /* If allocation cannot be made, increment *pnByte */ ){ if( (*(void**)pp)==0 ){ - nByte = (nByte+7)&~7; + nByte = ROUND8(nByte); if( (pEnd - *ppFrom)>=nByte ){ *(void**)pp = (void *)*ppFrom; *ppFrom += nByte;