1 #ifndef CORE_H
2 #define CORE_H
3 
4 #define QLIB3
5 
6 #ifndef flagMT
7 #define flagMT // MT is now always on
8 #endif
9 
10 #define _MULTITHREADED
11 #define MULTITHREADED
12 #ifdef flagDLL
13 	#define flagUSEMALLOC
14 	#define STD_NEWDELETE
15 #endif
16 
17 #ifdef flagDLL
18 	#define _USRDLL
19 #endif
20 
21 #ifdef flagHEAPDBG
22 	#define HEAPDBG
23 #endif
24 
25 #if defined(flagDEBUG)
26 	#ifndef _DEBUG
27 		#define _DEBUG
28 	#endif
29 	#ifndef TESTLEAKS
30 		#define TESTLEAKS
31 	#endif
32 	#ifndef HEAPDBG
33 		#define HEAPDBG
34 	#endif
35 #else
36 	#ifndef _RELEASE
37 		#define _RELEASE
38 	#endif
39 #endif
40 
41 #include "config.h"
42 
43 #if defined(flagSTD_NEWDELETE) && !defined(STD_NEWDELETE)
44 #define STD_NEWDELETE
45 #endif
46 
47 #ifdef _MSC_VER
48 	#ifndef _CPPRTTI
49 		#error  RTTI must be enabled !!!
50 	#endif  //_CPPRTTI
51 #endif
52 
53 #include <typeinfo>
54 #include <stddef.h>
55 #include <math.h>
56 #include <limits.h>
57 #include <stdlib.h>
58 #include <stdio.h>
59 #include <string.h>
60 #include <stdarg.h>
61 #include <math.h>
62 #include <ctype.h>
63 
64 #ifdef CPU_X86
65 #include <immintrin.h>
66 #endif
67 
68 #if defined(PLATFORM_POSIX)
69 	#ifndef __USE_FILE_OFFSET64
70 		#define __USE_FILE_OFFSET64
71 	#endif
72 	#define DIR_SEP  '/'
73 	#define DIR_SEPS "/"
74 	#define PLATFORM_PATH_HAS_CASE 1
75 
76 	#include <errno.h>
77 	#include <sys/types.h>
78 	#include <sys/stat.h>
79 	#include <sys/time.h>
80 	#include <sys/file.h>
81 	#include <time.h>
82 	#include <fcntl.h>
83 	#include <unistd.h>
84 	#include <pthread.h>
85 	#include <semaphore.h>
86 	#include <memory.h>
87 	#include <dirent.h>
88 	#include <signal.h>
89 	#include <syslog.h>
90 	#include <float.h>
91  	#include <fenv.h>
92  	#ifdef PLATFORM_SOLARIS
93 		#include <inttypes.h>
94 	#else
95 		#include <stdint.h>
96 	#endif
97 	#ifdef PLATFORM_OSX
98 		#include <dispatch/dispatch.h>
99 	#endif
100 #endif //PLATFORM_POSIX
101 
102 #ifdef PLATFORM_POSIX
103 #define LOFF_T_      off_t
104 #define LSEEK64_     lseek
105 #define FTRUNCATE64_ ftruncate
106 #endif
107 
108 #ifdef PLATFORM_LINUX
109 #undef  LOFF_T_
110 #define LOFF_T_      loff_t
111 #undef  LSEEK64_
112 #define LSEEK64_     lseek64
113 #undef  FTRUNCATE64_
114 #define FTRUNCATE64_ ftruncate64
115 #endif
116 
117 #ifdef PLATFORM_WIN32
118 
119 	#if defined(COMPILER_MSC) && defined(CPU_X86)
120 		#pragma warning(disable: 4035)
121 	#else
122 		#ifndef __NOASSEMBLY__
123 			#define __NOASSEMBLY__
124 		#endif
125 	#endif
126 
127 	#if defined(COMPILER_MINGW)
128 		#if !defined(WINVER)
129 			#define WINVER 0xFFFF
130 		#endif
131 		#include <float.h>
132 	#endif
133 
134 	#define DIR_SEP  '\\'
135 	#define DIR_SEPS "\\"
136 	#define PLATFORM_PATH_HAS_CASE 0
137 	#ifndef PLATFORM_WINCE
138 		#include <io.h>
139 	#endif
140 	#ifndef PLATFORM_MFC // just mini Windows headers
141 		#ifdef COMPILER_MSC
142 			#ifndef CPU_ARM
143 				#ifndef CPU_AMD64
144 					#ifndef _X86_
145 						#define _X86_
146 					#endif
147 				#else
148 					#ifndef _AMD64_
149 						#define _AMD64_
150 					#endif
151 					#ifndef __NOASSEMBLY__
152 						#define __NOASSEMBLY__
153 					#endif
154 					#ifndef WIN64
155 						#define WIN64
156 					#endif
157 				#endif
158 			#endif
159 			#ifndef _WINDOWS_
160 				#define _WINDOWS_
161 			#endif
162 			#ifndef _INC_WINDOWS
163 				#define _INC_WINDOWS
164 			#endif
165 			#ifndef _STRUCT_NAME
166 				#define _STRUCT_NAME(x)
167 				#define DUMMYSTRUCTNAME
168 				#define DUMMYSTRUCTNAME2
169 				#define DUMMYSTRUCTNAME3
170 			#endif
171 			#ifndef NO_STRICT
172 				#ifndef STRICT
173 					#define STRICT 1
174 				#endif
175 			#endif
176 			#include <stdarg.h>
177 			#include <windef.h>
178 			#include <winbase.h>
179 			#include <wingdi.h>
180 			#include <winuser.h>
181 			#include <Wincon.h>
182 			#include <float.h>
183 			#include <mmsystem.h>
184 		#define byte win32_byte_ // RpcNdr defines byte -> class with Upp::byte
185 		#define CY win32_CY_
186 			#include <objidl.h>
187 			#include <winnetwk.h>
188 		#undef byte
189 		#undef CY
190 			typedef DWORD LCTYPE;
191 			#define W_P(w, p) w
192 			#include <winsock2.h>
193 			#include <ws2tcpip.h>
194 			typedef int socklen_t;
195 		#else
196 			#define W_P(w, p) w
197 			#if !defined(PLATFORM_CYGWIN)
198 			#include <winsock2.h>
199 			#include <ws2tcpip.h>
200 			#endif
201 			typedef int socklen_t;
202 			#define _WINSOCKAPI_   /* Prevent inclusion of winsock.h in windows.h */
203 			#include <windows.h>
204 			#include <stdint.h>
205 		#endif
206 		#include <process.h>
207 	#endif
208 
209 	#ifdef RGBA
210 		#undef RGBA
211 	#endif
212 #endif
213 
214 #ifdef PLATFORM_POSIX
215 
216 #define W_P(w, p) p
217 #include <sys/types.h>
218 #include <sys/socket.h>
219 #include <netdb.h>
220 #include <netinet/in.h>
221 //#include <libiberty.h>
222 enum
223 {
224 	INVALID_SOCKET = -1,
225 	TCP_NODELAY    = 1,
226 	SD_RECEIVE     = 0,
227 	SD_SEND        = 1,
228 	SD_BOTH        = 2,
229 };
230 typedef int SOCKET;
231 #endif
232 
233 #ifdef PLATFORM_WIN32
234 #include <plugin/z/lib/zlib.h>
235 #else
236 #include <zlib.h>
237 #endif
238 
239 #include <functional>
240 #include <algorithm>
241 #include <string>
242 #include <complex>
243 #include <type_traits>
244 #include <atomic>
245 #include <chrono>
246 #include <utility>
247 
248 // fix MSC8 beta problem....
249 #ifdef COMPILER_MSC
250 #ifndef PLATFORM_WINCE
251 namespace std {
_Debug_message(const wchar_t *,const wchar_t *,unsigned int line)252 	inline void __cdecl _Debug_message(const wchar_t *, const wchar_t *, unsigned int line) {}
253 };
254 #endif
255 #endif
256 
257 // deprecated, use 'namespace' directly instead of macros
258 #define NAMESPACE_UPP     namespace Upp {
259 #define END_UPP_NAMESPACE }
260 #define UPP               Upp
261 
262 // #define atof @ // atof is broken, as it depends on setlocale - might want ',' instead of '.' breaking a lot of code
263 // Use Atof instead (which accepts both '.' and ',' as decimal separator)
264 
265 namespace Upp {
266 
267 #ifndef flagNODEPRECATED
268 #define DEPRECATED
269 #endif
270 
271 #include "Defs.h"
272 
273 class XmlIO;
274 class JsonIO;
275 
276 #include "Ops.h"
277 #include "Fn.h"
278 
279 #ifdef flagNOSIMD
280 	#ifdef CPU_SSE2
281 	#undef CPU_SSE2
282 	#endif
283 	#ifdef CPU_NEON
284 	#undef CPU_NEON
285 	#endif
286 #endif
287 
288 #ifdef CPU_SSE2
289 #include "SIMD_SSE2.h"
290 #define CPU_SIMD 1
291 #endif
292 
293 #ifdef CPU_NEON
294 #include "SIMD_NEON.h"
295 #define CPU_SIMD 1
296 #endif
297 
298 #include "Mem.h"
299 #include "Atomic.h"
300 #include "Topt.h"
301 #include "Mt.h"
302 #include "String.h"
303 
304 #include "TimeDate.h"
305 #include "Path.h"
306 #include "Stream.h"
307 #include "Diag.h"
308 
309 #include "Vcont.h"
310 #include "Range.h"
311 #include "BiCont.h"
312 #include "Index.h"
313 #include "Map.h"
314 #include "Algo.h"
315 #include "Sorted.h"
316 #include "Sort.h"
317 #include "Obsolete.h"
318 #include "FixedMap.h"
319 #include "InVector.h"
320 
321 #include "CharSet.h"
322 
323 #include "SplitMerge.h"
324 
325 #include "Other.h"
326 
327 #include "Lang.h"
328 
329 #include "Value.h"
330 #include "ValueUtil.h"
331 
332 #include "Tuple.h"
333 
334 #include "Uuid.h"
335 #include "Ptr.h"
336 
337 #include "Function.h"
338 
339 #include "Callback.h"
340 
341 #include "Color.h"
342 #include "Complex.h"
343 
344 #include "Hash.h"
345 
346 #include "Util.h"
347 
348 #include "Profile.h"
349 
350 #include "FilterStream.h"
351 
352 #include "Format.h"
353 #include "Convert.h"
354 
355 #include "z.h"
356 
357 #include "Parser.h"
358 #include "JSON.h"
359 #include "XML.h"
360 #include "Xmlize.h"
361 
362 #include "Gtypes.h"
363 #include "i18n.h"
364 #include "Topic.h"
365 
366 #include "App.h"
367 
368 #include "CoWork.h"
369 
370 #include "CoAlgo.h"
371 #include "CoSort.h"
372 
373 #include "LocalProcess.h"
374 
375 #include "Inet.h"
376 
377 #include "Win32Util.h"
378 
379 #include "Vcont.hpp"
380 #include "Index.hpp"
381 #include "Map.hpp"
382 #include "InVector.hpp"
383 #include "InMap.hpp"
384 
385 #include "Huge.h"
386 
387 #include "ValueCache.h"
388 
389 #ifdef CPU_SIMD
390 String AsString(const f32x4& x);
391 String AsString(const i32x4& x);
392 String AsString(const i16x8& x);
393 String AsString(const i8x16& x);
394 #endif
395 
396 #ifdef PLATFORM_WIN32
397 NTL_MOVEABLE(POINT)
398 NTL_MOVEABLE(SIZE)
399 NTL_MOVEABLE(RECT)
400 #endif
401 
402 }
403 
404 #if (defined(TESTLEAKS) || defined(HEAPDBG)) && defined(COMPILER_GCC) && defined(UPP_HEAP)
405 
406 //Place it to the begining of each file to be the first function called in whole executable...
407 //This is now backup to init_priority attribute in heapdbg.cpp
408 //$-
409 struct MemDiagCls {
410 	MemDiagCls();
411 	~MemDiagCls();
412 };
413 static const MemDiagCls sMemDiagHelper__upp__;
414 //$+
415 
416 
417 #endif
418 
419 //some global definitions
420 
421 void      RegisterTopic__(const char *topicfile, const char *topic, const char *title, const UPP::byte *data, int len);
422 
423 #ifdef PLATFORM_WIN32
424 typedef HMODULE DLLHANDLE;
425 #else
426 typedef void   *DLLHANDLE;
427 #endif
428 
429 DLLHANDLE LoadDll__(UPP::String& fn, const char *const *names, void *const *procs);
430 void      FreeDll__(DLLHANDLE dllhandle);
431 
432 #ifndef flagNONAMESPACE
433 using Upp::byte; // Dirty solution to Windows.h typedef byte...
434 #endif
435 
436 #endif //CORE_H
437