1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Attempting to add support for 64-bit platforms. (CVS 314)

FossilOrigin-Name: 03673adbfe0c8a92d79f86ddf1136736594208ad
This commit is contained in:
drh
2001-11-21 02:21:11 +00:00
parent bc1bd58acf
commit 5a2c2c20af
10 changed files with 73 additions and 63 deletions

View File

@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.39 2001/11/10 13:51:08 drh Exp $
** $Id: btree.c,v 1.40 2001/11/21 02:21:12 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@ -54,26 +54,6 @@
#include "btree.h"
#include <assert.h>
/*
** Primitive data types. u32 must be 4 bytes and u16 must be 2 bytes.
** The uptr type must be big enough to hold a pointer.
** Change these typedefs when porting to new architectures.
*/
typedef unsigned int uptr;
/* There are already defined in sqliteInt.h...
** typedef unsigned int u32;
** typedef unsigned short int u16;
** typedef unsigned char u8;
*/
/*
** This macro casts a pointer to an integer. Useful for doing
** pointer arithmetic.
*/
#define Addr(X) ((uptr)X)
/*
** Forward declarations of structures used only in this file.
*/
@ -829,7 +809,7 @@ int sqliteBtreeRollback(Btree *pBt){
int sqliteBtreeCursor(Btree *pBt, int iTable, int wrFlag, BtCursor **ppCur){
int rc;
BtCursor *pCur;
int nLock;
ptr nLock;
if( pBt->page1==0 ){
rc = lockBtree(pBt);
@ -852,7 +832,7 @@ int sqliteBtreeCursor(Btree *pBt, int iTable, int wrFlag, BtCursor **ppCur){
if( rc!=SQLITE_OK ){
goto create_cursor_exception;
}
nLock = (int)sqliteHashFind(&pBt->locks, 0, iTable);
nLock = (ptr)sqliteHashFind(&pBt->locks, 0, iTable);
if( nLock<0 || (nLock>0 && wrFlag) ){
rc = SQLITE_LOCKED;
goto create_cursor_exception;
@ -886,7 +866,7 @@ create_cursor_exception:
** when the last cursor is closed.
*/
int sqliteBtreeCloseCursor(BtCursor *pCur){
int nLock;
ptr nLock;
Btree *pBt = pCur->pBt;
if( pCur->pPrev ){
pCur->pPrev->pNext = pCur->pNext;
@ -900,7 +880,7 @@ int sqliteBtreeCloseCursor(BtCursor *pCur){
sqlitepager_unref(pCur->pPage);
}
unlockBtreeIfUnused(pBt);
nLock = (int)sqliteHashFind(&pBt->locks, 0, pCur->pgnoRoot);
nLock = (ptr)sqliteHashFind(&pBt->locks, 0, pCur->pgnoRoot);
assert( nLock!=0 || sqlite_malloc_failed );
nLock = nLock<0 ? 0 : nLock-1;
sqliteHashInsert(&pBt->locks, 0, pCur->pgnoRoot, (void*)nLock);
@ -2293,11 +2273,11 @@ static int clearDatabasePage(Btree *pBt, Pgno pgno, int freePageFlag){
*/
int sqliteBtreeClearTable(Btree *pBt, int iTable){
int rc;
int nLock;
ptr nLock;
if( !pBt->inTrans ){
return SQLITE_ERROR; /* Must start a transaction first */
}
nLock = (int)sqliteHashFind(&pBt->locks, 0, iTable);
nLock = (ptr)sqliteHashFind(&pBt->locks, 0, iTable);
if( nLock ){
return SQLITE_LOCKED;
}

View File

@ -25,7 +25,7 @@
** ROLLBACK
** PRAGMA
**
** $Id: build.c,v 1.55 2001/11/07 16:48:27 drh Exp $
** $Id: build.c,v 1.56 2001/11/21 02:21:12 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -101,7 +101,7 @@ Expr *sqliteExpr(int op, Expr *pLeft, Expr *pRight, Token *pToken){
void sqliteExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){
if( pExpr ){
pExpr->span.z = pLeft->z;
pExpr->span.n = pRight->n + (int)pRight->z - (int)pLeft->z;
pExpr->span.n = pRight->n + Addr(pRight->z) - Addr(pLeft->z);
}
}
@ -498,7 +498,7 @@ void sqliteAddColumnType(Parse *pParse, Token *pFirst, Token *pLast){
i = p->nCol-1;
if( i<0 ) return;
pz = &p->aCol[i].zType;
n = pLast->n + ((int)pLast->z) - (int)pFirst->z;
n = pLast->n + Addr(pLast->z) - Addr(pFirst->z);
sqliteSetNString(pz, pFirst->z, n, 0);
z = *pz;
if( z==0 ) return;
@ -618,7 +618,7 @@ void sqliteEndTable(Parse *pParse, Token *pEnd){
v = sqliteGetVdbe(pParse);
if( v==0 ) return;
n = (int)pEnd->z - (int)pParse->sFirstToken.z + 1;
n = Addr(pEnd->z) - Addr(pParse->sFirstToken.z) + 1;
if( !p->isTemp ){
sqliteVdbeAddOp(v, OP_NewRecno, 0, 0);
sqliteVdbeAddOp(v, OP_String, 0, 0);
@ -972,7 +972,7 @@ void sqliteCreateIndex(
if( !isTemp ){
addr = sqliteVdbeAddOp(v, OP_String, 0, 0);
if( pStart && pEnd ){
n = (int)pEnd->z - (int)pStart->z + 1;
n = Addr(pEnd->z) - Addr(pStart->z) + 1;
sqliteVdbeChangeP3(v, addr, pStart->z, n);
}
sqliteVdbeAddOp(v, OP_MakeRecord, 5, 0);

View File

@ -12,7 +12,7 @@
** This is the implementation of generic hash-tables
** used in SQLite.
**
** $Id: hash.c,v 1.3 2001/10/22 02:58:10 drh Exp $
** $Id: hash.c,v 1.4 2001/11/21 02:21:12 drh Exp $
*/
#include "sqliteInt.h"
#include <assert.h>
@ -68,11 +68,13 @@ static int intCompare(const void *pKey1, int n1, const void *pKey2, int n2){
** Hash and comparison functions when the mode is SQLITE_HASH_POINTER
*/
static int ptrHash(const void *pKey, int nKey){
nKey = (int)pKey;
return nKey ^ (nKey<<8) ^ (nKey>>8);
uptr x = Addr(pKey);
return x ^ (x<<8) ^ (x>>8);
}
static int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2){
return ((int)pKey2) - (int)pKey1;
if( pKey1==pKey2 ) return 0;
if( pKey1<pKey2 ) return -1;
return 1;
}
/*

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.69 2001/11/08 00:45:21 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.70 2001/11/21 02:21:12 drh Exp $
*/
#include "sqlite.h"
#include "hash.h"
@ -31,12 +31,35 @@
#define TEMP_PAGES 25
/*
** Integers of known sizes. These typedefs much change for architectures
** where the sizes very.
** Integers of known sizes. These typedefs might change for architectures
** where the sizes very. Preprocessor macros are available so that the
** types can be conveniently redefined at compile-type. Like this:
**
** cc '-DUINTPTR_TYPE=long long int' ...
*/
typedef unsigned int u32; /* 4-byte unsigned integer */
typedef unsigned short int u16; /* 2-byte unsigned integer */
typedef unsigned char u8; /* 1-byte unsigned integer */
#ifndef UINT32_TYPE
# define UINT32_TYPE unsigned int
#endif
#ifndef UINT16_TYPE
# define UINT16_TYPE unsigned short int
#endif
#ifndef UINT8_TYPE
# define UINT8_TYPE unsigned char
#endif
#ifndef INTPTR_TYPE
# define INTPTR_TYPE int
#endif
typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
typedef INTPTR_TYPE ptr; /* Big enough to hold a pointer */
typedef unsigned INTPTR_TYPE uptr; /* Big enough to hold a pointer */
/*
** This macro casts a pointer to an integer. Useful for doing
** pointer arithmetic.
*/
#define Addr(X) ((uptr)X)
/*
** The maximum number of bytes of data that can be put into a single

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle UPDATE statements.
**
** $Id: update.c,v 1.21 2001/11/07 14:22:00 drh Exp $
** $Id: update.c,v 1.22 2001/11/21 02:21:12 drh Exp $
*/
#include "sqliteInt.h"
@ -110,7 +110,7 @@ void sqliteUpdate(
}
}
/* Allocate memory for the array apIdx[] and fill it pointers to every
/* Allocate memory for the array apIdx[] and fill it with pointers to every
** index that needs to be updated. Indices only need updating if their
** key includes one of the columns named in pChanges.
*/
@ -193,7 +193,7 @@ void sqliteUpdate(
sqliteVdbeAddOp(v, OP_IdxDelete, base+i+1, 0);
}
/* Compute a completely new data for this record.
/* Compute new data for this record.
*/
for(i=0; i<pTab->nCol; i++){
j = aXRef[i];

View File

@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.31 2001/11/06 04:00:19 drh Exp $
** $Id: util.c,v 1.32 2001/11/21 02:21:12 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@ -769,7 +769,8 @@ int sqliteSortCompare(const char *a, const char *b){
** The following procedure converts a double-precision floating point
** number into a string. The resulting string has the property that
** two such strings comparied using strcmp() or memcmp() will give the
** same results as comparing the original floating point numbers.
** same results as a numeric comparison of the original floating point
** numbers.
**
** This routine is used to generate database keys from floating point
** numbers such that the keys sort in the same order as the original