From d051bd303225838e0e50a3e3ddc22337c1fc0f0c Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sun, 27 Mar 2016 11:59:50 +0800 Subject: [PATCH 1/9] CMakeLists: Use CMAKE_THREAD_LIBS_INIT --- CMakeLists.txt | 6 ++++-- src/citra/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a0a161e7..ddde19760 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,8 +65,8 @@ endif() message(STATUS "Target architecture: ${ARCHITECTURE}") if (NOT MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wno-attributes -pthread") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wno-attributes") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") if (ARCHITECTURE_x86_64) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1") @@ -135,6 +135,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules") find_package(OpenGL REQUIRED) include_directories(${OPENGL_INCLUDE_DIR}) +find_package(Threads REQUIRED) + if (ENABLE_SDL2) if (CITRA_USE_BUNDLED_SDL2) # Detect toolchain and platform diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index fa615deb9..351752c1c 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(citra ${SDL2_LIBRARY} ${OPENGL_gl_LIBRARY} inih glad) if (MSVC) target_link_libraries(citra getopt) endif() -target_link_libraries(citra ${PLATFORM_LIBRARIES}) +target_link_libraries(citra ${PLATFORM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|OpenBSD|NetBSD") install(TARGETS citra RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") From aacc3a4a59a9a66c3768c8cbba0ab4c03a4e5920 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sun, 27 Mar 2016 12:01:29 +0800 Subject: [PATCH 2/9] microprofile: Use std::abs Using the global-namespace C function will cause the wrong overload to get picked --- externals/microprofile/microprofileui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/microprofile/microprofileui.h b/externals/microprofile/microprofileui.h index eac1119a4..cc12739cb 100644 --- a/externals/microprofile/microprofileui.h +++ b/externals/microprofile/microprofileui.h @@ -879,7 +879,7 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY, static int64_t nRefCpu = 0, nRefGpu = 0; if(MicroProfileGetGpuTickReference(&nTickReferenceCpu, &nTickReferenceGpu)) { - if(0 == nRefCpu || abs(nRefCpu-nBaseTicksCpu) > abs(nTickReferenceCpu-nBaseTicksCpu)) + if(0 == nRefCpu || std::abs(nRefCpu-nBaseTicksCpu) > std::abs(nTickReferenceCpu-nBaseTicksCpu)) { nRefCpu = nTickReferenceCpu; nRefGpu = nTickReferenceGpu; From fdd7e9e86aba614b20d1773112c43c094f668803 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sun, 27 Mar 2016 12:01:57 +0800 Subject: [PATCH 3/9] microprofileui: Use correct printf specifier --- externals/microprofile/microprofileui.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/externals/microprofile/microprofileui.h b/externals/microprofile/microprofileui.h index cc12739cb..45bec8af6 100644 --- a/externals/microprofile/microprofileui.h +++ b/externals/microprofile/microprofileui.h @@ -1230,7 +1230,12 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY, char ThreadName[MicroProfileThreadLog::THREAD_MAX_LEN + 16]; const char* cLocal = MicroProfileIsLocalThread(nThreadId) ? "*": " "; +#if defined(WIN32) + // nThreadId is 32-bit on Windows int nStrLen = snprintf(ThreadName, sizeof(ThreadName)-1, "%04x: %s%s", nThreadId, cLocal, i < nNumThreadsBase ? &S.Pool[i]->ThreadName[0] : MICROPROFILE_THREAD_NAME_FROM_ID(nThreadId) ); +#else + int nStrLen = snprintf(ThreadName, sizeof(ThreadName)-1, "%04llx: %s%s", nThreadId, cLocal, i < nNumThreadsBase ? &S.Pool[i]->ThreadName[0] : MICROPROFILE_THREAD_NAME_FROM_ID(nThreadId) ); +#endif uint32_t nThreadColor = -1; if(nThreadId == nContextSwitchHoverThreadAfter || nThreadId == nContextSwitchHoverThreadBefore) nThreadColor = UI.nHoverColorShared|0x906060; From 2850a223592edad677e2fcd31a5f53b057c4ecc8 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sun, 27 Mar 2016 12:02:22 +0800 Subject: [PATCH 4/9] debugger: Warn if we reach an unreachable format --- src/citra_qt/debugger/graphics_framebuffer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp index c30e75933..68cff78b2 100644 --- a/src/citra_qt/debugger/graphics_framebuffer.cpp +++ b/src/citra_qt/debugger/graphics_framebuffer.cpp @@ -346,5 +346,11 @@ u32 GraphicsFramebufferWidget::BytesPerPixel(GraphicsFramebufferWidget::Format f case Format::RGBA4: case Format::D16: return 2; + default: + UNREACHABLE_MSG("GraphicsFramebufferWidget::BytesPerPixel: this " + "should not be reached as this function should " + "be given a format which is in " + "GraphicsFramebufferWidget::Format. Instead got %i", + static_cast(format)); } } From 41ec40e9aa2e8445ac73f90f9784c4130b977dae Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sun, 27 Mar 2016 12:03:19 +0800 Subject: [PATCH 5/9] gdbstub: Don't check if unsigned int is > 0 --- src/core/gdbstub/gdbstub.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index c1a7ec5bf..ae0c116ef 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -529,7 +529,7 @@ static void ReadRegister() { id |= HexCharToValue(command_buffer[2]); } - if (id >= R0_REGISTER && id <= R15_REGISTER) { + if (id <= R15_REGISTER) { IntToGdbHex(reply, Core::g_app_core->GetReg(id)); } else if (id == CPSR_REGISTER) { IntToGdbHex(reply, Core::g_app_core->GetCPSR()); @@ -584,7 +584,7 @@ static void WriteRegister() { id |= HexCharToValue(command_buffer[2]); } - if (id >= R0_REGISTER && id <= R15_REGISTER) { + if (id <= R15_REGISTER) { Core::g_app_core->SetReg(id, GdbHexToInt(buffer_ptr)); } else if (id == CPSR_REGISTER) { Core::g_app_core->SetCPSR(GdbHexToInt(buffer_ptr)); From 040b7386a92fcadc5c4b08643299567de876c4d6 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sun, 27 Mar 2016 12:03:44 +0800 Subject: [PATCH 6/9] fs: Fix what appears to be a typo (filename_size / file_size) --- src/core/hle/service/fs/fs_user.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 3ec7ceb30..7df7da5a4 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -250,7 +250,7 @@ static void CreateFile(Service::Interface* self) { FileSys::Path file_path(filename_type, filename_size, filename_ptr); - LOG_DEBUG(Service_FS, "type=%d size=%llu data=%s", filename_type, filename_size, file_path.DebugStr().c_str()); + LOG_DEBUG(Service_FS, "type=%d size=%llu data=%s", filename_type, file_size, file_path.DebugStr().c_str()); cmd_buff[1] = CreateFileInArchive(archive_handle, file_path, file_size).raw; } From 60f2587eaca6d9e3d73f5361b37b67dcd4a2a72d Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sun, 27 Mar 2016 12:04:01 +0800 Subject: [PATCH 7/9] ncch: Use correct format specifier (for long long uint) --- src/core/loader/ncch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index a4b47ef8c..066e91a9e 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -255,7 +255,7 @@ ResultStatus AppLoader_NCCH::Load() { resource_limit_category = exheader_header.arm11_system_local_caps.resource_limit_category; LOG_INFO(Loader, "Name: %s" , exheader_header.codeset_info.name); - LOG_INFO(Loader, "Program ID: %016X" , ncch_header.program_id); + LOG_INFO(Loader, "Program ID: %016llX" , ncch_header.program_id); LOG_DEBUG(Loader, "Code compressed: %s" , is_compressed ? "yes" : "no"); LOG_DEBUG(Loader, "Entry point: 0x%08X", entry_point); LOG_DEBUG(Loader, "Code size: 0x%08X", code_size); From 39d4994c15c46aeef0b3643e6db8b1f735674a7a Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sun, 27 Mar 2016 12:04:16 +0800 Subject: [PATCH 8/9] pica: Handle default lighting case --- src/video_core/pica.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 1810eca98..cf130d7f8 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h @@ -747,8 +747,13 @@ struct Regs { case LightingSampler::ReflectGreen: case LightingSampler::ReflectBlue: return (config == LightingConfig::Config4) || (config == LightingConfig::Config5) || (config == LightingConfig::Config7); + default: + UNREACHABLE_MSG("Regs::IsLightingSamplerSupported: Reached " + "unreachable section, sampler should be one " + "of Distribution0, Distribution1, Fresnel, " + "ReflectRed, ReflectGreen or ReflectBlue, instead " + "got %i", static_cast(config)); } - return false; } struct { From 205e8f9f9ece7ee335a1987aa4a1b72f7409abd5 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Mon, 11 Apr 2016 07:22:41 +0800 Subject: [PATCH 9/9] assert: Add _MSG variations for UNREACHABLE and UNIMPLEMENTED --- src/common/assert.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/assert.h b/src/common/assert.h index 6849778b7..d7f19f5eb 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -39,6 +39,7 @@ static void assert_noinline_call(const Fn& fn) { }); } while (0) #define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!") +#define UNREACHABLE_MSG(_a_, ...) ASSERT_MSG(false, _a_, __VA_ARGS__) #ifdef _DEBUG #define DEBUG_ASSERT(_a_) ASSERT(_a_) @@ -49,3 +50,4 @@ static void assert_noinline_call(const Fn& fn) { #endif #define UNIMPLEMENTED() DEBUG_ASSERT_MSG(false, "Unimplemented code!") +#define UNIMPLEMENTED_MSG(_a_, ...) ASSERT_MSG(false, _a_, __VA_ARGS__) \ No newline at end of file