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

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2018  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
#define A_CONST __attribute__ ((const))
125
#define A_PURE __attribute__ ((pure))
126
#define A_INLINE __attribute__ ((always_inline))
127
128
#ifdef __x86_64__
129
// gcc 4.8 look like support avx2, but need global define for enable any SIMD
130
#if GCC_VERSION >= 40900
131
#define SIMD_SUPPORTED
132
#endif  // GCC_VERSION > 40900
133
#if defined(__clang__) && CLANG_VERSION >= 30800
134
#define SIMD_SUPPORTED
135
#endif  // defined(__clang__) && CLANG_VERSION >= 30800
136
#endif  // __x86_64__
137
138
#ifdef __INTEL_COMPILER
139
#define RETURNS_NONNULL
140
#else  // __INTEL_COMPILER
141
#if GCC_VERSION < 40900
142
#define RETURNS_NONNULL
143
#else  // GCC_VERSION < 40900
144
#define RETURNS_NONNULL __attribute__((returns_nonnull))
145
#endif  // GCC_VERSION < 40900
146
#endif  // __INTEL_COMPILER
147
148
#define A_NONNULL(...) __attribute__((nonnull (__VA_ARGS__)))
149
150
#else  // __GNUC__
151
#define A_UNUSED
152
#define A_WARN_UNUSED
153
#define A_WARN_UNUSED_NON_TESTS
154
#define gnu_printf printf
155
#define DEPRECATED
156
#define restrict
157
#define restrict2
158
#define RETURNS_NONNULL
159
#define A_NONNULL(...)
160
#endif  // __GNUC__
161
#ifdef __clang__
162
#define gnu_printf printf
163
#endif  // __clang__
164
165
#ifdef ADVGCC
166
167
#define const2 const
168
169
#if GCC_VERSION >= 60000
170
#define PRAGMA6(str) _Pragma(#str)
171
#else  // GCC_VERSION > 60000
172
#define PRAGMA6(str)
173
#endif  // GCC_VERSION > 60000
174
175
#if GCC_VERSION >= 70000
176
#define A_FALLTHROUGH __attribute__ ((fallthrough));
177
#else  // GCC_VERSION > 70000
178
#define A_FALLTHROUGH
179
#endif  // GCC_VERSION > 70000
180
181
#else  // ADVGCC
182
#define const2
183
#define PRAGMA6(str)
184
#define A_FALLTHROUGH
185
#endif  // ADVGCC
186
187
#if GCC_VERSION >= 48000
188
#define PRAGMA48(str) _Pragma(#str)
189
#else  // GCC_VERSION > 48000
190
#define PRAGMA48(str)
191
#endif  // GCC_VERSION > 48000
192
193
#if GCC_VERSION >= 49000
194
#define PRAGMA49(str) _Pragma(#str)
195
#else  // GCC_VERSION > 49000
196
#define PRAGMA49(str)
197
#endif  // GCC_VERSION > 49000
198
199
#if GCC_VERSION >= 80000
200
#define PRAGMA8(str) _Pragma(#str)
201
#else  // GCC_VERSION > 80000
202
#define PRAGMA8(str)
203
#endif  // GCC_VERSION > 80000
204
205
#ifdef __clang__
206
#define PRAGMACLANG(str) _Pragma(#str)
207
#if CLANG_VERSION >= 50000
208
#define PRAGMACLANG5(str) _Pragma(#str)
209
#else  // CLANG_VERSION >= 50000
210
#define PRAGMACLANG5(str)
211
#endif  // CLANG_VERSION >= 50000
212
#if CLANG_VERSION >= 30800
213
#define PRAGMACLANG6(str) _Pragma(#str)
214
#define CLANG_FALLTHROUGH [[clang::fallthrough]];
215
#else  // __clang_major__ >= 6
216
#define PRAGMACLANG6(str)
217
#define CLANG_FALLTHROUGH
218
#endif  // __clang_major__ >= 6
219
#else  // __clang__
220
#define PRAGMACLANG(str)
221
#define PRAGMACLANG5(str)
222
#define PRAGMACLANG6(str)
223
#define CLANG_FALLTHROUGH
224
#endif  // __clang__
225
226
#if GCC_VERSION >= 40600
227
#define PRAGMACLANG6GCC(str) _Pragma(#str)
228
#elif defined(__clang__) && CLANG_VERSION >= 30800
229
#define PRAGMACLANG6GCC(str) _Pragma(#str)
230
#else  // __clang__
231
#define PRAGMACLANG6GCC(str)
232
#endif  // __clang__
233
234
#ifdef __GNUC__
235
#if GCC_VERSION >= 40600
236
#define PRAGMA45(str) _Pragma(#str)
237
#elif defined(__clang__)
238
#define PRAGMA45(str) _Pragma(#str)
239
#else  // GCC_VERSION > 40600
240
#define PRAGMA45(str)
241
#endif  // GCC_VERSION > 40600
242
243
#if GCC_VERSION >= 40000
244
#define PRAGMA4(str) _Pragma(#str)
245
#elif defined(__clang__)
246
#define PRAGMA4(str) _Pragma(#str)
247
#else  // GCC_VERSION > 40000
248
#define PRAGMA4(str)
249
#endif  // GCC_VERSION > 40000
250
#endif  // __GNUC__
251
252
#define notfinal
253
254
#ifdef ENABLE_CHECKPLUGIN
255
#define A_NONNULLPOINTER __attribute__((nonnullpointer))
256
#else  // ENABLE_CHECKPLUGIN
257
#define A_NONNULLPOINTER
258
#endif  // ENABLE_CHECKPLUGIN
259
260
#ifdef ENABLE_CHECKS
261
262
#define CHECKLISTENERS \
263
    config.checkListeners(this, __FILE__, __LINE__); \
