From 623b0621ab52df03ebb993979c220550135a0213 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 1 May 2019 14:28:49 +0200 Subject: [PATCH] Port various minor changes from yuzu PRs (#4725) * common/thread: Remove unused functions Many of these functions are carried over from Dolphin (where they aren't used anymore). Given these have no use (and we really shouldn't be screwing around with OS-specific thread scheduler handling from the emulator, these can be removed. The function for setting the thread name is left, however, since it can have debugging utility usages. * input_common/sdl: Use a type alias to shorten declaration of GetPollers Just makes the definitions a little bit more tidy. * input_common/sdl: Correct return values within implementations of GetPollers() In both cases, we weren't actually returning anything, which is undefined behavior. * yuzu/debugger/graphics_surface: Fill in missing surface format listings Fills in the missing surface types that were marked as unknown. The order corresponds with the TextureFormat enum within video_core/texture.h. We also don't need to all of these strings as translatable (only the first string, as it's an English word). * yuzu/debugger/graphics_surface: Clean up connection overload deduction We can utilize qOverload with the signal connections to make the function deducing a little less ugly. * yuzu/debugger/graphics_surface: Tidy up SaveSurface - Use QStringLiteral where applicable. - Use const where applicable - Remove unnecessary precondition check (we already assert the pixbuf being non null) * yuzu/debugger/graphics_surface: Display error messages for file I/O errors * core: Add missing override specifiers where applicable Applies the override specifier where applicable. In the case of destructors that are defaulted in their definition, they can simply be removed. This also removes the unnecessary inclusions being done in audin_u and audrec_u, given their close proximity. * kernel/thread: Make parameter of GetWaitObjectIndex() const qualified The pointed to member is never actually modified, so it can be made const. * kernel/thread: Avoid sign conversion within GetCommandBufferAddress() Previously this was performing a u64 + int sign conversion. When dealing with addresses, we should generally be keeping the arithmetic in the same signedness type. This also gets rid of the static lifetime of the constant, as there's no need to make a trivial type like this potentially live for the entire duration of the program. * kernel/codeset: Make CodeSet's memory data member a regular std::vector The use of a shared_ptr is an implementation detail of the VMManager itself when mapping memory. Because of that, we shouldn't require all users of the CodeSet to have to allocate the shared_ptr ahead of time. It's intended that CodeSet simply pass in the required direct data, and that the memory manager takes care of it from that point on. This means we just do the shared pointer allocation in a single place, when loading modules, as opposed to in each loader. * kernel/wait_object: Make ShouldWait() take thread members by pointer-to-const Given this is intended as a querying function, it doesn't make sense to allow the implementer to modify the state of the given thread. --- .../debugger/graphics/graphics_surface.cpp | 122 ++++++++++-------- src/common/thread.cpp | 37 ------ src/common/thread.h | 4 - src/core/arm/dynarmic/arm_dynarmic.h | 2 +- src/core/arm/dyncom/arm_dyncom.h | 2 +- src/core/hle/kernel/event.cpp | 2 +- src/core/hle/kernel/event.h | 2 +- src/core/hle/kernel/mutex.cpp | 2 +- src/core/hle/kernel/mutex.h | 2 +- src/core/hle/kernel/process.cpp | 2 +- src/core/hle/kernel/process.h | 2 +- src/core/hle/kernel/semaphore.cpp | 2 +- src/core/hle/kernel/semaphore.h | 2 +- src/core/hle/kernel/server_port.cpp | 2 +- src/core/hle/kernel/server_port.h | 2 +- src/core/hle/kernel/server_session.cpp | 2 +- src/core/hle/kernel/server_session.h | 2 +- src/core/hle/kernel/thread.cpp | 12 +- src/core/hle/kernel/thread.h | 4 +- src/core/hle/kernel/timer.cpp | 2 +- src/core/hle/kernel/timer.h | 2 +- src/core/hle/kernel/wait_object.h | 2 +- src/core/hle/service/service.h | 2 +- src/core/loader/3dsx.cpp | 2 +- src/core/loader/elf.cpp | 2 +- src/core/loader/ncch.cpp | 2 +- src/input_common/main.cpp | 2 +- src/input_common/sdl/sdl.h | 14 +- src/input_common/sdl/sdl_impl.cpp | 8 +- src/input_common/sdl/sdl_impl.h | 6 +- 30 files changed, 114 insertions(+), 137 deletions(-) diff --git a/src/citra_qt/debugger/graphics/graphics_surface.cpp b/src/citra_qt/debugger/graphics/graphics_surface.cpp index c5932a71f..7cdf71b35 100644 --- a/src/citra_qt/debugger/graphics/graphics_surface.cpp +++ b/src/citra_qt/debugger/graphics/graphics_surface.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -81,28 +82,31 @@ GraphicsSurfaceWidget::GraphicsSurfaceWidget(std::shared_ptr surface_picker_y_control = new QSpinBox; surface_picker_y_control->setRange(0, max_dimension - 1); - surface_format_control = new QComboBox; - // Color formats sorted by Pica texture format index - surface_format_control->addItem("RGBA8"); - surface_format_control->addItem("RGB8"); - surface_format_control->addItem("RGB5A1"); - surface_format_control->addItem("RGB565"); - surface_format_control->addItem("RGBA4"); - surface_format_control->addItem("IA8"); - surface_format_control->addItem("RG8"); - surface_format_control->addItem("I8"); - surface_format_control->addItem("A8"); - surface_format_control->addItem("IA4"); - surface_format_control->addItem("I4"); - surface_format_control->addItem("A4"); - surface_format_control->addItem("ETC1"); - surface_format_control->addItem("ETC1A4"); - surface_format_control->addItem("D16"); - surface_format_control->addItem("D24"); - surface_format_control->addItem("D24X8"); - surface_format_control->addItem("X24S8"); - surface_format_control->addItem(tr("Unknown")); + const QStringList surface_formats{ + QStringLiteral("RGBA8"), + QStringLiteral("RGB8"), + QStringLiteral("RGB5A1"), + QStringLiteral("RGB565"), + QStringLiteral("RGBA4"), + QStringLiteral("IA8"), + QStringLiteral("RG8"), + QStringLiteral("I8"), + QStringLiteral("A8"), + QStringLiteral("IA4"), + QStringLiteral("I4"), + QStringLiteral("A4"), + QStringLiteral("ETC1"), + QStringLiteral("ETC1A4"), + QStringLiteral("D16"), + QStringLiteral("D24"), + QStringLiteral("D24X8"), + QStringLiteral("X24S8"), + tr("Unknown"), + }; + + surface_format_control = new QComboBox; + surface_format_control->addItems(surface_formats); surface_info_label = new QLabel(); surface_info_label->setWordWrap(true); @@ -121,22 +125,20 @@ GraphicsSurfaceWidget::GraphicsSurfaceWidget(std::shared_ptr // Connections connect(this, &GraphicsSurfaceWidget::Update, this, &GraphicsSurfaceWidget::OnUpdate); - connect(surface_source_list, - static_cast(&QComboBox::currentIndexChanged), this, + connect(surface_source_list, qOverload(&QComboBox::currentIndexChanged), this, &GraphicsSurfaceWidget::OnSurfaceSourceChanged); connect(surface_address_control, &CSpinBox::ValueChanged, this, &GraphicsSurfaceWidget::OnSurfaceAddressChanged); - connect(surface_width_control, static_cast(&QSpinBox::valueChanged), - this, &GraphicsSurfaceWidget::OnSurfaceWidthChanged); - connect(surface_height_control, static_cast(&QSpinBox::valueChanged), - this, &GraphicsSurfaceWidget::OnSurfaceHeightChanged); - connect(surface_format_control, - static_cast(&QComboBox::currentIndexChanged), this, + connect(surface_width_control, qOverload(&QSpinBox::valueChanged), this, + &GraphicsSurfaceWidget::OnSurfaceWidthChanged); + connect(surface_height_control, qOverload(&QSpinBox::valueChanged), this, + &GraphicsSurfaceWidget::OnSurfaceHeightChanged); + connect(surface_format_control, qOverload(&QComboBox::currentIndexChanged), this, &GraphicsSurfaceWidget::OnSurfaceFormatChanged); - connect(surface_picker_x_control, static_cast(&QSpinBox::valueChanged), - this, &GraphicsSurfaceWidget::OnSurfacePickerXChanged); - connect(surface_picker_y_control, static_cast(&QSpinBox::valueChanged), - this, &GraphicsSurfaceWidget::OnSurfacePickerYChanged); + connect(surface_picker_x_control, qOverload(&QSpinBox::valueChanged), this, + &GraphicsSurfaceWidget::OnSurfacePickerXChanged); + connect(surface_picker_y_control, qOverload(&QSpinBox::valueChanged), this, + &GraphicsSurfaceWidget::OnSurfacePickerYChanged); connect(save_surface, &QPushButton::clicked, this, &GraphicsSurfaceWidget::SaveSurface); auto main_widget = new QWidget; @@ -657,37 +659,53 @@ void GraphicsSurfaceWidget::OnUpdate() { } void GraphicsSurfaceWidget::SaveSurface() { - QString png_filter = tr("Portable Network Graphic (*.png)"); - QString bin_filter = tr("Binary data (*.bin)"); + const QString png_filter = tr("Portable Network Graphic (*.png)"); + const QString bin_filter = tr("Binary data (*.bin)"); - QString selectedFilter; - QString filename = QFileDialog::getSaveFileName( + QString selected_filter; + const QString filename = QFileDialog::getSaveFileName( this, tr("Save Surface"), - QString("texture-0x%1.png").arg(QString::number(surface_address, 16)), - QString("%1;;%2").arg(png_filter, bin_filter), &selectedFilter); + QStringLiteral("texture-0x%1.png").arg(QString::number(surface_address, 16)), + QStringLiteral("%1;;%2").arg(png_filter, bin_filter), &selected_filter); if (filename.isEmpty()) { // If the user canceled the dialog, don't save anything. return; } - if (selectedFilter == png_filter) { - const QPixmap* pixmap = surface_picture_label->pixmap(); + if (selected_filter == png_filter) { + const QPixmap* const pixmap = surface_picture_label->pixmap(); ASSERT_MSG(pixmap != nullptr, "No pixmap set"); - QFile file(filename); - file.open(QIODevice::WriteOnly); - if (pixmap) - pixmap->save(&file, "PNG"); - } else if (selectedFilter == bin_filter) { - const u8* buffer = Core::System::GetInstance().Memory().GetPhysicalPointer(surface_address); + QFile file{filename}; + if (!file.open(QIODevice::WriteOnly)) { + QMessageBox::warning(this, tr("Error"), tr("Failed to open file '%1'").arg(filename)); + return; + } + + if (!pixmap->save(&file, "PNG")) { + QMessageBox::warning(this, tr("Error"), + tr("Failed to save surface data to file '%1'").arg(filename)); + } + } else if (selected_filter == bin_filter) { + const u8* const buffer = + Core::System::GetInstance().Memory().GetPhysicalPointer(surface_address); ASSERT_MSG(buffer != nullptr, "Memory not accessible"); - QFile file(filename); - file.open(QIODevice::WriteOnly); - int size = surface_width * surface_height * NibblesPerPixel(surface_format) / 2; - QByteArray data(reinterpret_cast(buffer), size); - file.write(data); + QFile file{filename}; + if (!file.open(QIODevice::WriteOnly)) { + QMessageBox::warning(this, tr("Error"), tr("Failed to open file '%1'").arg(filename)); + return; + } + + const int size = surface_width * surface_height * NibblesPerPixel(surface_format) / 2; + const QByteArray data(reinterpret_cast(buffer), size); + if (file.write(data) != data.size()) { + QMessageBox::warning( + this, tr("Error"), + tr("Failed to completely write surface data to file. The saved data will " + "likely be corrupt.")); + } } else { UNREACHABLE_MSG("Unhandled filter selected"); } diff --git a/src/common/thread.cpp b/src/common/thread.cpp index 5144c0d9f..fe7a420cc 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -27,18 +27,6 @@ namespace Common { #ifdef _MSC_VER -void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { - SetThreadAffinityMask(thread, mask); -} - -void SetCurrentThreadAffinity(u32 mask) { - SetThreadAffinityMask(GetCurrentThread(), mask); -} - -void SwitchCurrentThread() { - SwitchToThread(); -} - // Sets the debugger-visible name of the current thread. // Uses undocumented (actually, it is now documented) trick. // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtsksettingthreadname.asp @@ -70,31 +58,6 @@ void SetCurrentThreadName(const char* name) { #else // !MSVC_VER, so must be POSIX threads -void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { -#ifdef __APPLE__ - thread_policy_set(pthread_mach_thread_np(thread), THREAD_AFFINITY_POLICY, (integer_t*)&mask, 1); -#elif (defined __linux__ || defined __FreeBSD__) && !(defined ANDROID) - cpu_set_t cpu_set; - CPU_ZERO(&cpu_set); - - for (int i = 0; i != sizeof(mask) * 8; ++i) - if ((mask >> i) & 1) - CPU_SET(i, &cpu_set); - - pthread_setaffinity_np(thread, sizeof(cpu_set), &cpu_set); -#endif -} - -void SetCurrentThreadAffinity(u32 mask) { - SetThreadAffinity(pthread_self(), mask); -} - -#ifndef _WIN32 -void SwitchCurrentThread() { - usleep(1000 * 1); -} -#endif - // MinGW with the POSIX threading model does not support pthread_setname_np #if !defined(_WIN32) || defined(_MSC_VER) void SetCurrentThreadName(const char* name) { diff --git a/src/common/thread.h b/src/common/thread.h index 20af70f4d..70dcf4601 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -9,7 +9,6 @@ #include #include #include -#include "common/common_types.h" namespace Common { @@ -92,9 +91,6 @@ private: std::size_t generation = 0; // Incremented once each time the barrier is used }; -void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask); -void SetCurrentThreadAffinity(u32 mask); -void SwitchCurrentThread(); // On Linux, this is equal to sleep 1ms void SetCurrentThreadName(const char* name); } // namespace Common diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index 537784e08..02467f879 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h @@ -25,7 +25,7 @@ class DynarmicUserCallbacks; class ARM_Dynarmic final : public ARM_Interface { public: ARM_Dynarmic(Core::System* system, Memory::MemorySystem& memory, PrivilegeMode initial_mode); - ~ARM_Dynarmic(); + ~ARM_Dynarmic() override; void Run() override; void Step() override; diff --git a/src/core/arm/dyncom/arm_dyncom.h b/src/core/arm/dyncom/arm_dyncom.h index 16c332d3b..2bb0212b3 100644 --- a/src/core/arm/dyncom/arm_dyncom.h +++ b/src/core/arm/dyncom/arm_dyncom.h @@ -22,7 +22,7 @@ class ARM_DynCom final : public ARM_Interface { public: explicit ARM_DynCom(Core::System* system, Memory::MemorySystem& memory, PrivilegeMode initial_mode); - ~ARM_DynCom(); + ~ARM_DynCom() override; void Run() override; void Step() override; diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index 403e26009..f31162e35 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp @@ -25,7 +25,7 @@ std::shared_ptr KernelSystem::CreateEvent(ResetType reset_type, std::stri return evt; } -bool Event::ShouldWait(Thread* thread) const { +bool Event::ShouldWait(const Thread* thread) const { return !signaled; } diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index d102f069a..efc4a0c28 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h @@ -34,7 +34,7 @@ public: return reset_type; } - bool ShouldWait(Thread* thread) const override; + bool ShouldWait(const Thread* thread) const override; void Acquire(Thread* thread) override; void WakeupAllWaitingThreads() override; diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 7c2c52c9f..ccc7cb221 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -41,7 +41,7 @@ std::shared_ptr KernelSystem::CreateMutex(bool initial_locked, std::strin return mutex; } -bool Mutex::ShouldWait(Thread* thread) const { +bool Mutex::ShouldWait(const Thread* thread) const { return lock_count > 0 && thread != holding_thread.get(); } diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 6ec401aca..1f6358909 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -43,7 +43,7 @@ public: */ void UpdatePriority(); - bool ShouldWait(Thread* thread) const override; + bool ShouldWait(const Thread* thread) const override; void Acquire(Thread* thread) override; void AddWaitingThread(std::shared_ptr thread) override; diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 6b1fabcbc..15d70db7c 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -120,7 +120,7 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) { auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions, MemoryState memory_state) { HeapAllocate(segment.addr, segment.size, permissions, memory_state, true); - kernel.memory.WriteBlock(*this, segment.addr, codeset->memory->data() + segment.offset, + kernel.memory.WriteBlock(*this, segment.addr, codeset->memory.data() + segment.offset, segment.size); }; diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 4c5dbe93d..dc2c878b8 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -97,7 +97,7 @@ public: return segments[2]; } - std::shared_ptr> memory; + std::vector memory; std::array segments; VAddr entrypoint; diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp index 04dd36923..bbc8a385f 100644 --- a/src/core/hle/kernel/semaphore.cpp +++ b/src/core/hle/kernel/semaphore.cpp @@ -31,7 +31,7 @@ ResultVal> KernelSystem::CreateSemaphore(s32 initial_ return MakeResult>(std::move(semaphore)); } -bool Semaphore::ShouldWait(Thread* thread) const { +bool Semaphore::ShouldWait(const Thread* thread) const { return available_count <= 0; } diff --git a/src/core/hle/kernel/semaphore.h b/src/core/hle/kernel/semaphore.h index 8c4d8e679..47b3eabf1 100644 --- a/src/core/hle/kernel/semaphore.h +++ b/src/core/hle/kernel/semaphore.h @@ -34,7 +34,7 @@ public: s32 available_count; ///< Number of free slots left in the semaphore std::string name; ///< Name of semaphore (optional) - bool ShouldWait(Thread* thread) const override; + bool ShouldWait(const Thread* thread) const override; void Acquire(Thread* thread) override; /** diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index 0e08b79e8..a69b42778 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp @@ -26,7 +26,7 @@ ResultVal> ServerPort::Accept() { return MakeResult(std::move(session)); } -bool ServerPort::ShouldWait(Thread* thread) const { +bool ServerPort::ShouldWait(const Thread* thread) const { // If there are no pending sessions, we wait until a new one is added. return pending_sessions.size() == 0; } diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index 8cc94d6ab..9b0f13480 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h @@ -58,7 +58,7 @@ public: /// ServerSessions created from this port inherit a reference to this handler. std::shared_ptr hle_handler; - bool ShouldWait(Thread* thread) const override; + bool ShouldWait(const Thread* thread) const override; void Acquire(Thread* thread) override; }; diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index c40ca2e6d..5855d83a5 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp @@ -38,7 +38,7 @@ ResultVal> ServerSession::Create(KernelSystem& ke return MakeResult(std::move(server_session)); } -bool ServerSession::ShouldWait(Thread* thread) const { +bool ServerSession::ShouldWait(const Thread* thread) const { // Closed sessions should never wait, an error will be returned from svcReplyAndReceive. if (parent->client == nullptr) return false; diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index 079dbd817..940f38f9b 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h @@ -68,7 +68,7 @@ public: */ ResultCode HandleSyncRequest(std::shared_ptr thread); - bool ShouldWait(Thread* thread) const override; + bool ShouldWait(const Thread* thread) const override; void Acquire(Thread* thread) override; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 819ccd53a..e3ee705c3 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -25,7 +25,7 @@ namespace Kernel { -bool Thread::ShouldWait(Thread* thread) const { +bool Thread::ShouldWait(const Thread* thread) const { return status != ThreadStatus::Dead; } @@ -450,17 +450,17 @@ void Thread::SetWaitSynchronizationOutput(s32 output) { context->SetCpuRegister(1, output); } -s32 Thread::GetWaitObjectIndex(WaitObject* object) const { +s32 Thread::GetWaitObjectIndex(const WaitObject* object) const { ASSERT_MSG(!wait_objects.empty(), "Thread is not waiting for anything"); - auto match = std::find_if(wait_objects.rbegin(), wait_objects.rend(), - [object](const auto& p) { return p.get() == object; }); + const auto match = std::find_if(wait_objects.rbegin(), wait_objects.rend(), + [object](const auto& p) { return p.get() == object; }); return static_cast(std::distance(match, wait_objects.rend()) - 1); } VAddr Thread::GetCommandBufferAddress() const { // Offset from the start of TLS at which the IPC command buffer begins. - static constexpr int CommandHeaderOffset = 0x80; - return GetTLSAddress() + CommandHeaderOffset; + constexpr u32 command_header_offset = 0x80; + return GetTLSAddress() + command_header_offset; } ThreadManager::ThreadManager(Kernel::KernelSystem& kernel) : kernel(kernel) { diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index ce69087c6..1f1fca939 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -165,7 +165,7 @@ public: return HANDLE_TYPE; } - bool ShouldWait(Thread* thread) const override; + bool ShouldWait(const Thread* thread) const override; void Acquire(Thread* thread) override; /** @@ -234,7 +234,7 @@ public: * object in the list. * @param object Object to query the index of. */ - s32 GetWaitObjectIndex(WaitObject* object) const; + s32 GetWaitObjectIndex(const WaitObject* object) const; /** * Stops a thread, invalidating it from further use diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index bac1ca848..9c3d0f725 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -35,7 +35,7 @@ std::shared_ptr KernelSystem::CreateTimer(ResetType reset_type, std::stri return timer; } -bool Timer::ShouldWait(Thread* thread) const { +bool Timer::ShouldWait(const Thread* thread) const { return !signaled; } diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index 21bab1c42..6865f5243 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h @@ -64,7 +64,7 @@ public: return interval_delay; } - bool ShouldWait(Thread* thread) const override; + bool ShouldWait(const Thread* thread) const override; void Acquire(Thread* thread) override; void WakeupAllWaitingThreads() override; diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/wait_object.h index cbfed01d2..220aeabf0 100644 --- a/src/core/hle/kernel/wait_object.h +++ b/src/core/hle/kernel/wait_object.h @@ -25,7 +25,7 @@ public: * @param thread The thread about which we're deciding. * @return True if the current thread should wait due to this object being unavailable */ - virtual bool ShouldWait(Thread* thread) const = 0; + virtual bool ShouldWait(const Thread* thread) const = 0; /// Acquire/lock the object for the specified thread if it is available virtual void Acquire(Thread* thread) = 0; diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 4aa60eb41..0e8d7222e 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -83,7 +83,7 @@ private: Kernel::HLERequestContext& ctx); ServiceFrameworkBase(const char* service_name, u32 max_sessions, InvokerFn* handler_invoker); - ~ServiceFrameworkBase(); + ~ServiceFrameworkBase() override; void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n); void ReportUnimplementedFunction(u32* cmd_buf, const FunctionInfoBase* info); diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index 20dbc276f..7629ad376 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp @@ -231,7 +231,7 @@ static THREEDSX_Error Load3DSXFile(FileUtil::IOFile& file, u32 base_addr, code_set->DataSegment().size = loadinfo.seg_sizes[2]; code_set->entrypoint = code_set->CodeSegment().addr; - code_set->memory = std::make_shared>(std::move(program_image)); + code_set->memory = std::move(program_image); LOG_DEBUG(Loader, "code size: {:#X}", loadinfo.seg_sizes[0]); LOG_DEBUG(Loader, "rodata size: {:#X}", loadinfo.seg_sizes[1]); diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index 417c309a2..d39181ebd 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp @@ -342,7 +342,7 @@ std::shared_ptr ElfReader::LoadInto(u32 vaddr) { } codeset->entrypoint = base_addr + header->e_entry; - codeset->memory = std::make_shared>(std::move(program_image)); + codeset->memory = std::move(program_image); LOG_DEBUG(Loader, "Done loading."); diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 21237d862..9ece9c69e 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -101,7 +101,7 @@ ResultStatus AppLoader_NCCH::LoadExec(std::shared_ptr& process) bss_page_size; codeset->entrypoint = codeset->CodeSegment().addr; - codeset->memory = std::make_shared>(std::move(code)); + codeset->memory = std::move(code); process = Core::System::GetInstance().Kernel().CreateProcess(std::move(codeset)); diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 5f62b3ef1..0beef8c48 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -85,7 +85,7 @@ std::vector> GetPollers(DeviceType type) { std::vector> pollers; #ifdef HAVE_SDL2 - sdl->GetPollers(type, pollers); + pollers = sdl->GetPollers(type); #endif return pollers; diff --git a/src/input_common/sdl/sdl.h b/src/input_common/sdl/sdl.h index 40d948261..d7f24c68a 100644 --- a/src/input_common/sdl/sdl.h +++ b/src/input_common/sdl/sdl.h @@ -24,19 +24,19 @@ namespace InputCommon::SDL { class State { public: - /// Unresisters SDL device factories and shut them down. + using Pollers = std::vector>; + + /// Unregisters SDL device factories and shut them down. virtual ~State() = default; - virtual void GetPollers( - InputCommon::Polling::DeviceType type, - std::vector>& pollers) = 0; + virtual Pollers GetPollers(Polling::DeviceType type) = 0; }; class NullState : public State { public: - void GetPollers( - InputCommon::Polling::DeviceType type, - std::vector>& pollers) override {} + Pollers GetPollers(Polling::DeviceType type) override { + return {}; + } }; std::unique_ptr Init(); diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index a474d27aa..5949ecbae 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -652,9 +652,9 @@ private: }; } // namespace Polling -void SDLState::GetPollers( - InputCommon::Polling::DeviceType type, - std::vector>& pollers) { +SDLState::Pollers SDLState::GetPollers(InputCommon::Polling::DeviceType type) { + Pollers pollers; + switch (type) { case InputCommon::Polling::DeviceType::Analog: pollers.emplace_back(std::make_unique(*this)); @@ -663,6 +663,8 @@ void SDLState::GetPollers( pollers.emplace_back(std::make_unique(*this)); break; } + + return pollers; } } // namespace SDL diff --git a/src/input_common/sdl/sdl_impl.h b/src/input_common/sdl/sdl_impl.h index 91b8d276c..2579741d6 100644 --- a/src/input_common/sdl/sdl_impl.h +++ b/src/input_common/sdl/sdl_impl.h @@ -25,7 +25,7 @@ public: /// Initializes and registers SDL device factories SDLState(); - /// Unresisters SDL device factories and shut them down. + /// Unregisters SDL device factories and shut them down. ~SDLState() override; /// Handle SDL_Events for joysticks from SDL_PollEvent @@ -35,9 +35,7 @@ public: std::shared_ptr GetSDLJoystickByGUID(const std::string& guid, int port); /// Get all DevicePoller that use the SDL backend for a specific device type - void GetPollers( - InputCommon::Polling::DeviceType type, - std::vector>& pollers) override; + Pollers GetPollers(Polling::DeviceType type) override; /// Used by the Pollers during config std::atomic polling = false;