Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef COMMON_SCUMMSYS_H
00024 #define COMMON_SCUMMSYS_H
00025
00026 #ifndef __has_feature // Optional of course.
00027 #define __has_feature(x) 0 // Compatibility with non-clang compilers.
00028 #endif
00029
00030
00031
00032 #ifdef __GNUC__
00033 #define GCC_ATLEAST(major, minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
00034 #else
00035 #define GCC_ATLEAST(major, minor) 0
00036 #endif
00037
00038 #if defined(_WIN32_WCE) && _WIN32_WCE < 300
00039 #define NONSTANDARD_PORT
00040 #endif
00041
00042 #if defined(NONSTANDARD_PORT)
00043
00044
00045
00046
00047
00048 #include <portdefs.h>
00049 #else // defined(NONSTANDARD_PORT)
00050
00051 #if defined(WIN32)
00052
00053 #if defined(_MSC_VER) && _MSC_VER <= 1800
00054
00055
00056
00057
00058
00059 #include <stdio.h>
00060 #include <stdarg.h>
00061
00062
00063
00064
00065
00066 inline int vsnprintf_msvc(char *str, size_t size, const char *format, va_list args) {
00067
00068
00069
00070 int retValue = _vsnprintf(str, size, format, args);
00071 str[size - 1] = 0;
00072 return retValue;
00073 }
00074
00075 #define vsnprintf vsnprintf_msvc
00076
00077
00078
00079
00080
00081
00082
00083 inline int snprintf(char *str, size_t size, const char *format, ...) {
00084 va_list args;
00085 va_start(args, format);
00086 int len = vsnprintf(str, size, format, args);
00087 va_end(args);
00088 return len;
00089 }
00090 #endif
00091
00092 #if !defined(_WIN32_WCE)
00093
00094 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
00095 #define NOGDICAPMASKS
00096 #define OEMRESOURCE
00097 #define NONLS
00098 #define NOICONS
00099 #define NOMCX
00100 #define NOPROFILER
00101 #define NOKANJI
00102 #define NOSERVICE
00103 #define NOMETAFILE
00104 #define NOCOMM
00105 #define NOCRYPT
00106 #define NOIME
00107 #define NOATOM
00108 #define NOCTLMGR
00109 #define NOCLIPBOARD
00110 #define NOMEMMGR
00111 #define NOSYSMETRICS
00112 #define NOMENUS
00113 #define NOOPENFILE
00114 #define NOWH
00115 #define NOSOUND
00116 #define NODRAWTEXT
00117
00118 #endif
00119
00120 #endif
00121
00122 #if defined(__QNXNTO__)
00123 #include <strings.h>
00124 #endif
00125
00126 #include <stdio.h>
00127 #include <stdlib.h>
00128 #include <string.h>
00129 #include <stdarg.h>
00130 #include <stddef.h>
00131 #include <assert.h>
00132 #include <ctype.h>
00133
00134
00135
00136
00137 #define _USE_MATH_DEFINES
00138 #include <math.h>
00139
00140
00141
00142
00143
00144
00145
00146 #if !defined(__SYMBIAN32__)
00147 #include <new>
00148 #endif
00149 #endif
00150
00151 #ifndef STATIC_ASSERT
00152 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER > 1600)
00153
00160 #define STATIC_ASSERT(expression, message) \
00161 static_assert((expression), #message)
00162 #else
00163
00170 #define STATIC_ASSERT(expression, message) \
00171 do { \
00172 extern int STATIC_ASSERT_##message[(expression) ? 1 : -1]; \
00173 (void)(STATIC_ASSERT_##message); \
00174 } while (false)
00175 #endif
00176 #endif
00177
00178
00179
00180
00181
00182
00183 #ifndef M_E
00184 #define M_E 2.7182818284590452354
00185 #endif
00186
00187 #ifndef M_LOG2E
00188 #define M_LOG2E 1.4426950408889634074
00189 #endif
00190
00191 #ifndef M_LOG10E
00192 #define M_LOG10E 0.43429448190325182765
00193 #endif
00194
00195 #ifndef M_LN2
00196 #define M_LN2 0.69314718055994530942
00197 #endif
00198
00199 #ifndef M_LN10
00200 #define M_LN10 2.30258509299404568402
00201 #endif
00202
00203 #ifndef M_PI
00204 #define M_PI 3.14159265358979323846
00205 #endif
00206
00207 #ifndef M_PI_2
00208 #define M_PI_2 1.57079632679489661923
00209 #endif
00210
00211 #ifndef M_PI_4
00212 #define M_PI_4 0.78539816339744830962
00213 #endif
00214
00215 #ifndef M_1_PI
00216 #define M_1_PI 0.31830988618379067154
00217 #endif
00218
00219 #ifndef M_2_PI
00220 #define M_2_PI 0.63661977236758134308
00221 #endif
00222
00223 #ifndef M_2_SQRTPI
00224 #define M_2_SQRTPI 1.12837916709551257390
00225 #endif
00226
00227 #ifndef M_SQRT2
00228 #define M_SQRT2 1.41421356237309504880
00229 #endif
00230
00231 #ifndef M_SQRT1_2
00232 #define M_SQRT1_2 0.70710678118654752440
00233 #endif
00234
00235
00236 #if __cplusplus < 201103L
00237 #include "common/c++11-compat.h"
00238 #endif
00239
00240
00241 #if defined(HAVE_CONFIG_H)
00242 #include "config.h"
00243 #endif
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 #define SCUMMVM_USE_PRAGMA_PACK
00273
00274
00275
00276
00277 #if !defined(HAVE_CONFIG_H)
00278
00279 #if defined(__DC__) || \
00280 defined(__DS__) || \
00281 defined(__3DS__) || \
00282 defined(IPHONE) || \
00283 defined(__PLAYSTATION2__) || \
00284 defined(__PSP__) || \
00285 defined(__SYMBIAN32__)
00286
00287 #define SCUMM_LITTLE_ENDIAN
00288 #define SCUMM_NEED_ALIGNMENT
00289
00290 #elif defined(_WIN32_WCE) || defined(_MSC_VER) || defined(__MINGW32__)
00291
00292 #define SCUMM_LITTLE_ENDIAN
00293
00294 #elif defined(__amigaos4__) || defined(__N64__) || defined(__WII__)
00295
00296 #define SCUMM_BIG_ENDIAN
00297 #define SCUMM_NEED_ALIGNMENT
00298
00299 #elif defined(SDL_BACKEND)
00300
00301
00302
00303 #include <SDL_endian.h>
00304
00305 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
00306 #define SCUMM_LITTLE_ENDIAN
00307 #elif SDL_BYTEORDER == SDL_BIG_ENDIAN
00308 #define SCUMM_BIG_ENDIAN
00309 #else
00310 #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set.
00311 #endif
00312
00313 #else
00314
00315 #error No system type defined, host endianess unknown.
00316
00317 #endif
00318 #endif
00319
00320
00321
00322
00323
00324 #if defined(DINGUX)
00325
00326
00327
00328 #undef toupper
00329 #define toupper(c) (((c & 0xFF) >= 97) && ((c & 0xFF) <= 122) ? ((c & 0xFF) - 32) : (c & 0xFF))
00330
00331 #elif defined(__PSP__)
00332
00333 #include <malloc.h>
00334 #include "backends/platform/psp/memory.h"
00335
00336
00337 #define memcpy(dst, src, size) psp_memcpy(dst, src, size)
00338
00339 #endif
00340
00341 #if defined(USE_TREMOR) && !defined(USE_VORBIS)
00342 #define USE_VORBIS // make sure this one is defined together with USE_TREMOR!
00343 #endif
00344
00345
00346
00347
00348 #ifndef GCC_PRINTF
00349 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
00350 #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y)))
00351 #else
00352 #define GCC_PRINTF(x,y)
00353 #endif
00354 #endif
00355
00356 #ifndef PACKED_STRUCT
00357 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
00358 #define PACKED_STRUCT __attribute__((__packed__))
00359 #else
00360 #define PACKED_STRUCT
00361 #endif
00362 #endif
00363
00364 #ifndef FORCEINLINE
00365 #if defined(_MSC_VER)
00366 #define FORCEINLINE __forceinline
00367 #elif GCC_ATLEAST(3, 1)
00368 #define FORCEINLINE inline __attribute__((__always_inline__))
00369 #else
00370 #define FORCEINLINE inline
00371 #endif
00372 #endif
00373
00374 #ifndef PLUGIN_EXPORT
00375 #if defined(_MSC_VER) || defined(_WIN32_WCE) || defined(__MINGW32__)
00376 #define PLUGIN_EXPORT __declspec(dllexport)
00377 #else
00378 #define PLUGIN_EXPORT
00379 #endif
00380 #endif
00381
00382 #ifndef NORETURN_PRE
00383 #if defined(_MSC_VER)
00384 #define NORETURN_PRE __declspec(noreturn)
00385 #else
00386 #define NORETURN_PRE
00387 #endif
00388 #endif
00389
00390 #ifndef NORETURN_POST
00391 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
00392 #define NORETURN_POST __attribute__((__noreturn__))
00393 #else
00394 #define NORETURN_POST
00395 #endif
00396 #endif
00397
00398 #ifndef WARN_UNUSED_RESULT
00399 #if __cplusplus >= 201703L
00400 #define WARN_UNUSED_RESULT [[nodiscard]]
00401 #elif GCC_ATLEAST(3, 4)
00402 #define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
00403 #elif defined(_Check_return_)
00404 #define WARN_UNUSED_RESULT _Check_return_
00405 #else
00406 #define WARN_UNUSED_RESULT
00407 #endif
00408 #endif
00409
00410 #ifndef STRINGBUFLEN
00411 #if defined(__N64__) || defined(__DS__) || defined(__3DS__)
00412 #define STRINGBUFLEN 256
00413 #else
00414 #define STRINGBUFLEN 1024
00415 #endif
00416 #endif
00417
00418
00419 #ifndef LOCAL_PI
00420 #define LOCAL_PI 3.14159265358979323846
00421 #endif
00422
00423 #ifndef MAXPATHLEN
00424 #define MAXPATHLEN 256
00425 #endif
00426
00427 #ifndef scumm_va_copy
00428 #if defined(va_copy)
00429 #define scumm_va_copy va_copy
00430 #elif defined(__va_copy)
00431 #define scumm_va_copy __va_copy
00432 #elif defined(_MSC_VER) || defined(__SYMBIAN32__)
00433 #define scumm_va_copy(dst, src) ((dst) = (src))
00434 #else
00435 #error scumm_va_copy undefined for this port
00436 #endif
00437 #endif
00438
00439
00440
00441
00442
00443
00444
00445 #if !defined(HAVE_CONFIG_H) && !defined(SCUMMVM_DONT_DEFINE_TYPES)
00446 typedef unsigned char byte;
00447 typedef unsigned char uint8;
00448 typedef signed char int8;
00449 typedef unsigned short uint16;
00450 typedef signed short int16;
00451 typedef unsigned int uint32;
00452 typedef signed int int32;
00453 typedef unsigned int uint;
00454 #ifdef __PLAYSTATION2__
00455 typedef signed long int64;
00456 typedef unsigned long uint64;
00457 #else
00458 typedef signed long long int64;
00459 typedef unsigned long long uint64;
00460 #endif
00461 #endif
00462
00463
00464
00465
00466
00467 #if !defined(HAVE_CONFIG_H)
00468
00469 #if defined(__x86_64__) || \
00470 defined(_M_X64) || \
00471 defined(__ppc64__) || \
00472 defined(__powerpc64__) || \
00473 defined(__LP64__)
00474
00475 typedef uint64 uintptr;
00476
00477 #else
00478
00479 typedef uint32 uintptr;
00480
00481 #endif
00482
00483 #endif
00484
00485 #include "common/forbidden.h"
00486
00487 #endif