From ff013388249c4f51537e09f9f84b51e51d77cf10 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Tue, 8 Sep 2020 19:45:42 +0300 Subject: [PATCH] OGRE_CPU: cleaned definition to fix build for Apple Silicon aka macOS on ARM64; moved to Platform.h as it is already used there. --- OgreMain/include/OgrePlatform.h | 56 +++++++++++++++------- OgreMain/include/OgrePlatformInformation.h | 28 ----------- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/OgreMain/include/OgrePlatform.h b/OgreMain/include/OgrePlatform.h index de4726358dbca796f6fc8d8c76f6efc9d661d532..c187b816d04ec79168faa5883b7452cbc3f58473 100644 --- a/OgreMain/include/OgrePlatform.h +++ b/OgreMain/include/OgrePlatform.h @@ -56,6 +56,46 @@ namespace Ogre { #define OGRE_ARCHITECTURE_32 1 #define OGRE_ARCHITECTURE_64 2 +#define OGRE_CPU_UNKNOWN 0 +#define OGRE_CPU_X86 1 +#define OGRE_CPU_PPC 2 +#define OGRE_CPU_ARM 3 +#define OGRE_CPU_MIPS 4 + +/* Find CPU type */ +#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) +# define OGRE_CPU OGRE_CPU_X86 +#elif defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) +# define OGRE_CPU OGRE_CPU_PPC +#elif defined(__arm__) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64) +# define OGRE_CPU OGRE_CPU_ARM +#elif defined(__mips__) || defined(__mips64) || defined(__mips64_) || defined(_M_MIPS) +# define OGRE_CPU OGRE_CPU_MIPS +#else +# define OGRE_CPU OGRE_CPU_UNKNOWN +#endif + +/* Find the arch type */ +#if defined(__x86_64__) || defined(_M_X64) || defined(_M_X64) || defined(_M_AMD64) \ + || defined(__ppc64__) \ + || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) \ + || defined(__mips64) || defined(__mips64_) \ + || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) +# define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64 +#else +# define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32 +#endif + +/* Determine CPU endian. + We were once in situation when XCode could produce mixed endian fat binary with x86 and ppc archs inside, so it's safer to sniff compiler macros too + */ +#if defined(OGRE_CONFIG_BIG_ENDIAN) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +# define OGRE_ENDIAN OGRE_ENDIAN_BIG +#else +# define OGRE_ENDIAN OGRE_ENDIAN_LITTLE +#endif + + /* Finds the compiler type and version. */ #if (defined( __WIN32__ ) || defined( _WIN32 )) && defined(__ANDROID__) // We are using NVTegra @@ -170,13 +210,6 @@ namespace Ogre { # define OGRE_PLATFORM OGRE_PLATFORM_FREEBSD #else # define OGRE_PLATFORM OGRE_PLATFORM_LINUX -#endif - - /* Find the arch type */ -#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_ARM64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__) || defined(__arm64__) || defined(__aarch64__) || defined(__mips64) || defined(__mips64_) -# define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64 -#else -# define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32 #endif // For generating compiler warnings - should work on any compiler @@ -366,15 +399,6 @@ namespace Ogre { # define __OGRE_HAVE_DIRECTXMATH 0 #endif -//---------------------------------------------------------------------------- -// Endian Settings -// check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly -#ifdef OGRE_CONFIG_BIG_ENDIAN -# define OGRE_ENDIAN OGRE_ENDIAN_BIG -#else -# define OGRE_ENDIAN OGRE_ENDIAN_LITTLE -#endif - //---------------------------------------------------------------------------- // Set the default locale for strings #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID diff --git a/OgreMain/include/OgrePlatformInformation.h b/OgreMain/include/OgrePlatformInformation.h index 00bc867449c1a297362cf6695ea1bbc338e233a4..cb89801e6af4d474747e0ab3c3f31ec31377234f 100644 --- a/OgreMain/include/OgrePlatformInformation.h +++ b/OgreMain/include/OgrePlatformInformation.h @@ -35,34 +35,6 @@ namespace Ogre { // TODO: Puts following macros into OgrePlatform.h? // -/* Initial CPU stuff to set. -*/ -#define OGRE_CPU_UNKNOWN 0 -#define OGRE_CPU_X86 1 -#define OGRE_CPU_PPC 2 -#define OGRE_CPU_ARM 3 -#define OGRE_CPU_MIPS 4 - -/* Find CPU type -*/ -#if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))) || \ - (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) -# define OGRE_CPU OGRE_CPU_X86 - -#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE && defined(__BIG_ENDIAN__) -# define OGRE_CPU OGRE_CPU_PPC -#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE -# define OGRE_CPU OGRE_CPU_X86 -#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS && (defined(__i386__) || defined(__x86_64__)) -# define OGRE_CPU OGRE_CPU_X86 -#elif defined(__arm__) || defined(_M_ARM) || defined(__arm64__) || defined(__aarch64__) -# define OGRE_CPU OGRE_CPU_ARM -#elif defined(__mips64) || defined(__mips64_) -# define OGRE_CPU OGRE_CPU_MIPS -#else -# define OGRE_CPU OGRE_CPU_UNKNOWN -#endif - /* Find how to declare aligned variable. */ #if OGRE_COMPILER == OGRE_COMPILER_MSVC