aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2009-03-23 04:33:32 +0000
committerdanielk1977 <danielk1977@noemail.net>2009-03-23 04:33:32 +0000
commitbc73971db6162bf60d775775b180cea06615b29c (patch)
tree3e9bd43e05e6924e8b5147ffc625338472c40d9f /src
parentca18d20fd69801f8dcf4693fcfb5fb22d65e9746 (diff)
downloadsqlite-bc73971db6162bf60d775775b180cea06615b29c.tar.gz
sqlite-bc73971db6162bf60d775775b180cea06615b29c.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/expr.c4
-rw-r--r--src/main.c6
-rw-r--r--src/malloc.c6
-rw-r--r--src/mem1.c8
-rw-r--r--src/mem2.c12
-rw-r--r--src/pager.c10
-rw-r--r--src/pcache1.c4
-rw-r--r--src/sqliteInt.h9
-rw-r--r--src/test_wsd.c4
-rw-r--r--src/vdbeaux.c4
10 files changed, 33 insertions, 34 deletions
diff --git a/src/expr.c b/src/expr.c
index a7a954c09..edea9224d 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 5eddc02e6..072e14e07 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 dc111ba36..2678526ad 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 <stdarg.h>
@@ -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<sqlite3GlobalConfig.nScratch; i++){ mem0.aScratchFree[i] = i; }
@@ -134,7 +134,7 @@ int sqlite3MallocInit(void){
&& sqlite3GlobalConfig.nPage>=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 ca1e6aecf..e3b886341 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 436683659..8c498a2ab 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 fc13b38c2..335ec21e5 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"
@@ -100,12 +100,6 @@ int sqlite3PagerTrace=1; /* True to enable tracing */
#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
*/
#ifdef SQLITE_HAS_CODEC
@@ -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 d43ce6406..0f2c36d78 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 506daaee9..67836d1b0 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 a7fad263a..a5d10a71f 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 8ff424517..e1c965a7d 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;