mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
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.
This commit is contained in:
parent
e0552e0642
commit
bcdc5b5f7e
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user