From b10a6d5271ff23cfea47d98bdbae36bc4f73b75c Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 17 Nov 2010 04:58:35 +0000 Subject: [PATCH] newHostVM: MSVC compilation fix. git-svn-id: http://pcsx2.googlecode.com/svn/branches/newHostVM@4028 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Utilities/StringHelpers.h | 3 +++ common/src/Utilities/StringHelpers.cpp | 33 ++++++++++++++++++++++++ common/src/Utilities/VirtualMemory.cpp | 30 --------------------- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/common/include/Utilities/StringHelpers.h b/common/include/Utilities/StringHelpers.h index 1c40692991..c4b3927a53 100644 --- a/common/include/Utilities/StringHelpers.h +++ b/common/include/Utilities/StringHelpers.h @@ -82,6 +82,9 @@ extern bool TryParse( wxPoint& dest, const wxString& src, const wxPoint& defval= extern bool TryParse( wxSize& dest, const wxString& src, const wxSize& defval=wxDefaultSize, const wxString& separators=L","); extern bool TryParse( wxRect& dest, const wxString& src, const wxRect& defval=wxDefaultRect, const wxString& separators=L","); +const wxChar* pxPtrToString( void* ptr ); +const wxChar* pxPtrToString( uptr ptr ); + // -------------------------------------------------------------------------------------- // ParsedAssignmentString // -------------------------------------------------------------------------------------- diff --git a/common/src/Utilities/StringHelpers.cpp b/common/src/Utilities/StringHelpers.cpp index 1b4785fa8a..a8d8c25a3e 100644 --- a/common/src/Utilities/StringHelpers.cpp +++ b/common/src/Utilities/StringHelpers.cpp @@ -16,6 +16,8 @@ #include "PrecompiledHeader.h" #include // for wxPoint/wxRect stuff +#include "TlsVariable.inl" + __fi wxString fromUTF8( const char* src ) { // IMPORTANT: We cannot use wxString::FromUTF8 because it *stupidly* relies on a C++ global instance of @@ -118,6 +120,37 @@ wxString JoinString( const wxChar** src, const wxString& separator ) return dest; } + +template< uint T > +struct pxMiniCharBuffer +{ + wxChar chars[T]; + pxMiniCharBuffer() {} +}; + +// Rational for this function: %p behavior is undefined, and not well-implemented in most cases. +// MSVC doesn't prefix 0x, and Linux doesn't pad with zeros. (furthermore, 64-bit formatting is unknown +// and has even more room for variation and confusion). As is typical, we need portability, and so this +// isn't really acceptable. So here's a portable version! +const wxChar* pxPtrToString( void* ptr ) +{ + static Threading::TlsVariable< pxMiniCharBuffer < 32 > > buffer; + +#ifdef __x86_64__ + wxSnprintf( buffer->chars, 31, wxT("0x%08X.%08X"), ptr ); +#else + wxSnprintf( buffer->chars, 31, wxT("0x%08X"), ptr ); +#endif + + return buffer->chars; +} + +const wxChar* pxPtrToString( uptr ptr ) +{ + return pxPtrToString( (void*)ptr ); +} + + // Attempts to parse and return a value for the given template type, and throws a ParseError // exception if the parse fails. The template type can be anything that is supported/ // implemented via one of the TryParse() method overloads. diff --git a/common/src/Utilities/VirtualMemory.cpp b/common/src/Utilities/VirtualMemory.cpp index f9f0b3cfd8..bb6ec7e838 100644 --- a/common/src/Utilities/VirtualMemory.cpp +++ b/common/src/Utilities/VirtualMemory.cpp @@ -22,7 +22,6 @@ #include "EventSource.inl" #include "MemsetFast.inl" -#include "TlsVariable.inl" template class EventSource< IEventListener_PageFault >; @@ -102,35 +101,6 @@ VirtualMemoryReserve& VirtualMemoryReserve::SetPageAccessOnCommit( const PagePro return *this; } -template< uint T > -struct pxMiniCharBuffer -{ - wxChar chars[T]; - pxMiniCharBuffer() {} -}; - -// Rational for this function: %p behavior is undefined, and not well-implemented in most cases. -// MSVC doesn't prefix 0x, and Linux doesn't pad with zeros. (furthermore, 64-bit formatting is unknown -// and has even more room for variation and confusion). As is typical, we need portability, and so this -// isn't really acceptable. So here's a portable version! -const wxChar* pxPtrToString( void* ptr ) -{ - static Threading::TlsVariable< pxMiniCharBuffer < 32 > > buffer; - -#ifdef __x86_64__ - wxSnprintf( buffer->chars, 31, wxT("0x%08X.%08X"), ptr ); -#else - wxSnprintf( buffer->chars, 31, wxT("0x%08X"), ptr ); -#endif - - return buffer->chars; -} - -const wxChar* pxPtrToString( uptr ptr ) -{ - pxPtrToString( (void*)ptr ); -} - // Notes: // * This method should be called if the object is already in an released (unreserved) state. // Subsequent calls will be ignored, and the existing reserve will be returned.