Skip to content

Commit

Permalink
OGRE_CPU: cleaned definition to fix build for Apple Silicon aka macOS…
Browse files Browse the repository at this point in the history
… on ARM64; moved to Platform.h as it is already used there.
  • Loading branch information
Eugene Golushkov committed Sep 8, 2020
1 parent 48d88dc commit ff01338
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 44 deletions.
56 changes: 40 additions & 16 deletions OgreMain/include/OgrePlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 0 additions & 28 deletions OgreMain/include/OgrePlatformInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff01338

Please sign in to comment.