From db01c159775db2bff2f6a5c86af2235376b3c0ce Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sun, 4 Oct 2009 09:00:07 +0000 Subject: [PATCH] Linux: Minor fixups! git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1952 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Pcsx2Defs.h | 4 +-- common/src/Utilities/Exceptions.cpp | 8 +++--- common/src/Utilities/PathUtils.cpp | 6 ++--- common/src/Utilities/StringHelpers.cpp | 14 +++++------ common/src/Utilities/ThreadTools.cpp | 32 ++++++++++++------------ pcsx2/Linux/pcsx2.cbp | 1 + pcsx2/gui/Panels/PluginSelectorPanel.cpp | 2 +- 7 files changed, 34 insertions(+), 33 deletions(-) diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h index 1a4a7ac054..323d76f3d8 100644 --- a/common/include/Pcsx2Defs.h +++ b/common/include/Pcsx2Defs.h @@ -1,6 +1,6 @@ /* PCSX2 - PS2 Emulator for PCs * Copyright (C) 2002-2009 PCSX2 Dev Team - * + * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -229,7 +229,7 @@ This theoretically unoptimizes. Not having much luck so far. # define __naked // GCC lacks the naked specifier # define __assume(cond) // GCC has no equivalent for __assume -# define CALLBACK __stdcall +# define CALLBACK __attribute__((stdcall)) // Inlining note: GCC needs ((unused)) attributes defined on inlined functions to suppress // warnings when a static inlined function isn't used in the scope of a single file (which diff --git a/common/src/Utilities/Exceptions.cpp b/common/src/Utilities/Exceptions.cpp index 8186259dea..c686c3c70f 100644 --- a/common/src/Utilities/Exceptions.cpp +++ b/common/src/Utilities/Exceptions.cpp @@ -1,6 +1,6 @@ /* PCSX2 - PS2 Emulator for PCs * Copyright (C) 2002-2009 PCSX2 Dev Team - * + * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -47,12 +47,12 @@ DEVASSERT_INLINE void pxOnAssert( const wxChar* file, int line, const char* func #ifdef PCSX2_DEVBUILD RecursionGuard guard( s_assert_guard ); if( guard.IsReentrant() ) return; - + if( wxTheApp == NULL ) { // Note: Format uses MSVC's syntax for output window hotlinking. wxsFormat( L"%s(%d): Assertion failed in %s: %s\n", - file, line, fromUTF8(func), msg ); + file, line, fromUTF8(func).c_str(), msg ); wxLogError( msg ); } @@ -179,7 +179,7 @@ wxString Exception::StateCrcMismatch::FormatDisplayMessage() const { return wxsFormat( m_message_user + L"\n\n" + - wxsFormat( + wxsFormat( L"Savestate game/crc mismatch. Cdvd CRC: 0x%X Game CRC: 0x%X\n", Crc_Savestate, Crc_Cdvd ) diff --git a/common/src/Utilities/PathUtils.cpp b/common/src/Utilities/PathUtils.cpp index d4bfaacd4f..0273b2662e 100644 --- a/common/src/Utilities/PathUtils.cpp +++ b/common/src/Utilities/PathUtils.cpp @@ -1,6 +1,6 @@ /* PCSX2 - PS2 Emulator for PCs * Copyright (C) 2002-2009 PCSX2 Dev Team - * + * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -92,7 +92,7 @@ void wxDirName::Rmdir() bool wxDirName::Mkdir() { if( Exists() ) return true; - + // Recursively create child directories as needed: wxDirName recurse( *this ); recurse.RemoveLastDir(); @@ -173,7 +173,7 @@ wxString Path::GetDirectory( const wxString& src ) // Example /this/that/something.txt -> dest == "/" wxString Path::GetRootDirectory( const wxString& src ) { - int pos = src.find_first_of( wxFileName::GetPathSeparators() ); + size_t pos = src.find_first_of( wxFileName::GetPathSeparators() ); if( pos == wxString::npos ) return wxString(); else diff --git a/common/src/Utilities/StringHelpers.cpp b/common/src/Utilities/StringHelpers.cpp index 99f20f02ef..faa53fdafc 100644 --- a/common/src/Utilities/StringHelpers.cpp +++ b/common/src/Utilities/StringHelpers.cpp @@ -1,6 +1,6 @@ /* PCSX2 - PS2 Emulator for PCs * Copyright (C) 2002-2009 PCSX2 Dev Team - * + * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -12,7 +12,7 @@ * You should have received a copy of the GNU General Public License along with PCSX2. * If not, see . */ - + #include "PrecompiledHeader.h" const wxRect wxDefaultRect( wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxDefaultCoord ); @@ -161,7 +161,7 @@ bool TryParse( wxRect& dest, const wxString& src, const wxRect& defval, const wx dest = defval; wxStringTokenizer parts( src, separators ); - + wxPoint point; wxSize size; @@ -172,7 +172,7 @@ bool TryParse( wxRect& dest, const wxString& src, const wxRect& defval, const wx return true; } -// Performs a cross-platform puts operation, which adds CRs to naked LFs on Win32 platforms, +// Performs a cross-platform puts operation, which adds CRs to naked LFs on Win32 platforms, // so that Notepad won't throw a fit and Rama can read the logs again! On Unix and Mac platforms, // the input string is written unmodified. // @@ -187,7 +187,7 @@ void px_fputs( FILE* fp, const char* src ) #ifdef _WIN32 // Windows needs CR's partnered with all newlines, or else notepad.exe can't view // the stupid logfile. Best way is to write one char at a time.. >_< - + const char* curchar = src; bool prevcr = false; while( *curchar != 0 ) @@ -214,6 +214,6 @@ void px_fputs( FILE* fp, const char* src ) // Linux is happy with plain old LFs. Not sure about Macs... does OSX still // go by the old school Mac style of using Crs only? - fputs( src, emuLog ); // fputs does not do automatic newlines, so it's ok! + fputs( src, fp ); // fputs does not do automatic newlines, so it's ok! #endif -} \ No newline at end of file +} diff --git a/common/src/Utilities/ThreadTools.cpp b/common/src/Utilities/ThreadTools.cpp index a9009acdce..1f0ceb3dc3 100644 --- a/common/src/Utilities/ThreadTools.cpp +++ b/common/src/Utilities/ThreadTools.cpp @@ -1,6 +1,6 @@ /* PCSX2 - PS2 Emulator for PCs * Copyright (C) 2002-2009 PCSX2 Dev Team - * + * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -12,7 +12,7 @@ * You should have received a copy of the GNU General Public License along with PCSX2. * If not, see . */ - + #include "PrecompiledHeader.h" #include "Threading.h" @@ -52,7 +52,7 @@ namespace Threading // against the thread. Extending classes should almost always implement their own // thread closure process, since any PersistentThread will, by design, not terminate // unless it has been properly canceled. - // + // // Thread safetly: This class must not be deleted from its own thread. That would be // like marrying your sister, and then cheating on her with your daughter. PersistentThread::~PersistentThread() throw() @@ -222,12 +222,12 @@ namespace Threading catch( std::logic_error& ex ) { throw Exception::LogicError( wxsFormat( L"(thread: %s) STL Logic Error: %s\n\t%s", - GetName().c_str(), wxString::FromUTF8( ex.what() ) ) + GetName().c_str(), fromUTF8( ex.what() ).c_str() ) ); } catch( Exception::LogicError& ex ) { - m_except->DiagMsg() = wxsFormat( L"(thread:%s) ", GetName() ) + m_except->DiagMsg(); + m_except->DiagMsg() = wxsFormat( L"(thread:%s) ", GetName().c_str() ) + m_except->DiagMsg(); ex.Rethrow(); } catch( std::runtime_error& ex ) @@ -235,25 +235,25 @@ namespace Threading m_except = new Exception::RuntimeError( // Diagnostic message: wxsFormat( L"(thread: %s) STL Runtime Error: %s\n\t%s", - GetName().c_str(), wxString::FromUTF8( ex.what() ) + GetName().c_str(), fromUTF8( ex.what() ).c_str() ), - + // User Message (not translated, std::exception doesn't have that kind of fancy! wxsFormat( L"A runtime error occurred in %s:\n\n%s (STL)", - GetName().c_str(), wxString::FromUTF8( ex.what() ) + GetName().c_str(), fromUTF8( ex.what() ).c_str() ) ); } catch( Exception::RuntimeError& ex ) { m_except = ex.Clone(); - m_except->DiagMsg() = wxsFormat( L"(thread:%s) ", GetName() ) + m_except->DiagMsg(); + m_except->DiagMsg() = wxsFormat( L"(thread:%s) ", GetName().c_str() ) + m_except->DiagMsg(); } } void PersistentThread::OnStart() {} void PersistentThread::OnThreadCleanup() {} - + void* PersistentThread::_internal_callback( void* itsme ) { jASSUME( itsme != NULL ); @@ -269,17 +269,17 @@ namespace Threading { DoSetThreadName( toUTF8(name) ); } - + void PersistentThread::DoSetThreadName( __unused const char* name ) { wxASSERT( IsSelf() ); // only allowed from our own thread, thanks. #ifdef _WINDOWS_ - + // This code sample was borrowed form some obscure MSDN article. // In a rare bout of sanity, it's an actual Micrsoft-published hack // that actually works! - + static const int MS_VC_EXCEPTION = 0x406D1388; #pragma pack(push,8) @@ -332,7 +332,7 @@ namespace Threading m_post_TaskComplete.Reset(); m_sem_event.Post(); } - + // Blocks current thread execution pending the completion of the parallel task. void BaseTaskThread::WaitForResult() { @@ -402,7 +402,7 @@ namespace Threading // -------------------------------------------------------------------------------------- // Semaphore Implementations // -------------------------------------------------------------------------------------- - + Semaphore::Semaphore() { sem_init( &sema, false, 0 ); @@ -452,7 +452,7 @@ namespace Threading { // In order to avoid deadlock we need to make sure we cut some time // to handle messages. - + do { wxTheApp->Yield(); } while( !Wait( ts_msec_250 ) ); diff --git a/pcsx2/Linux/pcsx2.cbp b/pcsx2/Linux/pcsx2.cbp index b981d5b22b..fb92e0b784 100644 --- a/pcsx2/Linux/pcsx2.cbp +++ b/pcsx2/Linux/pcsx2.cbp @@ -269,6 +269,7 @@ + diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp index ad29624807..f601a3f943 100644 --- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp +++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp @@ -566,7 +566,7 @@ void Panels::PluginSelectorPanel::EnumThread::ExecuteTask() DoNextPlugin( curidx ); if( (curidx & 3) == 3 ) wxGetApp().Ping(); // gives the gui thread some time to refresh pthread_testcancel(); - Sleep(150); + //Sleep(150); // uncomment this to slow down the selector, for debugging threading. } wxCommandEvent done( pxEVT_EnumerationFinished );