mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-21 09:00:59 +03:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
12
src/mem2.c
12
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);
|
||||
}
|
||||
|
||||
|
||||
10
src/pager.c
10
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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user