summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-07-19 22:10:12 +0200
committerLioncash <mathew1800@gmail.com>2018-07-19 23:05:12 +0200
commitff500a7b6838f2eaca25b79ce602c499a71b9c10 (patch)
tree7813699b6de1c54556817cba997c870cb4846b35 /src/core/hle/kernel
parentMerge pull request #714 from lioncash/index (diff)
downloadyuzu-ff500a7b6838f2eaca25b79ce602c499a71b9c10.tar
yuzu-ff500a7b6838f2eaca25b79ce602c499a71b9c10.tar.gz
yuzu-ff500a7b6838f2eaca25b79ce602c499a71b9c10.tar.bz2
yuzu-ff500a7b6838f2eaca25b79ce602c499a71b9c10.tar.lz
yuzu-ff500a7b6838f2eaca25b79ce602c499a71b9c10.tar.xz
yuzu-ff500a7b6838f2eaca25b79ce602c499a71b9c10.tar.zst
yuzu-ff500a7b6838f2eaca25b79ce602c499a71b9c10.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp4
-rw-r--r--src/core/hle/kernel/hle_ipc.h23
2 files changed, 21 insertions, 6 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 911e6fbc1..8f40bdd5a 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -301,10 +301,6 @@ size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size, int buffe
return size;
}
-size_t HLERequestContext::WriteBuffer(const std::vector<u8>& buffer, int buffer_index) const {
- return WriteBuffer(buffer.data(), buffer.size(), buffer_index);
-}
-
size_t HLERequestContext::GetReadBufferSize(int buffer_index) const {
const bool is_buffer_a{BufferDescriptorA().size() && BufferDescriptorA()[buffer_index].Size()};
return is_buffer_a ? BufferDescriptorA()[buffer_index].Size()
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index 88f93ad22..01b805df8 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -5,8 +5,10 @@
#pragma once
#include <array>
+#include <iterator>
#include <memory>
#include <string>
+#include <type_traits>
#include <vector>
#include <boost/container/small_vector.hpp>
#include "common/common_types.h"
@@ -171,8 +173,25 @@ public:
/// Helper function to write a buffer using the appropriate buffer descriptor
size_t WriteBuffer(const void* buffer, size_t size, int buffer_index = 0) const;
- /// Helper function to write a buffer using the appropriate buffer descriptor
- size_t WriteBuffer(const std::vector<u8>& buffer, int buffer_index = 0) const;
+ /* Helper function to write a buffer using the appropriate buffer descriptor
+ *
+ * @tparam ContiguousContainer an arbitrary container that satisfies the
+ * ContiguousContainer concept in the C++ standard library.
+ *
+ * @param container The container to write the data of into a buffer.
+ * @param buffer_index The buffer in particular to write to.
+ */
+ template <typename ContiguousContainer,
+ typename = std::enable_if_t<!std::is_pointer_v<ContiguousContainer>>>
+ size_t WriteBuffer(const ContiguousContainer& container, int buffer_index = 0) const {
+ using ContiguousType = typename ContiguousContainer::value_type;
+
+ static_assert(std::is_trivially_copyable_v<ContiguousType>,
+ "Container to WriteBuffer must contain trivially copyable objects");
+
+ return WriteBuffer(std::data(container), std::size(container) * sizeof(ContiguousType),
+ buffer_index);
+ }
/// Helper function to get the size of the input buffer
size_t GetReadBufferSize(int buffer_index = 0) const;