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(NONSTANDARD_PORT) 45 #else // defined(NONSTANDARD_PORT) 49 #if defined(_MSC_VER) && _MSC_VER <= 1800 62 inline int vsnprintf_msvc(
char *str,
size_t size,
const char *format, va_list args) {
66 int retValue = _vsnprintf(str, size, format, args);
71 #define vsnprintf vsnprintf_msvc 79 inline int snprintf(
char *str,
size_t size,
const char *format, ...) {
81 va_start(args, format);
82 int len = vsnprintf(str, size, format, args);
88 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 115 #if defined(__QNXNTO__) 131 #define _USE_MATH_DEFINES 147 #ifndef STATIC_ASSERT 148 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER > 1600) 156 #define STATIC_ASSERT(expression, message) \ 157 static_assert((expression), #message) 166 #define STATIC_ASSERT(expression, message) \ 168 extern int STATIC_ASSERT_##message[(expression) ? 1 : -1]; \ 169 (void)(STATIC_ASSERT_##message); \ 180 #define M_E 2.7182818284590452354 184 #define M_LOG2E 1.4426950408889634074 188 #define M_LOG10E 0.43429448190325182765 192 #define M_LN2 0.69314718055994530942 196 #define M_LN10 2.30258509299404568402 200 #define M_PI 3.14159265358979323846 204 #define M_PI_2 1.57079632679489661923 208 #define M_PI_4 0.78539816339744830962 212 #define M_1_PI 0.31830988618379067154 216 #define M_2_PI 0.63661977236758134308 220 #define M_2_SQRTPI 1.12837916709551257390 224 #define M_SQRT2 1.41421356237309504880 228 #define M_SQRT1_2 0.70710678118654752440 232 #if defined(HAVE_CONFIG_H) 263 #define SCUMMVM_USE_PRAGMA_PACK 268 #if !defined(HAVE_CONFIG_H) 274 #if __has_feature(undefined_behavior_sanitizer) 275 #define SCUMM_NEED_ALIGNMENT 278 #if defined(__DC__) || \ 280 defined(__3DS__) || \ 284 #define SCUMM_LITTLE_ENDIAN 285 #define SCUMM_NEED_ALIGNMENT 287 #elif defined(_MSC_VER) || defined(__MINGW32__) 289 #define SCUMM_LITTLE_ENDIAN 291 #elif defined(__MORPHOS__) || defined(__amigaos4__) || defined(__N64__) || defined(__WII__) 293 #define SCUMM_BIG_ENDIAN 294 #define SCUMM_NEED_ALIGNMENT 296 #elif defined(SDL_BACKEND) 300 #include <SDL_endian.h> 302 #if SDL_BYTEORDER == SDL_LIL_ENDIAN 303 #define SCUMM_LITTLE_ENDIAN 304 #elif SDL_BYTEORDER == SDL_BIG_ENDIAN 305 #define SCUMM_BIG_ENDIAN 307 #error Neither SDL_BIG_ENDIAN nor SDL_LIL_ENDIAN is set. 312 #error No system type defined, host endianess unknown. 317 #if !defined(SCUMM_FLOAT_WORD_LITTLE_ENDIAN) && !defined(SCUMM_FLOAT_WORD_BIG_ENDIAN) 319 #if defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__FLOAT_WORD_ORDER__) 321 #if (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) 322 #define SCUMM_FLOAT_WORD_LITTLE_ENDIAN 323 #elif (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) 324 #define SCUMM_FLOAT_WORD_BIG_ENDIAN 326 #error Unsupported endianness 330 #ifdef SCUMM_LITTLE_ENDIAN 331 #define SCUMM_FLOAT_WORD_LITTLE_ENDIAN 333 #define SCUMM_FLOAT_WORD_BIG_ENDIAN 348 #define toupper(c) __extension__ ({ auto _x = ((c) & 0xFF); (_x >= 97 && _x <= 122) ? (_x - 32) : _x; }) 350 #elif defined(__PSP__) 353 #include "backends/platform/psp/memory.h" 356 #define memcpy(dst, src, size) psp_memcpy(dst, src, size) 360 #if defined(USE_TREMOR) && !defined(USE_VORBIS) 361 #define USE_VORBIS // make sure this one is defined together with USE_TREMOR! 368 #if defined(__GNUC__) || defined(__INTEL_COMPILER) 369 #if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO && !defined(__clang__) 370 #define GCC_PRINTF(x,y) __attribute__((__format__(__gnu_printf__, x, y))) 372 #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) 375 #define GCC_PRINTF(x,y) 380 #if defined(_MSC_VER) && _MSC_VER > 1400 381 #define MSVC_PRINTF _Printf_format_string_ 387 #ifndef PACKED_STRUCT 388 #if defined(__GNUC__) || defined(__INTEL_COMPILER) 389 #define PACKED_STRUCT __attribute__((__packed__)) 391 #define PACKED_STRUCT 396 #if defined(_MSC_VER) 397 #define FORCEINLINE __forceinline 398 #elif defined(__GNUC__) 399 #define FORCEINLINE inline __attribute__((__always_inline__)) 401 #define FORCEINLINE inline 405 #ifndef PLUGIN_EXPORT 406 #if defined(_MSC_VER) || defined(__MINGW32__) 407 #define PLUGIN_EXPORT __declspec(dllexport) 409 #define PLUGIN_EXPORT 414 #if defined(_MSC_VER) 415 #define NORETURN_PRE __declspec(noreturn) 416 #elif defined(__GNUC__) 417 #define NORETURN_PRE __attribute__((__noreturn__)) 423 #ifndef NORETURN_POST 424 #if defined(__INTEL_COMPILER) 425 #define NORETURN_POST __attribute__((__noreturn__)) 427 #define NORETURN_POST 431 #ifndef WARN_UNUSED_RESULT 432 #if __cplusplus >= 201703L 433 #define WARN_UNUSED_RESULT [[nodiscard]] 434 #elif defined(__GNUC__) 435 #define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 436 #elif defined(_Check_return_) 437 #define WARN_UNUSED_RESULT _Check_return_ 439 #define WARN_UNUSED_RESULT 443 #ifndef WARN_DEPRECATED 444 #if __cplusplus >= 201703L 445 #define WARN_DEPRECATED(msg) [[deprecated(msg)]] 446 #elif defined(__GNUC__) 447 #define WARN_DEPRECATED(msg) __attribute__((__deprecated__(msg))) 448 #elif defined(_MSC_VER) 449 #define WARN_DEPRECATED(msg) __declspec(deprecated(msg)) 451 #define WARN_DEPRECATED(msg) 456 #if defined(__N64__) || defined(__DS__) || defined(__3DS__) 457 #define STRINGBUFLEN 256 459 #define STRINGBUFLEN 1024 464 #define MAXPATHLEN 256 467 #ifndef scumm_va_copy 469 #define scumm_va_copy va_copy 470 #elif defined(__va_copy) 471 #define scumm_va_copy __va_copy 472 #elif defined(_MSC_VER) 473 #define scumm_va_copy(dst, src) ((dst) = (src)) 475 #error scumm_va_copy undefined for this port 485 #if !defined(HAVE_CONFIG_H) && !defined(SCUMMVM_DONT_DEFINE_TYPES) 486 typedef unsigned char byte;
487 typedef unsigned char uint8;
488 typedef signed char int8;
489 typedef unsigned short uint16;
490 typedef signed short int16;
498 #if defined(WIN32) && !defined(_WIN64) 499 typedef unsigned long uint32;
500 typedef signed long int32;
502 typedef unsigned int uint32;
503 typedef signed int int32;
505 typedef unsigned int uint;
506 typedef signed long long int64;
507 typedef unsigned long long uint64;
514 #if !defined(HAVE_CONFIG_H) 516 #if defined(__x86_64__) || \ 518 defined(__ppc64__) || \ 519 defined(__powerpc64__) || \ 520 defined(__LP64__) || \ 523 typedef int64 intptr;
524 typedef uint64 uintptr;
528 typedef int32 intptr;
529 typedef uint32 uintptr;
538 #if defined(NO_CXX11_NULLPTR_T) 540 typedef decltype(
nullptr) nullptr_t;
548 #if defined(NO_CXX11_INITIALIZER_LIST) 550 template<
class T>
class initializer_list {
552 typedef T value_type;
553 typedef const T &reference;
554 typedef const T &const_reference;
555 typedef size_t size_type;
556 typedef const T *iterator;
557 typedef const T *const_iterator;
559 constexpr initializer_list() noexcept = default;
560 constexpr
size_t size() const noexcept {
return _size; };
561 constexpr
const T *begin() const noexcept {
return _begin; };
562 constexpr
const T *end() const noexcept {
return _begin + _size; }
566 const T *_begin = {
nullptr };
567 size_t _size = { 0 };
570 constexpr initializer_list(
const T* t,
size_t s) noexcept : _begin(t) , _size(s) {}
573 template<
class T> constexpr
const T* begin(initializer_list<T> il) noexcept {
577 template<
class T> constexpr
const T* end(initializer_list<T> il) noexcept {
584 #include <initializer_list> 586 #endif // NO_CXX11_INITIALIZER_LIST