Auto generate SWA.h, add offsetof/sizeof asserts.

This commit is contained in:
Skyth
2024-11-25 16:48:58 +03:00
parent 8f525b571b
commit 49b0dbe4db
5 changed files with 93 additions and 42 deletions
+24 -4
View File
@@ -4,13 +4,33 @@
#include <cpu/guest_stack_var.h>
#include <kernel/function.h>
#define SWA__CONCAT2(x, y) x##y
#define SWA_CONCAT2(x, y) _CONCAT(x, y)
#define SWA_CONCAT2(x, y) x##y
#define SWA_CONCAT(x, y) SWA_CONCAT2(x, y)
#define SWA_INSERT_PADDING(length) \
uint8_t SWA_CONCAT2(pad, __LINE__)[length]
uint8_t SWA_CONCAT(pad, __LINE__)[length]
#define SWA_ASSERT_OFFSETOF(type, field, offset) \
static inline swa_assert_offsetof<BB_OFFSETOF(type, field), offset> SWA_CONCAT(_, __COUNTER__)
#define SWA_ASSERT_SIZEOF(type, size) \
static inline swa_assert_sizeof<sizeof type, size> SWA_CONCAT(_, __COUNTER__)
#define SWA_VIRTUAL_FUNCTION(returnType, virtualIndex, ...) \
GuestToHostFunction<returnType>(*(be<uint32_t>*)(g_memory.Translate(*(be<uint32_t>*)(this) + (4 * virtualIndex))), __VA_ARGS__)
struct swa_null_ctor {};
struct swa_null_ctor
{
};
template<int TActual, int TExpected>
struct swa_assert_offsetof
{
static_assert(TActual == TExpected, "offsetof assertion failed");
};
template<int TActual, int TExpected>
struct swa_assert_sizeof
{
static_assert(TActual == TExpected, "sizeof assertion failed");
};