From 945e1ac37ba0e75572b502c47a3dc0b7cdac4ebc Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sun, 29 Jan 2012 00:18:26 -0800 Subject: [PATCH] Make pnUtUuid compile on *nix. --- Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp | 11 +++++++++++ Sources/Plasma/NucleusLib/pnUUID/pnUUID.h | 6 ------ Sources/Plasma/NucleusLib/pnUUID/pnUUID_Win32.cpp | 11 ----------- Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt | 4 ++-- Sources/Plasma/NucleusLib/pnUtils/Pch.h | 1 - Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp | 2 +- Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h | 4 ---- Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.cpp | 6 ++++-- Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h | 7 ++++--- Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp | 2 ++ Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h | 4 ++-- 11 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp b/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp index f6c6073e..9780d2bb 100644 --- a/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp +++ b/Sources/Plasma/NucleusLib/pnUUID/pnUUID.cpp @@ -57,6 +57,11 @@ plUUID::plUUID( const plUUID & other ) CopyFrom( &other ); } +plUUID::plUUID( const Uuid & uuid ) +{ + memcpy(fData, uuid.data, sizeof(fData)); +} + void plUUID::Read( hsStream * s) { s->LogSubStreamPushDesc("plUUID"); @@ -73,3 +78,9 @@ const char * plUUID::AsString() const { ToStdString(str); return str.c_str(); } + +plUUID::operator Uuid () const { + Uuid uuid; + memcpy(uuid.data, fData, sizeof(uuid.data)); + return uuid; +} diff --git a/Sources/Plasma/NucleusLib/pnUUID/pnUUID.h b/Sources/Plasma/NucleusLib/pnUUID/pnUUID.h index 91878faa..8438601a 100644 --- a/Sources/Plasma/NucleusLib/pnUUID/pnUUID.h +++ b/Sources/Plasma/NucleusLib/pnUUID/pnUUID.h @@ -44,9 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "HeadSpin.h" #include "hsStlUtils.h" -#ifdef HS_BUILD_FOR_WIN32 #include "pnUtils/pnUtUuid.h" -#endif class hsStream; @@ -65,9 +63,7 @@ public: plUUID(); plUUID( const char * s ); plUUID( const plUUID & other ); -#ifdef HS_BUILD_FOR_WIN32 plUUID( const Uuid & uuid ); -#endif void Clear(); bool IsNull() const; bool IsSet() const { return !IsNull(); } @@ -85,9 +81,7 @@ public: bool operator==( const plUUID & other ) const { return IsEqualTo( &other ); } bool operator!=( const plUUID & other ) const { return !IsEqualTo( &other ); } int operator <( const plUUID & other ) const { return CompareTo( &other ); } -#ifdef HS_BUILD_FOR_WIN32 operator Uuid () const; -#endif static plUUID Generate(); }; diff --git a/Sources/Plasma/NucleusLib/pnUUID/pnUUID_Win32.cpp b/Sources/Plasma/NucleusLib/pnUUID/pnUUID_Win32.cpp index 59d585a3..da39532d 100644 --- a/Sources/Plasma/NucleusLib/pnUUID/pnUUID_Win32.cpp +++ b/Sources/Plasma/NucleusLib/pnUUID/pnUUID_Win32.cpp @@ -47,11 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include -plUUID::plUUID( const Uuid & uuid ) -{ - memcpy(fData, uuid.data, sizeof(fData)); -} - void plUUID::Clear() { UuidCreateNil( (GUID *)this ); @@ -85,12 +80,6 @@ void plUUID::CopyFrom( const plUUID & v ) { memcpy(fData, v.fData, sizeof(fData)); } -plUUID::operator Uuid () const { - Uuid uuid; - memcpy(uuid.data, fData, sizeof(uuid.data)); - return uuid; -} - bool plUUID::FromString( const char * str ) { Clear(); diff --git a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt index 56366de6..2774f622 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt +++ b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt @@ -45,6 +45,7 @@ set(pnUtils_SOURCES pnUtSpareList.cpp pnUtStr.cpp pnUtTime.cpp + pnUtUuid.cpp ) if(WIN32) @@ -59,13 +60,12 @@ if(WIN32) pnUtCrypt.cpp pnUtTls.cpp - pnUtUuid.cpp ) else() set(pnUtils_UNIX Unix/pnUtUxStr.cpp #Unix/pnUtUxSync.cpp - #Unix/pnUtUxUuid.cpp + Unix/pnUtUxUuid.cpp ) endif() diff --git a/Sources/Plasma/NucleusLib/pnUtils/Pch.h b/Sources/Plasma/NucleusLib/pnUtils/Pch.h index ac9bcdc7..b62001ac 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Pch.h +++ b/Sources/Plasma/NucleusLib/pnUtils/Pch.h @@ -50,7 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnUtCoreLib.h" // must be first in list #include "pnUtPragma.h" -#include "pnProduct/pnProduct.h" #include diff --git a/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp b/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp index 6722e337..25601fe2 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxUuid.cpp @@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com * ***/ -#include "../pnUtUUID.h" +#include "../pnUtUuid.h" /***************************************************************************** * diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h index 8a0d9e12..8e167f45 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h @@ -52,18 +52,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnUtCoreLib.h" // must be first in list #include "pnUtPragma.h" #include "pnUtAddr.h" -#if HS_BUILD_FOR_WIN32 #include "pnUtUuid.h" -#endif #include "pnUtMath.h" #include "pnUtSort.h" #include "pnUtArray.h" #include "pnUtList.h" #include "pnUtHash.h" #include "pnUtPriQ.h" -#if HS_BUILD_FOR_WIN32 #include "pnUtSync.h" -#endif #include "pnUtTime.h" #if HS_BUILD_FOR_WIN32 #include "pnUtTls.h" diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.cpp index 6c4a3801..1b303595 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.cpp @@ -46,6 +46,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com ***/ #include "pnUtCrypt.h" +#include "pnUtStr.h" +#include "pnUtTime.h" #include #include @@ -360,13 +362,13 @@ void CryptHashPasswordChallenge ( const ShaDigest & namePassHash, ShaDigest * challengeHash ) { - #include +#pragma pack(push, 1) struct { uint32_t clientChallenge; uint32_t serverChallenge; ShaDigest namePassHash; } buffer; - #include +#pragma pack(pop) buffer.clientChallenge = clientChallenge; buffer.serverChallenge = serverChallenge; buffer.namePassHash = namePassHash; diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h index d2dc4977..750b5bb7 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h @@ -104,9 +104,9 @@ public: #ifdef HS_BUILD_FOR_WIN32 typedef HANDLE EventHandle; -#else -# error "CEvent: Not implemented on this platform" -#endif +//#else +//# error "CEvent: Not implemented on this platform" +//#endif const unsigned kEventWaitForever = (unsigned)-1; @@ -130,5 +130,6 @@ public: const EventHandle & Handle () const { return m_handle; } }; +#endif // HS_BUILD_FOR_WIN32 #endif diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp index 5cda53ed..c5f31c32 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.cpp @@ -46,6 +46,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com ***/ #include "pnUtUuid.h" +#include "pnUtHash.h" +#include "pnUtStr.h" const Uuid kNilGuid; diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h index 4f0f20be..875adcf9 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h +++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtUuid.h @@ -95,7 +95,7 @@ bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid); * ***/ -#include +#pragma pack(push, 1) struct Uuid { union { uint32_t uint32_ts[4]; @@ -113,6 +113,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 +#pragma pack(pop) #endif