1 | /*------------------------------------------------------------------------------ |
2 | * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team |
3 | * |
4 | * Distributable under the terms of either the Apache License (Version 2.0) or |
5 | * the GNU Lesser General Public License, as specified in the COPYING file. |
6 | ------------------------------------------------------------------------------*/ |
7 | #if !defined(lucene_compiler_h) |
8 | #define lucene_compiler_h |
9 | |
10 | #if defined(_MBCS) || defined(_ASCII) |
11 | #undef _ASCII |
12 | #undef _UCS2 |
13 | #define _ASCII |
14 | #elif defined(_UNICODE) |
15 | #define _UCS2 |
16 | #elif !defined(_UCS2) |
17 | #define _UCS2 |
18 | #endif |
19 | |
20 | //msvc needs unicode define so that it uses unicode library |
21 | #ifdef _UCS2 |
22 | #undef _UNICODE |
23 | #define _UNICODE |
24 | #undef _ASCII |
25 | #else |
26 | #undef _UNICODE |
27 | #undef _UCS2 |
28 | #endif |
29 | |
30 | |
31 | //////////////////////////////////////////////////////////////////// |
32 | // Figure out what compiler we are using |
33 | //////////////////////////////////////////////////////////////////// |
34 | |
35 | #if defined(_MSC_VER) && !defined(__MWERKS__) && !defined (__COMO__) |
36 | #define _CLCOMPILER_MSVC _MSC_VER |
37 | #endif |
38 | |
39 | #if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__xlC__) || defined(__sgi) && defined(__EDG__) |
40 | #include "CLucene/config/CompilerGcc.h" |
41 | |
42 | #elif defined(_CLCOMPILER_MSVC) |
43 | /* Microsoft Visual C++ */ |
44 | #include "CLucene/config/CompilerMsvc.h" |
45 | |
46 | #elif defined (__BORLANDC__) |
47 | #include "CLucene/config/CompilerBcb.h" |
48 | |
49 | #elif defined (__HP_aCC) |
50 | #include "CLucene/config/CompilerAcc.h" |
51 | |
52 | #else |
53 | //Unable to identify the compiler, issue error diagnostic. |
54 | //Edit <CLucene/config/LuceneMycomp.h> to set STLport up for your compiler. |
55 | //Uncomment this next line |
56 | #error "Unable to identify the compiler, issue error diagnostic. Edit <CLucene/config/CompilerMycomp.h> to set Lucene up for your compiler." |
57 | #include "CLucene/config/LuceneMycomp.h" |
58 | #endif /* end of compiler choice */ |
59 | //////////////////////////////////////////////////////////////////// |
60 | |
61 | |
62 | |
63 | //////////////////////////////////////////////////////////////////// |
64 | // Now include platform specific definitions |
65 | //////////////////////////////////////////////////////////////////// |
66 | |
67 | /* Operating system recognition (basic) */ |
68 | #if defined (__unix) || defined (__linux__) || defined (__QNX__) || defined (_AIX) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__Lynx__) || defined(hpux) || defined(__hpux) |
69 | #undef _UNIX |
70 | #define _UNIX 1 |
71 | #include "CLucene/config/PlatformUnix.h" |
72 | |
73 | #elif defined(macintosh) || defined (_MAC) || defined(__APPLE__) |
74 | #undef _MAC |
75 | #define _MAC 1 |
76 | #include "CLucene/config/PlatformMac.h" |
77 | |
78 | #elif defined (_WIN32) || defined (__WIN32) || defined (WIN32) || defined (__WIN32__) |
79 | #undef _WIN32 |
80 | #define _WIN32 |
81 | #include "CLucene/config/PlatformWin32.h" |
82 | |
83 | #elif defined (__WIN16) || defined (WIN16) || defined (_WIN16) |
84 | #undef _WIN16 |
85 | #define _WIN16 |
86 | #error "CLucene has not been tested on this platform. Please send a report to the lucene administrators if you are able to successfully compile" |
87 | #else |
88 | #error "CLucene could not identify the platform." |
89 | #endif /* platforms */ |
90 | |
91 | |
92 | |
93 | //////////////////////////////////////////////////////////////////// |
94 | // Now we take all that we have learnt, and define some things |
95 | //////////////////////////////////////////////////////////////////// |
96 | |
97 | //lets just say that we can always do unicode! :) |
98 | #ifdef CL_CHARSET_GUESS |
99 | #define _UCS2 |
100 | #endif |
101 | |
102 | #if defined(_ASCII) |
103 | #undef _UCS2 |
104 | #elif defined(_UCS2) |
105 | #undef _ASCII |
106 | #endif |
107 | |
108 | #ifndef _LUCENE_NO_NEW_STYLE_CASTS |
109 | #define __CONST_CAST(typ,var) const_cast<typ>(var) |
110 | #define __REINTERPRET_CAST(typ,var) reinterpret_cast<typ>(var) |
111 | #else |
112 | #define __CONST_CAST(typ,var) ((typ)(var)) |
113 | #define __REINTERPRET_CAST,var) ((typ)(var)) |
114 | #endif |
115 | |
116 | #ifndef _CL_DEPRECATE_TEXT |
117 | #define _CL_DEPRECATE_TEXT(_Text) |
118 | #endif |
119 | #define _CL_DEPRECATED(_NewItem) _CL_DEPRECATE_TEXT("This function or variable has been superceded by newer library or operating system functionality. Consider using" #_NewItem "instead. See online help for details.") |
120 | |
121 | |
122 | //cnd-debug exit command |
123 | #ifndef debugFatalExit |
124 | #define debugFatalExit(ret) exit(ret) |
125 | #endif |
126 | |
127 | #ifndef _CL_ILONG |
128 | #define _CL_ILONG(x) x ## L |
129 | #endif |
130 | #ifndef _ILONGLONG |
131 | #define _ILONGLONG(x) x ## LL |
132 | #endif |
133 | |
134 | //define whats the values of item intergers *should* be. we can check this in a test |
135 | #define LUCENE_INT64_MAX_SHOULDBE _ILONGLONG(0x7FFFFFFFFFFFFFFF) |
136 | #define LUCENE_INT32_MAX_SHOULDBE 0x7FFFFFFFL |
137 | #define LUCENE_UINT8_MAX_SHOULDBE 0xff |
138 | |
139 | //maximum path length. only used for buffers that use fullpath. |
140 | //anything else should use a dynamic length. |
141 | #if defined(CL_MAX_PATH) |
142 | //do nothing... |
143 | #elif defined(PATH_MAX) |
144 | #define CL_MAX_PATH PATH_MAX |
145 | #elif defined(MAX_PATH) |
146 | #define CL_MAX_PATH MAX_PATH |
147 | #elif defined(_MAX_PATH) |
148 | #define CL_MAX_PATH _MAX_PATH |
149 | #else |
150 | #error "CL_MAX_PATH could not be determined" |
151 | #endif |
152 | |
153 | //this is the max filename... for now its just the same, |
154 | //but this could change, so we use a different name |
155 | #define CL_MAX_NAME CL_MAX_PATH |
156 | //this used to be CL_MAX_NAME * 32, but as Alex Hudson points out, this could come to be 128kb. |
157 | //the above logic for CL_MAX_NAME should be correct enough to handle all file names |
158 | #define CL_MAX_DIR CL_MAX_PATH |
159 | |
160 | #ifdef _LARGE_FILES |
161 | #define LUCENE_MAX_FILELENGTH LUCENE_INT64_MAX_SHOULDBE |
162 | #else |
163 | #define LUCENE_MAX_FILELENGTH LUCENE_INT32_MAX_SHOULDBE |
164 | #endif |
165 | |
166 | //use the LUCENE_STATIC_CONSTANT_SYNTAX to determine LUCENE_STATIC_CONSTANT |
167 | #ifndef LUCENE_STATIC_CONSTANT |
168 | //autoconf is not properly detecting the correct method for this, and since there's no real big |
169 | //harm in always using an enum, we'll probably just make this the default. |
170 | /*#if LUCENE_STATIC_CONSTANT_SYNTAX == 1 |
171 | #define LUCENE_STATIC_CONSTANT(type, assignment) static const type assignment |
172 | #elif LUCENE_STATIC_CONSTANT_SYNTAX == 2*/ |
173 | #define LUCENE_STATIC_CONSTANT(type, assignment) enum { assignment } |
174 | /*#else |
175 | #error "LUCENE_STATIC_CONSTANT not defined, and/or LUCENE_STATIC_CONSTANT_SYNTAX is not defined to a valid value" |
176 | #endif*/ |
177 | #endif |
178 | |
179 | //end of lucene_compiler_h |
180 | #elif !defined(lucene_compiler_h2) |
181 | #define lucene_compiler_h2 |
182 | //here we include the compiler header again, this gives the header a |
183 | //second chance at including stuff, after the main inclusions are complete |
184 | |
185 | #if defined (__GNUC__) || defined(__SUNPRO_CC) || defined(__xlC__) || defined(__sgi) && defined(__EDG__) |
186 | #include "CLucene/config/CompilerGcc.h" |
187 | |
188 | #elif defined(_CLCOMPILER_MSVC) |
189 | /* Microsoft Visual C++ */ |
190 | #include "CLucene/config/CompilerMsvc.h" |
191 | |
192 | #elif defined __BORLANDC__ |
193 | #include "CLucene/config/CompilerBcb.h" |
194 | |
195 | #elif defined (__HP_aCC) |
196 | #include "CLucene/config/CompilerAcc.h" |
197 | |
198 | #else |
199 | //Unable to identify the compiler, issue error diagnostic. |
200 | //Edit <CLucene/config/LuceneMycomp.h> to set STLport up for your compiler. |
201 | //Uncomment this next line |
202 | #error "Unable to identify the compiler, issue error diagnostic. Edit <CLucene/config/CompilerMycomp.h> to set Lucene up for your compiler." |
203 | #include "CLucene/config/LuceneMycomp.h" |
204 | #endif /* end of compiler choice */ |
205 | |
206 | #ifndef _CL_HAVE_FLOAT_T |
207 | //#ifdef _CL_HAVE_LONG_DOUBLE |
208 | // long double's are not working (reported by Mark Ashworth on Solaris 64) |
209 | // typedef long double float_t; /* `float' expressions are evaluated as `long double'. */ |
210 | //#else |
211 | // we are going to use qreal now |
212 | // typedef double float_t; |
213 | //#endif |
214 | #endif |
215 | |
216 | /*todo: but need to define SIZEOF_VOID_P #if (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8) |
217 | #ifndef _CL_HAVE_INTPTR_T |
218 | typedef int64_t intptr_t; |
219 | #endif |
220 | #elif (SIZEOF_VOID_P > 2 && SIZEOF_VOID_P <= 4) |
221 | # ifndef _CL_HAVE_INTPTR_T |
222 | typedef int32_t intptr_t; |
223 | # endif |
224 | #else |
225 | #error "void * is either >8 bytes or <= 2. In either case, I am confused." |
226 | #endif*/ |
227 | |
228 | #ifndef _CL_HAVE_INTPTR_T |
229 | typedef int intptr_t; |
230 | #endif |
231 | |
232 | //end of lucene_compiler_h2 |
233 | #elif !defined(lucene_compiler_h3) |
234 | #define lucene_compiler_h3 |
235 | //here we include the compiler header again, this gives the header a |
236 | //third chance at including stuff, after the main inclusions are complete |
237 | |
238 | #if defined (__GNUC__ ) || defined(__SUNPRO_CC) || defined(__xlC__) || defined(__sgi) && defined(__EDG__) |
239 | #include "CLucene/config/CompilerGcc.h" |
240 | |
241 | #elif defined(_CLCOMPILER_MSVC) |
242 | /* Microsoft Visual C++ */ |
243 | #include "CLucene/config/CompilerMsvc.h" |
244 | |
245 | #elif defined __BORLANDC__ |
246 | #include "CLucene/config/CompilerBcb.h" |
247 | |
248 | #elif defined (__HP_aCC) |
249 | #include "CLucene/config/CompilerAcc.h" |
250 | |
251 | #else |
252 | //Unable to identify the compiler, issue error diagnostic. |
253 | //Edit <CLucene/config/LuceneMycomp.h> to set STLport up for your compiler. |
254 | //Uncomment this next line |
255 | #error "Unable to identify the compiler, issue error diagnostic. Edit <CLucene/config/CompilerMycomp.h> to set Lucene up for your compiler." |
256 | #include "CLucene/config/LuceneMycomp.h" |
257 | #endif /* end of compiler choice */ |
258 | |
259 | #endif |
260 | |