GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/localconsts.h Lines: 1 1 100.0 %
Date: 2017-11-29 Branches: 2 4 50.0 %

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

6
PRAGMA48(GCC diagnostic pop)
323
#ifdef USE_SDL2
324
PRAGMA45(GCC diagnostic pop)
325
#endif  // USE_SDL2
326
327
#if SDL_VERSION_ATLEAST(2, 0, 0)
328
#ifndef USE_SDL2
329
#warning using SDL2 headers but configure set to use SDL1.2
330
#warning please add configure flag --with-sdl2
331
#define USE_SDL2
332
#endif  // USE_SDL2
333
#else  // SDL_VERSION_ATLEAST(2, 0, 0)
334
#ifdef USE_SDL2
335
#error using SDL1.2 headers but configure set to use SDL2
336
#error please remove configure flag --with-sdl2
337
#endif  // USE_SDL2
338
#endif  // SDL_VERSION_ATLEAST(2, 0, 0)
339
340
// #define DEBUG_CONFIG 1
341
// #define DEBUG_BIND_TEXTURE 1
342
// #define DISABLE_RESOURCE_CACHING 1
343
#define DUMP_LEAKED_RESOURCES 1
344
// #define DEBUG_DUMP_LEAKS1 1
345
// #define DEBUG_SDLFONT 1
346
347
// android or nacl logging
348
// #define SPECIAL_LOGGING 1
349
350
// profiler
351
// #define USE_PROFILER 1
352
353
// draw calls
354
// #define DEBUG_DRAW_CALLS 1
355
356
// debug images usage
357
// #define DEBUG_IMAGES 1
358
359
// debug SDL surfaces
360
// #define DEBUG_SDL_SURFACES 1
361
362
// debug virtfs usage
363
// #define DEBUG_VIRTFS 1
364
365
// use file access fuzzer
366
// #define USE_FUZZER 1
367
368
// use OpenGL debug features
369
// #define DEBUG_OPENGL 1
370
371
// debug animations
372
// #define DEBUG_ANIMATIONS 1
373
374
#define USE_FILE_FOPEN 1
375
376
#ifdef __MINGW32__
377
#define PRAGMAMINGW(str) _Pragma(#str)
378
#define A_WIN_UNUSED __attribute__ ((unused))
379
#else  // __MINGW32__
380
#define PRAGMAMINGW(str)
381
#define A_WIN_UNUSED
382
#endif  // __MINGW32__
383
384
#ifdef DYECMD
385
#undef USE_FUZZER
386
#endif  // DYECMD
387
#include "utils/perfomance.h"
388
UTILS_PERFOMANCE_H  // guard for protect previous include
389
#ifdef HAVE_CONFIG_H
390
#include "config.h"
391
#endif  // HAVE_CONFIG_H
392
393
#endif  // LOCALCONSTS_H