summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/clucene/src/CLucene/config/CompilerAcc.h
blob: 019dd833eb06ac2c4e0947dfc2c3be65b4c0c591 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
* 
* Distributable under the terms of either the Apache License (Version 2.0) or 
* the GNU Lesser General Public License, as specified in the COPYING file.
*
* Changes are Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
------------------------------------------------------------------------------*/
#if !defined(_lucene_COMPILER_ACC)
#define _lucene_COMPILER_ACC

// It is internal CLucene header - DO NOT include it directly
#if !defined(_SUPPRESS_MAKE_BASED_CONFIG)
#if defined(_BUILD_FOR_QT_)
#include "fulltextsearch/qclucene-config_p.h"
#else
#include "CLucene/clucene-config.h" //make clucene-config.h file
#endif
#endif

#if defined(_ASCII)
#undef _UCS2
#elif defined(_UCS2)
//
#else
#define CL_CHARSET_GUESS
#endif

//dont allow FS_MMAP if mmap is not available
#if defined(LUCENE_FS_MMAP) && !defined(_CL_HAVE_MMAP)
#error "LUCENE_FS_MMAP is defined and MMap doesn't appear to be available"
#endif

#ifdef _CL_HAVE_NO_FUNCTION_TRY_BLOCKS
#undef  _LUCENE_DISABLE_EXCEPTIONS
#define _LUCENE_DISABLE_EXCEPTIONS
    
#error "this is bad if you made it here... your compiler seems not to have try/catch blocks."
#error "maybe you could implement an alternative solution for us? :)"
#endif

#ifndef _CL_HAVE_NAMESPACES
#define DISABLE_NAMESPACE
#endif

#define LUCENE_DISABLE_HASHING //we could enable this, but so far test show that the hashing is slower :(

//define the file functions
#define fileSeek lseek
#define fileSize _filelength
#define fileStat stat
#define fileHandleStat fstat
#ifdef _CL_HAVE_TELL
#define fileTell tell
#else
//ftell (and probably soon ftell64) are POSIX standard functions, but tell and
//tell64 are not, so we define fileTell in terms of fileSeek.
#define fileTell(fhandle) fileSeek(fhandle, 0, SEEK_CUR)
#endif

//this is needed early on so that CL_MAX_PATH can be correctly determined
//in the StdHeader.h. This was earlier causing problems with macosx.
//:: crash was due to realpath() that expects an output arguments that
//has at least the size of PATH_MAX (even if the result has a lower size)
#include <limits.h>
    
#ifndef _CL_HAVE_WCHAR_T
    typedef unsigned short wchar_t;
#endif

#if defined(__CYGWIN__)
//cygwin seems to incorrectly define that it has wprintf???
#undef _CL_HAVE_WPRINTF
#elif defined(__MINGW32__)
#    ifndef _CL_HAVE_WINDOWS_H
#    define _CL_HAVE_WINDOWS_H
#    endif
#endif


///////////////////////////////////////////////////////////////////////////////
//end _lucene_COMPILER_ACC
#elif !defined(_lucene_COMPILER_ACC2)
#define _lucene_COMPILER_ACC2
//second inclusion

    //types
    #if defined(_CL_HAVE_SYS_TYPES_H)
        #include <sys/types.h>
    #endif
	#if defined(_CL_HAVE_INTTYPES_H)
		#include <inttypes.h>
	#elif defined(_CL_HAVE_STDINT_H)
		#include <stdint.h>
	#else
		#if _CL_SIZEOF_UNSIGNED_LONG_LONG==8
			typedef unsigned long long uint64_t;
			typedef long long int64_t;
		#elif _CL_SIZEOF_UNSIGNED_LONG==8
			typedef unsigned long uint64_t;
			typedef long int64_t;
		#else
			#error I do not know what to use for a uint64_t.
		#endif
		
		/* Give us an unsigned 32-bit data type. */
		#if _CL_SIZEOF_UNSIGNED_LONG==4
			typedef unsigned long uint32_t;
			typedef long int32_t;
		#elif _CL_SIZEOF_UNSIGNED_INT==4
			typedef unsigned int uint32_t;
			typedef int int32_t;
		#else
			#error I do not know what to use for a uint32_t.
		#endif

		/* An unsigned 8-bit data type */
		#if _CL_SIZEOF_UNSIGNED_CHAR==1
			typedef unsigned char uint8_t;
		#else
			#error I do not know what to use for a uint8_t.
		#endif
	#endif
    
    //second chance to fix default settings
	//this must be defined later, otherwise it messes up
	//the standard libraries
	#if !defined(__MINGW32__)
	    #define _close ::close
	    #define _read ::read
	#endif

  	//now that int64_t is defined, we can define this...
	#ifndef _CL_HAVE_FILELENGTH
	    #undef fileSize
	    #define fileSize lucene_filelength
	    int64_t lucene_filelength(int handle);
	#endif

#elif !defined(_lucene_COMPILER_ACC3)
#define _lucene_COMPILER_ACC3
    //third inclusion

	#if !defined(__MINGW32__)
	    //define replacements
	    #define O_RANDOM 0
	    #undef O_BINARY
	    #define O_BINARY 0
	    #define _S_IREAD  0444
	    #define _S_IWRITE 0333  // write and execute permissions

	    //some functions that are needed - not charset dependent and not tchar type functions
	    #define _open open
	    #define _write write
	    #define _snprintf snprintf

	    //clucene uses ascii for filename interactions
	    #define _realpath(rel,abs) realpath(rel,abs)
	    #define _mkdir(x) mkdir(x,0777)
	    #define _unlink unlink
	#else
	    #define _realpath(rel,abs) _fullpath(abs,rel,CL_MAX_PATH)
	#endif
	//also required by mingw
	#define _rename rename
#endif