/ Check-in [ddee7ff2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ddee7ff23e9a396cab89d20ff9fc4cf3dfd4561c
User & Date: drh 2009-05-16 17:38:21
Context
2009-05-17
02:06
Tweaks and simplifications to select.c to facility full coverage testing. (CVS 6642) check-in: e3ccbc69 user: drh tags: trunk
2009-05-16
17:38
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) check-in: ddee7ff2 user: drh tags: trunk
2009-05-15
14:41
Re-enable file locking in async4.test. (CVS 6640) check-in: f7098187 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65





66




67
68

69
70
71
72
73
74
75
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.871 2009/05/13 17:21:14 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build
................................................................................
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#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
** underlying operating system supports it.  If the OS lacks
** large file support, or if the OS is windows, these should be no-ops.
**
** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any







|







 







|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
|
>
>
>
>
|
|
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.872 2009/05/16 17:38:21 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build
................................................................................
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#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.
**
** 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_PTR_TO_INT(X)   ((int)(((char*)X)-(char*)0))
#endif

/*
** These #defines should enable >2GB file support on POSIX if the
** underlying operating system supports it.  If the OS lacks
** large file support, or if the OS is windows, these should be no-ops.
**
** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any