From 59335f6796480f6b98f981cbb672cdb112a8a3f8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 23 Nov 2022 13:14:04 -0500 Subject: hle_ipc: Add helper functions for getting number of buffer elements --- src/core/hle/kernel/hle_ipc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index d68ea5b1e..e252b5f4b 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -313,6 +313,18 @@ public: /// Helper function to get the size of the output buffer [[nodiscard]] std::size_t GetWriteBufferSize(std::size_t buffer_index = 0) const; + /// Helper function to derive the number of elements able to be contained in the read buffer + template + [[nodiscard]] std::size_t GetReadBufferNumElements(std::size_t buffer_index = 0) const { + return GetReadBufferSize(buffer_index) / sizeof(T); + } + + /// Helper function to derive the number of elements able to be contained in the write buffer + template + [[nodiscard]] std::size_t GetWriteBufferNumElements(std::size_t buffer_index = 0) const { + return GetWriteBufferSize(buffer_index) / sizeof(T); + } + /// Helper function to test whether the input buffer at buffer_index can be read [[nodiscard]] bool CanReadBuffer(std::size_t buffer_index = 0) const; -- cgit v1.2.3