1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-06 15:49:35 +03:00

Attempt to provide a version of the SQLITE_INT_TO_PTR macro that works

on both llvm-gcc-4.2 and MSVC.  Ticket #3860. (CVS 6641)

FossilOrigin-Name: ddee7ff23e9a396cab89d20ff9fc4cf3dfd4561c
This commit is contained in:
drh
2009-05-16 17:38:21 +00:00
parent 74632880b7
commit 875e9e7d88
3 changed files with 34 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
C Re-enable\sfile\slocking\sin\sasync4.test.\s(CVS\s6640) C Attempt\sto\sprovide\sa\sversion\sof\sthe\sSQLITE_INT_TO_PTR\smacro\sthat\sworks\non\sboth\sllvm-gcc-4.2\sand\sMSVC.\s\sTicket\s#3860.\s(CVS\s6641)
D 2009-05-15T14:41:40 D 2009-05-16T17:38:21
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -162,7 +162,7 @@ F src/select.c 2877098ffabd751c274aa5f993d515484d955896
F src/shell.c 0a11f831603f17fea20ca97133c0f64e716af4a7 F src/shell.c 0a11f831603f17fea20ca97133c0f64e716af4a7
F src/sqlite.h.in 85c4398938ee2fd1382fee24bbedd5342a2bc2ed F src/sqlite.h.in 85c4398938ee2fd1382fee24bbedd5342a2bc2ed
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17 F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
F src/sqliteInt.h d20ac97b4daf97621d641f52ac16e8ff26fb53fd F src/sqliteInt.h f45e2a34e91803d1f10406dd73a2327bee894865
F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76 F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c cc86ad3d6ad54df7c63a3e807b5783c90411a08d F src/table.c cc86ad3d6ad54df7c63a3e807b5783c90411a08d
@@ -729,7 +729,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P e8ca932d8c7e1753c159041499355724d3e78b35 P f7098187280866a56563c7614513a40becd172e0
R 4039bbedaa716152755b0bba07446db3 R 7dde16074ccb85e393d78533a8d161b4
U danielk1977 U drh
Z 79003871abff44e9b110627807ec8d3b Z 8b4c2b5d43c85ad0807aa2ba5ab2e1e1

View File

@@ -1 +1 @@
f7098187280866a56563c7614513a40becd172e0 ddee7ff23e9a396cab89d20ff9fc4cf3dfd4561c

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** Internal interface definitions for SQLite.
** **
** @(#) $Id: sqliteInt.h,v 1.871 2009/05/13 17:21:14 drh Exp $ ** @(#) $Id: sqliteInt.h,v 1.872 2009/05/16 17:38:21 drh Exp $
*/ */
#ifndef _SQLITEINT_H_ #ifndef _SQLITEINT_H_
#define _SQLITEINT_H_ #define _SQLITEINT_H_
@@ -51,21 +51,31 @@
#endif #endif
/* /*
* This macro is used to "hide" some ugliness in casting an int ** This macro is used to "hide" some ugliness in casting an int
* value to a ptr value under the MSVC 64-bit compiler. Casting ** 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 ** non 64-bit values to ptr types results in a "hard" error with
* the MSVC 64-bit compiler which this attempts to avoid. ** the MSVC 64-bit compiler which this attempts to avoid.
* **
* A simple compiler pragma or casting sequence could not be found ** A simple compiler pragma or casting sequence could not be found
* to correct this in all situations, so this macro was introduced. ** 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 ** 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 ** case, but that type is not available on all compilers, or
* requires the #include of specific headers which differs between ** requires the #include of specific headers which differs between
* platforms. ** platforms.
**
** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
** We we have to define the macros in different ways depending on the
** compiler.
*/ */
#if defined(__GNUC__)
# define SQLITE_INT_TO_PTR(X) ((void*)(X))
# define SQLITE_PTR_TO_INT(X) ((int)(X))
#else
# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X]) # define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) # define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
#endif
/* /*
** These #defines should enable >2GB file support on POSIX if the ** These #defines should enable >2GB file support on POSIX if the