From 3ed8d95866eeebc8edfe3d886b4e24f84148563d Mon Sep 17 00:00:00 2001 From: Hamish Milne Date: Fri, 27 Dec 2019 11:46:10 +0000 Subject: [PATCH] Serialize FS service; some compiler fixes --- src/core/hle/kernel/hle_ipc.h | 3 ++- src/core/hle/service/apt/apt.cpp | 11 +---------- src/core/hle/service/csnd/csnd_snd.cpp | 12 +----------- src/core/hle/service/csnd/csnd_snd.h | 1 + src/core/hle/service/dsp/dsp_dsp.cpp | 12 +----------- src/core/hle/service/fs/fs_user.cpp | 5 +++++ src/core/hle/service/fs/fs_user.h | 20 ++++++++++++++++++++ src/core/hle/service/service.h | 19 ++++++++++++++++++- src/tests/core/hle/kernel/hle_ipc.cpp | 3 +++ src/video_core/pica_state.h | 21 ++++++++++----------- 10 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index da89ad39a..162a2eb39 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -22,7 +22,6 @@ #include "core/hle/kernel/server_session.h" BOOST_SERIALIZATION_ASSUME_ABSTRACT(Kernel::SessionRequestHandler) -BOOST_SERIALIZATION_ASSUME_ABSTRACT(Kernel::SessionRequestHandler::SessionDataBase) namespace Service { class ServiceFrameworkBase; @@ -282,3 +281,5 @@ private: }; } // namespace Kernel + +BOOST_CLASS_EXPORT_KEY(Kernel::SessionRequestHandler::SessionDataBase) diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 8e02d2bd4..d5a7fb001 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -27,16 +27,7 @@ #include "core/hw/aes/ccm.h" #include "core/hw/aes/key.h" -namespace boost::serialization { - template - void load_construct_data(Archive& ar, Service::APT::Module* t, const unsigned int) - { - ::new(t)Service::APT::Module(Core::Global()); - } - - template - void load_construct_data(iarchive& ar, Service::APT::Module* t, const unsigned int); -} +SERVICE_CONSTRUCT_IMPL(Service::APT::Module) namespace Service::APT { diff --git a/src/core/hle/service/csnd/csnd_snd.cpp b/src/core/hle/service/csnd/csnd_snd.cpp index d011a1c66..1a7a00964 100644 --- a/src/core/hle/service/csnd/csnd_snd.cpp +++ b/src/core/hle/service/csnd/csnd_snd.cpp @@ -9,17 +9,7 @@ #include "core/hle/result.h" #include "core/hle/service/csnd/csnd_snd.h" -namespace boost::serialization { - template - void load_construct_data(Archive& ar, Service::CSND::CSND_SND* t, const unsigned int) - { - ::new(t)Service::CSND::CSND_SND(Core::Global()); - } - - template - void load_construct_data(iarchive& ar, Service::CSND::CSND_SND* t, const unsigned int); -} - +SERVICE_CONSTRUCT_IMPL(Service::CSND::CSND_SND) SERIALIZE_EXPORT_IMPL(Service::CSND::CSND_SND) namespace Service::CSND { diff --git a/src/core/hle/service/csnd/csnd_snd.h b/src/core/hle/service/csnd/csnd_snd.h index 0e2dd8cd8..44e4c030c 100644 --- a/src/core/hle/service/csnd/csnd_snd.h +++ b/src/core/hle/service/csnd/csnd_snd.h @@ -260,6 +260,7 @@ private: template void serialize(Archive& ar, const unsigned int) { + ar & boost::serialization::base_object(*this); ar & mutex; ar & shared_memory; ar & capture_units; diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index 519d39b0c..9b0ef8986 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -15,17 +15,7 @@ using DspPipe = AudioCore::DspPipe; using InterruptType = Service::DSP::DSP_DSP::InterruptType; SERIALIZE_EXPORT_IMPL(Service::DSP::DSP_DSP) - -namespace boost::serialization { - template - void load_construct_data(Archive& ar, Service::DSP::DSP_DSP* t, const unsigned int) - { - ::new(t)Service::DSP::DSP_DSP(Core::Global()); - } - - template - void load_construct_data(iarchive& ar, Service::DSP::DSP_DSP* t, const unsigned int); -} +SERVICE_CONSTRUCT_IMPL(Service::DSP::DSP_DSP) namespace AudioCore { enum class DspPipe; diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index bca8e77e5..e027e837f 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "common/archives.h" #include "common/assert.h" #include "common/common_types.h" #include "common/file_util.h" @@ -25,6 +26,10 @@ #include "core/hle/service/fs/fs_user.h" #include "core/settings.h" +SERVICE_CONSTRUCT_IMPL(Service::FS::FS_USER) +SERIALIZE_EXPORT_IMPL(Service::FS::FS_USER) +SERIALIZE_EXPORT_IMPL(Service::FS::ClientSlot) + //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace FS_User diff --git a/src/core/hle/service/fs/fs_user.h b/src/core/hle/service/fs/fs_user.h index 97b45714b..c001be0c5 100644 --- a/src/core/hle/service/fs/fs_user.h +++ b/src/core/hle/service/fs/fs_user.h @@ -22,6 +22,14 @@ struct ClientSlot : public Kernel::SessionRequestHandler::SessionDataBase { // behaviour is modified. Since we don't emulate fs:REG mechanism, we assume the program ID is // the same as codeset ID and fetch from there directly. u64 program_id = 0; + +private: + template + void serialize(Archive& ar, const unsigned int) + { + ar & program_id; + } + friend class boost::serialization::access; }; class FS_USER final : public ServiceFramework { @@ -545,8 +553,20 @@ private: Core::System& system; ArchiveManager& archives; + + template + void serialize(Archive& ar, const unsigned int) + { + ar & boost::serialization::base_object(*this); + ar & priority; + } + friend class boost::serialization::access; }; void InstallInterfaces(Core::System& system); } // namespace Service::FS + +SERVICE_CONSTRUCT(Service::FS::FS_USER) +BOOST_CLASS_EXPORT_KEY(Service::FS::FS_USER) +BOOST_CLASS_EXPORT_KEY(Service::FS::ClientSlot) diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index c0c48892a..4961678df 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -220,4 +220,21 @@ extern const std::array service_module_map; ar & boost::serialization::base_object(*this); \ } \ friend class boost::serialization::access; \ - friend class construct_access; + friend class ::construct_access; + +#define SERVICE_CONSTRUCT(T) \ +namespace boost::serialization { \ + template \ + void load_construct_data(Archive& ar, T* t, const unsigned int); \ +} + +#define SERVICE_CONSTRUCT_IMPL(T) \ +namespace boost::serialization { \ + template \ + void load_construct_data(Archive& ar, T* t, const unsigned int) \ + { \ + ::new(t)T(Core::Global()); \ + } \ + template \ + void load_construct_data(iarchive& ar, T* t, const unsigned int); \ +} \ No newline at end of file diff --git a/src/tests/core/hle/kernel/hle_ipc.cpp b/src/tests/core/hle/kernel/hle_ipc.cpp index fb549f829..e405f6729 100644 --- a/src/tests/core/hle/kernel/hle_ipc.cpp +++ b/src/tests/core/hle/kernel/hle_ipc.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "common/archives.h" #include "core/core.h" #include "core/core_timing.h" #include "core/hle/ipc.h" @@ -14,6 +15,8 @@ #include "core/hle/kernel/process.h" #include "core/hle/kernel/server_session.h" +SERIALIZE_EXPORT_IMPL(Kernel::SessionRequestHandler::SessionDataBase) + namespace Kernel { static std::shared_ptr MakeObject(Kernel::KernelSystem& kernel) { diff --git a/src/video_core/pica_state.h b/src/video_core/pica_state.h index 95ee77662..30cef3496 100644 --- a/src/video_core/pica_state.h +++ b/src/video_core/pica_state.h @@ -18,18 +18,17 @@ // Boost::serialization doesn't like union types for some reason, // so we need to mark arrays of union values with a special serialization method template -struct UnionArray : public std::array { }; - -namespace boost::serialization { - -template -void serialize(Archive& ar, UnionArray& array, const unsigned int version) +struct UnionArray : public std::array { - static_assert(sizeof(Value) == sizeof(u32)); - ar & *static_cast(static_cast(array.data())); -} - -} +private: + template + void serialize(Archive& ar, const unsigned int) + { + static_assert(sizeof(Value) == sizeof(u32)); + ar & *static_cast(static_cast(this->data())); + } + friend class boost::serialization::access; +}; namespace Pica {