264
    serverConfig.checkListeners(this, __FILE__, __LINE__);
265
266
#else  // ENABLE_CHECKS
267
268
#define CHECKLISTENERS
269
270
#endif  // ENABLE_CHECKS
271
272
#if defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
273
#define ifconstexpr if constexpr
274
#else  // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
275
#define ifconstexpr if
276
#endif  // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
277
278
#ifdef USE_SDL2
279
PRAGMA45(GCC diagnostic push)
280
PRAGMA45(GCC diagnostic ignored "-Wswitch-default")
281
#endif  // USE_SDL2
282
PRAGMA48(GCC diagnostic push)
283
PRAGMA48(GCC diagnostic ignored "-Wshadow")
284
#include <SDL_version.h>
285

3
PRAGMA48(GCC diagnostic pop)
286
#ifdef USE_SDL2
287
PRAGMA45(GCC diagnostic pop)
288
#endif  // USE_SDL2
289
290
#if SDL_VERSION_ATLEAST(2, 0, 0)
291
#ifndef USE_SDL2
292
#warning using SDL2 headers but configure set to use SDL1.2
293
#warning please add configure flag --with-sdl2
294
#define USE_SDL2
295
#endif  // USE_SDL2
296
#else  // SDL_VERSION_ATLEAST(2, 0, 0)
297
#ifdef USE_SDL2
298
#error using SDL1.2 headers but configure set to use SDL2
299
#error please remove configure flag --with-sdl2
300
#endif  // USE_SDL2
301
#endif  // SDL_VERSION_ATLEAST(2, 0, 0)
302
303
// #define DEBUG_CONFIG 1
304
// #define DEBUG_BIND_TEXTURE 1
305
// #define DISABLE_RESOURCE_CACHING 1
306
#define DUMP_LEAKED_RESOURCES 1
307
// #define DEBUG_DUMP_LEAKS1 1
308
// #define DEBUG_SDLFONT 1
309
310
// android or nacl logging
311
// #define SPECIAL_LOGGING 1
312
313
// profiler
314
// #define USE_PROFILER 1
315
316
// draw calls
317
// #define DEBUG_DRAW_CALLS 1
318
319
// debug images usage
320
// #define DEBUG_IMAGES 1
321
322
// debug SDL surfaces
323
// #define DEBUG_SDL_SURFACES 1
324
325
// debug virtfs usage
326
// #define DEBUG_VIRTFS 1
327
328
// use file access fuzzer
329
// #define USE_FUZZER 1
330
331
// use OpenGL debug features
332
// #define DEBUG_OPENGL 1
333
334
// debug animations
335
// #define DEBUG_ANIMATIONS 1
336
337
#define USE_FILE_FOPEN 1
338
339
#ifdef __MINGW32__
340
#define PRAGMAMINGW(str) _Pragma(#str)
341
#define A_WIN_UNUSED __attribute__ ((unused))
342
#else  // __MINGW32__
343
#define PRAGMAMINGW(str)
344
#define A_WIN_UNUSED
345
#endif  // __MINGW32__
346
347
#ifdef DYECMD
348
#undef USE_FUZZER
349
#endif  // DYECMD
350
#include "utils/perfomance.h"
351
UTILS_PERFOMANCE_H  // guard for protect previous include
352
#ifdef HAVE_CONFIG_H
353
#include "config.h"
354
#endif  // HAVE_CONFIG_H
355
356
#endif  // LOCALCONSTS_H