diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-05-31 08:36:05 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-05-31 08:51:46 -0400 |
| commit | bcdc5b5f7e94ebee49ccc8de77cc54cb9d64b372 (patch) | |
| tree | 9677ce50ab1dbe7aabcd3a52669708dadf13b0e7 /Source/Core | |
| parent | e0552e0642fa8b2efd05de402f65263ff61eba4a (diff) | |
IOS/USB_KBD: Add static assertion to enforce MessageData as trivially copyable
MessageData must be a trivially copyable type, given it's copied into
emulated memory via our memory copy function CopyToEmu. Under the
covers, this function utilizes memcpy. One of memcpy's requirements is
that pointers to it point to types that are trivially copyable,
otherwise the behavior is undefined.
Given that, we can enforce this requirement at compile-time.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/IOS/USB/USB_KBD.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Source/Core/Core/IOS/USB/USB_KBD.h b/Source/Core/Core/IOS/USB/USB_KBD.h index bd53e0ae0e..d0039d4ba7 100644 --- a/Source/Core/Core/IOS/USB/USB_KBD.h +++ b/Source/Core/Core/IOS/USB/USB_KBD.h @@ -7,6 +7,7 @@ #include <array> #include <queue> #include <string> +#include <type_traits> #include "Common/CommonTypes.h" #include "Core/IOS/Device.h" @@ -45,6 +46,8 @@ private: MessageData(u32 msg_type, u8 modifiers, PressedKeyData pressed_keys); }; + static_assert(std::is_trivially_copyable_v<MessageData>, + "MessageData must be trivially copyable, as it's copied into emulated memory."); #pragma pack(pop) std::queue<MessageData> m_MessageQueue; |
