aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorshane <shane@noemail.net>2008-07-08 22:28:48 +0000
committershane <shane@noemail.net>2008-07-08 22:28:48 +0000
commit1fc4129df7b6a304f050a5aadfaed4196fbd014e (patch)
tree824187b97d42e73531a7ad2bf0b84e3de0c2e1fc /src
parentc6f66c534914647794b1d2167b2f1e2d92aa0fa0 (diff)
downloadsqlite-1fc4129df7b6a304f050a5aadfaed4196fbd014e.tar.gz
sqlite-1fc4129df7b6a304f050a5aadfaed4196fbd014e.zip
Added macros to convert between 32-bit ints and 64-bit ptrs to avoid compiler warnings. (CVS 5378)
FossilOrigin-Name: 6cdb6841ff4683e424ef394733da9c24f5602570
Diffstat (limited to 'src')
-rw-r--r--src/build.c4
-rw-r--r--src/func.c8
-rw-r--r--src/insert.c4
-rw-r--r--src/sqliteInt.h18
-rw-r--r--src/table.c6
-rw-r--r--src/vdbeaux.c4
-rw-r--r--src/vdbemem.c4
-rw-r--r--src/where.c6
8 files changed, 35 insertions, 19 deletions
diff --git a/src/build.c b/src/build.c
index 1cff08b1f..926015fe9 100644
--- a/src/build.c
+++ b/src/build.c
@@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
-** $Id: build.c,v 1.488 2008/07/08 19:34:07 drh Exp $
+** $Id: build.c,v 1.489 2008/07/08 22:28:49 shane Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -2302,7 +2302,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
regRowid = regIdxKey + pIndex->nColumn;
j1 = sqlite3VdbeAddOp3(v, OP_IsNull, regIdxKey, 0, pIndex->nColumn);
j2 = sqlite3VdbeAddOp4(v, OP_IsUnique, iIdx,
- 0, regRowid, (char*)regRecord, P4_INT32);
+ 0, regRowid, SQLITE_INT_TO_PTR(regRecord), P4_INT32);
sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, OE_Abort, 0,
"indexed columns are not unique", P4_STATIC);
sqlite3VdbeJumpHere(v, j1);
diff --git a/src/func.c b/src/func.c
index 014d0af7f..47709caab 100644
--- a/src/func.c
+++ b/src/func.c
@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: func.c,v 1.194 2008/06/18 15:34:10 drh Exp $
+** $Id: func.c,v 1.195 2008/07/08 22:28:49 shane Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -908,7 +908,7 @@ static void trimFunc(
}
}
if( nChar>0 ){
- flags = (int)sqlite3_user_data(context);
+ flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context));
if( flags & 1 ){
while( nIn>0 ){
int len;
@@ -1286,7 +1286,7 @@ void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
void *pArg;
u8 argType = aFuncs[i].argType;
- pArg = (void*)(int)argType;
+ pArg = SQLITE_INT_TO_PTR(argType);
sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg,
aFuncs[i].eTextRep, pArg, aFuncs[i].xFunc, 0, 0);
if( aFuncs[i].needCollSeq ){
@@ -1304,7 +1304,7 @@ void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
sqlite3AttachFunctions(db);
#endif
for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){
- void *pArg = (void*)(int)aAggs[i].argType;
+ void *pArg = SQLITE_INT_TO_PTR(aAggs[i].argType);
sqlite3CreateFunc(db, aAggs[i].zName, aAggs[i].nArg, SQLITE_UTF8,
pArg, 0, aAggs[i].xStep, aAggs[i].xFinalize);
if( aAggs[i].needCollSeq ){
diff --git a/src/insert.c b/src/insert.c
index bada46654..586775e5c 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
-** $Id: insert.c,v 1.245 2008/07/08 19:34:07 drh Exp $
+** $Id: insert.c,v 1.246 2008/07/08 22:28:49 shane Exp $
*/
#include "sqliteInt.h"
@@ -1258,7 +1258,7 @@ void sqlite3GenerateConstraintChecks(
regR = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_SCopy, regRowid-hasTwoRowids, regR);
j3 = sqlite3VdbeAddOp4(v, OP_IsUnique, baseCur+iCur+1, 0,
- regR, (char*)aRegIdx[iCur],
+ regR, SQLITE_INT_TO_PTR(aRegIdx[iCur]),
P4_INT32);
/* Generate code that executes if the new index entry is not unique */
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index e56f6f514..103fd04fe 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.736 2008/07/08 19:34:07 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.737 2008/07/08 22:28:49 shane Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@@ -77,6 +77,22 @@
# define unlikely(X) !!(X)
#endif
+/*
+ * This macro is used to "hide" some ugliness in casting an int
+ * value to a ptr value under the MSVC 64-bit compiler. Casting
+ * non 64-bit values to ptr types results in a "hard" error with
+ * the MSVC 64-bit compiler which this attempts to avoid.
+ *
+ * A simple compiler pragma or casting sequence could not be found
+ * to correct this in all situations, so this macro was introduced.
+ *
+ * It could be argued that the intptr_t type could be used in this
+ * case, but that type is not available on all compilers, or
+ * requires the #include of specific headers which differs between
+ * platforms.
+ */
+#define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
+#define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
/*
** These #defines should enable >2GB file support on Posix if the
diff --git a/src/table.c b/src/table.c
index 563bf637f..1bd1bd19e 100644
--- a/src/table.c
+++ b/src/table.c
@@ -16,7 +16,7 @@
** These routines are in a separate files so that they will not be linked
** if they are not used.
**
-** $Id: table.c,v 1.35 2008/05/16 04:51:55 danielk1977 Exp $
+** $Id: table.c,v 1.36 2008/07/08 22:28:49 shane Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
@@ -147,7 +147,7 @@ int sqlite3_get_table(
res.azResult[0] = 0;
rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);
assert( sizeof(res.azResult[0])>= sizeof(res.nData) );
- res.azResult[0] = (char*)res.nData;
+ res.azResult[0] = SQLITE_INT_TO_PTR(res.nData);
if( (rc&0xff)==SQLITE_ABORT ){
sqlite3_free_table(&res.azResult[1]);
if( res.zErrMsg ){
@@ -192,7 +192,7 @@ void sqlite3_free_table(
int i, n;
azResult--;
assert( azResult!=0 );
- n = (int)azResult[0];
+ n = SQLITE_PTR_TO_INT(azResult[0]);
for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }
sqlite3_free(azResult);
}
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index 0a7dc6e6f..b774d994e 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.394 2008/07/08 19:34:07 drh Exp $
+** $Id: vdbeaux.c,v 1.395 2008/07/08 22:28:49 shane Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -535,7 +535,7 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){
if( n==P4_INT32 ){
/* Note: this cast is safe, because the origin data point was an int
** that was cast to a (const char *). */
- pOp->p4.i = (int)zP4;
+ pOp->p4.i = SQLITE_PTR_TO_INT(zP4);
pOp->p4type = n;
}else if( zP4==0 ){
pOp->p4.p = 0;
diff --git a/src/vdbemem.c b/src/vdbemem.c
index 7abf08dc7..22ca21d9a 100644
--- a/src/vdbemem.c
+++ b/src/vdbemem.c
@@ -15,7 +15,7 @@
** only within the VDBE. Interface routines refer to a Mem using the
** name sqlite_value
**
-** $Id: vdbemem.c,v 1.116 2008/07/08 14:52:10 drh Exp $
+** $Id: vdbemem.c,v 1.117 2008/07/08 22:28:49 shane Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -904,7 +904,7 @@ const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
expandBlob(pVal);
if( pVal->flags&MEM_Str ){
sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED);
- if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&(int)pVal->z) ){
+ if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&SQLITE_PTR_TO_INT(pVal->z)) ){
assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );
if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){
return 0;
diff --git a/src/where.c b/src/where.c
index 069b70778..b59450a0c 100644
--- a/src/where.c
+++ b/src/where.c
@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
-** $Id: where.c,v 1.313 2008/07/08 19:45:02 drh Exp $
+** $Id: where.c,v 1.314 2008/07/08 22:28:49 shane Exp $
*/
#include "sqliteInt.h"
@@ -2605,7 +2605,7 @@ WhereInfo *sqlite3WhereBegin(
testcase( op==OP_MoveLe );
testcase( op==OP_MoveLt );
sqlite3VdbeAddOp4(v, op, iIdxCur, nxt, regBase,
- (char*)nConstraint, P4_INT32);
+ SQLITE_INT_TO_PTR(nConstraint), P4_INT32);
/* Load the value for the inequality constraint at the end of the
** range (if any).
@@ -2627,7 +2627,7 @@ WhereInfo *sqlite3WhereBegin(
testcase( op==OP_IdxGE );
testcase( op==OP_IdxLT );
sqlite3VdbeAddOp4(v, op, iIdxCur, nxt, regBase,
- (char*)nConstraint, P4_INT32);
+ SQLITE_INT_TO_PTR(nConstraint), P4_INT32);
sqlite3VdbeChangeP5(v, endEq!=bRev);
/* If there are inequality constraints, check that the value