From 3d0f8c986ff1b66823a43f5d8ccd64034b594bd1 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 9 Jul 2014 15:41:09 +0200 Subject: [PATCH 01/11] Update contributing.md --- CONTRIBUTING.md | 75 ++++--------------------------------------------- 1 file changed, 5 insertions(+), 70 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 256f6cd25b..a696c4aac5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,71 +1,6 @@ -# Contribution requirement -* be patient - Your contribution will gladly be reviewed but -* discuss with us your future contribution before coding it - Let's avoid duplicate work! Besides specification could be clarified this way. +[Please read me before posting any issue](https://github.com/PCSX2/pcsx2/wiki/How-to-create-useful-and-valid-issues) - -# Window contribution possibility -* check linux chapter ;) Various improvements are actually cross platform! - -# Linux contribution possibility - -You're welcome to the [linux contribution thread](http://forums.pcsx2.net/Thread-Areas-of-interest-for-new-linux-developers) to have full details. Here an handy list of feature that you could implement. Feel free to propse new enhancement. - -## House keeping and general compilation -* clean gcc flags -* clean gcc warning -* support clang (template mess) -* speed comparison clang/gcc -* support avx (gsdx) -* add missing/update copyright header -* LTO support -* PGO support - -## Core -* support XZ compressed iso - -## GSdx -* Fix OpenGL -* implement DX features on OGL (Amsodean's fxaa/video recording ....) -* Fix GLES3 -* add tooltip on gsdx gui -* finish shader subroutine usage (+find a way to clean shader and avoid duplication) -* finish buffer storage -* OSD - -## CDVD -* port CDVDgiga to linux ? - -## zzogl -* reduce gl requirement to 3.3 + gl4 extension -* use multibind -* fix EGL -* port GLSL to window -* Drop old GLSL backend (and much later Nivida CG) -* support wx3.0 - -## Portability -* port GSThread to std::thread -* port core thread to std::thread -* C11 aligned_alloc -* C++11 alignof/alignas syntax -* replace volatile/lock-free queue with real C++ atomic - -## Debian package -* need a refresh to the latest standard -* Clean debian/copyright => debmake -k - - -## QA -* [C++11 auto port](http://clang.llvm.org/extra/clang-modernize.html). Initial requirement: drop XP and support clang/llvm -* [Clean header include](https://code.google.com/p/include-what-you-use/) -* address sanitizer (gcc or clang) -* valgrind (not sure it can run PCSX2, maybe limit the scope to plugin) -* reformat the core/plugin to a constant style with tool like astyle - -# Very very long term feature -Those features will require a lots of work! It would require months if not years. There are listed here for completeness ;) -* PS2 ROM reimplementation (wrongly named HLE bios) -* Android X86 port -* Win/Linux ARM port +If you want to contribute be sure to check those links +1. [TODO list](https://github.com/PCSX2/pcsx2/wiki/Idea-of-contribution-%28aka-todo-list%29) +2. [wxWidgets coding stategies](https://github.com/PCSX2/pcsx2/wiki/wxWidgets-Coding-Strategies) +3. [Coding style](https://github.com/PCSX2/pcsx2/wiki/Code-Formatting-Guidelines) From 0de6e80093d804188b0035e290aaf8364293f30d Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 9 Jul 2014 15:46:46 +0200 Subject: [PATCH 02/11] stupid space --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a696c4aac5..47a4cac58d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ [Please read me before posting any issue](https://github.com/PCSX2/pcsx2/wiki/How-to-create-useful-and-valid-issues) If you want to contribute be sure to check those links -1. [TODO list](https://github.com/PCSX2/pcsx2/wiki/Idea-of-contribution-%28aka-todo-list%29) -2. [wxWidgets coding stategies](https://github.com/PCSX2/pcsx2/wiki/wxWidgets-Coding-Strategies) -3. [Coding style](https://github.com/PCSX2/pcsx2/wiki/Code-Formatting-Guidelines) + 1. [TODO list](https://github.com/PCSX2/pcsx2/wiki/Idea-of-contribution-%28aka-todo-list%29) + 2. [wxWidgets coding stategies](https://github.com/PCSX2/pcsx2/wiki/wxWidgets-Coding-Strategies) + 3. [Coding style](https://github.com/PCSX2/pcsx2/wiki/Code-Formatting-Guidelines) From a6d8b3b8478db511018f36b5ed8762c75d6e33d6 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 10 Jul 2014 09:17:07 +0200 Subject: [PATCH 03/11] linux build: add an easy option to strip binary --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 77d6a3097a..503fdcda90 100755 --- a/build.sh +++ b/build.sh @@ -23,6 +23,7 @@ do case $f in --dev|--devel ) flags="$flags -DCMAKE_BUILD_TYPE=Devel" ;; --dbg|--debug ) flags="$flags -DCMAKE_BUILD_TYPE=Debug" ;; + --strip ) flags="$flags -DCMAKE_BUILD_STRIP=TRUE" ;; --release ) flags="$flags -DCMAKE_BUILD_TYPE=Release" ;; --glsl ) flags="$flags -DGLSL_API=TRUE" ;; --egl ) flags="$flags -DEGL_API=TRUE" ;; From 1f188b2610d71ce9254f03c077205accc9687bbc Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 11 Jul 2014 14:32:17 -0500 Subject: [PATCH 04/11] Remove -march argument on x86_64 build option. GCC doesn't support pentium4 as a arch target for x86_64. It complains that the architecture doesn't support x86_64 Which to be fair the first few models didn't support 64bit. Just remove the architecture setting since there isn't a need for it. --- cmake/BuildParameters.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 29859a1aed..422c665c84 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -85,7 +85,7 @@ if(_ARCH_64 AND 64BIT_BUILD) set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") endif() - set(ARCH_FLAG "-m64 -msse -msse2 -march=pentium4") + set(ARCH_FLAG "-m64 -msse -msse2") add_definitions(-D_ARCH_64=1) else() message("Compiling 32bit build on 32/64bit architecture") From f401f817edae0a13f810b638720a5c5f880e4bec Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 11 Jul 2014 23:33:09 +0200 Subject: [PATCH 05/11] cmake: sdl opt typo + clean warning management Add back a lots of warning in the core! --- cmake/BuildParameters.cmake | 15 ++++++++++----- common/src/Utilities/CMakeLists.txt | 12 ++---------- common/src/x86emitter/CMakeLists.txt | 12 ++---------- pcsx2/CMakeLists.txt | 14 ++++---------- plugins/GSdx/CMakeLists.txt | 1 + 5 files changed, 19 insertions(+), 35 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 422c665c84..61256fcdba 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -34,7 +34,7 @@ option(XDG_STD "Use XDG standard path instead of the standard PCSX2 path") option(EXTRA_PLUGINS "Build various 'extra' plugins") # FIXME do a proper detection set(SDL2_LIBRARY "-lSDL2") -option(SDL2_LIBRARY "Use SDL2 on spu2x and onepad") +option(SDL2_API "Use SDL2 on spu2x and onepad") if(PACKAGE_MODE) if(NOT DEFINED PLUGIN_DIR) @@ -183,12 +183,17 @@ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") # -Wstrict-aliasing: to fix one day aliasing issue # -Wno-missing-field-initializers: standard allow to init only the begin of struct/array in static init. Just a silly warning. # -Wno-unused-function: warn for function not used in release build -set(DEFAULT_WARNINGS "-Wno-attributes -Wstrict-aliasing -Wno-missing-field-initializers -Wno-unused-function") -set(HARDEING_OPT "-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security") -set(DEFAULT_GCC_FLAG "${ARCH_FLAG} -pthread ${DEFAULT_WARNINGS} ${HARDEING_OPT}") +# -Wno-unused-variable: just annoying to manage different level of logging, a couple of extra var won't kill any serious compiler. +set(DEFAULT_WARNINGS "-Wall -Wno-attributes -Wstrict-aliasing -Wno-missing-field-initializers -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable") +set(HARDENING_FLAG "-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security") +set(COMMON_FLAG "-pipe -std=c++0x -fvisibility=hidden -pthread") if(CMAKE_BUILD_TYPE MATCHES "Debug|Devel") - set(DEFAULT_GCC_FLAG "-g ${DEFAULT_GCC_FLAG}") + set(DEBUG_FLAG "-g") +else() + set(DEBUG_FLAG "") endif() + +set(DEFAULT_GCC_FLAG "${ARCH_FLAG} ${COMMON_FLAG} ${DEFAULT_WARNINGS} ${HARDENING_FLAG} ${DEBUG_FLAG}") # c++ only flags set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -Wno-invalid-offsetof") diff --git a/common/src/Utilities/CMakeLists.txt b/common/src/Utilities/CMakeLists.txt index b5d9040d30..c53539d04f 100644 --- a/common/src/Utilities/CMakeLists.txt +++ b/common/src/Utilities/CMakeLists.txt @@ -11,19 +11,11 @@ set(Output Utilities) # set common flags set(CommonFlags - -pthread - -fvisibility=hidden -fno-dse -fno-guess-branch-probability -fno-strict-aliasing -fno-tree-dse - -pipe - -Wunused-variable) - -# set warning flags -set(DebugFlags - -g - -W) + ) # set optimization flags set(OptimizationFlags @@ -70,7 +62,7 @@ set(OptimizationFlags if(CMAKE_BUILD_TYPE STREQUAL Debug) # add defines - add_definitions(${CommonFlags} ${DebugFlags} -DPCSX2_DEBUG -DPCSX2_DEVBUILD) + add_definitions(${CommonFlags} -DPCSX2_DEBUG -DPCSX2_DEVBUILD) endif(CMAKE_BUILD_TYPE STREQUAL Debug) # Devel - Build diff --git a/common/src/x86emitter/CMakeLists.txt b/common/src/x86emitter/CMakeLists.txt index 6b159ad654..3bb115987d 100644 --- a/common/src/x86emitter/CMakeLists.txt +++ b/common/src/x86emitter/CMakeLists.txt @@ -11,19 +11,11 @@ set(Output x86emitter) # set common flags set(CommonFlags - -pthread - -fvisibility=hidden -fno-guess-branch-probability -fno-dse -fno-tree-dse -fno-strict-aliasing - -pipe - -Wunused-variable) - -# set warning flags -set(DebugFlags - -W - -g) + ) # set optimization flags set(OptimizationFlags @@ -70,7 +62,7 @@ set(OptimizationFlags if(CMAKE_BUILD_TYPE STREQUAL Debug) # add defines - add_definitions(${CommonFlags} ${DebugFlags} -DPCSX2_DEVBUILD -DPCSX2_DEBUG) + add_definitions(${CommonFlags} -DPCSX2_DEVBUILD -DPCSX2_DEBUG) endif(CMAKE_BUILD_TYPE STREQUAL Debug) # Devel - Build diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 4c07b87c4c..7d61832453 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -12,20 +12,14 @@ set(CommonFlags # Disable this optimization for the moment -fno-omit-frame-pointer # END GCC-4.6 - -pthread - -fvisibility=hidden -fno-guess-branch-probability -fno-dse -fno-tree-dse -fno-strict-aliasing + -Wno-parentheses -Wstrict-aliasing # Allow to track strict aliasing issue. - -std=c++0x - -pipe) - -# set warning flags -set(DebugFlags - -W - -g) + -Wno-char-subscripts # only impact svu which is deprecated + ) # set optimization flags set(OptimizationFlags @@ -72,7 +66,7 @@ set(OptimizationFlags if(CMAKE_BUILD_TYPE STREQUAL Debug) set(Output pcsx2-dbg) - add_definitions(${CommonFlags} ${DebugFlags} -DPCSX2_DEVBUILD -DPCSX2_DEBUG -DWX_PRECOMP) + add_definitions(${CommonFlags} -DPCSX2_DEVBUILD -DPCSX2_DEBUG -DWX_PRECOMP) endif(CMAKE_BUILD_TYPE STREQUAL Debug) # Devel - Build diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 128240da95..57636731c4 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -19,6 +19,7 @@ set(CommonFlags -fno-strict-aliasing -Wno-unknown-pragmas -Wno-parentheses + -Wunused-variable # __dummy variable need to be investigated ) set(OptimizationFlags From a1ac59a48a694155b45fbb558cdc6e766d756a01 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 12 Jul 2014 12:47:35 +0200 Subject: [PATCH 06/11] pcsx2: add various default case statement Note: add a note on some case note handled properly not sure how to fix them. Actually there are potentially invalid case. --- common/src/x86emitter/simd.cpp | 3 ++- pcsx2/DebugTools/DisassemblyManager.cpp | 4 ++++ pcsx2/DebugTools/DisassemblyManager.h | 2 +- pcsx2/DebugTools/MIPSAnalyst.cpp | 2 ++ pcsx2/IopBios.cpp | 5 ++--- pcsx2/System/SysThreadBase.cpp | 10 ++++++++++ pcsx2/gui/AppEventSources.cpp | 3 +++ pcsx2/gui/GlobalCommands.cpp | 1 + pcsx2/gui/Panels/GameDatabasePanel.cpp | 3 +-- 9 files changed, 26 insertions(+), 7 deletions(-) diff --git a/common/src/x86emitter/simd.cpp b/common/src/x86emitter/simd.cpp index 6e15059fcf..0c5715c346 100644 --- a/common/src/x86emitter/simd.cpp +++ b/common/src/x86emitter/simd.cpp @@ -30,8 +30,9 @@ const wxChar* EnumToString( SSE_RoundMode sse ) case SSEround_NegInf: return L"NegativeInfinity"; case SSEround_PosInf: return L"PositiveInfinity"; case SSEround_Chop: return L"Chop"; + default: return L"Invalid"; } - + return L"Invalid"; } diff --git a/pcsx2/DebugTools/DisassemblyManager.cpp b/pcsx2/DebugTools/DisassemblyManager.cpp index 0be7f6003e..efa33aa96d 100644 --- a/pcsx2/DebugTools/DisassemblyManager.cpp +++ b/pcsx2/DebugTools/DisassemblyManager.cpp @@ -211,6 +211,8 @@ void DisassemblyManager::analyze(u32 address, u32 size = 1024) address = info.address+info.size; } break; + default: + break; } } @@ -986,6 +988,8 @@ void DisassemblyData::createLines() pos += 4; } break; + default: + break; } size_t len = strlen(buffer); diff --git a/pcsx2/DebugTools/DisassemblyManager.h b/pcsx2/DebugTools/DisassemblyManager.h index e5303fda97..068e105311 100644 --- a/pcsx2/DebugTools/DisassemblyManager.h +++ b/pcsx2/DebugTools/DisassemblyManager.h @@ -32,7 +32,7 @@ struct DisassemblyLineInfo u32 totalSize; }; -enum LineType { LINE_UP, LINE_DOWN, LINE_RIGHT }; +enum LineType { LINE_UP, LINE_DOWN }; struct BranchLine { diff --git a/pcsx2/DebugTools/MIPSAnalyst.cpp b/pcsx2/DebugTools/MIPSAnalyst.cpp index 22f7929321..7f221e5d94 100644 --- a/pcsx2/DebugTools/MIPSAnalyst.cpp +++ b/pcsx2/DebugTools/MIPSAnalyst.cpp @@ -291,6 +291,8 @@ namespace MIPSAnalyst case BRANCH: info.branchTarget = info.opcodeAddress + 4 + ((signed short)(op&0xFFFF)<<2); break; + case NONE: + return false; } return true; diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index 7ffe08f248..b03299cd2a 100644 --- a/pcsx2/IopBios.cpp +++ b/pcsx2/IopBios.cpp @@ -264,9 +264,6 @@ namespace ioman { void close() { - if (type == FILE_FREE) - return; - switch (type) { case FILE_FILE: @@ -277,6 +274,8 @@ namespace ioman { dir->close(); dir = NULL; break; + case FILE_FREE: + return; } type = FILE_FREE; diff --git a/pcsx2/System/SysThreadBase.cpp b/pcsx2/System/SysThreadBase.cpp index 694a6a3a78..f4b472aa56 100644 --- a/pcsx2/System/SysThreadBase.cpp +++ b/pcsx2/System/SysThreadBase.cpp @@ -93,6 +93,9 @@ void SysThreadBase::Suspend( bool isBlocking ) switch( m_ExecMode ) { + // FIXME what to do for this case + // case ExecMode_NoThreadYet: + // Check again -- status could have changed since above. case ExecMode_Closed: return; @@ -109,6 +112,9 @@ void SysThreadBase::Suspend( bool isBlocking ) case ExecMode_Opened: m_ExecMode = ExecMode_Closing; break; + + case ExecMode_Closing: + break; } pxAssertDev( m_ExecMode == ExecMode_Closing, "ExecMode should be nothing other than Closing..." ); @@ -214,6 +220,10 @@ void SysThreadBase::Resume() if( (m_ExecMode != ExecMode_Closed) && (m_ExecMode != ExecMode_Paused) ) return; if( !GetCorePlugins().AreLoaded() ) return; break; + + case ExecMode_Paused: + case ExecMode_Closed: + break; } pxAssertDev( (m_ExecMode == ExecMode_Closed) || (m_ExecMode == ExecMode_Paused), diff --git a/pcsx2/gui/AppEventSources.cpp b/pcsx2/gui/AppEventSources.cpp index 26412ab3eb..419b72cd78 100644 --- a/pcsx2/gui/AppEventSources.cpp +++ b/pcsx2/gui/AppEventSources.cpp @@ -132,6 +132,9 @@ void Pcsx2App::DispatchEvent( CoreThreadStatus evt ) { switch( evt ) { + // FIXME what to do for this case + // case CoreThread_Indeterminate: + case CoreThread_Started: case CoreThread_Reset: case CoreThread_Stopped: diff --git a/pcsx2/gui/GlobalCommands.cpp b/pcsx2/gui/GlobalCommands.cpp index a72f942642..2106928161 100644 --- a/pcsx2/gui/GlobalCommands.cpp +++ b/pcsx2/gui/GlobalCommands.cpp @@ -182,6 +182,7 @@ namespace Implementations case AspectRatio_Stretch: art = AspectRatio_4_3; arts = L"AspectRatio_4_3"; break; case AspectRatio_4_3: art = AspectRatio_16_9; arts = L"AspectRatio_16:9"; break; case AspectRatio_16_9: art = AspectRatio_Stretch; arts = L"AspectRatio_Stretch";break; + default: break; } Console.WriteLn(L"(GSwindow) Aspect ratio: %s.", arts.c_str()); diff --git a/pcsx2/gui/Panels/GameDatabasePanel.cpp b/pcsx2/gui/Panels/GameDatabasePanel.cpp index 97871fcbc3..d9c3d0d87f 100644 --- a/pcsx2/gui/Panels/GameDatabasePanel.cpp +++ b/pcsx2/gui/Panels/GameDatabasePanel.cpp @@ -244,8 +244,7 @@ GameDatabaseListView& GameDatabaseListView::SortBy( GameDataColumnId column ) case GdbCol_Compat: std::sort(begin, end, GLSort_byCompat(isDescending)); break; case GdbCol_Patches: std::sort(begin, end, GLSort_byPatches(isDescending)); break; - // do not use jNO_DEFAULT here -- keeps release builds from crashing (it'll just - // ignore the sort request!) + default: break; // for GdbCol_Count } //m_GamesInView.( ); From f3d03b025aabc04ef75962e616f23058689d8d1c Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 12 Jul 2014 12:49:03 +0200 Subject: [PATCH 07/11] pcsx2: reorder init of member in constructor Init must be done in the order of declaration --- pcsx2/CDVD/CompressedFileReader.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pcsx2/CDVD/CompressedFileReader.cpp b/pcsx2/CDVD/CompressedFileReader.cpp index a9a0293344..8b15deae1e 100644 --- a/pcsx2/CDVD/CompressedFileReader.cpp +++ b/pcsx2/CDVD/CompressedFileReader.cpp @@ -105,7 +105,7 @@ static void WriteIndexToFile(Access* index, const wxString filename) { class ChunksCache { public: - ChunksCache(uint initialLimitMb) : m_size(0), m_entries(0), m_limit(initialLimitMb * 1024 * 1024) {}; + ChunksCache(uint initialLimitMb) : m_entries(0), m_size(0), m_limit(initialLimitMb * 1024 * 1024) {}; ~ChunksCache() { Clear(); }; void SetLimit(uint megabytes); void Clear() { MatchLimit(true); }; @@ -125,8 +125,8 @@ private: CacheEntry(void* pMallocedSrc, PX_off_t offset, int length, int coverage) : data(pMallocedSrc), offset(offset), - size(length), - coverage(coverage) + coverage(coverage), + size(length) {}; ~CacheEntry() { if (data) free(data); }; @@ -199,9 +199,9 @@ class GzippedFileReader : public AsyncFileReader public: GzippedFileReader(void) : m_pIndex(0), - m_cache(CACHE_SIZE_MB), + m_zstates(0), m_src(0), - m_zstates(0) { + m_cache(CACHE_SIZE_MB) { m_blocksize = 2048; }; @@ -466,4 +466,4 @@ bool CompressedFileReader::DetectCompressed(AsyncFileReader* pReader) { AsyncFileReader* CompressedFileReader::GetNewReader(const wxString& fileName) { //if (GzippedFileReader::CanHandle(pReader)) return new GzippedFileReader(); -} \ No newline at end of file +} From c73ce3d02df26256c17e6af19958832cc72ba708 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 12 Jul 2014 12:50:29 +0200 Subject: [PATCH 08/11] pcsx2: don't use 0&& to remove code It works but compiler is not happy because it is still parsing the full line. --- pcsx2/MTGS.cpp | 2 +- pcsx2/SamplProf.h | 6 +++--- pcsx2/x86/microVU_Macro.inl | 2 +- pcsx2/x86/sVU_zerorec.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index dba3a04b45..def44a6422 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -34,7 +34,7 @@ using namespace Threading; #if 0 //PCSX2_DEBUG # define MTGS_LOG Console.WriteLn #else -# define MTGS_LOG 0&& +# define MTGS_LOG(...) do {} while (0) #endif // forces the compiler to treat a non-volatile value as volatile. diff --git a/pcsx2/SamplProf.h b/pcsx2/SamplProf.h index 7fa918d7c6..e0adb8d709 100644 --- a/pcsx2/SamplProf.h +++ b/pcsx2/SamplProf.h @@ -42,9 +42,9 @@ void ProfilerTerminateSource( const wxString& Name ); #define ProfilerInit() (void)0 #define ProfilerTerm() (void)0 -#define ProfilerSetEnabled 0&& -#define ProfilerRegisterSource 0&& -#define ProfilerTerminateSource 0&& +#define ProfilerSetEnabled(...) (void)0 +#define ProfilerRegisterSource(...) (void)0 +#define ProfilerTerminateSource(...) (void)0 #endif diff --git a/pcsx2/x86/microVU_Macro.inl b/pcsx2/x86/microVU_Macro.inl index 225c98b0ea..021f894bb6 100644 --- a/pcsx2/x86/microVU_Macro.inl +++ b/pcsx2/x86/microVU_Macro.inl @@ -26,7 +26,7 @@ static VURegs& vu0Regs = vuRegs[0]; using namespace R5900::Dynarec; -#define printCOP2 0&& +#define printCOP2(...) (void)0 //#define printCOP2 DevCon.Status void setupMacroOp(int mode, const char* opName) { diff --git a/pcsx2/x86/sVU_zerorec.cpp b/pcsx2/x86/sVU_zerorec.cpp index 56dbc220be..db67a5399f 100644 --- a/pcsx2/x86/sVU_zerorec.cpp +++ b/pcsx2/x86/sVU_zerorec.cpp @@ -339,7 +339,7 @@ static void SuperVUEliminateDeadCode(); static void SuperVUAssignRegs(); //void SuperVUFreeXMMreg(int xmmreg, int xmmtype, int reg); -#define SuperVUFreeXMMreg 0&& +#define SuperVUFreeXMMreg(...) (void)0 void SuperVUFreeXMMregs(u32* livevars); static u32* SuperVUStaticAlloc(u32 size); From 79f6aacc8548ff09fb202249392099cfc89fe6eb Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 12 Jul 2014 12:52:28 +0200 Subject: [PATCH 09/11] common: various warning fix * Use c++11 static assert * Properly cast to parameter template to u32 (help clang) * Remove lots of useless ASM. Memset it only used with a size of 4096. * check pthread_mutex_init status --- common/include/Pcsx2Defs.h | 6 +++++- common/include/Utilities/lnx_memzero.h | 14 ++++++++++---- common/src/Utilities/Mutex.cpp | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h index 1acf59561c..7c0ab69384 100644 --- a/common/include/Pcsx2Defs.h +++ b/common/include/Pcsx2Defs.h @@ -77,7 +77,11 @@ extern "C" unsigned __int64 __xgetbv(int); // restaints must be enforced). // #ifndef C_ASSERT -# define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] + #ifdef __LINUX__ + # define C_ASSERT(e) static_assert(e, "this is a nice message to explain the failure ;)") + #else + # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] + #endif #endif // -------------------------------------------------------------------------------------- diff --git a/common/include/Utilities/lnx_memzero.h b/common/include/Utilities/lnx_memzero.h index e787acea26..c7dba5a76b 100644 --- a/common/include/Utilities/lnx_memzero.h +++ b/common/include/Utilities/lnx_memzero.h @@ -51,8 +51,10 @@ static __fi void memset8( T& obj ) // Aligned sizes use the optimized 32 bit inline memset. Unaligned sizes use memset. if( (sizeof(T) & 0x3) != 0 ) memset( &obj, data, sizeof( T ) ); - else - memset32( obj ); + else { + const u32 data32 = data + (data<<8) + (data<<16) + (data<<24); + memset32( obj ); + } } template< u16 data, typename T > @@ -60,8 +62,10 @@ static __fi void memset16( T& obj ) { if( (sizeof(T) & 0x3) != 0 ) _memset16_unaligned( &obj, data, sizeof( T ) ); - else - memset32( obj ); + else { + const u32 data32 = data + (data<<16); + memset32( obj ); + } } @@ -92,6 +96,7 @@ static __fi void memset_8( void *dest ) // macro to execute the x86/32 "stosd" copies. switch( remdat ) { +#if 0 case 1: *(u32*)dest = data32; return; @@ -157,6 +162,7 @@ static __fi void memset_8( void *dest ) ); return; +#endif default: __asm__ volatile diff --git a/common/src/Utilities/Mutex.cpp b/common/src/Utilities/Mutex.cpp index 8ae6cd0e5f..73ef0a18bd 100644 --- a/common/src/Utilities/Mutex.cpp +++ b/common/src/Utilities/Mutex.cpp @@ -77,8 +77,8 @@ Threading::MutexRecursive::MutexRecursive() : Mutex( false ) pthread_mutexattr_settype( &_attr_recursive, PTHREAD_MUTEX_RECURSIVE ); } - int err = 0; - err = pthread_mutex_init( &m_mutex, &_attr_recursive ); + if (pthread_mutex_init( &m_mutex, &_attr_recursive )); + Console.Error( "(Thread Log) Failed to initialize mutex."); } Threading::MutexRecursive::~MutexRecursive() throw() From 4fdfd04d3c0d388f8904cfff5a55219531f2822e Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 12 Jul 2014 13:30:34 +0200 Subject: [PATCH 10/11] partially revert c5d2343f51a2e43a822e436fd0bda9f23db22ff9 Parameter name can help to understand the code so let's keep them. Clang warning was disabled in previous commit --- common/include/Utilities/Console.h | 36 ++++++++++----------- common/include/Utilities/PageFaultSource.h | 4 +-- common/include/Utilities/PersistentThread.h | 2 +- common/include/Utilities/TraceLog.h | 2 +- common/include/Utilities/wxGuiTools.h | 4 +-- pcsx2/Gif_Unit.h | 1 - pcsx2/IopBios.h | 6 ++-- pcsx2/System/SysThreads.h | 2 +- pcsx2/VUmicro.h | 8 ++--- 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/common/include/Utilities/Console.h b/common/include/Utilities/Console.h index 3a29fe3445..12a737c558 100644 --- a/common/include/Utilities/Console.h +++ b/common/include/Utilities/Console.h @@ -129,32 +129,32 @@ struct IConsoleWriter // struct NullConsoleWriter { - void WriteRaw( const wxString& ) {} - void DoWriteLn( const wxString& ) {} - void DoSetColor( ConsoleColors ) {} - void DoWriteFromStdout( const wxString& ) {} + void WriteRaw( const wxString& fmt ) {} + void DoWriteLn( const wxString& fmt ) {} + void DoSetColor( ConsoleColors color ) {} + void DoWriteFromStdout( const wxString& fmt ) {} void Newline() {} - void SetTitle( const wxString& ) {} + void SetTitle( const wxString& title ) {} ConsoleColors GetColor() const { return Color_Current; } - const NullConsoleWriter& SetColor( ConsoleColors ) const { return *this; } + const NullConsoleWriter& SetColor( ConsoleColors color ) const { return *this; } const NullConsoleWriter& ClearColor() const { return *this; } - const NullConsoleWriter& SetIndent( int =1 ) const { return *this; } + const NullConsoleWriter& SetIndent( int tabcount=1 ) const { return *this; } - NullConsoleWriter Indent( int =1 ) const { return NullConsoleWriter(); } + NullConsoleWriter Indent( int tabcount=1 ) const { return NullConsoleWriter(); } - bool FormatV( const char* , va_list ) const { return false; } - bool WriteLn( ConsoleColors , const char* , ... ) const { return false; } - bool WriteLn( const char* , ... ) const { return false; } - bool Error( const char* , ... ) const { return false; } - bool Warning( const char* , ... ) const { return false; } + bool FormatV( const char* fmt, va_list args ) const { return false; } + bool WriteLn( ConsoleColors color, const char* fmt, ... ) const { return false; } + bool WriteLn( const char* fmt, ... ) const { return false; } + bool Error( const char* fmt, ... ) const { return false; } + bool Warning( const char* fmt, ... ) const { return false; } - bool FormatV( const wxChar* , va_list ) const { return false; } - bool WriteLn( ConsoleColors , const wxChar* , ... ) const { return false; } - bool WriteLn( const wxChar* , ... ) const { return false; } - bool Error( const wxChar* , ... ) const { return false; } - bool Warning( const wxChar* , ... ) const { return false; } + bool FormatV( const wxChar* fmt, va_list args ) const { return false; } + bool WriteLn( ConsoleColors color, const wxChar* fmt, ... ) const { return false; } + bool WriteLn( const wxChar* fmt, ... ) const { return false; } + bool Error( const wxChar* fmt, ... ) const { return false; } + bool Warning( const wxChar* fmt, ... ) const { return false; } }; // -------------------------------------------------------------------------------------- diff --git a/common/include/Utilities/PageFaultSource.h b/common/include/Utilities/PageFaultSource.h index 3fab19a942..a4d971b010 100644 --- a/common/include/Utilities/PageFaultSource.h +++ b/common/include/Utilities/PageFaultSource.h @@ -52,12 +52,12 @@ public: OnPageFaultEvent( evtinfo, handled ); } - virtual void DispatchEvent( const PageFaultInfo& ) + virtual void DispatchEvent( const PageFaultInfo& evtinfo ) { pxFailRel( "Don't call me, damnit. Use DispatchException instead." ); } - virtual void OnPageFaultEvent( const PageFaultInfo& , bool& ) {} + virtual void OnPageFaultEvent( const PageFaultInfo& evtinfo, bool& handled ) {} }; // -------------------------------------------------------------------------------------- diff --git a/common/include/Utilities/PersistentThread.h b/common/include/Utilities/PersistentThread.h index c4de3dd4d4..7abc454549 100644 --- a/common/include/Utilities/PersistentThread.h +++ b/common/include/Utilities/PersistentThread.h @@ -44,7 +44,7 @@ namespace Threading void SetThread( pxThread& thr ) { m_thread = &thr; } void SetThread( pxThread* thr ) { m_thread = thr; } - void DispatchEvent( const int& ) + void DispatchEvent( const int& params ) { OnThreadCleanup(); } diff --git a/common/include/Utilities/TraceLog.h b/common/include/Utilities/TraceLog.h index cbdf963007..021be06e04 100644 --- a/common/include/Utilities/TraceLog.h +++ b/common/include/Utilities/TraceLog.h @@ -143,7 +143,7 @@ public: return false; } - virtual void ApplyPrefix( FastFormatAscii& ) const {} + virtual void ApplyPrefix( FastFormatAscii& ascii ) const {} virtual void DoWrite( const char* fmt ) const=0; }; diff --git a/common/include/Utilities/wxGuiTools.h b/common/include/Utilities/wxGuiTools.h index d1e7430b99..686630aeb3 100644 --- a/common/include/Utilities/wxGuiTools.h +++ b/common/include/Utilities/wxGuiTools.h @@ -438,7 +438,7 @@ public: // NOTE: Enabling system menu on dialogs usually doesn't work, and might cause // other unwanted behavior, such as a missing close button. - pxDialogCreationFlags SystemMenu( bool =true ) const + pxDialogCreationFlags SystemMenu( bool enable=true ) const { return pxDialogCreationFlags(*this).SetSystemMenu( false ); } @@ -648,7 +648,7 @@ public: protected: // line may be empty - virtual void OnOutputLine(const wxString&) { } + virtual void OnOutputLine(const wxString& line) { } // called at the start of every new line (except the very first one) virtual void OnNewLine() { } diff --git a/pcsx2/Gif_Unit.h b/pcsx2/Gif_Unit.h index 5f6664047b..f44c747ce0 100644 --- a/pcsx2/Gif_Unit.h +++ b/pcsx2/Gif_Unit.h @@ -648,7 +648,6 @@ struct Gif_Unit { } void PrintPathInfo(GIF_PATH path) { - (void)path; // avoid silly warning GUNIT_LOG("Gif Path %d - [hasData = %d][state = %d]", path, gifPath[path].hasDataRemaining(), gifPath[path].state); } diff --git a/pcsx2/IopBios.h b/pcsx2/IopBios.h index 7b97a8ecab..b8d3dece5e 100644 --- a/pcsx2/IopBios.h +++ b/pcsx2/IopBios.h @@ -42,9 +42,9 @@ public: virtual void close() = 0; - virtual int lseek(s32 , s32 ) { return -IOP_EIO; } - virtual int read(void *, u32 ) { return -IOP_EIO; } - virtual int write(void *, u32 ) { return -IOP_EIO; } + virtual int lseek(s32 offset, s32 whence) { return -IOP_EIO; } + virtual int read(void *buf, u32 count) { return -IOP_EIO; } + virtual int write(void *buf, u32 count) { return -IOP_EIO; } }; class IOManDir { diff --git a/pcsx2/System/SysThreads.h b/pcsx2/System/SysThreads.h index f786a5319f..853ad4d735 100644 --- a/pcsx2/System/SysThreads.h +++ b/pcsx2/System/SysThreads.h @@ -236,7 +236,7 @@ public: IEventListener_SysState() {} virtual ~IEventListener_SysState() throw() {} - virtual void DispatchEvent( const SysStateUnlockedParams& ) + virtual void DispatchEvent( const SysStateUnlockedParams& status ) { SysStateAction_OnUnlocked(); } diff --git a/pcsx2/VUmicro.h b/pcsx2/VUmicro.h index 5ddb7719b5..097231ab2c 100644 --- a/pcsx2/VUmicro.h +++ b/pcsx2/VUmicro.h @@ -177,10 +177,10 @@ public: void Step(); void Execute(u32 cycles); - void Clear(u32 , u32 ) {} + void Clear(u32 addr, u32 size) {} uint GetCacheReserve() const { return 0; } - void SetCacheReserve( uint ) const {} + void SetCacheReserve( uint reserveInMegs ) const {} }; class InterpVU1 : public BaseVUmicroCPU @@ -198,11 +198,11 @@ public: void Step(); void Execute(u32 cycles); - void Clear(u32 , u32 ) {} + void Clear(u32 addr, u32 size) {} void ResumeXGkick() {} uint GetCacheReserve() const { return 0; } - void SetCacheReserve( uint ) const {} + void SetCacheReserve( uint reserveInMegs ) const {} }; // -------------------------------------------------------------------------------------- From d4a76b979cfa9e0acac40cff8690bd948527d670 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 12 Jul 2014 13:33:24 +0200 Subject: [PATCH 11/11] ooups a very bad typo --- common/src/Utilities/Mutex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/Utilities/Mutex.cpp b/common/src/Utilities/Mutex.cpp index 73ef0a18bd..5356d11cb8 100644 --- a/common/src/Utilities/Mutex.cpp +++ b/common/src/Utilities/Mutex.cpp @@ -77,7 +77,7 @@ Threading::MutexRecursive::MutexRecursive() : Mutex( false ) pthread_mutexattr_settype( &_attr_recursive, PTHREAD_MUTEX_RECURSIVE ); } - if (pthread_mutex_init( &m_mutex, &_attr_recursive )); + if (pthread_mutex_init( &m_mutex, &_attr_recursive )) Console.Error( "(Thread Log) Failed to initialize mutex."); }