GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/localconsts.h Lines: 1 1 100.0 %
Date: 2018-05-19 03:07:18 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 >= 30800
208
#define PRAGMACLANG6(str) _Pragma(#str)
209
#define CLANG_FALLTHROUGH [[clang::fallthrough]];
210
#else  // __clang_major__ >= 6
211
#define PRAGMACLANG6(str)
212
#define CLANG_FALLTHROUGH
213
#endif  // __clang_major__ >= 6
214
#else  // __clang__
215
#define PRAGMACLANG(str)
216
#define PRAGMACLANG6(str)
217
#define CLANG_FALLTHROUGH
218
#endif  // __clang__
219
220
#if GCC_VERSION >= 40600
221
#define PRAGMACLANG6GCC(str) _Pragma(#str)
222
#elif defined(__clang__) && CLANG_VERSION >= 30800
223
#define PRAGMACLANG6GCC(str) _Pragma(#str)
224
#else  // __clang__
225
#define PRAGMACLANG6GCC(str)
226
#endif  // __clang__
227
228
#ifdef __GNUC__
229
#if GCC_VERSION >= 40600
230
#define PRAGMA45(str) _Pragma(#str)
231
#elif defined(__clang__)
232
#define PRAGMA45(str) _Pragma(#str)
233
#else  // GCC_VERSION > 40600
234
#define PRAGMA45(str)
235
#endif  // GCC_VERSION > 40600
236
237
#if GCC_VERSION >= 40000
238
#define PRAGMA4(str) _Pragma(#str)
239
#elif defined(__clang__)
240
#define PRAGMA4(str) _Pragma(#str)
241
#else  // GCC_VERSION > 40000
242
#define PRAGMA4(str)
243
#endif  // GCC_VERSION > 40000
244
#endif  // __GNUC__
245
246
#define notfinal
247
248
#ifdef ENABLE_CHECKPLUGIN
249
#define A_NONNULLPOINTER __attribute__((nonnullpointer))
250
#else  // ENABLE_CHECKPLUGIN
251
#define A_NONNULLPOINTER
252
#endif  // ENABLE_CHECKPLUGIN
253
254
#ifdef ENABLE_CHECKS
255
256
#define CHECKLISTENERS \
257
    config.checkListeners(this, __FILE__, __LINE__); \
258
    serverConfig.checkListeners(this, __FILE__, __LINE__);
259
260
#else  // ENABLE_CHECKS
261
262
#define CHECKLISTENERS
263
264
#endif  // ENABLE_CHECKS
265
266
#if defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
267
#define ifconstexpr if constexpr
268
#else  // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
269
#define ifconstexpr if
270
#endif  // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
271
272
#ifdef USE_SDL2
273
PRAGMA45(GCC diagnostic push)
274
PRAGMA45(GCC diagnostic ignored "-Wswitch-default")
275
#endif  // USE_SDL2
276
PRAGMA48(GCC diagnostic push)
277
PRAGMA48(GCC diagnostic ignored "-Wshadow")
278
#include <SDL_version.h>
279

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