diff --git a/src/openrct2/common.h b/src/openrct2/common.h index 14a2f3dea1..6e5b60ec17 100644 --- a/src/openrct2/common.h +++ b/src/openrct2/common.h @@ -41,45 +41,4 @@ constexpr datetime64 DATETIME64_MIN = 0; #define abstract = 0 -#if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) -# define OPENRCT2_X86 -#elif defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_X64) || defined(_M_IX86)) // VS2008 -# define OPENRCT2_X86 -#endif - -#if defined(__i386__) || defined(_M_IX86) -# define PLATFORM_X86 -#endif - -#if defined(__LP64__) || defined(_WIN64) -# define PLATFORM_64BIT -#else -# define PLATFORM_32BIT -#endif - -// C99's restrict keywords guarantees the pointer in question, for the whole of its lifetime, -// will be the only way to access a given memory region. In other words: there is no other pointer -// aliasing the same memory area. Using it lets compiler generate better code. If your compiler -// does not support it, feel free to drop it, at some performance hit. -#ifdef _MSC_VER -# define RESTRICT __restrict -#else -# define RESTRICT __restrict__ -#endif - #define assert_struct_size(x, y) static_assert(sizeof(x) == (y), "Improper struct size") - -#ifdef PLATFORM_X86 -# ifndef FASTCALL -# ifdef __GNUC__ -# define FASTCALL __attribute__((fastcall)) -# elif defined(_MSC_VER) -# define FASTCALL __fastcall -# else -# pragma message "Not using fastcall calling convention, please check your compiler support" -# define FASTCALL -# endif -# endif // FASTCALL -#else // PLATFORM_X86 -# define FASTCALL -#endif // PLATFORM_X86 diff --git a/src/openrct2/core/CallingConventions.h b/src/openrct2/core/CallingConventions.h new file mode 100644 index 0000000000..5d0646b087 --- /dev/null +++ b/src/openrct2/core/CallingConventions.h @@ -0,0 +1,51 @@ +/***************************************************************************** + * Copyright (c) 2014-2024 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) +# define OPENRCT2_X86 +#elif defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_X64) || defined(_M_IX86)) // VS2008 +# define OPENRCT2_X86 +#endif + +#if defined(__i386__) || defined(_M_IX86) +# define PLATFORM_X86 +#endif + +#if defined(__LP64__) || defined(_WIN64) +# define PLATFORM_64BIT +#else +# define PLATFORM_32BIT +#endif + +// C99's restrict keywords guarantees the pointer in question, for the whole of its lifetime, +// will be the only way to access a given memory region. In other words: there is no other pointer +// aliasing the same memory area. Using it lets compiler generate better code. If your compiler +// does not support it, feel free to drop it, at some performance hit. +#ifdef _MSC_VER +# define RESTRICT __restrict +#else +# define RESTRICT __restrict__ +#endif + +#ifdef PLATFORM_X86 +# ifndef FASTCALL +# ifdef __GNUC__ +# define FASTCALL __attribute__((fastcall)) +# elif defined(_MSC_VER) +# define FASTCALL __fastcall +# else +# pragma message "Not using fastcall calling convention, please check your compiler support" +# define FASTCALL +# endif +# endif // FASTCALL +#else // PLATFORM_X86 +# define FASTCALL +#endif // PLATFORM_X86 diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index cd26b80f70..6737aeeb9c 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -9,7 +9,7 @@ #pragma once -#include "../common.h" +#include "../core/CallingConventions.h" #include "../core/String.hpp" #include "../interface/Colour.h" #include "../interface/ZoomLevel.h" diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index d35b0a480b..533d141c12 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -182,6 +182,7 @@ + diff --git a/src/openrct2/util/Util.h b/src/openrct2/util/Util.h index d8130cb435..e790470d41 100644 --- a/src/openrct2/util/Util.h +++ b/src/openrct2/util/Util.h @@ -9,7 +9,7 @@ #pragma once -#include "../common.h" +#include "../core/CallingConventions.h" #include "../core/Money.hpp" #include "../core/String.hpp"