Skip to content
Snippets Groups Projects
Commit bbff6158 authored by Mergen Imeev's avatar Mergen Imeev Committed by Vladimir Davydov
Browse files

sql: remove macro to convert int to pointer

This patch removes macros that were used to convert int to pointer and
vice versa. These macros have been removed as they are no longer needed.

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring
parent 5d658e7e
No related branches found
No related tags found
No related merge requests found
......@@ -135,34 +135,6 @@
#include <inttypes.h>
#endif
/*
* The following macros are used to cast pointers to integers and
* integers to pointers. The way you do this varies from one compiler
* to the next, so we have developed the following set of #if statements
* to generate appropriate macros for a wide range of compilers.
*
* The correct "ANSI" way to do this is to use the intptr_t type.
* Unfortunately, that typedef is not available on all compilers, or
* if it is available, it requires an #include of specific headers
* that vary from one machine to the next.
*
* Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
* the ((void*)&((char*)0)[X]) construct.
*/
#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
#define SQL_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
#define SQL_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
#define SQL_INT_TO_PTR(X) ((void*)&((char*)0)[X])
#define SQL_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
#define SQL_INT_TO_PTR(X) ((void*)(intptr_t)(X))
#define SQL_PTR_TO_INT(X) ((int)(intptr_t)(X))
#else /* Generates a warning - but it always works */
#define SQL_INT_TO_PTR(X) ((void*)(X))
#define SQL_PTR_TO_INT(X) ((int)(X))
#endif
/*
* A macro to hint to the compiler that a function should not be
* inlined.
......
......@@ -437,8 +437,8 @@ sqlUpdate(Parse * pParse, /* The parser context */
0, (const char *)upd_cols, P4_DYNAMIC);
u16 pik_flags = OPFLAG_NCHANGE;
SET_CONFLICT_FLAG(pik_flags, on_error);
sqlVdbeAddOp4(v, OP_Update, regNew, key_reg,
upd_cols_reg, (char *)reg, P4_INT32);
sqlVdbeAddOp4Int(v, OP_Update, regNew, key_reg,
upd_cols_reg, reg);
sqlVdbeChangeP5(v, pik_flags);
}
}
......
......@@ -305,6 +305,7 @@ sqlVdbeAddOp4(Vdbe * p, /* Add the opcode to this VM */
int p4type) /* P4 operand type */
{
assert(p4type != P4_INT32);
int addr = sqlVdbeAddOp3(p, op, p1, p2, p3);
sqlVdbeChangeP4(p, addr, zP4, p4type);
return addr;
......@@ -704,13 +705,7 @@ sqlVdbeChangeP4(Vdbe * p, int addr, const char *zP4, int n)
vdbeChangeP4Full(p, pOp, zP4, n);
return;
}
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 = SQL_PTR_TO_INT(zP4);
pOp->p4type = P4_INT32;
} if (n == P4_BOOL) {
if (n == P4_BOOL) {
pOp->p4.b = *(bool*)zP4;
pOp->p4type = P4_BOOL;
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment