From 3c1bf3ca8e55c7cbe09a67be036b1f96ae6ad956 Mon Sep 17 00:00:00 2001 From: philippelatulippe Date: Fri, 22 Apr 2011 21:00:55 -0400 Subject: [PATCH 1/3] Fix case of two include --- Sources/Plasma/NucleusLib/pnUtils/Private/pnUtUuid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtUuid.h b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtUuid.h index 0af9a71e..d4e60a7e 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtUuid.h +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtUuid.h @@ -80,7 +80,7 @@ bool GuidFromHex (const byte buf[], unsigned length, Uuid * uuid); * ***/ -#include +#include struct Uuid { union { dword dwords[4]; @@ -98,6 +98,6 @@ struct Uuid { inline bool operator != (const Uuid & rhs) const { return !GuidsAreEqual(*this, rhs); } inline bool operator != (int rhs) const { ASSERT(!rhs); return !GuidsAreEqual(*this, kNilGuid); } }; -#include +#include From d14938029f2fd84114f470a7e7c62cb69d32e9d8 Mon Sep 17 00:00:00 2001 From: philippelatulippe Date: Fri, 22 Apr 2011 21:13:39 -0400 Subject: [PATCH 2/3] Fix compile-time endianness check to work on linux. As the original comment says, it's still not very robust. --- Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h index 29f2eeb1..ca3f8976 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h @@ -46,13 +46,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com * ***/ -#ifdef _M_IX86 -# define LITTLE_ENDIAN 1 +#if defined(_M_IX86) || defined(i386) || defined(__i386__) || defined(__i386) +# ifndef LITTLE_ENDIAN +# define LITTLE_ENDIAN 1 +# endif #else -# define BIG_ENDIAN 1 +# ifndef BIG_ENDIAN +# define BIG_ENDIAN 1 // That was a pretty weak check for endian-ness, if it // failed then we probably need to strengthen it a bit. # error "Are you sure this is a big-endian CPU?" +# endif #endif From 62a6757ea69958bcc36dac4f505e4502a741dc0c Mon Sep 17 00:00:00 2001 From: philippelatulippe Date: Sat, 23 Apr 2011 20:43:03 -0400 Subject: [PATCH 3/3] Use cmake's TestBigEndian to set BIG_ENDIAN or LITTLE_ENDIAN. --- CMakeLists.txt | 8 ++++++++ .../NucleusLib/pnUtils/Private/pnUtEndian.h | 20 ------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66ab43a7..443f49c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,14 @@ if(PLASMA_TARGETS STREQUAL "Ethereal") add_definitions(-DSTREAM_LOGGER) endif(PLASMA_TARGETS STREQUAL "Ethereal") +INCLUDE(TestBigEndian) +TEST_BIG_ENDIAN(BIG_ENDIAN) +IF(BIG_ENDIAN) + ADD_DEFINITIONS(-DBIG_ENDIAN) +ELSE() + ADD_DEFINITIONS(-DLITTLE_ENDIAN) +ENDIF() + if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_SCL_SECURE_NO_WARNINGS) diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h index ca3f8976..51e2837d 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtEndian.h @@ -40,26 +40,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // use little-endian as the "native" language of our network messages. -/***************************************************************************** -* -* Types and constants -* -***/ - -#if defined(_M_IX86) || defined(i386) || defined(__i386__) || defined(__i386) -# ifndef LITTLE_ENDIAN -# define LITTLE_ENDIAN 1 -# endif -#else -# ifndef BIG_ENDIAN -# define BIG_ENDIAN 1 -// That was a pretty weak check for endian-ness, if it -// failed then we probably need to strengthen it a bit. -# error "Are you sure this is a big-endian CPU?" -# endif -#endif - - /***************************************************************************** * * Little endian functions