Serialize FS service; some compiler fixes

This commit is contained in:
Hamish Milne 2019-12-27 11:46:10 +00:00 committed by zhupengfei
parent d1096de245
commit 3ed8d95866
10 changed files with 62 additions and 45 deletions

View file

@ -22,7 +22,6 @@
#include "core/hle/kernel/server_session.h" #include "core/hle/kernel/server_session.h"
BOOST_SERIALIZATION_ASSUME_ABSTRACT(Kernel::SessionRequestHandler) BOOST_SERIALIZATION_ASSUME_ABSTRACT(Kernel::SessionRequestHandler)
BOOST_SERIALIZATION_ASSUME_ABSTRACT(Kernel::SessionRequestHandler::SessionDataBase)
namespace Service { namespace Service {
class ServiceFrameworkBase; class ServiceFrameworkBase;
@ -282,3 +281,5 @@ private:
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::SessionRequestHandler::SessionDataBase)

View file

@ -27,16 +27,7 @@
#include "core/hw/aes/ccm.h" #include "core/hw/aes/ccm.h"
#include "core/hw/aes/key.h" #include "core/hw/aes/key.h"
namespace boost::serialization { SERVICE_CONSTRUCT_IMPL(Service::APT::Module)
template <class Archive>
void load_construct_data(Archive& ar, Service::APT::Module* t, const unsigned int)
{
::new(t)Service::APT::Module(Core::Global<Core::System>());
}
template
void load_construct_data<iarchive>(iarchive& ar, Service::APT::Module* t, const unsigned int);
}
namespace Service::APT { namespace Service::APT {

View file

@ -9,17 +9,7 @@
#include "core/hle/result.h" #include "core/hle/result.h"
#include "core/hle/service/csnd/csnd_snd.h" #include "core/hle/service/csnd/csnd_snd.h"
namespace boost::serialization { SERVICE_CONSTRUCT_IMPL(Service::CSND::CSND_SND)
template <class Archive>
void load_construct_data(Archive& ar, Service::CSND::CSND_SND* t, const unsigned int)
{
::new(t)Service::CSND::CSND_SND(Core::Global<Core::System>());
}
template
void load_construct_data<iarchive>(iarchive& ar, Service::CSND::CSND_SND* t, const unsigned int);
}
SERIALIZE_EXPORT_IMPL(Service::CSND::CSND_SND) SERIALIZE_EXPORT_IMPL(Service::CSND::CSND_SND)
namespace Service::CSND { namespace Service::CSND {

View file

@ -260,6 +260,7 @@ private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) void serialize(Archive& ar, const unsigned int)
{ {
ar & boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar & mutex; ar & mutex;
ar & shared_memory; ar & shared_memory;
ar & capture_units; ar & capture_units;

View file

@ -15,17 +15,7 @@ using DspPipe = AudioCore::DspPipe;
using InterruptType = Service::DSP::DSP_DSP::InterruptType; using InterruptType = Service::DSP::DSP_DSP::InterruptType;
SERIALIZE_EXPORT_IMPL(Service::DSP::DSP_DSP) SERIALIZE_EXPORT_IMPL(Service::DSP::DSP_DSP)
SERVICE_CONSTRUCT_IMPL(Service::DSP::DSP_DSP)
namespace boost::serialization {
template <class Archive>
void load_construct_data(Archive& ar, Service::DSP::DSP_DSP* t, const unsigned int)
{
::new(t)Service::DSP::DSP_DSP(Core::Global<Core::System>());
}
template
void load_construct_data<iarchive>(iarchive& ar, Service::DSP::DSP_DSP* t, const unsigned int);
}
namespace AudioCore { namespace AudioCore {
enum class DspPipe; enum class DspPipe;

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cinttypes> #include <cinttypes>
#include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/file_util.h" #include "common/file_util.h"
@ -25,6 +26,10 @@
#include "core/hle/service/fs/fs_user.h" #include "core/hle/service/fs/fs_user.h"
#include "core/settings.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 // Namespace FS_User

View file

@ -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 // 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. // the same as codeset ID and fetch from there directly.
u64 program_id = 0; u64 program_id = 0;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int)
{
ar & program_id;
}
friend class boost::serialization::access;
}; };
class FS_USER final : public ServiceFramework<FS_USER, ClientSlot> { class FS_USER final : public ServiceFramework<FS_USER, ClientSlot> {
@ -545,8 +553,20 @@ private:
Core::System& system; Core::System& system;
ArchiveManager& archives; ArchiveManager& archives;
template <class Archive>
void serialize(Archive& ar, const unsigned int)
{
ar & boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar & priority;
}
friend class boost::serialization::access;
}; };
void InstallInterfaces(Core::System& system); void InstallInterfaces(Core::System& system);
} // namespace Service::FS } // namespace Service::FS
SERVICE_CONSTRUCT(Service::FS::FS_USER)
BOOST_CLASS_EXPORT_KEY(Service::FS::FS_USER)
BOOST_CLASS_EXPORT_KEY(Service::FS::ClientSlot)

View file

@ -220,4 +220,21 @@ extern const std::array<ServiceModuleInfo, 40> service_module_map;
ar & boost::serialization::base_object<Kernel::SessionRequestHandler>(*this); \ ar & boost::serialization::base_object<Kernel::SessionRequestHandler>(*this); \
} \ } \
friend class boost::serialization::access; \ friend class boost::serialization::access; \
friend class construct_access; friend class ::construct_access;
#define SERVICE_CONSTRUCT(T) \
namespace boost::serialization { \
template <class Archive> \
void load_construct_data(Archive& ar, T* t, const unsigned int); \
}
#define SERVICE_CONSTRUCT_IMPL(T) \
namespace boost::serialization { \
template <class Archive> \
void load_construct_data(Archive& ar, T* t, const unsigned int) \
{ \
::new(t)T(Core::Global<Core::System>()); \
} \
template \
void load_construct_data<iarchive>(iarchive& ar, T* t, const unsigned int); \
}

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
#include "common/archives.h"
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/ipc.h" #include "core/hle/ipc.h"
@ -14,6 +15,8 @@
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/server_session.h" #include "core/hle/kernel/server_session.h"
SERIALIZE_EXPORT_IMPL(Kernel::SessionRequestHandler::SessionDataBase)
namespace Kernel { namespace Kernel {
static std::shared_ptr<Object> MakeObject(Kernel::KernelSystem& kernel) { static std::shared_ptr<Object> MakeObject(Kernel::KernelSystem& kernel) {

View file

@ -18,18 +18,17 @@
// Boost::serialization doesn't like union types for some reason, // Boost::serialization doesn't like union types for some reason,
// so we need to mark arrays of union values with a special serialization method // so we need to mark arrays of union values with a special serialization method
template<typename Value, size_t Size> template<typename Value, size_t Size>
struct UnionArray : public std::array<Value, Size> { }; struct UnionArray : public std::array<Value, Size>
{
namespace boost::serialization { private:
template<class Archive>
template<class Archive, typename Value, size_t Size> void serialize(Archive& ar, const unsigned int)
void serialize(Archive& ar, UnionArray<Value, Size>& array, const unsigned int version)
{ {
static_assert(sizeof(Value) == sizeof(u32)); static_assert(sizeof(Value) == sizeof(u32));
ar & *static_cast<u32 (*)[Size]>(static_cast<void *>(array.data())); ar & *static_cast<u32 (*)[Size]>(static_cast<void *>(this->data()));
}
} }
friend class boost::serialization::access;
};
namespace Pica { namespace Pica {