1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
4 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
5 |
|
|
* |
6 |
|
|
* This file is part of The ManaPlus Client. |
7 |
|
|
* |
8 |
|
|
* This program is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License as published by |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
11 |
|
|
* any later version. |
12 |
|
|
* |
13 |
|
|
* This program is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU General Public License |
19 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
#ifndef LOCALCONSTS_H |
23 |
|
|
#define LOCALCONSTS_H |
24 |
|
|
|
25 |
|
|
#define ENABLEDEBUGLOG 1 |
26 |
|
|
|
27 |
|
|
#ifndef GCC_VERSION |
28 |
|
|
#define GCC_VERSION (__GNUC__ * 10000 \ |
29 |
|
|
+ __GNUC_MINOR__ * 100 \ |
30 |
|
|
+ __GNUC_PATCHLEVEL__) |
31 |
|
|
#endif // GCC_VERSION |
32 |
|
|
|
33 |
|
|
#ifdef __clang__ |
34 |
|
|
#ifndef CLANG_VERSION |
35 |
|
|
#define CLANG_VERSION (__clang_major__ * 10000 \ |
36 |
|
|
+ __clang_minor__ * 100 \ |
37 |
|
|
+ __clang_patchlevel__) |
38 |
|
|
#endif // CLANG_VERSION |
39 |
|
|
#endif // __clang__ |
40 |
|
|
|
41 |
|
|
#define A_DEFAULT_COPY(func) |
42 |
|
|
|
43 |
|
|
#if !defined(__GXX_EXPERIMENTAL_CXX0X__) |
44 |
|
|
#undef nullptr |
45 |
|
|
#define nullptr 0 |
46 |
|
|
#define final |
47 |
|
|
#define override |
48 |
|
|
#define constexpr |
49 |
|
|
#define constexpr2 |
50 |
|
|
#define noexcept2 |
51 |
|
|
#define noexcept |
52 |
|
|
#define A_DELETE(func) |
53 |
|
|
#define A_DELETE_COPY(func) |
54 |
|
|
#else // !defined(__GXX_EXPERIMENTAL_CXX0X__) |
55 |
|
|
#if GCC_VERSION < 40700 |
56 |
|
|
|
57 |
|
|
#if defined(__clang__) && __cplusplus > 201100L |
58 |
|
|
#else // __clang__ |
59 |
|
|
#define final |
60 |
|
|
#define override |
61 |
|
|
#define constexpr |
62 |
|
|
#define noexcept |
63 |
|
|
#endif // __clang__ |
64 |
|
|
#define noexcept2 |
65 |
|
|
#define constexpr2 |
66 |
|
|
|
67 |
|
|
// #define A_DELETE |
68 |
|
|
// #define A_DELETE_COPY |
69 |
|
|
#else // GCC_VERSION < 40700 |
70 |
|
|
#define ADVGCC |
71 |
|
|
#if GCC_VERSION < 40900 |
72 |
|
|
#define constexpr2 |
73 |
|
|
#define noexcept2 |
74 |
|
|
#else // GCC_VERSION < 40900 |
75 |
|
|
#if __cpp_constexpr >= 201304 |
76 |
|
|
#define constexpr2 constexpr |
77 |
|
|
#else // __cpp_constexpr >= 201304 |
78 |
|
|
#define constexpr2 |
79 |
|
|
#endif // __cpp_constexpr >= 201304 |
80 |
|
|
|
81 |
|
|
#ifdef __clang__ |
82 |
|
|
#define noexcept2 |
83 |
|
|
#else // __clang__ |
84 |
|
|
#define noexcept2 noexcept |
85 |
|
|
#endif // __clang__ |
86 |
|
|
|
87 |
|
|
#endif // GCC_VERSION < 40900 |
88 |
|
|
#endif // GCC_VERSION < 40700 |
89 |
|
|
#define M_TCPOK |
90 |
|
|
#define A_DELETE(func) func = delete |
91 |
|
|
#define A_DELETE_COPY(name) name(const name &) = delete; \ |
92 |
|
|
name &operator=(const name&) = delete; |
93 |
|
|
#endif // !defined(__GXX_EXPERIMENTAL_CXX0X__) |
94 |
|
|
|
95 |
|
|
#ifdef __clang__ |
96 |
|
|
#define constexpr3 |
97 |
|
|
#elif GCC_VERSION > 70000 |
98 |
|
|
#define constexpr3 constexpr |
99 |
|
|
#else |
100 |
|
|
#define constexpr3 |
101 |
|
|
#endif |
102 |
|
|
|
103 |
|
|
#ifdef __GNUC__ |
104 |
|
|
#define A_UNUSED __attribute__ ((unused)) |
105 |
|
|
#define A_WARN_UNUSED __attribute__ ((warn_unused_result)) |
106 |
|
|
#ifdef UNITTESTS |
107 |
|
|
#define A_WARN_UNUSED_NON_TESTS |
108 |
|
|
#else // UNITTESTS |
109 |
|
|
#define A_WARN_UNUSED_NON_TESTS __attribute__ ((warn_unused_result)) |
110 |
|
|
#endif // UNITTESTS |
111 |
|
|
#define DEPRECATED __attribute__ ((deprecated)) |
112 |
|
|
#ifdef DYECMD |
113 |
|
|
#define A_DYECMD_UNUSED __attribute__ ((unused)) |
114 |
|
|
#else // DYECMD |
115 |
|
|
#define A_DYECMD_UNUSED |
116 |
|
|
#endif // DYECMD |
117 |
|
|
|
118 |
|
|
#ifdef __native_client__ |
119 |
|
|
#define restrict |
120 |
|
|
#define restrict2 |
121 |
|
|
#else // __native_client__ |
122 |
|
|
#ifdef __clang__ |
123 |
|
|
// because restrict broken in clang, now it removed from all places. |
124 |
|
|
// #define restrict __restrict__ |
125 |
|
|
#define restrict |
126 |
|
|
#define restrict2 |
127 |
|
|
#else // __clang__ |
128 |
|
|
#define restrict __restrict__ |
129 |
|
|
#define restrict2 __restrict__ |
130 |
|
|
#endif // __clang__ |
131 |
|
|
#endif // __native_client__ |
132 |
|
|
|
133 |
|
|
#define A_CONST __attribute__ ((const)) |
134 |
|
|
#define A_PURE __attribute__ ((pure)) |
135 |
|
|
#define A_INLINE __attribute__ ((always_inline)) |
136 |
|
|
|
137 |
|
|
#ifdef __x86_64__ |
138 |
|
|
// gcc 4.8 look like support avx2, but need global define for enable any SIMD |
139 |
|
|
#if GCC_VERSION >= 40900 |
140 |
|
|
#define SIMD_SUPPORTED |
141 |
|
|
#endif // GCC_VERSION > 40900 |
142 |
|
|
#if defined(__clang__) && CLANG_VERSION >= 30800 |
143 |
|
|
#define SIMD_SUPPORTED |
144 |
|
|
#endif // defined(__clang__) && CLANG_VERSION >= 30800 |
145 |
|
|
#endif // __x86_64__ |
146 |
|
|
|
147 |
|
|
#ifdef __INTEL_COMPILER |
148 |
|
|
#define RETURNS_NONNULL |
149 |
|
|
#else // __INTEL_COMPILER |
150 |
|
|
#if GCC_VERSION < 40900 |
151 |
|
|
#define RETURNS_NONNULL |
152 |
|
|
#else // GCC_VERSION < 40900 |
153 |
|
|
#define RETURNS_NONNULL __attribute__((returns_nonnull)) |
154 |
|
|
#endif // GCC_VERSION < 40900 |
155 |
|
|
#endif // __INTEL_COMPILER |
156 |
|
|
|
157 |
|
|
#define A_NONNULL(...) __attribute__((nonnull (__VA_ARGS__))) |
158 |
|
|
|
159 |
|
|
#else // __GNUC__ |
160 |
|
|
#define A_UNUSED |
161 |
|
|
#define A_WARN_UNUSED |
162 |
|
|
#define A_WARN_UNUSED_NON_TESTS |
163 |
|
|
#define gnu_printf printf |
164 |
|
|
#define DEPRECATED |
165 |
|
|
#define restrict |
166 |
|
|
#define restrict2 |
167 |
|
|
#define RETURNS_NONNULL |
168 |
|
|
#define A_NONNULL(...) |
169 |
|
|
#endif // __GNUC__ |
170 |
|
|
#ifdef __clang__ |
171 |
|
|
#define gnu_printf printf |
172 |
|
|
#endif // __clang__ |
173 |
|
|
|
174 |
|
|
#ifdef ADVGCC |
175 |
|
|
|
176 |
|
|
#define const2 const |
177 |
|
|
|
178 |
|
|
#if GCC_VERSION >= 60000 |
179 |
|
|
#define PRAGMA6(str) _Pragma(#str) |
180 |
|
|
#else // GCC_VERSION > 60000 |
181 |
|
|
#define PRAGMA6(str) |
182 |
|
|
#endif // GCC_VERSION > 60000 |
183 |
|
|
|
184 |
|
|
#if GCC_VERSION >= 70000 |
185 |
|
|
#define A_FALLTHROUGH __attribute__ ((fallthrough)); |
186 |
|
|
#else // GCC_VERSION > 70000 |
187 |
|
|
#define A_FALLTHROUGH |
188 |
|
|
#endif // GCC_VERSION > 70000 |
189 |
|
|
|
190 |
|
|
#else // ADVGCC |
191 |
|
|
#define const2 |
192 |
|
|
#define PRAGMA6(str) |
193 |
|
|
#define A_FALLTHROUGH |
194 |
|
|
#endif // ADVGCC |
195 |
|
|
|
196 |
|
|
#if GCC_VERSION >= 48000 |
197 |
|
|
#define PRAGMA48(str) _Pragma(#str) |
198 |
|
|
#else // GCC_VERSION > 48000 |
199 |
|
|
#define PRAGMA48(str) |
200 |
|
|
#endif // GCC_VERSION > 48000 |
201 |
|
|
|
202 |
|
|
#if GCC_VERSION >= 49000 |
203 |
|
|
#define PRAGMA49(str) _Pragma(#str) |
204 |
|
|
#else // GCC_VERSION > 49000 |
205 |
|
|
#define PRAGMA49(str) |
206 |
|
|
#endif // GCC_VERSION > 49000 |
207 |
|
|
|
208 |
|
|
#if GCC_VERSION >= 80000 |
209 |
|
|
#define PRAGMA8(str) _Pragma(#str) |
210 |
|
|
#else // GCC_VERSION > 80000 |
211 |
|
|
#define PRAGMA8(str) |
212 |
|
|
#endif // GCC_VERSION > 80000 |
213 |
|
|
|
214 |
|
|
#ifdef __clang__ |
215 |
|
|
#define PRAGMACLANG(str) _Pragma(#str) |
216 |
|
|
#if CLANG_VERSION >= 50000 |
217 |
|
|
#define PRAGMACLANG5(str) _Pragma(#str) |
218 |
|
|
#else // CLANG_VERSION >= 50000 |
219 |
|
|
#define PRAGMACLANG5(str) |
220 |
|
|
#endif // CLANG_VERSION >= 50000 |
221 |
|
|
#if CLANG_VERSION >= 30800 |
222 |
|
|
#define PRAGMACLANG6(str) _Pragma(#str) |
223 |
|
|
#define CLANG_FALLTHROUGH [[clang::fallthrough]]; |
224 |
|
|
#else // __clang_major__ >= 6 |
225 |
|
|
#define PRAGMACLANG6(str) |
226 |
|
|
#define CLANG_FALLTHROUGH |
227 |
|
|
#endif // __clang_major__ >= 6 |
228 |
|
|
#else // __clang__ |
229 |
|
|
#define PRAGMACLANG(str) |
230 |
|
|
#define PRAGMACLANG5(str) |
231 |
|
|
#define PRAGMACLANG6(str) |
232 |
|
|
#define CLANG_FALLTHROUGH |
233 |
|
|
#endif // __clang__ |
234 |
|
|
|
235 |
|
|
#if GCC_VERSION >= 40600 |
236 |
|
|
#define PRAGMACLANG6GCC(str) _Pragma(#str) |
237 |
|
|
#elif defined(__clang__) && CLANG_VERSION >= 30800 |
238 |
|
|
#define PRAGMACLANG6GCC(str) _Pragma(#str) |
239 |
|
|
#else // __clang__ |
240 |
|
|
#define PRAGMACLANG6GCC(str) |
241 |
|
|
#endif // __clang__ |
242 |
|
|
|
243 |
|
|
#ifdef __GNUC__ |
244 |
|
|
#if GCC_VERSION >= 40600 |
245 |
|
|
#define PRAGMA45(str) _Pragma(#str) |
246 |
|
|
#elif defined(__clang__) |
247 |
|
|
#define PRAGMA45(str) _Pragma(#str) |
248 |
|
|
#else // GCC_VERSION > 40600 |
249 |
|
|
#define PRAGMA45(str) |
250 |
|
|
#endif // GCC_VERSION > 40600 |
251 |
|
|
|
252 |
|
|
#if GCC_VERSION >= 40000 |
253 |
|
|
#define PRAGMA4(str) _Pragma(#str) |
254 |
|
|
#elif defined(__clang__) |
255 |
|
|
#define PRAGMA4(str) _Pragma(#str) |
256 |
|
|
#else // GCC_VERSION > 40000 |
257 |
|
|
#define PRAGMA4(str) |
258 |
|
|
#endif // GCC_VERSION > 40000 |
259 |
|
|
#endif // __GNUC__ |
260 |
|
|
|
261 |
|
|
#define notfinal |
262 |
|
|
|
263 |
|
|
#ifdef ENABLE_CHECKPLUGIN |
264 |
|
|
#define A_NONNULLPOINTER __attribute__((nonnullpointer)) |
265 |
|
|
#else // ENABLE_CHECKPLUGIN |
266 |
|
|
#define A_NONNULLPOINTER |
267 |
|
|
#endif // ENABLE_CHECKPLUGIN |
268 |
|
|
|
269 |
|
|
#ifdef ENABLE_CHECKS |
270 |
|
|
|
271 |
|
|
#define CHECKLISTENERS \ |
272 |
|
|
config.checkListeners(this, __FILE__, __LINE__); \ |
273 |
|
|
serverConfig.checkListeners(this, __FILE__, __LINE__); |
274 |
|
|
|
275 |
|
|
#else // ENABLE_CHECKS |
276 |
|
|
|
277 |
|
|
#define CHECKLISTENERS |
278 |
|
|
|
279 |
|
|
#endif // ENABLE_CHECKS |
280 |
|
|
|
281 |
|
|
#if defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606 |
282 |
|
|
#define ifconstexpr if constexpr |
283 |
|
|
#else // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606 |
284 |
|
|
#define ifconstexpr if |
285 |
|
|
#endif // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606 |
286 |
|
|
|
287 |
|
|
#ifdef USE_SDL2 |
288 |
|
|
PRAGMA45(GCC diagnostic push) |
289 |
|
|
PRAGMA45(GCC diagnostic ignored "-Wswitch-default") |
290 |
|
|
#endif // USE_SDL2 |
291 |
|
|
PRAGMA48(GCC diagnostic push) |
292 |
|
|
PRAGMA48(GCC diagnostic ignored "-Wshadow") |
293 |
|
|
#include <SDL_version.h> |
294 |
|
|
PRAGMA48(GCC diagnostic pop) |
295 |
|
|
#ifdef USE_SDL2 |
296 |
✓✗✓✗
|
3 |
PRAGMA45(GCC diagnostic pop) |
297 |
|
|
#endif // USE_SDL2 |
298 |
|
|
|
299 |
|
|
#if SDL_VERSION_ATLEAST(2, 0, 0) |
300 |
|
|
#ifndef USE_SDL2 |
301 |
|
|
#warning using SDL2 headers but configure set to use SDL1.2 |
302 |
|
|
#warning please add configure flag --with-sdl2 |
303 |
|
|
#define USE_SDL2 |
304 |
|
|
#endif // USE_SDL2 |
305 |
|
|
#else // SDL_VERSION_ATLEAST(2, 0, 0) |
306 |
|
|
#ifdef USE_SDL2 |
307 |
|
|
#error using SDL1.2 headers but configure set to use SDL2 |
308 |
|
|
#error please remove configure flag --with-sdl2 |
309 |
|
|
#endif // USE_SDL2 |
310 |
|
|
#endif // SDL_VERSION_ATLEAST(2, 0, 0) |
311 |
|
|
|
312 |
|
|
// #define DEBUG_CONFIG 1 |
313 |
|
|
// #define DEBUG_BIND_TEXTURE 1 |
314 |
|
|
// #define DISABLE_RESOURCE_CACHING 1 |
315 |
|
|
#define DUMP_LEAKED_RESOURCES 1 |
316 |
|
|
// #define DEBUG_DUMP_LEAKS1 1 |
317 |
|
|
// #define DEBUG_SDLFONT 1 |
318 |
|
|
|
319 |
|
|
// android or nacl logging |
320 |
|
|
// #define SPECIAL_LOGGING 1 |
321 |
|
|
|
322 |
|
|
// profiler |
323 |
|
|
// #define USE_PROFILER 1 |
324 |
|
|
|
325 |
|
|
// draw calls |
326 |
|
|
// #define DEBUG_DRAW_CALLS 1 |
327 |
|
|
|
328 |
|
|
// debug images usage |
329 |
|
|
// #define DEBUG_IMAGES 1 |
330 |
|
|
|
331 |
|
|
// debug SDL surfaces |
332 |
|
|
// #define DEBUG_SDL_SURFACES 1 |
333 |
|
|
|
334 |
|
|
// debug virtfs usage |
335 |
|
|
// #define DEBUG_VIRTFS 1 |
336 |
|
|
|
337 |
|
|
// use file access fuzzer |
338 |
|
|
// #define USE_FUZZER 1 |
339 |
|
|
|
340 |
|
|
// use OpenGL debug features |
341 |
|
|
// #define DEBUG_OPENGL 1 |
342 |
|
|
|
343 |
|
|
// debug animations |
344 |
|
|
// #define DEBUG_ANIMATIONS 1 |
345 |
|
|
|
346 |
|
|
#define USE_FILE_FOPEN 1 |
347 |
|
|
|
348 |
|
|
#ifdef __MINGW32__ |
349 |
|
|
#define PRAGMAMINGW(str) _Pragma(#str) |
350 |
|
|
#define A_WIN_UNUSED __attribute__ ((unused)) |
351 |
|
|
#else // __MINGW32__ |
352 |
|
|
#define PRAGMAMINGW(str) |
353 |
|
|
#define A_WIN_UNUSED |
354 |
|
|
#endif // __MINGW32__ |
355 |
|
|
|
356 |
|
|
#ifdef DYECMD |
357 |
|
|
#undef USE_FUZZER |
358 |
|
|
#endif // DYECMD |
359 |
|
|
#include "utils/perfomance.h" |
360 |
|
|
UTILS_PERFOMANCE_H // guard for protect previous include |
361 |
|
|
#ifdef HAVE_CONFIG_H |
362 |
|
|
#include "config.h" |
363 |
|
|
#endif // HAVE_CONFIG_H |
364 |
|
|
|
365 |
|
|
#endif // LOCALCONSTS_H |