On Wed, 20 Apr 2005, Ted Unangst wrote:
>Christian Smith wrote:
>> On Mon, 18 Apr 2005, Cem Vedat ISIK wrote:
>>
>>
>>>Having a lot of cross compiling trials and errors, I have decided not to
>>>cross compile, but to compile the SQLite on Motorola PowerPC itself.
>>
>>
>>
>> If this is still the config.h issue, I have made some changes to allow
>> compiling without config.h being generated. It's only used for dodgy
>> pointer arithmatic in a couple of places, and can be done more portably
>> without converting pointers to integers.
>>
>> Try the attached patch, against the latest CVS source, which removes the
>> need for config.h, hence removing the need to generate config.h. I've not
>> removed config.h from Makefile.in or Makefile.linux-gcc. All tests on
>> Linux x86 with gcc 3.3.3 pass OK with this code. Not tested on other
>> platforms or cross-compile. Apply patch (in sqlite directory) with:
>
>Looks like it will deref 0 to get Timeout in some cases.
>
No, it's worse than that. sqliteDefaultBusyCallback() will always get a
pointer, but it will get a pointer to an int that no longer exists
(sqliteDefaultBusyCallback() is called when the database is busy, not when
sqlite3_busy_timeout() is called, and so will point to garbage.
In this case, the timeout for sqlite3_busy_timeout() should be converted
to a pointer and passed as before. However, as sizeof(int)<=sizeof(void*)
on all platforms I know of, there should be no problems simply casting the
int to a void* and then casting back in sqliteDefaultBusyCallback().
Updated patch against CVS head attached.
Christian
--
/"\
\ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
X - AGAINST MS ATTACHMENTS
/ \
Index: src/btree.c
===================================================================
RCS file: /sqlite/sqlite/src/btree.c,v
retrieving revision 1.256
diff -u -r1.256 btree.c
--- src/btree.c 29 Mar 2005 13:17:46 -0000 1.256
+++ src/btree.c 21 Apr 2005 09:50:01 -0000
@@ -1216,8 +1216,10 @@
assert( sizeof(u32)==4 );
assert( sizeof(u16)==2 );
assert( sizeof(Pgno)==4 );
+#if 0
assert( sizeof(ptr)==sizeof(char*) );
assert( sizeof(uptr)==sizeof(ptr) );
+#endif
pBt = sqliteMalloc( sizeof(*pBt) );
if( pBt==0 ){
Index: src/build.c
===================================================================
RCS file: /sqlite/sqlite/src/build.c,v
retrieving revision 1.318
diff -u -r1.318 build.c
--- src/build.c 29 Mar 2005 03:10:59 -0000 1.318
+++ src/build.c 21 Apr 2005 09:50:01 -0000
@@ -1510,7 +1510,7 @@
if( pSelect ){
zStmt = createTableStmt(p);
}else{
- n = Addr(pEnd->z) - Addr(pParse->sNameToken.z) + 1;
+ n = pEnd->z - pParse->sNameToken.z + 1;
zStmt = sqlite3MPrintf("CREATE %s %.*s", zType2, n,
pParse->sNameToken.z);
}
@@ -2463,7 +2463,7 @@
/* A named index with an explicit CREATE INDEX statement */
zStmt = sqlite3MPrintf("CREATE%s INDEX %.*s",
onError==OE_None ? "" : " UNIQUE",
- Addr(pEnd->z) - Addr(pName->z) + 1,
+ pEnd->z - pName->z + 1,
pName->z);
}else{
/* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
Index: src/expr.c
===================================================================
RCS file: /sqlite/sqlite/src/expr.c,v
retrieving revision 1.197
diff -u -r1.197 expr.c
--- src/expr.c 21 Mar 2005 03:53:38 -0000 1.197
+++ src/expr.c 21 Apr 2005 09:50:01 -0000
@@ -265,7 +265,7 @@
assert( pLeft->dyn==0 || pLeft->z[pLeft->n]==0 );
if( pLeft->dyn==0 && pRight->dyn==0 ){
pExpr->span.z = pLeft->z;
- pExpr->span.n = pRight->n + Addr(pRight->z) - Addr(pLeft->z);
+ pExpr->span.n = pRight->n + (pRight->z - pLeft->z);
}else{
pExpr->span.z = 0;
}
Index: src/main.c
===================================================================
RCS file: /sqlite/sqlite/src/main.c,v
retrieving revision 1.285
diff -u -r1.285 main.c
--- src/main.c 29 Mar 2005 23:34:58 -0000 1.285
+++ src/main.c 21 Apr 2005 09:50:01 -0000
@@ -623,8 +623,8 @@
static const short int totals[] =
{ 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228, 287};
# define NDELAY (sizeof(delays)/sizeof(delays[0]))
- ptr timeout = (ptr)Timeout;
- ptr delay, prior;
+ int timeout = (int)Timeout;
+ int delay, prior;
if( count <= NDELAY ){
delay = delays[count-1];
@@ -699,7 +699,7 @@
*/
int sqlite3_busy_timeout(sqlite3 *db, int ms){
if( ms>0 ){
- sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)(ptr)ms);
+ sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)ms);
}else{
sqlite3_busy_handler(db, 0, 0);
}
Index: src/sqliteInt.h
===================================================================
RCS file: /sqlite/sqlite/src/sqliteInt.h,v
retrieving revision 1.375
diff -u -r1.375 sqliteInt.h
--- src/sqliteInt.h 29 Mar 2005 03:10:59 -0000 1.375
+++ src/sqliteInt.h 21 Apr 2005 09:50:01 -0000
@@ -39,7 +39,9 @@
# define _LARGEFILE_SOURCE 1
#endif
+#if 0
#include "config.h"
+#endif
#include "sqlite3.h"
#include "hash.h"
#include "parse.h"
@@ -180,6 +182,7 @@
#ifndef LONGDOUBLE_TYPE
# define LONGDOUBLE_TYPE long double
#endif
+#if 0
#ifndef INTPTR_TYPE
# if SQLITE_PTR_SZ==4
# define INTPTR_TYPE int
@@ -194,6 +197,7 @@
# define UINTPTR_TYPE sqlite_uint64
# endif
#endif
+#endif /* 0 */
typedef sqlite_int64 i64; /* 8-byte signed integer */
typedef UINT64_TYPE u64; /* 8-byte unsigned integer */
typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
@@ -201,8 +205,10 @@
typedef INT16_TYPE i16; /* 2-byte signed integer */
typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
typedef UINT8_TYPE i8; /* 1-byte signed integer */
+#if 0
typedef INTPTR_TYPE ptr; /* Big enough to hold a pointer */
typedef UINTPTR_TYPE uptr; /* Big enough to hold a pointer */
+#endif
/*
** Macros to determine whether the machine is big or little endian,