22 #ifndef COMMON_SCUMMSYS_H 23 #define COMMON_SCUMMSYS_H 25 #ifndef __has_feature // Optional of course. 26 #define __has_feature(x) 0 // Compatibility with non-clang compilers. 33 #define GCC_ATLEAST(major, minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) 35 #define GCC_ATLEAST(major, minor) 0 38 #if defined(_MSC_VER) && _MSC_VER < 1900 39 #error MSVC support requires MSVC 2015 or newer 42 #if defined(NONSTANDARD_PORT) 49 #else // defined(NONSTANDARD_PORT) 53 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 80 #if defined(__QNXNTO__) 96 #define __STDC_CONSTANT_MACROS 97 #define __STDC_FORMAT_MACROS 98 #define __STDC_LIMIT_MACROS 102 #if defined(MACOSX) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050 103 #undef __PRI_8_LENGTH_MODIFIER__ 104 #undef __PRI_64_LENGTH_MODIFIER__ 105 #undef __SCN_64_LENGTH_MODIFIER__ 106 #define __PRI_8_LENGTH_MODIFIER__ "hh" 107 #define __PRI_64_LENGTH_MODIFIER__ "ll" 108 #define __SCN_64_LENGTH_MODIFIER__ "ll" 117 #define _USE_MATH_DEFINES 133 #ifndef STATIC_ASSERT 134 #if __cplusplus >= 201103L || defined(_MSC_VER) 142 #define STATIC_ASSERT(expression, message) \ 143 static_assert((expression), #message) 152 #define STATIC_ASSERT(expression, message) \ 154 extern int STATIC_ASSERT_##message[(expression) ? 1 : -1]; \ 155 (void)(STATIC_ASSERT_##message); \ 166 #define M_E 2.7182818284590452354 170 #define M_LOG2E 1.4426950408889634074 174 #define M_LOG10E 0.43429448190325182765 178 #define M_LN2 0.69314718055994530942 182 #define M_LN10 2.30258509299404568402 186 #define M_PI 3.14159265358979323846 190 #define M_PI_2 1.57079632679489661923 194 #define M_PI_4 0.78539816339744830962 198 #define M_1_PI 0.31830988618379067154 202 #define M_2_PI 0.63661977236758134308 206 #define M_2_SQRTPI 1.12837916709551257390 210 #define M_SQRT2 1.41421356237309504880 214 #define M_SQRT1_2 0.70710678118654752440 218 #if defined(HAVE_CONFIG_H) 243 #if __has_feature(alignment_sanitizer) || __has_feature(undefined_behavior_sanitizer) 244 #define SCUMM_NEED_ALIGNMENT 258 #define SCUMMVM_USE_PRAGMA_PACK 263 #if !defined(HAVE_CONFIG_H) 265 #if defined(__DC__) || \ 267 defined(__3DS__) || \ 271 #define SCUMM_LITTLE_ENDIAN 272 #define SCUMM_NEED_ALIGNMENT 274 #elif defined(_MSC_VER) || defined(__MINGW32__) 276 #define SCUMM_LITTLE_ENDIAN 278 #elif defined(__MORPHOS__) || defined(__amigaos4__) || defined(__N64__) || defined(__WII__) 280 #define SCUMM_BIG_ENDIAN 281 #define SCUMM_NEED_ALIGNMENT 283 #elif defined(SDL_BACKEND) 287 #include <SDL_endian.h> 289 #if SDL_BYTEORDER == SDL_LIL_ENDIAN 290 #define SCUMM_LITTLE_ENDIAN 291 #elif SDL_BYTEORDER == SDL_BIG_ENDIAN 292 #define SCUMM_BIG_ENDIAN 294 #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. 299 #error No system type defined, host endianess unknown. 304 #if !defined(SCUMM_FLOAT_WORD_LITTLE_ENDIAN) && !defined(SCUMM_FLOAT_WORD_BIG_ENDIAN) 306 #if defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__FLOAT_WORD_ORDER__) 308 #if (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) 309 #define SCUMM_FLOAT_WORD_LITTLE_ENDIAN 310 #elif (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) 311 #define SCUMM_FLOAT_WORD_BIG_ENDIAN 313 #error Unsupported endianness 317 #ifdef SCUMM_LITTLE_ENDIAN 318 #define SCUMM_FLOAT_WORD_LITTLE_ENDIAN 320 #define SCUMM_FLOAT_WORD_BIG_ENDIAN 326 #if defined(USE_TREMOR) && !defined(USE_VORBIS) 327 #define USE_VORBIS // make sure this one is defined together with USE_TREMOR! 334 #if defined(__GNUC__) || defined(__INTEL_COMPILER) 335 #if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO && !defined(__clang__) 336 #define GCC_PRINTF(x,y) __attribute__((__format__(__gnu_printf__, x, y))) 338 #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) 341 #define GCC_PRINTF(x,y) 346 #if defined(_MSC_VER) 347 #define MSVC_PRINTF _Printf_format_string_ 353 #ifndef PACKED_STRUCT 354 #if defined(__GNUC__) || defined(__INTEL_COMPILER) 355 #define PACKED_STRUCT __attribute__((__packed__)) 357 #define PACKED_STRUCT 362 #if defined(_MSC_VER) 363 #define FORCEINLINE __forceinline 364 #elif defined(__GNUC__) 365 #define FORCEINLINE inline __attribute__((__always_inline__)) 367 #define FORCEINLINE inline 371 #ifndef PLUGIN_EXPORT 372 #if defined(_MSC_VER) || defined(__MINGW32__) 373 #define PLUGIN_EXPORT __declspec(dllexport) 375 #define PLUGIN_EXPORT 380 #if defined(_MSC_VER) 381 #define NORETURN_PRE __declspec(noreturn) 382 #elif defined(__GNUC__) 383 #define NORETURN_PRE __attribute__((__noreturn__)) 389 #ifndef NORETURN_POST 390 #if defined(__INTEL_COMPILER) 391 #define NORETURN_POST __attribute__((__noreturn__)) 393 #define NORETURN_POST 397 #ifndef WARN_UNUSED_RESULT 398 #if __cplusplus >= 201703L 399 #define WARN_UNUSED_RESULT [[nodiscard]] 400 #elif defined(__GNUC__) 401 #define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 402 #elif defined(_Check_return_) 403 #define WARN_UNUSED_RESULT _Check_return_ 405 #define WARN_UNUSED_RESULT 409 #ifndef WARN_DEPRECATED 410 #if __cplusplus >= 201703L 411 #define WARN_DEPRECATED(msg) [[deprecated(msg)]] 412 #elif defined(__GNUC__) 413 #define WARN_DEPRECATED(msg) __attribute__((__deprecated__(msg))) 414 #elif defined(_MSC_VER) 415 #define WARN_DEPRECATED(msg) __declspec(deprecated(msg)) 417 #define WARN_DEPRECATED(msg) 422 #if defined(__N64__) || defined(__DS__) || defined(__3DS__) 423 #define STRINGBUFLEN 256 425 #define STRINGBUFLEN 1024 430 #define MAXPATHLEN 256 433 #ifndef scumm_va_copy 435 #define scumm_va_copy va_copy 436 #elif defined(__va_copy) 437 #define scumm_va_copy __va_copy 438 #elif defined(_MSC_VER) 439 #define scumm_va_copy(dst, src) ((dst) = (src)) 441 #error scumm_va_copy undefined for this port 451 #ifndef SCUMMVM_DONT_DEFINE_TYPES 452 typedef unsigned char byte;
453 typedef unsigned int uint;
455 typedef uint8_t uint8;
457 typedef uint16_t uint16;
458 typedef int16_t int16;
459 #if defined(__3DS__) || defined(__DC__) || defined(__PSP__) 464 typedef unsigned int uint32;
466 #elif defined(__amigaos4__) || defined(__MORPHOS__) 472 typedef unsigned long uint32;
473 typedef signed long int32;
475 typedef uint32_t uint32;
476 typedef int32_t int32;
478 typedef uint64_t uint64;
479 typedef int64_t int64;
480 typedef uintptr_t uintptr;
481 typedef intptr_t intptr;
488 #if defined(NO_CXX11_NULLPTR_T) 490 typedef decltype(
nullptr) nullptr_t;
498 #if defined(NO_CXX11_INITIALIZER_LIST) 500 template<
class T>
class initializer_list {
502 typedef T value_type;
503 typedef const T &reference;
504 typedef const T &const_reference;
505 typedef size_t size_type;
506 typedef const T *iterator;
507 typedef const T *const_iterator;
509 constexpr initializer_list() noexcept = default;
510 constexpr
size_t size() const noexcept {
return _size; };
511 constexpr
const T *begin() const noexcept {
return _begin; };
512 constexpr
const T *end() const noexcept {
return _begin + _size; }
516 const T *_begin = {
nullptr };
517 size_t _size = { 0 };
520 constexpr initializer_list(
const T* t,
size_t s) noexcept : _begin(t) , _size(s) {}
523 template<
class T> constexpr
const T* begin(initializer_list<T> il) noexcept {
527 template<
class T> constexpr
const T* end(initializer_list<T> il) noexcept {
534 #include <initializer_list> 536 #endif // NO_CXX11_INITIALIZER_LIST 547 #define toupper(c) __extension__ ({ auto _x = ((c) & 0xFF); (_x >= 97 && _x <= 122) ? (_x - 32) : _x; }) 549 #elif defined(__PSP__) 552 #include "backends/platform/psp/memory.h" 555 #define memcpy(dst, src, size) psp_memcpy(dst, src, size)
Definition: algorithm.h:37