From 92640fc29c6fee66b6c110ce7631f8e5b3e74e72 Mon Sep 17 00:00:00 2001 From: Hamish Milne Date: Tue, 31 Mar 2020 17:54:28 +0100 Subject: [PATCH] Code review actions (plus hopefully fix the linux CI) --- src/CMakeLists.txt | 17 +++++------- src/audio_core/hle/hle.cpp | 1 + src/common/archives.h | 4 +-- src/common/memory_ref.h | 6 ++++- src/common/serialization/atomic.h | 4 +++ .../serialization/boost_discrete_interval.hpp | 22 ++++++++------- src/common/serialization/boost_flat_set.h | 4 +++ .../serialization/boost_interval_set.hpp | 20 ++++++++++++++ src/common/thread_queue_list.h | 4 +-- src/core/arm/arm_interface.h | 27 +++++++++---------- src/core/arm/dynarmic/arm_dynarmic.h | 4 ++- src/core/arm/dyncom/arm_dyncom.h | 4 ++- src/core/core.cpp | 19 +++++-------- src/core/core.h | 1 - src/core/core_timing.cpp | 5 ++-- src/core/hle/kernel/address_arbiter.h | 1 + src/core/hle/kernel/client_port.h | 2 ++ src/core/hle/kernel/client_session.h | 1 + src/core/hle/kernel/event.h | 2 ++ src/core/hle/kernel/kernel.cpp | 3 +++ src/core/hle/kernel/kernel.h | 3 --- src/core/hle/kernel/memory.h | 6 ++--- src/core/hle/kernel/mutex.h | 3 +++ src/core/hle/kernel/object.h | 2 +- src/core/hle/kernel/resource_limit.h | 2 ++ src/core/hle/kernel/semaphore.h | 2 ++ src/core/hle/kernel/server_port.cpp | 4 +++ src/core/hle/kernel/server_port.h | 3 --- src/core/hle/kernel/server_session.cpp | 16 ++++++++++- src/core/hle/kernel/server_session.h | 12 +-------- src/core/hle/kernel/session.cpp | 1 - src/core/hle/kernel/shared_memory.cpp | 1 - src/core/hle/kernel/shared_memory.h | 4 ++- src/core/hle/kernel/shared_page.h | 1 + src/core/hle/kernel/thread.cpp | 2 +- src/core/hle/kernel/timer.cpp | 1 - src/core/hle/kernel/timer.h | 1 + src/core/hle/kernel/vm_manager.h | 1 + src/core/hle/kernel/wait_object.cpp | 10 +++++++ src/core/hle/kernel/wait_object.h | 7 +---- src/core/hle/service/hid/hid.cpp | 8 ------ src/core/hle/service/ir/extra_hid.h | 4 ++- src/core/memory.cpp | 4 +-- src/core/memory.h | 13 +++++---- src/video_core/geometry_pipeline.cpp | 1 - src/video_core/pica_state.h | 1 + 46 files changed, 155 insertions(+), 109 deletions(-) create mode 100644 src/common/serialization/boost_interval_set.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 96c7f35cd..1ada1b3eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,8 +31,10 @@ if (MSVC) # /Zc:externConstexpr - Allow extern constexpr variables to have external linkage, like the standard mandates # /Zc:inline - Let codegen omit inline functions in object files # /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null + # /external:* - Suppress warnings from external headers add_compile_options( /W3 + /MP /Zi /Zo /permissive- @@ -40,17 +42,12 @@ if (MSVC) /volatile:iso /Zc:externConstexpr /Zc:inline + /Zc:throwingNew + /experimental:external + /external:I "${CMAKE_SOURCE_DIR}/externals" + /external:anglebrackets + /external:W0 ) - if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - add_compile_options( - /MP - /Zc:throwingNew - /experimental:external - /external:I "${CMAKE_SOURCE_DIR}/externals" - /external:anglebrackets - /external:W0 - ) - endif() # /GS- - No stack buffer overflow checks add_compile_options("$<$:/GS->") diff --git a/src/audio_core/hle/hle.cpp b/src/audio_core/hle/hle.cpp index f4e372f85..3a761dcfa 100644 --- a/src/audio_core/hle/hle.cpp +++ b/src/audio_core/hle/hle.cpp @@ -45,6 +45,7 @@ void DspHle::serialize(Archive& ar, const unsigned int) { ar& boost::serialization::base_object(*this); ar&* impl.get(); } +SERIALIZE_IMPL(DspHle) static constexpr u64 audio_frame_ticks = 1310252ull; ///< Units: ARM11 cycles diff --git a/src/common/archives.h b/src/common/archives.h index 4f8b735d3..b9f4330bd 100644 --- a/src/common/archives.h +++ b/src/common/archives.h @@ -5,8 +5,8 @@ #pragma once #include -#include "boost/archive/binary_oarchive.hpp" -#include "boost/serialization/export.hpp" +#include +#include using iarchive = boost::archive::binary_iarchive; using oarchive = boost::archive::binary_oarchive; diff --git a/src/common/memory_ref.h b/src/common/memory_ref.h index 30eabbaee..0a50c7be9 100644 --- a/src/common/memory_ref.h +++ b/src/common/memory_ref.h @@ -41,13 +41,17 @@ public: } std::size_t GetSize() const override { - return static_cast(data.size()); + return data.size(); } std::vector& Vector() { return data; } + const std::vector& Vector() const { + return data; + } + private: std::vector data; diff --git a/src/common/serialization/atomic.h b/src/common/serialization/atomic.h index dbc4c0dec..0cf0f20bc 100644 --- a/src/common/serialization/atomic.h +++ b/src/common/serialization/atomic.h @@ -1,3 +1,7 @@ +// Copyright 2020 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + #pragma once #include diff --git a/src/common/serialization/boost_discrete_interval.hpp b/src/common/serialization/boost_discrete_interval.hpp index dc920e439..961a9a7ef 100644 --- a/src/common/serialization/boost_discrete_interval.hpp +++ b/src/common/serialization/boost_discrete_interval.hpp @@ -1,33 +1,37 @@ +// Copyright 2020 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + #pragma once -#include "common/common_types.h" #include +#include "common/common_types.h" namespace boost::serialization { template -void save(Archive& ar, const boost::icl::discrete_interval& obj, const unsigned int file_version) -{ +void save(Archive& ar, const boost::icl::discrete_interval& obj, + const unsigned int file_version) { ar << obj.lower(); ar << obj.upper(); ar << obj.bounds()._bits; } template -void load(Archive& ar, boost::icl::discrete_interval& obj, const unsigned int file_version) -{ +void load(Archive& ar, boost::icl::discrete_interval& obj, + const unsigned int file_version) { DomainT upper, lower; boost::icl::bound_type bounds; - ar >> upper; ar >> lower; + ar >> upper; ar >> bounds; obj = boost::icl::discrete_interval(upper, lower, boost::icl::interval_bounds(bounds)); } template -void serialize(Archive& ar, boost::icl::discrete_interval& obj, const unsigned int file_version) -{ +void serialize(Archive& ar, boost::icl::discrete_interval& obj, + const unsigned int file_version) { boost::serialization::split_free(ar, obj, file_version); } -} +} // namespace boost::serialization diff --git a/src/common/serialization/boost_flat_set.h b/src/common/serialization/boost_flat_set.h index c47e8c1a7..703bd28b3 100644 --- a/src/common/serialization/boost_flat_set.h +++ b/src/common/serialization/boost_flat_set.h @@ -1,3 +1,7 @@ +// Copyright 2020 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + #pragma once #include diff --git a/src/common/serialization/boost_interval_set.hpp b/src/common/serialization/boost_interval_set.hpp new file mode 100644 index 000000000..08e6a14f1 --- /dev/null +++ b/src/common/serialization/boost_interval_set.hpp @@ -0,0 +1,20 @@ +// Copyright 2020 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include "common/serialization/boost_discrete_interval.hpp" + +namespace boost::serialization { + +template +void serialize(Archive& ar, boost::icl::interval_set& obj, const unsigned int file_version) { + using IntervalSet = boost::icl::interval_set; + // This works because interval_set has exactly one member of type ImplSetT + static_assert(std::is_standard_layout_v); + ar&*(reinterpret_cast(&obj)); +} + +} // namespace boost::serialization diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h index 1ba68e1e4..af40bf09b 100644 --- a/src/common/thread_queue_list.h +++ b/src/common/thread_queue_list.h @@ -186,7 +186,7 @@ private: void save(Archive& ar, const unsigned int file_version) const { const s64 idx = ToIndex(first); ar << idx; - for (size_t i = 0; i < NUM_QUEUES; i++) { + for (std::size_t i = 0; i < NUM_QUEUES; i++) { const s64 idx1 = ToIndex(queues[i].next_nonempty); ar << idx1; ar << queues[i].data; @@ -198,7 +198,7 @@ private: s64 idx; ar >> idx; first = ToPointer(idx); - for (auto i = 0; i < NUM_QUEUES; i++) { + for (std::size_t i = 0; i < NUM_QUEUES; i++) { ar >> idx; queues[i].next_nonempty = ToPointer(idx); ar >> queues[i].data; diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index fca488586..a6b8a279a 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -6,15 +6,13 @@ #include #include +#include #include #include "common/common_types.h" #include "core/arm/skyeye_common/arm_regformat.h" #include "core/arm/skyeye_common/vfp/asm_vfp.h" #include "core/core_timing.h" - -namespace Memory { -struct PageTable; -} +#include "core/memory.h" /// Generic ARM11 CPU interface class ARM_Interface : NonCopyable { @@ -28,11 +26,11 @@ public: template void save(Archive& ar, const unsigned int file_version) const { - for (size_t i = 0; i < 16; i++) { + for (std::size_t i = 0; i < 16; i++) { const auto r = GetCpuRegister(i); ar << r; } - for (size_t i = 0; i < 16; i++) { + for (std::size_t i = 0; i < 16; i++) { const auto r = GetFpuRegister(i); ar << r; } @@ -47,11 +45,11 @@ public: template void load(Archive& ar, const unsigned int file_version) { u32 r; - for (size_t i = 0; i < 16; i++) { + for (std::size_t i = 0; i < 16; i++) { ar >> r; SetCpuRegister(i, r); } - for (size_t i = 0; i < 16; i++) { + for (std::size_t i = 0; i < 16; i++) { ar >> r; SetFpuRegister(i, r); } @@ -120,8 +118,6 @@ public: /// Notify CPU emulation that page tables have changed virtual void SetPageTable(const std::shared_ptr& page_table) = 0; - virtual std::shared_ptr GetPageTable() const = 0; - /** * Set the Program Counter to an address * @param addr Address to set PC to @@ -234,6 +230,9 @@ public: } protected: + // This us used for serialization. Returning nullptr is valid if page tables are not used. + virtual std::shared_ptr GetPageTable() const = 0; + std::shared_ptr timer; private: @@ -259,11 +258,11 @@ private: const auto r = GetVFPReg(i); ar << r; } - for (size_t i = 0; i < VFPSystemRegister::VFP_SYSTEM_REGISTER_COUNT; i++) { + for (std::size_t i = 0; i < VFPSystemRegister::VFP_SYSTEM_REGISTER_COUNT; i++) { const auto r = GetVFPSystemReg(static_cast(i)); ar << r; } - for (size_t i = 0; i < CP15Register::CP15_REGISTER_COUNT; i++) { + for (std::size_t i = 0; i < CP15Register::CP15_REGISTER_COUNT; i++) { const auto r = GetCP15Register(static_cast(i)); ar << r; } @@ -290,11 +289,11 @@ private: ar >> r; SetVFPReg(i, r); } - for (size_t i = 0; i < VFPSystemRegister::VFP_SYSTEM_REGISTER_COUNT; i++) { + for (std::size_t i = 0; i < VFPSystemRegister::VFP_SYSTEM_REGISTER_COUNT; i++) { ar >> r; SetVFPSystemReg(static_cast(i), r); } - for (size_t i = 0; i < CP15Register::CP15_REGISTER_COUNT; i++) { + for (std::size_t i = 0; i < CP15Register::CP15_REGISTER_COUNT; i++) { ar >> r; SetCP15Register(static_cast(i), r); } diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index a8f224083..a5b4893a6 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h @@ -53,9 +53,11 @@ public: void ClearInstructionCache() override; void InvalidateCacheRange(u32 start_address, std::size_t length) override; void SetPageTable(const std::shared_ptr& page_table) override; - std::shared_ptr GetPageTable() const override; void PurgeState() override; +protected: + std::shared_ptr GetPageTable() const override; + private: friend class DynarmicUserCallbacks; Core::System& system; diff --git a/src/core/arm/dyncom/arm_dyncom.h b/src/core/arm/dyncom/arm_dyncom.h index 91cbcded0..1452216c2 100644 --- a/src/core/arm/dyncom/arm_dyncom.h +++ b/src/core/arm/dyncom/arm_dyncom.h @@ -49,10 +49,12 @@ public: void LoadContext(const std::unique_ptr& arg) override; void SetPageTable(const std::shared_ptr& page_table) override; - std::shared_ptr GetPageTable() const override; void PrepareReschedule() override; void PurgeState() override; +protected: + std::shared_ptr GetPageTable() const override; + private: void ExecuteInstructions(u64 num_instructions); diff --git a/src/core/core.cpp b/src/core/core.cpp index 2928d50e7..69223a05e 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -1,4 +1,3 @@ -#pragma optimize("", off) // Copyright 2014 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -184,12 +183,14 @@ System::ResultStatus System::RunLoop(bool tight_loop) { LOG_INFO(Core, "Begin load"); System::LoadState(param); LOG_INFO(Core, "Load completed"); - } break; + break; + } case Signal::Save: { LOG_INFO(Core, "Begin save"); System::SaveState(param); LOG_INFO(Core, "Save completed"); - } break; + break; + } default: break; } @@ -551,19 +552,11 @@ void System::serialize(Archive& ar, const unsigned int file_version) { // NOTE: DSP doesn't like being destroyed and recreated. So instead we do an inline // serialization; this means that the DSP Settings need to match for loading to work. - bool dsp_type = Settings::values.enable_dsp_lle; - ar& dsp_type; - if (dsp_type != Settings::values.enable_dsp_lle) { - throw std::runtime_error( - "Incorrect DSP type - please change this in Settings before loading"); - } auto dsp_hle = dynamic_cast(dsp_core.get()); if (dsp_hle) { ar&* dsp_hle; - } - auto dsp_lle = dynamic_cast(dsp_core.get()); - if (dsp_lle) { - ar&* dsp_lle; + } else { + throw std::runtime_error("LLE audio not supported for save states"); } ar&* memory.get(); diff --git a/src/core/core.h b/src/core/core.h index 66e880fd1..dfb6aee3e 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -7,7 +7,6 @@ #include #include #include -#include "boost/serialization/access.hpp" #include "common/common_types.h" #include "core/custom_tex_cache.h" #include "core/frontend/applets/mii_selector.h" diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 493bb6344..963926596 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -183,11 +183,10 @@ void Timing::Timer::Advance(s64 max_slice_length) { Event evt = std::move(event_queue.front()); std::pop_heap(event_queue.begin(), event_queue.end(), std::greater<>()); event_queue.pop_back(); - if (evt.type->callback == nullptr) { - LOG_ERROR(Core, "Event '{}' has no callback", *evt.type->name); - } if (evt.type->callback != nullptr) { evt.type->callback(evt.userdata, executed_ticks - evt.time); + } else { + LOG_ERROR(Core, "Event '{}' has no callback", *evt.type->name); } } diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h index 85a2a065a..059ff1400 100644 --- a/src/core/hle/kernel/address_arbiter.h +++ b/src/core/hle/kernel/address_arbiter.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "common/common_types.h" #include "core/hle/kernel/object.h" diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index 1d0f5c024..8d0f50520 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/server_port.h" diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 38f39c299..1943db8e6 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/result.h" diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index 892718533..02eabd750 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h @@ -4,7 +4,9 @@ #pragma once +#include #include +#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/wait_object.h" diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index f0974f88a..ef9856363 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include +#include #include "common/archives.h" #include "common/serialization/atomic.h" #include "core/hle/kernel/client_port.h" diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 828843afc..f0a8368d9 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -11,9 +11,6 @@ #include #include #include -#include -#include -#include #include "common/common_types.h" #include "core/hle/kernel/memory.h" #include "core/hle/result.h" diff --git a/src/core/hle/kernel/memory.h b/src/core/hle/kernel/memory.h index f4b0a6d98..0560b0bec 100644 --- a/src/core/hle/kernel/memory.h +++ b/src/core/hle/kernel/memory.h @@ -5,10 +5,11 @@ #pragma once #include +#include #include #include #include "common/common_types.h" -#include "common/serialization/boost_discrete_interval.hpp" +#include "common/serialization/boost_interval_set.hpp" namespace Kernel { @@ -70,8 +71,7 @@ private: ar& base; ar& size; ar& used; - // This works because interval_set has exactly one member of type ImplSetT - ar&*(reinterpret_cast(&free_blocks)); + ar& free_blocks; } }; diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 4adf674c3..73ee2a0e6 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include #include "common/common_types.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/wait_object.h" diff --git a/src/core/hle/kernel/object.h b/src/core/hle/kernel/object.h index 57b208dc1..b272366d7 100644 --- a/src/core/hle/kernel/object.h +++ b/src/core/hle/kernel/object.h @@ -104,7 +104,7 @@ BOOST_SERIALIZATION_ASSUME_ABSTRACT(Kernel::Object) #define CONSTRUCT_KERNEL_OBJECT(T) \ namespace boost::serialization { \ template \ - inline void load_construct_data(Archive& ar, T* t, const unsigned int file_version) { \ + void load_construct_data(Archive& ar, T* t, const unsigned int file_version) { \ ::new (t) T(Core::Global()); \ } \ } diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h index 8593a03a3..cb1c8c78e 100644 --- a/src/core/hle/kernel/resource_limit.h +++ b/src/core/hle/kernel/resource_limit.h @@ -7,7 +7,9 @@ #include #include #include +#include #include +#include #include "common/common_types.h" #include "core/hle/kernel/object.h" diff --git a/src/core/hle/kernel/semaphore.h b/src/core/hle/kernel/semaphore.h index a7ab192a6..b9863a838 100644 --- a/src/core/hle/kernel/semaphore.h +++ b/src/core/hle/kernel/semaphore.h @@ -5,7 +5,9 @@ #pragma once #include +#include #include +#include #include #include "common/common_types.h" #include "core/hle/kernel/object.h" diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index 077150222..4d293be34 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp @@ -3,6 +3,10 @@ // Refer to the license.txt file included. #include +#include +#include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "core/hle/kernel/client_port.h" diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index 2f00e586e..00eb10100 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h @@ -7,10 +7,7 @@ #include #include #include -#include #include -#include -#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/server_session.h" diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 3dc20e9a7..61ade5b70 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp @@ -3,8 +3,10 @@ // Refer to the license.txt file included. #include +#include +#include +#include #include "common/archives.h" -#include "core/global.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" #include "core/hle/kernel/hle_ipc.h" @@ -16,6 +18,18 @@ SERIALIZE_EXPORT_IMPL(Kernel::ServerSession) namespace Kernel { +template +void ServerSession::serialize(Archive& ar, const unsigned int file_version) { + ar& boost::serialization::base_object(*this); + ar& name; + ar& parent; + ar& hle_handler; + ar& pending_requesting_threads; + ar& currently_handling; + ar& mapped_buffer_context; +} +SERIALIZE_IMPL(ServerSession) + ServerSession::ServerSession(KernelSystem& kernel) : WaitObject(kernel), kernel(kernel) {} ServerSession::~ServerSession() { // This destructor will be called automatically when the last ServerSession handle is closed by diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index 74dbef624..b91accce5 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include "common/assert.h" #include "common/common_types.h" #include "core/hle/kernel/ipc.h" @@ -110,15 +108,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& name; - ar& parent; - ar& hle_handler; - ar& pending_requesting_threads; - ar& currently_handling; - ar& mapped_buffer_context; - } + void serialize(Archive& ar, const unsigned int file_version); }; } // namespace Kernel diff --git a/src/core/hle/kernel/session.cpp b/src/core/hle/kernel/session.cpp index 1ec1039dc..8bb846c52 100644 --- a/src/core/hle/kernel/session.cpp +++ b/src/core/hle/kernel/session.cpp @@ -6,7 +6,6 @@ #include "common/archives.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/server_session.h" #include "core/hle/kernel/session.h" diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 47c966fec..e8f792ee8 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -5,7 +5,6 @@ #include #include "common/archives.h" #include "common/logging/log.h" -#include "core/global.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/memory.h" #include "core/hle/kernel/shared_memory.h" diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index cb2dee685..0e500a1dd 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h @@ -6,7 +6,9 @@ #include #include +#include #include +#include #include "common/common_types.h" #include "common/memory_ref.h" #include "core/hle/kernel/object.h" @@ -118,7 +120,7 @@ private: ar& owner_process; ar& base_address; ar& name; - ar&*(reinterpret_cast(&holding_memory)); + ar& holding_memory; } friend class boost::serialization::access; }; diff --git a/src/core/hle/kernel/shared_page.h b/src/core/hle/kernel/shared_page.h index c4b174db4..9cd579d52 100644 --- a/src/core/hle/kernel/shared_page.h +++ b/src/core/hle/kernel/shared_page.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include "common/bit_field.h" diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 0567ef325..cdd908b4e 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "common/archives.h" #include "common/assert.h" #include "common/common_types.h" @@ -15,7 +16,6 @@ #include "core/arm/arm_interface.h" #include "core/arm/skyeye_common/armstate.h" #include "core/core.h" -#include "core/global.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index d29b25986..d2a12ade1 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -8,7 +8,6 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/core.h" -#include "core/global.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/thread.h" diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index b591c1b03..d5af5e654 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include "common/common_types.h" #include "core/core_timing.h" diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 3ca46d069..06fbb8672 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "common/common_types.h" #include "common/memory_ref.h" diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index 6fe75b6d8..2cd4331c5 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp @@ -4,6 +4,7 @@ #include #include +#include "common/archives.h" #include "common/assert.h" #include "common/logging/log.h" #include "core/hle/kernel/errors.h" @@ -16,6 +17,15 @@ namespace Kernel { +template +void WaitObject::serialize(Archive& ar, const unsigned int file_version) { + ar& boost::serialization::base_object(*this); + ar& waiting_threads; + // NB: hle_notifier *not* serialized since it's a callback! + // Fortunately it's only used in one place (DSP) so we can reconstruct it there +} +SERIALIZE_IMPL(WaitObject) + void WaitObject::AddWaitingThread(std::shared_ptr thread) { auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); if (itr == waiting_threads.end()) diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/wait_object.h index c07290e8a..7f73eab9f 100644 --- a/src/core/hle/kernel/wait_object.h +++ b/src/core/hle/kernel/wait_object.h @@ -69,12 +69,7 @@ private: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& waiting_threads; - // NB: hle_notifier *not* serialized since it's a callback! - // Fortunately it's only used in one place (DSP) so we can reconstruct it there - } + void serialize(Archive& ar, const unsigned int file_version); }; // Specialization of DynamicObjectCast for WaitObjects diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 845319f62..981a4aa63 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -210,10 +210,6 @@ void Module::UpdateAccelerometerCallback(u64 userdata, s64 cycles_late) { next_accelerometer_index = (next_accelerometer_index + 1) % mem->accelerometer.entries.size(); Common::Vec3 accel; - if (!motion_device) { - is_device_reload_pending.store(true); - return; - } std::tie(accel, std::ignore) = motion_device->GetStatus(); accel *= accelerometer_coef; // TODO(wwylele): do a time stretch like the one in UpdateGyroscopeCallback @@ -261,10 +257,6 @@ void Module::UpdateGyroscopeCallback(u64 userdata, s64 cycles_late) { GyroscopeDataEntry& gyroscope_entry = mem->gyroscope.entries[mem->gyroscope.index]; Common::Vec3 gyro; - if (!motion_device) { - is_device_reload_pending.store(true); - return; - } std::tie(std::ignore, gyro) = motion_device->GetStatus(); double stretch = system.perf_stats->GetLastFrameTimeScale(); gyro *= gyroscope_coef * static_cast(stretch); diff --git a/src/core/hle/service/ir/extra_hid.h b/src/core/hle/service/ir/extra_hid.h index 46c0fdca4..4b27fba9b 100644 --- a/src/core/hle/service/ir/extra_hid.h +++ b/src/core/hle/service/ir/extra_hid.h @@ -71,7 +71,9 @@ private: void serialize(Archive& ar, const unsigned int) { ar& hid_period; ar& calibration_data; // This isn't writeable for now, but might be in future - RequestInputDevicesReload(); // zl, zr, c_stick are loaded here + if (Archive::is_loading::value) { + LoadInputDevices(); // zl, zr, c_stick are loaded here + } } friend class boost::serialization::access; }; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index c0c030de1..184b7f9bd 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -4,9 +4,9 @@ #include #include +#include +#include #include "audio_core/dsp_interface.h" -#include "boost/serialization/array.hpp" -#include "boost/serialization/binary_object.hpp" #include "common/archives.h" #include "common/assert.h" #include "common/common_types.h" diff --git a/src/core/memory.h b/src/core/memory.h index eb5b6d69c..66b28d87d 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include "common/common_types.h" @@ -86,12 +85,12 @@ struct PageTable { struct Entry { Entry(Pointers& pointers_, VAddr idx_) : pointers(pointers_), idx(idx_) {} - inline void operator=(MemoryRef value) { + void operator=(MemoryRef value) { pointers.refs[idx] = value; pointers.raw[idx] = value.GetPtr(); } - inline operator u8*() { + operator u8*() { return pointers.raw[idx]; } @@ -100,15 +99,15 @@ struct PageTable { VAddr idx; }; - inline Entry operator[](VAddr idx) { + Entry operator[](VAddr idx) { return Entry(*this, idx); } - inline u8* operator[](VAddr idx) const { + u8* operator[](VAddr idx) const { return raw[idx]; } - inline Entry operator[](std::size_t idx) { + Entry operator[](std::size_t idx) { return Entry(*this, static_cast(idx)); } @@ -133,7 +132,7 @@ struct PageTable { */ std::array attributes; - inline std::array& GetPointerArray() { + std::array& GetPointerArray() { return pointers.raw; } diff --git a/src/video_core/geometry_pipeline.cpp b/src/video_core/geometry_pipeline.cpp index 7e002d55d..0ddbda943 100644 --- a/src/video_core/geometry_pipeline.cpp +++ b/src/video_core/geometry_pipeline.cpp @@ -385,7 +385,6 @@ void GeometryPipeline::serialize(Archive& ar, const unsigned int version) { } // namespace Pica -BOOST_SERIALIZATION_ASSUME_ABSTRACT(Pica::GeometryPipelineBackend) SERIALIZE_EXPORT_IMPL(Pica::GeometryPipeline_Point) SERIALIZE_EXPORT_IMPL(Pica::GeometryPipeline_VariablePrimitive) SERIALIZE_EXPORT_IMPL(Pica::GeometryPipeline_FixedPrimitive) diff --git a/src/video_core/pica_state.h b/src/video_core/pica_state.h index 3a9ec79c5..3c29ff84e 100644 --- a/src/video_core/pica_state.h +++ b/src/video_core/pica_state.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include "common/bit_field.h" #include "common/common_types.h"