vm::gvar: add array support

This commit is contained in:
Nekotekina 2019-09-15 00:15:28 +03:00
commit 584174d371
3 changed files with 9 additions and 6 deletions

View file

@ -2,6 +2,7 @@
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/Cell/PPUModule.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/Cell/lv2/sys_lwmutex.h"
#include "Emu/Cell/lv2/sys_prx.h" #include "Emu/Cell/lv2/sys_prx.h"
#include "sysPrxForUser.h" #include "sysPrxForUser.h"

View file

@ -56,7 +56,7 @@ struct ppu_static_function
struct ppu_static_variable struct ppu_static_variable
{ {
const char* name; const char* name;
vm::gvar<void>* var; // Pointer to variable address storage vm::gvar<char>* var; // Pointer to variable address storage
void(*init)(); // Variable initialization function void(*init)(); // Variable initialization function
u32 size; u32 size;
u32 align; u32 align;
@ -150,10 +150,10 @@ public:
auto& info = access_static_variable(module, vnid); auto& info = access_static_variable(module, vnid);
info.name = name; info.name = name;
info.var = reinterpret_cast<vm::gvar<void>*>(Var); info.var = reinterpret_cast<vm::gvar<char>*>(Var);
info.init = [] {}; info.init = [] {};
info.size = sizeof(typename gvar::type); info.size = gvar::alloc_size;
info.align = alignof(typename gvar::type); info.align = gvar::alloc_align;
info.type = typeid(*Var).name(); info.type = typeid(*Var).name();
info.flags = 0; info.flags = 0;
info.addr = 0; info.addr = 0;

View file

@ -148,9 +148,11 @@ namespace vm
} }
// Global HLE variable // Global HLE variable
template <typename T> template <typename T, uint Count = 1>
struct gvar : ptr<T> struct gvar final : ptr<T>
{ {
static constexpr u32 alloc_size{sizeof(T) * Count};
static constexpr u32 alloc_align{alignof(T)};
}; };
} // namespace ps3_ } // namespace ps3_
} // namespace vm } // namespace vm