Fix persistent global mapping

This commit is contained in:
2024-09-23 23:14:47 +08:00
parent 80c072e757
commit 3d9181f654
8 changed files with 226 additions and 44 deletions

View File

@@ -10,31 +10,31 @@
#include <stdio.h>
#include <string.h>
// Fallback to int if type is not annotated
struct undefined {
size_t _0;
undefined(int i) {
*this = i;
}
undefined(uint32_t i) {
*this = i;
}
undefined(void* i) {
reinterpret_cast<void*&>(_0) = i;
}
undefined(uint64_t i) {
*this = i;
}
undefined() = default;
template <typename T> operator T&() {
static_assert(sizeof(T) <= sizeof(_0), "Invalid assignment");
return reinterpret_cast<T&>(_0);
}
template <typename T> T& operator=(const T &other) {
static_assert(sizeof(T) <= sizeof(_0), "Invalid assignment");
return reinterpret_cast<T&>(_0) = other;
}
};
// struct undefined {
// size_t _0;
// undefined(int i) {
// *this = i;
// }
// undefined(uint32_t i) {
// *this = i;
// }
// undefined(void* i) {
// reinterpret_cast<void*&>(_0) = i;
// }
// undefined(uint64_t i) {
// *this = i;
// }
// undefined() = default;
// template <typename T> operator T&() {
// static_assert(sizeof(T) <= sizeof(_0), "Invalid assignment");
// return reinterpret_cast<T&>(_0);
// }
// template <typename T> T& operator=(const T &other) {
// static_assert(sizeof(T) <= sizeof(_0), "Invalid assignment");
// return reinterpret_cast<T&>(_0) = other;
// }
// };
typedef uint8_t undefined;
typedef uint32_t undefined4;
typedef uint16_t undefined2;
struct undefined3 {