diff options
| author | 2019-03-08 16:35:57 -0500 | |
|---|---|---|
| committer | 2019-03-08 16:35:57 -0500 | |
| commit | 9909d40530d74bd57bd2f2450e72530843fbc124 (patch) | |
| tree | e1b4b674ca19cb51fc41272321b77f20a32ef364 | |
| parent | Merge pull request #2209 from lioncash/reorder (diff) | |
| parent | kernel/hle_ipc: Convert std::shared_ptr IPC header instances to std::optional (diff) | |
| download | yuzu-9909d40530d74bd57bd2f2450e72530843fbc124.tar.gz yuzu-9909d40530d74bd57bd2f2450e72530843fbc124.tar.xz yuzu-9909d40530d74bd57bd2f2450e72530843fbc124.zip | |
Merge pull request #2210 from lioncash/optional
kernel/hle_ipc: Convert std::shared_ptr IPC header instances to std::optional
Diffstat (limited to '')
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rwxr-xr-x | .travis/macos/build.sh | 2 | ||||
| -rw-r--r-- | src/common/bit_field.h | 16 | ||||
| -rw-r--r-- | src/core/hle/ipc_helpers.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 15 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.cpp | 63 |
7 files changed, 56 insertions, 58 deletions
diff --git a/.travis.yml b/.travis.yml index b0fbe3c5f..9512f7843 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -24,7 +24,7 @@ matrix: | |||
| 24 | - os: osx | 24 | - os: osx |
| 25 | env: NAME="macos build" | 25 | env: NAME="macos build" |
| 26 | sudo: false | 26 | sudo: false |
| 27 | osx_image: xcode10 | 27 | osx_image: xcode10.1 |
| 28 | install: "./.travis/macos/deps.sh" | 28 | install: "./.travis/macos/deps.sh" |
| 29 | script: "./.travis/macos/build.sh" | 29 | script: "./.travis/macos/build.sh" |
| 30 | after_success: "./.travis/macos/upload.sh" | 30 | after_success: "./.travis/macos/upload.sh" |
diff --git a/.travis/macos/build.sh b/.travis/macos/build.sh index 4a14837fc..b7b4c6f8c 100755 --- a/.travis/macos/build.sh +++ b/.travis/macos/build.sh | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | set -o pipefail | 3 | set -o pipefail |
| 4 | 4 | ||
| 5 | export MACOSX_DEPLOYMENT_TARGET=10.13 | 5 | export MACOSX_DEPLOYMENT_TARGET=10.14 |
| 6 | export Qt5_DIR=$(brew --prefix)/opt/qt5 | 6 | export Qt5_DIR=$(brew --prefix)/opt/qt5 |
| 7 | export UNICORNDIR=$(pwd)/externals/unicorn | 7 | export UNICORNDIR=$(pwd)/externals/unicorn |
| 8 | export PATH="/usr/local/opt/ccache/libexec:$PATH" | 8 | export PATH="/usr/local/opt/ccache/libexec:$PATH" |
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 21e07925d..7433c39ba 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h | |||
| @@ -111,12 +111,6 @@ | |||
| 111 | template <std::size_t Position, std::size_t Bits, typename T> | 111 | template <std::size_t Position, std::size_t Bits, typename T> |
| 112 | struct BitField { | 112 | struct BitField { |
| 113 | private: | 113 | private: |
| 114 | // We hide the copy assigment operator here, because the default copy | ||
| 115 | // assignment would copy the full storage value, rather than just the bits | ||
| 116 | // relevant to this particular bit field. | ||
| 117 | // We don't delete it because we want BitField to be trivially copyable. | ||
| 118 | constexpr BitField& operator=(const BitField&) = default; | ||
| 119 | |||
| 120 | // UnderlyingType is T for non-enum types and the underlying type of T if | 114 | // UnderlyingType is T for non-enum types and the underlying type of T if |
| 121 | // T is an enumeration. Note that T is wrapped within an enable_if in the | 115 | // T is an enumeration. Note that T is wrapped within an enable_if in the |
| 122 | // former case to workaround compile errors which arise when using | 116 | // former case to workaround compile errors which arise when using |
| @@ -163,9 +157,13 @@ public: | |||
| 163 | BitField(T val) = delete; | 157 | BitField(T val) = delete; |
| 164 | BitField& operator=(T val) = delete; | 158 | BitField& operator=(T val) = delete; |
| 165 | 159 | ||
| 166 | // Force default constructor to be created | 160 | constexpr BitField() noexcept = default; |
| 167 | // so that we can use this within unions | 161 | |
| 168 | constexpr BitField() = default; | 162 | constexpr BitField(const BitField&) noexcept = default; |
| 163 | constexpr BitField& operator=(const BitField&) noexcept = default; | ||
| 164 | |||
| 165 | constexpr BitField(BitField&&) noexcept = default; | ||
| 166 | constexpr BitField& operator=(BitField&&) noexcept = default; | ||
| 169 | 167 | ||
| 170 | constexpr FORCE_INLINE operator T() const { | 168 | constexpr FORCE_INLINE operator T() const { |
| 171 | return Value(); | 169 | return Value(); |
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 90f276ee8..079283830 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h | |||
| @@ -350,7 +350,7 @@ public: | |||
| 350 | template <class T> | 350 | template <class T> |
| 351 | std::shared_ptr<T> PopIpcInterface() { | 351 | std::shared_ptr<T> PopIpcInterface() { |
| 352 | ASSERT(context->Session()->IsDomain()); | 352 | ASSERT(context->Session()->IsDomain()); |
| 353 | ASSERT(context->GetDomainMessageHeader()->input_object_count > 0); | 353 | ASSERT(context->GetDomainMessageHeader().input_object_count > 0); |
| 354 | return context->GetDomainRequestHandler<T>(Pop<u32>() - 1); | 354 | return context->GetDomainRequestHandler<T>(Pop<u32>() - 1); |
| 355 | } | 355 | } |
| 356 | }; | 356 | }; |
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index cbffff017..fe710eb6e 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -86,7 +86,7 @@ HLERequestContext::~HLERequestContext() = default; | |||
| 86 | void HLERequestContext::ParseCommandBuffer(const HandleTable& handle_table, u32_le* src_cmdbuf, | 86 | void HLERequestContext::ParseCommandBuffer(const HandleTable& handle_table, u32_le* src_cmdbuf, |
| 87 | bool incoming) { | 87 | bool incoming) { |
| 88 | IPC::RequestParser rp(src_cmdbuf); | 88 | IPC::RequestParser rp(src_cmdbuf); |
| 89 | command_header = std::make_shared<IPC::CommandHeader>(rp.PopRaw<IPC::CommandHeader>()); | 89 | command_header = rp.PopRaw<IPC::CommandHeader>(); |
| 90 | 90 | ||
| 91 | if (command_header->type == IPC::CommandType::Close) { | 91 | if (command_header->type == IPC::CommandType::Close) { |
| 92 | // Close does not populate the rest of the IPC header | 92 | // Close does not populate the rest of the IPC header |
| @@ -95,8 +95,7 @@ void HLERequestContext::ParseCommandBuffer(const HandleTable& handle_table, u32_ | |||
| 95 | 95 | ||
| 96 | // If handle descriptor is present, add size of it | 96 | // If handle descriptor is present, add size of it |
| 97 | if (command_header->enable_handle_descriptor) { | 97 | if (command_header->enable_handle_descriptor) { |
| 98 | handle_descriptor_header = | 98 | handle_descriptor_header = rp.PopRaw<IPC::HandleDescriptorHeader>(); |
| 99 | std::make_shared<IPC::HandleDescriptorHeader>(rp.PopRaw<IPC::HandleDescriptorHeader>()); | ||
| 100 | if (handle_descriptor_header->send_current_pid) { | 99 | if (handle_descriptor_header->send_current_pid) { |
| 101 | rp.Skip(2, false); | 100 | rp.Skip(2, false); |
| 102 | } | 101 | } |
| @@ -140,16 +139,15 @@ void HLERequestContext::ParseCommandBuffer(const HandleTable& handle_table, u32_ | |||
| 140 | // If this is an incoming message, only CommandType "Request" has a domain header | 139 | // If this is an incoming message, only CommandType "Request" has a domain header |
| 141 | // All outgoing domain messages have the domain header, if only incoming has it | 140 | // All outgoing domain messages have the domain header, if only incoming has it |
| 142 | if (incoming || domain_message_header) { | 141 | if (incoming || domain_message_header) { |
| 143 | domain_message_header = | 142 | domain_message_header = rp.PopRaw<IPC::DomainMessageHeader>(); |
| 144 | std::make_shared<IPC::DomainMessageHeader>(rp.PopRaw<IPC::DomainMessageHeader>()); | ||
| 145 | } else { | 143 | } else { |
| 146 | if (Session()->IsDomain()) | 144 | if (Session()->IsDomain()) { |
| 147 | LOG_WARNING(IPC, "Domain request has no DomainMessageHeader!"); | 145 | LOG_WARNING(IPC, "Domain request has no DomainMessageHeader!"); |
| 146 | } | ||
| 148 | } | 147 | } |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | data_payload_header = | 150 | data_payload_header = rp.PopRaw<IPC::DataPayloadHeader>(); |
| 152 | std::make_shared<IPC::DataPayloadHeader>(rp.PopRaw<IPC::DataPayloadHeader>()); | ||
| 153 | 151 | ||
| 154 | data_payload_offset = rp.GetCurrentOffset(); | 152 | data_payload_offset = rp.GetCurrentOffset(); |
| 155 | 153 | ||
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 0107acea4..2bdd9f02c 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <optional> | ||
| 9 | #include <string> | 10 | #include <string> |
| 10 | #include <type_traits> | 11 | #include <type_traits> |
| 11 | #include <vector> | 12 | #include <vector> |
| @@ -168,12 +169,12 @@ public: | |||
| 168 | return buffer_c_desciptors; | 169 | return buffer_c_desciptors; |
| 169 | } | 170 | } |
| 170 | 171 | ||
| 171 | const IPC::DomainMessageHeader* GetDomainMessageHeader() const { | 172 | const IPC::DomainMessageHeader& GetDomainMessageHeader() const { |
| 172 | return domain_message_header.get(); | 173 | return domain_message_header.value(); |
| 173 | } | 174 | } |
| 174 | 175 | ||
| 175 | bool HasDomainMessageHeader() const { | 176 | bool HasDomainMessageHeader() const { |
| 176 | return domain_message_header != nullptr; | 177 | return domain_message_header.has_value(); |
| 177 | } | 178 | } |
| 178 | 179 | ||
| 179 | /// Helper function to read a buffer using the appropriate buffer descriptor | 180 | /// Helper function to read a buffer using the appropriate buffer descriptor |
| @@ -272,10 +273,10 @@ private: | |||
| 272 | boost::container::small_vector<SharedPtr<Object>, 8> copy_objects; | 273 | boost::container::small_vector<SharedPtr<Object>, 8> copy_objects; |
| 273 | boost::container::small_vector<std::shared_ptr<SessionRequestHandler>, 8> domain_objects; | 274 | boost::container::small_vector<std::shared_ptr<SessionRequestHandler>, 8> domain_objects; |
| 274 | 275 | ||
| 275 | std::shared_ptr<IPC::CommandHeader> command_header; | 276 | std::optional<IPC::CommandHeader> command_header; |
| 276 | std::shared_ptr<IPC::HandleDescriptorHeader> handle_descriptor_header; | 277 | std::optional<IPC::HandleDescriptorHeader> handle_descriptor_header; |
| 277 | std::shared_ptr<IPC::DataPayloadHeader> data_payload_header; | 278 | std::optional<IPC::DataPayloadHeader> data_payload_header; |
| 278 | std::shared_ptr<IPC::DomainMessageHeader> domain_message_header; | 279 | std::optional<IPC::DomainMessageHeader> domain_message_header; |
| 279 | std::vector<IPC::BufferDescriptorX> buffer_x_desciptors; | 280 | std::vector<IPC::BufferDescriptorX> buffer_x_desciptors; |
| 280 | std::vector<IPC::BufferDescriptorABW> buffer_a_desciptors; | 281 | std::vector<IPC::BufferDescriptorABW> buffer_a_desciptors; |
| 281 | std::vector<IPC::BufferDescriptorABW> buffer_b_desciptors; | 282 | std::vector<IPC::BufferDescriptorABW> buffer_b_desciptors; |
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 3452a9c0c..4d8a337a7 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp | |||
| @@ -92,41 +92,42 @@ std::size_t ServerSession::NumDomainRequestHandlers() const { | |||
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& context) { | 94 | ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& context) { |
| 95 | auto* const domain_message_header = context.GetDomainMessageHeader(); | 95 | if (!context.HasDomainMessageHeader()) { |
| 96 | if (domain_message_header) { | 96 | return RESULT_SUCCESS; |
| 97 | // Set domain handlers in HLE context, used for domain objects (IPC interfaces) as inputs | 97 | } |
| 98 | context.SetDomainRequestHandlers(domain_request_handlers); | 98 | |
| 99 | 99 | // Set domain handlers in HLE context, used for domain objects (IPC interfaces) as inputs | |
| 100 | // If there is a DomainMessageHeader, then this is CommandType "Request" | 100 | context.SetDomainRequestHandlers(domain_request_handlers); |
| 101 | const u32 object_id{context.GetDomainMessageHeader()->object_id}; | 101 | |
| 102 | switch (domain_message_header->command) { | 102 | // If there is a DomainMessageHeader, then this is CommandType "Request" |
| 103 | case IPC::DomainMessageHeader::CommandType::SendMessage: | 103 | const auto& domain_message_header = context.GetDomainMessageHeader(); |
| 104 | if (object_id > domain_request_handlers.size()) { | 104 | const u32 object_id{domain_message_header.object_id}; |
| 105 | LOG_CRITICAL(IPC, | 105 | switch (domain_message_header.command) { |
| 106 | "object_id {} is too big! This probably means a recent service call " | 106 | case IPC::DomainMessageHeader::CommandType::SendMessage: |
| 107 | "to {} needed to return a new interface!", | 107 | if (object_id > domain_request_handlers.size()) { |
| 108 | object_id, name); | 108 | LOG_CRITICAL(IPC, |
| 109 | UNREACHABLE(); | 109 | "object_id {} is too big! This probably means a recent service call " |
| 110 | return RESULT_SUCCESS; // Ignore error if asserts are off | 110 | "to {} needed to return a new interface!", |
| 111 | } | 111 | object_id, name); |
| 112 | return domain_request_handlers[object_id - 1]->HandleSyncRequest(context); | 112 | UNREACHABLE(); |
| 113 | 113 | return RESULT_SUCCESS; // Ignore error if asserts are off | |
| 114 | case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: { | ||
| 115 | LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x{:08X}", object_id); | ||
| 116 | |||
| 117 | domain_request_handlers[object_id - 1] = nullptr; | ||
| 118 | |||
| 119 | IPC::ResponseBuilder rb{context, 2}; | ||
| 120 | rb.Push(RESULT_SUCCESS); | ||
| 121 | return RESULT_SUCCESS; | ||
| 122 | } | ||
| 123 | } | 114 | } |
| 115 | return domain_request_handlers[object_id - 1]->HandleSyncRequest(context); | ||
| 124 | 116 | ||
| 125 | LOG_CRITICAL(IPC, "Unknown domain command={}", | 117 | case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: { |
| 126 | static_cast<int>(domain_message_header->command.Value())); | 118 | LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x{:08X}", object_id); |
| 127 | ASSERT(false); | 119 | |
| 120 | domain_request_handlers[object_id - 1] = nullptr; | ||
| 121 | |||
| 122 | IPC::ResponseBuilder rb{context, 2}; | ||
| 123 | rb.Push(RESULT_SUCCESS); | ||
| 124 | return RESULT_SUCCESS; | ||
| 125 | } | ||
| 128 | } | 126 | } |
| 129 | 127 | ||
| 128 | LOG_CRITICAL(IPC, "Unknown domain command={}", | ||
| 129 | static_cast<int>(domain_message_header.command.Value())); | ||
| 130 | ASSERT(false); | ||
| 130 | return RESULT_SUCCESS; | 131 | return RESULT_SUCCESS; |
| 131 | } | 132 | } |
| 132 | 133 | ||