Refine new IO port concept

This commit is contained in:
2023-03-14 22:53:32 +01:00
parent 46aedaa067
commit 218b8e0e3b
3 changed files with 27 additions and 33 deletions

View File

@@ -6,17 +6,28 @@ namespace JabyEngine {
template<typename T>
struct NormalValue {
typedef T Value;
typedef T NakedValue;
};
template<typename T>
struct VolatileValue {
typedef volatile T Value;
typedef T NakedValue;
};
#define __declare_new_io_port(name, adr) \
typedef name##_io_base<VolatileValue> name##_v; \
typedef name##_io_base<NormalValue> name##_t; \
static auto& name = *reinterpret_cast<name##_v*>(adr)
#define __declare_io_type(name, type, ...) \
template<template<typename> typename T> \
struct name##_io_base { \
T<type>::Value value; \
\
__VA_ARGS__ \
}
template<typename T>
struct VolatilePOD {
struct __attribute__((deprecated)) VolatilePOD {
volatile T raw;
constexpr T read() const {
@@ -30,7 +41,7 @@ namespace JabyEngine {
// For use with ComplexBitMaps or what else satisfies this API
template<typename T>
struct VolatileBitMapPOD {
struct __attribute__((deprecated)) VolatileBitMapPOD {
typedef typename T::UnderlyingType Raw;
VolatilePOD<Raw> pod;