From b24d4cce8d99dab50b301bb1ddff4779558d69a8 Mon Sep 17 00:00:00 2001 From: Forrest McDonald Date: Sat, 12 Jul 2014 09:52:27 -0700 Subject: [PATCH 01/10] Clang doesn't support some flags that GCC does, so conditionally check the compiler and add them if we are doing a GCC build --- common/src/Utilities/CMakeLists.txt | 8 +++++--- common/src/x86emitter/CMakeLists.txt | 8 +++++--- pcsx2/CMakeLists.txt | 11 +++++++---- plugins/GSdx/CMakeLists.txt | 6 +++++- plugins/zzogl-pg/opengl/CMakeLists.txt | 6 +++++- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/common/src/Utilities/CMakeLists.txt b/common/src/Utilities/CMakeLists.txt index c53539d04f..4bc3b7d0b4 100644 --- a/common/src/Utilities/CMakeLists.txt +++ b/common/src/Utilities/CMakeLists.txt @@ -11,10 +11,7 @@ set(Output Utilities) # set common flags set(CommonFlags - -fno-dse - -fno-guess-branch-probability -fno-strict-aliasing - -fno-tree-dse ) # set optimization flags @@ -58,6 +55,11 @@ set(OptimizationFlags -ftree-vrp -funit-at-a-time) +#Clang doesn't support a few common flags that GCC does. +if(NOT USE_CLANG) + add_definitions(${CommonFlags} -fno-guess-branch-probability -fno-dse -fno-tree-dse) +endif(NOT USE_CLANG) + # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) diff --git a/common/src/x86emitter/CMakeLists.txt b/common/src/x86emitter/CMakeLists.txt index 3bb115987d..cc7c6ae472 100644 --- a/common/src/x86emitter/CMakeLists.txt +++ b/common/src/x86emitter/CMakeLists.txt @@ -11,9 +11,6 @@ set(Output x86emitter) # set common flags set(CommonFlags - -fno-guess-branch-probability - -fno-dse - -fno-tree-dse -fno-strict-aliasing ) @@ -58,6 +55,11 @@ set(OptimizationFlags -ftree-vrp -funit-at-a-time) +#Clang doesn't support a few common flags that GCC does. +if(NOT USE_CLANG) + add_definitions(${CommonFlags} -fno-guess-branch-probability -fno-dse -fno-tree-dse) +endif(NOT USE_CLANG) + # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index da18c571ee..846092f4a9 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -12,14 +12,12 @@ set(CommonFlags # Disable this optimization for the moment -fno-omit-frame-pointer # END GCC-4.6 - -fno-guess-branch-probability - -fno-dse - -fno-tree-dse - -fno-strict-aliasing + -fno-strict-aliasing -Wno-parentheses -Wstrict-aliasing # Allow to track strict aliasing issue. -Wno-char-subscripts # only impact svu which is deprecated -Wno-missing-braces + -Wno-ignored-attributes ) # set optimization flags @@ -63,6 +61,11 @@ set(OptimizationFlags -ftree-vrp -funit-at-a-time) +#Clang doesn't support a few common flags that GCC does. +if(NOT USE_CLANG) + add_definitions(${CommonFlags} -fno-guess-branch-probability -fno-dse -fno-tree-dse) +endif(NOT USE_CLANG) + # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) set(Output pcsx2-dbg) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 57636731c4..1fe226758a 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -12,7 +12,6 @@ set(Output GSdx-0.1.16) set(CommonFlags -D_LINUX -fno-operator-names # because Xbyak uses and()/xor()/or()/not() function - -mpreferred-stack-boundary=2 -mfpmath=sse #-Wstrict-aliasing # Allow to track strict aliasing issue. -std=c++0x @@ -27,6 +26,11 @@ set(OptimizationFlags -DNDEBUG ) +#Clang doesn't support a few common flags that GCC does. +if(NOT USE_CLANG) + add_definitions(${CommonFlags} -mpreferred-stack-boundary=2) +endif(NOT USE_CLANG) + # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) add_definitions(${CommonFlags} -D_DEBUG -g -Wall) diff --git a/plugins/zzogl-pg/opengl/CMakeLists.txt b/plugins/zzogl-pg/opengl/CMakeLists.txt index 5e27853355..bfbd3e881e 100644 --- a/plugins/zzogl-pg/opengl/CMakeLists.txt +++ b/plugins/zzogl-pg/opengl/CMakeLists.txt @@ -16,7 +16,6 @@ set(Output zzogl-0.4.0) set(CommonFlags -pthread -DZEROGS_SSE2 - -fno-regmove -fno-strict-aliasing -Wstrict-aliasing # Allow to track strict aliasing issue. -Wunused-variable @@ -27,6 +26,11 @@ set(OptimizationFlags -DNDEBUG ) +#Clang doesn't support a few common flags that GCC does. +if(NOT USE_CLANG) + add_definitions(${CommonFlags} -fno-regmove) +endif(NOT USE_CLANG) + # Debug - Build if(CMAKE_BUILD_TYPE STREQUAL Debug) # add defines From f85a4c04671142ef4c1eadf098f8f7289eb3fb40 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Mon, 14 Jul 2014 13:58:06 +0200 Subject: [PATCH 02/10] clang: don't use clang asm tool -no-integrated-as fixes most of the asm issue :) --- cmake/BuildParameters.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 534d43d178..74b123dcf0 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -185,19 +185,20 @@ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") #------------------------------------------------------------------------------- # Set some default compiler flags #------------------------------------------------------------------------------- +set(COMMON_FLAG "-pipe -std=c++0x -fvisibility=hidden -pthread") +set(HARDENING_FLAG "-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security") # -Wno-attributes: "always_inline function might not be inlinable" <= real spam (thousand of warnings!!!) # -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 # -Wno-unused-variable: just annoying to manage different level of logging, a couple of extra var won't kill any serious compiler. -# -Wno-deprecated-register: glib issue... set(DEFAULT_WARNINGS "-Wall -Wno-attributes -Wstrict-aliasing -Wno-missing-field-initializers -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable") -if (USE_CLANG) - set(DEFAULT_WARNINGS "${DEFAULT_WARNINGS} -Wno-deprecated-register") -endif() -set(HARDENING_FLAG "-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security") -set(COMMON_FLAG "-pipe -std=c++0x -fvisibility=hidden -pthread") +if (USE_CLANG) + # -Wno-deprecated-register: glib issue... + set(DEFAULT_WARNINGS "${DEFAULT_WARNINGS} -Wno-deprecated-register") + set(COMMON_FLAG "${COMMON_FLAG} -no-integrated-as") +endif() if(CMAKE_BUILD_TYPE MATCHES "Debug|Devel") set(DEBUG_FLAG "-g") From 3d0094b6115e3212b9e69ea612a9f7290409cfb9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 14 Jul 2014 16:11:01 -0400 Subject: [PATCH 03/10] cdvdGigaherz: Fix some minor tab/space mismatches in TocStuff --- plugins/cdvdGigaherz/src/TocStuff.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/cdvdGigaherz/src/TocStuff.cpp b/plugins/cdvdGigaherz/src/TocStuff.cpp index 8d5ef96c52..746e6599dd 100644 --- a/plugins/cdvdGigaherz/src/TocStuff.cpp +++ b/plugins/cdvdGigaherz/src/TocStuff.cpp @@ -37,12 +37,12 @@ s32 cdvdParseTOC() return 0; } - s32 lastaddr = src->GetLayerBreakAddress(); + s32 lastaddr = src->GetLayerBreakAddress(); if(lastaddr>=0) { - if((lastaddr > 0)&&(tracks[0].length>lastaddr)) + if((lastaddr > 0)&&(tracks[0].length>lastaddr)) { tracks[1].length=lastaddr+1; tracks[1].type=0; @@ -54,14 +54,14 @@ s32 cdvdParseTOC() strack=1; etrack=2; } - else + else { tracks[1].length=tracks[0].length; tracks[1].type=0; strack=1; etrack=1; - } + } } else { From d648227e3df7ca71cd32a4acd06a7083ee9466ce Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 14 Jul 2014 16:11:51 -0400 Subject: [PATCH 04/10] cdvdGigaherz: Get rid of a magic constant in TocStuff --- plugins/cdvdGigaherz/src/TocStuff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cdvdGigaherz/src/TocStuff.cpp b/plugins/cdvdGigaherz/src/TocStuff.cpp index 746e6599dd..bd77d00810 100644 --- a/plugins/cdvdGigaherz/src/TocStuff.cpp +++ b/plugins/cdvdGigaherz/src/TocStuff.cpp @@ -136,7 +136,7 @@ s32 cdvdParseTOC() if((cdtoc.Descriptors[i].Control&4)==0) { - tracks[tn].type = 1; + tracks[tn].type = CDVD_AUDIO_TRACK; } else if((cdtoc.Descriptors[i].Control&0xE)==4) { From 7ec3cf46d62b45c7c64530e71d5b06d320dc3007 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 14 Jul 2014 20:26:38 -0400 Subject: [PATCH 05/10] SPU2-X: Fix float truncation warnings --- plugins/spu2-x/src/Timestretcher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/spu2-x/src/Timestretcher.cpp b/plugins/spu2-x/src/Timestretcher.cpp index 527aad6e1c..2b30c18103 100644 --- a/plugins/spu2-x/src/Timestretcher.cpp +++ b/plugins/spu2-x/src/Timestretcher.cpp @@ -189,9 +189,9 @@ void SndBuffer::UpdateTempoChangeSoundTouch2() #endif //Algorithm params: (threshold params (hysteresis), etc) - const float hys_ok_factor=1.04; + const float hys_ok_factor = 1.04f; + const float hys_bad_factor = 1.2f; int hys_min_ok_count = GetClamped((int)(50.0 *(float)targetIPS/750.0), 2, 100); //consecutive iterations within hys_ok before going to 1:1 mode - const float hys_bad_factor=1.2; int compensationDivider = GetClamped((int)(100.0 *(float)targetIPS/750), 15, 150); float tempoAdjust=bufferFullness/dynamicTargetFullness; From 69ecdd3236e1aafe125ffdfebcae017a8005928b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 14 Jul 2014 20:49:03 -0400 Subject: [PATCH 06/10] DEV9ghzdrk: Clarify precedence for a bitwise and in smap. --- plugins/dev9ghzdrk/Win32/smap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dev9ghzdrk/Win32/smap.cpp b/plugins/dev9ghzdrk/Win32/smap.cpp index 0d9bfe11d4..4120737e3e 100644 --- a/plugins/dev9ghzdrk/Win32/smap.cpp +++ b/plugins/dev9ghzdrk/Win32/smap.cpp @@ -252,7 +252,7 @@ void emac3_write(u32 addr) DEV9_LOG("SMAP: SMAP_R_EMAC3_TxMODE0_L write %x\n", value); //spams// emu_printf("SMAP: SMAP_R_EMAC3_TxMODE0_L write %x\n", value); //Process TX here ? - if (!value&SMAP_E3_TX_GNP_0) + if (!(value & SMAP_E3_TX_GNP_0)) emu_printf("SMAP_R_EMAC3_TxMODE0_L: SMAP_E3_TX_GNP_0 not set\n"); tx_process(); From 1fa95de554b35340816a18750be87eea993ca06d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 14 Jul 2014 22:58:49 -0400 Subject: [PATCH 07/10] cdvdGigaherz: Simplify the loops within readLine and readLineW --- plugins/cdvdGigaherz/src/FileStream.cpp | 34 ++++++++++--------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/plugins/cdvdGigaherz/src/FileStream.cpp b/plugins/cdvdGigaherz/src/FileStream.cpp index f8a21ca906..ddf3b196aa 100644 --- a/plugins/cdvdGigaherz/src/FileStream.cpp +++ b/plugins/cdvdGigaherz/src/FileStream.cpp @@ -98,20 +98,17 @@ int FileStream::read(byte* b, int len) string FileStream::readLine() { string s; - char c; s.clear(); - do { - if(eof()) + while (!eof()) + { + char c = read(); + + if ((c == '\n') || (c == '\r') || (c == '\0')) break; - c = read(); - - if((c=='\n')||(c=='\r')||(c==0)) - break; - - s.append(1,c); - } while(true); + s.append(1, c); + } return s; } @@ -119,20 +116,17 @@ string FileStream::readLine() wstring FileStream::readLineW() { wstring s; - wchar_t c; s.clear(); - do { - if(eof()) + while (!eof()) + { + wchar_t c = read(); + + if ((c == L'\n') || (c == L'\r') || (c == L'\0')) break; - c = read(); - - if((c==L'\n')||(c==L'\r')||(c==0)) - break; - - s.append(1,c); - } while(true); + s.append(1, c); + } return s; } From 55c8633f9ad1f16b6a6c2c62d5a551e6766b8b8c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 14 Jul 2014 23:24:12 -0400 Subject: [PATCH 08/10] dev9ghzdrk: Remove unreachable code. Same as what is in the default switch cases --- plugins/dev9ghzdrk/Win32/smap.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/plugins/dev9ghzdrk/Win32/smap.cpp b/plugins/dev9ghzdrk/Win32/smap.cpp index 0d9bfe11d4..11f6a2874b 100644 --- a/plugins/dev9ghzdrk/Win32/smap.cpp +++ b/plugins/dev9ghzdrk/Win32/smap.cpp @@ -486,10 +486,6 @@ u16 CALLBACK smap_read16(u32 addr) DEV9_LOG("SMAP : Unknown 16 bit read @ %X,v=%X\n",addr,dev9Ru16(addr)); return dev9Ru16(addr); } - - DEV9_LOG("SMAP : error , 16 bit read @ %X,v=%X\n",addr,dev9Ru16(addr)); - return dev9Ru16(addr); - } u32 CALLBACK smap_read32(u32 addr) { @@ -529,9 +525,6 @@ u32 CALLBACK smap_read32(u32 addr) DEV9_LOG("SMAP : Unknown 32 bit read @ %X,v=%X\n",addr,dev9Ru32(addr)); return dev9Ru32(addr); } - - DEV9_LOG("SMAP : error , 32 bit read @ %X,v=%X\n",addr,dev9Ru32(addr)); - return dev9Ru32(addr); } void CALLBACK smap_write8(u32 addr, u8 value) { @@ -599,9 +592,6 @@ void CALLBACK smap_write8(u32 addr, u8 value) dev9Ru8(addr) = value; return; } - - DEV9_LOG("SMAP : error , 8 bit write @ %X,v=%X\n",addr,value); - dev9Ru8(addr) = value; } void CALLBACK smap_write16(u32 addr, u16 value) { @@ -782,9 +772,6 @@ void CALLBACK smap_write16(u32 addr, u16 value) dev9Ru16(addr) = value; return; } - - DEV9_LOG("SMAP : error , 16 bit write @ %X,v=%X\n",addr,value); - dev9Ru16(addr) = value; } void CALLBACK smap_write32(u32 addr, u32 value) { @@ -809,9 +796,6 @@ void CALLBACK smap_write32(u32 addr, u32 value) dev9Ru32(addr) = value; return; } - - DEV9_LOG("SMAP : error , 32 bit write @ %X,v=%X\n",addr,value); - dev9Ru32(addr) = value; } void CALLBACK smap_readDMA8Mem(u32 *pMem, int size) { From b5f805fc6c4851910b809a3ff80e94201f14097b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 14 Jul 2014 23:39:07 -0400 Subject: [PATCH 09/10] dev9ghzdrk: Fix a few warnings. Mostly unsigned mismatches. --- plugins/dev9ghzdrk/Win32/Win32.cpp | 2 +- plugins/dev9ghzdrk/Win32/smap.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/dev9ghzdrk/Win32/Win32.cpp b/plugins/dev9ghzdrk/Win32/Win32.cpp index 5436ced59b..ff77cf47ae 100644 --- a/plugins/dev9ghzdrk/Win32/Win32.cpp +++ b/plugins/dev9ghzdrk/Win32/Win32.cpp @@ -60,7 +60,7 @@ void OnInitDialog(HWND hW) { } } vector * al=GetTapAdapters(); - for (int i=0; isize(); i++) { + for (size_t i=0; isize(); i++) { int itm=ComboBox_AddString(GetDlgItem(hW, IDC_ETHDEV), al[0][i].name.c_str()); ComboBox_SetItemData(GetDlgItem(hW, IDC_ETHDEV),itm,strdup( al[0][i].guid.c_str())); diff --git a/plugins/dev9ghzdrk/Win32/smap.cpp b/plugins/dev9ghzdrk/Win32/smap.cpp index 0d9bfe11d4..61509bd7bd 100644 --- a/plugins/dev9ghzdrk/Win32/smap.cpp +++ b/plugins/dev9ghzdrk/Win32/smap.cpp @@ -131,10 +131,10 @@ void tx_process() { //we loop based on count ? or just *use* it ? u32 cnt=dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT); - //spams// printf("tx_process : %d cnt frames !\n",cnt); + //spams// printf("tx_process : %u cnt frames !\n",cnt); NetPacket pk; - int fc=0; + u32 fc=0; for (fc=0;fclength&3) { - //spams// emu_printf("WARN : pbd->length not alligned %d\n",pbd->length); + //spams// emu_printf("WARN : pbd->length not aligned %u\n",pbd->length); } if(pbd->length>1514) @@ -157,13 +157,13 @@ void tx_process() { u32 base=(pbd->pointer-0x1000)&16383; DEV9_LOG("Sending Packet from base %x, size %d\n", base, pbd->length); - //spams// emu_printf("Sending Packet from base %x, size %d\n", base, pbd->length); + //spams// emu_printf("Sending Packet from base %x, size %u\n", base, pbd->length); pk.size=pbd->length; if (!(pbd->pointer>=0x1000)) { - emu_printf("ERROR: odd , !pbd->pointer>0x1000 | 0x%X %d\n", pbd->pointer, pbd->length); + emu_printf("ERROR: odd , !pbd->pointer>0x1000 | 0x%X %u\n", pbd->pointer, pbd->length); } //increase fifo pointer(s) //uh does that even exist on real h/w ? @@ -205,7 +205,7 @@ void tx_process() u32 was=16384-base; memcpy(pk.buffer,dev9.txfifo+base,was); memcpy(pk.buffer,dev9.txfifo,pbd->length-was); - printf("Warped read, was=%d, sz=%d, sz-was=%d\n",was,pbd->length,pbd->length-was); + printf("Warped read, was=%u, sz=%u, sz-was=%u\n", was, pbd->length, pbd->length-was); } else { @@ -225,7 +225,7 @@ void tx_process() dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT)--; } - //spams// emu_printf("processed %d frames, %d count, cnt = %d\n",fc,dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT),cnt); + //spams// emu_printf("processed %u frames, %u count, cnt = %u\n",fc,dev9Ru8(SMAP_R_TXFIFO_FRAME_CNT),cnt); //if some error/early exit signal TXDNV if (fc!=cnt || cnt==0) { From 0a825a1aa483a901eab4f5735f577979f84fb0ab Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 15 Jul 2014 00:09:48 -0400 Subject: [PATCH 10/10] SPU2-X: Fix some signed/unsigned mismatch warnings. --- plugins/spu2-x/src/Mixer.cpp | 4 ++-- plugins/spu2-x/src/Reverb.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index 2ad77d762f..64c47bd44c 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -116,7 +116,7 @@ static void __forceinline IncrementNextA(V_Core& thiscore, uint voiceidx) // Important! Both cores signal IRQ when an address is read, regardless of // which core actually reads the address. - for( uint i=0; i<2; i++ ) + for( int i=0; i<2; i++ ) { if( Cores[i].IRQEnable && (vc.NextA==Cores[i].IRQA ) ) { @@ -522,7 +522,7 @@ static __forceinline s32 GetNoiseValues( V_Core& thiscore, uint voiceidx ) static __forceinline void spu2M_WriteFast( u32 addr, s16 value ) { // Fixes some of the oldest hangs in pcsx2's history! :p - for( uint i=0; i<2; i++ ) + for( int i=0; i<2; i++ ) { if( Cores[i].IRQEnable && Cores[i].IRQA == addr ) { diff --git a/plugins/spu2-x/src/Reverb.cpp b/plugins/spu2-x/src/Reverb.cpp index 0e985587d0..a56bf2de07 100644 --- a/plugins/spu2-x/src/Reverb.cpp +++ b/plugins/spu2-x/src/Reverb.cpp @@ -140,7 +140,7 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input ) // within that zone then the "bulk" of the test is skipped, so this should only // be a slowdown on a few evil games. - for( uint i=0; i<2; i++ ) + for( int i=0; i<2; i++ ) { if( Cores[i].IRQEnable && ((Cores[i].IRQA >= EffectsStartA) && (Cores[i].IRQA <= EffectsEndA)) ) {